@bendyline/gezel-service 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/gezeld.js +16929 -6105
- package/dist/handboek-content/conceptual/connected-apps.md +64 -2
- package/dist/handboek-content/conceptual/night-shift.md +22 -2
- package/dist/handboek-content/conceptual/welcome.md +2 -0
- package/dist/handboek-content/technical/where-files-live.md +3 -1
- package/dist/handboek-content/whats-new/1.26226.md +4 -7
- package/dist/handboek-content/whats-new/1.26230.md +100 -0
- package/dist/handboek.js +19 -9
- package/dist/index-store/static-index-worker.js +116 -27
- package/dist/index.d.ts +1165 -253
- package/dist/index.js +16922 -6098
- package/dist/providers/mlx/python/gezel_mlx_server.py +126 -11
- package/dist/ui/assets/{TerminalCodeEditor-BuMcfTS4.js → TerminalCodeEditor-BUHpk3pJ.js} +2 -2
- package/dist/ui/assets/{_.contribution-CZO2XAKt.js → _.contribution-B34uMeM2.js} +1 -1
- package/dist/ui/assets/{chunk-2JJ5RFDZ-Ckbzd10a.js → chunk-2JJ5RFDZ-B2-BFNXu.js} +1 -1
- package/dist/ui/assets/{chunk-BAOV476U-yPHu-ECL.js → chunk-BAOV476U-CEOFYt8X.js} +1 -1
- package/dist/ui/assets/{chunk-GAZKTT4R-BUf32614.js → chunk-GAZKTT4R-BkP6-w3z.js} +1 -1
- package/dist/ui/assets/{chunk-USU6HTKB-B-ElCUQS.js → chunk-USU6HTKB-htGRNErW.js} +1 -1
- package/dist/ui/assets/{cpp.contribution-BJzhk0Zj.js → cpp.contribution-CvG4GFxL.js} +1 -1
- package/dist/ui/assets/{csharp.contribution-BR9K2qKj.js → csharp.contribution-DekWAPj3.js} +1 -1
- package/dist/ui/assets/{css.contribution-CfkVmdah.js → css.contribution-CDuF4Xjo.js} +1 -1
- package/dist/ui/assets/{cssMode-MMeGUmV2.js → cssMode-D848zTHU.js} +1 -1
- package/dist/ui/assets/{csv-RAgECoUg.js → csv-PublMwG8.js} +1 -1
- package/dist/ui/assets/dist-CJRsJTdk.js +222 -0
- package/dist/ui/assets/dist-Cg3Ab49q.js +2 -0
- package/dist/ui/assets/{doc-B7NXSLxH.js → doc-Bq50ED-X.js} +41 -41
- package/dist/ui/assets/{dockerfile.contribution-IZMl57B5.js → dockerfile.contribution-ChT95Kbh.js} +1 -1
- package/dist/ui/assets/{docx-BEJpkI6I.js → docx-BSDeP5Eu.js} +1 -1
- package/dist/ui/assets/{epub-00L2M424.js → epub-D8zTSe9-.js} +1 -1
- package/dist/ui/assets/{go.contribution-BxCBwhZs.js → go.contribution-D_1myt_B.js} +1 -1
- package/dist/ui/assets/{handlebars-CreIkams.js → handlebars-Mxcy9PWv.js} +1 -1
- package/dist/ui/assets/{handlebars.contribution-BGlyL-dm.js → handlebars.contribution-DYF5z0XX.js} +2 -2
- package/dist/ui/assets/{html-BSrz1IKi.js → html-HXzM-WGZ.js} +1 -1
- package/dist/ui/assets/{html-Cgejr9YM.js → html-X72kRvXT.js} +1 -1
- package/dist/ui/assets/{html.contribution-CucOMFQ_.js → html.contribution-C0xFTPDL.js} +2 -2
- package/dist/ui/assets/{htmlMode-DRG7XY5Z.js → htmlMode-BVtBWJQM.js} +1 -1
- package/dist/ui/assets/{index-Bqu-32S3.js → index-DUf4wIj5.js} +207 -200
- package/dist/ui/assets/index-udlcniNf.css +1 -0
- package/dist/ui/assets/{infer-D6e75m-s.js → infer-Be4Xn3O1.js} +1 -1
- package/dist/ui/assets/{ini.contribution-CGX5OdXM.js → ini.contribution-BqUQ8Oa0.js} +1 -1
- package/dist/ui/assets/{java.contribution-CVhfJ_us.js → java.contribution-u4QvI2UZ.js} +1 -1
- package/dist/ui/assets/{javascript-QelFp9t5.js → javascript-BVm8fvMk.js} +1 -1
- package/dist/ui/assets/javascript.contribution-BtlENuoy.js +2 -0
- package/dist/ui/assets/{jsonMode-T4Ss3lDu.js → jsonMode-DcoSB4Jg.js} +1 -1
- package/dist/ui/assets/{kotlin.contribution-DxFbGDYA.js → kotlin.contribution-D1ZfW5lW.js} +1 -1
- package/dist/ui/assets/{less.contribution-g9R8XRZf.js → less.contribution-BBWek5Gc.js} +1 -1
- package/dist/ui/assets/{lua.contribution-YqDsEy8Z.js → lua.contribution-DJEpMduq.js} +1 -1
- package/dist/ui/assets/mapTheme-4TWH25FT-C2uLgUhs.js +1 -0
- package/dist/ui/assets/{markdown.contribution-DboXnPnx.js → markdown.contribution-CsVCTE0K.js} +1 -1
- package/dist/ui/assets/{monaco-BdFw56DI.js → monaco-DcZAEsIZ.js} +3 -3
- package/dist/ui/assets/{monaco-base-DrP3D13F.js → monaco-base-C-UMfHa9.js} +1 -1
- package/dist/ui/assets/{monaco-setup-QyF22y9h.js → monaco-setup-Dy_kv6Gv.js} +1 -1
- package/dist/ui/assets/{monaco.contribution-FA_ESP-W.js → monaco.contribution-BpJqoa65.js} +2 -2
- package/dist/ui/assets/{monaco.contribution-XEpc63ty.js → monaco.contribution-BujOhotZ.js} +2 -2
- package/dist/ui/assets/{monaco.contribution-BkqIxESv.js → monaco.contribution-DW4-UIJp.js} +2 -2
- package/dist/ui/assets/{monaco.contribution-CMzPFHtO.js → monaco.contribution-ypbCAEx4.js} +2 -2
- package/dist/ui/assets/{pdf-66KslaXf.js → pdf-BZeBurJI.js} +1 -1
- package/dist/ui/assets/{php.contribution-rnpik0Kk.js → php.contribution-B6Atm_xI.js} +1 -1
- package/dist/ui/assets/{pptx-DZdEoDP9.js → pptx-BbAcnlML.js} +4 -4
- package/dist/ui/assets/{python-CF7X5t9Q.js → python-CCiWacbd.js} +1 -1
- package/dist/ui/assets/{python.contribution-CyJGCfSq.js → python.contribution-3CThbaoI.js} +2 -2
- package/dist/ui/assets/{ruby.contribution-4ZyPGu2E.js → ruby.contribution-D3g6EADN.js} +1 -1
- package/dist/ui/assets/{rust.contribution-Cl_B3X2G.js → rust.contribution-CSdjIX0R.js} +1 -1
- package/dist/ui/assets/{schemas-Drh23Boe.js → schemas-JY4jmLbC.js} +1 -1
- package/dist/ui/assets/{scss.contribution-BO02gVLZ.js → scss.contribution-mQ_vuYxE.js} +1 -1
- package/dist/ui/assets/{shell.contribution-Dn9Y0uHs.js → shell.contribution-BLQSLx3H.js} +1 -1
- package/dist/ui/assets/{sql.contribution-Bog_5Rc8.js → sql.contribution-GScL7Mrt.js} +1 -1
- package/dist/ui/assets/{swift.contribution-CfiAr7AX.js → swift.contribution-DG__yqNr.js} +1 -1
- package/dist/ui/assets/{terminal-monaco-setup-B-EnkGiy.js → terminal-monaco-setup-x6piH1Un.js} +1 -1
- package/dist/ui/assets/{transform-MBfVXq54.js → transform-ywncQECB.js} +1 -1
- package/dist/ui/assets/{tsMode-B2WuLuPL.js → tsMode-B5nM5MR7.js} +1 -1
- package/dist/ui/assets/{typescript-Bv_J1tKT.js → typescript-xiOVha1M.js} +1 -1
- package/dist/ui/assets/{typescript.contribution-CM0XQCYi.js → typescript.contribution-BU2V4Vz8.js} +2 -2
- package/dist/ui/assets/worker-BzdDEeh7.js +1 -0
- package/dist/ui/assets/{xlsx-DDBRN-IU.js → xlsx-f9AYHB2W.js} +1 -1
- package/dist/ui/assets/{xml-DMV-f4tm.js → xml-m3MSnvuD.js} +1 -1
- package/dist/ui/assets/{xml.contribution-QqmOB9gT.js → xml.contribution-bOoaS55N.js} +2 -2
- package/dist/ui/assets/{yaml-Bb6mZXY5.js → yaml-DOtMVgbb.js} +1 -1
- package/dist/ui/assets/{yaml.contribution-DCDnWhHR.js → yaml.contribution-CNCYEtwk.js} +2 -2
- package/dist/ui/index.html +14 -14
- package/package.json +13 -12
- package/dist/ui/assets/dist-8uH4DcHx.js +0 -2
- package/dist/ui/assets/dist-CFOmf7nD.js +0 -222
- package/dist/ui/assets/index-DTicLc4o.css +0 -1
- package/dist/ui/assets/javascript.contribution--no0ijCu.js +0 -2
- package/dist/ui/assets/mapTheme-4TWH25FT-B5nAKRmb.js +0 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p as i,s as a,t as o}from"./chunk-O7JILDEF-CqcO1qaI.js";import{a as s,c,d as l,f as u,i as d,l as f,n as p,o as m,s as h,u as g}from"./chunk-BAOV476U-yPHu-ECL.js";import{o as _}from"./chunk-4VOD55SX-BFSSw0c8.js";import{A as v,C as y,D as b,E as x,M as S,O as C,_ as w,c as T,j as E,k as D,l as O,o as k,r as A,t as ee,v as te,y as ne}from"./chunk-GAZKTT4R-BUf32614.js";import{A as re,C as ie,D as ae,E as oe,F as se,I as ce,L as le,N as j,R as ue,S as de,T as fe,j as pe,k as me,n as he,w as ge}from"./chunk-6MVWWZHL-BtFOxGE8.js";import{i as _e,n as ve,r as ye,t as be}from"./chunk-XRW6P7IF-BeQQgMVK.js";var xe=new Set([`triangle`,`right-triangle`,`diamond`,`pentagon`,`hexagon`,`octagon`,`star`,`star4`,`star6`,`parallelogram`,`trapezoid`,`plus`,`chevron`,`arrow-right`,`arrow-left`,`arrow-up`,`arrow-down`,`double-arrow`,`callout`,`cylinder`,`cloud`,`heart`,`lightning`]);function M(e){return Math.round(e*10)/10}function N(e){if(e.length===0)return``;let[t,...n]=e;return`${`M ${M(t[0])} ${M(t[1])}`} ${n.map(([e,t])=>`L ${M(e)} ${M(t)}`).join(` `)} Z`}function Se(e,t,n,r,i,a){let o=[];for(let s=0;s<i;s++){let c=a+s*2*Math.PI/i;o.push([e+n*Math.cos(c),t+r*Math.sin(c)])}return o}function Ce(e,t,n,r,i,a){let o=[],s=-Math.PI/2;for(let c=0;c<i*2;c++){let l=c%2==0,u=s+c*Math.PI/i,d=l?n:n*a,f=l?r:r*a;o.push([e+d*Math.cos(u),t+f*Math.sin(u)])}return o}function we(e,t,n,r,i){let a=t+r/2,o=n+i/2,s=r/2,c=i/2,l=t+r,u=n+i;switch(e){case`triangle`:return N([[a,n],[l,u],[t,u]]);case`right-triangle`:return N([[t,n],[t,u],[l,u]]);case`diamond`:return N([[a,n],[l,o],[a,u],[t,o]]);case`pentagon`:return N(Se(a,o,s,c,5,-Math.PI/2));case`hexagon`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,o],[l-e,u],[t+e,u],[t,o]])}case`octagon`:{let e=Math.min(r,i)*.29;return N([[t+e,n],[l-e,n],[l,n+e],[l,u-e],[l-e,u],[t+e,u],[t,u-e],[t,n+e]])}case`star`:return N(Ce(a,o,s,c,5,.4));case`star4`:return N(Ce(a,o,s,c,4,.4));case`star6`:return N(Ce(a,o,s,c,6,.5));case`parallelogram`:{let e=r*.25;return N([[t+e,n],[l,n],[l-e,u],[t,u]])}case`trapezoid`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,u],[t,u]])}case`plus`:{let e=Math.min(r,i)/3,a=t+(r-e)/2,o=a+e,s=n+(i-e)/2,c=s+e;return N([[a,n],[o,n],[o,s],[l,s],[l,c],[o,c],[o,u],[a,u],[a,c],[t,c],[t,s],[a,s]])}case`chevron`:{let e=r*.25;return N([[t,n],[l-e,n],[l,o],[l-e,u],[t,u],[t+e,o]])}case`arrow-right`:return Te(t,n,r,i,`right`);case`arrow-left`:return Te(t,n,r,i,`left`);case`arrow-up`:return Te(t,n,r,i,`up`);case`arrow-down`:return Te(t,n,r,i,`down`);case`double-arrow`:{let e=r*.3,a=i*.4,s=o-a/2,c=o+a/2;return N([[t,o],[t+e,n],[t+e,s],[l-e,s],[l-e,n],[l,o],[l-e,u],[l-e,c],[t+e,c],[t+e,u]])}case`callout`:{let e=n+i*.78,a=t+r*.25;return`M ${M(t)} ${M(n)} L ${M(l)} ${M(n)} L ${M(l)} ${M(e)} L ${M(a+r*.12)} ${M(e)} L ${M(a)} ${M(u)} L ${M(a-r*.02)} ${M(e)} L ${M(t)} ${M(e)} Z`}case`cylinder`:{let e=i*.16;return`M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 1 ${M(l)} ${M(n+e)} L ${M(l)} ${M(u-e)} A ${M(s)} ${M(e)} 0 0 1 ${M(t)} ${M(u-e)} Z M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 0 ${M(l)} ${M(n+e)}`}case`cloud`:{let e=i*.5;return`M ${M(t+r*.2)} ${M(u)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.15)} ${M(o)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.45)} ${M(n+i*.2)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.8)} ${M(n+i*.25)} A ${M(r*.18)} ${M(e)} 0 0 1 ${M(t+r*.85)} ${M(u)} Z`}case`heart`:{let e=n+i*.3;return`M ${M(a)} ${M(u)} C ${M(t-r*.1)} ${M(o)} ${M(t)} ${M(n)} ${M(a)} ${M(e)} C ${M(l)} ${M(n)} ${M(l+r*.1)} ${M(o)} ${M(a)} ${M(u)} Z`}case`lightning`:return N([[t+r*.55,n],[t+r*.2,n+i*.55],[t+r*.45,n+i*.55],[t+r*.3,u],[l,n+i*.4],[t+r*.55,n+i*.4]]);default:return null}}function Te(e,t,n,r,i){let a=e+n,o=t+r,s=e+n/2,c=t+r/2;if(i===`right`||i===`left`){let s=n*.4,l=r*.5,u=c-l/2,d=c+l/2;return N(i===`right`?[[e,u],[a-s,u],[a-s,t],[a,c],[a-s,o],[a-s,d],[e,d]]:[[a,u],[e+s,u],[e+s,t],[e,c],[e+s,o],[e+s,d],[a,d]])}let l=r*.4,u=n*.5,d=s-u/2,f=s+u/2;return N(i===`down`?[[d,t],[f,t],[f,o-l],[a,o-l],[s,o],[e,o-l],[d,o-l]]:[[d,o],[f,o],[f,t+l],[a,t+l],[s,t],[e,t+l],[d,t+l]])}function Ee(e,t){let n=t===`start`,r=e=>n?10-e:e,i=e=>`M ${r(0)} 0 L ${r(10)} 5 L ${r(0)} 10${e?` z`:``}`;switch(e){case`arrow`:return{d:i(!0),filled:!0};case`open`:return{d:i(!1),filled:!1};case`diamond`:return{d:`M 0 5 L 5 0 L 10 5 L 5 10 z`,filled:!0};case`square`:return{d:`M 1 1 L 9 1 L 9 9 L 1 9 z`,filled:!0};case`circle`:return{d:`M 0 5 A 5 5 0 1 0 10 5 A 5 5 0 1 0 0 5 z`,filled:!0};default:return null}}function De(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.abs(n)>0?e.rx/Math.abs(n):1/0,a=Math.abs(r)>0?e.ry/Math.abs(r):1/0,o=Math.min(i,a);return{x:e.cx+n*o,y:e.cy+r*o}}function Oe(e,t){return{start:De(e,t),end:De(t,e)}}function ke(e){let t=e.cx-e.rx,n=e.cx+e.rx,r=e.cy-e.ry,i=e.cy+e.ry;return[{port:`top`,x:e.cx,y:r},{port:`right`,x:n,y:e.cy},{port:`bottom`,x:e.cx,y:i},{port:`left`,x:t,y:e.cy},{port:`top-left`,x:t,y:r},{port:`top-right`,x:n,y:r},{port:`bottom-right`,x:n,y:i},{port:`bottom-left`,x:t,y:i}]}function Ae(e,t){let n=Math.max(0,Math.min(1,t.offset)),r=e.cx-e.rx,i=e.cx+e.rx,a=e.cy-e.ry,o=e.cy+e.ry;switch(t.side){case`top`:return{port:`top`,x:r+(i-r)*n,y:a};case`right`:return{port:`right`,x:i,y:a+(o-a)*n};case`bottom`:return{port:`bottom`,x:r+(i-r)*n,y:o};case`left`:return{port:`left`,x:r,y:a+(o-a)*n}}}function je(e,t){let n=ke(e)[0],r=1/0;for(let i of ke(e)){let e=Ne(i,t)+Pe(i.port);e<r&&(n=i,r=e)}return n}function Me(e,t){let n=ke(e)[0],r=ke(t)[0],i=1/0;for(let a of ke(e))for(let e of ke(t)){let t=Ne(a,e)+Pe(a.port)+Pe(e.port);t<i&&(n=a,r=e,i=t)}return{start:n,end:r}}function Ne(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Pe(e){return e.includes(`-`)?.02:0}function Fe(e,t,n){if(e===`straight`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`orthogonal`){let e=Ie(t.port),r=Ie(n.port);if(e===`vertical`&&r===`vertical`){let e=(t.y+n.y)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(e)} L ${M(n.x)} ${M(e)} L ${M(n.x)} ${M(n.y)}`}if(e===`vertical`&&r===`horizontal`)return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`horizontal`&&r===`vertical`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;let i=(t.x+n.x)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(i)} ${M(t.y)} L ${M(i)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`}let r=Math.hypot(n.x-t.x,n.y-t.y),i=Math.max(40,r/2),a=Le(t.port,{x:1,y:0}),o=Le(n.port,{x:-1,y:0});return`M ${M(t.x)} ${M(t.y)} C ${M(t.x+a.x*i)} ${M(t.y+a.y*i)}, ${M(n.x+o.x*i)} ${M(n.y+o.y*i)}, ${M(n.x)} ${M(n.y)}`}function Ie(e){return e===`top`||e===`bottom`?`vertical`:e===`left`||e===`right`?`horizontal`:null}function Le(e,t){switch(e){case`top`:return{x:0,y:-1};case`right`:return{x:1,y:0};case`bottom`:return{x:0,y:1};case`left`:return{x:-1,y:0};default:return t}}function Re(e){switch(e?.toLowerCase()){case`dashed`:case`dash`:return`8 6`;case`dotted`:case`dot`:return`2 6`;default:return}}var ze=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Be(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length,a=n+2<e.length,o=i?e[n+1]:0,s=a?e[n+2]:0,c=r<<16|o<<8|s;t+=ze[c>>>18&63],t+=ze[c>>>12&63],t+=i?ze[c>>>6&63]:`=`,t+=a?ze[c&63]:`=`}return t}function Ve(e){let t=e.replace(/[\t\n\r ]/g,``);if(t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))throw TypeError(`Invalid base64 data`);let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(t.length/4*3-n),i=0;for(let e=0;e<t.length;e+=4){let n=ze.indexOf(t[e]),a=ze.indexOf(t[e+1]),o=t[e+2]===`=`?0:ze.indexOf(t[e+2]),s=t[e+3]===`=`?0:ze.indexOf(t[e+3]),c=n<<18|a<<12|o<<6|s;i<r.length&&(r[i++]=c>>>16&255),i<r.length&&(r[i++]=c>>>8&255),i<r.length&&(r[i++]=c&255)}return r}function He(e){return new TextDecoder().decode(Ve(e))}function Ue(e){return Array.from(e)}function We(e){return Ue(e).length}var Ge=new Set([`┌`,`╭`,`┏`,`╔`]),Ke=new Set([`┐`,`╮`,`┓`,`╗`]),qe=new Set([`└`,`╰`,`┗`,`╚`]),Je=new Set([`┘`,`╯`,`┛`,`╝`]),Ye=new Set([`─`,`━`,`═`,`-`]),Xe=new Set([`│`,`┃`,`║`,`|`]),Ze=new Set([`├`,`┤`,`┬`,`┴`,`┼`,`┣`,`┫`,`┳`,`┻`,`╋`,`╠`,`╣`,`╦`,`╩`,`╬`,`╞`,`╡`,`╥`,`╨`,`╫`,`╪`]),Qe=new Set([`├`,`┤`,`┼`,`┣`,`┫`,`╋`,`╠`,`╣`,`╬`,`╞`,`╡`,`╫`,`╪`]),$e=new Set([`┬`,`┴`,`┼`,`┳`,`┻`,`╋`,`╦`,`╩`,`╬`,`╥`,`╨`,`╫`,`╪`]),et=new Set([`▲`,`↑`]),tt=new Set([`▼`,`↓`]),nt=new Set([`◄`,`←`,`◀`]),rt=new Set([`►`,`→`,`▶`]);function it(e){return Ge.has(e)}function at(e){return Ke.has(e)}function ot(e){return qe.has(e)}function st(e){return Je.has(e)}function ct(e){return Ge.has(e)||Ke.has(e)||qe.has(e)||Je.has(e)}function P(e){return Ye.has(e)}function lt(e){return Xe.has(e)}function ut(e){return Ze.has(e)}function dt(e){return e===`+`}function ft(e){return P(e)||$e.has(e)||dt(e)}function pt(e){return lt(e)||Qe.has(e)||dt(e)}function F(e){return et.has(e)?`up`:tt.has(e)?`down`:nt.has(e)?`left`:rt.has(e)?`right`:null}function mt(e){return e===`^`?`up`:e===`v`||e===`V`?`down`:e===`<`?`left`:e===`>`?`right`:null}function ht(e){return P(e)||lt(e)||ut(e)||dt(e)||ct(e)}function gt(e){let t=e.codePointAt(0)??0;return t>=9472&&t<=9599||et.has(e)||tt.has(e)||e===`←`||e===`→`||e===`◄`||e===`►`||e===`◀`||e===`▶`}function _t(e){return e===`+`||e===`-`||e===`|`}var vt={tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`,stemDown:`┬`,stemUp:`┴`,stemLeft:`┤`,stemRight:`├`,cross:`┼`,arrowUp:`▲`,arrowDown:`▼`,arrowLeft:`◄`,arrowRight:`►`,turnDownRight:`┌`,turnDownLeft:`┐`,turnUpRight:`└`,turnUpLeft:`┘`},yt={tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`,stemDown:`+`,stemUp:`+`,stemLeft:`+`,stemRight:`+`,cross:`+`,arrowUp:`^`,arrowDown:`v`,arrowLeft:`<`,arrowRight:`>`,turnDownRight:`+`,turnDownLeft:`+`,turnUpRight:`+`,turnUpLeft:`+`},bt=60,xt=10,St=3,Ct=10,wt=new Set([`┼`,`╋`,`╬`,`╫`,`╪`]);function Tt(e){return Et(e).diagram}function Et(e){let t=[],n=Dt(e,t),r=n.length,i=r>0?n[0].length:0,a=0,o=!1;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];r!==` `&&a++,!o&&Ot(r)&&(o=!0)}o&&t.push(`wide-chars`);let s=kt(n),c=Bt(n,At(n),t),l=new Uint8Array(i*r),u=new Map;for(let e=0;e<c.length;e++){let t=c[e];for(let n=t.c0;n<=t.c1;n++)for(let r of[t.r0,t.r1]){l[r*i+n]=1;let t=u.get(r*i+n)??[];t.push(e),u.set(r*i+n,t)}for(let n=t.r0+1;n<=t.r1-1;n++)for(let r of[t.c0,t.c1]){l[n*i+r]=1;let t=u.get(n*i+r)??[];t.push(e),u.set(n*i+r,t)}}let d=c.map((e,t)=>c.some(e=>e.parentIdx===t));for(let e=0;e<c.length;e++){let t=c[e];if(d[e]){let r=Math.min(...c.filter(t=>t.parentIdx===e).map(e=>e.r0));for(let e=t.r0+1;e<r;e++)for(let r=t.c0+1;r<=t.c1-1;r++){let t=n[e][r];t!==` `&&!ht(t)&&F(t)===null&&(l[e*i+r]=1)}}else for(let e=t.r0+1;e<=t.r1-1;e++)for(let n=t.c0+1;n<=t.c1-1;n++)l[e*i+n]=1}let{edges:f,edgeCells:p}=Ut(n,l,u,c,t),m=0,h=[];for(let e=0;e<r;e++){let t=``,r=()=>{t.trim().length>0&&h.push(`@${e}: ${Yt(t.trim(),30)}`),t=``},a=t=>{if(t<0||t>=i)return!1;let r=e*i+t;return n[e][t]!==` `&&!l[r]&&!p.has(r)};for(let o=0;o<i;o++)a(o)?(t+=n[e][o],m++):t!==``&&n[e][o]===` `&&a(o+1)?t+=` `:r();r()}for(let e of h.slice(0,xt))t.push(`loose-text ${e}`);return h.length>xt&&t.push(`loose-text (+${h.length-xt} more)`),{diagram:{nodes:c.map(e=>({id:e.id,label:e.labelLines.join(`
|
|
2
|
-
`),col:e.c0,row:e.r0,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1,...e.parentIdx>=0?{containerId:c[e.parentIdx].id}:{}})),edges:f,style:s,warnings:t},stats:{totalNonSpaceCells:a,looseNonSpaceCells:m,hasWideChars:o}}}function
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p as i,s as a,t as o}from"./chunk-O7JILDEF-CqcO1qaI.js";import{a as s,c,d as l,f as u,l as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./chunk-BAOV476U-CEOFYt8X.js";import{o as v}from"./chunk-4VOD55SX-BFSSw0c8.js";import{A as y,C as b,D as x,E as S,M as C,O as w,_ as T,c as E,j as D,k as O,l as k,o as A,r as ee,t as te,v as ne,w as re,y as ie}from"./chunk-GAZKTT4R-BkP6-w3z.js";import{A as ae,C as oe,D as se,E as ce,F as le,I as ue,L as de,N as j,R as fe,S as pe,T as me,j as he,k as ge,n as _e,w as ve}from"./chunk-6MVWWZHL-BtFOxGE8.js";import{i as ye,n as be,r as xe,t as Se}from"./chunk-XRW6P7IF-BeQQgMVK.js";var Ce=new Set([`triangle`,`right-triangle`,`diamond`,`pentagon`,`hexagon`,`octagon`,`star`,`star4`,`star6`,`parallelogram`,`trapezoid`,`plus`,`chevron`,`arrow-right`,`arrow-left`,`arrow-up`,`arrow-down`,`double-arrow`,`callout`,`cylinder`,`cloud`,`heart`,`lightning`]);function M(e){return Math.round(e*10)/10}function N(e){if(e.length===0)return``;let[t,...n]=e;return`${`M ${M(t[0])} ${M(t[1])}`} ${n.map(([e,t])=>`L ${M(e)} ${M(t)}`).join(` `)} Z`}function we(e,t,n,r,i,a){let o=[];for(let s=0;s<i;s++){let c=a+s*2*Math.PI/i;o.push([e+n*Math.cos(c),t+r*Math.sin(c)])}return o}function Te(e,t,n,r,i,a){let o=[],s=-Math.PI/2;for(let c=0;c<i*2;c++){let l=c%2==0,u=s+c*Math.PI/i,d=l?n:n*a,f=l?r:r*a;o.push([e+d*Math.cos(u),t+f*Math.sin(u)])}return o}function Ee(e,t,n,r,i){let a=t+r/2,o=n+i/2,s=r/2,c=i/2,l=t+r,u=n+i;switch(e){case`triangle`:return N([[a,n],[l,u],[t,u]]);case`right-triangle`:return N([[t,n],[t,u],[l,u]]);case`diamond`:return N([[a,n],[l,o],[a,u],[t,o]]);case`pentagon`:return N(we(a,o,s,c,5,-Math.PI/2));case`hexagon`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,o],[l-e,u],[t+e,u],[t,o]])}case`octagon`:{let e=Math.min(r,i)*.29;return N([[t+e,n],[l-e,n],[l,n+e],[l,u-e],[l-e,u],[t+e,u],[t,u-e],[t,n+e]])}case`star`:return N(Te(a,o,s,c,5,.4));case`star4`:return N(Te(a,o,s,c,4,.4));case`star6`:return N(Te(a,o,s,c,6,.5));case`parallelogram`:{let e=r*.25;return N([[t+e,n],[l,n],[l-e,u],[t,u]])}case`trapezoid`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,u],[t,u]])}case`plus`:{let e=Math.min(r,i)/3,a=t+(r-e)/2,o=a+e,s=n+(i-e)/2,c=s+e;return N([[a,n],[o,n],[o,s],[l,s],[l,c],[o,c],[o,u],[a,u],[a,c],[t,c],[t,s],[a,s]])}case`chevron`:{let e=r*.25;return N([[t,n],[l-e,n],[l,o],[l-e,u],[t,u],[t+e,o]])}case`arrow-right`:return De(t,n,r,i,`right`);case`arrow-left`:return De(t,n,r,i,`left`);case`arrow-up`:return De(t,n,r,i,`up`);case`arrow-down`:return De(t,n,r,i,`down`);case`double-arrow`:{let e=r*.3,a=i*.4,s=o-a/2,c=o+a/2;return N([[t,o],[t+e,n],[t+e,s],[l-e,s],[l-e,n],[l,o],[l-e,u],[l-e,c],[t+e,c],[t+e,u]])}case`callout`:{let e=n+i*.78,a=t+r*.25;return`M ${M(t)} ${M(n)} L ${M(l)} ${M(n)} L ${M(l)} ${M(e)} L ${M(a+r*.12)} ${M(e)} L ${M(a)} ${M(u)} L ${M(a-r*.02)} ${M(e)} L ${M(t)} ${M(e)} Z`}case`cylinder`:{let e=i*.16;return`M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 1 ${M(l)} ${M(n+e)} L ${M(l)} ${M(u-e)} A ${M(s)} ${M(e)} 0 0 1 ${M(t)} ${M(u-e)} Z M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 0 ${M(l)} ${M(n+e)}`}case`cloud`:{let e=i*.5;return`M ${M(t+r*.2)} ${M(u)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.15)} ${M(o)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.45)} ${M(n+i*.2)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.8)} ${M(n+i*.25)} A ${M(r*.18)} ${M(e)} 0 0 1 ${M(t+r*.85)} ${M(u)} Z`}case`heart`:{let e=n+i*.3;return`M ${M(a)} ${M(u)} C ${M(t-r*.1)} ${M(o)} ${M(t)} ${M(n)} ${M(a)} ${M(e)} C ${M(l)} ${M(n)} ${M(l+r*.1)} ${M(o)} ${M(a)} ${M(u)} Z`}case`lightning`:return N([[t+r*.55,n],[t+r*.2,n+i*.55],[t+r*.45,n+i*.55],[t+r*.3,u],[l,n+i*.4],[t+r*.55,n+i*.4]]);default:return null}}function De(e,t,n,r,i){let a=e+n,o=t+r,s=e+n/2,c=t+r/2;if(i===`right`||i===`left`){let s=n*.4,l=r*.5,u=c-l/2,d=c+l/2;return N(i===`right`?[[e,u],[a-s,u],[a-s,t],[a,c],[a-s,o],[a-s,d],[e,d]]:[[a,u],[e+s,u],[e+s,t],[e,c],[e+s,o],[e+s,d],[a,d]])}let l=r*.4,u=n*.5,d=s-u/2,f=s+u/2;return N(i===`down`?[[d,t],[f,t],[f,o-l],[a,o-l],[s,o],[e,o-l],[d,o-l]]:[[d,o],[f,o],[f,t+l],[a,t+l],[s,t],[e,t+l],[d,t+l]])}function Oe(e,t){let n=t===`start`,r=e=>n?10-e:e,i=e=>`M ${r(0)} 0 L ${r(10)} 5 L ${r(0)} 10${e?` z`:``}`;switch(e){case`arrow`:return{d:i(!0),filled:!0};case`open`:return{d:i(!1),filled:!1};case`diamond`:return{d:`M 0 5 L 5 0 L 10 5 L 5 10 z`,filled:!0};case`square`:return{d:`M 1 1 L 9 1 L 9 9 L 1 9 z`,filled:!0};case`circle`:return{d:`M 0 5 A 5 5 0 1 0 10 5 A 5 5 0 1 0 0 5 z`,filled:!0};default:return null}}function ke(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.abs(n)>0?e.rx/Math.abs(n):1/0,a=Math.abs(r)>0?e.ry/Math.abs(r):1/0,o=Math.min(i,a);return{x:e.cx+n*o,y:e.cy+r*o}}function Ae(e,t){return{start:ke(e,t),end:ke(t,e)}}function je(e){let t=e.cx-e.rx,n=e.cx+e.rx,r=e.cy-e.ry,i=e.cy+e.ry;return[{port:`top`,x:e.cx,y:r},{port:`right`,x:n,y:e.cy},{port:`bottom`,x:e.cx,y:i},{port:`left`,x:t,y:e.cy},{port:`top-left`,x:t,y:r},{port:`top-right`,x:n,y:r},{port:`bottom-right`,x:n,y:i},{port:`bottom-left`,x:t,y:i}]}function Me(e,t){let n=Math.max(0,Math.min(1,t.offset)),r=e.cx-e.rx,i=e.cx+e.rx,a=e.cy-e.ry,o=e.cy+e.ry;switch(t.side){case`top`:return{port:`top`,x:r+(i-r)*n,y:a};case`right`:return{port:`right`,x:i,y:a+(o-a)*n};case`bottom`:return{port:`bottom`,x:r+(i-r)*n,y:o};case`left`:return{port:`left`,x:r,y:a+(o-a)*n}}}function Ne(e,t){let n=je(e)[0],r=1/0;for(let i of je(e)){let e=Fe(i,t)+Ie(i.port);e<r&&(n=i,r=e)}return n}function Pe(e,t){let n=je(e)[0],r=je(t)[0],i=1/0;for(let a of je(e))for(let e of je(t)){let t=Fe(a,e)+Ie(a.port)+Ie(e.port);t<i&&(n=a,r=e,i=t)}return{start:n,end:r}}function Fe(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Ie(e){return e.includes(`-`)?.02:0}function Le(e,t,n){if(e===`straight`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`orthogonal`){let e=Re(t.port),r=Re(n.port);if(e===`vertical`&&r===`vertical`){let e=(t.y+n.y)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(e)} L ${M(n.x)} ${M(e)} L ${M(n.x)} ${M(n.y)}`}if(e===`vertical`&&r===`horizontal`)return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`horizontal`&&r===`vertical`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;let i=(t.x+n.x)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(i)} ${M(t.y)} L ${M(i)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`}let r=Math.hypot(n.x-t.x,n.y-t.y),i=Math.max(40,r/2),a=ze(t.port,{x:1,y:0}),o=ze(n.port,{x:-1,y:0});return`M ${M(t.x)} ${M(t.y)} C ${M(t.x+a.x*i)} ${M(t.y+a.y*i)}, ${M(n.x+o.x*i)} ${M(n.y+o.y*i)}, ${M(n.x)} ${M(n.y)}`}function Re(e){return e===`top`||e===`bottom`?`vertical`:e===`left`||e===`right`?`horizontal`:null}function ze(e,t){switch(e){case`top`:return{x:0,y:-1};case`right`:return{x:1,y:0};case`bottom`:return{x:0,y:1};case`left`:return{x:-1,y:0};default:return t}}function Be(e){switch(e?.toLowerCase()){case`dashed`:case`dash`:return`8 6`;case`dotted`:case`dot`:return`2 6`;default:return}}var Ve=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function He(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length,a=n+2<e.length,o=i?e[n+1]:0,s=a?e[n+2]:0,c=r<<16|o<<8|s;t+=Ve[c>>>18&63],t+=Ve[c>>>12&63],t+=i?Ve[c>>>6&63]:`=`,t+=a?Ve[c&63]:`=`}return t}function Ue(e){let t=e.replace(/[\t\n\r ]/g,``);if(t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))throw TypeError(`Invalid base64 data`);let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(t.length/4*3-n),i=0;for(let e=0;e<t.length;e+=4){let n=Ve.indexOf(t[e]),a=Ve.indexOf(t[e+1]),o=t[e+2]===`=`?0:Ve.indexOf(t[e+2]),s=t[e+3]===`=`?0:Ve.indexOf(t[e+3]),c=n<<18|a<<12|o<<6|s;i<r.length&&(r[i++]=c>>>16&255),i<r.length&&(r[i++]=c>>>8&255),i<r.length&&(r[i++]=c&255)}return r}function We(e){return new TextDecoder().decode(Ue(e))}function Ge(e){return Array.from(e)}function Ke(e){return Ge(e).length}var qe=new Set([`┌`,`╭`,`┏`,`╔`]),Je=new Set([`┐`,`╮`,`┓`,`╗`]),Ye=new Set([`└`,`╰`,`┗`,`╚`]),Xe=new Set([`┘`,`╯`,`┛`,`╝`]),Ze=new Set([`─`,`━`,`═`,`-`]),Qe=new Set([`│`,`┃`,`║`,`|`]),$e=new Set([`├`,`┤`,`┬`,`┴`,`┼`,`┣`,`┫`,`┳`,`┻`,`╋`,`╠`,`╣`,`╦`,`╩`,`╬`,`╞`,`╡`,`╥`,`╨`,`╫`,`╪`]),et=new Set([`├`,`┤`,`┼`,`┣`,`┫`,`╋`,`╠`,`╣`,`╬`,`╞`,`╡`,`╫`,`╪`]),tt=new Set([`┬`,`┴`,`┼`,`┳`,`┻`,`╋`,`╦`,`╩`,`╬`,`╥`,`╨`,`╫`,`╪`]),nt=new Set([`▲`,`↑`]),rt=new Set([`▼`,`↓`]),it=new Set([`◄`,`←`,`◀`]),at=new Set([`►`,`→`,`▶`]);function ot(e){return qe.has(e)}function st(e){return Je.has(e)}function ct(e){return Ye.has(e)}function lt(e){return Xe.has(e)}function ut(e){return qe.has(e)||Je.has(e)||Ye.has(e)||Xe.has(e)}function P(e){return Ze.has(e)}function dt(e){return Qe.has(e)}function ft(e){return $e.has(e)}function pt(e){return e===`+`}function mt(e){return P(e)||tt.has(e)||pt(e)}function ht(e){return dt(e)||et.has(e)||pt(e)}function F(e){return nt.has(e)?`up`:rt.has(e)?`down`:it.has(e)?`left`:at.has(e)?`right`:null}function gt(e){return e===`^`?`up`:e===`v`||e===`V`?`down`:e===`<`?`left`:e===`>`?`right`:null}function _t(e){return P(e)||dt(e)||ft(e)||pt(e)||ut(e)}function vt(e){let t=e.codePointAt(0)??0;return t>=9472&&t<=9599||nt.has(e)||rt.has(e)||e===`←`||e===`→`||e===`◄`||e===`►`||e===`◀`||e===`▶`}function yt(e){return e===`+`||e===`-`||e===`|`}var bt={tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`,stemDown:`┬`,stemUp:`┴`,stemLeft:`┤`,stemRight:`├`,cross:`┼`,arrowUp:`▲`,arrowDown:`▼`,arrowLeft:`◄`,arrowRight:`►`,turnDownRight:`┌`,turnDownLeft:`┐`,turnUpRight:`└`,turnUpLeft:`┘`},xt={tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`,stemDown:`+`,stemUp:`+`,stemLeft:`+`,stemRight:`+`,cross:`+`,arrowUp:`^`,arrowDown:`v`,arrowLeft:`<`,arrowRight:`>`,turnDownRight:`+`,turnDownLeft:`+`,turnUpRight:`+`,turnUpLeft:`+`},St=60,Ct=10,wt=3,Tt=10,Et=new Set([`┼`,`╋`,`╬`,`╫`,`╪`]);function Dt(e){return Ot(e).diagram}function Ot(e){let t=[],n=kt(e,t),r=n.length,i=r>0?n[0].length:0,a=0,o=!1;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];r!==` `&&a++,!o&&At(r)&&(o=!0)}o&&t.push(`wide-chars`);let s=jt(n),c=Ht(n,Mt(n),t),l=new Uint8Array(i*r),u=new Map;for(let e=0;e<c.length;e++){let t=c[e];for(let n=t.c0;n<=t.c1;n++)for(let r of[t.r0,t.r1]){l[r*i+n]=1;let t=u.get(r*i+n)??[];t.push(e),u.set(r*i+n,t)}for(let n=t.r0+1;n<=t.r1-1;n++)for(let r of[t.c0,t.c1]){l[n*i+r]=1;let t=u.get(n*i+r)??[];t.push(e),u.set(n*i+r,t)}}let d=c.map((e,t)=>c.some(e=>e.parentIdx===t));for(let e=0;e<c.length;e++){let t=c[e];if(d[e]){let r=Math.min(...c.filter(t=>t.parentIdx===e).map(e=>e.r0));for(let e=t.r0+1;e<r;e++)for(let r=t.c0+1;r<=t.c1-1;r++){let t=n[e][r];t!==` `&&!_t(t)&&F(t)===null&&(l[e*i+r]=1)}}else for(let e=t.r0+1;e<=t.r1-1;e++)for(let n=t.c0+1;n<=t.c1-1;n++)l[e*i+n]=1}let{edges:f,edgeCells:p}=Gt(n,l,u,c,t),m=0,h=[];for(let e=0;e<r;e++){let t=``,r=()=>{t.trim().length>0&&h.push(`@${e}: ${Zt(t.trim(),30)}`),t=``},a=t=>{if(t<0||t>=i)return!1;let r=e*i+t;return n[e][t]!==` `&&!l[r]&&!p.has(r)};for(let o=0;o<i;o++)a(o)?(t+=n[e][o],m++):t!==``&&n[e][o]===` `&&a(o+1)?t+=` `:r();r()}for(let e of h.slice(0,Ct))t.push(`loose-text ${e}`);return h.length>Ct&&t.push(`loose-text (+${h.length-Ct} more)`),{diagram:{nodes:c.map(e=>({id:e.id,label:e.labelLines.join(`
|
|
2
|
+
`),col:e.c0,row:e.r0,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1,...e.parentIdx>=0?{containerId:c[e.parentIdx].id}:{}})),edges:f,style:s,warnings:t},stats:{totalNonSpaceCells:a,looseNonSpaceCells:m,hasWideChars:o}}}function kt(e,t){let n=e.replace(/\r\n?/g,`
|
|
3
3
|
`).split(`
|
|
4
|
-
`),r=!1,i=n.map(e=>{let t=[];for(let n of e)if(n===` `){r=!0;do t.push(` `);while(t.length%4!=0)}else t.push(n);return t});r&&t.push(`tabs-expanded`);let a=0;for(let e of i)a=Math.max(a,e.length);for(let e of i)for(;e.length<a;)e.push(` `);return i}function
|
|
4
|
+
`),r=!1,i=n.map(e=>{let t=[];for(let n of e)if(n===` `){r=!0;do t.push(` `);while(t.length%4!=0)}else t.push(n);return t});r&&t.push(`tabs-expanded`);let a=0;for(let e of i)a=Math.max(a,e.length);for(let e of i)for(;e.length<a;)e.push(` `);return i}function At(e){let t=e.codePointAt(0)??0;return t>=4352&&t<=4447||t>=11904&&t<=12350||t>=12353&&t<=13311||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65280&&t<=65376||t>=127744&&t<=129791}function jt(e){let t=0,n=0;for(let r of e)for(let e of r)vt(e)?t++:yt(e)&&n++;return n>t?`ascii`:`unicode`}function Mt(e,t=!1){let n=e.length,r=n>0?e[0].length:0,i=[];for(let a=0;a<n;a++)for(let n=0;n<r;n++){if(!Pt(e,a,n))continue;let r=Ft(e,a,n,t);r&&i.push(r)}return i}function Nt(e){return kt(e,[])}function Pt(e,t,n){let r=e[t][n];if(ot(r))return!0;if(!pt(r)&&!ft(r))return!1;let i=e[t][n+1]??` `,a=e[t+1]?.[n]??` `,o=mt(i)||st(i),s=ht(a)||ct(a);return o&&s}function Ft(e,t,n,r=!1){let i=e.length,a=e[0]?.length??0,o=[];for(let r=n+1;r<a;r++){let n=e[t][r];if(st(n)){if(o.push(r),ht(e[t+1]?.[r]??` `))break;continue}(pt(n)||ft(n))&&o.push(r)}if(o.length===0)return null;let s=Rt(e,n,t,i,ct,r);if(s.length===0)return null;let c=new Set(s);for(let a of o){if(a<n+2)continue;let o=It(e[t],n,a);if(!o.ok)continue;let s=Rt(e,a,t,i,lt,r);for(let i of s){if(i<t+2||!c.has(i))continue;let s=!0;for(let t=n+1;t<=a-1;t++)if(!mt(e[i][t])){s=!1;break}if(!s)continue;let l=+!!r,u=0,d=0;for(let r=t+1;r<=i-1;r++)Lt(e[r],n,l)&&u++,Lt(e[r],a,l)&&d++;if(!(u===0||d===0))return{r0:t,c0:n,r1:i,c1:a,...o.title?{borderTitle:o.title}:{}}}}return null}function It(e,t,n){let r=e=>mt(e)||F(e)!==null,i=t+1,a=n-1;for(;i<=a&&r(e[i]);)i++;for(;a>=i&&r(e[a]);)a--;if(i>a)return{ok:!0};if(a-i+1>St)return{ok:!1};let o=e.slice(i,a+1).join(``).trim();return o.length>0?{ok:!0,title:o}:{ok:!0}}function Lt(e,t,n){for(let r=t-n;r<=t+n;r++){let t=e[r];if(t!==void 0&&ht(t))return!0}return!1}function Rt(e,t,n,r,i,a=!1){let o=[],s=a?Tt:wt,c=0;for(let l=n+1;l<r;l++){let n=e[l][t];if(i(n)){o.push(l);break}if(pt(n)||ft(n)){o.push(l),c=0;continue}if(ht(n)){c=0;continue}if(!a&&(_t(n)||F(n)!==null)||++c>s)break}return o}function zt(e,t){return e.r0<t.r0&&e.c0<t.c0&&e.r1>t.r1&&e.c1>t.c1}function Bt(e,t){return e.r0+1<=t.r1-1&&t.r0+1<=e.r1-1&&e.c0+1<=t.c1-1&&t.c0+1<=e.c1-1}function Vt(e){return(e.r1-e.r0+1)*(e.c1-e.c0+1)}function Ht(e,t,n){let r=[...t].sort((e,t)=>e.r0-t.r0||e.c0-t.c0),i=r.map((e,t)=>{let n=-1,i=1/0;for(let a=0;a<r.length;a++){if(a===t||!zt(r[a],e))continue;let o=Vt(r[a]);o<i&&(i=o,n=a)}return n}),a=!1;for(let e=0;e<r.length&&!a;e++)for(let t=e+1;t<r.length;t++)if(Bt(r[e],r[t])&&!zt(r[e],r[t])&&!zt(r[t],r[e])){n.push(`overlapping-boxes`),a=!0;break}let o=r.map((e,t)=>i.includes(t)),s=new Map;return r.map((t,n)=>{let a=[];if(t.borderTitle&&a.push(t.borderTitle),o[n]){let o=Math.min(...r.filter((e,t)=>i[t]===n).map(e=>e.r0));for(let n=t.r0+1;n<o;n++){let r=e[n].slice(t.c0+1,t.c1).map(e=>_t(e)||F(e)!==null?` `:e).join(``).trim();r.length>0&&a.push(r)}}else for(let n=t.r0+1;n<=t.r1-1;n++){let r=e[n].slice(t.c0+1,t.c1).join(``);if(Ut(r))continue;let i=r.trim();i.length>0&&a.push(i)}let c=Wt(a[0]??``),l=s.get(c)??0;s.set(c,l+1);let u=l===0?c:`${c}-${l+1}`;return{...t,parentIdx:i[n],labelLines:a,id:u}})}function Ut(e){if(e.length===0||e!==e.trim())return!1;let t=!1;for(let n of e)if(n!==` `){if(P(n)||ft(n)||pt(n)){t=!0;continue}return!1}return t}function Wt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Gt(e,t,n,r,i){let a=e.length,o=a>0?e[0].length:0,s=new Map;for(let n=0;n<a;n++)for(let r=0;r<o;r++){let i=n*o+r;if(t[i])continue;let a=e[n][r],c=F(a);if(c){s.set(i,{arrow:c});continue}let l=gt(a);if(l&&Jt(e,n,r,l)){s.set(i,{arrow:l});continue}_t(a)&&s.set(i,{arrow:null})}for(let n=0;n<a;n++){let r=0;for(;r<o;){let i=n*o+r;if(!s.has(i)||!P(e[n][r])){r++;continue}let a=r;for(;a+1<o&&s.has(n*o+a+1)&&P(e[n][a+1]);)a++;let c=a+1,l=!1,u=!1;for(;c<o&&c-a-1<=40;){let r=e[n][c];if(t[n*o+c]){u=!0;break}if(P(r)){if(Kt(e,t,n,c,o))break;for(;c<o&&P(e[n][c]);)c++;l=!0;continue}if(qt(e,n,c)){u=!0;break}r!==` `&&(l=!0),c++}if(!u&&c<o&&c>a+1&&l&&P(e[n][c])&&!t[n*o+c]){let t=e[n].slice(a+1,c).join(``).trim();for(let e=a+1;e<c;e++)s.set(n*o+e,{arrow:null,bridgeLabel:t});r=c}else r=a+1}}let c=t=>Et.has(e[Math.floor(t/o)][t%o]),l=(e,t)=>e*2+t,u=new Set,d=[],f=[];for(let e of s.keys())f.push([e,0]),c(e)&&f.push([e,1]);for(let[e,t]of f){if(u.has(l(e,t)))continue;let n=new Set,r=[[e,t]];for(u.add(l(e,t));r.length>0;){let[e,t]=r.pop();n.add(e);let i=Math.floor(e/o),d=e%o,f=c(e)&&t===1?[[i-1,d],[i+1,d]]:c(e)?[[i,d-1],[i,d+1]]:[[i-1,d],[i+1,d],[i,d-1],[i,d+1]];for(let[e,t]of f){if(e<0||e>=a||t<0||t>=o)continue;let n=e*o+t;if(!s.has(n))continue;let d=c(n)?e===i?0:1:0,f=l(n,d);u.has(f)||(u.add(f),r.push([n,d]))}}d.push([...n].sort((e,t)=>e-t))}d.sort((e,t)=>e[0]-t[0]);let p=[],m=new Set,h=!1,g=new Set,_=new Set;for(let c of d){let l=new Set(c),u=[];for(let e of c){let t=Math.floor(e/o),n=e%o,r=0;for(let[e,i]of[[t-1,n],[t+1,n],[t,n-1],[t,n+1]])l.has(e*o+i)&&r++;let i=s.get(e);(r<=1||i.arrow!==null)&&u.push(e)}let d=new Map,f=!1;for(let e of u){let t=Math.floor(e/o),i=e%o,c=s.get(e),l=Yt(t,i,c.arrow,n,r,o,a);if(l===null){f=!0;continue}let u=d.get(l);u?u.isArrowEnd=u.isArrowEnd||c.arrow!==null:d.set(l,{boxIdx:l,isArrowEnd:c.arrow!==null})}let v=(e,t)=>{let i=n.get(e*o+t)??[];return i.length===0?null:[...i].sort((e,t)=>r[e].r0-r[t].r0||r[e].c0-r[t].c0||e-t)[0]};for(let t of c){let n=Math.floor(t/o),r=t%o,i=e[n][r];if(!(!ft(i)&&!pt(i)))for(let[e,t]of[[-1,0],[1,0],[0,-1],[0,1]]){let i=v(n+e,r+t);i!==null&&!d.has(i)&&d.set(i,{boxIdx:i,isArrowEnd:!1})}}for(let e of c){let t=Math.floor(e/o),n=e%o,r=s.get(e);if(r.arrow===null)continue;let[i,a]=r.arrow===`down`?[-1,0]:r.arrow===`up`?[1,0]:r.arrow===`right`?[0,-1]:[0,1],c=v(t+i,n+a);c!==null&&!d.has(c)&&d.set(c,{boxIdx:c,isArrowEnd:!1})}let y=[...d.values()].sort((e,t)=>r[e.boxIdx].r0-r[t.boxIdx].r0||r[e.boxIdx].c0-r[t.boxIdx].c0);if(y.length===0){for(let e of c)g.add(e);i.push(`dangling-edge`);continue}if(y.length===1){i.push(`dangling-edge`);continue}f&&i.push(`dangling-edge`);let b=[];for(let e of c){let t=s.get(e);t.bridgeLabel&&!b.includes(t.bridgeLabel)&&b.push(t.bridgeLabel)}let x=e=>_t(e)&&e!==`-`||F(e)!==null,S=e=>/[a-z0-9]/i.test(e),C=b[0];if(!C)outer:for(let n of c){let r=Math.floor(n/o),i=n%o;if(dt(e[r][i])){if((e[r][i+1]??``)===` `){let n=i+2,a=``;for(;n<o;){let i=e[r][n];if(t[r*o+n]||x(i)||i===` `&&(e[r][n+1]??` `)===` `)break;a+=i,n++}let s=a.trim().replace(/^-+|-+$/g,``);if(s.length>0&&s.length<=40&&S(s)){C=s;for(let e=i+2;e<n;e++)_.add(r*o+e);break outer}}if((e[r][i-1]??``)===` `){let n=i-2,a=``;for(;n>=0;){let i=e[r][n];if(t[r*o+n]||x(i)||i===` `&&(e[r][n-1]??` `)===` `)break;a=i+a,n--}let s=a.trim().replace(/^-+|-+$/g,``);if(s.length>0&&s.length<=40&&S(s)){C=s;for(let e=n+1;e<=i-2;e++)_.add(r*o+e);break outer}}}}b.length>1&&i.push(`multiple-edge-labels`);let w=(e,t,n)=>{let i={source:r[e].id,target:r[t].id,...C?{label:C}:{},directed:n},a=`${i.source}|${i.target}|${i.directed}|${i.label??``}`;if(m.has(a)){h=!0;return}m.add(a),p.push(i)},T=y.filter(e=>e.isArrowEnd),E=y.filter(e=>!e.isArrowEnd);if(y.length===2){let[e,t]=y;if(T.length===2)w(e.boxIdx,t.boxIdx,!0),w(t.boxIdx,e.boxIdx,!0);else if(T.length===1){let n=T[0];w((e===n?t:e).boxIdx,n.boxIdx,!0)}else w(e.boxIdx,t.boxIdx,!1)}else if(E.length===1&&T.length>=1)for(let e of T)w(E[0].boxIdx,e.boxIdx,!0);else if(T.length===1&&E.length>=1)for(let e of E)w(e.boxIdx,T[0].boxIdx,!0);else if(T.length===0){i.push(`ambiguous-bus`);for(let e=1;e<y.length;e++)w(y[0].boxIdx,y[e].boxIdx,!1)}else{i.push(`ambiguous-bus`);for(let e of T)E.length>0&&w(E[0].boxIdx,e.boxIdx,!0)}}h&&i.push(`parallel-edges-merged`),p.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``));let v=new Set;for(let e of d)for(let t of e)g.has(t)||v.add(t);for(let e of _)v.add(e);return{edges:p,edgeCells:v}}function Kt(e,t,n,r,i){let a=r;for(;a<i&&P(e[n][a])&&!t[n*i+a];)a++;if(a>=i||t[n*i+a])return!0;let o=e[n][a];if(_t(o)||F(o)!==null)return!0;let s=gt(o);return s!==null&&Jt(e,n,a,s)}function qt(e,t,n){let r=e[t][n];if(F(r)!==null)return!0;let i=gt(r);if(i!==null&&Jt(e,t,n,i))return!0;if(!_t(r))return!1;let a=e=>e!==void 0&&(_t(e)||F(e)!==null);return a(e[t-1]?.[n])||a(e[t+1]?.[n])}function Jt(e,t,n,r){let i=r===`down`?e[t-1]?.[n]:r===`up`?e[t+1]?.[n]:r===`right`?e[t]?.[n-1]:e[t]?.[n+1];return i===void 0?!1:r===`down`||r===`up`?dt(i):P(i)}function Yt(e,t,n,r,i,a,o){let s=(e,t)=>e<0||e>=o||t<0||t>=a?[]:r.get(e*a+t)??[];if(n){let[r,a]=n===`down`?[1,0]:n===`up`?[-1,0]:n===`right`?[0,1]:[0,-1];for(let o of[1,2]){let c=s(e+r*o,t+a*o);if(c.length>0)return[...c].sort((s,c)=>{let l=Xt(i[s],e+r*o,t+a*o,n);return Xt(i[c],e+r*o,t+a*o,n)-l||s-c})[0]}}let c=new Map;for(let[n,r,i]of[[-1,0,0],[1,0,0],[0,-1,0],[0,1,0],[-1,-1,1],[-1,1,1],[1,-1,1],[1,1,1],[-2,0,2],[2,0,2],[0,-2,2],[0,2,2]])for(let a of s(e+n,t+r)){let e=c.get(a);(e===void 0||i<e)&&c.set(a,i)}return c.size===0?null:[...c.entries()].sort((e,t)=>e[1]-t[1]||i[e[0]].r0-i[t[0]].r0||i[e[0]].c0-i[t[0]].c0||e[0]-t[0])[0][0]}function Xt(e,t,n,r){switch(r){case`down`:return+(e.r0===t);case`up`:return+(e.r1===t);case`right`:return+(e.c0===n);case`left`:return+(e.c1===n)}}function Zt(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}var Qt=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`diagram`]),$t=400,en=400,tn=3,nn=.25,rn=/[│┃║┌┐└┘├┤┬┴┼╭╮╰╯┏┓┗┛╔╗╚╝┣┫┳┻╋╠╣╦╩╬╞╡╥╨╫╪]/;function an(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||Qt.has(t)}function on(e){return typeof e==`string`&&e.trim().toLowerCase()===`diagram`}function sn(e,t={}){let n=t.explicit===!0,r=[],i=e.replace(/\r\n?/g,`
|
|
5
5
|
`).split(`
|
|
6
|
-
`);if(i.length
|
|
6
|
+
`);if(i.length<tn)return{isDiagram:!1,reasons:[`too-few-lines(${i.length})`]};if(i.length>$t)return{isDiagram:!1,reasons:[`too-many-lines(${i.length})`]};let a=0;for(let e of i)a=Math.max(a,e.length);if(a>en)return{isDiagram:!1,reasons:[`too-wide(${a})`]};if(!n){let e=0;for(let t of i){let n=t.match(/[┌╭┏╔]|[├┬┼┣┳╋╠╦╬][─━═]/gu);e+=n?n.length:0;let r=t.match(/\+[-+]/g);e+=r?r.length:0}if(e<2)return{isDiagram:!1,reasons:[`too-few-corner-candidates(${e})`]}}let o=i.filter(e=>e.trim().length>0),s=o.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,c=o.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(s>o.length/2&&c)return{isDiagram:!1,reasons:[`markdown-table`]};let{diagram:l,stats:u}=Ot(e),d=n?1:2;if(l.nodes.length<d)return{isDiagram:!1,reasons:[`too-few-boxes(${l.nodes.length})`]};let f=l.nodes.filter(e=>rn.test(e.label)).length;if(f>0&&f>=l.nodes.length*.25)return{isDiagram:!1,reasons:[`garbled-labels(${f}/${l.nodes.length})`]};if(!n){if(l.edges.length===0&&l.nodes.length>=4&&ln(l))return{isDiagram:!1,reasons:[`table-lattice`]};if(u.totalNonSpaceCells>0){let e=u.looseNonSpaceCells/u.totalNonSpaceCells;if(e>nn)return{isDiagram:!1,reasons:[`loose-ratio(${e.toFixed(2)})`]}}}return r.push(`boxes(${l.nodes.length})`,`edges(${l.edges.length})`),n&&r.push(`explicit`),{isDiagram:!0,diagram:l,reasons:r}}function cn(e){return e.type!==`code`||!an(e.lang)?!1:sn(e.value,{explicit:on(e.lang)}).isDiagram}function ln(e){let t=e.nodes.filter(e=>!e.containerId);if(t.length<4)return!1;let n=new Set(t.map(e=>e.row)),r=new Set(t.map(e=>e.col));return n.size<2||r.size<2?!1:t.every(e=>t.some(t=>{if(e===t)return!1;let n=e.row+e.hRows-1,r=e.col+e.wCols-1,i=t.row+t.hRows-1,a=t.col+t.wCols-1;return e.row===i||n===t.row||e.col===a||r===t.col}))}var un=/[─━═-]{6,}/gu,dn=/[─━═│|►◄→←┌┐└┘├┤]/u,fn=/[►◄→←]/u,pn=/[◄←]/u,mn=/[►→]/u,hn=/^[\s─━═│|►◄→←┌┐└┘├┤]+$/u,gn=/^[A-Z][A-Z0-9 _/-]*(?:\s+\([^)]*\))?$/u;function _n(e){let t=e.replace(/\r\n?/g,`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),n=
|
|
8
|
+
`),n=yn(t);if(!n||n.tracks.length<2)return null;let r=[],i=[],a=new Set,o=new Map,s=null,c=null,l=null,u=0,d=!1,f=!1,p=!1,m=!1,h=e=>{let t=Tn(e.text),n={id:Dn(t,a),label:t,trackIndex:e.trackIndex,order:r.length};return r.push(n),n},g=(e,t,n)=>{!e||!t||e===t||i.some(r=>r.source===e&&r.target===t&&r.label===n)||i.push({source:e,target:t,...n?{label:n}:{}})};for(let e=n.underlineRow+1;e<t.length;e++){let i=t[e];if(!i.trim())continue;if(hn.test(i)){p||=i.includes(`┐`),m||=i.includes(`┘`);continue}if(i.trim().startsWith(`(`)&&!fn.test(i)){let e=Sn(n.tracks,Cn(i)),t=o.get(e);if(!t)return null;s={eventId:t,text:Tn(i.replace(/[│|]+\s*$/u,``))};continue}let a=i,_=null;if(s){let e=wn(a);if(e<0)return null;let t=Tn(Array.from(a).slice(0,e).join(``)),n=r.find(e=>e.id===s?.eventId);if(!n)return null;n.description=Tn(`${s.text} ${t}`),_=n.id,a=`${` `.repeat(e)}${Array.from(a).slice(e).join(``)}`,s=null}let v=xn(a,n.tracks);if(v.length===0||v.some(e=>!/[\p{L}\p{N}]/u.test(e.text)))return null;let y=new Map(o),b=v.map(h),x=[];for(let e=0;e<v.length-1;e++){let t=Array.from(a).slice(v[e].end+1,v[e+1].start).join(``),n=pn.test(t)?`left`:mn.test(t)?`right`:null;x.push(n),n&&u++,d||=n===`left`,f||=n===`right`,n===`left`&&g(b[e+1].id,b[e].id),n===`right`&&g(b[e].id,b[e+1].id)}let S=/^[\s│|]*[├└]/u.exec(i)?.[0]??``;S?(c||=y.get(b[0].trackIndex)??null,g(c??void 0,b[0].id),S.includes(`└`)&&(c=null)):c=null;let C=x.length>0&&x.every(e=>e===`left`),w=C?[...b].reverse():b,T=w[0];!S&&!i.includes(`┘`)&&g(y.get(T.trackIndex),T.id),_&&g(w[w.length-1]?.id,_);for(let e of w)o.set(e.trackIndex,e.id);if(i.includes(`┐`)&&(p=!0,l=b[b.length-1]?.id??null),i.includes(`┘`)){m=!0;let e=C?b[0]?.id:b[b.length-1]?.id;g(l??void 0,e)}}if(s||r.length<6||u<4||!d||!f||!p||!m||!On(r,i))return null;let _=kn(r,i),v=Math.max(10,..._.values()),y=n.tracks.map((e,t)=>{let n=r.filter(e=>e.trackIndex===t).sort((e,t)=>(_.get(e.id)??0)-(_.get(t.id)??0)||e.order-t.order),i=-1,a=n.map((e,t)=>{let n=_.get(e.id)??t*10,r=Math.max(i+1,n);return i=r,{id:e.id,label:e.label,...e.description?{description:e.description}:{},column:r,side:t%2==0?`above`:`below`,marker:`filled`}});return{id:e.id,label:e.label,row:e.row,startColumn:0,endColumn:v,events:a}}),b=Math.max(0,...t.map(e=>Array.from(e).length));return i.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),{tracks:y,links:i,width:b,height:t.length,style:`unicode`,warnings:[]}}function vn(e){return _n(e)!==null}function yn(e){for(let t=1;t<Math.min(e.length,5);t++){let n=Array.from(e[t].matchAll(un)).map(e=>({start:e.index,end:(e.index??0)+Array.from(e[0]).length-1}));if(n.length<2)continue;let r=bn(e[t-1]);if(!(r.length!==n.length||r.some(e=>!gn.test(e.text))))return{tracks:n.map((e,n)=>{let i=r[n];return{id:En(i.text.replace(/\s+\([^)]*\)\s*$/u,``).trim()),label:i.text,row:t-1,start:e.start,end:e.end}}),underlineRow:t}}return null}function bn(e){let t=Array.from(e),n=[],r=-1,i=0;for(let e=0;e<=t.length;e++){let a=t[e];if(a===` `){if(i++,r>=0&&i>=3){let a=e-i,o=t.slice(r,a+1).join(``).trim();o&&n.push({text:o,start:r,end:a}),r=-1}continue}if(i=0,a!==void 0&&r<0&&(r=e),a===void 0&&r>=0){let e=t.slice(r).join(``).trim();e&&n.push({text:e,start:r,end:t.length-1})}}return n}function xn(e,t){let n=Array.from(e),r=[],i=-1;for(let e=0;e<=n.length;e++){let a=e===n.length||dn.test(n[e]??``);if(!a&&i<0&&(i=e),!a||i<0)continue;let o=n.slice(i,e).join(``),s=o.length-o.trimStart().length,c=Tn(o);if(c){let e=i+s,n=e+Array.from(c).length-1;r.push({text:c,start:e,end:n,trackIndex:Sn(t,e)})}i=-1}return r}function Sn(e,t){for(let n=1;n<e.length;n++)if(t<e[n].start)return n-1;return e.length-1}function Cn(e){let t=Array.from(e).findIndex(e=>/[\p{L}\p{N}(]/u.test(e));return Math.max(0,t)}function wn(e){return Array.from(e).findIndex(e=>fn.test(e))}function Tn(e){return e.normalize(`NFC`).replace(/^[\s:]+|[\s:]+$/gu,``).replace(/\s+/gu,` `).trim()}function En(e){return e.normalize(`NFC`).toLowerCase().replace(/[^a-z0-9_.~-]+/gu,`-`).replace(/^-+|-+$/gu,``)||`event`}function Dn(e,t){let n=En(e);if(!t.has(n))return t.add(n),n;let r=2;for(;t.has(`${n}-${r}`);)r++;let i=`${n}-${r}`;return t.add(i),i}function On(e,t){let n=new Map(e.map(e=>[e.id,e.trackIndex]));return t.some(e=>n.get(e.source)!==n.get(e.target))}function kn(e,t){let n=new Map,r=new Map(e.map(e=>[e.id,0]));for(let e of t)n.set(e.source,[...n.get(e.source)??[],e.target]),r.set(e.target,(r.get(e.target)??0)+1);let i=new Map(e.map(e=>[e.id,0])),a=e.filter(e=>r.get(e.id)===0).map(e=>e.id),o=0;for(;a.length>0;){let e=a.shift();o++;for(let t of n.get(e)??[]){i.set(t,Math.max(i.get(t)??0,(i.get(e)??0)+1));let n=(r.get(t)??1)-1;r.set(t,n),n===0&&a.push(t)}}if(o<e.length)for(let t of e)i.set(t.id,t.order);return new Map(Array.from(i,([e,t])=>[e,t*10]))}var An=new Set([`●`,`○`,`◉`,`◆`,`◇`,`•`]),jn=new Set([`*`,`o`,`O`]),Mn=new Set([`─`,`━`,`═`,`╌`,`╍`,`┄`,`┅`,`┈`,`┉`,`-`]),Nn=new Set([`►`,`▶`,`▷`,`→`,`>`]),Pn=new Set([`▲`,`△`,`▼`,`▽`,`^`,`v`]),Fn=new Set([`└`,`┌`,`├`,`┬`,`┘`,`┐`,`╰`,`╭`,`╯`,`╮`]);function In(e){return Ln(e).timeline}function Ln(e){let t=e.replace(/\r\n?/g,`
|
|
9
9
|
`).split(`
|
|
10
|
-
`),n=Math.max(0,...t.map(e=>Array.from(e).length)),r=hn(e);if(r){let t=r.tracks.reduce((e,t)=>e+t.events.length,0);return{timeline:r,stats:{axisLines:r.tracks.length,markerCount:t,strongMarkerCount:t,horizontalChars:Array.from(e).filter(e=>I.has(e)).length,pointerCount:0,branchDeclarations:r.links.length,wrappedFlow:!0}}}let i=cr(t),a=[],o=[];for(let e=0;e<t.length;e++){let n=Wn(t[e]);if(n){a.push(n);continue}let r=In(t[e],e,i);if(r){o.push(r);continue}let s=Ln(t[e],e);s&&o.push(s)}let s=o.map((e,t)=>({id:e.id??or(e.label||`track-${t+1}`),...e.label?{label:e.label}:{},...e.endLabel?{endLabel:e.endLabel}:{},row:e.row,startColumn:e.startColumn,endColumn:e.endColumn,events:e.markerColumns.map((t,n)=>{let r=e.inline[n];return{id:r.id??``,label:r.label??``,...r.description?{description:r.description}:{},column:r.column??t,...r.side?{side:r.side}:{},...r.descriptionSide?{descriptionSide:r.descriptionSide}:{},...r.callout===!1?{callout:!1}:{},marker:er(e.markerGlyphs[n])}})}));for(let e=0;e<o.length;e++){let n=o[e],r=s[e],i=$n(t,n.row-1);if(i>=0&&!o.some(e=>e.row===i)){let e=Gn(t[i]),n=r.events.filter(e=>!e.label),a=Fn(e,n);if(a){for(let e=0;e<n.length;e++)n[e].label=ir(a[e].text),n[e].side=`above`;let t=e.indexOf(a[0]),i=t>0?e[t-1]:void 0;i?.text.trim().endsWith(`:`)&&(r.label=ar(i.text),r.id=or(r.label))}for(let t of r.events){if(t.label)continue;let n=Qn(r.events,t.column),i=Math.max(3,Math.min(8,n*.38)),a=Zn(e,t.column,i);a&&(t.label=ir(a.text),t.side=`above`)}}}let c=0;for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Array.from(t[e]),r=n.map((e,t)=>({char:e,column:t})).filter(({column:e})=>Jn(n,e)).map(({column:e})=>e);for(let t=0;t<r.length;t++){let i=r[t],a=Yn(s,e,i)??qn(s,e,i);if(!a)continue;c++;let o=r[t+1]??n.length,l=ir(n.slice(i+1,o).join(``)),u=t===0?ir(n.slice(0,i).join(``)):``,d=/\{[^{}]*#[^{}\s]+[^{}]*\}\s*$/u.test(l)?Rn(l):{label:l||void 0},f=ar(u)||d.label||l||`Event ${a.events.length+1}`,p=u&&l?l:d.description,m=d.side??(e<a.row?`above`:`below`),h=a.events.find(e=>!e.id&&Math.abs(e.column-i)<=1)??a.events.find(e=>e.callout!==!1&&Math.abs(e.column-i)<=1);h?(d.id&&(h.id=d.id),d.column!==void 0&&(h.column=d.column),h.label||=f,d.label&&(h.label=d.label),p&&!h.description&&(h.description=p),d.description&&(h.description=d.description),d.descriptionSide?h.descriptionSide=d.descriptionSide:p&&!d.id&&(h.descriptionSide??=m),d.callout!==void 0&&(h.callout=d.callout),h.side=m):a.events.push({id:d.id??``,label:f,...p?{description:p}:{},column:d.column??i,side:m,...d.descriptionSide?{descriptionSide:d.descriptionSide}:p&&!d.id?{descriptionSide:m}:{},...d.callout===void 0?{}:{callout:d.callout},marker:`hollow`})}}for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Kn(t[e]),r=n.length>0?ir(Array.from(t[e]).slice(0,n[0].start).join(``)):``;for(let t=0;t<n.length;t++){let i=n[t],a=qn(s,e,i.start);if(!a||a.events.length===0)continue;let o=Xn(a.events,i.start);if(!o)continue;let c=ir(i.text),l=t===0&&r?`${r} ${c}`:c;if(!(!l||l===o.label)){if(o.callout===!1){o.callout=!0,o.label=l,o.side=e<a.row?`above`:`below`;continue}o.description=o.description?`${o.description} ${l}`:l,o.descriptionSide??=e<a.row?`above`:`below`,o.side??=e<a.row?`above`:`below`}}}let l=[],u=new Map;for(let e of s)e.id=sr(e.id,u);let d=new Map;for(let e of s){e.events.sort((e,t)=>e.column-t.column);for(let t=0;t<e.events.length;t++){let n=e.events[t];n.label||(n.label=`Event ${t+1}`,l.push(`unlabeled-event(${e.id}:${n.column})`)),n.id=sr(n.id||or(n.label),d),n.side??=t%2==0?`above`:`below`}}let f=new Set(s.flatMap(e=>e.events.map(e=>e.id))),p=new Map;for(let e of s)for(let t of e.events)p.set(or(t.label),t.id),p.set(t.id,t.id);let m=[];for(let e of a){let t=p.get(or(e.source))??e.source,n=p.get(or(e.target))??e.target;if(!f.has(t)||!f.has(n)){l.push(`unresolved-link(${e.source}->${e.target})`);continue}m.push({source:t,target:n,...e.label?{label:e.label}:{}})}let h={axisLines:o.length,markerCount:o.reduce((e,t)=>e+t.markerColumns.length,0),strongMarkerCount:o.reduce((e,t)=>e+t.strongMarkerCount,0),horizontalChars:o.reduce((e,t)=>e+t.horizontalChars,0),pointerCount:c,branchDeclarations:a.length,wrappedFlow:!1};return{timeline:{tracks:s,links:m,width:n,height:t.length,style:i,warnings:l},stats:h}}function Fn(e,t){if(t.length<2||e.length<t.length)return;let n=e.slice(-t.length);if(n.some(e=>rr(e.text).length>40))return;let r=n.map((e,n)=>(e.start+e.end)/2-t[n].column);return Math.max(...r)-Math.min(...r)<=3?[...n]:void 0}function In(e,t,n){let r=Array.from(e),i=[],a=[],o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e];I.has(t)&&o++,tr(r,e,n)&&(i.push(e),a.push(t),On.has(t)&&s++)}if(i.length===0||o<2)return null;let c=i[0],l=r.slice(0,c).lastIndexOf(`:`),u;if(l>=0)for(u=l+1;r[u]===` `;)u++;else{let e=c-1;for(;e>=0&&(I.has(r[e])||r[e]===` `);)e--;for(u=e+1;r[u]===` `;)u++}let d=i[i.length-1],f=d+1,p=r.findIndex((e,t)=>t>=f&&An.has(e)&&Hn(r,t,e===`>`?3:2)),m;if(p>=0)d=p,m=p;else{let e=Un(r);d=Math.max(d,e),m=d+1}let h=zn(ar(r.slice(0,u).join(``).trim())),g=ir(r.slice(d+1).join(``)),_=h.label,v=i.map((e,t)=>{let n=t+1<i.length?i[t+1]:m;return Rn(r.slice(e+1,n).join(``))});return{row:t,...h.id?{id:h.id}:{},startColumn:h.startColumn??u,endColumn:h.endColumn??Math.max(d,u+1),markerColumns:i,markerGlyphs:a,inline:v,..._?{label:_}:{},...g?{endLabel:g}:{},horizontalChars:o,strongMarkerCount:s}}function Ln(e,t){let n=Array.from(e),r=n.indexOf(`:`);if(r<0)return null;let i=n.slice(0,r).join(``).trim();if(!i)return null;let a=[],o=r+1;for(;o<n.length;){for(;o<n.length&&/\s/u.test(n[o]);)o++;if(o>=n.length)break;let e=o;for(;o<n.length&&!/\s/u.test(n[o]);)o++;a.push({value:n.slice(e,o).join(``),column:e})}return a.length<4||a[0].value.length!==1||a.some(e=>e.value!==a[0].value)?null:{row:t,startColumn:a[0].column,endColumn:a[a.length-1].column,markerColumns:a.map(e=>e.column),markerGlyphs:a.map(()=>`○`),inline:a.map((e,t)=>({label:e.value,id:`${or(i)}-${t+1}`,column:e.column,callout:!1})),label:i,horizontalChars:0,strongMarkerCount:0}}function Rn(e){let t=Vn(e).replace(/\s+/g,` `).trim();if(!t)return{};let n,r,i,a,o,s=/\{([^{}]+)\}\s*$/.exec(t);if(s){let e=!1;for(let t of s[1].trim().split(/\s+/))if(t.startsWith(`#`)&&t.length>1)n=t.slice(1),e=!0;else if(t===`side=above`)i=`above`,e=!0;else if(t===`side=below`)i=`below`,e=!0;else if(t===`descriptionSide=above`)a=`above`,e=!0;else if(t===`descriptionSide=below`)a=`below`,e=!0;else if(t.startsWith(`column=`)){let n=Bn(t.slice(7));n!==void 0&&(r=n,e=!0)}else t===`callout=false`?(o=!1,e=!0):t===`callout=true`&&(o=!0,e=!0);e&&(t=t.slice(0,s.index).trim())}t.startsWith(`^ `)?(i=`above`,t=t.slice(2).trim()):/^[vV]\s+/.test(t)&&(i=`below`,t=t.slice(2).trim());let c=t.indexOf(`::`),l=(c>=0?t.slice(0,c):t).trim(),u=c>=0?t.slice(c+2).trim():void 0;return{...l?{label:l}:{},...u?{description:u}:{},...n?{id:n}:{},...r===void 0?{}:{column:r},...i?{side:i}:{},...a?{descriptionSide:a}:{},...o===void 0?{}:{callout:o}}}function zn(e){let t=e.trim(),n,r,i,a=!1,o=/\{([^{}]+)\}\s*$/.exec(t);if(o){for(let e of o[1].trim().split(/\s+/))e.startsWith(`#`)&&e.length>1?(n=e.slice(1),a=!0):e.startsWith(`start=`)?(r=Bn(e.slice(6)),a||=r!==void 0):e.startsWith(`end=`)&&(i=Bn(e.slice(4)),a||=i!==void 0);a&&(t=t.slice(0,o.index).trim())}return{...t?{label:t}:{},...n?{id:n}:{},...r===void 0?{}:{startColumn:r},...i===void 0?{}:{endColumn:i},hasMetadata:a}}function Bn(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Vn(e){let t=Array.from(e),n=0,r=t.length-1,i=0;for(;i<=r&&/\s/u.test(t[i]);)i++;let a=i;for(;a<=r&&I.has(t[a]);)a++;for(n=a>i&&(i===0||a>r||/\s/u.test(t[a]??``))?a:i;n<=r&&/\s/u.test(t[n]);)n++;for(;r>=n&&/\s/u.test(t[r]);)r--;let o=r;for(;r>=n&&I.has(t[r]);)r--;let s=r<o,c=s?t.slice(r+1,o+1):[];for(s&&(r<n||/\s/u.test(t[r]??``)||c.length>=3||c.some(e=>e!==`-`))||(r=o);r>=n&&/\s/u.test(t[r]);)r--;return t.slice(n,r+1).join(``)}function Hn(e,t,n){let r=t-1;for(;r>=0&&/\s/u.test(e[r]);)r--;let i=0;for(;r>=0&&I.has(e[r]);)i++,r--;return i>=n}function Un(e){for(let t=e.length-1;t>=0;t--)if(!/\s/u.test(e[t]))return t;return-1}function Wn(e){let t=/^\s*(?:branch|link)\s*:\s*([^\s:]+)\s*(?:->|=>|→)\s*([^\s:]+)(?:\s*:\s*(.+))?\s*$/i.exec(e);return t?{source:t[1],target:t[2],...t[3]?.trim()?{label:t[3].trim()}:{}}:null}function Gn(e){let t=Array.from(e),n=[],r=-1,i=0;for(let e=0;e<=t.length;e++){let a=t[e];if(a===` `){if(i++,r>=0&&i>=2){let a=e-i,o=t.slice(r,a+1).join(``).trim();o&&n.push({start:r,end:a,text:o}),r=-1}continue}if(i=0,a!==void 0&&r<0&&(r=e),a===void 0&&r>=0){let e=t.slice(r).join(``).trim();e&&n.push({start:r,end:t.length-1,text:e})}}return n.filter(e=>rr(e.text).length>0)}function Kn(e){let t=Array.from(e),n=[];for(let e=0;e<t.length;e++){if(!Mn.has(t[e]))continue;let r=e+1,i=r;for(;r<t.length&&(I.has(t[r])||t[r]===` `);)r++;let a=r,o=t[r];if(o!==void 0&&!/\s/u.test(o)){let e=-1;for(let n=i;n<r;n++)I.has(t[n])&&t[n]!==`-`&&(e=n);e>=i&&e+1<r?r=e+1:e<0&&r-i>=3&&r--}let s=r;if(r<a)for(;r<t.length&&t[r]===`-`;)r++;for(;r<t.length&&!I.has(t[r])&&!Mn.has(t[r]);)r++;let c=t.slice(s,r).join(``).trim();c&&n.push({start:e,end:Math.max(e,r-1),text:c})}return n}function qn(e,t,n){return e.filter(e=>n>=e.startColumn-2&&n<=e.endColumn+2).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function Jn(e,t){let n=e[t];return jn.has(n)?n!==`^`&&n!==`v`||(t===0||/\s/u.test(e[t-1]??``))&&(t+1>=e.length||/\s/u.test(e[t+1]??``)):!1}function Yn(e,t,n){return e.filter(e=>e.events.some(e=>!e.id&&Math.abs(e.column-n)<=1)).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function Xn(e,t){return[...e].sort((e,n)=>Math.abs(e.column-t)-Math.abs(n.column-t)||Number(e.callout===!1)-Number(n.callout===!1))[0]}function Zn(e,t,n){return[...e].map(e=>({segment:e,distance:Math.abs((e.start+e.end)/2-t)})).filter(e=>e.distance<=n).sort((e,t)=>e.distance-t.distance)[0]?.segment}function Qn(e,t){let n=e.filter(e=>e.column!==t).map(e=>Math.abs(e.column-t));return n.length>0?Math.min(...n):12}function $n(e,t){for(let n=t;n>=0;n--)if(e[n].trim())return n;return-1}function er(e){return e===`◆`||e===`◇`?`diamond`:e===`○`||e===`o`||e===`O`?`hollow`:`filled`}function tr(e,t,n){let r=e[t];if(On.has(r))return!0;if(n!==`ascii`||!kn.has(r))return!1;let i=nr(e,t,-1),a=nr(e,t,1),o=/[\p{L}\p{N}_]/u.test(e[t-1]??``),s=/[\p{L}\p{N}_]/u.test(e[t+1]??``);return i>=2&&!s||a>=2&&!o}function nr(e,t,n){let r=0;for(let i=t+n;I.has(e[i]??``);i+=n)r++;return r}function rr(e){return e.replace(/^[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉-]+/u,``).replace(/[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉►▶▷→>-]+$/u,``).replace(/\s+/g,` `).trim()}function ir(e){return e.replace(/^[\s│|]+/u,``).replace(/[\s│|]+$/u,``).replace(/\s+/g,` `).trim()}function ar(e){return e.replace(/:\s*$/,``).trim()}function or(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function sr(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n+1}`}function cr(e){for(let t of e)for(let e of t)if(On.has(e)||I.has(e)&&e!==`-`||[`►`,`▶`,`▷`,`→`].includes(e))return`unicode`;return`ascii`}var lr=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`timeline`]),ur=400,dr=2e3,fr=400,pr=4096,mr=/[┌┏╔╭].*[┐┓╗╮]/u,hr=/\{#[^{}\s]+ start=[^{}\s]+ end=[^{}\s]+\}:\s/u;function gr(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||lr.has(t)}function _r(e){return typeof e==`string`&&e.trim().toLowerCase()===`timeline`}function vr(e,t={}){let n=t.explicit===!0,r=e.replace(/\r\n?/g,`
|
|
10
|
+
`),n=Math.max(0,...t.map(e=>Array.from(e).length)),r=_n(e);if(r){let t=r.tracks.reduce((e,t)=>e+t.events.length,0);return{timeline:r,stats:{axisLines:r.tracks.length,markerCount:t,strongMarkerCount:t,horizontalChars:Array.from(e).filter(e=>Mn.has(e)).length,pointerCount:0,branchDeclarations:r.links.length,wrappedFlow:!0}}}let i=dr(t),a=[],o=[];for(let e=0;e<t.length;e++){let n=qn(t[e]);if(n){a.push(n);continue}let r=zn(t[e],e,i);if(r){o.push(r);continue}let s=Bn(t[e],e);s&&o.push(s)}let s=o.map((e,t)=>({id:e.id??lr(e.label||`track-${t+1}`),...e.label?{label:e.label}:{},...e.endLabel?{endLabel:e.endLabel}:{},row:e.row,startColumn:e.startColumn,endColumn:e.endColumn,events:e.markerColumns.map((t,n)=>{let r=e.inline[n];return{id:r.id??``,label:r.label??``,...r.description?{description:r.description}:{},column:r.column??t,...r.side?{side:r.side}:{},...r.descriptionSide?{descriptionSide:r.descriptionSide}:{},...r.callout===!1?{callout:!1}:{},marker:rr(e.markerGlyphs[n])}})}));for(let e=0;e<o.length;e++){let n=o[e],r=s[e],i=nr(t,n.row-1);if(i>=0&&!o.some(e=>e.row===i)){let e=Jn(t[i]),n=r.events.filter(e=>!e.label),a=Rn(e,n);if(a){for(let e=0;e<n.length;e++)n[e].label=sr(a[e].text),n[e].side=`above`;let t=e.indexOf(a[0]),i=t>0?e[t-1]:void 0;i?.text.trim().endsWith(`:`)&&(r.label=cr(i.text),r.id=lr(r.label))}for(let t of r.events){if(t.label)continue;let n=tr(r.events,t.column),i=Math.max(3,Math.min(8,n*.38)),a=er(e,t.column,i);a&&(t.label=sr(a.text),t.side=`above`)}}}let c=0;for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Array.from(t[e]),r=n.map((e,t)=>({char:e,column:t})).filter(({column:e})=>Zn(n,e)).map(({column:e})=>e);for(let t=0;t<r.length;t++){let i=r[t],a=Qn(s,e,i)??Xn(s,e,i);if(!a)continue;c++;let o=r[t+1]??n.length,l=sr(n.slice(i+1,o).join(``)),u=t===0?sr(n.slice(0,i).join(``)):``,d=/\{[^{}]*#[^{}\s]+[^{}]*\}\s*$/u.test(l)?Vn(l):{label:l||void 0},f=cr(u)||d.label||l||`Event ${a.events.length+1}`,p=u&&l?l:d.description,m=d.side??(e<a.row?`above`:`below`),h=a.events.find(e=>!e.id&&Math.abs(e.column-i)<=1)??a.events.find(e=>e.callout!==!1&&Math.abs(e.column-i)<=1);h?(d.id&&(h.id=d.id),d.column!==void 0&&(h.column=d.column),h.label||=f,d.label&&(h.label=d.label),p&&!h.description&&(h.description=p),d.description&&(h.description=d.description),d.descriptionSide?h.descriptionSide=d.descriptionSide:p&&!d.id&&(h.descriptionSide??=m),d.callout!==void 0&&(h.callout=d.callout),h.side=m):a.events.push({id:d.id??``,label:f,...p?{description:p}:{},column:d.column??i,side:m,...d.descriptionSide?{descriptionSide:d.descriptionSide}:p&&!d.id?{descriptionSide:m}:{},...d.callout===void 0?{}:{callout:d.callout},marker:`hollow`})}}for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Yn(t[e]),r=n.length>0?sr(Array.from(t[e]).slice(0,n[0].start).join(``)):``;for(let t=0;t<n.length;t++){let i=n[t],a=Xn(s,e,i.start);if(!a||a.events.length===0)continue;let o=$n(a.events,i.start);if(!o)continue;let c=sr(i.text),l=t===0&&r?`${r} ${c}`:c;if(!(!l||l===o.label)){if(o.callout===!1){o.callout=!0,o.label=l,o.side=e<a.row?`above`:`below`;continue}o.description=o.description?`${o.description} ${l}`:l,o.descriptionSide??=e<a.row?`above`:`below`,o.side??=e<a.row?`above`:`below`}}}let l=[],u=new Map;for(let e of s)e.id=ur(e.id,u);let d=new Map;for(let e of s){e.events.sort((e,t)=>e.column-t.column);for(let t=0;t<e.events.length;t++){let n=e.events[t];n.label||(n.label=`Event ${t+1}`,l.push(`unlabeled-event(${e.id}:${n.column})`)),n.id=ur(n.id||lr(n.label),d),n.side??=t%2==0?`above`:`below`}}let f=new Set(s.flatMap(e=>e.events.map(e=>e.id))),p=new Map;for(let e of s)for(let t of e.events)p.set(lr(t.label),t.id),p.set(t.id,t.id);let m=[];for(let e of a){let t=p.get(lr(e.source))??e.source,n=p.get(lr(e.target))??e.target;if(!f.has(t)||!f.has(n)){l.push(`unresolved-link(${e.source}->${e.target})`);continue}m.push({source:t,target:n,...e.label?{label:e.label}:{}})}let h={axisLines:o.length,markerCount:o.reduce((e,t)=>e+t.markerColumns.length,0),strongMarkerCount:o.reduce((e,t)=>e+t.strongMarkerCount,0),horizontalChars:o.reduce((e,t)=>e+t.horizontalChars,0),pointerCount:c,branchDeclarations:a.length,wrappedFlow:!1};return{timeline:{tracks:s,links:m,width:n,height:t.length,style:i,warnings:l},stats:h}}function Rn(e,t){if(t.length<2||e.length<t.length)return;let n=e.slice(-t.length);if(n.some(e=>or(e.text).length>40))return;let r=n.map((e,n)=>(e.start+e.end)/2-t[n].column);return Math.max(...r)-Math.min(...r)<=3?[...n]:void 0}function zn(e,t,n){let r=Array.from(e),i=[],a=[],o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e];Mn.has(t)&&o++,ir(r,e,n)&&(i.push(e),a.push(t),An.has(t)&&s++)}if(i.length===0||o<2)return null;let c=i[0],l=r.slice(0,c).lastIndexOf(`:`),u;if(l>=0)for(u=l+1;r[u]===` `;)u++;else{let e=c-1;for(;e>=0&&(Mn.has(r[e])||r[e]===` `);)e--;for(u=e+1;r[u]===` `;)u++}let d=i[i.length-1],f=d+1,p=r.findIndex((e,t)=>t>=f&&Nn.has(e)&&Gn(r,t,e===`>`?3:2)),m;if(p>=0)d=p,m=p;else{let e=Kn(r);d=Math.max(d,e),m=d+1}let h=Hn(cr(r.slice(0,u).join(``).trim())),g=sr(r.slice(d+1).join(``)),_=h.label,v=i.map((e,t)=>{let n=t+1<i.length?i[t+1]:m;return Vn(r.slice(e+1,n).join(``))});return{row:t,...h.id?{id:h.id}:{},startColumn:h.startColumn??u,endColumn:h.endColumn??Math.max(d,u+1),markerColumns:i,markerGlyphs:a,inline:v,..._?{label:_}:{},...g?{endLabel:g}:{},horizontalChars:o,strongMarkerCount:s}}function Bn(e,t){let n=Array.from(e),r=n.indexOf(`:`);if(r<0)return null;let i=n.slice(0,r).join(``).trim();if(!i)return null;let a=[],o=r+1;for(;o<n.length;){for(;o<n.length&&/\s/u.test(n[o]);)o++;if(o>=n.length)break;let e=o;for(;o<n.length&&!/\s/u.test(n[o]);)o++;a.push({value:n.slice(e,o).join(``),column:e})}return a.length<4||a[0].value.length!==1||a.some(e=>e.value!==a[0].value)?null:{row:t,startColumn:a[0].column,endColumn:a[a.length-1].column,markerColumns:a.map(e=>e.column),markerGlyphs:a.map(()=>`○`),inline:a.map((e,t)=>({label:e.value,id:`${lr(i)}-${t+1}`,column:e.column,callout:!1})),label:i,horizontalChars:0,strongMarkerCount:0}}function Vn(e){let t=Wn(e).replace(/\s+/g,` `).trim();if(!t)return{};let n,r,i,a,o,s=/\{([^{}]+)\}\s*$/.exec(t);if(s){let e=!1;for(let t of s[1].trim().split(/\s+/))if(t.startsWith(`#`)&&t.length>1)n=t.slice(1),e=!0;else if(t===`side=above`)i=`above`,e=!0;else if(t===`side=below`)i=`below`,e=!0;else if(t===`descriptionSide=above`)a=`above`,e=!0;else if(t===`descriptionSide=below`)a=`below`,e=!0;else if(t.startsWith(`column=`)){let n=Un(t.slice(7));n!==void 0&&(r=n,e=!0)}else t===`callout=false`?(o=!1,e=!0):t===`callout=true`&&(o=!0,e=!0);e&&(t=t.slice(0,s.index).trim())}t.startsWith(`^ `)?(i=`above`,t=t.slice(2).trim()):/^[vV]\s+/.test(t)&&(i=`below`,t=t.slice(2).trim());let c=t.indexOf(`::`),l=(c>=0?t.slice(0,c):t).trim(),u=c>=0?t.slice(c+2).trim():void 0;return{...l?{label:l}:{},...u?{description:u}:{},...n?{id:n}:{},...r===void 0?{}:{column:r},...i?{side:i}:{},...a?{descriptionSide:a}:{},...o===void 0?{}:{callout:o}}}function Hn(e){let t=e.trim(),n,r,i,a=!1,o=/\{([^{}]+)\}\s*$/.exec(t);if(o){for(let e of o[1].trim().split(/\s+/))e.startsWith(`#`)&&e.length>1?(n=e.slice(1),a=!0):e.startsWith(`start=`)?(r=Un(e.slice(6)),a||=r!==void 0):e.startsWith(`end=`)&&(i=Un(e.slice(4)),a||=i!==void 0);a&&(t=t.slice(0,o.index).trim())}return{...t?{label:t}:{},...n?{id:n}:{},...r===void 0?{}:{startColumn:r},...i===void 0?{}:{endColumn:i},hasMetadata:a}}function Un(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Wn(e){let t=Array.from(e),n=0,r=t.length-1,i=0;for(;i<=r&&/\s/u.test(t[i]);)i++;let a=i;for(;a<=r&&Mn.has(t[a]);)a++;for(n=a>i&&(i===0||a>r||/\s/u.test(t[a]??``))?a:i;n<=r&&/\s/u.test(t[n]);)n++;for(;r>=n&&/\s/u.test(t[r]);)r--;let o=r;for(;r>=n&&Mn.has(t[r]);)r--;let s=r<o,c=s?t.slice(r+1,o+1):[];for(s&&(r<n||/\s/u.test(t[r]??``)||c.length>=3||c.some(e=>e!==`-`))||(r=o);r>=n&&/\s/u.test(t[r]);)r--;return t.slice(n,r+1).join(``)}function Gn(e,t,n){let r=t-1;for(;r>=0&&/\s/u.test(e[r]);)r--;let i=0;for(;r>=0&&Mn.has(e[r]);)i++,r--;return i>=n}function Kn(e){for(let t=e.length-1;t>=0;t--)if(!/\s/u.test(e[t]))return t;return-1}function qn(e){let t=/^\s*(?:branch|link)\s*:\s*([^\s:]+)\s*(?:->|=>|→)\s*([^\s:]+)(?:\s*:\s*(.+))?\s*$/i.exec(e);return t?{source:t[1],target:t[2],...t[3]?.trim()?{label:t[3].trim()}:{}}:null}function Jn(e){let t=Array.from(e),n=[],r=-1,i=0;for(let e=0;e<=t.length;e++){let a=t[e];if(a===` `){if(i++,r>=0&&i>=2){let a=e-i,o=t.slice(r,a+1).join(``).trim();o&&n.push({start:r,end:a,text:o}),r=-1}continue}if(i=0,a!==void 0&&r<0&&(r=e),a===void 0&&r>=0){let e=t.slice(r).join(``).trim();e&&n.push({start:r,end:t.length-1,text:e})}}return n.filter(e=>or(e.text).length>0)}function Yn(e){let t=Array.from(e),n=[];for(let e=0;e<t.length;e++){if(!Fn.has(t[e]))continue;let r=e+1,i=r;for(;r<t.length&&(Mn.has(t[r])||t[r]===` `);)r++;let a=r,o=t[r];if(o!==void 0&&!/\s/u.test(o)){let e=-1;for(let n=i;n<r;n++)Mn.has(t[n])&&t[n]!==`-`&&(e=n);e>=i&&e+1<r?r=e+1:e<0&&r-i>=3&&r--}let s=r;if(r<a)for(;r<t.length&&t[r]===`-`;)r++;for(;r<t.length&&!Mn.has(t[r])&&!Fn.has(t[r]);)r++;let c=t.slice(s,r).join(``).trim();c&&n.push({start:e,end:Math.max(e,r-1),text:c})}return n}function Xn(e,t,n){return e.filter(e=>n>=e.startColumn-2&&n<=e.endColumn+2).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function Zn(e,t){let n=e[t];return Pn.has(n)?n!==`^`&&n!==`v`||(t===0||/\s/u.test(e[t-1]??``))&&(t+1>=e.length||/\s/u.test(e[t+1]??``)):!1}function Qn(e,t,n){return e.filter(e=>e.events.some(e=>!e.id&&Math.abs(e.column-n)<=1)).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function $n(e,t){return[...e].sort((e,n)=>Math.abs(e.column-t)-Math.abs(n.column-t)||Number(e.callout===!1)-Number(n.callout===!1))[0]}function er(e,t,n){return[...e].map(e=>({segment:e,distance:Math.abs((e.start+e.end)/2-t)})).filter(e=>e.distance<=n).sort((e,t)=>e.distance-t.distance)[0]?.segment}function tr(e,t){let n=e.filter(e=>e.column!==t).map(e=>Math.abs(e.column-t));return n.length>0?Math.min(...n):12}function nr(e,t){for(let n=t;n>=0;n--)if(e[n].trim())return n;return-1}function rr(e){return e===`◆`||e===`◇`?`diamond`:e===`○`||e===`o`||e===`O`?`hollow`:`filled`}function ir(e,t,n){let r=e[t];if(An.has(r))return!0;if(n!==`ascii`||!jn.has(r))return!1;let i=ar(e,t,-1),a=ar(e,t,1),o=/[\p{L}\p{N}_]/u.test(e[t-1]??``),s=/[\p{L}\p{N}_]/u.test(e[t+1]??``);return i>=2&&!s||a>=2&&!o}function ar(e,t,n){let r=0;for(let i=t+n;Mn.has(e[i]??``);i+=n)r++;return r}function or(e){return e.replace(/^[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉-]+/u,``).replace(/[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉►▶▷→>-]+$/u,``).replace(/\s+/g,` `).trim()}function sr(e){return e.replace(/^[\s│|]+/u,``).replace(/[\s│|]+$/u,``).replace(/\s+/g,` `).trim()}function cr(e){return e.replace(/:\s*$/,``).trim()}function lr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function ur(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n+1}`}function dr(e){for(let t of e)for(let e of t)if(An.has(e)||Mn.has(e)&&e!==`-`||[`►`,`▶`,`▷`,`→`].includes(e))return`unicode`;return`ascii`}var fr=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`timeline`]),pr=400,mr=2e3,hr=400,gr=4096,_r=/[┌┏╔╭].*[┐┓╗╮]/u,vr=/\{#[^{}\s]+ start=[^{}\s]+ end=[^{}\s]+\}:\s/u;function yr(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||fr.has(t)}function br(e){return typeof e==`string`&&e.trim().toLowerCase()===`timeline`}function xr(e,t={}){let n=t.explicit===!0,r=e.replace(/\r\n?/g,`
|
|
11
11
|
`).split(`
|
|
12
|
-
`),i=r.filter(e=>
|
|
12
|
+
`),i=r.filter(e=>vr.test(e)).length,a=Math.min(mr,i*6+r.filter(e=>/^\s*(?:branch|link)\s*:/iu.test(e)).length+2);if(r.length>pr&&(i===0||r.length>a))return{isTimeline:!1,reasons:[`too-many-lines(${r.length})`]};let o=Math.max(0,...r.map(e=>Array.from(e).length)),s=i>0&&r.every(e=>Array.from(e).length<=hr||vr.test(e));if(o>(n||s?gr:hr))return{isTimeline:!1,reasons:[`too-wide(${o})`]};let c=r.filter(e=>e.trim().length>0),l=c.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,u=c.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(l>c.length/2&&u)return{isTimeline:!1,reasons:[`markdown-table`]};if(!n&&r.some(e=>_r.test(e)))return{isTimeline:!1,reasons:[`has-box-corners`]};let d=Ot(e).diagram.nodes.length;if(d>=(n?2:1))return{isTimeline:!1,reasons:[`has-boxes(${d})`]};if(!n&&/^[ \t]*(?:[│|][ \t]*)*[├└+|`][─━═-]{1,4}[ \t]+[●○◉◆◇•]/mu.test(e))return{isTimeline:!1,reasons:[`tree-connector-prefix`]};let{timeline:f,stats:p}=Ln(e);return p.wrappedFlow?{isTimeline:!0,timeline:f,reasons:[`tracks(${p.axisLines})`,`events(${p.markerCount})`,`wrapped-flow`]}:p.axisLines===0?{isTimeline:!1,reasons:[`no-axis-lines`]}:!(n&&p.horizontalChars===0&&p.markerCount>=4)&&p.horizontalChars<(n?2:8)?{isTimeline:!1,reasons:[`too-few-horizontal(${p.horizontalChars})`]}:p.markerCount<(n?1:2)?{isTimeline:!1,reasons:[`too-few-markers(${p.markerCount})`]}:!n&&p.strongMarkerCount<2?{isTimeline:!1,reasons:[`too-few-strong-markers(${p.strongMarkerCount})`]}:{isTimeline:!0,timeline:f,reasons:[`tracks(${p.axisLines})`,`events(${p.markerCount+p.pointerCount})`,n?`explicit`:`strong-markers`]}}function Sr(e){return e.type!==`code`||!yr(e.lang)?!1:xr(e.value,{explicit:br(e.lang)}).isTimeline}var Cr=new Set([`│`,`┃`,`╎`,`╏`,`║`,`|`]),wr=new Set([`├`,`┣`,`┠`,`┝`,`╠`,`╞`]),Tr=new Set([`└`,`┗`,`╰`,`╚`,`╘`]),Er=new Set([`─`,`━`,`═`,`-`]);function Dr(e){return Cr.has(e)}function Or(e){return wr.has(e)}function kr(e){return Tr.has(e)}function Ar(e){return Er.has(e)}function jr(e){return wr.has(e)||Tr.has(e)||e===`│`||e===`┃`||e===`─`||e===`━`}function Mr(e){return e===`|`||e==="`"||e===`+`||e===`-`}var Nr={tee:`├── `,elbow:`└── `,rail:`│ `,gap:` `},Pr={tee:`|-- `,elbow:"`-- ",rail:`| `,gap:` `};function Fr(e){return Ir(e).tree}function Ir(e){let t=[],n=e.replace(/\r\n?/g,`
|
|
13
13
|
`).split(`
|
|
14
|
-
`),r=
|
|
14
|
+
`),r=Rr(n),i={contentLines:0,connectorLines:0,looseLines:0,indentLevels:0},a=new Set,o=[];for(let e of n){if(e.trim().length===0)continue;i.contentLines++;let t=Lr(e);if(!t||t.label.length===0){i.looseLines++;continue}t.hadConnector&&i.connectorLines++,a.add(t.indent),o.push(t)}i.indentLevels=a.size;let s=[],c=[];for(let e of o){let t={id:``,label:e.label,children:[],...e.comment?{comment:e.comment}:{}};for(;c.length>0&&c[c.length-1].indent>=e.indent;)c.pop();c.length===0?s.push(t):c[c.length-1].node.children.push(t),c.push({indent:e.indent,node:t})}let l=new Map,u=e=>{e.isDir=e.label.endsWith(`/`)||e.children.length>0;let t=Br(zr(e.label)),n=l.get(t)??0;l.set(t,n+1),e.id=n===0?t:`${t}-${n+1}`;for(let t of e.children)u(t)};for(let e of s)u(e);return o.length>0&&i.looseLines>0&&t.push(`loose-lines(${i.looseLines})`),{tree:{roots:s,style:r,warnings:t},stats:i}}function Lr(e){let t=Array.from(e),n=0,r=!1;for(;;){for(;n<t.length&&(t[n]===` `||t[n]===` `);)n++;let e=t[n];if(e===void 0)return null;if(Dr(e)&&!Ar(t[n+1]??``)){n++;continue}break}let i=t[n];if(i!==void 0)if(Or(i)||kr(i)){for(n++;n<t.length&&(Ar(t[n])||Dr(t[n]));)n++;r=!0}else if((i===`|`||i==="`"||i===`+`)&&Ar(t[n+1]??``)){for(n++;n<t.length&&Ar(t[n]);)n++;r=!0}else(i===`-`||i===`*`||i===`+`)&&(t[n+1]??``)===` `&&(n++,r=!1);for(;n<t.length&&(t[n]===` `||t[n]===` `);)n++;let a=n,o=t.slice(n).join(``).replace(/\s+$/u,``);if(o.length===0)return null;let s,c=/\s{2,}(?:#|<--|\/\/)\s?(.*)$/.exec(o);return c&&(s=c[1].trim()||void 0,o=o.slice(0,c.index).replace(/\s+$/u,``)),o.length===0?null:{indent:a,label:o,hadConnector:r,...s?{comment:s}:{}}}function Rr(e){let t=0,n=0;for(let r of e)for(let e of r)jr(e)?t++:Mr(e)&&n++;return n>t?`ascii`:`unicode`}function zr(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Br(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}var Vr=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`tree`]),Hr=400,Ur=2,Wr=2,Gr=2,Kr=/[┌┐┘┏┓┛╔╗╝╭╮╯]/u;function qr(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||Vr.has(t)}function Jr(e){return typeof e==`string`&&e.trim().toLowerCase()===`tree`}function Yr(e,t={}){let n=t.explicit===!0,r=e.replace(/\r\n?/g,`
|
|
15
15
|
`).split(`
|
|
16
|
-
`),i=r.filter(e=>e.trim().length>0),a=n?1:Br;if(i.length<a)return{isTree:!1,reasons:[`too-few-lines(${i.length})`]};if(r.length>zr)return{isTree:!1,reasons:[`too-many-lines(${r.length})`]};let o=i.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,s=i.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(o>i.length/2&&s)return{isTree:!1,reasons:[`markdown-table`]};if(Ur.test(e))return{isTree:!1,reasons:[`has-box-corners`]};if(!n&&vr(e).isTimeline)return{isTree:!1,reasons:[`is-timeline`]};let c=Et(e).diagram.nodes.length;if(c>=2)return{isTree:!1,reasons:[`has-boxes(${c})`]};let{tree:l,stats:u}=Nr(e),d=Jr(l.roots);if(d<(n?1:Hr))return{isTree:!1,reasons:[`too-few-nodes(${d})`]};if(!n){if(u.connectorLines<Vr)return{isTree:!1,reasons:[`too-few-connectors(${u.connectorLines})`]};if(u.looseLines>u.contentLines*.25)return{isTree:!1,reasons:[`loose-ratio(${u.looseLines}/${u.contentLines})`]}}return{isTree:!0,tree:l,reasons:[`nodes(${d})`,n?`explicit`:`connectors(${u.connectorLines})`]}}function qr(e){return e.type!==`code`||!Wr(e.lang)?!1:Kr(e.value,{explicit:Gr(e.lang)}).isTree}function Jr(e){let t=0;for(let n of e)t+=1+Jr(n.children);return t}var Yr=/(?:[$€£¥]\s?\d+(?:[.,]\d+)*(?:\s?(?:[MBK]|million|billion|thousand))?|\d+(?:[.,]\d+)*\s?(?:%|‰|x|×|[MBK]|million|billion|thousand|percent|years?|days?|hours?)|\d{3,}(?:[.,]\d+)*)/i;function Xr(e){let t=Yr.exec(e);return!t||t.index===void 0?null:{value:t[0],index:t.index,end:t.index+t[0].length}}var Zr=Object.freeze({hasImage:!1,imageCount:0,hasVideo:!1,hasBlockquote:!1,hasList:!1,hasTable:!1,hasDate:!1,hasNumberHighlight:!1,wordCount:0}),Qr=[/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?\d{4}\b/i,/\b\d{1,2}\s+(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{4}\b/i,/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)\.?\s+\d{1,2},?\s+\d{4}\b/i,/\b\d{4}-\d{2}-\d{2}\b/,/\b\d{1,2}\/\d{1,2}\/\d{2,4}\b/,/\bQ[1-4]\s+\d{4}\b/,/\b\d{4}s\b/,/\b\d{1,2}(st|nd|rd|th)\s+century\b/i],$r=/(youtube\.com|youtu\.be|vimeo\.com|wistia\.|loom\.com)/i;function ei(e,t){let n=r(e,`htmlBlock`),i=r(e,`htmlInline`),a=[],o=e=>{if(e.type===`htmlElement`){t.has(e.tagName.toLowerCase())&&a.push(e);for(let t of e.children)o(t)}};for(let e of n)for(let t of e.htmlChildren)o(t);for(let e of i)if(Array.isArray(e.htmlChildren))for(let t of e.htmlChildren)o(t);return a}function ti(e){if(!e||e.length===0)return{...Zr};let t=0,n=!1,a=!1,s=!1,c=[];for(let i of e)t+=r(i,`image`).length,t+=r(i,`imageReference`).length,r(i,`blockquote`).length>0&&(n=!0),r(i,`list`).length>0&&(a=!0),r(i,`table`).length>0&&(s=!0),c.push(o(i));let l={type:`document`,children:e},u=ei(l,new Set([`img`]));t+=u.length;let d=ei(l,new Set([`video`,`iframe`,`source`])),f=!1;for(let e of d){if(e.tagName.toLowerCase()===`video`){f=!0;break}let t=e.attributes.src||e.attributes.href||``;if($r.test(t)){f=!0;break}}if(!f){let e=r(l,`link`);for(let t of e)if(t.url&&$r.test(t.url)){f=!0;break}}let p=c.join(` `).trim(),m=p?p.split(/\s+/).length:0,h=!1;for(let e of Qr)if(e.test(p)){h=!0;break}let g=!1;i(l,e=>{if(g)return!0;if(e.type!==`paragraph`)return;let t=o(e).trim();return!t||!Xr(t)||t.split(/\s+/).length<=8&&(g=!0),!0});let _=!1,v=[];for(let t of e)v.push(...r(t,`code`));if(v.length===1&&nn(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=rn(v[0].lang);e<=400&&an(v[0].value,{explicit:t}).isDiagram&&(_=!0)}let y=!1;if(!_&&v.length===1&&gr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=_r(v[0].lang);e<=400&&vr(v[0].value,{explicit:t}).isTimeline&&(y=!0)}let b=!1;if(!_&&!y&&v.length===1&&Wr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Gr(v[0].lang);e<=400&&Kr(v[0].value,{explicit:t}).isTree&&(b=!0)}return{hasImage:t>0,imageCount:t,hasVideo:f,hasBlockquote:n,hasList:a,hasTable:s,hasDate:h,hasNumberHighlight:g,wordCount:m,hasAsciiDiagram:_,hasTimeline:y,hasTree:b}}var ni=[`title`,`sectionHeader`,`factCard`,`twoColumn`];function ri(e){let t=new Set,n=!1;if(e.hasAsciiDiagram&&(n=!0,t.add(`diagram`)),e.hasTimeline&&(n=!0,t.add(`timeline`)),e.hasTree&&(n=!0,t.add(`tree`)),e.hasImage&&(n=!0,t.add(`imageWithCaption`),t.add(`leftFeature`),t.add(`rightFeature`),e.imageCount>=2&&t.add(`photoGrid`)),e.hasVideo&&(n=!0,t.add(`videoWithCaption`),e.hasBlockquote&&t.add(`videoPullQuote`)),e.hasBlockquote&&(n=!0,t.add(`quote`),t.add(`pullQuote`),t.add(`fullBleedQuote`)),e.hasList&&(n=!0,t.add(`list`)),e.hasTable&&(n=!0,t.add(`dataTable`),t.add(`comparisonBar`),t.add(`columnChart`),t.add(`barChart`),t.add(`lineChart`),t.add(`pieChart`)),e.hasDate&&(n=!0,t.add(`dateEvent`)),e.hasNumberHighlight&&(n=!0,t.add(`statHighlight`)),n)t.add(`title`),t.add(`sectionHeader`);else for(let e of ni)t.add(e);return Array.from(t)}function ii(e,t=0){if(e.hasAsciiDiagram)return`diagram`;if(e.hasTimeline)return`timeline`;if(e.hasTree)return`tree`;if(e.hasTable)return`dataTable`;if(e.hasVideo)return`videoWithCaption`;if(e.imageCount>=2)return`photoGrid`;if(e.hasImage)return t%2==0?`leftFeature`:`rightFeature`;if(e.hasBlockquote)return`quote`;if(e.hasNumberHighlight)return`statHighlight`;if(e.hasList)return`list`}function ai(e,t){let n=new Set(ri(e)),r=[],i=[];for(let e of t)n.has(e)?r.push(e):i.push(e);return{recommended:r,rest:i}}var oi=200;function si(e,t){let n=t?.wordsPerMinute,r=typeof n==`number`&&n>0?n:oi,i=e.split(/\s+/).filter(e=>e.length>0).length,a=i/r;return{words:i,minutes:a,seconds:Math.round(a*60)}}var ci={"dark-vignette":`radial-gradient(ellipse at center, rgba(26,32,44,0.8) 0%, rgba(0,0,0,0.95) 100%)`,"radial-dark":`radial-gradient(ellipse at center, #1a202c 0%, #000000 100%)`,"warm-sunset":`linear-gradient(135deg, rgba(124,58,48,0.9) 0%, rgba(46,20,16,0.95) 100%)`,"cool-blue":`linear-gradient(135deg, rgba(26,54,93,0.9) 0%, rgba(26,32,44,0.95) 100%)`,"earth-tones":`linear-gradient(135deg, rgba(68,51,34,0.9) 0%, rgba(30,22,15,0.95) 100%)`};function li(e){return{type:`shape`,id:`persistent-bg-solid`,content:{shape:`rect`,fill:e.color},position:{x:0,y:0,width:`100%`,height:`100%`}}}function ui(e){return{type:`shape`,id:`persistent-bg-gradient`,content:{shape:`rect`,fill:e.gradient??ci[e.preset??`dark-vignette`]},position:{x:0,y:0,width:`100%`,height:`100%`}}}function di(e){let t=[],n=e.opacity??.4,r={type:`image`,id:`persistent-bg-image`,content:{src:e.src,alt:`Background`,fit:`cover`,...e.blur!=null&&e.blur>0?{blur:e.blur}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e.ambientMotion?{type:e.ambientMotion,duration:30}:void 0};return t.push(r),t.push({type:`shape`,id:`persistent-bg-overlay`,content:{shape:`rect`,fill:`rgba(0,0,0,${.5+(1-n)*.3})`},position:{x:0,y:0,width:`100%`,height:`100%`}}),t}function fi(e){if(e.pattern===`noise`)return{type:`shape`,id:`persistent-grain`,content:{shape:`rect`,fill:`#000000`,filter:{type:`noise`,opacity:e.opacity??.05}},position:{x:0,y:0,width:`100%`,height:`100%`}};let t=e.opacity??.06;return{type:`shape`,id:`persistent-bg-pattern`,content:{shape:`rect`,pattern:{kind:e.pattern,color:e.color??`#ffffff`,size:Math.round(24*(e.scale??1)),opacity:t}},position:{x:0,y:0,width:`100%`,height:`100%`}}}function pi(e){let t=Math.max(0,Math.min(1,e.strength??.3)),n=e.color??`#000000`,r=S(n,t);return{type:`shape`,id:`persistent-vignette`,content:{shape:`rect`,fill:`radial-gradient(ellipse at center, ${S(n,0)} 55%, ${r} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}}function mi(e,t){return{type:`shape`,id:`persistent-ambient-gradient`,content:{shape:`rect`,fill:`linear-gradient(150deg, ${e.from??t?.colors.backgroundLight??`#1a202c`} 0%, ${e.to??(t?y(t.colors.background,.04):`#0f141d`)} 100%)`},position:{x:`-5%`,y:`-5%`,width:`110%`,height:`110%`},animation:{type:`slowZoom`,panDirection:`left`,duration:e.duration??40}}}function hi(e){let t=[],n=e.fontSize??18,r=!!e.subtitle,i=e.position.includes(`bottom`),a=e.position.includes(`left`),o=1.5,s=r?`15%`:`7%`,c=i?r?`78%`:`84%`:`2%`,l=e.showThumbnail?30:28,u=a?3:97-l,d=`${u}%`,f=r?6:5,p=`${f}%`,m=r?`10%`:`5%`,h=u+o,g=l-o*2,_=e.showThumbnail&&a?`${h+f+o}%`:`${h}%`,v=e.showThumbnail?`${g-f-o}%`:`${g}%`,y=i?r?`80%`:`86%`:`4%`;if(t.push({type:`shape`,id:`persistent-caption-bg`,content:{shape:`rect`,fill:`rgba(0,0,0,0.6)`,borderRadius:8},position:{x:d,y:c,width:`${l}%`,height:s}}),e.showThumbnail&&e.thumbnailSrc){let n=a?`${h}%`:`${u+l-o-f}%`,s=i?r?`79.5%`:`85%`:`3%`;t.push({type:`image`,id:`persistent-caption-thumb`,content:{src:e.thumbnailSrc,alt:`Article thumbnail`,fit:`cover`},position:{x:n,y:s,width:p,height:m}})}if(t.push({type:`text`,id:`persistent-caption-title`,content:{text:e.title,style:{fontSize:n,fontWeight:`bold`,color:`rgba(255,255,255,0.9)`,textAlign:a?`left`:`right`,maxLines:1}},position:{x:_,y,width:v}}),r){let n=i?`85.5%`:`8%`;t.push({type:`text`,id:`persistent-caption-subtitle`,content:{text:e.subtitle,style:{fontSize:18,fontWeight:`normal`,color:`rgba(255,255,255,0.55)`,textAlign:a?`left`:`right`}},position:{x:_,y:n,width:v}})}return t}function gi(e){let t=e.position.includes(`bottom`),n=e.position.includes(`left`)?`3%`:`90%`,r=t?`94%`:`3%`;return e.isImage?{type:`image`,id:`persistent-branding`,content:{src:e.content,alt:`Branding`,fit:`contain`},position:{x:n,y:r,width:`8%`,height:`4%`}}:{type:`text`,id:`persistent-branding`,content:{text:e.content,style:{fontSize:14,fontWeight:`normal`,color:`rgba(255,255,255,0.6)`}},position:{x:n,y:r}}}function _i(e){let t=e.color??`rgba(255,255,255,0.3)`,n=e.position===`top`?`1%`:`98%`;return{type:`shape`,id:`persistent-progress`,content:{shape:`rect`,fill:t,borderRadius:2},position:{x:`5%`,y:n,width:`90%`,height:`0.5%`}}}function vi(e,t){if(!g(e))return[d(e)];let n=e.config;switch(n.type){case`solidBackground`:return[li(n)];case`gradientBackground`:return[ui(n)];case`imageBackground`:return di(n);case`patternBackground`:return[fi(n)];case`vignette`:return[pi(n)];case`ambientGradient`:return[mi(n,t)];case`titleCaption`:return hi(n);case`cornerBranding`:return[gi(n)];case`progressIndicator`:return[_i(n)];default:return console.warn(`Unknown persistent layer template:`,n.type),[]}}function yi(e,t){return!e||e.length===0?[]:e.reduce((e,n)=>e.concat(vi(n,t)),[])}function bi(e){return e.persistentLayers??{}}function xi(e,t){let n=e.persistentLayers;if(n&&((n.bottomLayers?.length??0)>0||(n.topLayers?.length??0)>0))return n;let r=t.persistentLayers;return r&&((r.bottomLayers?.length??0)>0||(r.topLayers?.length??0)>0)?r:n}function Si(e,t,n,r){if(n.length===0&&r.length===0)return e;let i=t.useBottomLayer!==!1,a=t.useTopLayer!==!1;return[...i?n.map(e=>d(e)):[],...e,...a?r.map(e=>d(e)):[]]}var Ci={bg:`#1a365d`,text:`#63b3ed`,accent:`#90cdf4`};function L(e,t){let n=e.theme.colorSchemes;if(t&&t in n)return n[t];let r=Object.keys(n);return r.length>0?n[r[0]]:Ci}var wi=`system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,Ti=`Georgia, "Times New Roman", serif`,Ei=`Consolas, "Courier New", monospace`;function R(e,t){let{typography:n}=e.theme;switch(t){case`title`:return C(n.titleFont,Ti);case`body`:return C(n.bodyFont,wi);case`mono`:return C(n.monoFont,Ei)}}function z(e,t,n=!1){let{fontScale:r,layout:i,theme:a}=t,o=n?i.titleScale:i.bodyScale,s=n?a.typography.titleScale??1:a.typography.bodyScale??1;return Math.round(e*r*o*s)}function Di(e,t){return e*(t.theme.style.animationSpeed??1)}function Oi(e,t){let n=e.theme.renderStyle;return t===`text`?n.defaultTextAnimation:n.defaultImageAnimation}function B(e,t,n){let r=Oi(e,t);return!r||r===`slowZoom`||r===n.type?n:{...n,type:r}}function V(e){return e.theme.style.textShadow??!0}function ki(e){return e.theme.style.overlayOpacity??.5}function H(e,t){if(t===`none`)return;let n=e.theme.style.imageTreatment,r=t?{type:t,strength:n?.strength}:n;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.theme.colors.primary}:r}function U(e,t=160){let{background:n,backgroundLight:r}=e.theme.colors;return`linear-gradient(${t}deg, ${r} 0%, ${y(n,.04)} 100%)`}function Ai(e,t){let n=t??Math.max(.55,ki(e));return S(e.theme.colors.background,n)}function ji(e,t,n,r){let i=e.theme.renderStyle.templateHints;if(!i)return r;let a=i[t];return!a||!(n in a)?r:a[n]}var Mi=/[.;:!?]+$/;function Ni(e){return e.replace(Mi,``).trim()}function Pi(e,t){return{type:`shape`,id:e,content:{shape:`rect`,fill:t},position:{x:0,y:0,width:`100%`,height:`100%`}}}function W(e,t,n,r){let i=t*.52,a=Math.max(8,Math.floor(n/i));return Math.max(1,Math.ceil(e.length/a))*t*r}function Fi(e,t){let{title:n,subtitle:r,backgroundColor:i}=e,{theme:a,layout:o,viewport:s}=t,c=z(96,t,!0),l=z(36,t,!1),u=i||a.colors.primary,d=parseFloat(o.maxTextWidth)/100*s.width,f=W(n,c,d,1.15),p=56+(Math.max(1,Math.round(f/(c*1.15)))>1?c*.25:0),m=r?42:48,h=e=>e/s.height*100,g=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:a.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${S(u,.32)} 0%, ${S(u,0)} 75%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(ji(t,`title`,`showAccentLine`,!0)&&g.push({type:`shape`,id:`accent-line`,content:{shape:`rect`,fill:S(a.colors.text,.3)},position:{x:`44%`,y:`${m-h(f/2+56)}%`,width:`12%`,height:`3px`}}),g.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:c,fontFamily:R(t,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:`${m}%`,anchor:`center`,width:o.maxTextWidth},animation:B(t,`text`,{type:`fadeIn`,duration:2})}),r){let e=W(r,l,d,1.5);g.push({type:`text`,id:`subtitle`,content:{text:r,style:{fontSize:l,fontFamily:R(t,`body`),color:a.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`${m+h(f/2+p+e/2)}%`,anchor:`center`,width:o.maxTextWidth},animation:{type:`fadeIn`,duration:1.5,delay:1}})}return g}var Ii=/^(\d+(?:\.\d+)?)\s*%?$/,Li={textCenterX:`50%`,textWidth:`85%`,textYAdjust:0,adjustY:!1};function Ri(e,t){if(!e)return;let n=t===void 0?{}:{duration:t};switch(e){case`zoomIn`:case`in`:return{type:`slowZoom`,direction:`in`,...n};case`zoomOut`:case`out`:return{type:`slowZoom`,direction:`out`,...n};case`panLeft`:case`left`:return{type:`slowZoom`,panDirection:`left`,...n};case`panRight`:case`right`:return{type:`slowZoom`,panDirection:`right`,...n};default:return}}var zi=35,Bi=`${zi}%`;function Vi(e){switch(e){case`left-strip`:return{textCenterX:`${50+zi/2}%`,textWidth:`${100-zi-8}%`,textYAdjust:0,adjustY:!1};case`right-strip`:return{textCenterX:`${50-zi/2}%`,textWidth:`${100-zi-8}%`,textYAdjust:0,adjustY:!1};case`bottom-strip`:return{textCenterX:`50%`,textWidth:`85%`,textYAdjust:-10,adjustY:!0};case`corner-inset`:return{textCenterX:`45%`,textWidth:`70%`,textYAdjust:0,adjustY:!1};default:return Li}}function Hi(e,t,n){let r=[],{src:i,alt:a,position:o,ambientMotion:s,credit:c,license:l}=e;switch(o){case`left-strip`:r.push(Ui(i,a,`left`,t,s,c,l,n)),r.push(Wi(`left`,t));break;case`right-strip`:r.push(Ui(i,a,`right`,t,s,c,l,n)),r.push(Wi(`right`,t));break;case`bottom-strip`:r.push(Gi(i,a,t,s,c,l,n)),r.push(Ki(t));break;case`corner-inset`:r.push(qi(i,a,t,s,c,l,n)),r.push(Ji(t));break}return r}function Ui(e,t,n,r,i,a,o,s){return{type:`image`,id:`${r}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:a,license:o,...s?{treatment:s}:{}},position:{x:n===`left`?0:`${100-zi}%`,y:0,width:Bi,height:`100%`},animation:Ri(i,15)}}function Wi(e,t){let n=e===`left`?`accent-gradient-left`:`accent-gradient-right`;return{type:`shape`,id:`${t}-accent-fade`,content:{shape:`rect`,fill:`url(#${n})`},position:{x:e===`left`?`${zi-8}%`:`${100-zi}%`,y:0,width:`10%`,height:`100%`}}}function Gi(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:0,y:`${100-zi}%`,width:`100%`,height:Bi},animation:Ri(r,15)}}function Ki(e){return{type:`shape`,id:`${e}-accent-fade`,content:{shape:`rect`,fill:`url(#accent-gradient-bottom)`},position:{x:0,y:`${100-zi-8}%`,width:`100%`,height:`12%`}}}function qi(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:`70%`,y:`60%`,width:`28%`,height:`38%`,anchor:`top-left`},animation:Ri(r,15)??{type:`fadeIn`,duration:2,delay:.5}}}function Ji(e){return{type:`shape`,id:`${e}-accent-vignette`,content:{shape:`rect`,fill:`url(#accent-vignette-corner)`,borderRadius:8},position:{x:`69%`,y:`59%`,width:`30%`,height:`40%`}}}function G(e,t){if(!t.adjustY||t.textYAdjust===0)return typeof e==`number`?`${e}%`:e;let n=typeof e==`number`?`${e}`:e,r=n.match(Ii);if(r){let e=parseFloat(r[1]);return`${Math.max(5,e+t.textYAdjust)}%`}return n}function Yi(e,t){let{title:n=``,colorScheme:r=`blue`,imageSrc:i,imageAlt:a,ambientMotion:o}=e,{theme:s,layout:c}=t,l=H(t,e.imageTreatment),u=L(t,r),d=z(84,t,!0),f=[];return i?(f.push({type:`image`,id:`bg-image`,content:{src:i,alt:a||n,fit:`cover`,...l?{treatment:l}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ri(o,8)??{type:`slowZoom`,duration:8,direction:`in`}}),f.push({type:`shape`,id:`overlay`,content:{shape:`rect`,fill:Ai(t)},position:{x:0,y:0,width:`100%`,height:`100%`}})):(f.push({type:`shape`,id:`bg`,content:{shape:`rect`,fill:u.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}),f.push({type:`shape`,id:`line-top`,content:{shape:`rect`,fill:S(u.text,.2)},position:{x:`50%`,y:`40%`,width:`20%`,height:`2px`,anchor:`center`}}),f.push({type:`shape`,id:`line-bottom`,content:{shape:`rect`,fill:S(u.text,.2)},position:{x:`50%`,y:`60%`,width:`20%`,height:`2px`,anchor:`center`}})),f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:d,fontFamily:R(t,`title`),fontWeight:`bold`,color:i?s.colors.text:u.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:c.maxTextWidth},animation:B(t,`text`,{type:`fadeIn`,duration:1.5})}),f}var Xi=1.05,Zi=.92,Qi=.86,$i=.62,ea=48;function ta(e,t){let n=1,r=0;for(let i of e){let e=r===0?i:r+1+i;e<=t?r=e:(n+=1,r=i)}return n}function na(e,t){let n=t.width*Zi,r=t.height*Qi,i=e.trim().split(/\s+/).filter(Boolean).map(e=>e.length);if(i.length===0)return Math.floor(r/Xi);let a=n/($i*Math.max(...i)),o=r/Xi,s=e=>{let t=Math.max(1,Math.floor(n/(e*$i)));return ta(i,t)*e*Xi<=r},c=ea,l=Math.min(a,o);if(l<=c)return Math.max(ea,Math.floor(l));if(!s(c))return ea;for(let e=0;e<24;e+=1){let e=(c+l)/2;s(e)?c=e:l=e}return Math.floor(c)}function ra(e){return`radial-gradient(ellipse at 50% 50%, ${S(e,.92)} 0%, ${S(e,.78)} 38%, ${S(e,.32)} 66%, ${S(e,0)} 88%)`}function ia(e,t){let{title:n=``,imageSrc:r,imageAlt:i,ambientMotion:a}=e,{theme:o,viewport:s}=t,c=H(t,e.imageTreatment),l=n.toUpperCase(),u=na(l,s),d=[];return r?d.push({type:`image`,id:`bigtext-image`,content:{src:r,alt:i||n,fit:`cover`,...c?{treatment:c}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ri(a,8)??{type:`slowZoom`,duration:8,direction:`in`}},{type:`shape`,id:`bigtext-bloom`,content:{shape:`rect`,fill:ra(o.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}}):d.push({type:`shape`,id:`bigtext-bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bigtext-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${S(o.colors.primary,.38)} 0%, ${S(o.colors.primary,.14)} 48%, ${S(o.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),d.push({type:`text`,id:`bigtext-title`,content:{text:l,style:{fontSize:u,fontFamily:R(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:Xi,shadow:!!r,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`${Zi*100}%`,height:`${Qi*100}%`},animation:B(t,`text`,{type:`fadeIn`,duration:1})}),d}function aa(e){return(e.block?.contents??[]).filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`)).map(e=>o(e)).join(`
|
|
17
|
-
`).trim()}function oa(e,t){return z(e.length>1800?18:e.length>1100?21:e.length>650?24:28,t,!1)}function sa(e,t){let{theme:n}=t,r=e.title??t.block?.title??``,i=aa(t),a=[Pi(`bg`,n.colors.background)];return r&&a.push({type:`text`,id:`title`,content:{text:r,style:{fontSize:z(46,t,!0),fontFamily:R(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`left`,lineHeight:1.15,shadow:V(t)}},position:{x:`8%`,y:`9%`,width:`84%`,height:`15%`,anchor:`top-left`}}),i&&a.push({type:`text`,id:`body`,content:{text:i,style:{fontSize:oa(i,t),fontFamily:R(t,`body`),color:n.colors.text,textAlign:`left`,lineHeight:1.35,shadow:V(t)}},position:{x:`8%`,y:r?`28%`:`10%`,width:`84%`,height:r?`64%`:`82%`,anchor:`top-left`}}),a}function ca(e,t){let{stat:n,description:r,detail:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=L(t,a),l=o?Vi(o.position):Li,u=z(148,t,!0),d=z(32,t,!1),f=z(26,t,!1),p=[Pi(`bg`,U(t,180))];return o&&p.push(...Hi(o,e.id,H(t,e.imageTreatment))),p.push({type:`text`,id:`stat`,content:{text:n,style:{fontSize:u,fontFamily:R(t,`title`),fontWeight:`bold`,color:c.text,shadow:V(t)}},position:{x:l.textCenterX,y:G(`36%`,l),anchor:`center`},animation:ji(t,`statHighlight`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.4}:{type:`zoomIn`,duration:.6}}),p.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:d,fontFamily:R(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:V(t)}},position:{x:l.textCenterX,y:G(`54%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:.3}}),i&&p.push({type:`text`,id:`detail`,content:{text:i,style:{fontSize:f,fontFamily:R(t,`body`),color:c.text,textAlign:`center`,shadow:V(t)}},position:{x:l.textCenterX,y:G(`66%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1}}),p}function la(e,t){let{title:n,quote:r,attribution:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Vi(a.position):Li,l=z(48,t,!0),u=z(34,t,!0),d=z(26,t,!1),f=Math.max(o.typography.titleLineHeight??1.4,1.25),p=z(280,t,!0),m=[Pi(`bg`,U(t,160))];a&&m.push(...Hi(a,e.id,H(t,e.imageTreatment))),n&&m.push({type:`text`,id:`quote-title`,content:{text:n,style:{fontSize:u,fontFamily:R(t,`body`),fontWeight:`bold`,color:o.colors.textMuted,textAlign:`center`,shadow:V(t)}},position:{x:c.textCenterX,y:G(`14%`,c),width:c.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),m.push({type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:p,fontFamily:R(t,`title`),color:S(o.colors.text,.09),textAlign:`center`}},position:{x:c.textCenterX,y:G(`26%`,c),anchor:`center`}});let h=i?45:n?52:50;if(m.push({type:`text`,id:`quote`,content:{text:r,style:{fontSize:l,fontFamily:R(t,`title`),color:o.colors.text,textAlign:`center`,lineHeight:f,shadow:V(t)}},position:{x:c.textCenterX,y:G(`${h}%`,c),anchor:`center`,width:c.textWidth},animation:B(t,`text`,{type:`fadeIn`,duration:2})}),i){let e=W(r,l,parseFloat(c.textWidth)/100*s.width,f),n=l*1.7,a=Math.min(82,h+(e/2+n)/s.height*100);m.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${i}`,style:{fontSize:d,fontFamily:R(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:V(t)}},position:{x:c.textCenterX,y:G(`${a}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return m}function ua(e,t){let{fact:n,explanation:r,source:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Vi(a.position):Li,l=z(56,t,!0),u=z(34,t,!1),d=z(20,t,!1),f=[Pi(`bg`,U(t,170))];a&&f.push(...Hi(a,e.id,H(t,e.imageTreatment)));let p=parseFloat(c.textWidth)/100*s.width,m=W(n,l,p,1.3),h=W(r,u,p,1.5),g=i?d*1.4:0,_=l*.9,v=i?u*1.1:0,y=47-(m+_+h+v+g)/2/s.height*100,b=e=>y+e/s.height*100,x=b(m/2),S=b(m+_+h/2),C=b(m+_+h+v+g/2);return f.push({type:`text`,id:`fact`,content:{text:n,style:{fontSize:l,fontFamily:R(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:1.3,shadow:V(t)}},position:{x:c.textCenterX,y:G(`${x}%`,c),width:c.textWidth,anchor:`center`},animation:B(t,`text`,{type:`fadeIn`,duration:1.5})}),f.push({type:`text`,id:`explanation`,content:{text:r,style:{fontSize:u,fontFamily:R(t,`body`),color:o.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:V(t)}},position:{x:c.textCenterX,y:G(`${S}%`,c),width:c.textWidth,anchor:`center`},animation:B(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&f.push({type:`text`,id:`source`,content:{text:i,style:{fontSize:d,fontFamily:R(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:V(t)}},position:{x:c.textCenterX,y:G(`${C}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),f}function da(e,t){let{left:n,right:r,header:i,leftColor:a=`green`,rightColor:o=`blue`}=e;if(!n?.label||!r?.label)return[];let{theme:s,layout:c,orientation:l}=t,u=L(t,a),d=L(t,o),f=h(l),p=c.stackColumns,m=p?`85%`:`42%`,g=z(36,t,!0),_=z(44,t,!0),v=z(22,t,!1),y=i&&!p?22:15,b=i&&!p?64:70,x=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:U(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(!p){let e=S(s.colors.text,.05);x.push({type:`shape`,id:`left-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`3%`,y:`${y}%`,width:`44%`,height:`${b}%`}}),x.push({type:`shape`,id:`right-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`53%`,y:`${y}%`,width:`44%`,height:`${b}%`}})}let C=p?`8%`:`12%`;i&&x.push({type:`text`,id:`header`,content:{text:i,style:{fontSize:g,fontFamily:R(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`}},position:{x:`50%`,y:C,anchor:`center`},animation:B(t,`text`,{type:`fadeIn`,duration:.8})});let w,T,E,D;if(p)w=i?`30%`:`25%`,T=i?`40%`:`35%`,E=i?`60%`:`55%`,D=i?`70%`:`65%`;else{let e=y+b/2;w=`${e-4}%`,T=`${e+7}%`,E=`${e-4}%`,D=`${e+7}%`}x.push({type:`text`,id:`left-label`,content:{text:n.label,style:{fontSize:_,fontFamily:R(t,`body`),fontWeight:`bold`,color:u.text,textAlign:`center`,lineHeight:1.3}},position:{x:f.left.x,y:w,anchor:`center`,width:m},animation:B(t,`text`,{type:`fadeIn`,duration:1})}),n.sublabel&&x.push({type:`text`,id:`left-sublabel`,content:{text:n.sublabel,style:{fontSize:v,fontFamily:R(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:f.left.x,y:T,anchor:`center`,width:m},animation:{type:`fadeIn`,duration:.8,delay:.3}});let O=z(64,t,!0),k=p?`48%`:`${y+b/2}%`,A=p?`↓`:`→`;return x.push({type:`text`,id:`connector`,content:{text:A,style:{fontSize:O,fontFamily:R(t,`title`),fontWeight:`bold`,color:S(s.colors.text,.45),textAlign:`center`}},position:{x:`50%`,y:k,anchor:`center`},animation:{type:`fadeIn`,duration:.6,delay:.4}}),x.push({type:`text`,id:`right-label`,content:{text:r.label,style:{fontSize:_,fontFamily:R(t,`body`),fontWeight:`bold`,color:d.text,textAlign:`center`,lineHeight:1.3}},position:{x:f.right.x,y:E,anchor:`center`,width:m},animation:B(t,`text`,{type:`fadeIn`,duration:1,delay:.5})}),r.sublabel&&x.push({type:`text`,id:`right-sublabel`,content:{text:r.sublabel,style:{fontSize:v,fontFamily:R(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:f.right.x,y:D,anchor:`center`,width:m},animation:{type:`fadeIn`,duration:.8,delay:.8}}),x}var fa={neutral:`#63b3ed`,somber:`#e53e3e`,celebratory:`#68d391`};function pa(e,t){let{date:n,description:r,footer:i,mood:a=`neutral`,accentImage:o}=e,{theme:s}=t,c=fa[a],l=b(s.colors.background)>.5?y(c,.25):c,u=o?Vi(o.position):Li,d=z(96,t,!0),f=z(30,t,!1),p=z(26,t,!1),m=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:U(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];return o&&m.push(...Hi(o,e.id,H(t,e.imageTreatment))),m.push({type:`text`,id:`date`,content:{text:n,style:{fontSize:d,fontFamily:R(t,`title`),fontWeight:`bold`,color:l,shadow:V(t)}},position:{x:u.textCenterX,y:G(`35%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1.5}}),m.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:f,fontFamily:R(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,shadow:V(t)}},position:{x:u.textCenterX,y:G(`58%`,u),width:u.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:2,delay:1}}),i&&m.push({type:`text`,id:`footer`,content:{text:i,style:{fontSize:p,fontFamily:R(t,`body`),color:s.colors.textMuted,shadow:V(t)}},position:{x:u.textCenterX,y:G(`72%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:3}}),m}function ma(e,t){let{imageSrc:n,imageAlt:r,caption:i,captionPosition:a=`bottom`,ambientMotion:o,isTitle:s,subtitle:c,imageCredit:l,imageLicense:u}=e,d=i&&Ni(i),{theme:f,layout:p}=t,m=H(t,e.imageTreatment),h=z(30,t,!1),g=z(96,t,!0),_=z(36,t,!1),v=e.kenBurns,y=Ri(o||v),b=[{type:`image`,id:`bg-image`,content:{src:n,alt:r,fit:`cover`,credit:l,license:u,...m?{treatment:m}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:y}],x=f.colors.background;if(s&&d)return b.push({type:`shape`,id:`title-gradient`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${S(x,.85)} 0%, ${S(x,.45)} 40%, ${S(x,.1)} 70%, ${S(x,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),b.push({type:`text`,id:`title`,content:{text:d,style:{fontSize:g,fontFamily:R(t,`title`),fontWeight:`bold`,color:f.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:c?`70%`:`75%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),c&&b.push({type:`text`,id:`subtitle`,content:{text:c,style:{fontSize:_,fontFamily:R(t,`body`),color:f.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`82%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),b;if(d){let e=a===`top`?`7%`:a===`center`?`42%`:`68%`,n=a===`top`?`13%`:a===`center`?`48%`:`74%`;b.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${S(x,0)}, ${S(x,.78)} 16%, ${S(x,.78)} 84%, ${S(x,0)})`},position:{x:0,y:e,width:`100%`,height:`16%`}}),b.push({type:`text`,id:`caption`,content:{text:d,style:{fontSize:h,fontFamily:R(t,`body`),color:f.colors.text,textAlign:`center`,shadow:V(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return b}function ha(e,t,n){let{imageSrc:r,imageAlt:i,imageWidth:a,imageHeight:o,title:s,body:c}=e,{theme:l,layout:u}=t,d=H(t,e.imageTreatment),f=(a??0)>0||(o??0)>0,p=u.stackColumns,m=z(48,t,!0),h=z(24,t,!1),g,_,v,y,b;p?(g=`0`,_=`0`,v=`100%`,y=`50%`,b=f?`contain`:`cover`):f?(g=`${n===`left`?5:55}%`,_=`5%`,v=`40%`,y=`90%`,b=`contain`):(g=n===`left`?`0`:`50%`,_=`0`,v=`50%`,y=`100%`,b=`cover`);let x=p?90:42,S=p?`${(100-x)/2}%`:n===`left`?`54%`:`6%`,C=p?`60%`:c?`42%`:`50%`,w=p?`78%`:s?`55%`:`50%`,T=`top-left`,E=`left`,D=[{type:`shape`,id:`feature-bg`,content:{shape:`rect`,fill:l.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}];return r&&D.push({type:`image`,id:`feature-image`,content:{src:r,alt:i??s??``,fit:b,...d?{treatment:d}:{}},position:{x:g,y:_,width:v,height:y}}),s&&D.push({type:`text`,id:`feature-title`,content:{text:s,style:{fontSize:m,fontFamily:R(t,`title`),fontWeight:`bold`,color:l.colors.text,textAlign:E,lineHeight:1.2}},position:{x:S,y:C,anchor:T,width:`${x}%`},animation:B(t,`text`,{type:`fadeIn`,duration:.8})}),c&&D.push({type:`text`,id:`feature-body`,content:{text:c,style:{fontSize:h,fontFamily:R(t,`body`),color:l.colors.textMuted,textAlign:E,lineHeight:1.5}},position:{x:S,y:w,anchor:T,width:`${x}%`},animation:B(t,`text`,{type:`fadeIn`,duration:.8,delay:.2})}),D}function ga(e,t){return ha(e,t,`left`)}function _a(e,t){return ha(e,t,`right`)}function va(e,t){let{center:n,zoom:r,mapStyle:i=`terrain`,title:a,caption:o,markers:s,ambientMotion:c,staticSrc:l}=e,{theme:u,layout:d}=t,f=z(64,t,!0),p=z(32,t,!1),m=Ri(c),h=[{type:`map`,id:`map-bg`,content:{center:n,zoom:r,style:i,markers:s,showAttribution:!0,staticSrc:l},position:{x:0,y:0,width:`100%`,height:`100%`},animation:m}],g=u.colors.background;return a&&(h.push({type:`shape`,id:`title-overlay`,content:{shape:`rect`,fill:`linear-gradient(180deg, ${S(g,.85)} 0%, ${S(g,.6)} 70%, ${S(g,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`title`,content:{text:a,style:{fontSize:f,fontFamily:R(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:`9%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.3}})),o&&(h.push({type:`shape`,id:`caption-overlay`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${S(g,.85)} 0%, ${S(g,.6)} 70%, ${S(g,0)} 100%)`},position:{x:0,y:`80%`,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`caption`,content:{text:o,style:{fontSize:p,fontFamily:R(t,`body`),color:u.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:d.captionY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.5}})),h}function ya(e,t){let{text:n,colorScheme:r=`blue`}=e,i=L(t,r),a=z(120,t,!0);return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${i.bg} 0%, ${y(i.bg,.12)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`impact-text`,content:{text:n,style:{fontSize:a,fontFamily:R(t,`title`),fontWeight:`bold`,color:i.text,textAlign:`center`,lineHeight:1.2,shadow:V(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`85%`},animation:ji(t,`fullBleedQuote`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.8}:{type:`fadeIn`,duration:1.5}}]}var ba={gapX:260,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80};function xa(e,t={}){let n={...ba,...t},r=[],i=[],a=[];for(let t=0;t<e.length;t++){let n=e[t],r=typeof n.x==`number`,o=typeof n.y==`number`;r&&o?i.push({child:n,pinned:!0,x:n.x,y:n.y}):(i.push({child:n,pinned:!1,x:0,y:0}),a.push(t))}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=n.gridOriginX,r=n.gridOriginY,o=i.filter(e=>e.pinned);if(o.length>0){let e=Math.min(...o.map(e=>e.x)),i=Math.max(...o.map(e=>e.y));t=e,r=i+n.gridPad+n.gapY}a.forEach((a,o)=>{let s=o%e,c=Math.floor(o/e);i[a].x=t+s*n.gapX,i[a].y=r+c*n.gapY})}let o=i.map(e=>({id:e.child.id,label:e.child.title??e.child.id,x:e.x,y:e.y,pinned:e.pinned,...e.child.classes&&e.child.classes.length>0?{classes:e.child.classes}:{}})),s=new Set(o.map(e=>e.id)),c=[],l=new Set;for(let t of e)if(t.connectsTo)for(let e of t.connectsTo){if(!s.has(e.target)){r.push(`Edge from "${t.id}" to "${e.target}" dropped: no such sibling node`);continue}let n=Sa(t.id,e);l.has(n)||(l.add(n),c.push({id:n,source:t.id,target:e.target,...e.type?{type:e.type}:{}}))}return{nodes:o,edges:c,warnings:r}}function Sa(e,t){return t.type?`${e}->${t.target}:${t.type}`:`${e}->${t.target}`}var Ca=14,wa=28;function Ta(e,t){return{x:e*14,y:t*28}}function Ea(e,t){return{col:Math.max(0,Math.round(e/14)),row:Math.max(0,Math.round(t/28))}}function Da(e){let t=e.nodes.map(e=>({id:e.id,label:e.label,...Ta(e.col,e.row),w:e.wCols*14,h:e.hRows*28,...e.containerId?{container:e.containerId}:{}})),n=Oa(t,e.edges);return{nodes:t,edges:e.edges.map((e,t)=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.directed?{}:{directed:!1},...n[t],routing:`orthogonal`}))}}function Oa(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.source),r=n.get(e.target);if(!t||!r)return{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}};let i=t.w??168,a=t.h??84,o=r.w??168,s=r.h??84,c=r.x+o/2-(t.x+i/2),l=r.y+s/2-(t.y+a/2),u=Math.abs(c)/Math.max(1,(i+o)/2);return Math.abs(l)/Math.max(1,(a+s)/2)>=u?l>=0?{sourceAnchor:{side:`bottom`,offset:.5},targetAnchor:{side:`top`,offset:.5}}:{sourceAnchor:{side:`top`,offset:.5},targetAnchor:{side:`bottom`,offset:.5}}:c>=0?{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}}:{sourceAnchor:{side:`left`,offset:.5},targetAnchor:{side:`right`,offset:.5}}});return Aa(r,t,e,`source`),Aa(r,t,e,`target`),ka(r,t,e),r}function ka(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map;t.forEach((e,t)=>{let n=i.get(e.source)??[];n.push(t),i.set(e.source,n)});for(let[n,a]of i){if(a.length<2)continue;let i=r.get(n),o=a.map(e=>r.get(t[e].target)).filter(e=>e!==void 0);if(!i||o.length!==a.length)continue;let s=i.w??168,c=i.h??84,l=i.x+s,u=i.y+c,d=e=>e.x+(e.w??168),f=e=>e.y+(e.h??84),p,m;if(o.every(e=>e.y>=u)?(p=`bottom`,m=`top`):o.every(e=>f(e)<=i.y)?(p=`top`,m=`bottom`):o.every(e=>e.x>=l)?(p=`right`,m=`left`):o.every(e=>d(e)<=i.x)&&(p=`left`,m=`right`),!(!p||!m))for(let t of a)e[t]={sourceAnchor:{side:p,offset:.5},targetAnchor:{side:m,offset:.5}}}}function Aa(e,t,n,r){let i=new Map(n.map(e=>[e.id,e])),a=new Map;for(let n=0;n<t.length;n++){let i=t[n],o=r===`source`?e[n].sourceAnchor:e[n].targetAnchor,s=`${r===`source`?i.source:i.target}:${o.side}`,c=a.get(s)??[];c.push(n),a.set(s,c)}for(let n of a.values()){if(n.length<2)continue;let a=r===`source`?e[n[0]].sourceAnchor.side:e[n[0]].targetAnchor.side;n.sort((e,n)=>{let o=i.get(r===`source`?t[e].target:t[e].source),s=i.get(r===`source`?t[n].target:t[n].source);return(a===`top`||a===`bottom`?o?.x??0:o?.y??0)-(a===`top`||a===`bottom`?s?.x??0:s?.y??0)||e-n}),n.forEach((t,i)=>{let a=r===`source`?e[t].sourceAnchor:e[t].targetAnchor;a.offset=(i+1)/(n.length+1)})}}function ja(e,t,n={}){let r=new Set(e.map(e=>e.id));return{nodes:e.map(e=>{let{col:t,row:n}=Ea(e.x,e.y),i=e.label.length>0?e.label.split(`
|
|
18
|
-
`):[],a=i.reduce((e,t)=>Math.max(e,t.length),0),o=typeof e.w==`number`?Math.max(3,Math.round(e.w/14)):a+4,s=typeof e.h==`number`?Math.max(3,Math.round(e.h/28)):i.length+2;return{id:e.id,label:e.label,col:t,row:n,wCols:Math.max(o,3),hRows:Math.max(s,3),...e.container&&r.has(e.container)&&e.container!==e.id?{containerId:e.container}:{}}}),edges:t.filter(e=>r.has(e.source)&&r.has(e.target)).map(e=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},directed:e.directed!==!1})),style:n.style??`unicode`,warnings:[]}}function
|
|
19
|
-
`).trim()}function
|
|
20
|
-
`).trim():``}function io(e,t,n){let r=eo(t);if(r){let n=o(r.node).trim(),i=to(r.node);if(i){let a=n.indexOf(i);return{stat:i,description:ro(t,r.index,n,a,a+i.length)||e||i}}}let i=e.trim(),a=Xr(i);if(a&&a.index===0&&a.end===i.length)return{stat:e,description:n||e};if(r){let n=o(r.node).trim(),i=Xr(n);if(i){let a=ro(t,r.index,n,i.index,i.end);return{stat:i.value,description:a||e||i.value}}}return{stat:e,description:n||e}}function ao(e){return e.replace(/\s+/g,` `).trim()}function oo(e,t){let n=t??[];switch(e){case`quote`:return n.length===1&&n[0]?.type===`blockquote`;case`dataTable`:return n.length===1&&n[0]?.type===`table`;case`list`:return n.length===1&&n[0]?.type===`list`;case`diagram`:case`timeline`:return n.length===1&&n[0]?.type===`code`;case`tree`:return n.length===1&&(n[0]?.type===`code`||n[0]?.type===`list`);case`photoGrid`:{let e=Ja(n);if(e.length<2||e.length>4)return!1;let t=ao(Ha(n)),r=ao(e.map(e=>e.alt).filter(Boolean).join(` `));return t===``||t===r}case`videoWithCaption`:{let e=Xa(n);return e.length===1&&ao(Ha(n))===ao(e[0]?.alt??``)}case`leftFeature`:case`rightFeature`:case`statHighlight`:return!0;default:return!1}}function so(e,t,n,r={}){let i=r.placeholders===!0,a=Ha(n);switch(e){case`statHighlight`:{let e=io(t,n,a);return r.preserveSourceHeading&&t&&e.stat!==t&&e.description!==t?{...e,description:t,...e.description?{detail:e.description}:{}}:e}case`quote`:{let e=$a(n)||a;return e?{quote:e,...t?{title:t}:{}}:{quote:t}}case`fullBleedQuote`:case`pullQuote`:return{text:$a(n)||a||t};case`factCard`:return{fact:t,explanation:a||t};case`comparisonBar`:return i?{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40}:null;case`list`:{let e=Ua(n);return e.length>0?{items:e,...t?{title:t}:{}}:i?{items:[`Item 1`,`Item 2`,`Item 3`]}:null}case`definitionCard`:return{term:t,definition:a||t};case`dateEvent`:return{date:t,description:a||t};case`dataTable`:{let e=Qa(n);return e?{...e,...t?{title:t}:{}}:i?{headers:[`Column`],rows:[[`Data`]]}:null}case`barChart`:case`columnChart`:case`pieChart`:case`donutChart`:case`lineChart`:case`areaChart`:case`scatterChart`:{let e=Qa(n);return e?{headers:e.headers,rows:e.rows,...t?{title:t}:{}}:i&&!a.trim()?{headers:[`Quarter`,`Revenue`,`Costs`],rows:[[`Q1`,`40`,`28`],[`Q2`,`55`,`31`],[`Q3`,`48`,`30`],[`Q4`,`62`,`35`]],...t?{title:t}:{}}:null}case`imageWithCaption`:{let e=Ya(n);return e?{imageSrc:e.src,imageAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`bigText`:{let e=Ya(n);return{title:t,...e?{imageSrc:e.src,imageAlt:e.alt||t}:{}}}case`photoGrid`:{let e=Ja(n,4);return e.length<2?i?{}:null:{images:e.map(e=>({src:e.src,alt:e.alt})),caption:t}}case`videoWithCaption`:{let e=Za(n);return e?{videoSrc:e.src,posterSrc:e.posterSrc,videoAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`leftFeature`:case`rightFeature`:{let e=Ya(n);return!e&&!i?null:{imageSrc:e?.src??``,imageAlt:e?.alt||t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:a}}case`diagram`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&nn(e[0].lang)?e[0]:void 0,a=r?an(r.value,{explicit:rn(r.lang)}):void 0;if(!a?.isDiagram||!a.diagram)return i?{}:null;let{nodes:o,edges:s}=Da(a.diagram);return{nodes:o,edges:s,...t?{title:t}:{}}}case`timeline`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&gr(e[0].lang)?e[0]:void 0,a=r?vr(r.value,{explicit:!0}):void 0;if(!a?.isTimeline||!a.timeline)return i?{}:null;let{tracks:o,links:s}=Na(a.timeline);return{tracks:o,links:s,...t?{title:t}:{}}}case`tree`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&Wr(e[0].lang)?e[0]:void 0;if(r){let e=Kr(r.value,{explicit:Gr(r.lang)});if(e.isTree&&e.tree){let{items:n}=Fa(e.tree);return{items:n,...t?{title:t}:{}}}}let a=Ba(n);if(a){let{items:e}=Fa(za(a));if(e.length>0)return{items:e,...t?{title:t}:{}}}return i?{}:null}default:return i?{}:null}}var co=1.2,lo=18;function uo(e,t,n){if(!e.trim())return 1;let r=Math.floor(n/(t*.5));if(r<=0)return 1;let i=0,a=0;for(let t of e.split(/\s+/)){let e=a?a+1+t.length:t.length;if(e<=r){a=e;continue}a&&(i+=1);let n=t.length;for(;n>r;)i+=1,n-=r;a=n}return Math.max(1,i+ +!!a)}function fo(e,t){let{title:n,accentImage:r}=e,i=Array.isArray(e.items)?e.items:[],a=Ka(t.block?.contents),{theme:o}=t,s=r?Vi(r.position):Li,c=z(44,t,!0),l=z(34,t,!1),u=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`linear-gradient(155deg, ${o.colors.backgroundLight} 0%, ${o.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];r&&u.push(...Hi(r,e.id,H(t,e.imageTreatment)));let d=parseFloat(s.textCenterX),f=parseFloat(s.textWidth),p=Number.isFinite(d)&&Number.isFinite(f)?d-f/2:8,m=`${p}%`,h=n?34:26;n&&u.push({type:`text`,id:`list-title`,content:{text:n,style:{fontSize:c,fontFamily:R(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`left`,shadow:V(t)}},position:{x:m,y:G(`20%`,s),width:s.textWidth},animation:B(t,`text`,{type:`fadeIn`,duration:1})});let g=(Number.isFinite(f)?f/100:.85)*t.viewport.width,_=`${i.length}.`,v=Math.max(l,_.length*l*.5),y=v+l*.35,b=`${p+y/t.viewport.width*100}%`,x=Math.max(l,g-y),S=h;for(let e=0;e<i.length;e++){let n=i[e],r=a[e]?.text===n?a[e]?.html:void 0,c=uo(n,l,x),d=B(t,`text`,{type:`fadeIn`,duration:.8,delay:.3+.3*e});u.push({type:`text`,id:`item-${e}-marker`,content:{text:`${e+1}.`,style:{fontSize:l,fontFamily:R(t,`body`),color:o.colors.text,textAlign:`right`,lineHeight:co,shadow:V(t)}},position:{x:m,y:G(`${S}%`,s),width:v},animation:d}),u.push({type:`text`,id:`item-${e}`,content:{text:n,...r?{html:r}:{},style:{fontSize:l,fontFamily:R(t,`body`),color:o.colors.text,textAlign:`left`,lineHeight:co,shadow:V(t)}},position:{x:b,y:G(`${S}%`,s),width:x},animation:d});let f=c*l*co;S+=(f+lo)/t.viewport.height*100}return u}var q=1.2;function po(e,t){let{images:n,caption:r,ambientMotion:i}=e;if(!n||n.length===0)return[];let a=r&&Ni(r),{theme:o,layout:s}=t,c=H(t,e.imageTreatment),l=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}],u=mo(n.length,100,s.stackColumns);for(let e=0;e<Math.min(n.length,4);e++){let t=n[e],r=u[e];l.push({type:`shape`,id:`grid-placeholder-${e}`,content:{shape:`rect`,fill:o.colors.background},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`}}),l.push({type:`image`,id:`grid-img-${e}`,content:{src:t.src,alt:t.alt,fit:`cover`,credit:t.credit,license:t.license,...c?{treatment:c}:{}},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`},animation:e===0&&i?{type:i,duration:15}:{type:`fadeIn`,duration:1,delay:.2*e}})}if(a){let e=z(s.stackColumns?24:26,t,!1),n=s.stackColumns?`78%`:`74%`,r=s.stackColumns?`72%`:`68%`,i=s.stackColumns?`13%`:`16%`,c=o.colors.background;l.push({type:`shape`,id:`caption-bg`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${S(c,0)}, ${S(c,.78)} 16%, ${S(c,.78)} 84%, ${S(c,0)})`},position:{x:0,y:r,width:`100%`,height:i}}),l.push({type:`text`,id:`caption`,content:{text:a,style:{fontSize:e,fontFamily:R(t,`body`),color:o.colors.text,textAlign:`center`,shadow:!0,lineHeight:1.18,maxLines:s.stackColumns?2:1}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1,delay:.5}})}return l}function mo(e,t,n){let r=50-q/2,i=t/2-q/2;switch(e){case 1:return[{x:0,y:0,w:100,h:t}];case 2:return n?[{x:0,y:0,w:100,h:i},{x:0,y:t/2+q/2,w:100,h:i}]:[{x:0,y:0,w:r,h:t},{x:50+q/2,y:0,w:r,h:t}];case 3:{if(n){let e=t/3-q*2/3;return[{x:0,y:0,w:100,h:e},{x:0,y:t/3+q/3,w:100,h:e},{x:0,y:t*2/3+q*2/3,w:100,h:e}]}let e=60-q/2,r=40-q/2;return[{x:0,y:0,w:e,h:t},{x:60+q/2,y:0,w:r,h:i},{x:60+q/2,y:t/2+q/2,w:r,h:i}]}default:return[{x:0,y:0,w:r,h:i},{x:50+q/2,y:0,w:r,h:i},{x:0,y:t/2+q/2,w:r,h:i},{x:50+q/2,y:t/2+q/2,w:r,h:i}]}}function ho(e,t){let{term:n,definition:r,origin:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=L(t,a),l=o?Vi(o.position):Li,u=z(72,t,!0),d=z(32,t,!1),f=z(22,t,!1),p=[Pi(`bg`,U(t,145))];return o&&p.push(...Hi(o,e.id,H(t,e.imageTreatment))),p.push({type:`text`,id:`term`,content:{text:n,style:{fontSize:u,fontFamily:R(t,`title`),fontWeight:`bold`,color:c.text,textAlign:`center`,shadow:V(t)}},position:{x:l.textCenterX,y:G(`30%`,l),anchor:`center`},animation:B(t,`text`,{type:`fadeIn`,duration:1.5})}),p.push({type:`shape`,id:`separator`,content:{shape:`rect`,fill:`${c.text}33`},position:{x:l.textCenterX,y:G(`42%`,l),width:`30%`,height:`2px`,anchor:`center`}}),p.push({type:`text`,id:`definition`,content:{text:r,style:{fontSize:d,fontFamily:R(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,maxLines:4,shadow:V(t)}},position:{x:l.textCenterX,y:G(`55%`,l),width:l.textWidth,anchor:`center`},animation:B(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&p.push({type:`text`,id:`origin`,content:{text:i,style:{fontSize:f,fontFamily:R(t,`body`),color:s.colors.textMuted,textAlign:`center`,shadow:V(t)}},position:{x:l.textCenterX,y:G(`70%`,l),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),p}function go(e,t){let{leftLabel:n,rightLabel:r,unit:i,colorScheme:a=`blue`}=e,{theme:o,viewport:s}=t,c=L(t,a),l=Number.isFinite(e.leftValue)?e.leftValue:0,u=Number.isFinite(e.rightValue)?e.rightValue:0,d=z(28,t,!1),f=z(48,t,!0),p=e=>Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:e.toLocaleString():`—`,m=i?`${p(l)} ${i}`:p(l),h=i?`${p(u)} ${i}`:p(u),g=Math.max(0,l),_=Math.max(0,u),v=Math.max(g,_,1),y=Math.max(m.length,h.length)*f*.58/s.width*100,b=Math.max(20,Math.min(65,81-y-2)),x=g/v*b,S=_/v*b;return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:U(t,180)},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`left-label`,content:{text:n,style:{fontSize:d,fontFamily:R(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`28%`}},{type:`text`,id:`left-value`,content:{text:m,style:{fontSize:f,fontFamily:R(t,`body`),fontWeight:`bold`,color:c.text}},position:{x:`${15+x+2}%`,y:`35%`},animation:{type:`fadeIn`,duration:.8,delay:.3}},{type:`shape`,id:`left-bar`,content:{shape:`rect`,fill:c.text,borderRadius:4},position:{x:`15%`,y:`36%`,width:`${x}%`,height:`6%`},animation:{type:`fadeIn`,duration:1}},{type:`text`,id:`right-label`,content:{text:r,style:{fontSize:d,fontFamily:R(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`50%`}},{type:`text`,id:`right-value`,content:{text:h,style:{fontSize:f,fontFamily:R(t,`body`),fontWeight:`bold`,color:c.accent}},position:{x:`${15+S+2}%`,y:`57%`},animation:{type:`fadeIn`,duration:.8,delay:.6}},{type:`shape`,id:`right-bar`,content:{shape:`rect`,fill:c.accent,borderRadius:4},position:{x:`15%`,y:`58%`,width:`${S}%`,height:`6%`},animation:{type:`fadeIn`,duration:1,delay:.3}}]}function _o(e,t){let{text:n,attribution:r,backgroundImage:i,ambientMotion:a}=e,{viewport:o}=t,s=H(t,e.imageTreatment);if(!i?.src)return[];let c=z(52,t,!0),l=z(26,t,!1),u=z(200,t,!0),d=1.4,f=r?45:50,p=[{type:`image`,id:`bg-image`,content:{src:i.src,alt:i.alt,fit:`cover`,credit:i.credit,license:i.license,...s?{treatment:s}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ri(a,15)},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:u,fontFamily:R(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:c,fontFamily:R(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:d,shadow:!0}},position:{x:`50%`,y:`${f}%`,anchor:`center`,width:`72%`},animation:B(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=W(n,c,.72*o.width,d),i=Math.min(82,f+(e/2+c*1.7)/o.height*100);p.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:l,fontFamily:R(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return p}function vo(e,t){let{videoSrc:n,posterSrc:r,videoAlt:i,clipStart:a=0,clipEnd:o,sourceDuration:s,caption:c,captionPosition:l=`bottom`,videoCredit:u,videoLicense:d}=e,f=c&&Ni(c),{theme:p}=t,m=Math.max(a,o??a+Math.max(0,e.duration)),h=z(30,t,!1),g=z(16,t,!1),_=[{type:`video`,id:`bg-video`,content:{src:n,posterSrc:r,alt:i,fit:`cover`,clipStart:a,clipEnd:m,sourceDuration:s,credit:u,license:d},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(f){let e=p.colors.background,n=l===`top`?`7%`:l===`center`?`42%`:`68%`,r=l===`top`?`13%`:l===`center`?`48%`:`74%`;_.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${S(e,0)}, ${S(e,.78)} 16%, ${S(e,.78)} 84%, ${S(e,0)})`},position:{x:0,y:n,width:`100%`,height:`16%`}}),_.push({type:`text`,id:`caption`,content:{text:f,style:{fontSize:h,fontFamily:R(t,`body`),color:p.colors.text,textAlign:`center`,shadow:V(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:r,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return u&&_.push({type:`text`,id:`credit`,content:{text:u,style:{fontSize:g,fontFamily:R(t,`body`),color:S(p.colors.text,.65),textAlign:`right`}},position:{x:`96%`,y:`96%`,anchor:`bottom-right`}}),_}function yo(e,t){let{text:n,attribution:r,backgroundVideo:i}=e,{viewport:a}=t;if(!i?.src)return[];let o=z(52,t,!0),s=z(26,t,!1),c=z(200,t,!0),l=1.4,u=r?45:50,d=[{type:`video`,id:`bg-video`,content:{src:i.src,posterSrc:i.posterSrc,alt:i.alt,fit:`cover`,clipStart:i.clipStart,clipEnd:i.clipEnd,credit:i.credit,license:i.license},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:c,fontFamily:R(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:o,fontFamily:R(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:l,shadow:!0}},position:{x:`50%`,y:`${u}%`,anchor:`center`,width:`72%`},animation:B(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=W(n,o,.72*a.width,l),i=Math.min(82,u+(e/2+o*1.7)/a.height*100);d.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:s,fontFamily:R(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return d}function bo(e,t){let{title:n,headers:r,rows:i,align:a,colorScheme:o}=e,{theme:s,viewport:c}=t,l=L(t,o),u=z(48,t,!0),d=z(28,t,!1),f=[Pi(`bg`,U(t,170))],p=(Array.isArray(i)?i.length:0)+1,m=Math.min(74,p*d*2.4/c.height*100),h=n?u*2.2*100/c.height:0,g=Math.max(8,(100-h-m)/2);return n&&f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:u,fontFamily:R(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:`${g+h/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),f.push({type:`table`,id:`table`,content:{headers:r,rows:i,align:a,style:{headerBackground:l.accent,headerColor:x(l.accent),cellBackground:S(s.colors.text,.04),cellColor:s.colors.text,borderColor:S(s.colors.text,.15),fontSize:d,fontFamily:R(t,`body`),headerFontFamily:R(t,`title`),borderRadius:8}},position:{x:`10%`,y:`${g+h}%`,width:`80%`,height:`${m}%`},animation:{type:`fadeIn`,duration:1,delay:n?.4:0}}),f}var xo=1.25;function So(e,t,n,r){let i=Math.max(1,t-24),a=Math.max(1,n-16),o=Math.max(10,Math.floor(r)),s=Co(e,o,i);for(;o>10&&s*o*1.25>a;)o--,s=Co(e,o,i);return{fontSize:o,lineCount:s,firstLineOffset:s===1?0:-((s-1)*o*xo)/2,textWidth:i}}function Co(e,t,n){return e.split(`
|
|
21
|
-
`).reduce((e,r)=>e+
|
|
22
|
-
`)[0]??``,style:{fontSize:i,fontFamily:R(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`center`}},position:{x:r.x+r.w/2,y:r.y+i,anchor:`center`,width:r.w}};T.push(a)}return T}function jo(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(typeof e.label!=`string`)continue;let r=jo(e.children);t.push({id:typeof e.id==`string`&&e.id?e.id:Mo(e.label),label:e.label,children:r,...e.isDir===!0||r.length>0?{isDir:!0}:{},...typeof e.comment==`string`&&e.comment?{comment:e.comment}:{}})}return t}function Mo(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function No(e,t){let{theme:n,viewport:r}=t,i=L(t,e.colorScheme),a=jo(e.items),o=z(48,t,!0),s=z(28,t,!1),c=[Pi(`bg`,U(t,170))];if(a.length===0)return c.push({type:`text`,id:`tree-empty`,content:{text:e.title??`Empty tree`,style:{fontSize:o,fontFamily:R(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}),c;let l=e.title?o*2.2*100/r.height:0;return e.title&&c.push({type:`text`,id:`title`,content:{text:e.title,style:{fontSize:o,fontFamily:R(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:`${8+l/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),c.push({type:`tree`,id:`tree`,content:{items:a,style:{rowColor:n.colors.text,dirColor:i.accent??n.colors.primary,connectorColor:S(n.colors.text,.25),iconColor:i.accent??n.colors.primary,commentColor:n.colors.textMuted,fontSize:s,fontFamily:R(t,`body`),monoFontFamily:R(t,`mono`),indentPx:Math.round(s*1.4)}},position:{x:`10%`,y:`${8+l}%`,width:`80%`,height:`${Math.max(60,90-l)}%`},animation:{type:`fadeIn`,duration:1,delay:e.title?.4:0}}),c}var Po=e=>Math.max(0,Math.min(1,e)),Fo=(e,t,n)=>Math.max(t,Math.min(n,e));function Io(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)||`item`}function Lo(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e!=`object`||!e)return;let r=e,i=typeof r.id==`string`&&r.id.trim()?r.id.trim():`track-${n+1}`,a=[];Array.isArray(r.events)&&r.events.forEach((e,t)=>{if(typeof e!=`object`||!e)return;let n=e;if(typeof n.label!=`string`)return;let r=typeof n.position==`number`?n.position:Number(n.position);if(!Number.isFinite(r))return;let o=typeof n.id==`string`&&n.id.trim()?n.id.trim():`${i}-event-${t+1}`,s=n.side===`above`||n.side===`below`?n.side:void 0,c=n.descriptionSide===`above`||n.descriptionSide===`below`?n.descriptionSide:void 0,l=n.marker===`filled`||n.marker===`hollow`||n.marker===`diamond`?n.marker:void 0;a.push({id:o,label:n.label,position:Po(r),...typeof n.description==`string`&&n.description.trim()?{description:n.description.trim()}:{},...s?{side:s}:{},...c?{descriptionSide:c}:{},...n.callout===!1?{callout:!1}:{},...l?{marker:l}:{}})}),t.push({id:i,...typeof r.label==`string`&&r.label.trim()?{label:r.label.trim()}:{},...typeof r.endLabel==`string`&&r.endLabel.trim()?{endLabel:r.endLabel.trim()}:{},events:a})}),t}function Ro(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r;typeof e.source!=`string`||typeof e.target!=`string`||!t.has(e.source)||!t.has(e.target)||e.source===e.target||n.push({source:e.source,target:e.target,...typeof e.label==`string`&&e.label.trim()?{label:e.label.trim()}:{}})}return n}function zo(e,t,n,r,i,a){return{type:`path`,id:e,content:{d:`M ${t} ${n-r} L ${t+r} ${n} L ${t} ${n+r} L ${t-r} ${n} Z`,fill:i,stroke:i,strokeWidth:2},position:{x:t-r,y:n-r,width:r*2,height:r*2},animation:{type:`zoomIn`,duration:.35,delay:a}}}function Bo(e,t,n){if(Math.abs(e.y-t.y)<1){let r=(e.event.side??(e.eventIndex%2==0?`above`:`below`))===`above`?1:-1,i=e.y+r*n;return`M ${e.x} ${e.y} C ${e.x} ${i}, ${t.x} ${i}, ${t.x} ${t.y}`}let r=(e.y+t.y)/2;return`M ${e.x} ${e.y} C ${e.x} ${r}, ${t.x} ${r}, ${t.x} ${t.y}`}function Vo(e,t){let{theme:n,viewport:r}=t,i=L(t,e.colorScheme),a=Lo(e.tracks),o=[Pi(`bg`,U(t,165))],s=z(44,t,!0),c=z(22,t,!1),l=z(24,t,!1),u=z(17,t,!1);if(e.title&&o.push({type:`text`,id:`timeline-title`,content:{text:e.title,style:{fontSize:s,fontFamily:R(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:V(t)}},position:{x:`50%`,y:Math.max(50,s*1.2),width:`82%`,anchor:`center`},animation:{type:`fadeIn`,duration:.7}}),a.length===0)return o.push({type:`text`,id:`timeline-empty`,content:{text:e.title?`No timeline events`:`Empty timeline`,style:{fontSize:z(36,t,!0),fontFamily:R(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,width:`80%`,anchor:`center`}}),o;let d=a.some(e=>!!e.label),f=Math.max(48,r.width*.065),p=d?Math.min(280,r.width*.18):0,m=f+p,h=r.width-f,g=Math.max(1,h-m),_=e.title?Math.max(s*2.2,r.height*.2):r.height*.09,v=r.height*.91,y=Math.max(1,v-_)/a.length,b=Math.max(6,Math.min(11,Math.min(r.width,r.height)/105)),x=S(i.text??n.colors.primary,.72),C=i.accent??n.colors.primary,w=S(C,.78),T=S(n.colors.text,.48),E=Math.max(1,...a.map(e=>e.events.filter(e=>e.callout!==!1).length)),D=Math.max(Math.min(150,r.width*.2),Math.min(330,g/Math.min(E,4)*.86)),O=Math.min(r.width,r.height)/1080,k=Math.min(l,24*O),A=Math.min(u,17*O),ee=a.map(e=>{let t=e.events.map(e=>Po(e.position)).sort((e,t)=>e-t),n=1/0;for(let e=1;e<t.length;e++)n=Math.min(n,(t[e]-t[e-1])*g);return Number.isFinite(n)?Math.min(b,Math.max(3,n*.32)):b}),te=[],ne=new Map;a.forEach((e,r)=>{let i=_+y*(r+.5),a=.12+r*.12,s=Io(e.id),l={type:`path`,id:`timeline-track-${s}-${r}`,content:{d:`M ${m} ${i} L ${h} ${i}`,stroke:x,strokeWidth:Math.max(2,b*.32),fill:`none`,endMarker:`arrow`},position:{x:m,y:i-b,width:g,height:b*2},animation:{type:`fadeIn`,duration:.65,delay:a}};if(o.push(l),e.label){let l={type:`text`,id:`timeline-track-label-${s}-${r}`,content:{text:e.label,style:{fontSize:c,fontFamily:R(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`right`}},position:{x:f+p/2-16,y:i,width:Math.max(1,p-32),anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:a}};o.push(l)}e.endLabel&&o.push({type:`text`,id:`timeline-track-end-label-${s}-${r}`,content:{text:e.endLabel,style:{fontSize:A,fontFamily:R(t,`body`),color:n.colors.textMuted,textAlign:`left`,maxLines:2}},position:{x:h+b*1.6,y:i-A*.7,width:Math.max(48,f-b*2),anchor:`top-left`},animation:{type:`fadeIn`,duration:.5,delay:a}}),e.events.forEach((e,t)=>{let n={event:e,trackIndex:r,eventIndex:t,x:m+g*Po(e.position),y:i};te.push(n),ne.has(e.id)||ne.set(e.id,n)})}),Ro(e.links,new Set(ne.keys())).forEach((e,i)=>{let a=ne.get(e.source),s=ne.get(e.target);if(!a||!s)return;let c=Math.min(90,Math.max(42,y*.28));if(o.push({type:`path`,id:`timeline-link-${Io(e.source)}-${Io(e.target)}-${i}`,content:{d:Bo(a,s,c),stroke:w,strokeWidth:Math.max(2,b*.26),fill:`none`,endMarker:`arrow`},position:{x:0,y:0,width:`100%`,height:`100%`},animation:{type:`fadeIn`,duration:.6,delay:.45+i*.08}}),e.label){let l=a.trackIndex===s.trackIndex,u=Math.min(320,Math.max(150,e.label.length*A*.55+24)),d=Math.min(A*1.25*2+8,W(e.label,A,u,1.25)+8),f=(a.x+s.x)/2,p=(a.event.side??(a.eventIndex%2==0?`above`:`below`))===`above`?1:-1,m=l?a.y+p*(c+A*.6):(a.y+s.y)/2;if(!l){let e=s.x-a.x,t=s.y-a.y,n=Math.max(1,Math.hypot(e,t)),i=u*.56,o=f+-t/n*i,c=m+e/n*i,l=o>=u/2+8&&o<=r.width-u/2-8&&c>=A*1.5&&c<=r.height-12?1:-1;f+=l*(-t/n)*i,m+=e/n*l*i}f=Fo(f,u/2+8,r.width-u/2-8),m=Fo(m,A*1.5,r.height-12),o.push({type:`text`,id:`timeline-link-label-${i}`,content:{text:e.label,style:{fontSize:A,fontFamily:R(t,`body`),color:n.colors.textMuted,textAlign:`center`,background:n.colors.background,backgroundOpacity:.88,padding:4,maxLines:2,verticalAlign:`middle`}},position:{x:f,y:m,width:u,height:d,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:.55+i*.08}})}});let re=Math.min(78,Math.max(34,y*.2));for(let e of te){let{event:i,trackIndex:a,eventIndex:s,x:c,y:l}=e,u=i.side??(s%2==0?`above`:`below`),d=u===`above`?-1:1,f=l+d*re,p=.28+a*.12+s*.07,m=`${Io(i.id)}-${a}-${s}`,h=ee[a]??b,g=Fo(c,D/2+8,r.width-D/2-8),_=(e,t,n)=>{o.push({type:`path`,id:e,content:{d:`M ${c} ${l} L ${g} ${t}`,stroke:T,strokeWidth:Math.max(1,b*.18),fill:`none`},position:{x:Math.min(c,g),y:Math.min(l,t),width:Math.max(2,Math.abs(g-c)),height:Math.max(2,Math.abs(t-l))},animation:{type:`fadeIn`,duration:.4,delay:n}})};if(i.callout!==!1){_(`timeline-stem-${m}`,f,p);let e=i.descriptionSide??u;if(i.description&&e!==u){let t=e===`above`?-1:1;_(`timeline-description-stem-${m}`,l+t*re,p+.03)}}let v=i.marker??`filled`;if(v===`diamond`)o.push(zo(`timeline-marker-${m}`,c,l,h,C,p));else{let e={type:`shape`,id:`timeline-marker-${m}`,content:{shape:`circle`,fill:v===`hollow`?n.colors.background:C,stroke:C,strokeWidth:Math.max(1.5,h*.28)},position:{x:c-h,y:l-h,width:h*2,height:h*2},animation:{type:`zoomIn`,duration:.35,delay:p}};o.push(e)}if(i.callout!==!1){let e=1.2,a=Math.min(W(i.label,k,D,e),k*e*2),s=Math.max(1,Math.round(a/(k*e))),c=Fo(d>0?f+k*.9:f-(s-1)*k*e-k*.9,k,r.height-(s-1)*k*e-12);if(o.push({type:`text`,id:`timeline-event-label-${m}`,content:{text:i.label,style:{fontSize:k,fontFamily:R(t,`body`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,lineHeight:e,shadow:V(t),maxLines:2}},position:{x:g,y:c,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.08}}),i.description){let a=i.descriptionSide??u,d=a===`above`?-1:1,f=1.25,h=t.orientation===`portrait`?6:4,_=Math.min(W(i.description,A,D,f),A*f*h),v=Math.max(1,Math.round(_/(A*f))),y=l+d*re,b;b=a===u?d>0?c+s*k*e+A*.45:c-v*A*f-A*.45:d>0?y+A*.9:y-(v-1)*A*f-A*.9,b=Fo(b,A,r.height-(v-1)*A*f-12),o.push({type:`text`,id:`timeline-event-description-${m}`,content:{text:i.description,style:{fontSize:A,fontFamily:R(t,`body`),color:n.colors.textMuted,textAlign:`center`,lineHeight:f,maxLines:h}},position:{x:g,y:b,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.14}})}}}return o}var Ho=`rectangle.rect.square.circle.ellipse.oval.line.arrow.path.text.triangle.right-triangle.diamond.rhombus.pentagon.hexagon.octagon.star.star4.star6.parallelogram.trapezoid.plus.cross.chevron.arrow-right.arrow-left.arrow-up.arrow-down.double-arrow.callout.speech.cylinder.cloud.heart.lightning.bolt`.split(`.`),Uo={rectangle:`rect`,rect:`rect`,square:`rect`,circle:`circle`,ellipse:`circle`,oval:`circle`,line:`line`,arrow:`arrow`,path:`path`,text:`text`,label:`text`,triangle:`triangle`,"right-triangle":`right-triangle`,righttriangle:`right-triangle`,diamond:`diamond`,rhombus:`diamond`,pentagon:`pentagon`,hexagon:`hexagon`,octagon:`octagon`,star:`star`,star5:`star`,star4:`star4`,star6:`star6`,parallelogram:`parallelogram`,trapezoid:`trapezoid`,plus:`plus`,cross:`plus`,chevron:`chevron`,"arrow-right":`arrow-right`,arrowright:`arrow-right`,rightarrow:`arrow-right`,"arrow-left":`arrow-left`,arrowleft:`arrow-left`,leftarrow:`arrow-left`,"arrow-up":`arrow-up`,arrowup:`arrow-up`,uparrow:`arrow-up`,"arrow-down":`arrow-down`,arrowdown:`arrow-down`,downarrow:`arrow-down`,"double-arrow":`double-arrow`,doublearrow:`double-arrow`,callout:`callout`,speech:`callout`,bubble:`callout`,cylinder:`cylinder`,can:`cylinder`,cloud:`cloud`,heart:`heart`,lightning:`lightning`,bolt:`lightning`};function Wo(e){return e?Uo[e.toLowerCase()]??null:null}function Go(e){return Wo(e)!=null}var Ko={gapX:180,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80},qo={rect:{w:160,h:90},circle:{w:120,h:120},line:{w:160,h:0},arrow:{w:160,h:0},path:{w:160,h:120},text:{w:200,h:48}},Jo={w:120,h:120};function Yo(e){return qo[e]??Jo}function Xo(e,t={}){let n={...Ko,...t},r=[],i=[],a=[],o=[];for(let t of e){let e=Wo(t.template),n=t.templateOverrides??{},s=t.title??``,c=as(t);if(!e){r.push(`Child "${t.id}" is not a shape (annotation "${t.template??`—`}") and was skipped`);continue}let l=J(n,`from`),u=J(n,`to`);if((e===`line`||e===`arrow`)&&(l||u)){o.push({id:t.id,kind:e,from:l??``,to:u??``,...s?{label:s}:{},...is(n,e),source:t.id});continue}for(let e of t.connectsTo??[])o.push({id:`${t.id}->${e.target}${e.type?`:${e.type}`:``}`,kind:`arrow`,from:t.id,to:e.target,...e.type?{label:e.type}:{},...is(n,`arrow`),source:t.id});let d=Yo(e),f=Zo(n,`x`)??(typeof t.x==`number`?t.x:void 0),p=Zo(n,`y`)??(typeof t.y==`number`?t.y:void 0),m={id:t.id,kind:e,x:f??0,y:p??0,width:Zo(n,`width`)??Zo(n,`w`)??d.w,height:Zo(n,`height`)??Zo(n,`h`)??d.h,pinned:f!=null&&p!=null,label:s,...c?{sublabel:c}:{},...$o(n)};if(e===`path`){let e=J(n,`d`);e&&(m.d=e)}e===`text`&&(m.text=J(n,`text`)??s??c??``),Zo(n,`borderRadius`)!=null&&(m.borderRadius=Zo(n,`borderRadius`)),i.push({shape:m,hasX:f!=null,hasY:p!=null}),(f==null||p==null)&&a.push(i.length-1)}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=Math.max(...a.map(e=>i[e].shape.width)),r=Math.max(...a.map(e=>i[e].shape.height)),o=Math.max(n.gapX,t+60),s=Math.max(n.gapY,r+50),c=n.gridOriginX,l=n.gridOriginY,u=i.filter(e=>e.shape.pinned);u.length>0&&(c=Math.min(...u.map(e=>e.shape.x)),l=Math.max(...u.map(e=>e.shape.y+e.shape.height))+n.gridPad),a.forEach((t,n)=>{let r=n%e,a=Math.floor(n/e);i[t].shape.x=c+r*o,i[t].shape.y=l+a*s})}let s=i.map(e=>e.shape),c=new Set(s.map(e=>e.id)),l=[],u=new Set;for(let e of o){if(!c.has(e.from)||!c.has(e.to)){let t=c.has(e.from)?e.to:e.from;r.push(`Connector "${e.source}" dropped: ${t?`no shape with id "${t}"`:`missing from/to`}`);continue}let t=`${e.kind}:${e.from}->${e.to}:${e.label??``}`;if(u.has(t))continue;u.add(t);let{source:n,...i}=e;l.push(i)}return{shapes:s,connectors:l,warnings:r}}function J(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function Zo(e,t){let n=J(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Qo(e){let t={},n=J(e,`stroke`),r=Zo(e,`strokeWidth`),i=J(e,`dasharray`);return n&&(t.stroke=n),r!=null&&(t.strokeWidth=r),i&&(t.dasharray=i),t}function $o(e){let t=J(e,`fill`);return{...Qo(e),...t?{fill:t}:{}}}var es={none:`none`,arrow:`arrow`,triangle:`arrow`,filled:`arrow`,open:`open`,v:`open`,diamond:`diamond`,circle:`circle`,dot:`circle`,square:`square`,box:`square`},ts={straight:`straight`,direct:`straight`,orthogonal:`orthogonal`,elbow:`orthogonal`,step:`orthogonal`,curved:`curved`,curve:`curved`,bezier:`curved`};function ns(e){return e?es[e.toLowerCase()]:void 0}function rs(e){return e?ts[e.toLowerCase()]:void 0}function is(e,t){let n=Qo(e),r=n.dasharray??Re(J(e,`lineStyle`));return{...n,...r?{dasharray:r}:{},startMarker:ns(J(e,`startStyle`))??`none`,endMarker:ns(J(e,`endStyle`))??(t===`arrow`?`arrow`:`none`),routing:rs(J(e,`routing`))??`straight`}}function as(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(` `).trim()}var os=80;function ss(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=L(t,e.colorScheme),o=e.stroke??a.text??n.colors.text,s=e.fill??`none`,c=Xo(i);if(c.shapes.length===0&&c.connectors.length===0)return[ds(e,t)];let l=Math.min(...c.shapes.map(e=>e.x)),u=Math.max(...c.shapes.map(e=>e.x+e.width)),d=Math.min(...c.shapes.map(e=>e.y)),f=Math.max(...c.shapes.map(e=>e.y+e.height)),p=e.title?120:0,m=Math.max(1,r.width-os*2),h=Math.max(1,r.height-os*2-p),g=Math.max(1,u-l),_=Math.max(1,f-d),v=Math.min(m/g,h/_,1.8),y=g*v,b=_*v,x=Math.max(os/2,(r.height-p-b)/2),S=os+(m-y)/2,C=x+p,w=e=>S+(e-l)*v,T=e=>C+(e-d)*v,E=Math.min(Math.max(v,1),1.5),D=[];e.title&&D.push({type:`text`,id:`drawing-title`,content:{text:e.title,style:{fontSize:z(40,t,!0),fontFamily:R(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`}},position:{x:`50%`,y:x+p/2-16,anchor:`center`}});let O=new Map;for(let e of c.shapes){let t=w(e.x),n=T(e.y),r=e.width*v,i=e.height*v;O.set(e.id,{cx:t+r/2,cy:n+i/2,rx:Math.max(1,r/2),ry:Math.max(1,i/2)})}for(let e of c.connectors){let n=O.get(e.from),r=O.get(e.to);if(!n||!r)continue;let{start:i,end:a}=Me(n,r),s={type:`path`,id:`connector-${e.id}`,content:{d:Fe(e.routing,i,a),stroke:e.stroke??o,strokeWidth:e.strokeWidth??Math.round(2*E),fill:`none`,...e.dasharray?{dasharray:e.dasharray}:{},...e.startMarker===`none`?{}:{startMarker:e.startMarker},...e.endMarker===`none`?{}:{endMarker:e.endMarker}},position:{x:0,y:0,width:`100%`,height:`100%`}};D.push(s),e.label&&D.push(us(e,n,r,t,E))}for(let e of c.shapes){let n=w(e.x),r=T(e.y),i=e.width*v,a=e.height*v;D.push(...cs(e,n,r,i,a,t,o,s,E))}return D}function cs(e,t,n,r,i,a,o,s,c){let l=[],u=e.stroke??o,d=e.fill??s;if(e.kind===`text`)return l.push(ls(`shape-${e.id}`,e.text??e.label??``,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),l;if(e.kind===`rect`||e.kind===`circle`){let a={type:`shape`,id:`shape-${e.id}`,content:{shape:e.kind,fill:d,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),...e.kind===`rect`&&e.borderRadius!=null?{borderRadius:e.borderRadius}:{}},position:{x:t,y:n,width:r,height:i}};l.push(a)}else{let a=`M ${fs(t)} ${fs(n)} L ${fs(t+r)} ${fs(n+i)}`,o=a,s=`none`,f=`none`;e.kind===`path`?(o=e.d??a,s=d):e.kind===`arrow`?f=`arrow`:e.kind!==`line`&&(o=we(e.kind,t,n,r,i)??a,s=d);let p={type:`path`,id:`shape-${e.id}`,content:{d:o,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),fill:s,...e.dasharray?{dasharray:e.dasharray}:{},...f===`none`?{}:{endMarker:f}},position:{x:0,y:0,width:`100%`,height:`100%`}};l.push(p)}return e.label&&l.push(ls(`shape-label-${e.id}`,e.label,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),e.sublabel&&l.push(ls(`shape-sublabel-${e.id}`,e.sublabel,t+r/2,n+i+14*c,r,a,a.theme.colors.textMuted,!1,c)),l}function ls(e,t,n,r,i,a,o,s,c){return{type:`text`,id:e,content:{text:t,style:{fontSize:z(Math.round((s?22:18)*c),a,!1),fontFamily:R(a,`body`),...s?{fontWeight:`bold`}:{},color:o,textAlign:`center`}},position:{x:n,y:r,anchor:`center`,width:i}}}function us(e,t,n,r,i){let a=z(Math.round(18*i),r,!1);return{type:`text`,id:`connector-label-${e.id}`,content:{text:e.label??``,style:{fontSize:a,fontFamily:R(r,`body`),color:r.theme.colors.textMuted,textAlign:`center`}},position:{x:(t.cx+n.cx)/2,y:(t.cy+n.cy)/2-a*.9,anchor:`center`}}}function ds(e,t){return{type:`text`,id:`drawing-empty`,content:{text:e.title??`Empty drawing`,style:{fontSize:z(36,t,!0),fontFamily:R(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}function fs(e){return Math.round(e*100)/100}var ps=`#1e293b`,ms={w:300,h:80},hs={w:160,h:90},gs={w:320,h:240};function _s(e,t,n={}){let r=n.ink??ps,i=[],a=[];for(let t of e){let e=t.templateOverrides??{},n=(t.template??``).toLowerCase(),o=X(e,`x`)??0,s=X(e,`y`)??0;if(n===`image`||n===`img`){let n=Y(e,`src`);if(!n){a.push(`Layout image "${t.id}" has no src= and was skipped`);continue}let r={id:t.id,type:`image`,position:{x:o,y:s,width:X(e,`width`)??gs.w,height:X(e,`height`)??gs.h},content:{src:n,alt:Y(e,`alt`)??``,...Y(e,`fit`)?{fit:Y(e,`fit`)}:{}}};i.push(r);continue}let c=Wo(t.template);if(!c){a.push(`Layout child "${t.id}" is not a layer (annotation "${t.template??`—`}") and was skipped`);continue}if(c===`text`){let n=ys(t)||t.title||``,a={id:t.id,type:`text`,position:{x:o,y:s,width:X(e,`width`)??ms.w,height:X(e,`height`)??ms.h},content:{text:n,style:vs(e,r)}};i.push(a);continue}let l=X(e,`width`)??X(e,`w`)??hs.w,u=X(e,`height`)??X(e,`h`)??hs.h;if(c===`rect`||c===`circle`){let n={id:t.id,type:`shape`,position:{x:o,y:s,width:l,height:u},content:{shape:c,...Y(e,`fill`)?{fill:Y(e,`fill`)}:{},...Y(e,`stroke`)?{stroke:Y(e,`stroke`)}:{},...X(e,`strokeWidth`)==null?{}:{strokeWidth:X(e,`strokeWidth`)},...Y(e,`borderStyle`)?{borderStyle:Y(e,`borderStyle`)}:{},...c===`rect`&&X(e,`borderRadius`)!=null?{borderRadius:X(e,`borderRadius`)}:{}}};i.push(n);continue}let d=`M ${bs(o)} ${bs(s)} L ${bs(o+l)} ${bs(s+u)}`,f=d,p=`none`,m=`none`;c===`path`?(f=Y(e,`d`)??d,p=Y(e,`fill`)??`none`):c===`arrow`?m=`arrow`:c!==`line`&&(f=we(c,o,s,l,u)??d,p=Y(e,`fill`)??`none`);let h={id:t.id,type:`path`,position:{x:0,y:0,width:`100%`,height:`100%`},content:{d:f,stroke:Y(e,`stroke`)??r,strokeWidth:X(e,`strokeWidth`)??2,fill:p,...Y(e,`dasharray`)?{dasharray:Y(e,`dasharray`)}:{},...m===`none`?{}:{endMarker:m}}};i.push(h)}return{layers:i,warnings:a}}function vs(e,t){let n={fontSize:X(e,`fontSize`)??32,color:Y(e,`color`)??t},r=Y(e,`fontFamily`);r&&(n.fontFamily=r);let i=Y(e,`fontWeight`);(i===`bold`||i===`normal`)&&(n.fontWeight=i);let a=Y(e,`fontStyle`);(a===`italic`||a===`normal`)&&(n.fontStyle=a);let o=Y(e,`align`);(o===`left`||o===`center`||o===`right`)&&(n.textAlign=o);let s=Y(e,`valign`);(s===`top`||s===`middle`||s===`bottom`)&&(n.verticalAlign=s);let c=X(e,`lineHeight`);c!=null&&(n.lineHeight=c);let l=X(e,`padding`);l!=null&&(n.padding=l);let u=Y(e,`background`);return u&&(n.background=u),n}function Y(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function X(e,t){let n=Y(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function ys(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(`
|
|
23
|
-
`).trim()}function bs(e){return Math.round(e*100)/100}function xs(e,t){let{theme:n,viewport:r,children:i=[]}=t,{layers:a}=_s(i,r,{ink:n.colors.text});return a.length>0?a:[Ss(e,t)]}function Ss(e,t){return{type:`text`,id:`layout-empty`,content:{text:e.title??`Empty layout`,style:{fontSize:u(36,t,!0),fontFamily:R(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}var Cs=/\{(\w+)(?::([^}|]+))?(?:\|([^}]*))?\}/g,ws=/\{\{([^{}]*)\}\}/g,Ts=` ESC_OPEN `,Es=` ESC_CLOSE `;function Ds(e){if(!e.contents)return[];let t=[],n=e=>{if(e.type===`image`){let n=e;t.push({url:n.url??``,alt:n.alt??``})}};for(let t of e.contents)i(t,e=>{n(e)});return t}function Os(e){if(!e.contents)return[];let t=[];for(let n of e.contents)i(n,e=>{if(e.type===`listItem`){let n=o(e).replace(/\s+/g,` `).trim();return n&&t.push(n),!0}});return t}function ks(e){return e.contents?e.contents.map(e=>o(e).trim()).filter(e=>e.length>0).join(` `):``}function As(e){return!e.children||e.children.length===0?``:e.children.map(e=>e.title?.trim()).filter(e=>!!e).join(`, `)}function js(e){return e.replace(ws,(e,t)=>Ts+t+Es)}function Ms(e){return e.replace(new RegExp(Ts,`g`),`{`).replace(new RegExp(Es,`g`),`}`)}function Ns(e,t){return Ms(js(e).replace(Cs,(e,n,r,i)=>{let a=t(n,r);return a==null?e:a===``&&i!==void 0?i:a}))}function Ps(e,t,n,r,i){switch(e){case`title`:return n.title??``;case`content`:return ks(n);case`children`:return As(n);case`attr`:{if(!t)return``;let e=n.templateOverrides?.[t]??n.templateData?.[t]??n.metadata?.[t];return e==null?``:String(e)}case`image`:{let e=t?parseInt(t,10):0;return!Number.isFinite(e)||e<0||e>=r.length?``:r[e].alt}case`item`:return i?t?t===`src`?i.src??``:t===`label`?i.label??``:``:i.text:null;case`index`:return i?String(i.index):null;default:return null}}function Fs(e,t,n,r){return Ns(e,(e,i)=>Ps(e,i,t,n,r))}function Is(e,t,n,r){if(!e.includes(`{`))return e;let i=!1,a=js(e).replace(Cs,(e,a,o,s)=>{if(a===`image`){let e=o?parseInt(o,10):0;return Number.isFinite(e)&&e>=0&&e<n.length?n[e].url:s===void 0?(i=!0,``):s}let c=Ps(a,o,t,n,r);return c==null?e:c===``&&s!==void 0?s:c});return i?null:Ms(a)}function Ls(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.match(/-?\d*\.?\d+/);if(t)return parseFloat(t[0])}return 0}function Rs(e,t){if(e==null)return t;if(typeof e==`number`)return e+t;let n=e.match(/^(\s*)(-?\d*\.?\d+)(.*)$/);if(n){let e=parseFloat(n[2])+t;return`${n[1]}${e}${n[3]}`}return e}function zs(e,t,n){switch(e){case`images`:return n.map((e,t)=>({text:e.alt,src:e.url,label:e.alt,index:t+1}));case`children`:return(t.children??[]).map((e,t)=>({text:e.title??``,label:e.title??``,index:t+1}));case`listItems`:return Os(t).map((e,t)=>({text:e,label:e,index:t+1}));default:return[]}}function Bs(e,t,n){let r=e.repeat;if(!r){let r=Hs(e,t,n,void 0);return r?[r]:[]}let i=zs(r.source,t,n),a=r.direction??`column`,o=r.gap??24,s=r.max!=null&&r.max>=0?Math.min(r.max,i.length):i.length,c=[],l=0;for(let r=0;r<s;r++){let s={...e.position};a===`row`?s.x=Rs(s.x,l):s.y=Rs(s.y,l);let u={...e,position:s,id:`${e.id}-${r}`};delete u.repeat;let d=Hs(u,t,n,i[r]);d&&c.push(d);let f=a===`row`?e.position.width:e.position.height;l+=Ls(f)+o}return c}function Vs(e,t){let n=Ds(t),r=[];for(let i of e)if(i.repeat)r.push(...Bs(i,t,n));else{let e=Hs(i,t,n,void 0);e&&r.push(e)}return r}function Hs(e,t,n,r){switch(e.type){case`text`:return{...e,content:{...e.content,text:Fs(e.content.text,t,n,r)}};case`image`:{let i=Is(e.content.src,t,n,r);if(i==null)return null;let a={...e,content:{...e.content,src:i}};return e.content.alt&&e.content.alt.includes(`{`)&&(a.content.alt=Fs(e.content.alt,t,n,r)),a}default:return e}}function Us(e){return(t,n)=>{let r=n.block??t;return r?Vs(e.layers,r):e.layers.slice()}}var Ws=.6;function Gs(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=!1,r=/^\((.*)\)$/.exec(t);if(r&&(n=!0,t=r[1].trim()),t=t.replace(/^([+-]?)\s*[$€£¥]\s*/,`$1`),t=t.replace(/%$/,``).trim(),t=t.replace(/,/g,``),/^[+-]?\d{1,3}(?: \d{3})+(?:\.\d+)?$/.test(t)&&(t=t.replace(/ /g,``)),!/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(t))return null;let i=Number(t);return Number.isFinite(i)?n?-i:i:null}function Ks(e,t){let n=0,r=0;for(let i of e){let e=(i[t]??``).trim();e&&(n+=1,Gs(e)!==null&&(r+=1))}return r>0&&r/Math.max(1,n)>=Ws}function qs(e,t){let n=String(e).trim();if(!n)return null;let r=n.toLowerCase(),i=t.findIndex(e=>e.trim().toLowerCase()===r);if(i>=0)return i;if(/^\d+$/.test(n)){let e=Number(n);if(e<t.length)return e}return null}function Js(e,t={}){let n=Array.isArray(e.headers)?e.headers:[],r=Array.isArray(e.rows)?e.rows:[];if(n.length===0||r.length===0)return null;let i=[],a=0;if(t.labelColumn!==void 0&&String(t.labelColumn).trim()!==``){let e=qs(String(t.labelColumn),n);e===null?i.push(`labelColumn "${t.labelColumn}" matches no column; using the first column`):a=e}let o=[],s=(t.valueColumns??[]).map(e=>String(e)).filter(e=>e.trim()!==``);if(s.length>0)for(let e of s){let t=qs(e,n);t===null?i.push(`valueColumns entry "${e}" matches no column; skipped`):o.includes(t)||o.push(t)}else o=n.map((e,t)=>t).filter(e=>e!==a&&Ks(r,e));return o.length===0?null:{labels:r.map(e=>(e[a]??``).trim()),labelHeader:n[a]??``,labelNumbers:r.map(e=>Gs(e[a]??``)),series:o.map(e=>({name:(n[e]??`Column ${e+1}`).trim()||`Column ${e+1}`,values:r.map(t=>Gs(t[e]??``))})),warnings:i}}function Ys(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function Xs(e,t,n=5){let r=Number.isFinite(e)?e:0,i=Number.isFinite(t)?t:0;if(r>i&&([r,i]=[i,r]),r===i){let t=r===0?1:Ys(Math.abs(r),!0);r-=t,i+=t,e>=0&&r<0&&(r=0)}let a=Math.max(2,n),o=Ys(Ys(i-r,!1)/(a-1),!0),s=Math.floor(r/o)*o,c=Math.ceil(i/o)*o,l=[];for(let e=s;e<=c+o*1e-6;e+=o)l.push(Math.abs(e)<o*1e-6?0:Number(e.toPrecision(12)));return{ticks:l,niceMin:s,niceMax:c,step:o}}function Zs(e,t){if(!Number.isFinite(e))return`—`;let n=e<0?`-`:``,r=Math.abs(e),i;return i=r>=1e6?`${n}${Qs((r/1e6).toFixed(1))}M`:r>=1e3?`${n}${Qs((r/1e3).toFixed(r>=1e4?0:1))}K`:`${n}${r.toLocaleString(`en-US`,{maximumFractionDigits:2})}`,t?`${i} ${t}`:i}function Qs(e){return e.replace(/\.0$/,``)}function Z(e){return Math.round(e*100)/100}function $s(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:Z(e+n*Math.cos(i)),y:Z(t+n*Math.sin(i))}}function ec(e,t,n,r,i,a){let o=a-i;if(o<=0)return``;o>=359.9&&(o=359.9);let s=i+o,c=+(o>180),l=$s(e,t,n,i),u=$s(e,t,n,s);if(r<=0)return[`M ${Z(e)} ${Z(t)}`,`L ${l.x} ${l.y}`,`A ${Z(n)} ${Z(n)} 0 ${c} 1 ${u.x} ${u.y}`,`Z`].join(` `);let d=$s(e,t,r,i),f=$s(e,t,r,s);return[`M ${l.x} ${l.y}`,`A ${Z(n)} ${Z(n)} 0 ${c} 1 ${u.x} ${u.y}`,`L ${f.x} ${f.y}`,`A ${Z(r)} ${Z(r)} 0 ${c} 0 ${d.x} ${d.y}`,`Z`].join(` `)}function tc(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`} ${Z(e.x)} ${Z(e.y)}`).join(` `)}function nc(e,t){if(e.length===0)return``;let n=tc(e),r=e[0],i=e[e.length-1];return`${n} L ${Z(i.x)} ${Z(t)} L ${Z(r.x)} ${Z(t)} Z`}function rc(e){let t=e.viewportWidth,n=e.viewportHeight,r=t*.06,i=n*.06,a=t-r*2,o=i,s;e.hasTitle&&(s={x:r,y:o,width:a,height:e.titleFontSize*2.2},o=s.y+s.height);let c,l=0;e.tableRowCount>0&&(l=Math.min(n*.4,(e.tableRowCount+1)*e.tableFontSize*2.4));let u=e.legendRows>0?e.legendRows*e.legendRowHeight:0,d={x:r,y:o,width:a,height:Math.max(40,n-i-o-u-l)};o=d.y+d.height;let f;u>0&&(f={x:r,y:o,width:a,height:u},o+=u),l>0&&(c={x:r,y:o,width:a,height:l});let p={x:d.x+e.leftGutter,y:d.y,width:Math.max(20,d.width-e.leftGutter),height:Math.max(20,d.height-e.bottomGutter)};return{titleBand:s,chartArea:d,plot:p,legendBand:f,tableBand:c}}function ic(e){let t=e.reduce((e,t)=>Math.max(e,t.values.length),0),n=Array(t).fill(0),r=Array(t).fill(0);return e.map(e=>Array.from({length:t},(t,i)=>{let a=e.values[i];if(a==null||!Number.isFinite(a))return{y0:n[i],y1:n[i]};if(a>=0){let e=n[i];return n[i]+=a,{y0:e,y1:n[i]}}let o=r[i];return r[i]+=a,{y0:r[i],y1:o}}))}function ac(e,t,n){let r=t*.9,i=t*1.6,a=t*2,o=e.map(e=>r+t*.5+e.length*t*.58),s=[],c=[],l=0;o.forEach((e,t)=>{let r=c.length>0?i:0;c.length>0&&l+r+e>n&&(s.push(c),c=[],l=0),c.push(t),l+=(c.length>1?i:0)+e}),c.length>0&&s.push(c);let u=[];return s.forEach((t,s)=>{let c=t.reduce((e,t,n)=>e+o[t]+(n>0?i:0),0),l=Math.max(0,(n-c)/2);t.forEach(t=>{u.push({label:e[t],index:t,x:l,y:s*a,swatchSize:r}),l+=o[t]+i})}),{items:u,rows:s.length,rowHeight:a}}function oc(e,t,n){if(e<=1)return 1;let r=n*6,i=t/e;return Math.max(1,Math.ceil(r/Math.max(1,i)))}var sc={bar:`barChart`,column:`columnChart`,pie:`pieChart`,donut:`donutChart`,line:`lineChart`,area:`areaChart`,scatter:`scatterChart`};function cc(e,t,n){let r=lc(t,n),i=r?Js(r,t):null;if(!r||!i)return uc(t,n);let{theme:a,viewport:o}=n,s=sc[e],c=(t.title??``).trim(),l=z(44,n,!0),u=z(20,n,!1),d=z(22,n,!1),f=z(22,n,!1),p=z(20,n,!1),m=R(n,`body`),h=e===`pie`||e===`donut`,g=dc(e,t,i),_=fc(n,t.colorScheme,h?i.labels.length:i.series.length);if(h&&!i.series[0].values.some(e=>e!==null&&e>0))return uc(t,n);let v=o.width*.88,y=g.length>0?ac(g,f,v):null,b=pc(e,i,t,n,u,d),x=rc({viewportWidth:o.width,viewportHeight:o.height,hasTitle:c.length>0,titleFontSize:l,leftGutter:b.left,bottomGutter:b.bottom,legendRows:y?.rows??0,legendRowHeight:f*2,tableRowCount:t.showTable===!0?r.rows.length:0,tableFontSize:p}),C=ji(n,s,`entrance`,`staggered`),w={kind:e,input:t,context:n,data:i,frame:x,colors:_,axisFontSize:u,labelFontSize:d,bodyFont:m,gridColor:S(a.colors.text,.12),axisTextColor:a.colors.textMuted,entrance:e=>({type:`fadeIn`,duration:.6,delay:C===`subtle`?.1:Math.min(1.2,.2+e*.08)})},T=[Pi(`bg`,U(n,170))];switch(c&&x.titleBand&&T.push({type:`text`,id:`title`,content:{text:c,style:{fontSize:l,fontFamily:R(n,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:V(n)}},position:{x:x.titleBand.x+x.titleBand.width/2,y:x.titleBand.y+x.titleBand.height/2,width:x.titleBand.width,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),e){case`bar`:T.push(...vc(w));break;case`column`:T.push(..._c(w));break;case`pie`:case`donut`:T.push(...yc(w));break;case`line`:case`area`:T.push(...bc(w));break;case`scatter`:T.push(...xc(w));break}return y&&x.legendBand&&T.push(...Sc(w,y,x.legendBand,f)),t.showTable===!0&&x.tableBand&&T.push(wc(r,x.tableBand,p,t,n)),T}function lc(e,t){return Array.isArray(e.headers)&&e.headers.length>0&&Array.isArray(e.rows)&&e.rows.length>0?{headers:e.headers,rows:e.rows}:Qa(e.contents??t.block?.contents)}function uc(e,t){return sa({...e,template:`content`,title:e.title??t.block?.title??``},t)}function dc(e,t,n){return t.showLegend===!1?[]:e===`pie`||e===`donut`?n.labels:n.series.length>1||t.showLegend===!0?n.series.map(e=>e.name):[]}function fc(e,t,n){let r=e.theme.colorSchemes,i=Object.keys(r),a=[L(e,t).accent],o=t&&i.includes(t)?i.indexOf(t):0;for(let e=1;e<i.length&&a.length<n;e++){let t=r[i[(o+e)%i.length]].accent;a.some(e=>e.toLowerCase()===t.toLowerCase())||a.push(t)}let s=a.length;for(let e=0;a.length<n;e++)a.push(S(a[e%s],.55));return a.slice(0,Math.max(1,n))}function pc(e,t,n,r,i,a){if(e===`pie`||e===`donut`)return{left:0,bottom:0};if(e===`bar`){let e=t.labels.reduce((e,t)=>Math.max(e,t.length),0);return{left:Math.min(r.viewport.width*.24,Math.max(a*3,e*a*.58+16)),bottom:i*2.4}}let o=mc(e,t,n).ticks.reduce((e,t)=>Math.max(e,Zs(t,n.unit).length),0);return{left:Math.max(i*2.5,o*i*.6+16),bottom:a*2.6}}function mc(e,t,n){let r;r=(e===`bar`||e===`column`)&&n.stacked===!0?ic(t.series).flat().flatMap(e=>[e.y0,e.y1]):t.series.flatMap(e=>e.values.filter(e=>e!==null)),r.length===0&&(r=[0,1]);let i=Math.min(...r),a=Math.max(...r);return e!==`line`&&e!==`scatter`&&(i=Math.min(0,i),a=Math.max(0,a)),Xs(i,a,5)}function hc(e,t,n){let{frame:r,gridColor:i,axisTextColor:a,axisFontSize:o,bodyFont:s,input:c}=e,l=[];return t.ticks.forEach((t,u)=>{let d=n(t);l.push({type:`shape`,id:`grid-${u}`,content:{shape:`rect`,fill:t===0?S(e.context.theme.colors.text,.35):i},position:{x:r.plot.x,y:d-(t===0?1:.5),width:r.plot.width,height:t===0?2:1}}),l.push({type:`text`,id:`tick-${u}`,content:{text:Zs(t,c.unit),style:{fontSize:o,fontFamily:s,color:a,textAlign:`center`}},position:{x:r.chartArea.x+(r.plot.x-r.chartArea.x)/2,y:d,anchor:`center`}})}),l}function gc(e,t){let{frame:n,data:r,labelFontSize:i,axisTextColor:a,bodyFont:o}=e,s=oc(r.labels.length,n.plot.width,i),c=[];return r.labels.forEach((e,r)=>{r%s!==0||!e||c.push({type:`text`,id:`cat-${r}`,content:{text:e,style:{fontSize:i,fontFamily:o,color:a,textAlign:`center`}},position:{x:t(r),y:n.plot.y+n.plot.height+i*1.2,anchor:`center`}})}),c}function _c(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=mc(`column`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=hc(e,o,s),l=n.labels.length,u=t.plot.width/Math.max(1,l),d=u*.15;c.push(...gc(e,e=>t.plot.x+(e+.5)*u));let f=i.stacked===!0&&n.series.length>1,p=f?ic(n.series):null,m=u-d*2,h=f?m:Math.max(2,(m-4*(n.series.length-1))/n.series.length);return n.series.forEach((n,o)=>{n.values.forEach((n,m)=>{if(m>=l)return;let g=p?p[o][m]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!g||g.y0===g.y1)return;let _=s(g.y1),v=Math.max(1,s(g.y0)-_),y=f?t.plot.x+m*u+d:t.plot.x+m*u+d+o*(h+4);c.push({type:`shape`,id:`mark-${o}-${m}`,content:{shape:`rect`,fill:r[o],borderRadius:f?0:3},position:{x:y,y:_,width:h,height:v},animation:a(m+o)}),i.showValues===!0&&n!==null&&!f&&c.push(Cc(e,`val-${o}-${m}`,n,y+h/2,n>=0?_-e.axisFontSize*.9:_+v+e.axisFontSize*.9))})}),c}function vc(e){let{frame:t,data:n,colors:r,input:i,entrance:a,labelFontSize:o,axisFontSize:s,bodyFont:c,axisTextColor:l,gridColor:u}=e,d=mc(`bar`,n,i),f=s*.6,p=e=>Zs(e,i.unit).length*s*.58,m=i.showValues===!0&&i.stacked!==!0,h=m?n.series.flatMap(e=>e.values).filter(e=>e!==null).reduce((e,t)=>Math.max(e,p(t)),0)+f:0,g=Math.max(20,t.plot.width-h),_=e=>t.plot.x+g*((e-d.niceMin)/(d.niceMax-d.niceMin)),v=[];d.ticks.forEach((n,r)=>{let a=_(n);v.push({type:`shape`,id:`grid-${r}`,content:{shape:`rect`,fill:n===0?S(e.context.theme.colors.text,.35):u},position:{x:a-(n===0?1:.5),y:t.plot.y,width:n===0?2:1,height:t.plot.height}}),v.push({type:`text`,id:`tick-${r}`,content:{text:Zs(n,i.unit),style:{fontSize:s,fontFamily:c,color:l,textAlign:`center`}},position:{x:a,y:t.plot.y+t.plot.height+s*1.2,anchor:`center`}})});let y=n.labels.length,b=t.plot.height/Math.max(1,y),x=b*.15,C=i.stacked===!0&&n.series.length>1,w=C?ic(n.series):null,T=b-x*2,E=C?T:Math.max(2,(T-4*(n.series.length-1))/n.series.length);return n.labels.forEach((e,n)=>{e&&v.push({type:`text`,id:`cat-${n}`,content:{text:e,style:{fontSize:o,fontFamily:c,color:l,textAlign:`center`}},position:{x:t.chartArea.x+(t.plot.x-t.chartArea.x)/2,y:t.plot.y+(n+.5)*b,anchor:`center`}})}),n.series.forEach((n,i)=>{n.values.forEach((n,o)=>{if(o>=y)return;let s=w?w[i][o]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!s||s.y0===s.y1)return;let c=_(s.y0),l=Math.max(1,_(s.y1)-c),u=C?t.plot.y+o*b+x:t.plot.y+o*b+x+i*(E+4);if(v.push({type:`shape`,id:`mark-${i}-${o}`,content:{shape:`rect`,fill:r[i],borderRadius:C?0:3},position:{x:c,y:u,width:l,height:E},animation:a(o+i)}),m&&n!==null){let t=p(n)/2,r=n>=0?c+l+f+t:c-f-t;v.push(Cc(e,`val-${i}-${o}`,n,r,u+E/2))}})}),v}function yc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o,context:s}=e,c=r.labels.map((e,t)=>({label:e,value:r.series[0].values[t],index:t})).filter(e=>e.value!==null&&Number.isFinite(e.value)&&e.value>0),l=c.reduce((e,t)=>e+t.value,0),u=n.chartArea.x+n.chartArea.width/2,d=n.chartArea.y+n.chartArea.height/2,f=Math.min(n.chartArea.width,n.chartArea.height)*.42,p=t===`donut`?f*.55:0,m=[],h=0;return c.forEach((t,n)=>{let r=t.value/l*360;if(m.push({type:`path`,id:`mark-${t.index}`,content:{d:ec(u,d,f,p,h,h+r),fill:i[t.index%i.length],stroke:s.theme.colors.background,strokeWidth:2},position:{x:u-f,y:d-f,width:f*2,height:f*2},animation:o(n)}),a.showValues===!0&&r>=14){let a=(h+r/2-90)*Math.PI/180,s=p>0?(p+f)/2:f*.68,c=`${Math.round(t.value/l*100)}%`;m.push({type:`text`,id:`val-${t.index}`,content:{text:c,style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:x(i[t.index%i.length]),textAlign:`center`}},position:{x:u+s*Math.cos(a),y:d+s*Math.sin(a),anchor:`center`},animation:o(n)})}h+=r}),m}function bc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o}=e,s=mc(t,r,a),c=e=>n.plot.y+n.plot.height*(1-(e-s.niceMin)/(s.niceMax-s.niceMin)),l=r.labels.length,u=n.plot.width/Math.max(1,l),d=e=>n.plot.x+(e+.5)*u,f=hc(e,s,c);f.push(...gc(e,d));let p=c(Math.max(s.niceMin,Math.min(s.niceMax,0))),m=l<=30;return r.series.forEach((r,s)=>{let u=[],h=[];r.values.forEach((e,t)=>{if(!(t>=l)){if(e===null){h.length>0&&u.push(h),h=[];return}h.push({x:d(t),y:c(e)})}}),h.length>0&&u.push(h),u.forEach((e,r)=>{t===`area`&&e.length>1&&f.push({type:`path`,id:`area-${s}-${r}`,content:{d:nc(e,p),fill:i[s],fillOpacity:.25,stroke:`none`,strokeWidth:0},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)}),e.length>1&&f.push({type:`path`,id:`line-${s}-${r}`,content:{d:tc(e),stroke:i[s],strokeWidth:4,fill:`none`},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)})}),m&&r.values.forEach((t,n)=>{n>=l||t===null||(f.push({type:`shape`,id:`pt-${s}-${n}`,content:{shape:`circle`,fill:i[s]},position:{x:d(n)-5,y:c(t)-5,width:10,height:10},animation:o(s)}),a.showValues===!0&&f.push(Cc(e,`val-${s}-${n}`,t,d(n),c(t)-e.axisFontSize)))})}),f}function xc(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=mc(`scatter`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=hc(e,o,s),l=n.labelNumbers.filter(e=>e!==null).length,u=n.labels.length>0&&l/n.labels.length>=.6,d;if(u){let r=n.labelNumbers.filter(e=>e!==null),i=Xs(Math.min(...r),Math.max(...r),5),a=i.niceMax-i.niceMin;d=e=>{let r=n.labelNumbers[e];return r===null?null:t.plot.x+t.plot.width*((r-i.niceMin)/a)},i.ticks.forEach((n,r)=>{let o=t.plot.x+t.plot.width*((n-i.niceMin)/a);c.push({type:`shape`,id:`xgrid-${r}`,content:{shape:`rect`,fill:e.gridColor},position:{x:o-.5,y:t.plot.y,width:1,height:t.plot.height}}),c.push({type:`text`,id:`xtick-${r}`,content:{text:Zs(n),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,color:e.axisTextColor,textAlign:`center`}},position:{x:o,y:t.plot.y+t.plot.height+e.axisFontSize*1.2,anchor:`center`}})})}else{let r=t.plot.width/Math.max(1,n.labels.length);d=e=>t.plot.x+(e+.5)*r,c.push(...gc(e,e=>t.plot.x+(e+.5)*r))}return n.series.forEach((e,t)=>{e.values.forEach((e,n)=>{if(e===null)return;let i=d(n);i!==null&&c.push({type:`shape`,id:`mark-${t}-${n}`,content:{shape:`circle`,fill:r[t],fillOpacity:.85},position:{x:i-7,y:s(e)-7,width:14,height:14},animation:a(Math.floor(n/3)+t)})})}),c}function Sc(e,t,n,r){let i=[];return t.items.forEach((a,o)=>{let s=e.colors[a.index%e.colors.length],c=n.y+a.y+t.rowHeight/2;i.push({type:`shape`,id:`legend-swatch-${o}`,content:{shape:`rect`,fill:s,borderRadius:3},position:{x:n.x+a.x,y:c-a.swatchSize/2,width:a.swatchSize,height:a.swatchSize}}),i.push({type:`text`,id:`legend-label-${o}`,content:{text:a.label,style:{fontSize:r,fontFamily:e.bodyFont,color:e.context.theme.colors.text}},position:{x:n.x+a.x+a.swatchSize+r*.5,y:c-r*.62}})}),i}function Cc(e,t,n,r,i){return{type:`text`,id:t,content:{text:Zs(n,e.input.unit),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:e.context.theme.colors.text,textAlign:`center`}},position:{x:r,y:i,anchor:`center`}}}function wc(e,t,n,r,i){let{theme:a}=i,o=L(i,r.colorScheme);return{type:`table`,id:`table`,content:{headers:e.headers,rows:e.rows,align:e.align,style:{headerBackground:o.accent,headerColor:x(o.accent),cellBackground:S(a.colors.text,.04),cellColor:a.colors.text,borderColor:S(a.colors.text,.15),fontSize:n,fontFamily:R(i,`body`),headerFontFamily:R(i,`title`),borderRadius:8}},position:{x:t.x,y:t.y,width:t.width,height:t.height},animation:{type:`fadeIn`,duration:1,delay:.4}}}function Tc(e,t){return cc(`bar`,e,t)}function Ec(e,t){return cc(`column`,e,t)}function Dc(e,t){return cc(`pie`,e,t)}function Oc(e,t){return cc(`donut`,e,t)}function kc(e,t){return cc(`line`,e,t)}function Ac(e,t){return cc(`area`,e,t)}function jc(e,t){return cc(`scatter`,e,t)}var Mc={title:Fi,sectionHeader:Yi,bigText:ia,content:sa,statHighlight:ca,quote:la,factCard:ua,twoColumn:da,dateEvent:pa,imageWithCaption:ma,leftFeature:ga,rightFeature:_a,map:va,fullBleedQuote:ya,list:fo,photoGrid:po,definitionCard:ho,comparisonBar:go,pullQuote:_o,videoWithCaption:vo,videoPullQuote:yo,dataTable:bo,barChart:Tc,columnChart:Ec,pieChart:Dc,donutChart:Oc,lineChart:kc,areaChart:Ac,scatterChart:jc,diagram:Ao,tree:No,timeline:Vo,layout:xs,drawing:ss};function Nc(e){let t={...Mc};if(e)for(let n of e)t[n.name]||(t[n.name]=Us(n));return t}var Pc=[{type:`slowZoom`,direction:`in`},{type:`slowZoom`,direction:`out`},{type:`slowZoom`,panDirection:`left`},{type:`slowZoom`,panDirection:`right`}],Fc=8;function Ic(e){return e===0||e===`0`||e===`0%`}function Lc(e){if(e.type!==`image`&&e.type!==`video`)return!1;let{position:t}=e;if(!Ic(t.x)||!Ic(t.y)||t.width!==`100%`||t.height!==`100%`)return!1;let n=e.content.fit;return n===void 0||n===`cover`}function Rc(e){return e.renderStyle.ambientMotion===!0}function zc(e,t,n){let r=n.style.animationSpeed??1,i=Rc(n);return r===1&&!i?e:e.map(e=>{let n=e.animation;return!n&&i&&Lc(e)&&(n={...new be(ve(`${t.id}:${e.id}`)).pickRequired(Pc),duration:Math.max(Fc,t.duration??0)}),!n||n.type===`none`||r!==1&&(n={...n,...n.duration==null?{}:{duration:n.duration*r},...n.delay==null?{}:{delay:n.delay*r}}),n===e.animation?e:{...e,animation:n}})}function Bc(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min(i[n]+1,a[n-1]+1,i[n-1]+r)}[i,a]=[a,i]}return i[r]}function Vc(e,t,n){let r=n?.maxDistance??2,i,a=1/0,o=e.toLowerCase();for(let e of t){let t=Bc(o,e.toLowerCase());t<a&&(a=t,i=e)}if(i&&(a<=r||a<=Math.ceil(e.length*.4)))return n?.map?n.map(i):i}var Hc=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`],Uc=[`bottom`,`top`,`center`],Wc=[`terrain`,`satellite`,`road`,`toner`,`watercolor`],Gc=[`neutral`,`somber`,`celebratory`],Kc=`theme color-scheme name — e.g. 'blue', 'green'`;function qc(e=[]){return[{key:`title`,description:`Optional title above the chart`},{key:`labelColumn`,description:`Category/label column`,valueHint:`header name or 0-based index`},{key:`valueColumns`,description:`Value columns to plot`,coerce:`stringList`,valueHint:`comma-separated header names or 0-based indexes`},{key:`showTable`,description:`Render the source table beneath the chart`,coerce:`boolean`},{key:`showLegend`,description:`Show a series legend`,coerce:`boolean`},{key:`showValues`,description:`Print numeric value labels on marks`,coerce:`boolean`},{key:`unit`,description:`Unit suffix for tick/value labels (e.g. "km")`},{key:`colorScheme`,description:`Color scheme seeding the series color rotation`,valueHint:Kc},{key:`headers`,description:`Header cells (normally derived from the table)`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},...e]}var Jc={key:`stacked`,description:`Stack series instead of grouping them side by side`,coerce:`boolean`},Yc=[{key:`imageTreatment`,description:`Per-block photographic grade override ('none' opts out)`,values:[`none`,`mono`,`duotone`,`warm`,`cool`]},{key:`useBottomLayer`,description:`Show the doc's bottom persistent layers`,coerce:`boolean`},{key:`useTopLayer`,description:`Show the doc's top persistent layers`,coerce:`boolean`}],Xc={title:[{key:`title`,description:`Main title text`},{key:`subtitle`,description:`Subtitle or tagline`},{key:`backgroundColor`,description:`Background color`,valueHint:`CSS color`}],sectionHeader:[{key:`title`,description:`Section title`},{key:`colorScheme`,description:`Fallback background color scheme`,valueHint:Kc},{key:`imageSrc`,description:`Optional background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Hc}],bigText:[{key:`title`,description:`The display text (rendered uppercase)`},{key:`imageSrc`,description:`Optional full-bleed background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Hc}],content:[{key:`title`,description:`Heading shown above the complete body`}],statHighlight:[{key:`stat`,description:`The statistic (e.g. "89%", "2x")`},{key:`description`,description:`What the stat means`},{key:`detail`,description:`Additional detail or context`},{key:`colorScheme`,description:`Color scheme for the stat`,valueHint:Kc}],quote:[{key:`title`,description:`Optional heading above the quote`},{key:`quote`,description:`The quote text`},{key:`attribution`,description:`Attribution (author, source)`}],pullQuote:[{key:`text`,description:`Quote text`},{key:`attribution`,description:`Attribution`}],twoColumn:[{key:`left`,description:`Left column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`right`,description:`Right column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`header`,description:`Optional header above the columns`},{key:`leftColor`,description:`Left column color scheme`,valueHint:Kc},{key:`rightColor`,description:`Right column color scheme`,valueHint:Kc}],dateEvent:[{key:`date`,description:`The date (e.g. "July 14, 1974")`},{key:`description`,description:`What happened`},{key:`footer`,description:`Optional footer text`},{key:`mood`,description:`Emotional tone`,values:Gc}],imageWithCaption:[{key:`imageSrc`,description:`Path to the image file`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Uc},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Hc},{key:`isTitle`,description:`Style the caption as a title`,coerce:`boolean`},{key:`subtitle`,description:`Subtitle (only when isTitle)`},{key:`imageCredit`,description:`Photo credit / artist name`},{key:`imageLicense`,description:`License identifier`}],leftFeature:Zc(),rightFeature:Zc(),map:[{key:`center`,description:`Map center as "lat,lng"`,coerce:`latLng`,required:!0},{key:`zoom`,description:`Zoom level (4-16)`,coerce:`number`},{key:`mapStyle`,description:`Map tile style`,values:Wc},{key:`title`,description:`Optional title overlay`},{key:`caption`,description:`Optional caption`}],photoGrid:[{key:`images`,description:`Comma-separated image paths`,coerce:`stringList`},{key:`caption`,description:`Optional caption below the grid`},{key:`ambientMotion`,description:`Slow zoom/pan on the largest image`,values:Hc}],comparisonBar:[{key:`leftLabel`,description:`Left bar label`,required:!0},{key:`leftValue`,description:`Left bar numeric value`,coerce:`number`,required:!0},{key:`rightLabel`,description:`Right bar label`,required:!0},{key:`rightValue`,description:`Right bar numeric value`,coerce:`number`,required:!0},{key:`unit`,description:`Unit label (e.g. "km")`},{key:`colorScheme`,description:`Color scheme`,valueHint:Kc}],dataTable:[{key:`title`,description:`Optional title above the table`},{key:`headers`,description:`Comma-separated header cells`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},{key:`align`,description:`Per-column alignment (supply via a data fence)`},{key:`colorScheme`,description:`Header color scheme`,valueHint:Kc}],barChart:qc([Jc]),columnChart:qc([Jc]),pieChart:qc(),donutChart:qc(),lineChart:qc(),areaChart:qc(),scatterChart:qc(),tree:[{key:`title`,description:`Optional title above the tree`},{key:`colorScheme`,description:`Folder-row color scheme`,valueHint:Kc},{key:`items`,description:`Tree items (derived from the tree fence)`}],timeline:[{key:`title`,description:`Optional title above the timeline`},{key:`colorScheme`,description:`Track and marker color scheme`,valueHint:Kc},{key:`tracks`,description:`Timeline tracks and events (supply via template data)`},{key:`links`,description:`Branch links between event ids (supply via template data)`}],videoWithCaption:[{key:`videoSrc`,description:`Path to the video file`,required:!0},{key:`posterSrc`,description:`Poster frame path`},{key:`videoAlt`,description:`Alt text for accessibility`},{key:`clipStart`,description:`Clip start time (seconds)`,coerce:`number`},{key:`clipEnd`,description:`Clip end time (seconds)`,coerce:`number`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Uc},{key:`videoCredit`,description:`Video credit / artist name`},{key:`videoLicense`,description:`License identifier`}]};function Zc(){return[{key:`imageSrc`,description:`Path to the feature image`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`imageWidth`,description:`Explicit display width in px`,coerce:`number`},{key:`imageHeight`,description:`Explicit display height in px`,coerce:`number`},{key:`title`,description:`Heading text next to the image`},{key:`body`,description:`Body text below the title`}]}function Qc(e){let t=Xc[e];if(t)return[...t,...Yc]}function $c(e){return new Map(e.map(e=>[e.key,e]))}function el(e,t){let n={},r=[],i=e?Qc(j(e)):void 0,a=i?$c(i):void 0;for(let[e,i]of Object.entries(t)){let{value:t,warning:o}=tl(a?.get(e)?.coerce??`string`,i);o?(r.push(`"${e}": ${o}`),n[e]=i):n[e]=t}return{input:n,warnings:r}}function tl(e,t){switch(e){case`number`:{let e=re(t);return e==null?{value:t,warning:`not a number (${JSON.stringify(t)})`}:{value:e}}case`boolean`:return nl(t);case`latLng`:return rl(t);case`labeledPair`:return{value:il(t)};case`stringList`:return{value:al(t)};default:return{value:t}}}function nl(e){let t=e.trim().toLowerCase();return t===`true`||t===``?{value:!0}:t===`false`?{value:!1}:{value:e,warning:`not a boolean (${JSON.stringify(e)}) \u2014 expected true or false`}}function rl(e){let t=e.split(`,`);if(t.length===2){let e=re(t[0]),n=re(t[1]);if(e!=null&&n!=null)return{value:{lat:e,lng:n}}}return{value:e,warning:`not a "lat,lng" pair (${JSON.stringify(e)})`}}function il(e){let t=e.indexOf(`|`);if(t<0)return{label:e.trim()};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return r?{label:n,sublabel:r}:{label:n}}function al(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function ol(e,t){let n=j(e),r=Xc[n];if(!r)return[];let i=[],a=$c([...r,...Yc]),o=new Set([...a.keys(),...Object.keys(ie)]);for(let[e,r]of Object.entries(t)){let t=a.get(e);if(!t){if(o.has(e))continue;let t=Vc(e,o);i.push({kind:`unknown-input`,key:e,message:`Unknown input "${e}" for template "${n}"`+(t?`. Did you mean "${t}"?`:``),...t?{suggestion:t}:{}});continue}if(t.values){let n=r.trim();n!==``&&!t.values.includes(n)&&i.push({kind:`invalid-input-value`,key:e,message:`Invalid value ${JSON.stringify(r)} for "${e}" \u2014 expected one of: ${t.values.join(`, `)}`})}else if(t.coerce&&t.coerce!==`string`){let{warning:n}=tl(t.coerce,r);n&&i.push({kind:`invalid-input-value`,key:e,message:`"${e}": ${n}`})}}for(let e of r)e.required&&t[e.key]==null&&i.push({kind:`missing-input`,key:e.key,message:`Missing required input "${e.key}" for template "${n}"`});return i}var sl=600;function cl(e,t,n){let r=L(t,`blue`),{layout:i}=t,a=e.title??e.id??``,o=ll(e),s=[{type:`shape`,id:`fallback-bg`,content:{shape:`rect`,fill:r.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}];return a&&s.push({type:`text`,id:`fallback-title`,content:{text:a,style:{fontSize:z(56,t,!0),fontFamily:R(t,`title`),fontWeight:`bold`,color:r.text,textAlign:`center`}},position:{x:`50%`,y:o?`28%`:`50%`,anchor:`center`,width:i.maxTextWidth}}),o&&s.push({type:`text`,id:`fallback-body`,content:{text:o,style:{fontSize:z(28,t),fontFamily:R(t,`body`),color:r.text,textAlign:`center`}},position:{x:`50%`,y:`55%`,anchor:`center`,width:i.maxTextWidth}}),s.push({type:`text`,id:`fallback-notice`,content:{text:`\u26A0 ${n}`,style:{fontSize:z(18,t),fontFamily:R(t,`body`),color:S(r.text,.6),textAlign:`center`}},position:{x:`50%`,y:`92%`,anchor:`center`,width:i.maxTextWidth}}),s}function ll(e){if(!e.contents||e.contents.length===0)return``;let t=e.contents.map(e=>o(e)).join(`
|
|
24
|
-
`).trim();return t.length<=sl?t:`${t.slice(0,sl).trimEnd()}\u2026`}var ul={landscape:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},square:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},portrait:{wide:`title-stack`,tall:`title-stack`,square:`title-stack`,multiple:`title-stack`}},dl={landscape:{wide:`split`,tall:`split`,square:`split`,multiple:`split`},square:{wide:`text-stack`,tall:`split`,square:`text-stack`,multiple:`text-stack`},portrait:{wide:`text-stack`,tall:`text-stack`,square:`text-stack`,multiple:`text-stack`}},fl={landscape:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},square:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},portrait:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`}},pl={title:{summary:`Text-only by default; supplemental media gets a title band plus a reserved field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:ul},sectionHeader:{summary:`Uses its authored background image when present; otherwise supplemental media receives a title composition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ul},bigText:{summary:`Uses its authored background image (behind a contrast bloom) when present; otherwise renders gigantic text on the theme surface.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ul},content:{summary:`Preserves the complete heading and body; supplemental media receives a companion field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:dl},statHighlight:{summary:`Uses its optional accent image natively; otherwise supplemental media occupies a companion field.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},quote:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the quote.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},factCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the fact card.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},twoColumn:{summary:`Text comparison by default; supplemental media stacks below the dense two-column panel.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},dateEvent:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the event.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},imageWithCaption:{summary:`Requires one primary image and owns its full-bleed image/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},leftFeature:{summary:`Requires a primary image in the left feature cell; text occupies the right cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-left`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},rightFeature:{summary:`Requires a primary image in the right feature cell; text occupies the left cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-right`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},map:{summary:`The map canvas is the primary visual; other media must not reflow its geography.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`map-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},fullBleedQuote:{summary:`Despite its name this is text-only; supplemental media receives the same dramatic title treatment.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:ul},list:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the list.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},photoGrid:{summary:`Requires a primary image collection and owns the complete tiled media field.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`photo-grid`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},definitionCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the definition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:dl},comparisonBar:{summary:`Data bars are primary; supplemental media stacks below to preserve horizontal scale.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},pullQuote:{summary:`Requires and owns a full-bleed background image behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoWithCaption:{summary:`Requires one primary video and owns its full-bleed video/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoPullQuote:{summary:`Requires and owns a full-bleed video behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},dataTable:{summary:`The table remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},barChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},columnChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},pieChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},donutChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},lineChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},areaChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},scatterChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:fl},diagram:{summary:`The node-and-edge canvas is intrinsic media and retains its spatial coordinate system.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},tree:{summary:`The interactive tree canvas is intrinsic media and retains its full layout region.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},timeline:{summary:`The track canvas is intrinsic media and retains its shared horizontal time scale.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},layout:{summary:`The authored layer canvas is intrinsic media and must preserve absolute placement.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},drawing:{summary:`The drawing canvas is intrinsic media and must preserve authored geometry.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`}};function ml(e){if(e)return pl[e]}function Q(e,t,n,r,i){return{x:e.width*t,y:e.height*n,width:e.width*r,height:e.height*i}}function hl(e,t){if(e>1)return`multiple`;let n=t[0]??16/9;return n<.8?`tall`:n>1.25?`wide`:`square`}function gl(e,t){return t===`portrait`?{contentRect:Q(e,.06,.04,.88,.3),mediaRect:Q(e,.06,.39,.88,.55),fontScale:.76}:t===`square`?{contentRect:Q(e,.05,.04,.9,.33),mediaRect:Q(e,.07,.42,.86,.51),fontScale:.72}:{contentRect:Q(e,.04,.03,.92,.32),mediaRect:Q(e,.08,.4,.84,.52),fontScale:.72}}function _l(e,t){let n=t===`square`;return{contentRect:Q(e,n?.05:.04,.05,n?.42:.43,.9),mediaRect:Q(e,n?.52:.53,.07,.43,.86),fontScale:.72}}function vl(e,t,n){return t===`portrait`?{contentRect:Q(e,.06,.04,.88,n?.41:.36),mediaRect:Q(e,.06,n?.5:.45,.88,n?.44:.49),fontScale:n?.42:.44}:t===`square`?{contentRect:Q(e,.05,.04,.9,n?.43:.36),mediaRect:Q(e,.07,n?.52:.45,.86,n?.41:.48),fontScale:n?.45:.46}:{contentRect:Q(e,.05,.03,.9,n?.46:.35),mediaRect:Q(e,.07,n?.55:.43,.86,n?.38:.49),fontScale:n?.5:.48}}function yl(e,t){let n=f(e);if(n===`portrait`)switch(t){case`tall`:return Q(e,.55,.5,.38,.44);case`square`:return Q(e,.49,.58,.44,.35);case`multiple`:return Q(e,.07,.67,.86,.27);case`wide`:return Q(e,.07,.71,.86,.23)}if(n===`square`)switch(t){case`tall`:return Q(e,.68,.1,.27,.8);case`square`:return Q(e,.55,.52,.4,.4);case`multiple`:return Q(e,.08,.62,.84,.31);case`wide`:return Q(e,.08,.68,.84,.27)}switch(t){case`tall`:return Q(e,.7,.1,.26,.8);case`square`:return Q(e,.62,.22,.34,.56);case`multiple`:return Q(e,.52,.5,.44,.42);case`wide`:return Q(e,.54,.58,.42,.34)}}function bl(e,t){let n=f(t);switch(e){case`title-stack`:return gl(t,n);case`split`:return _l(t,n);case`text-stack`:return vl(t,n,!1);case`dense-stack`:return vl(t,n,!0)}}function $(e,t){if(e===void 0)return 0;if(typeof e==`number`)return e;let n=e.match(/^\s*(-?\d+(?:\.\d+)?)%\s*$/);if(n)return Number(n[1])/100*t;let r=Number.parseFloat(e);return Number.isFinite(r)?r:0}function xl(e){return e===0||e===`0`||e===`0%`}function Sl(e,t){if(e.type!==`shape`&&e.type!==`image`)return!1;let{position:n}=e,r=n.width===`100%`||n.width===t.width,i=n.height===`100%`||n.height===t.height;return xl(n.x)&&xl(n.y)&&r&&i}function Cl(e,t,n){let r={...e,x:t.x+$(e.x,n.width)/n.width*t.width,y:t.y+$(e.y,n.height)/n.height*t.height};return e.width!==void 0&&(r.width=$(e.width,n.width)/n.width*t.width),e.height!==void 0&&(r.height=$(e.height,n.height)/n.height*t.height),r}function wl(e,t,n,r){let i=n.width/t.width,a=n.height/t.height,o=Math.min(i,a);return e.map(e=>{let s={...e.position,x:n.x+$(e.position.x,t.width)*i,y:n.y+$(e.position.y,t.height)*a,...e.position.width===void 0?{}:{width:$(e.position.width,t.width)*i},...e.position.height===void 0?{}:{height:$(e.position.height,t.height)*a}},c={...e,id:`${r}-${e.id}`,position:s};return e.type===`path`?{...c,type:`path`,content:{...e.content,d:Tl(e.content.d,i,a,n.x,n.y),...e.content.strokeWidth===void 0?{}:{strokeWidth:e.content.strokeWidth*o}}}:e.type===`text`&&o!==1?{...c,type:`text`,content:{...e.content,style:{...e.content.style,fontSize:Math.max(10,e.content.style.fontSize*o)}}}:c})}function Tl(e,t,n,r,i){let a=e.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi);if(!a)return e;let o=``,s=0;return a.map(e=>{if(/^[a-zA-Z]$/.test(e))return o=e,s=0,e;let a=Number(e);if(!Number.isFinite(a)||o===o.toLowerCase())return s++,e;let c=s++,l=a;switch(o){case`M`:case`L`:case`T`:case`C`:case`S`:case`Q`:l=c%2==0?a*t+r:a*n+i;break;case`H`:l=a*t+r;break;case`V`:l=a*n+i;break;case`A`:{let e=c%7;e===0?l=a*t:e===1?l=a*n:e===5?l=a*t+r:e===6&&(l=a*n+i);break}}return String(Math.round(l*1e3)/1e3)}).join(` `)}function El(e,t,n,r,i){return Dl(e.map(e=>{if(Sl(e,n))return e;let i=Cl(e.position,t,n);return e.type===`text`?{...e,position:i,content:{...e.content,style:{...e.content.style,fontSize:Math.max(12,Math.round(e.content.style.fontSize*r)),...e.content.style.padding===void 0?{}:{padding:Math.round(e.content.style.padding*r)}}}}:{...e,position:i}}),i,t,n)}function Dl(e,t,n,r){let i=n.x+n.width/2,a=n.y+n.height/2;if(t===`sectionHeader`)return e.map(e=>{if(e.id===`title`)return{...e,position:{...e.position,x:i,y:a,width:n.width*.9,anchor:`center`}};if(e.id===`line-top`||e.id===`line-bottom`){let t=e.id===`line-top`?-1:1;return{...e,position:{...e.position,x:i,y:a+t*n.height*.28,width:Math.min(n.width*.22,r.width*.2),height:2,anchor:`center`}}}return e});if(t!==`title`)return e;let o=e.find(e=>e.type===`text`&&e.id===`title`),s=e.find(e=>e.type===`text`&&e.id===`subtitle`);if(!o||o.type!==`text`)return e;let c=s?.type===`text`?s:void 0,l=n.width*.9,u=Math.max(12,Math.min(r.width,r.height)*.018),d=c?u:0,f=n.height*.78,p=o.content.style.fontSize,m=c?.content.style.fontSize??0,h=()=>{let e=W(o.content.text,p,l,o.content.style.lineHeight??1.15),t=c?W(c.content.text,m,l,c.content.style.lineHeight??1.5):0;return{titleHeight:e,subtitleHeight:t,total:e+d+t}},g=h();if(g.total>f){let e=Math.max(.5,f/g.total);p=Math.max(18,Math.round(p*e)),m=Math.max(14,Math.round(m*e)),g=h()}let _=n.y+(n.height-g.total)/2,v=_+g.titleHeight/2,y=_+g.titleHeight+d+g.subtitleHeight/2;return e.map(e=>e.id===`title`&&e.type===`text`?{...e,position:{...e.position,x:i,y:v,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:p}}}:e.id===`subtitle`&&e.type===`text`?{...e,position:{...e.position,x:i,y,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:m}}}:e.id===`accent-line`?{...e,position:{...e.position,x:i,y:Math.max(n.y+2,_-u*.75),width:Math.min(n.width*.18,r.width*.12),height:3,anchor:`center`}}:e)}function Ol(e,t,n,r){let i=e.width?$(e.width,t.width):n,a=e.height?$(e.height,t.height):r,o=$(e.x,t.width),s=$(e.y,t.height),c=e.anchor??`top-left`;return c===`center`?(o-=i/2,s-=a/2):(c.endsWith(`right`)&&(o-=i),c.startsWith(`bottom`)&&(s-=a)),{x:o,y:s,width:i,height:a}}function kl(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Al(e,t){let n=e.filter(e=>e.type!==`shape`&&e.type!==`path`&&e.type!==`mermaid`).map(e=>Ol(e.position,t,e.type===`text`?t.width*.45:t.width*.5,e.type===`text`?t.height*.2:t.height*.55));return n.length===0?Q(t,.06,.08,.88,.84):[Q(t,.52,.12,.44,.76),Q(t,.04,.12,.44,.76),Q(t,.15,.53,.7,.41)].reduce((e,t)=>n.reduce((e,n)=>e+kl(t,n),0)<n.reduce((t,n)=>t+kl(e,n),0)?t:e)}function jl(e,t,n,r,i){let a=ml(t),o=hl(r,i),s=e.some(e=>e.type===`image`||e.type===`video`||e.type===`map`||e.type===`mermaid`),c=a?.unconsumedMedia===`retain-native-layout`||a?.unconsumedMedia===`reserve-when-no-native-media`&&s;if(a?.additionalMediaLayout===`overlay-inset`&&c)return{layers:e,mediaRect:yl(n,o),framed:!0};let l=a?.unconsumedMedia===`reserved-slot`||a?.unconsumedMedia===`reserve-when-no-native-media`&&!s;if(!a||!l||!a.variants)return{layers:e,mediaRect:Al(e,n),framed:!1};let u=f(n),d=bl(a.variants[u][o],n);return{layers:El(e,d.contentRect,n,d.fontScale,t??``),mediaRect:d.mediaRect,framed:!0}}function Ml(e,t={}){return Nl(e,t,{registry:t.customTemplates&&t.customTemplates.length>0?Nc(t.customTemplates):Mc})}function Nl(e,t,n){let r=t.theme??k,i=t.viewport??p.landscape,a=t.blockIndex??0,o=t.totalBlocks??1,c=t.persistentLayers===!1?void 0:t.persistentLayers??r.persistentLayers,u=e.layers;if(u&&u.length>0&&!l(e))return{layers:Wl(Vl(d(u),e,r,i),e,r,c,n.expandedPersistentLayers),source:`authored`};if(!l(e)){let t=Vl([],e,r,i);return{layers:Wl(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`}}let f=n.templateContext?d(n.templateContext):s(r,a,o,i);f.block=d(e);let m=Hl(e,f,n.registry);if(m.status===`ok`)return{layers:Wl(Vl(n.applyRenderStyle===!1?m.layers:zc(m.layers,e,r),e,r,i),e,r,c,n.expandedPersistentLayers),source:`template`};let h=Ul(e.template,m);if((t.failureMode??`fallback`)===`empty`){let t=Vl([],e,r,i);return{layers:Wl(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`,diagnostic:h}}return{layers:Wl(Vl(cl(e,f,h.message),e,r,i),e,r,c,n.expandedPersistentLayers),source:`fallback`,diagnostic:h}}function Pl(e){return(e.contents??[]).filter(e=>e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`).map(e=>e.value).filter(e=>e.trim().length>0)}function Fl(e){let t=e.template?j(e.template):void 0,n=(e.contents??[]).filter(e=>e.type===`code`),r=[];for(let e of n){if(t!==`diagram`&&nn(e.lang)){let t=an(e.value,{explicit:rn(e.lang)});if(t.isDiagram&&t.diagram){r.push({kind:`spatial`,template:`diagram`,data:Da(t.diagram),aspectRatio:16/9});continue}}if(t!==`tree`&&Wr(e.lang)){let t=Kr(e.value,{explicit:Gr(e.lang)});if(t.isTree&&t.tree){r.push({kind:`spatial`,template:`tree`,data:Fa(t.tree),aspectRatio:3/4});continue}}if(t!==`timeline`&&gr(e.lang)){let t=vr(e.value,{explicit:_r(e.lang)});t.isTimeline&&t.timeline&&r.push({kind:`spatial`,template:`timeline`,data:Na(t.timeline),aspectRatio:16/9})}}return r}function Il(e,t){let n=new Set(e.filter(e=>e.type===`image`).map(e=>e.content.src)),r=new Set(e.filter(e=>e.type===`video`).map(e=>e.content.src)),i=new Set(e.filter(e=>e.type===`mermaid`).map(e=>e.content.source)),a=Xa(t.contents),o=a.filter(e=>!r.has(e.src)),s=new Set(a.map(e=>e.src)),c=new Set(n),l=Ja(t.contents).filter(e=>s.has(e.src)||c.has(e.src)?!1:(c.add(e.src),!0)),u=Pl(t).filter(e=>!i.has(e));return[...l.map(e=>({kind:`image`,src:e.src,alt:e.alt,...e.width&&e.height?{aspectRatio:e.width/e.height}:{}})),...o.map(e=>({kind:`video`,src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt,aspectRatio:16/9,...e.startAt==null?{}:{startAt:e.startAt},...e.clipStart==null?{}:{clipStart:e.clipStart},...e.clipEnd==null?{}:{clipEnd:e.clipEnd}})),...u.map(e=>({kind:`mermaid`,source:e,aspectRatio:16/9})),...Fl(t)]}function Ll(e,t,n,r){let i=Math.min(n.width,n.height),a=r?i*.025:0,o=t>1?i*.018:0,s={x:e.x+a,y:e.y+a,width:Math.max(0,e.width-a*2),height:Math.max(0,e.height-a*2)},c=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*(s.width/Math.max(1,s.height)))))),l=Math.ceil(t/c),u=(s.width-o*(c-1))/c,d=(s.height-o*(l-1))/l;return Array.from({length:t},(e,t)=>({x:s.x+t%c*(u+o),y:s.y+Math.floor(t/c)*(d+o),width:u,height:d}))}function Rl(e,t){let n=t.imageTreatment;if(n===`none`)return;let r=n?{type:n,strength:e.style.imageTreatment?.strength}:e.style.imageTreatment;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.colors.primary}:r}function zl(e,t,n,r,i){if(e.kind===`image`){let a=Rl(r,n);return[{id:`${n.id}-embedded-image-${i}`,type:`image`,position:t,content:{src:e.src,alt:e.alt||n.title||`Embedded image`,fit:`contain`,...a?{treatment:a}:{}}}]}if(e.kind===`video`){let r=Math.max(0,e.clipStart??0);return[{id:`${n.id}-embedded-video-${i}`,type:`video`,position:t,content:{src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt||n.title||`Embedded video`,fit:`contain`,clipStart:r,clipEnd:Math.max(r,e.clipEnd??r+Math.max(0,n.duration)),...e.startAt==null?{}:{startAt:Math.max(0,e.startAt)}}}]}if(e.kind===`mermaid`)return[{id:`${n.id}-mermaid-${i}`,type:`mermaid`,position:t,content:{source:e.source,background:r.colors.backgroundLight,foreground:r.colors.text,padding:Math.max(12,Math.round(Math.min(t.width,t.height)*.025))}}];let a={width:t.width,height:t.height,name:`Embedded ${e.template}`},o=s(r,0,1,a);o.block=d(n);let c={id:`${n.id}-embedded-${e.template}-${i}`,duration:n.duration,audioSegment:n.audioSegment,...e.data};return wl(e.template===`timeline`?Vo({...c,template:`timeline`},o):e.template===`tree`?No({...c,template:`tree`},o):Ao({...c,template:`diagram`},o),a,t,`${n.id}-embedded-${e.template}-${i}`)}function Bl(e,t){let n=new Map(Xa(t.contents).filter(e=>e.startAt!=null||e.clipStart!=null||e.clipEnd!=null).map(e=>[e.src,e]));return n.size===0?e:e.map(e=>{if(e.type!==`video`)return e;let r=n.get(e.content.src);if(!r)return e;let i=Math.max(0,r.clipStart??e.content.clipStart);return{...e,content:{...e.content,clipStart:i,clipEnd:Math.max(i,r.clipEnd??(r.clipStart==null?e.content.clipEnd:i+Math.max(0,t.duration))),...r.startAt==null?{}:{startAt:Math.max(0,r.startAt)}}}})}function Vl(e,t,n,r){let i=Bl(e,t),a=Il(i,t);if(a.length===0)return i;let o=jl(i,t.template?j(t.template):void 0,r,a.length,a.map(e=>e.aspectRatio)),s=Ll(o.mediaRect,a.length,r,o.framed),c={image:0,video:0,mermaid:0,spatial:0},l=a.flatMap((e,r)=>(c[e.kind]+=1,zl(e,s[r],t,n,c[e.kind]))),u=o.framed?{id:`${t.id}-rich-media-frame`,type:`shape`,position:o.mediaRect,content:{shape:`rect`,fill:n.colors.backgroundLight,stroke:S(n.colors.text,.14),strokeWidth:2,borderRadius:Math.max(12,Math.round(Math.min(r.width,r.height)*.018))}}:void 0;return[...o.layers,...u?[u]:[],...l]}function Hl(e,t,n){let r=d(e),i=d(t),a=r.children;(!i.children||i.children.length===0)&&a?.length&&(i.children=a);let o=n[j(r.template)];if(!o)return{status:`unknown-template`,layers:[]};let{templateData:s,templateOverrides:c}=r,l=r,u=l.sourceHeading?so(r.template,l.title??``,l.contents):null,f=el(r.template,c??{}).input,p=u||s||c?{...u,...r,...s,...f}:r,m=Object.prototype.hasOwnProperty.call(f,`quote`)?f.quote:Object.prototype.hasOwnProperty.call(s??{},`quote`)?s?.quote:Object.prototype.hasOwnProperty.call(r,`quote`)?r.quote:void 0;if(j(r.template)===`quote`&&u&&!Object.prototype.hasOwnProperty.call(u,`title`)&&!(typeof m==`string`&&m.trim())){let e=p;e.quote=u.quote,!Object.prototype.hasOwnProperty.call(s??{},`title`)&&!Object.prototype.hasOwnProperty.call(f,`title`)&&delete e.title}try{let e=o(p,i);return Array.isArray(e)?{status:`ok`,layers:d(e)}:{status:`invalid-result`,layers:[],receivedType:typeof e}}catch(e){return{status:`error`,layers:[],error:e}}}function Ul(e,t){return t.status===`unknown-template`?{code:`unknown-template`,template:e,message:`Unknown template "${e}"`}:t.status===`invalid-result`?{code:`invalid-template-result`,template:e,receivedType:t.receivedType,message:`Template "${e}" returned ${t.receivedType}, not a layer array`}:{code:`template-error`,template:e,cause:t.error,message:`Template "${e}" failed`}}function Wl(e,t,n,r,i){return r?Si(e,t,i?.bottomLayers??yi(r.bottomLayers,n),i?.topLayers??yi(r.topLayers,n)):e}var Gl={title:{label:`Title`,description:`A bold opening slide with large title text, perfect for covers and chapters.`},sectionHeader:{label:`Section Header`,description:`A clean section break with a prominent title and optional background image.`},bigText:{label:`Big Text`,description:`Gigantic uppercase display text — thumbnail-style — on a theme surface or over an image with a contrast bloom.`},content:{label:`Content`,description:`Shows a heading and the complete body in a loss-averse content-first layout.`},statHighlight:{label:`Stat Highlight`,description:`Showcases a single key number or metric with supporting context.`},quote:{label:`Quote`,description:`Displays a stylized pull quote with decorative marks and attribution.`},factCard:{label:`Fact Card`,description:`Presents a focused fact or insight with a labeled header and body text.`},twoColumn:{label:`Two Column`,description:`Divides the slide into two equal side-by-side content columns.`},dateEvent:{label:`Date Event`,description:`Highlights a date-based event or milestone with a prominent date display.`},imageWithCaption:{label:`Image with Caption`,description:`Displays a full-bleed image with an optional caption below.`},leftFeature:{label:`Left Feature`,description:`Image on the left, title and body text stacked on the right.`},rightFeature:{label:`Right Feature`,description:`Image on the right, title and body text stacked on the left.`},map:{label:`Map`,description:`Embeds an interactive map centered on a geographic location.`},fullBleedQuote:{label:`Full Bleed Quote`,description:`A full-width quote that spans the entire slide for maximum impact.`},list:{label:`List`,description:`Renders a bulleted or numbered list in a clean, card-style layout.`},photoGrid:{label:`Photo Grid`,description:`Arranges multiple photos in a 2×2 or 3×3 mosaic grid.`},definitionCard:{label:`Definition Card`,description:`Shows a term and its definition in a structured, dictionary-style card.`},comparisonBar:{label:`Comparison Bar`,description:`Visualizes two or more values side-by-side with labeled horizontal bars.`},pullQuote:{label:`Pull Quote`,description:`A stylized pull quote with large decorative marks and centered text.`},videoWithCaption:{label:`Video with Caption`,description:`Embeds a video player with an optional caption below.`},videoPullQuote:{label:`Video Pull Quote`,description:`Combines a video panel with a highlighted pull quote side-by-side.`},dataTable:{label:`Data Table`,description:`Renders tabular data in a clean, styled table with a header row.`},barChart:{label:`Bar Chart`,description:`Horizontal bars from the block's markdown table — one bar per row.`},columnChart:{label:`Column Chart`,description:`Vertical columns from the block's markdown table — one column per row.`},pieChart:{label:`Pie Chart`,description:`A pie of the block's markdown table — each row becomes a labeled slice.`},donutChart:{label:`Donut Chart`,description:`A donut of the block's markdown table — each row becomes a labeled slice.`},lineChart:{label:`Line Chart`,description:`Lines from the block's markdown table — one line per value column.`},areaChart:{label:`Area Chart`,description:`Filled area lines from the block's markdown table — one area per value column.`},scatterChart:{label:`Scatter Chart`,description:`An x/y scatter plot from the block's markdown table's numeric columns.`},diagram:{label:`Diagram`,description:`Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.`},tree:{label:`Tree`,description:`Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.`},timeline:{label:`Timeline`,description:`Plots events across one or more horizontal tracks with callouts and optional branching links.`},layout:{label:`Layout`,description:`Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.`},drawing:{label:`Drawing`,description:`Free-form sketches — draw shapes, paths, and text directly on a 2D surface.`}},Kl={title:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},sectionHeader:{role:`divider`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},bigText:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},content:{role:`content`,bodyPolicy:`complete`,safeForContentFirst:!0,placement:`heading`},statHighlight:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},quote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},factCard:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},twoColumn:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},dateEvent:{role:`event`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},imageWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},leftFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},rightFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},map:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},fullBleedQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},list:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},photoGrid:{role:`media`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},definitionCard:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},comparisonBar:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pullQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoPullQuote:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},dataTable:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},barChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},columnChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pieChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},donutChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},lineChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},areaChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},scatterChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},diagram:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},tree:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},timeline:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},drawing:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},layout:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`}},ql=120,Jl=26,Yl=62;function Xl(e){let t=e.trim().length;if(t<=Jl)return ql;let n=ql*Math.sqrt(Jl/t);return Math.max(Yl,Math.round(n))}function Zl(e){let{theme:t}=e;return t.id===`standard`&&b(t.colors.background)>.85}var Ql=[{pos:0,alpha:.95},{pos:38,alpha:.86},{pos:58,alpha:.4},{pos:78,alpha:.1},{pos:100,alpha:0}];function $l(e){return`linear-gradient(0deg, ${Ql.map(t=>`${S(e,t.alpha)} ${t.pos}%`).join(`, `)})`}function eu(e,t){let n=H(t,e.imageTreatment),{heroSrc:r,heroAlt:i,title:a,subtitle:o,ambientMotion:s,heroCredit:c,heroLicense:l}=e,{theme:u,layout:d}=t,f=!r&&Zl(t),p=z(Xl(a),t,!0),m=z(40,t,!1),h=[];if(r){let e=Ri(s);h.push({type:`image`,id:`cover-hero`,content:{src:r,alt:i||a,fit:`cover`,credit:c,license:l,...n?{treatment:n}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e},{type:`shape`,id:`cover-gradient`,content:{shape:`rect`,fill:$l(u.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}})}else f?h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:u.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`cover-bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${S(u.colors.primary,.16)} 0%, ${S(u.colors.primary,.07)} 38%, ${S(u.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}):h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${u.colors.primary} 0%, ${u.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),h.push({type:`shape`,id:`cover-accent`,content:{shape:`rect`,fill:f?S(u.colors.primary,.24):`rgba(255, 255, 255, 0.2)`},position:{x:`35%`,y:o?`42%`:`58%`,width:`30%`,height:`2px`}});return h.push({type:`text`,id:`cover-title`,content:{text:a,style:{fontSize:p,fontFamily:R(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:!f}},position:{x:`50%`,y:r?o?`70%`:`75%`:o?d.primaryY:`50%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),o&&h.push({type:`text`,id:`cover-subtitle`,content:{text:o,style:{fontSize:m,fontFamily:R(t,`body`),fontWeight:f?`bold`:`normal`,color:f?S(u.colors.text,.78):u.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:r?`82%`:d.secondaryY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),h}function tu(e){return{heroSrc:e.heroSrc,heroAlt:e.heroAlt,title:e.title,subtitle:e.subtitle,ambientMotion:e.ambientMotion,heroCredit:e.heroCredit,heroLicense:e.heroLicense}}function nu(e,t,n=`cover`){let r=tu(e),i={id:`cover-block`,duration:0,audioSegment:-1};if(n===`title`)return Fi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t);if(n===`sectionHeader`)return Yi({...i,template:`sectionHeader`,title:r.title,imageSrc:r.heroSrc,imageAlt:r.heroAlt,ambientMotion:r.ambientMotion},t);if(n===`bigText`||n===`bigTextImage`){let e=n===`bigTextImage`&&!!r.heroSrc;return ia({...i,template:`bigText`,title:r.title,...e?{imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,ambientMotion:r.ambientMotion}:{}},t)}return n===`imageWithCaption`?r.heroSrc?ma({...i,template:`imageWithCaption`,imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,caption:r.title,subtitle:r.subtitle,ambientMotion:r.ambientMotion,imageCredit:r.heroCredit,imageLicense:r.heroLicense,isTitle:!0},t):Fi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t):eu(r,t)}function ru(e,t,n,r,i,a,o,s,c,u){let f=Nl(e,{theme:r,viewport:i,persistentLayers:a??!1,blockIndex:t,totalBlocks:n,failureMode:c},{registry:s,expandedPersistentLayers:o});f.diagnostic&&u?.(f.diagnostic,e,t);let p=l(e)?{id:e.id,startTime:0,duration:e.duration,audioSegment:e.audioSegment,...f.layers.length>0?{layers:f.layers}:{},transition:e.transition,template:e.template}:{...d(e),...f.layers.length>0?{layers:f.layers}:{}},m=_(p,r,t);return m!==p.transition&&(p.transition=m),p}function iu(e,t={}){let n=t,r=n.theme??k,i=n.viewport??p.landscape,{persistentLayers:a,audioSegments:o,customTemplates:s,failureMode:c=`fallback`,onDiagnostic:l,splitLongBlocks:u=!0,mergeShortBlocks:f=!0}=n,m=e.length,h=s&&s.length>0?Nc(s):Mc,g=a===!1?void 0:a??r.persistentLayers,_=g?{bottomLayers:yi(g.bottomLayers,r),topLayers:yi(g.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=ru(e,n,m,r,i,g,_,h,c,l);return a.startTime=t,t+=a.duration,a})}let v=new Map;e.forEach((e,t)=>{let n=e.audioSegment??0;v.has(n)||v.set(n,[]),v.get(n).push({block:e,originalIndex:t})});let y=Array(e.length);for(let[e,t]of v){let n=o[e];if(!n){let e=0;for(let{block:n,originalIndex:a}of t){let t=ru(n,a,m,r,i,g,_,h,c,l);t.startTime=e,e+=t.duration,y[a]=t}continue}let a=[],s=[];for(let e of t)e.block.template===`sectionHeader`?a.push(e):s.push(e);let p=a.reduce((e,{block:t})=>e+(t.duration??0),0),v=s.reduce((e,{block:t})=>e+(t.duration??0),0),b=n.duration-p,x=v>0&&b>0?b/v:1,S=[];for(let{block:e,originalIndex:n}of t){let t=ru(e,n,m,r,i,g,_,h,c,l),a=e;S.push({block:t,originalIndex:n,templateBlock:a,hasSourceTiming:typeof a.sourceStartTime==`number`})}let C=S.some(e=>e.hasSourceTiming);S.sort((e,t)=>{if(C){let n=e.templateBlock.template===`sectionHeader`,r=t.templateBlock.template===`sectionHeader`;if(n&&!r)return-1;if(!n&&r)return 1;if(e.hasSourceTiming&&t.hasSourceTiming)return e.templateBlock.sourceStartTime-t.templateBlock.sourceStartTime;if(e.hasSourceTiming&&!t.hasSourceTiming)return-1;if(!e.hasSourceTiming&&t.hasSourceTiming)return 1}return e.originalIndex-t.originalIndex});let w=0;for(let e=0;e<S.length;e++){let t=S[e],{block:r,templateBlock:i}=t;if(t.hasSourceTiming){let e=i.sourceStartTime;r.startTime=n.startTime+e,typeof i.sourceDuration==`number`&&(r.duration=Math.max(5,i.sourceDuration)),w=e+r.duration}else if(i.template===`sectionHeader`)r.startTime=n.startTime+w,w+=r.duration;else{r.startTime=n.startTime+w;let e=r.duration*x;r.duration=e,w+=e}y[t.originalIndex]=r}let T=S.map(e=>y[e.originalIndex]).sort((e,t)=>e.startTime-t.startTime);for(let e=0;e<T.length-1;e++){let t=T[e],n=T[e+1],r=t.startTime+t.duration;r>n.startTime?t.duration=n.startTime-t.startTime:r<n.startTime-.5&&(t.duration=Math.max(.1,n.startTime-t.startTime))}let E=n.startTime+n.duration;for(;T.length>1;){let e=T[T.length-1],t=E-e.startTime;if(f&&t<5&&e.template!==`sectionHeader`){let t=T[T.length-2];t.duration=E-t.startTime,e.duration=0,e.startTime=E,T.pop()}else{e.startTime+e.duration<E&&(e.duration=E-e.startTime);break}}if(T.length===1){let e=T[0];e.startTime+e.duration<E&&(e.duration=E-e.startTime)}let D=f;for(;D;){D=!1;for(let e=T.length-1;e>=1;e--){let t=T[e];if(t.duration>0&&t.duration<5){let n=T[e-1];n.duration=t.startTime+t.duration-n.startTime,t.duration=0,t.startTime=E,T.splice(e,1),D=!0;break}}}if(u)for(let e=0;e<T.length;e++){let t=T[e];if(t.duration>20){let e=Math.ceil(t.duration/20),n=t.duration/e;if(n>=5){t.duration=n;for(let r=1;r<e;r++){let e={id:`${t.id}-split-${r}`,startTime:t.startTime+r*n,duration:n,audioSegment:t.audioSegment,layers:(t.layers??[]).map(e=>({...d(e),id:`${e.id}-split-${r}`})),transition:{type:`dissolve`,duration:1},template:t.template};y.push(e)}}}}}return f?y.filter(e=>e&&e.duration>0):y.filter(Boolean)}function au(){return Object.keys(Mc)}function ou(e){return j(e)in Mc}var su={width:1920,height:1080},cu={label:`lb`,description:`ds`,viewport:`vp`,layers:`ly`,name:`nm`,type:`ty`,position:`po`,content:`ct`,animation:`am`,width:`wd`,height:`hg`,anchor:`an`,text:`tx`,style:`sy`,fontSize:`fz`,fontFamily:`ff`,fontWeight:`fw`,color:`cl`,textAlign:`al`,verticalAlign:`vl`,lineHeight:`lh`,shadow:`sd`,background:`bg`,backgroundOpacity:`bo`,backgroundGradient:`bj`,borderColor:`bc`,borderWidth:`bw`,borderStyle:`bs`,padding:`pd`,maxLines:`mx`,shape:`sp`,fill:`fl`,fillOpacity:`fo`,gradient:`gr`,stroke:`sk`,strokeWidth:`sw`,borderRadius:`br`,shapeKind:`kd`,dasharray:`da`,arrow:`ar`,startMarker:`st`,endMarker:`em`,src:`sc`,alt:`at`,fit:`ft`,credit:`cr`,license:`lc`,from:`fr`,angle:`ag`},lu=Object.fromEntries(Object.entries(cu).map(([e,t])=>[t,e]));function uu(e,t){if(Array.isArray(e))return e.map(e=>uu(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=uu(i,t);return n}return e}function du(e){return!e||e.width===su.width&&e.height===su.height}function fu(e){if(!e)return;let t=_u(e[T]);if(!t)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r={name:t.name,label:t.label,viewport:t.viewport??{...su},layers:t.layers};t.description!==void 0&&(r.description=t.description);let i=v(r);i.template&&n.push(i.template)}return n.length>0?n:void 0}function pu(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let e={lb:t.label};t.description&&(e.ds=t.description),du(t.viewport)||(e.vp=t.viewport),e.ly=uu(t.layers,cu),n[t.name]=e}return JSON.stringify(n,null,t?.pretty?2:void 0)}function mu(e){return Object.entries(e).map(([e,t])=>{let n=t&&typeof t==`object`?t:{},r={name:e,label:n.lb,viewport:n.vp??{...su},layers:uu(n.ly??[],lu)};return typeof n.ds==`string`&&(r.description=n.ds),r})}function hu(e){return Array.isArray(e)?e:e&&typeof e==`object`?mu(e):null}function gu(e){try{return JSON.parse(e)}catch{return}}function _u(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return mu(e);if(typeof e!=`string`)return null;let t=gu(e.trim());if(t!==void 0)return hu(t);try{let t=gu(He(e));if(t!==void 0)return hu(t)}catch{}return null}function vu(e){if(e==null)return;let t=e;if(typeof t==`string`){let e=t.trim();if(!e)return;try{t=JSON.parse(e)}catch{return}}if(Array.isArray(t))return t;if(t&&typeof t==`object`)return Object.values(t)}function yu(e){if(!e)return;let t=vu(e[O]);if(!t)return;let n=[];for(let e of t){let t=E(e);t.valid&&t.theme&&n.push(t.theme)}return n.length>0?n:void 0}function bu(e,t){if(!e||e.length===0)return;let n={};for(let t of e)n[t.id]=t;return JSON.stringify(n,null,t?.pretty?2:void 0)}var xu=new Set([`json`,`yaml`,`yml`]);function Su(e){if(!e.lang||!xu.has(e.lang.toLowerCase()))return!1;let t=e.meta??``;return/\bdata\b/.test(t)}function Cu(e){if(e.lang?.toLowerCase()===`json`)try{let t=JSON.parse(e.value);return typeof t!=`object`||!t||Array.isArray(t)?{error:`JSON data fence must contain a top-level object ({"key": …})`}:{data:t}}catch(e){return{error:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}try{return{data:Ou(e.value)}}catch(e){return{error:`invalid YAML: ${e instanceof Error?e.message:String(e)}`}}}function wu(e,t){let n=JSON.stringify(t,null,2),r=e.findIndex(e=>e.type===`code`&&Su(e));if(r<0){let t={type:`code`,lang:`json`,meta:`data`,value:n};return[...e,t]}let i=[...e];return i[r]={...e[r],value:n},i}function Tu(e){let t=e.trim();if(t.length>=2){let e=t[0];if((e===`"`||e===`'`)&&t.endsWith(e))return t.slice(1,-1)}return t===`true`?!0:t===`false`?!1:t===`null`||t===`~`?null:t!==``&&!isNaN(Number(t))?Number(t):t}function Eu(e){let t=[],n=``,r=null;for(let i of e)r?(n+=i,i===r&&(r=null)):i===`"`||i===`'`?(r=i,n+=i):i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t.map(e=>e.trim()).filter(e=>e!==``)}function Du(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?Eu(t.slice(1,-1)).map(Tu):Tu(t)}function Ou(e){let t={},n=e.split(`
|
|
25
|
-
`),r=null,i=null,a=-1;for(let e=0;e<n.length;e++){let o=n[e],s=o.trim();if(!s||s.startsWith(`#`))continue;let c=o.length-o.trimStart().length;if(c>0){if(!r)throw Error(`line ${e+1}: unexpected indented line without a preceding "key:" line`);if(a<0&&(a=c),c>a)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);if(s.startsWith(`- `)){if(i===`map`)throw Error(`line ${e+1}: cannot mix list items and mapping keys under "${r}"`);i=`list`,t[r].push(Du(s.slice(2)));continue}if(i===`list`)throw Error(`line ${e+1}: cannot mix mapping keys and list items under "${r}"`);let n=s.indexOf(`:`);if(n<1)throw Error(`line ${e+1}: expected "key: value"`);let o=s.slice(n+1).trim();if(o===``)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);i!==`map`&&(i=`map`,t[r]={}),t[r][s.slice(0,n).trim()]=Du(o);continue}r=null,i=null,a=-1;let l=s.indexOf(`:`);if(l<1)throw Error(`line ${e+1}: expected "key: value"`);let u=s.slice(0,l).trim(),d=s.slice(l+1).trim();d===``?(t[u]=[],r=u):t[u]=Du(d)}return t}function ku(e){return e?.find(e=>e.type===`table`)}function Au(e){let t=e=>e.children.map(e=>o(e).trim()),[n,...r]=e.children;return{headers:n?t(n):[],rows:r.map(t),...e.align&&e.align.some(e=>e!=null)?{align:e.align}:{}}}function ju(e){let t=ue(e.trim()),n=t.length>0&&t[0].indexOf(`=`)>0,r=n||t.length===0?void 0:t[0],i=+!n,a={};for(let e=i;e<t.length;e++){let n=le(t[e]);n&&(a[n.key]=n.value)}return{template:r,params:a}}function Mu(e){if(e.type!==`paragraph`)return null;let t=e.children??[];if(t.length!==1||t[0].type!==`text`)return null;let n=me(t[0].value.trim());return!n||n.index!==0?null:ju(n.inner)}var Nu=new Set([`audio`,`video`,`media`]);function Pu(e){return e!=null&&Nu.has(e)}function Fu(e){return e==null?null:pe(e)}function Iu(e){let t=e.placement??e.presentation;if(t===`content`)return`content`;if(t===`pip`||t===`picture-in-picture`)return`picture-in-picture`;if(t===`overlay`||t===`full-frame`)return`overlay`;if(e.pip===``||e.pip===`true`)return`picture-in-picture`;if(e.overlay===``||e.overlay===`true`)return`overlay`}function Lu(e){return e!==`false`&&e!==`0`}function Ru(e){return e===`small`||e===`large`?e:void 0}function zu(e){return e===`square`||e===`wide`?e:void 0}function Bu(e){return e===`top-left`||e===`top-right`||e===`bottom-left`||e===`bottom-right`?e:void 0}function Vu(e,t){let{template:n,params:r}=e;if(!n||!Nu.has(n))return null;let i=r.src;if(!i)return null;let a=n===`video`?`video`:`audio`,o=r.anchor===`document`||r.span===`document`?`document`:`block`,s={id:t,src:i,kind:a,startAt:Fu(r.startAt??r.startTime)??0,anchor:o},c=a===`video`?Iu(r):void 0;c&&c!==`content`&&(s.placement=c);let l=Ru(r.pipSize),u=zu(r.pipShape),d=Bu(r.pipPosition);if(l&&(s.pipSize=l),u&&(s.pipShape=u),d&&(s.pipPosition=d),a===`video`&&c&&c!==`content`&&r.lockToBlock!=null){let e=Lu(r.lockToBlock);s.lockToBlock=e,s.anchor=e?`block`:`document`,e&&(s.startAt=0)}let f=Fu(r.clipStart),p=Fu(r.clipEnd);return f!=null&&(s.clipStart=f),p!=null&&(s.clipEnd=p),s.lockToBlock===!0&&delete s.clipEnd,(r.spillover===`true`||r.spillover===``)&&(s.spillover=!0),s}function Hu(e){let t=e=>{for(let n of e){if(n.type!==`htmlElement`)continue;if(n.tagName===`video`)return n;let e=t(n.children);if(e)return e}return null};return t(e)}function Uu(e){if(e.type===`htmlBlock`){if(!/^\s*<video\b/i.test(e.rawHtml))return null;let t=Hu(e.htmlChildren);return t?{element:t,raw:e.rawHtml.trim()}:null}if(e.type!==`paragraph`||!e.children.every(e=>e.type===`htmlInline`))return null;let t=e.children.map(e=>e.type===`htmlInline`?e.rawHtml:``).join(``);if(!/^\s*<video\b[\s\S]*<\/video>\s*$/i.test(t))return null;for(let n of e.children){if(n.type!==`htmlInline`)continue;let e=Hu(n.htmlChildren);if(e)return{element:e,raw:t.trim()}}return null}function Wu(e,t){let n=Uu(e);if(!n)return null;let{element:r}=n,i=Iu({placement:r.attributes[`data-squisq-video-placement`]??``});if(!i||i===`content`)return null;let a=r.attributes.src;if(!a)return null;let o=Lu(r.attributes[`data-squisq-video-lock-to-block`]),s={id:t,src:a,kind:`video`,placement:i,lockToBlock:o,startAt:o?0:Fu(r.attributes[`data-squisq-video-start-at`])??0,anchor:o?`block`:`document`},c=Ru(r.attributes[`data-squisq-video-pip-size`]),l=zu(r.attributes[`data-squisq-video-pip-shape`]),u=Bu(r.attributes[`data-squisq-video-pip-position`]);c&&(s.pipSize=c),l&&(s.pipShape=l),u&&(s.pipPosition=u);let d=Fu(r.attributes[`data-squisq-video-clip-start`]),f=Fu(r.attributes[`data-squisq-video-clip-end`]);return d!=null&&(s.clipStart=d),!o&&f!=null&&(s.clipEnd=f),s}function Gu(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(let c of e??[]){let e=Mu(c),l=e?Vu(e,``):Wu(c,``);if(l){l.id=t(l.src,o++);let e=c.position?.start.line;if(e!=null&&(l.sourceLine=e),n!==void 0){let e=Uu(c),t=c.type===`paragraph`&&c.children?.[0]?.type===`text`?c.children[0].value.trim():e?.raw;l.origin={blockId:n,index:s,...t===void 0?{}:{raw:t},...e?{format:`html`}:{}}}(l.anchor===`document`?i:r).push(l)}else a.push(c);s++}return{media:r,documentMedia:i,remaining:a}}function Ku(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function qu(e,t){let n=e.template,r=e.params,i=Object.keys(r).length>0,a={id:t.makeId(e),startTime:0,duration:t.defaultDuration,audioSegment:0,template:j(n),standaloneAnnotation:!0,sourceAnnotation:{template:n,...i?{params:r}:{}},...r.title?{title:r.title}:{}};return i&&(a.templateOverrides=r,Ku(a,oe(r).blockMeta)),a}function Ju(e,t){let n=[],r=[],i=null;for(let a of e??[]){let e=Mu(a);if(e!=null&&e.template!=null&&!Pu(e.template)){let n=qu(e,t);r.push(n),i=n}else i?(i.contents??=[]).push(a):n.push(a)}return{leading:n,blocks:r}}function Yu(e){if(e.type!==`paragraph`)return null;let t=e.children;if(t.length===0)return null;let n=t[t.length-1];return n.type===`text`?n.value:null}function Xu(e){if(Mu(e)?.template)return!0;let t=Yu(e);if(t==null)return!1;let n=me(t);return!!n&&n.index>0&&!!ju(n.inner).template}function Zu(e,t,n){let r=[...e],i=r[t];if(i.type!==`paragraph`)return r;let a=[...i.children],o=a[a.length-1];if(o.type!==`text`)return r;let s=o.value.slice(0,n);return s.length===0&&a.length===1?r.splice(t,1):(a[a.length-1]={...o,value:s},r[t]={...i,children:a}),r}function Qu(e){if(!e||e.length===0)return null;let t=e.length-1,n=e[t],r=null,i=null,a=Mu(n);if(a?.template&&n.type===`paragraph`){let o=n.children[0];r={template:a.template,params:a.params,origin:{kind:`paragraph`,index:t,raw:o&&o.type===`text`?o.value.trim():``}},i=e.slice(0,t)}else{let a=Yu(n),o=a==null?null:me(a);if(a!=null&&o&&o.index>0){let n=ju(o.inner);n.template&&(r={template:n.template,params:n.params,origin:{kind:`trailing`,index:t,suffix:a.slice(o.index)}},i=Zu(e,t,o.index))}}if(!r||!i)return null;for(let n=0;n<t;n++)if(Xu(e[n]))return null;return{data:r,strippedContents:i}}var $u=/[^\w\s-]/g,ed=/[\s_]+/g,td=/-+/g,nd=/^-|-$/g;function rd(e){return e.toLowerCase().replace($u,``).replace(ed,`-`).replace(td,`-`).replace(nd,``)||`block`}function id(){let e=new Map,t=(t,n)=>{let r=rd(o(t)),i=e.get(r)??0;return e.set(r,i+1),i===0?r:`${r}-${i+1}`};return t.reserve=t=>{e.set(t,Math.max(e.get(t)??0,1))},t.fromText=t=>{let n=rd(t),r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`},t}function ad(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function od(e){if(!e)return{};let t=e.templateAnnotation?.params?oe(e.templateAnnotation.params).blockMeta:{},n=e.attributes?.blockMeta??{};return{...t,...n}}function sd(e){return e.promotedBodyAnnotation?.params?oe(e.promotedBodyAnnotation.params).blockMeta:e.sourceHeading?od(e.sourceHeading):e.sourceAnnotation?.params?oe(e.sourceAnnotation.params).blockMeta:{}}function cd(e){return sd(e)}function ld(e){for(let t of e){if(!t.sourceHeading||t.sourceHeading.templateAnnotation?.template)continue;let e=Qu(t.contents);if(!e)continue;let{template:n,params:r}=e.data;Pu(n)||!ou(n)||(t.template=j(n),Object.keys(r).length>0&&(t.templateOverrides=r,ad(t,oe(r).blockMeta)),t.contents=e.strippedContents,t.promotedBodyAnnotation=e.data)}}function ud(e,t,n){let r=[];for(let i of e){i.children&&i.children.length>0&&(i.children=ud(i.children,t,n));let{leading:e,blocks:a}=Ju(i.contents,{makeId:t,defaultDuration:n});if(a.length===0){r.push(i);continue}i.contents=e,(i.children?.length??0)>0&&!ae(i.template)?(i.children=[...a,...i.children],r.push(i)):r.push(i,...a)}return r}function dd(e,t){let r=t?.articleId??`markdown-doc`,i=t?.defaultTemplate??`sectionHeader`,a=t?.defaultDuration??5,s=t?.generateId?null:id(),c=t?.generateId??s,l=[],u=[],d=0,f=[],p=[],m=null;function h(){m&&p.length>0&&(m.contents=(m.contents??[]).concat(p),p=[])}function g(e){let t=e?.attributes?.id,n=t||(e?c(e,d++):`preamble`);t&&s&&s.reserve(t);let r=e?.templateAnnotation,l=r?.template??(e?i:void 0),u=l==null?void 0:j(l),f=e?o(e):void 0,p={id:n,startTime:0,duration:a,audioSegment:0,template:u,...e?{sourceHeading:e}:{},...f?{title:f}:{}};r?.params&&(p.templateOverrides=r.params,ad(p,oe(r.params).blockMeta));let m=e?.attributes;return m&&(m.blockMeta&&ad(p,m.blockMeta),m.classes&&m.classes.length>0&&(p.classes=m.classes),m.metadata&&Object.keys(m.metadata).length>0&&(p.metadata=m.metadata)),p}for(let t of e.children)if(t.type===`heading`){let e=t,n=e.depth;h();let r=g(e);if(f.length===0)m&&!m.sourceHeading&&l.push(m),l.push(r),f.push({block:r,depth:n});else{for(;f.length>0&&f[f.length-1].depth>=n;)f.pop();if(f.length===0)l.push(r),f.push({block:r,depth:n});else{let e=f[f.length-1].block;e.children||=[],e.children.push(r),f.push({block:r,depth:n})}}m=r}else m||=g(null),p.push(t);h(),m&&!m.sourceHeading&&!l.includes(m)&&l.push(m);let _=[];for(let e of fd(l)){let{media:t,documentMedia:n,remaining:r}=Gu(e.contents,(t,n)=>`${e.id}-media-${n}-${t.replace(/[^a-zA-Z0-9]+/g,`-`)}`,e.id);t.length>0&&(e.media=t),n.length>0&&_.push(...n),e.contents&&=r}l.length>0&&!l[0].sourceHeading&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift(),ld(fd(l)),l=ud(l,e=>{let t=e.params.title??e.template??`block`;return s?s.fromText(t):rd(t)},a),l.length>0&&!l[0].sourceHeading&&!l[0].standaloneAnnotation&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift();let v=fd(l);for(let e of v)_d(e,u);for(let e of v)vd(e,u),bd(e,u),yd(e,u);(t?.autoTemplates??!0)&&!Sd(e)&&Cd(l,j(i),{featureIndex:0});for(let e of v)xd(e,u);let y=new Map;for(let e of v)y.has(e.id)?u.push({severity:`error`,code:`duplicate-id`,message:`Duplicate block id "${e.id}" \u2014 later connections and links are ambiguous`,blockId:e.id,...gd(e)}):y.set(e.id,e);for(let e of v)for(let t of e.connectsTo??[])y.has(t.target)||u.push({severity:`warning`,code:`unresolved-connection`,message:`Block "${e.id}" connects to unknown target "${t.target}"`,blockId:e.id,...gd(e)});let b=[];for(let e of v){if(sd(e).duration!=null)continue;let t=wd(e);if(t.length>0){let n=si(t);e.duration=Math.max(3,n.seconds)}else e.duration=a}let x=0;for(let e of v){sd(e).startTime??(e.startTime=x);let t=wd(e);if(t.length>0){let n=Ed(t);if(n.length>0){let t=e.duration/n.length;for(let e=0;e<n.length;e++)b.push({text:n[e],startTime:x+e*t,endTime:x+(e+1)*t,audioSegment:0})}}x+=e.duration}let S=new Map(v.map(e=>[e.id,e]));for(let e of _)e.lockToBlock===!1&&e.origin?.format===`html`&&!/\bdata-squisq-video-start-at\s*=/i.test(e.origin.raw??``)&&(e.startAt=S.get(e.origin.blockId)?.startTime??0);let C=b.length>0?{phrases:b,...t?.captionsGeneratedAt?{generatedAt:t.captionsGeneratedAt}:{},version:1}:void 0,w=fu(e.frontmatter),T=yu(e.frontmatter),E=n(e.frontmatter),D={articleId:r,duration:x,blocks:l,audio:{segments:[]},...C?{captions:C}:{},...e.frontmatter?{frontmatter:e.frontmatter}:{},...E?{themeId:E}:{},...w?{customTemplates:w}:{},...T?{customThemes:T}:{},...u.length>0?{diagnostics:u}:{},..._.length>0?{documentMedia:_}:{}};if(t?.generateCoverBlock??!0){let n=jd(e,l,t?.fileName);n&&(D.startBlock=n)}return D}function fd(e){let t=[];for(let n of e)t.push(n),n.children&&t.push(...fd(n.children));return t}function pd(e){let t=[];for(let n of e)t.push(n),n.children&&!ae(n.template)&&t.push(...pd(n.children));return t}function md(e){let t=0;for(let n of e)t+=1,n.children&&(t+=md(n.children));return t}function hd(e){return e.sourceHeading?.depth??0}function gd(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function _d(e,t){let n;for(let r of e.contents??[]){if(r.type!==`code`||!Su(r))continue;let i=Cu(r);if(i.error){t.push({severity:`error`,code:`data-fence-parse`,message:`Data fence in block "${e.id}": ${i.error}`,blockId:e.id,...r.position?{line:r.position.start.line}:gd(e)});continue}n={...n,...i.data}}if(ge.has(j(e.template??``))){let t=t=>n&&t in n||e.templateOverrides&&t in e.templateOverrides;if(!t(`headers`)&&!t(`rows`)){let t=ku(e.contents);t&&(n={...Au(t),...n})}}n&&Object.keys(n).length>0&&(e.templateData=n)}function vd(e,t){if(j(e.template??``)!==`diagram`||e.children&&e.children.length>0||e.templateData&&`nodes`in e.templateData)return;let n=(e.contents??[]).filter(e=>e.type===`code`);if(n.length!==1||!nn(n[0].lang))return;let r=Tt(n[0].value);if(r.nodes.length===0){t.push({severity:`warning`,code:`ascii-diagram-parse`,message:`Diagram block "${e.id}": code fence did not parse as an ASCII diagram`,blockId:e.id});return}let{nodes:i,edges:a}=Da(r);e.templateData={nodes:i,edges:a,...e.templateData}}function yd(e,t){if(j(e.template??``)!==`tree`||e.templateData&&`items`in e.templateData)return;let n=so(`tree`,e.title??``,e.contents);if(!n||!Array.isArray(n.items)||n.items.length===0){t.push({severity:`warning`,code:`tree-parse`,message:`Tree block "${e.id}": body did not parse as a tree`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function bd(e,t){if(j(e.template??``)!==`timeline`||e.templateData&&`tracks`in e.templateData)return;let n=so(`timeline`,e.title??``,e.contents);if(!n||!Array.isArray(n.tracks)||n.tracks.length===0){t.push({severity:`warning`,code:`timeline-parse`,message:`Timeline block "${e.id}": body did not parse as an ASCII timeline`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function xd(e,t){if(j(e.template??``)!==`timeline`||!e.templateData||!(`tracks`in e.templateData))return;let n=(e.contents??[]).filter(e=>e.type===`code`&&gr(e.lang));if(n.length===1)for(let r of Nn(n[0].value).warnings){let n=/^unresolved-link\((.+)\)$/.exec(r);t.push({severity:`warning`,code:n?`timeline-unresolved-link`:`timeline-parse-warning`,message:n?`Timeline block "${e.id}": unresolved branch ${n[1]}`:`Timeline block "${e.id}": ${r}`,blockId:e.id})}}function Sd(e){let t=e.frontmatter?.[`squisq-auto-templates`];return t===!1||t===`false`||t===`off`||t===`no`||t===0}function Cd(e,t,n){for(let r of e){let e=!!r.sourceHeading?.templateAnnotation?.template||!!r.promotedBodyAnnotation;if(r.sourceHeading&&!e&&r.template===t){let e=ii(ti(r.contents??[]),n.featureIndex);if(e&&oo(e,r.contents)){let t=so(e,r.title??``,r.contents,{preserveSourceHeading:!0});t&&((e===`leftFeature`||e===`rightFeature`)&&(n.featureIndex+=1),r.template=e,r.autoTemplate=!0,r.templateData={...t,...r.templateData})}}r.children&&r.children.length>0&&!ae(r.template)&&Cd(r.children,t,n)}}function wd(e){if(!e.contents||e.contents.length===0)return``;let t=j(e.template??``),n=t===`diagram`&&e.templateData!==void 0&&`nodes`in e.templateData||t===`timeline`&&e.templateData!==void 0&&`tracks`in e.templateData||t===`tree`&&e.templateData!==void 0&&`items`in e.templateData;return e.contents.filter(e=>!(n&&e.type===`code`)).map(e=>o(e)).join(`
|
|
26
|
-
`).trim()}var
|
|
27
|
-
${r}`:n||r}function
|
|
28
|
-
|
|
29
|
-
`,i=[];for(let t of
|
|
30
|
-
`)?t.pauseAfter=2:Vd(t.text)&&(t.pauseAfter=1)}let d=Array(s.length+1);d[0]=0;for(let e=0;e<s.length;e++)d[e+1]=d[e]+s[e].syllables;return{sourceText:a,tokens:s,blocks:o,totalSyllables:d[s.length],cumulativeSyllables:d}}var Rd=/["')\]}»”’]+$/;function zd(e){return/[\p{L}\p{N}]/u.test(e)}function Bd(e){return e.replace(/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,``)}function Vd(e){let t=e.replace(Rd,``),n=t.charAt(t.length-1);return n?n===`,`||n===`.`||n===`;`||n===`:`||n===`!`||n===`?`:!1}function Hd(e,t,n){return e<t?t:e>n?n:e}function Ud(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Hd(t,0,n),i=Math.floor(r);return i>=n?e.totalSyllables:e.cumulativeSyllables[i]+(r-i)*e.tokens[i].syllables}function Wd(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Hd(t,0,e.totalSyllables),i=0,a=n;for(;i<a;){let t=i+a+1>>1;e.cumulativeSyllables[t]<=r?i=t:a=t-1}if(i>=n)return n;let o=r-e.cumulativeSyllables[i],s=e.tokens[i].syllables;return i+(s>0?o/s:0)}function Gd(e,t){if(e.length===0)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i].tSec<=t?n=i:r=i-1}return e[n].tSec<=t?n:0}function Kd(e,t,n,r){let i=t.words.map(t=>{let n=e.tokens[t.tokenIndex];return{id:`word-${t.tokenIndex}`,time:t.tSec,charOffset:n?.charOffset??0,textFragment:n?.text??``}}),a=t.blocks.map(e=>({...e.blockId?{blockId:e.blockId}:{},...e.heading===void 0?{}:{heading:e.heading},blockIndex:e.blockIndex,charStart:e.charStart,charEnd:e.charEnd,startSec:e.startSec,endSec:e.endSec}));return{version:3,sourceText:e.sourceText,duration:Number.isFinite(n)&&n>=0?n:0,bookmarks:i,blocks:a,...Jd(r?.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},generator:{name:`squisq-teleprompter`,method:`dsp-align`,...r?.baseWpm===void 0?{}:{baseWpm:r.baseWpm}}}}function qd(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function Jd(e){return typeof e==`number`&&Number.isFinite(e)}function Yd(e){try{let t=typeof e==`string`?e:new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e)),n=JSON.parse(t);if(typeof n!=`object`||!n)return null;let r=n;if(typeof r.sourceText!=`string`||!qd(r.duration))return null;let i=Array.isArray(r.bookmarks)?r.bookmarks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!qd(t.time)||!qd(t.charOffset)?[]:[{id:typeof t.id==`string`?t.id:`bookmark-${t.charOffset}`,time:t.time,charOffset:t.charOffset,...typeof t.textFragment==`string`?{textFragment:t.textFragment}:{}}]}):[],a=Array.isArray(r.blocks)?r.blocks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!qd(t.startSec)||!qd(t.endSec)||!qd(t.charStart)||!qd(t.charEnd)?[]:[{...typeof t.blockId==`string`?{blockId:t.blockId}:{},...typeof t.heading==`string`?{heading:t.heading}:{},blockIndex:qd(t.blockIndex)?t.blockIndex:0,charStart:t.charStart,charEnd:t.charEnd,startSec:t.startSec,endSec:Math.max(t.startSec,t.endSec)}]}):[];a=a.sort((e,t)=>e.startSec-t.startSec);let o=0;for(let e of a)e.startSec<o&&(e.startSec=o),e.endSec<e.startSec&&(e.endSec=e.startSec),o=e.startSec;return{version:3,sourceText:r.sourceText,duration:r.duration,bookmarks:i,blocks:a,...Jd(r.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},...typeof r.generator==`object`&&r.generator!==null?{generator:r.generator}:{}}}catch{return null}}var Xd=``,Zd=RegExp(`${Xd}([a-z]+):([a-zA-Z0-9-]+)${Xd}`,`g`);function Qd(e,t){return`${Xd}${e}:${t}${Xd}`}function $d(e){return e.includes(Xd)}function ef(e){return e.replace(Zd,``)}function tf(e){let t=[],n=0;Zd.lastIndex=0;let r;for(;(r=Zd.exec(e))!==null;)r.index>n&&t.push({type:`text`,text:e.slice(n,r.index)}),t.push({type:`icon`,family:r[1],name:r[2]}),n=r.index+r[0].length;return n<e.length&&t.push({type:`text`,text:e.slice(n)}),t}function nf(e,t){return`fa-${e} fa-${t}`}function rf(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:af(e),style:of(e)}}function af(e){let{type:t,direction:n,panDirection:r}=e;switch(t){case`fadeIn`:return`anim-fadeIn`;case`fadeOut`:return`anim-fadeOut`;case`slowZoom`:return r===`left`?`anim-slowZoom-panLeft`:r===`right`?`anim-slowZoom-panRight`:n===`out`?`anim-slowZoom-out`:`anim-slowZoom-in`;case`zoomIn`:return`anim-zoomIn`;case`zoomOut`:return`anim-zoomOut`;case`panLeft`:return`anim-panLeft`;case`panRight`:return`anim-panRight`;case`typewriter`:return`anim-typewriter`;default:return``}}function of(e){let t={};return e.duration!==void 0&&(t[`--anim-duration`]=`${e.duration}s`),e.delay!==void 0&&(t[`--anim-delay`]=`${e.delay}s`),e.easing&&(t[`--anim-easing`]=e.easing),t}function sf(e){switch(e){case`slowZoom`:case`panLeft`:case`panRight`:return 8;case`typewriter`:return 3;case`fadeIn`:case`fadeOut`:return 1;case`zoomIn`:case`zoomOut`:return .5;default:return 1}}function cf(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${uf(e,n)}-${r}`}var lf={airplane:`airplane`,blinds:`blindsHorizontal`,box:`box`,checker:`checkerboard`,checkerboard:`checkerboard`,circle:`shapeCircle`,clock:`clock`,comb:`combHorizontal`,conveyor:`conveyor`,cover:`coverLeft`,crush:`crush`,cube:`cube`,curtains:`curtains`,cut:`cut`,diamond:`shapeDiamond`,dissolve:`dissolve`,doors:`doors`,drape:`drape`,fade:`fade`,fallOver:`fallOver`,ferris:`ferrisWheel`,ferrisWheel:`ferrisWheel`,flash:`flash`,flip:`flip`,flyThrough:`flyThrough`,flythrough:`flyThrough`,fracture:`fracture`,gallery:`gallery`,glitter:`glitter`,honeycomb:`honeycomb`,morph:`morph`,newsflash:`newsflash`,orbit:`orbit`,origami:`origami`,pageCurl:`pageCurl`,pageCurlDouble:`pageCurlDouble`,pageCurlSingle:`pageCurlSingle`,pan:`panLeft`,peelOff:`peelOff`,plus:`shapePlus`,prestige:`prestige`,prism:`prism`,pull:`pullLeft`,push:`pushLeft`,random:`random`,randomBar:`randomBarsHorizontal`,randomBars:`randomBarsVertical`,reveal:`revealLeft`,ripple:`ripple`,rotate:`rotate`,shape:`shapeCircle`,shred:`shred`,slideDown:`slideDown`,slideLeft:`slideLeft`,slideRight:`slideRight`,slideUp:`slideUp`,split:`splitHorizontal`,strips:`stripsLeft`,switch:`switch`,uncover:`uncoverLeft`,vortex:`vortex`,warp:`warp`,wedge:`wedge`,wheel:`wheel`,wheelReverse:`wheelReverse`,wind:`wind`,window:`window`,wipe:`wipeLeft`,zoom:`zoom`};function uf(e,t){switch(e){case`randomBars`:case`randomBar`:return ff(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return ff(`comb`,t,`Horizontal`);case`blinds`:return ff(`blinds`,t,`Horizontal`);case`split`:return ff(`split`,t,`Horizontal`);case`push`:return df(`push`,t,`Left`);case`wipe`:return df(`wipe`,t,`Left`);case`cover`:return df(`cover`,t,`Left`);case`uncover`:return df(`uncover`,t,`Left`);case`pull`:return df(`pull`,t,`Left`);case`reveal`:return df(`reveal`,t,`Left`);case`strips`:return df(`strips`,t,`Left`);case`pan`:return df(`pan`,t,`Left`);default:return lf[e]}}function df(e,t,n){return`${e}${pf(t,n)}`}function ff(e,t,n){return`${e}${mf(t,n)}`}function pf(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function mf(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function hf(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var gf=40,_f=e=>Math.max(0,Math.min(1,e)),vf=e=>Math.round(e*100)/100;function yf(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=_f(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${vf(t)})`,`contrast(${vf(1+.05*t)})`);break;case`duotone`:{let r=ne(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${vf(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-gf)}deg)`,`saturate(${vf(1+t)})`);break}case`warm`:n.push(`sepia(${vf(.4*t)})`,`saturate(${vf(1+.15*t)})`);break;case`cool`:n.push(`saturate(${vf(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${vf(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var bf=Object.freeze([{id:`cover`,label:`Hero cover`,description:`The classic Squisq cover with title, subtitle, and optional hero image.`},{id:`title`,label:`Title`,description:`A theme-led title card without a full-bleed image.`},{id:`sectionHeader`,label:`Section header`,description:`A bold section divider using the hero image when one is available.`},{id:`imageWithCaption`,label:`Image with title`,description:`A full-bleed image with the title and subtitle overlaid.`,requiresHeroImage:!0},{id:`bigText`,label:`Big text`,description:`The title in gigantic uppercase type on a clean theme surface — thumbnail-ready.`},{id:`bigTextImage`,label:`Big text on image`,description:`The title in gigantic uppercase type over the hero image, with a contrast bloom behind the text.`,requiresHeroImage:!0}]),xf=Object.freeze({enabled:{canonical:`squisq-cover-slide`,legacy:`cover-slide`},template:{canonical:`squisq-cover-template`,legacy:`cover-template`},duration:{canonical:`squisq-cover-duration`,legacy:`cover-duration`},playback:{canonical:`squisq-cover-playback`,legacy:`cover-playback`}}),Sf=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function Cf(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function wf(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function Tf(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s-]+/g,``);if(t===`cover`||t===`hero`||t===`managedcover`)return`cover`;if(t===`title`||t===`titleblock`)return`title`;if(t===`sectionheader`||t===`section`)return`sectionHeader`;if(t===`imagewithcaption`||t===`imagetitle`||t===`fullbleedimage`)return`imageWithCaption`;if(t===`bigtextimage`||t===`largetextimage`||t===`bigtextonimage`)return`bigTextImage`;if(t===`bigtext`||t===`largetext`)return`bigText`}function Ef(e){let t=typeof e==`number`?e:typeof e==`string`&&e.trim().length>0?Number(e):NaN;if(!(!Number.isFinite(t)||t<0||t>60))return t}function Df(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s]+/g,`-`);if([`overlay`,`over`,`concurrent`,`play-over`].includes(t))return`overlay`;if([`preroll`,`pre-roll`,`delay`,`push`,`shift`].includes(t))return`preroll`}function Of(e,t={}){let n={enabled:wf(Cf(e,xf.enabled))??Sf.enabled,template:Tf(Cf(e,xf.template))??Sf.template,duration:Ef(Cf(e,xf.duration))??Sf.duration,playback:Df(Cf(e,xf.playback))??Sf.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:Ef(t.duration)??n.duration,playback:t.playback??n.playback}}var kf=[`transition`,`transitionDuration`,`transitionDirection`],Af=`sectionHeader`;function jf(e,t={}){let n=j(t.defaultTemplate??Af),r=[],i=new Set(fd(e.blocks).map(e=>e.id)),a=new Map,o=[];for(let t of e.documentMedia??[])if(t.origin&&i.has(t.origin.blockId)){let e=a.get(t.origin.blockId)??[];e.push(t),a.set(t.origin.blockId,e)}else o.push(t);for(let e of o)r.push(Ff(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!Nf(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=If(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(Mf(e));let o=[...e.media??[],...a.get(e.id)??[]],c=[...e.contents??[]];if(o.length>0){let e=o.filter(e=>e.origin).sort((e,t)=>e.origin.index-t.origin.index);for(let t of e)c.splice(Math.min(t.origin.index,c.length),0,Ff(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(Ff(e))}if(i&&Pf(c,t),r.push(...c),e.children)for(let t of e.children)s(t)}for(let t of e.blocks)s(t);let c=pu(e.customTemplates),l=e.frontmatter;if(c)l={...l??{},[T]:c};else if(l&&`squisq-custom-templates`in l){let{[T]:e,...t}=l;l=t}let u=bu(e.customThemes);if(u)l={...l??{},[O]:u};else if(l&&`squisq-custom-themes`in l){let{[O]:e,...t}=l;l=t}return{type:`document`,children:r,...l&&Object.keys(l).length>0?{frontmatter:l}:{}}}function Mf(e){return{type:`paragraph`,children:[{type:`text`,value:ce(e.sourceAnnotation?.template,e.templateOverrides)}]}}function Nf(e,t){let n=j(e.template??``)===j(t.template),r=zf(e.templateOverrides??{},t.params??{});return!(n&&r)}function Pf(e,t){if(t.origin.kind===`paragraph`){e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.raw}]});return}let n=e[e.length-1];if(n&&n.type===`paragraph`){let r=n.children??[],i=r[r.length-1];if(i&&i.type===`text`){let a=[...r];a[a.length-1]={...i,value:i.value+t.origin.suffix},e[e.length-1]={...n,children:a};return}}e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.suffix.replace(/^\s+/,``)}]})}function Ff(e){if(e.origin?.format===`html`&&e.origin.raw)return{type:`htmlBlock`,rawHtml:e.origin.raw,htmlChildren:a(e.origin.raw)};if(e.origin?.raw)return{type:`paragraph`,children:[{type:`text`,value:e.origin.raw}]};let t={src:e.src};return e.placement&&(t.placement=e.placement),e.pipSize&&(t.pipSize=e.pipSize),e.pipShape&&(t.pipShape=e.pipShape),e.pipPosition&&(t.pipPosition=e.pipPosition),e.lockToBlock!=null&&(t.lockToBlock=String(e.lockToBlock)),e.anchor===`document`&&(t.anchor=`document`),e.startAt&&(t.startAt=String(e.startAt)),e.clipStart!=null&&(t.clipStart=String(e.clipStart)),e.clipEnd!=null&&(t.clipEnd=String(e.clipEnd)),e.spillover&&(t.spillover=`true`),{type:`paragraph`,children:[{type:`text`,value:ce(e.kind,t)}]}}function If(e,t,n){let{attributes:r,transitionParams:i}=Bf(e,t),a=t.templateAnnotation,o=Lf(e,a,n),s=e.templateOverrides&&Object.keys(e.templateOverrides).length>0?e.templateOverrides:void 0,c;return(o!==void 0||s!==void 0)&&(c={...o===void 0?{}:{template:o},...s?{params:s}:{}}),i&&(c={...c??{},params:{...c?.params??{},...i}}),Rf(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function Lf(e,t,n){if(!e.template||e.autoTemplate===!0)return t?.template;let r=j(e.template);if(t?.template&&j(t.template)===r)return t.template;if(r!==n)return e.template}function Rf(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&zf(e.params,t.params)}function zf(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n])}function Bf(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=Vf(t.attributes)??{};return{attributes:{...r,blockMeta:{...r.blockMeta??{},transition:n}},transitionParams:{transition:n.type,...n.duration===void 0?{}:{transitionDuration:String(n.duration)},...n.direction?{transitionDirection:n.direction}:{}}}}function Vf(e){if(!e?.params)return e;let t={...e.params};for(let e of kf)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function Hf(e){if(e.type===`inlineIcon`){let t=e;return Qd(t.family,t.name)}if(`value`in e&&typeof e.value==`string`)return e.value;let n=t(e),r=e.type===`list`||e.type===`listItem`?`
|
|
31
|
-
`:``;return n.map(
|
|
32
|
-
`).trim()}function
|
|
33
|
-
`).trim();return n?{text:n,markdown:t}:void 0}function
|
|
34
|
-
`).trim(),markdown:i}}function
|
|
35
|
-
`).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override=
|
|
16
|
+
`),i=r.filter(e=>e.trim().length>0),a=n?1:Ur;if(i.length<a)return{isTree:!1,reasons:[`too-few-lines(${i.length})`]};if(r.length>Hr)return{isTree:!1,reasons:[`too-many-lines(${r.length})`]};let o=i.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,s=i.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(o>i.length/2&&s)return{isTree:!1,reasons:[`markdown-table`]};if(Kr.test(e))return{isTree:!1,reasons:[`has-box-corners`]};if(!n&&xr(e).isTimeline)return{isTree:!1,reasons:[`is-timeline`]};let c=Ot(e).diagram.nodes.length;if(c>=2)return{isTree:!1,reasons:[`has-boxes(${c})`]};let{tree:l,stats:u}=Ir(e),d=Zr(l.roots);if(d<(n?1:Gr))return{isTree:!1,reasons:[`too-few-nodes(${d})`]};if(!n){if(u.connectorLines<Wr)return{isTree:!1,reasons:[`too-few-connectors(${u.connectorLines})`]};if(u.looseLines>u.contentLines*.25)return{isTree:!1,reasons:[`loose-ratio(${u.looseLines}/${u.contentLines})`]}}return{isTree:!0,tree:l,reasons:[`nodes(${d})`,n?`explicit`:`connectors(${u.connectorLines})`]}}function Xr(e){return e.type!==`code`||!qr(e.lang)?!1:Yr(e.value,{explicit:Jr(e.lang)}).isTree}function Zr(e){let t=0;for(let n of e)t+=1+Zr(n.children);return t}var Qr=/(?:[$€£¥]\s?\d+(?:[.,]\d+)*(?:\s?(?:[MBK]|million|billion|thousand))?|\d+(?:[.,]\d+)*\s?(?:%|‰|x|×|[MBK]|million|billion|thousand|percent|years?|days?|hours?)|\d{3,}(?:[.,]\d+)*)/i;function $r(e){let t=Qr.exec(e);return!t||t.index===void 0?null:{value:t[0],index:t.index,end:t.index+t[0].length}}var ei=Object.freeze({hasImage:!1,imageCount:0,hasVideo:!1,hasBlockquote:!1,hasList:!1,hasTable:!1,hasDate:!1,hasNumberHighlight:!1,wordCount:0}),ti=[/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?\d{4}\b/i,/\b\d{1,2}\s+(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{4}\b/i,/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)\.?\s+\d{1,2},?\s+\d{4}\b/i,/\b\d{4}-\d{2}-\d{2}\b/,/\b\d{1,2}\/\d{1,2}\/\d{2,4}\b/,/\bQ[1-4]\s+\d{4}\b/,/\b\d{4}s\b/,/\b\d{1,2}(st|nd|rd|th)\s+century\b/i],ni=/(youtube\.com|youtu\.be|vimeo\.com|wistia\.|loom\.com)/i;function ri(e,t){let n=r(e,`htmlBlock`),i=r(e,`htmlInline`),a=[],o=e=>{if(e.type===`htmlElement`){t.has(e.tagName.toLowerCase())&&a.push(e);for(let t of e.children)o(t)}};for(let e of n)for(let t of e.htmlChildren)o(t);for(let e of i)if(Array.isArray(e.htmlChildren))for(let t of e.htmlChildren)o(t);return a}function ii(e){if(!e||e.length===0)return{...ei};let t=0,n=!1,a=!1,s=!1,c=[];for(let i of e)t+=r(i,`image`).length,t+=r(i,`imageReference`).length,r(i,`blockquote`).length>0&&(n=!0),r(i,`list`).length>0&&(a=!0),r(i,`table`).length>0&&(s=!0),c.push(o(i));let l={type:`document`,children:e},u=ri(l,new Set([`img`]));t+=u.length;let d=ri(l,new Set([`video`,`iframe`,`source`])),f=!1;for(let e of d){if(e.tagName.toLowerCase()===`video`){f=!0;break}let t=e.attributes.src||e.attributes.href||``;if(ni.test(t)){f=!0;break}}if(!f){let e=r(l,`link`);for(let t of e)if(t.url&&ni.test(t.url)){f=!0;break}}let p=c.join(` `).trim(),m=p?p.split(/\s+/).length:0,h=!1;for(let e of ti)if(e.test(p)){h=!0;break}let g=!1;i(l,e=>{if(g)return!0;if(e.type!==`paragraph`)return;let t=o(e).trim();return!t||!$r(t)||t.split(/\s+/).length<=8&&(g=!0),!0});let _=!1,v=[];for(let t of e)v.push(...r(t,`code`));if(v.length===1&&an(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=on(v[0].lang);e<=400&&sn(v[0].value,{explicit:t}).isDiagram&&(_=!0)}let y=!1;if(!_&&v.length===1&&yr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=br(v[0].lang);e<=400&&xr(v[0].value,{explicit:t}).isTimeline&&(y=!0)}let b=!1;if(!_&&!y&&v.length===1&&qr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Jr(v[0].lang);e<=400&&Yr(v[0].value,{explicit:t}).isTree&&(b=!0)}return{hasImage:t>0,imageCount:t,hasVideo:f,hasBlockquote:n,hasList:a,hasTable:s,hasDate:h,hasNumberHighlight:g,wordCount:m,hasAsciiDiagram:_,hasTimeline:y,hasTree:b}}var ai=[`title`,`sectionHeader`,`factCard`,`twoColumn`];function oi(e){let t=new Set,n=!1;if(e.hasAsciiDiagram&&(n=!0,t.add(`diagram`)),e.hasTimeline&&(n=!0,t.add(`timeline`)),e.hasTree&&(n=!0,t.add(`tree`)),e.hasImage&&(n=!0,t.add(`imageWithCaption`),t.add(`leftFeature`),t.add(`rightFeature`),e.imageCount>=2&&t.add(`photoGrid`)),e.hasVideo&&(n=!0,t.add(`videoWithCaption`),e.hasBlockquote&&t.add(`videoPullQuote`)),e.hasBlockquote&&(n=!0,t.add(`quote`),t.add(`pullQuote`),t.add(`fullBleedQuote`)),e.hasList&&(n=!0,t.add(`list`)),e.hasTable&&(n=!0,t.add(`dataTable`),t.add(`comparisonBar`),t.add(`columnChart`),t.add(`barChart`),t.add(`lineChart`),t.add(`pieChart`)),e.hasDate&&(n=!0,t.add(`dateEvent`)),e.hasNumberHighlight&&(n=!0,t.add(`statHighlight`)),n)t.add(`title`),t.add(`sectionHeader`);else for(let e of ai)t.add(e);return Array.from(t)}function si(e,t=0){if(e.hasAsciiDiagram)return`diagram`;if(e.hasTimeline)return`timeline`;if(e.hasTree)return`tree`;if(e.hasTable)return`dataTable`;if(e.hasVideo)return`videoWithCaption`;if(e.imageCount>=2)return`photoGrid`;if(e.hasImage)return t%2==0?`leftFeature`:`rightFeature`;if(e.hasBlockquote)return`quote`;if(e.hasNumberHighlight)return`statHighlight`;if(e.hasList)return`list`}function ci(e,t){let n=new Set(oi(e)),r=[],i=[];for(let e of t)n.has(e)?r.push(e):i.push(e);return{recommended:r,rest:i}}var li=200;function ui(e,t){let n=t?.wordsPerMinute,r=typeof n==`number`&&n>0?n:li,i=e.split(/\s+/).filter(e=>e.length>0).length,a=i/r;return{words:i,minutes:a,seconds:Math.round(a*60)}}var di={"dark-vignette":`radial-gradient(ellipse at center, rgba(26,32,44,0.8) 0%, rgba(0,0,0,0.95) 100%)`,"radial-dark":`radial-gradient(ellipse at center, #1a202c 0%, #000000 100%)`,"warm-sunset":`linear-gradient(135deg, rgba(124,58,48,0.9) 0%, rgba(46,20,16,0.95) 100%)`,"cool-blue":`linear-gradient(135deg, rgba(26,54,93,0.9) 0%, rgba(26,32,44,0.95) 100%)`,"earth-tones":`linear-gradient(135deg, rgba(68,51,34,0.9) 0%, rgba(30,22,15,0.95) 100%)`};function fi(e){return{type:`shape`,id:`persistent-bg-solid`,content:{shape:`rect`,fill:e.color},position:{x:0,y:0,width:`100%`,height:`100%`}}}function pi(e){return{type:`shape`,id:`persistent-bg-gradient`,content:{shape:`rect`,fill:e.gradient??di[e.preset??`dark-vignette`]},position:{x:0,y:0,width:`100%`,height:`100%`}}}function mi(e){let t=[],n=e.opacity??.4,r={type:`image`,id:`persistent-bg-image`,content:{src:e.src,alt:`Background`,fit:`cover`,...e.blur!=null&&e.blur>0?{blur:e.blur}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e.ambientMotion?{type:e.ambientMotion,duration:30}:void 0};return t.push(r),t.push({type:`shape`,id:`persistent-bg-overlay`,content:{shape:`rect`,fill:`rgba(0,0,0,${.5+(1-n)*.3})`},position:{x:0,y:0,width:`100%`,height:`100%`}}),t}function hi(e){if(e.pattern===`noise`)return{type:`shape`,id:`persistent-grain`,content:{shape:`rect`,fill:`#000000`,filter:{type:`noise`,opacity:e.opacity??.05}},position:{x:0,y:0,width:`100%`,height:`100%`}};let t=e.opacity??.06;return{type:`shape`,id:`persistent-bg-pattern`,content:{shape:`rect`,pattern:{kind:e.pattern,color:e.color??`#ffffff`,size:Math.round(24*(e.scale??1)),opacity:t}},position:{x:0,y:0,width:`100%`,height:`100%`}}}function gi(e){let t=Math.max(0,Math.min(1,e.strength??.3)),n=e.color??`#000000`,r=C(n,t);return{type:`shape`,id:`persistent-vignette`,content:{shape:`rect`,fill:`radial-gradient(ellipse at center, ${C(n,0)} 55%, ${r} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}}function _i(e,t){return{type:`shape`,id:`persistent-ambient-gradient`,content:{shape:`rect`,fill:`linear-gradient(150deg, ${e.from??t?.colors.backgroundLight??`#1a202c`} 0%, ${e.to??(t?b(t.colors.background,.04):`#0f141d`)} 100%)`},position:{x:`-5%`,y:`-5%`,width:`110%`,height:`110%`},animation:{type:`slowZoom`,panDirection:`left`,duration:e.duration??40}}}function vi(e){let t=[],n=e.fontSize??18,r=!!e.subtitle,i=e.position.includes(`bottom`),a=e.position.includes(`left`),o=1.5,s=r?`15%`:`7%`,c=i?r?`78%`:`84%`:`2%`,l=e.showThumbnail?30:28,u=a?3:97-l,d=`${u}%`,f=r?6:5,p=`${f}%`,m=r?`10%`:`5%`,h=u+o,g=l-o*2,_=e.showThumbnail&&a?`${h+f+o}%`:`${h}%`,v=e.showThumbnail?`${g-f-o}%`:`${g}%`,y=i?r?`80%`:`86%`:`4%`;if(t.push({type:`shape`,id:`persistent-caption-bg`,content:{shape:`rect`,fill:`rgba(0,0,0,0.6)`,borderRadius:8},position:{x:d,y:c,width:`${l}%`,height:s}}),e.showThumbnail&&e.thumbnailSrc){let n=a?`${h}%`:`${u+l-o-f}%`,s=i?r?`79.5%`:`85%`:`3%`;t.push({type:`image`,id:`persistent-caption-thumb`,content:{src:e.thumbnailSrc,alt:`Article thumbnail`,fit:`cover`},position:{x:n,y:s,width:p,height:m}})}if(t.push({type:`text`,id:`persistent-caption-title`,content:{text:e.title,style:{fontSize:n,fontWeight:`bold`,color:`rgba(255,255,255,0.9)`,textAlign:a?`left`:`right`,maxLines:1}},position:{x:_,y,width:v}}),r){let n=i?`85.5%`:`8%`;t.push({type:`text`,id:`persistent-caption-subtitle`,content:{text:e.subtitle,style:{fontSize:18,fontWeight:`normal`,color:`rgba(255,255,255,0.55)`,textAlign:a?`left`:`right`}},position:{x:_,y:n,width:v}})}return t}function yi(e){let t=e.position.includes(`bottom`),n=e.position.includes(`left`)?`3%`:`90%`,r=t?`94%`:`3%`;return e.isImage?{type:`image`,id:`persistent-branding`,content:{src:e.content,alt:`Branding`,fit:`contain`},position:{x:n,y:r,width:`8%`,height:`4%`}}:{type:`text`,id:`persistent-branding`,content:{text:e.content,style:{fontSize:14,fontWeight:`normal`,color:`rgba(255,255,255,0.6)`}},position:{x:n,y:r}}}function bi(e){let t=e.color??`rgba(255,255,255,0.3)`,n=e.position===`top`?`1%`:`98%`;return{type:`shape`,id:`persistent-progress`,content:{shape:`rect`,fill:t,borderRadius:2},position:{x:`5%`,y:n,width:`90%`,height:`0.5%`}}}function xi(e,t){if(!l(e))return[s(e)];let n=e.config;switch(n.type){case`solidBackground`:return[fi(n)];case`gradientBackground`:return[pi(n)];case`imageBackground`:return mi(n);case`patternBackground`:return[hi(n)];case`vignette`:return[gi(n)];case`ambientGradient`:return[_i(n,t)];case`titleCaption`:return vi(n);case`cornerBranding`:return[yi(n)];case`progressIndicator`:return[bi(n)];default:return console.warn(`Unknown persistent layer template:`,n.type),[]}}function Si(e,t){return!e||e.length===0?[]:e.reduce((e,n)=>e.concat(xi(n,t)),[])}function Ci(e){return e.persistentLayers??{}}function wi(e,t){let n=e.persistentLayers;if(n&&((n.bottomLayers?.length??0)>0||(n.topLayers?.length??0)>0))return n;let r=t.persistentLayers;return r&&((r.bottomLayers?.length??0)>0||(r.topLayers?.length??0)>0)?r:n}function Ti(e,t,n,r){if(n.length===0&&r.length===0)return e;let i=t.useBottomLayer!==!1,a=t.useTopLayer!==!1;return[...i?n.map(e=>s(e)):[],...e,...a?r.map(e=>s(e)):[]]}var Ei={bg:`#1a365d`,text:`#63b3ed`,accent:`#90cdf4`};function I(e,t){let n=e.theme.colorSchemes;if(t&&t in n)return n[t];let r=Object.keys(n);return r.length>0?n[r[0]]:Ei}var Di=`system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,Oi=`Georgia, "Times New Roman", serif`,ki=`Consolas, "Courier New", monospace`;function L(e,t){let{typography:n}=e.theme;switch(t){case`title`:return w(n.titleFont,Oi);case`body`:return w(n.bodyFont,Di);case`mono`:return w(n.monoFont,ki)}}function R(e,t,n=!1){let{fontScale:r,layout:i,theme:a}=t,o=n?i.titleScale:i.bodyScale,s=n?a.typography.titleScale??1:a.typography.bodyScale??1;return Math.round(e*r*o*s)}function Ai(e,t){return e*(t.theme.style.animationSpeed??1)}function ji(e,t){let n=e.theme.renderStyle;return t===`text`?n.defaultTextAnimation:n.defaultImageAnimation}function z(e,t,n){let r=ji(e,t);return!r||r===`slowZoom`||r===n.type?n:{...n,type:r}}function B(e){return e.theme.style.textShadow??!0}function Mi(e){return e.theme.style.overlayOpacity??.5}function V(e,t){if(t===`none`)return;let n=e.theme.style.imageTreatment,r=t?{type:t,strength:n?.strength}:n;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.theme.colors.primary}:r}function H(e,t=160){let{background:n,backgroundLight:r}=e.theme.colors;return`linear-gradient(${t}deg, ${r} 0%, ${b(n,.04)} 100%)`}function Ni(e,t){let n=t??Math.max(.55,Mi(e));return C(e.theme.colors.background,n)}function Pi(e,t,n,r){let i=e.theme.renderStyle.templateHints;if(!i)return r;let a=i[t];return!a||!(n in a)?r:a[n]}var Fi=/[.;:!?]+$/;function Ii(e){return e.replace(Fi,``).trim()}function Li(e,t){return{type:`shape`,id:e,content:{shape:`rect`,fill:t},position:{x:0,y:0,width:`100%`,height:`100%`}}}function U(e,t,n,r){let i=t*.52,a=Math.max(8,Math.floor(n/i));return Math.max(1,Math.ceil(e.length/a))*t*r}function Ri(e,t){let{title:n,subtitle:r,backgroundColor:i}=e,{theme:a,layout:o,viewport:s}=t,c=R(96,t,!0),l=R(36,t,!1),u=i||a.colors.primary,d=parseFloat(o.maxTextWidth)/100*s.width,f=U(n,c,d,1.15),p=56+(Math.max(1,Math.round(f/(c*1.15)))>1?c*.25:0),m=r?42:48,h=e=>e/s.height*100,g=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:a.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${C(u,.32)} 0%, ${C(u,0)} 75%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(Pi(t,`title`,`showAccentLine`,!0)&&g.push({type:`shape`,id:`accent-line`,content:{shape:`rect`,fill:C(a.colors.text,.3)},position:{x:`44%`,y:`${m-h(f/2+56)}%`,width:`12%`,height:`3px`}}),g.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:c,fontFamily:L(t,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:`${m}%`,anchor:`center`,width:o.maxTextWidth},animation:z(t,`text`,{type:`fadeIn`,duration:2})}),r){let e=U(r,l,d,1.5);g.push({type:`text`,id:`subtitle`,content:{text:r,style:{fontSize:l,fontFamily:L(t,`body`),color:a.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`${m+h(f/2+p+e/2)}%`,anchor:`center`,width:o.maxTextWidth},animation:{type:`fadeIn`,duration:1.5,delay:1}})}return g}var zi=/^(\d+(?:\.\d+)?)\s*%?$/,Bi={textCenterX:`50%`,textWidth:`85%`,textYAdjust:0,adjustY:!1};function Vi(e,t){if(!e)return;let n=t===void 0?{}:{duration:t};switch(e){case`zoomIn`:case`in`:return{type:`slowZoom`,direction:`in`,...n};case`zoomOut`:case`out`:return{type:`slowZoom`,direction:`out`,...n};case`panLeft`:case`left`:return{type:`slowZoom`,panDirection:`left`,...n};case`panRight`:case`right`:return{type:`slowZoom`,panDirection:`right`,...n};default:return}}var Hi=35,Ui=`${Hi}%`;function Wi(e){switch(e){case`left-strip`:return{textCenterX:`${50+Hi/2}%`,textWidth:`${100-Hi-8}%`,textYAdjust:0,adjustY:!1};case`right-strip`:return{textCenterX:`${50-Hi/2}%`,textWidth:`${100-Hi-8}%`,textYAdjust:0,adjustY:!1};case`bottom-strip`:return{textCenterX:`50%`,textWidth:`85%`,textYAdjust:-10,adjustY:!0};case`corner-inset`:return{textCenterX:`45%`,textWidth:`70%`,textYAdjust:0,adjustY:!1};default:return Bi}}function Gi(e,t,n){let r=[],{src:i,alt:a,position:o,ambientMotion:s,credit:c,license:l}=e;switch(o){case`left-strip`:r.push(Ki(i,a,`left`,t,s,c,l,n)),r.push(qi(`left`,t));break;case`right-strip`:r.push(Ki(i,a,`right`,t,s,c,l,n)),r.push(qi(`right`,t));break;case`bottom-strip`:r.push(Ji(i,a,t,s,c,l,n)),r.push(Yi(t));break;case`corner-inset`:r.push(Xi(i,a,t,s,c,l,n)),r.push(Zi(t));break}return r}function Ki(e,t,n,r,i,a,o,s){return{type:`image`,id:`${r}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:a,license:o,...s?{treatment:s}:{}},position:{x:n===`left`?0:`${100-Hi}%`,y:0,width:Ui,height:`100%`},animation:Vi(i,15)}}function qi(e,t){let n=e===`left`?`accent-gradient-left`:`accent-gradient-right`;return{type:`shape`,id:`${t}-accent-fade`,content:{shape:`rect`,fill:`url(#${n})`},position:{x:e===`left`?`${Hi-8}%`:`${100-Hi}%`,y:0,width:`10%`,height:`100%`}}}function Ji(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:0,y:`${100-Hi}%`,width:`100%`,height:Ui},animation:Vi(r,15)}}function Yi(e){return{type:`shape`,id:`${e}-accent-fade`,content:{shape:`rect`,fill:`url(#accent-gradient-bottom)`},position:{x:0,y:`${100-Hi-8}%`,width:`100%`,height:`12%`}}}function Xi(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:`70%`,y:`60%`,width:`28%`,height:`38%`,anchor:`top-left`},animation:Vi(r,15)??{type:`fadeIn`,duration:2,delay:.5}}}function Zi(e){return{type:`shape`,id:`${e}-accent-vignette`,content:{shape:`rect`,fill:`url(#accent-vignette-corner)`,borderRadius:8},position:{x:`69%`,y:`59%`,width:`30%`,height:`40%`}}}function W(e,t){if(!t.adjustY||t.textYAdjust===0)return typeof e==`number`?`${e}%`:e;let n=typeof e==`number`?`${e}`:e,r=n.match(zi);if(r){let e=parseFloat(r[1]);return`${Math.max(5,e+t.textYAdjust)}%`}return n}function Qi(e,t){let{title:n=``,colorScheme:r=`blue`,imageSrc:i,imageAlt:a,ambientMotion:o}=e,{theme:s,layout:c}=t,l=V(t,e.imageTreatment),u=I(t,r),d=R(84,t,!0),f=[];return i?(f.push({type:`image`,id:`bg-image`,content:{src:i,alt:a||n,fit:`cover`,...l?{treatment:l}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Vi(o,8)??{type:`slowZoom`,duration:8,direction:`in`}}),f.push({type:`shape`,id:`overlay`,content:{shape:`rect`,fill:Ni(t)},position:{x:0,y:0,width:`100%`,height:`100%`}})):(f.push({type:`shape`,id:`bg`,content:{shape:`rect`,fill:u.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}),f.push({type:`shape`,id:`line-top`,content:{shape:`rect`,fill:C(u.text,.2)},position:{x:`50%`,y:`40%`,width:`20%`,height:`2px`,anchor:`center`}}),f.push({type:`shape`,id:`line-bottom`,content:{shape:`rect`,fill:C(u.text,.2)},position:{x:`50%`,y:`60%`,width:`20%`,height:`2px`,anchor:`center`}})),f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:d,fontFamily:L(t,`title`),fontWeight:`bold`,color:i?s.colors.text:u.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:c.maxTextWidth},animation:z(t,`text`,{type:`fadeIn`,duration:1.5})}),f}var $i=1.05,ea=.92,ta=.86,na=.62,ra=48;function ia(e,t){let n=1,r=0;for(let i of e){let e=r===0?i:r+1+i;e<=t?r=e:(n+=1,r=i)}return n}function aa(e,t){let n=t.width*ea,r=t.height*ta,i=e.trim().split(/\s+/).filter(Boolean).map(e=>e.length);if(i.length===0)return Math.floor(r/$i);let a=n/(na*Math.max(...i)),o=r/$i,s=e=>{let t=Math.max(1,Math.floor(n/(e*na)));return ia(i,t)*e*$i<=r},c=ra,l=Math.min(a,o);if(l<=c)return Math.max(ra,Math.floor(l));if(!s(c))return ra;for(let e=0;e<24;e+=1){let e=(c+l)/2;s(e)?c=e:l=e}return Math.floor(c)}function oa(e){return`radial-gradient(ellipse at 50% 50%, ${C(e,.92)} 0%, ${C(e,.78)} 38%, ${C(e,.32)} 66%, ${C(e,0)} 88%)`}function sa(e,t){let{title:n=``,imageSrc:r,imageAlt:i,ambientMotion:a}=e,{theme:o,viewport:s}=t,c=V(t,e.imageTreatment),l=n.toUpperCase(),u=aa(l,s),d=[];return r?d.push({type:`image`,id:`bigtext-image`,content:{src:r,alt:i||n,fit:`cover`,...c?{treatment:c}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Vi(a,8)??{type:`slowZoom`,duration:8,direction:`in`}},{type:`shape`,id:`bigtext-bloom`,content:{shape:`rect`,fill:oa(o.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}}):d.push({type:`shape`,id:`bigtext-bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bigtext-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${C(o.colors.primary,.38)} 0%, ${C(o.colors.primary,.14)} 48%, ${C(o.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),d.push({type:`text`,id:`bigtext-title`,content:{text:l,style:{fontSize:u,fontFamily:L(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:$i,shadow:!!r,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`${ea*100}%`,height:`${ta*100}%`},animation:z(t,`text`,{type:`fadeIn`,duration:1})}),d}function ca(e){return(e.block?.contents??[]).filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`)).map(e=>o(e)).join(`
|
|
17
|
+
`).trim()}function la(e,t){return R(e.length>1800?18:e.length>1100?21:e.length>650?24:28,t,!1)}function ua(e,t){let{theme:n}=t,r=e.title??t.block?.title??``,i=ca(t),a=[Li(`bg`,n.colors.background)];return r&&a.push({type:`text`,id:`title`,content:{text:r,style:{fontSize:R(46,t,!0),fontFamily:L(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`left`,lineHeight:1.15,shadow:B(t)}},position:{x:`8%`,y:`9%`,width:`84%`,height:`15%`,anchor:`top-left`}}),i&&a.push({type:`text`,id:`body`,content:{text:i,style:{fontSize:la(i,t),fontFamily:L(t,`body`),color:n.colors.text,textAlign:`left`,lineHeight:1.35,shadow:B(t)}},position:{x:`8%`,y:r?`28%`:`10%`,width:`84%`,height:r?`64%`:`82%`,anchor:`top-left`}}),a}function da(e,t){let{stat:n,description:r,detail:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=I(t,a),l=o?Wi(o.position):Bi,u=R(148,t,!0),d=R(32,t,!1),f=R(26,t,!1),p=[Li(`bg`,H(t,180))];return o&&p.push(...Gi(o,e.id,V(t,e.imageTreatment))),p.push({type:`text`,id:`stat`,content:{text:n,style:{fontSize:u,fontFamily:L(t,`title`),fontWeight:`bold`,color:c.text,shadow:B(t)}},position:{x:l.textCenterX,y:W(`36%`,l),anchor:`center`},animation:Pi(t,`statHighlight`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.4}:{type:`zoomIn`,duration:.6}}),p.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:d,fontFamily:L(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:B(t)}},position:{x:l.textCenterX,y:W(`54%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:.3}}),i&&p.push({type:`text`,id:`detail`,content:{text:i,style:{fontSize:f,fontFamily:L(t,`body`),color:c.text,textAlign:`center`,shadow:B(t)}},position:{x:l.textCenterX,y:W(`66%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1}}),p}function fa(e,t){let{title:n,quote:r,attribution:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Wi(a.position):Bi,l=R(48,t,!0),u=R(34,t,!0),d=R(26,t,!1),f=Math.max(o.typography.titleLineHeight??1.4,1.25),p=R(280,t,!0),m=[Li(`bg`,H(t,160))];a&&m.push(...Gi(a,e.id,V(t,e.imageTreatment))),n&&m.push({type:`text`,id:`quote-title`,content:{text:n,style:{fontSize:u,fontFamily:L(t,`body`),fontWeight:`bold`,color:o.colors.textMuted,textAlign:`center`,shadow:B(t)}},position:{x:c.textCenterX,y:W(`14%`,c),width:c.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),m.push({type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:p,fontFamily:L(t,`title`),color:C(o.colors.text,.09),textAlign:`center`}},position:{x:c.textCenterX,y:W(`26%`,c),anchor:`center`}});let h=i?45:n?52:50;if(m.push({type:`text`,id:`quote`,content:{text:r,style:{fontSize:l,fontFamily:L(t,`title`),color:o.colors.text,textAlign:`center`,lineHeight:f,shadow:B(t)}},position:{x:c.textCenterX,y:W(`${h}%`,c),anchor:`center`,width:c.textWidth},animation:z(t,`text`,{type:`fadeIn`,duration:2})}),i){let e=U(r,l,parseFloat(c.textWidth)/100*s.width,f),n=l*1.7,a=Math.min(82,h+(e/2+n)/s.height*100);m.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${i}`,style:{fontSize:d,fontFamily:L(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:B(t)}},position:{x:c.textCenterX,y:W(`${a}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return m}function pa(e,t){let{fact:n,explanation:r,source:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Wi(a.position):Bi,l=R(56,t,!0),u=R(34,t,!1),d=R(20,t,!1),f=[Li(`bg`,H(t,170))];a&&f.push(...Gi(a,e.id,V(t,e.imageTreatment)));let p=parseFloat(c.textWidth)/100*s.width,m=U(n,l,p,1.3),h=U(r,u,p,1.5),g=i?d*1.4:0,_=l*.9,v=i?u*1.1:0,y=47-(m+_+h+v+g)/2/s.height*100,b=e=>y+e/s.height*100,x=b(m/2),S=b(m+_+h/2),C=b(m+_+h+v+g/2);return f.push({type:`text`,id:`fact`,content:{text:n,style:{fontSize:l,fontFamily:L(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:1.3,shadow:B(t)}},position:{x:c.textCenterX,y:W(`${x}%`,c),width:c.textWidth,anchor:`center`},animation:z(t,`text`,{type:`fadeIn`,duration:1.5})}),f.push({type:`text`,id:`explanation`,content:{text:r,style:{fontSize:u,fontFamily:L(t,`body`),color:o.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:B(t)}},position:{x:c.textCenterX,y:W(`${S}%`,c),width:c.textWidth,anchor:`center`},animation:z(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&f.push({type:`text`,id:`source`,content:{text:i,style:{fontSize:d,fontFamily:L(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:B(t)}},position:{x:c.textCenterX,y:W(`${C}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),f}function ma(e,t){let{left:n,right:r,header:i,leftColor:a=`green`,rightColor:o=`blue`}=e;if(!n?.label||!r?.label)return[];let{theme:s,layout:l,orientation:u}=t,d=I(t,a),f=I(t,o),p=c(u),m=l.stackColumns,h=m?`85%`:`42%`,g=R(36,t,!0),_=R(44,t,!0),v=R(22,t,!1),y=i&&!m?22:15,b=i&&!m?64:70,x=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:H(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(!m){let e=C(s.colors.text,.05);x.push({type:`shape`,id:`left-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`3%`,y:`${y}%`,width:`44%`,height:`${b}%`}}),x.push({type:`shape`,id:`right-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`53%`,y:`${y}%`,width:`44%`,height:`${b}%`}})}let S=m?`8%`:`12%`;i&&x.push({type:`text`,id:`header`,content:{text:i,style:{fontSize:g,fontFamily:L(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`}},position:{x:`50%`,y:S,anchor:`center`},animation:z(t,`text`,{type:`fadeIn`,duration:.8})});let w,T,E,D;if(m)w=i?`30%`:`25%`,T=i?`40%`:`35%`,E=i?`60%`:`55%`,D=i?`70%`:`65%`;else{let e=y+b/2;w=`${e-4}%`,T=`${e+7}%`,E=`${e-4}%`,D=`${e+7}%`}x.push({type:`text`,id:`left-label`,content:{text:n.label,style:{fontSize:_,fontFamily:L(t,`body`),fontWeight:`bold`,color:d.text,textAlign:`center`,lineHeight:1.3}},position:{x:p.left.x,y:w,anchor:`center`,width:h},animation:z(t,`text`,{type:`fadeIn`,duration:1})}),n.sublabel&&x.push({type:`text`,id:`left-sublabel`,content:{text:n.sublabel,style:{fontSize:v,fontFamily:L(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:p.left.x,y:T,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.3}});let O=R(64,t,!0),k=m?`48%`:`${y+b/2}%`,A=m?`↓`:`→`;return x.push({type:`text`,id:`connector`,content:{text:A,style:{fontSize:O,fontFamily:L(t,`title`),fontWeight:`bold`,color:C(s.colors.text,.45),textAlign:`center`}},position:{x:`50%`,y:k,anchor:`center`},animation:{type:`fadeIn`,duration:.6,delay:.4}}),x.push({type:`text`,id:`right-label`,content:{text:r.label,style:{fontSize:_,fontFamily:L(t,`body`),fontWeight:`bold`,color:f.text,textAlign:`center`,lineHeight:1.3}},position:{x:p.right.x,y:E,anchor:`center`,width:h},animation:z(t,`text`,{type:`fadeIn`,duration:1,delay:.5})}),r.sublabel&&x.push({type:`text`,id:`right-sublabel`,content:{text:r.sublabel,style:{fontSize:v,fontFamily:L(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:p.right.x,y:D,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.8}}),x}var ha={neutral:`#63b3ed`,somber:`#e53e3e`,celebratory:`#68d391`};function ga(e,t){let{date:n,description:r,footer:i,mood:a=`neutral`,accentImage:o}=e,{theme:s}=t,c=ha[a],l=x(s.colors.background)>.5?b(c,.25):c,u=o?Wi(o.position):Bi,d=R(96,t,!0),f=R(30,t,!1),p=R(26,t,!1),m=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:H(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];return o&&m.push(...Gi(o,e.id,V(t,e.imageTreatment))),m.push({type:`text`,id:`date`,content:{text:n,style:{fontSize:d,fontFamily:L(t,`title`),fontWeight:`bold`,color:l,shadow:B(t)}},position:{x:u.textCenterX,y:W(`35%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1.5}}),m.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:f,fontFamily:L(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,shadow:B(t)}},position:{x:u.textCenterX,y:W(`58%`,u),width:u.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:2,delay:1}}),i&&m.push({type:`text`,id:`footer`,content:{text:i,style:{fontSize:p,fontFamily:L(t,`body`),color:s.colors.textMuted,shadow:B(t)}},position:{x:u.textCenterX,y:W(`72%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:3}}),m}function _a(e,t){let{imageSrc:n,imageAlt:r,caption:i,captionPosition:a=`bottom`,ambientMotion:o,isTitle:s,subtitle:c,imageCredit:l,imageLicense:u}=e,d=i&&Ii(i),{theme:f,layout:p}=t,m=V(t,e.imageTreatment),h=R(30,t,!1),g=R(96,t,!0),_=R(36,t,!1),v=e.kenBurns,y=Vi(o||v),b=[{type:`image`,id:`bg-image`,content:{src:n,alt:r,fit:`cover`,credit:l,license:u,...m?{treatment:m}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:y}],x=f.colors.background;if(s&&d)return b.push({type:`shape`,id:`title-gradient`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${C(x,.85)} 0%, ${C(x,.45)} 40%, ${C(x,.1)} 70%, ${C(x,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),b.push({type:`text`,id:`title`,content:{text:d,style:{fontSize:g,fontFamily:L(t,`title`),fontWeight:`bold`,color:f.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:c?`70%`:`75%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),c&&b.push({type:`text`,id:`subtitle`,content:{text:c,style:{fontSize:_,fontFamily:L(t,`body`),color:f.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`82%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),b;if(d){let e=a===`top`?`7%`:a===`center`?`42%`:`68%`,n=a===`top`?`13%`:a===`center`?`48%`:`74%`;b.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(x,0)}, ${C(x,.78)} 16%, ${C(x,.78)} 84%, ${C(x,0)})`},position:{x:0,y:e,width:`100%`,height:`16%`}}),b.push({type:`text`,id:`caption`,content:{text:d,style:{fontSize:h,fontFamily:L(t,`body`),color:f.colors.text,textAlign:`center`,shadow:B(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return b}function va(e,t,n){let{imageSrc:r,imageAlt:i,imageWidth:a,imageHeight:o,title:s,body:c}=e,{theme:l,layout:u}=t,d=V(t,e.imageTreatment),f=(a??0)>0||(o??0)>0,p=u.stackColumns,m=R(48,t,!0),h=R(24,t,!1),g,_,v,y,b;p?(g=`0`,_=`0`,v=`100%`,y=`50%`,b=f?`contain`:`cover`):f?(g=`${n===`left`?5:55}%`,_=`5%`,v=`40%`,y=`90%`,b=`contain`):(g=n===`left`?`0`:`50%`,_=`0`,v=`50%`,y=`100%`,b=`cover`);let x=p?90:42,S=p?`${(100-x)/2}%`:n===`left`?`54%`:`6%`,C=p?`60%`:c?`42%`:`50%`,w=p?`78%`:s?`55%`:`50%`,T=`top-left`,E=`left`,D=[{type:`shape`,id:`feature-bg`,content:{shape:`rect`,fill:l.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}];return r&&D.push({type:`image`,id:`feature-image`,content:{src:r,alt:i??s??``,fit:b,...d?{treatment:d}:{}},position:{x:g,y:_,width:v,height:y}}),s&&D.push({type:`text`,id:`feature-title`,content:{text:s,style:{fontSize:m,fontFamily:L(t,`title`),fontWeight:`bold`,color:l.colors.text,textAlign:E,lineHeight:1.2}},position:{x:S,y:C,anchor:T,width:`${x}%`},animation:z(t,`text`,{type:`fadeIn`,duration:.8})}),c&&D.push({type:`text`,id:`feature-body`,content:{text:c,style:{fontSize:h,fontFamily:L(t,`body`),color:l.colors.textMuted,textAlign:E,lineHeight:1.5}},position:{x:S,y:w,anchor:T,width:`${x}%`},animation:z(t,`text`,{type:`fadeIn`,duration:.8,delay:.2})}),D}function ya(e,t){return va(e,t,`left`)}function ba(e,t){return va(e,t,`right`)}function xa(e,t){let{center:n,zoom:r,mapStyle:i=`terrain`,title:a,caption:o,markers:s,ambientMotion:c,staticSrc:l}=e,{theme:u,layout:d}=t,f=R(64,t,!0),p=R(32,t,!1),m=Vi(c),h=[{type:`map`,id:`map-bg`,content:{center:n,zoom:r,style:i,markers:s,showAttribution:!0,staticSrc:l},position:{x:0,y:0,width:`100%`,height:`100%`},animation:m}],g=u.colors.background;return a&&(h.push({type:`shape`,id:`title-overlay`,content:{shape:`rect`,fill:`linear-gradient(180deg, ${C(g,.85)} 0%, ${C(g,.6)} 70%, ${C(g,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`title`,content:{text:a,style:{fontSize:f,fontFamily:L(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:`9%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.3}})),o&&(h.push({type:`shape`,id:`caption-overlay`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${C(g,.85)} 0%, ${C(g,.6)} 70%, ${C(g,0)} 100%)`},position:{x:0,y:`80%`,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`caption`,content:{text:o,style:{fontSize:p,fontFamily:L(t,`body`),color:u.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:d.captionY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.5}})),h}function Sa(e,t){let{text:n,colorScheme:r=`blue`}=e,i=I(t,r),a=R(120,t,!0);return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${i.bg} 0%, ${b(i.bg,.12)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`impact-text`,content:{text:n,style:{fontSize:a,fontFamily:L(t,`title`),fontWeight:`bold`,color:i.text,textAlign:`center`,lineHeight:1.2,shadow:B(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`85%`},animation:Pi(t,`fullBleedQuote`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.8}:{type:`fadeIn`,duration:1.5}}]}var Ca={gapX:260,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80};function wa(e,t={}){let n={...Ca,...t},r=[],i=[],a=[];for(let t=0;t<e.length;t++){let n=e[t],r=typeof n.x==`number`,o=typeof n.y==`number`;r&&o?i.push({child:n,pinned:!0,x:n.x,y:n.y}):(i.push({child:n,pinned:!1,x:0,y:0}),a.push(t))}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=n.gridOriginX,r=n.gridOriginY,o=i.filter(e=>e.pinned);if(o.length>0){let e=Math.min(...o.map(e=>e.x)),i=Math.max(...o.map(e=>e.y));t=e,r=i+n.gridPad+n.gapY}a.forEach((a,o)=>{let s=o%e,c=Math.floor(o/e);i[a].x=t+s*n.gapX,i[a].y=r+c*n.gapY})}let o=i.map(e=>({id:e.child.id,label:e.child.title??e.child.id,x:e.x,y:e.y,pinned:e.pinned,...e.child.classes&&e.child.classes.length>0?{classes:e.child.classes}:{}})),s=new Set(o.map(e=>e.id)),c=[],l=new Set;for(let t of e)if(t.connectsTo)for(let e of t.connectsTo){if(!s.has(e.target)){r.push(`Edge from "${t.id}" to "${e.target}" dropped: no such sibling node`);continue}let n=Ta(t.id,e);l.has(n)||(l.add(n),c.push({id:n,source:t.id,target:e.target,...e.type?{type:e.type}:{}}))}return{nodes:o,edges:c,warnings:r}}function Ta(e,t){return t.type?`${e}->${t.target}:${t.type}`:`${e}->${t.target}`}var Ea=14,Da=28;function Oa(e,t){return{x:e*14,y:t*28}}function ka(e,t){return{col:Math.max(0,Math.round(e/14)),row:Math.max(0,Math.round(t/28))}}function Aa(e){let t=e.nodes.map(e=>({id:e.id,label:e.label,...Oa(e.col,e.row),w:e.wCols*14,h:e.hRows*28,...e.containerId?{container:e.containerId}:{}})),n=ja(t,e.edges);return{nodes:t,edges:e.edges.map((e,t)=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.directed?{}:{directed:!1},...n[t],routing:`orthogonal`}))}}function ja(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.source),r=n.get(e.target);if(!t||!r)return{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}};let i=t.w??168,a=t.h??84,o=r.w??168,s=r.h??84,c=r.x+o/2-(t.x+i/2),l=r.y+s/2-(t.y+a/2),u=Math.abs(c)/Math.max(1,(i+o)/2);return Math.abs(l)/Math.max(1,(a+s)/2)>=u?l>=0?{sourceAnchor:{side:`bottom`,offset:.5},targetAnchor:{side:`top`,offset:.5}}:{sourceAnchor:{side:`top`,offset:.5},targetAnchor:{side:`bottom`,offset:.5}}:c>=0?{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}}:{sourceAnchor:{side:`left`,offset:.5},targetAnchor:{side:`right`,offset:.5}}});return Na(r,t,e,`source`),Na(r,t,e,`target`),Ma(r,t,e),r}function Ma(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map;t.forEach((e,t)=>{let n=i.get(e.source)??[];n.push(t),i.set(e.source,n)});for(let[n,a]of i){if(a.length<2)continue;let i=r.get(n),o=a.map(e=>r.get(t[e].target)).filter(e=>e!==void 0);if(!i||o.length!==a.length)continue;let s=i.w??168,c=i.h??84,l=i.x+s,u=i.y+c,d=e=>e.x+(e.w??168),f=e=>e.y+(e.h??84),p,m;if(o.every(e=>e.y>=u)?(p=`bottom`,m=`top`):o.every(e=>f(e)<=i.y)?(p=`top`,m=`bottom`):o.every(e=>e.x>=l)?(p=`right`,m=`left`):o.every(e=>d(e)<=i.x)&&(p=`left`,m=`right`),!(!p||!m))for(let t of a)e[t]={sourceAnchor:{side:p,offset:.5},targetAnchor:{side:m,offset:.5}}}}function Na(e,t,n,r){let i=new Map(n.map(e=>[e.id,e])),a=new Map;for(let n=0;n<t.length;n++){let i=t[n],o=r===`source`?e[n].sourceAnchor:e[n].targetAnchor,s=`${r===`source`?i.source:i.target}:${o.side}`,c=a.get(s)??[];c.push(n),a.set(s,c)}for(let n of a.values()){if(n.length<2)continue;let a=r===`source`?e[n[0]].sourceAnchor.side:e[n[0]].targetAnchor.side;n.sort((e,n)=>{let o=i.get(r===`source`?t[e].target:t[e].source),s=i.get(r===`source`?t[n].target:t[n].source);return(a===`top`||a===`bottom`?o?.x??0:o?.y??0)-(a===`top`||a===`bottom`?s?.x??0:s?.y??0)||e-n}),n.forEach((t,i)=>{let a=r===`source`?e[t].sourceAnchor:e[t].targetAnchor;a.offset=(i+1)/(n.length+1)})}}function Pa(e,t,n={}){let r=new Set(e.map(e=>e.id));return{nodes:e.map(e=>{let{col:t,row:n}=ka(e.x,e.y),i=e.label.length>0?e.label.split(`
|
|
18
|
+
`):[],a=i.reduce((e,t)=>Math.max(e,t.length),0),o=typeof e.w==`number`?Math.max(3,Math.round(e.w/14)):a+4,s=typeof e.h==`number`?Math.max(3,Math.round(e.h/28)):i.length+2;return{id:e.id,label:e.label,col:t,row:n,wCols:Math.max(o,3),hRows:Math.max(s,3),...e.container&&r.has(e.container)&&e.container!==e.id?{containerId:e.container}:{}}}),edges:t.filter(e=>r.has(e.source)&&r.has(e.target)).map(e=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},directed:e.directed!==!1})),style:n.style??`unicode`,warnings:[]}}function Fa(e,t={}){let n=wa(e),r=Pa(n.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y})),n.edges.map(e=>({source:e.source,target:e.target,...e.type?{label:e.type}:{}})),t);return r.warnings.push(...n.warnings),r}function Ia(e){let t=e.tracks.length>0?Math.min(...e.tracks.map(e=>e.startColumn)):0,n=e.tracks.length>0?Math.max(...e.tracks.map(e=>e.endColumn)):1,r=Math.max(1,n-t);return{tracks:e.tracks.map(e=>({id:e.id,...e.label?{label:e.label}:{},...e.endLabel?{endLabel:e.endLabel}:{},events:e.events.map(e=>({id:e.id,label:e.label,...e.description?{description:e.description}:{},position:La((e.column-t)/r),...e.side?{side:e.side}:{},...e.descriptionSide?{descriptionSide:e.descriptionSide}:{},...e.callout===!1?{callout:!1}:{},...e.marker?{marker:e.marker}:{}}))})),links:e.links.map(e=>({...e}))}}function La(e){return Math.max(0,Math.min(1,e))}function Ra(e){return{items:e.roots.map(za)}}function za(e){return{id:e.id,label:e.label,...e.isDir?{isDir:!0}:{},...e.comment?{comment:e.comment}:{},children:e.children.map(za)}}function Ba(e,t={}){return{roots:e.map(Va),style:t.style??`unicode`,warnings:[]}}function Va(e){let t=Array.isArray(e.children)?e.children.map(Va):[];return{id:typeof e.id==`string`&&e.id?e.id:`node`,label:typeof e.label==`string`?e.label:``,children:t,isDir:e.isDir===!0||t.length>0,...e.comment?{comment:e.comment}:{}}}function Ha(e){let t=new Map,n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`,r=e=>{let r=n(e.replace(/\/$/,``)),i=t.get(r)??0;return t.set(r,i+1),i===0?r:`${r}-${i+1}`},i=e=>{let t=e.children.find(e=>e.type!==`list`),n=t?o(t).trim():``,a=e.children.filter(e=>e.type===`list`),s=[];for(let e of a)for(let t of e.children)s.push(i(t));return{id:r(n),label:n,children:s,isDir:n.endsWith(`/`)||s.length>0}};return{roots:e.children.map(i),style:`unicode`,warnings:[]}}function Ua(e){return e?.find(e=>e.type===`list`)}var Wa=/\.(?:webm|mp4|mov|m4v|ogv)(?:[?#].*)?$/i;function Ga(e){return!e||e.length===0?``:e.filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`)).map(e=>o(e)).join(`
|
|
19
|
+
`).trim()}function Ka(e){return Ya(e).map(e=>e.text)}function G(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function qa(e){return e.map(e=>{switch(e.type){case`text`:return G(e.value);case`emphasis`:return`<em>${qa(e.children)}</em>`;case`strong`:return`<strong>${qa(e.children)}</strong>`;case`delete`:return`<del>${qa(e.children)}</del>`;case`inlineCode`:return`<code>${G(e.value)}</code>`;case`link`:{let t=qa(e.children),n=le(e.url,`link`);if(!n)return t;let r=e.title?` title="${G(e.title)}"`:``;return`<a href="${G(n)}"${r}>${t}</a>`}case`break`:return`<br>`;case`image`:return G(e.alt??``);case`inlineMath`:return G(`$${e.value}$`);case`footnoteReference`:return G(`[^${e.label??e.identifier}]`);case`linkReference`:case`textDirective`:return qa(e.children);case`imageReference`:return G(e.alt??``);case`mention`:return G(`@${e.displayName}`);case`inlineIcon`:return`<i class="fa-${e.family} fa-${e.name}" aria-hidden="true"></i>`;case`htmlInline`:return G(e.rawHtml)}}).join(``)}function Ja(e){return e.map(e=>e.type===`paragraph`||e.type===`heading`?qa(e.children):G(o(e))).join(`<br>`)}function Ya(e){if(!e)return[];let t=[];for(let n of e)if(n.type===`list`)for(let e of n.children){let n=o(e).trim();if(!n)continue;let r=Ja(e.children),i=G(n).replace(/\r?\n/g,`<br>`);t.push({text:n,markdown:e.children,...r&&r!==i?{html:r}:{}})}return t}function Xa(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function Za(e,t=1/0){if(!e||e.length===0)return[];let n=[];function r(e){for(let i of e){if(n.length>=t)return;if(!i||typeof i!=`object`)continue;let e=i;if(e.type===`htmlElement`&&e.tagName===`img`){let t=e.attributes;t&&typeof t.src==`string`&&t.src&&n.push({src:t.src,alt:typeof t.alt==`string`?t.alt:``,width:Xa(t.width),height:Xa(t.height)})}Array.isArray(e.children)&&r(e.children)}}function i(e){if(n.length>=t||!e||typeof e!=`object`)return;let a=e;if(a.type===`image`&&typeof a.url==`string`&&a.url){n.push({src:a.url,alt:typeof a.alt==`string`?a.alt:``});return}if((a.type===`htmlBlock`||a.type===`htmlInline`)&&Array.isArray(a.htmlChildren)&&r(a.htmlChildren),Array.isArray(a.children))for(let e of a.children)i(e)}for(let r of e){if(n.length>=t)break;i(r)}return n}function Qa(e){return Za(e,1)[0]??null}function $a(e,t=1/0){if(!e||e.length===0)return[];let n=[],r=new Set,i=e=>{!e.src||n.length>=t||r.has(e.src)||(r.add(e.src),n.push(e))};function a(e){if(Array.isArray(e))for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(e.tagName===`source`){let t=e.attributes;if(typeof t?.src==`string`&&t.src)return t.src}let n=a(e.children);if(n)return n}}function s(e){if(n.length>=t||!e||typeof e!=`object`)return;let r=e;if(r.type===`htmlElement`&&r.tagName===`video`){let e=r.attributes,t=e?.src||a(r.children);if(t){let n=e?.[`data-squisq-video-start-at`]?he(e[`data-squisq-video-start-at`]):null,r=e?.[`data-squisq-video-clip-start`]?he(e[`data-squisq-video-clip-start`]):null,a=e?.[`data-squisq-video-clip-end`]?he(e[`data-squisq-video-clip-end`]):null;i({src:t,...e?.poster?{posterSrc:e.poster}:{},alt:e?.[`aria-label`]||e?.title||e?.alt||``,...n==null?{}:{startAt:n},...r==null?{}:{clipStart:r},...a==null?{}:{clipEnd:a}})}}else(r.type===`link`||r.type===`image`)&&typeof r.url==`string`&&Wa.test(r.url)&&i({src:r.url,alt:typeof r.alt==`string`?r.alt:o(r).trim()});Array.isArray(r.children)&&r.children.forEach(s),Array.isArray(r.htmlChildren)&&r.htmlChildren.forEach(s)}return e.forEach(s),n}function eo(e){return $a(e,1)[0]??null}function to(e){if(!e)return null;for(let t of e)if(t.type===`table`){let e=t,[n,...r]=e.children;return n?{headers:n.children.map(e=>o(e).trim()),rows:r.map(e=>e.children.map(e=>o(e).trim())),align:e.align}:null}return null}function no(e){if(!e)return``;for(let t of e)if(t.type===`blockquote`)return o(t).trim();return``}function ro(e){if(!e)return null;let t=e.findIndex(e=>e.type===`paragraph`);return t<0?null:{node:e[t],index:t}}function io(e){for(let t of e.children)if(!(t.type===`text`&&t.value.trim()===``))return t.type===`strong`&&o(t).trim().match(/^(?:[$€£¥]\s*)?[+-]?\d+(?:[.,]\d+)*(?:\s?(?:[%‰x×]|[A-Za-z]+))?/)?.[0].trim()||null;return null}function ao(e,t,n){let r=e.slice(0,t).trim(),i=e.slice(n);return i=r?i.trim():i.replace(/^\s*(?:[-–—:]\s*)?/,``),[r,i].filter(Boolean).join(` `).trim()}function oo(e,t,n,r,i){return e?e.map((e,a)=>a===t?ao(n,r,i):o(e).trim()).filter(Boolean).join(`
|
|
20
|
+
`).trim():``}function so(e,t,n){let r=ro(t);if(r){let n=o(r.node).trim(),i=io(r.node);if(i){let a=n.indexOf(i);return{stat:i,description:oo(t,r.index,n,a,a+i.length)||e||i}}}let i=e.trim(),a=$r(i);if(a&&a.index===0&&a.end===i.length)return{stat:e,description:n||e};if(r){let n=o(r.node).trim(),i=$r(n);if(i){let a=oo(t,r.index,n,i.index,i.end);return{stat:i.value,description:a||e||i.value}}}return{stat:e,description:n||e}}function co(e){return e.replace(/\s+/g,` `).trim()}function lo(e,t){let n=t??[];switch(e){case`quote`:return n.length===1&&n[0]?.type===`blockquote`;case`dataTable`:return n.length===1&&n[0]?.type===`table`;case`list`:return n.length===1&&n[0]?.type===`list`;case`diagram`:case`timeline`:return n.length===1&&n[0]?.type===`code`;case`tree`:return n.length===1&&(n[0]?.type===`code`||n[0]?.type===`list`);case`photoGrid`:{let e=Za(n);if(e.length<2||e.length>4)return!1;let t=co(Ga(n)),r=co(e.map(e=>e.alt).filter(Boolean).join(` `));return t===``||t===r}case`videoWithCaption`:{let e=$a(n);return e.length===1&&co(Ga(n))===co(e[0]?.alt??``)}case`leftFeature`:case`rightFeature`:case`statHighlight`:return!0;default:return!1}}function uo(e,t,n,r={}){let i=r.placeholders===!0,a=Ga(n);switch(e){case`statHighlight`:{let e=so(t,n,a);return r.preserveSourceHeading&&t&&e.stat!==t&&e.description!==t?{...e,description:t,...e.description?{detail:e.description}:{}}:e}case`quote`:{let e=no(n)||a;return e?{quote:e,...t?{title:t}:{}}:{quote:t}}case`fullBleedQuote`:case`pullQuote`:return{text:no(n)||a||t};case`factCard`:return{fact:t,explanation:a||t};case`comparisonBar`:return i?{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40}:null;case`list`:{let e=Ka(n);return e.length>0?{items:e,...t?{title:t}:{}}:i?{items:[`Item 1`,`Item 2`,`Item 3`]}:null}case`definitionCard`:return{term:t,definition:a||t};case`dateEvent`:return{date:t,description:a||t};case`dataTable`:{let e=to(n);return e?{...e,...t?{title:t}:{}}:i?{headers:[`Column`],rows:[[`Data`]]}:null}case`barChart`:case`columnChart`:case`pieChart`:case`donutChart`:case`lineChart`:case`areaChart`:case`scatterChart`:{let e=to(n);return e?{headers:e.headers,rows:e.rows,...t?{title:t}:{}}:i&&!a.trim()?{headers:[`Quarter`,`Revenue`,`Costs`],rows:[[`Q1`,`40`,`28`],[`Q2`,`55`,`31`],[`Q3`,`48`,`30`],[`Q4`,`62`,`35`]],...t?{title:t}:{}}:null}case`imageWithCaption`:{let e=Qa(n);return e?{imageSrc:e.src,imageAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`bigText`:{let e=Qa(n);return{title:t,...e?{imageSrc:e.src,imageAlt:e.alt||t}:{}}}case`photoGrid`:{let e=Za(n,4);return e.length<2?i?{}:null:{images:e.map(e=>({src:e.src,alt:e.alt})),caption:t}}case`videoWithCaption`:{let e=eo(n);return e?{videoSrc:e.src,posterSrc:e.posterSrc,videoAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`leftFeature`:case`rightFeature`:{let e=Qa(n);return!e&&!i?null:{imageSrc:e?.src??``,imageAlt:e?.alt||t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:a}}case`diagram`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&an(e[0].lang)?e[0]:void 0,a=r?sn(r.value,{explicit:on(r.lang)}):void 0;if(!a?.isDiagram||!a.diagram)return i?{}:null;let{nodes:o,edges:s}=Aa(a.diagram);return{nodes:o,edges:s,...t?{title:t}:{}}}case`timeline`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&yr(e[0].lang)?e[0]:void 0,a=r?xr(r.value,{explicit:!0}):void 0;if(!a?.isTimeline||!a.timeline)return i?{}:null;let{tracks:o,links:s}=Ia(a.timeline);return{tracks:o,links:s,...t?{title:t}:{}}}case`tree`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&qr(e[0].lang)?e[0]:void 0;if(r){let e=Yr(r.value,{explicit:Jr(r.lang)});if(e.isTree&&e.tree){let{items:n}=Ra(e.tree);return{items:n,...t?{title:t}:{}}}}let a=Ua(n);if(a){let{items:e}=Ra(Ha(a));if(e.length>0)return{items:e,...t?{title:t}:{}}}return i?{}:null}default:return i?{}:null}}var fo=1.2,po=18;function mo(e,t,n){if(!e.trim())return 1;let r=Math.floor(n/(t*.5));if(r<=0)return 1;let i=0,a=0;for(let t of e.split(/\s+/)){let e=a?a+1+t.length:t.length;if(e<=r){a=e;continue}a&&(i+=1);let n=t.length;for(;n>r;)i+=1,n-=r;a=n}return Math.max(1,i+ +!!a)}function ho(e,t){let{title:n,accentImage:r}=e,i=Array.isArray(e.items)?e.items:[],a=Ya(t.block?.contents),{theme:o}=t,s=r?Wi(r.position):Bi,c=R(44,t,!0),l=R(34,t,!1),u=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`linear-gradient(155deg, ${o.colors.backgroundLight} 0%, ${o.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];r&&u.push(...Gi(r,e.id,V(t,e.imageTreatment)));let d=parseFloat(s.textCenterX),f=parseFloat(s.textWidth),p=Number.isFinite(d)&&Number.isFinite(f)?d-f/2:8,m=`${p}%`,h=n?34:26;n&&u.push({type:`text`,id:`list-title`,content:{text:n,style:{fontSize:c,fontFamily:L(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`left`,shadow:B(t)}},position:{x:m,y:W(`20%`,s),width:s.textWidth},animation:z(t,`text`,{type:`fadeIn`,duration:1})});let g=(Number.isFinite(f)?f/100:.85)*t.viewport.width,_=`${i.length}.`,v=Math.max(l,_.length*l*.5),y=v+l*.35,b=`${p+y/t.viewport.width*100}%`,x=Math.max(l,g-y),S=h;for(let e=0;e<i.length;e++){let n=i[e],r=a[e]?.text===n?a[e]?.html:void 0,c=mo(n,l,x),d=z(t,`text`,{type:`fadeIn`,duration:.8,delay:.3+.3*e});u.push({type:`text`,id:`item-${e}-marker`,content:{text:`${e+1}.`,style:{fontSize:l,fontFamily:L(t,`body`),color:o.colors.text,textAlign:`right`,lineHeight:fo,shadow:B(t)}},position:{x:m,y:W(`${S}%`,s),width:v},animation:d}),u.push({type:`text`,id:`item-${e}`,content:{text:n,...r?{html:r}:{},style:{fontSize:l,fontFamily:L(t,`body`),color:o.colors.text,textAlign:`left`,lineHeight:fo,shadow:B(t)}},position:{x:b,y:W(`${S}%`,s),width:x},animation:d});let f=c*l*fo;S+=(f+po)/t.viewport.height*100}return u}var K=1.2;function go(e,t){let{images:n,caption:r,ambientMotion:i}=e;if(!n||n.length===0)return[];let a=r&&Ii(r),{theme:o,layout:s}=t,c=V(t,e.imageTreatment),l=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}],u=_o(n.length,100,s.stackColumns);for(let e=0;e<Math.min(n.length,4);e++){let t=n[e],r=u[e];l.push({type:`shape`,id:`grid-placeholder-${e}`,content:{shape:`rect`,fill:o.colors.background},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`}}),l.push({type:`image`,id:`grid-img-${e}`,content:{src:t.src,alt:t.alt,fit:`cover`,credit:t.credit,license:t.license,...c?{treatment:c}:{}},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`},animation:e===0&&i?{type:i,duration:15}:{type:`fadeIn`,duration:1,delay:.2*e}})}if(a){let e=R(s.stackColumns?24:26,t,!1),n=s.stackColumns?`78%`:`74%`,r=s.stackColumns?`72%`:`68%`,i=s.stackColumns?`13%`:`16%`,c=o.colors.background;l.push({type:`shape`,id:`caption-bg`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(c,0)}, ${C(c,.78)} 16%, ${C(c,.78)} 84%, ${C(c,0)})`},position:{x:0,y:r,width:`100%`,height:i}}),l.push({type:`text`,id:`caption`,content:{text:a,style:{fontSize:e,fontFamily:L(t,`body`),color:o.colors.text,textAlign:`center`,shadow:!0,lineHeight:1.18,maxLines:s.stackColumns?2:1}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1,delay:.5}})}return l}function _o(e,t,n){let r=50-K/2,i=t/2-K/2;switch(e){case 1:return[{x:0,y:0,w:100,h:t}];case 2:return n?[{x:0,y:0,w:100,h:i},{x:0,y:t/2+K/2,w:100,h:i}]:[{x:0,y:0,w:r,h:t},{x:50+K/2,y:0,w:r,h:t}];case 3:{if(n){let e=t/3-K*2/3;return[{x:0,y:0,w:100,h:e},{x:0,y:t/3+K/3,w:100,h:e},{x:0,y:t*2/3+K*2/3,w:100,h:e}]}let e=60-K/2,r=40-K/2;return[{x:0,y:0,w:e,h:t},{x:60+K/2,y:0,w:r,h:i},{x:60+K/2,y:t/2+K/2,w:r,h:i}]}default:return[{x:0,y:0,w:r,h:i},{x:50+K/2,y:0,w:r,h:i},{x:0,y:t/2+K/2,w:r,h:i},{x:50+K/2,y:t/2+K/2,w:r,h:i}]}}function vo(e,t){let{term:n,definition:r,origin:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=I(t,a),l=o?Wi(o.position):Bi,u=R(72,t,!0),d=R(32,t,!1),f=R(22,t,!1),p=[Li(`bg`,H(t,145))];return o&&p.push(...Gi(o,e.id,V(t,e.imageTreatment))),p.push({type:`text`,id:`term`,content:{text:n,style:{fontSize:u,fontFamily:L(t,`title`),fontWeight:`bold`,color:c.text,textAlign:`center`,shadow:B(t)}},position:{x:l.textCenterX,y:W(`30%`,l),anchor:`center`},animation:z(t,`text`,{type:`fadeIn`,duration:1.5})}),p.push({type:`shape`,id:`separator`,content:{shape:`rect`,fill:`${c.text}33`},position:{x:l.textCenterX,y:W(`42%`,l),width:`30%`,height:`2px`,anchor:`center`}}),p.push({type:`text`,id:`definition`,content:{text:r,style:{fontSize:d,fontFamily:L(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,maxLines:4,shadow:B(t)}},position:{x:l.textCenterX,y:W(`55%`,l),width:l.textWidth,anchor:`center`},animation:z(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&p.push({type:`text`,id:`origin`,content:{text:i,style:{fontSize:f,fontFamily:L(t,`body`),color:s.colors.textMuted,textAlign:`center`,shadow:B(t)}},position:{x:l.textCenterX,y:W(`70%`,l),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),p}function yo(e,t){let{leftLabel:n,rightLabel:r,unit:i,colorScheme:a=`blue`}=e,{theme:o,viewport:s}=t,c=I(t,a),l=Number.isFinite(e.leftValue)?e.leftValue:0,u=Number.isFinite(e.rightValue)?e.rightValue:0,d=R(28,t,!1),f=R(48,t,!0),p=e=>Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:e.toLocaleString():`—`,m=i?`${p(l)} ${i}`:p(l),h=i?`${p(u)} ${i}`:p(u),g=Math.max(0,l),_=Math.max(0,u),v=Math.max(g,_,1),y=Math.max(m.length,h.length)*f*.58/s.width*100,b=Math.max(20,Math.min(65,81-y-2)),x=g/v*b,S=_/v*b;return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:H(t,180)},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`left-label`,content:{text:n,style:{fontSize:d,fontFamily:L(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`28%`}},{type:`text`,id:`left-value`,content:{text:m,style:{fontSize:f,fontFamily:L(t,`body`),fontWeight:`bold`,color:c.text}},position:{x:`${15+x+2}%`,y:`35%`},animation:{type:`fadeIn`,duration:.8,delay:.3}},{type:`shape`,id:`left-bar`,content:{shape:`rect`,fill:c.text,borderRadius:4},position:{x:`15%`,y:`36%`,width:`${x}%`,height:`6%`},animation:{type:`fadeIn`,duration:1}},{type:`text`,id:`right-label`,content:{text:r,style:{fontSize:d,fontFamily:L(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`50%`}},{type:`text`,id:`right-value`,content:{text:h,style:{fontSize:f,fontFamily:L(t,`body`),fontWeight:`bold`,color:c.accent}},position:{x:`${15+S+2}%`,y:`57%`},animation:{type:`fadeIn`,duration:.8,delay:.6}},{type:`shape`,id:`right-bar`,content:{shape:`rect`,fill:c.accent,borderRadius:4},position:{x:`15%`,y:`58%`,width:`${S}%`,height:`6%`},animation:{type:`fadeIn`,duration:1,delay:.3}}]}function bo(e,t){let{text:n,attribution:r,backgroundImage:i,ambientMotion:a}=e,{viewport:o}=t,s=V(t,e.imageTreatment);if(!i?.src)return[];let c=R(52,t,!0),l=R(26,t,!1),u=R(200,t,!0),d=1.4,f=r?45:50,p=[{type:`image`,id:`bg-image`,content:{src:i.src,alt:i.alt,fit:`cover`,credit:i.credit,license:i.license,...s?{treatment:s}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Vi(a,15)},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:u,fontFamily:L(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:c,fontFamily:L(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:d,shadow:!0}},position:{x:`50%`,y:`${f}%`,anchor:`center`,width:`72%`},animation:z(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=U(n,c,.72*o.width,d),i=Math.min(82,f+(e/2+c*1.7)/o.height*100);p.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:l,fontFamily:L(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return p}function xo(e,t){let{videoSrc:n,posterSrc:r,videoAlt:i,clipStart:a=0,clipEnd:o,sourceDuration:s,caption:c,captionPosition:l=`bottom`,videoCredit:u,videoLicense:d}=e,f=c&&Ii(c),{theme:p}=t,m=Math.max(a,o??a+Math.max(0,e.duration)),h=R(30,t,!1),g=R(16,t,!1),_=[{type:`video`,id:`bg-video`,content:{src:n,posterSrc:r,alt:i,fit:`cover`,clipStart:a,clipEnd:m,sourceDuration:s,credit:u,license:d},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(f){let e=p.colors.background,n=l===`top`?`7%`:l===`center`?`42%`:`68%`,r=l===`top`?`13%`:l===`center`?`48%`:`74%`;_.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(e,0)}, ${C(e,.78)} 16%, ${C(e,.78)} 84%, ${C(e,0)})`},position:{x:0,y:n,width:`100%`,height:`16%`}}),_.push({type:`text`,id:`caption`,content:{text:f,style:{fontSize:h,fontFamily:L(t,`body`),color:p.colors.text,textAlign:`center`,shadow:B(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:r,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return u&&_.push({type:`text`,id:`credit`,content:{text:u,style:{fontSize:g,fontFamily:L(t,`body`),color:C(p.colors.text,.65),textAlign:`right`}},position:{x:`96%`,y:`96%`,anchor:`bottom-right`}}),_}function So(e,t){let{text:n,attribution:r,backgroundVideo:i}=e,{viewport:a}=t;if(!i?.src)return[];let o=R(52,t,!0),s=R(26,t,!1),c=R(200,t,!0),l=1.4,u=r?45:50,d=[{type:`video`,id:`bg-video`,content:{src:i.src,posterSrc:i.posterSrc,alt:i.alt,fit:`cover`,clipStart:i.clipStart,clipEnd:i.clipEnd,credit:i.credit,license:i.license},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:c,fontFamily:L(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:o,fontFamily:L(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:l,shadow:!0}},position:{x:`50%`,y:`${u}%`,anchor:`center`,width:`72%`},animation:z(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=U(n,o,.72*a.width,l),i=Math.min(82,u+(e/2+o*1.7)/a.height*100);d.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:s,fontFamily:L(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return d}function Co(e,t){let{title:n,headers:r,rows:i,align:a,colorScheme:o}=e,{theme:s,viewport:c}=t,l=I(t,o),u=R(48,t,!0),d=R(28,t,!1),f=[Li(`bg`,H(t,170))],p=(Array.isArray(i)?i.length:0)+1,m=Math.min(74,p*d*2.4/c.height*100),h=n?u*2.2*100/c.height:0,g=Math.max(8,(100-h-m)/2);return n&&f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:u,fontFamily:L(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:`${g+h/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),f.push({type:`table`,id:`table`,content:{headers:r,rows:i,align:a,style:{headerBackground:l.accent,headerColor:S(l.accent),cellBackground:C(s.colors.text,.04),cellColor:s.colors.text,borderColor:C(s.colors.text,.15),fontSize:d,fontFamily:L(t,`body`),headerFontFamily:L(t,`title`),borderRadius:8}},position:{x:`10%`,y:`${g+h}%`,width:`80%`,height:`${m}%`},animation:{type:`fadeIn`,duration:1,delay:n?.4:0}}),f}var wo=1.25;function To(e,t,n,r){let i=Math.max(1,t-24),a=Math.max(1,n-16),o=Math.max(10,Math.floor(r)),s=Eo(e,o,i);for(;o>10&&s*o*1.25>a;)o--,s=Eo(e,o,i);return{fontSize:o,lineCount:s,firstLineOffset:s===1?0:-((s-1)*o*wo)/2,textWidth:i}}function Eo(e,t,n){return e.split(`
|
|
21
|
+
`).reduce((e,r)=>e+Do(r,t,n),0)}function Do(e,t,n){if(!e.trim())return 1;let r=Math.floor(n/(t*.5));if(r<=0)return 1;let i=0,a=0;for(let t of e.split(/\s+/)){let e=a>0?a+1+t.length:t.length;if(e<=r){a=e;continue}a>0&&i++,t.length>r?(i+=Math.floor((t.length-1)/r),a=t.length%r||r):a=t.length}return a>0&&i++,Math.max(1,i)}var Oo=180,ko=64,Ao=80;function jo(e){let t=wa(e.children??[]);return{nodes:t.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:Oo,h:ko,depth:0,isContainer:!1})),edges:t.edges.map(e=>({id:e.id,source:e.source,target:e.target,...e.type?{label:e.type}:{},directed:!0}))}}function Mo(e){let t=(Array.isArray(e.nodes)?e.nodes:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&e.id.length>0&&typeof e.label==`string`&&typeof e.x==`number`&&Number.isFinite(e.x)&&typeof e.y==`number`&&Number.isFinite(e.y)),n=new Set(t.map(e=>e.id)),r=new Set(t.map(e=>e.container).filter(e=>typeof e==`string`&&n.has(e))),i=e=>{let r=0,i=e,a=new Set;for(;i?.container&&n.has(i.container)&&!a.has(i.id);)a.add(i.id),r++,i=t.find(e=>e.id===i?.container);return r};return{nodes:t.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:typeof e.w==`number`&&Number.isFinite(e.w)&&e.w>0?e.w:Oo,h:typeof e.h==`number`&&Number.isFinite(e.h)&&e.h>0?e.h:ko,depth:i(e),isContainer:r.has(e.id)})),edges:(Array.isArray(e.edges)?e.edges:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.source==`string`&&typeof e.target==`string`&&n.has(e.source)&&n.has(e.target)).map((e,t)=>({id:e.label?`${e.source}->${e.target}:${e.label}`:`${e.source}->${e.target}-${t}`,source:e.source,target:e.target,...e.label?{label:e.label}:{},directed:e.directed!==!1,...e.sourceAnchor?{sourceAnchor:e.sourceAnchor}:{},...e.targetAnchor?{targetAnchor:e.targetAnchor}:{},...e.routing?{routing:e.routing}:{}}))}}function No(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=e.colorScheme?I(t,e.colorScheme):void 0,o=i.length>0?jo(t):e.nodes&&e.nodes.length>0?Mo(e):{nodes:[],edges:[]};if(o.nodes.length===0)return[{type:`text`,id:`diagram-empty`,content:{text:e.title??`Empty diagram`,style:{fontSize:R(36,t,!0),fontFamily:L(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}];let s=Math.min(...o.nodes.map(e=>e.x)),c=Math.max(...o.nodes.map(e=>e.x+e.w)),l=Math.min(...o.nodes.map(e=>e.y)),u=Math.max(...o.nodes.map(e=>e.y+e.h)),d=e.title?120:0,f=Math.max(1,r.width-Ao*2),p=Math.max(1,r.height-Ao*2-d),m=Math.max(1,c-s),h=Math.max(1,u-l),g=Math.min(f/m,p/h,1.8),_=Math.min(Math.max(g,1),1.5),v=Math.round(2*_),y=m*g,b=h*g,x=Math.max(Ao/2,(r.height-d-b)/2),S=Ao+(f-y)/2,C=x+d,w=e=>({x:S+(e.x-s)*g,y:C+(e.y-l)*g,w:e.w*g,h:e.h*g}),T=[];e.title&&T.push({type:`text`,id:`diagram-title`,content:{text:e.title,style:{fontSize:R(40,t,!0),fontFamily:L(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`}},position:{x:`50%`,y:x+d/2-16,anchor:`center`}});let E=o.nodes.filter(e=>e.isContainer).sort((e,t)=>e.depth-t.depth||e.y-t.y||e.x-t.x),D=o.nodes.filter(e=>!e.isContainer);for(let e of E){let t=w(e),r={type:`shape`,id:`node-card-${e.id}`,content:{shape:`rect`,fill:a?.bg??n.colors.backgroundLight,fillOpacity:.25,stroke:a?.text??n.colors.primary,strokeWidth:Math.max(1,v-1),borderRadius:10},position:{x:t.x,y:t.y,width:t.w,height:t.h}};T.push(r)}let O=new Map;for(let e of o.nodes){let t=w(e);O.set(e.id,{cx:t.x+t.w/2,cy:t.y+t.h/2,rx:t.w/2,ry:t.h/2})}let k=e.startStyle??`none`,A=e.endStyle??`arrow`,ee=Be(e.lineStyle);for(let r of o.edges){let i=O.get(r.source),o=O.get(r.target);if(!i||!o)continue;let s=r.directed?A:`none`,c=Pe(i,o),l=r.sourceAnchor?Me(i,r.sourceAnchor):c.start,u=r.targetAnchor?Me(o,r.targetAnchor):c.end,d={type:`path`,id:`edge-${r.id}`,content:{d:Le(r.routing??e.edgeStyle??`curved`,l,u),stroke:a?.text??n.colors.primary,strokeWidth:v,fill:`none`,...ee?{dasharray:ee}:{},...k===`none`?{}:{startMarker:k},...s===`none`?{}:{endMarker:s}},position:{x:0,y:0,width:`100%`,height:`100%`}};if(T.push(d),r.label){let e=(i.cx+o.cx)/2,a=(i.cy+o.cy)/2,s=R(Math.round(18*_),t,!1),c={type:`text`,id:`edge-label-${r.id}`,content:{text:r.label,style:{fontSize:s,fontFamily:L(t,`body`),color:n.colors.textMuted,textAlign:`center`}},position:{x:e,y:a-s*.9,anchor:`center`}};T.push(c)}}for(let r of D){let i=w(r),o={type:`shape`,id:`node-card-${r.id}`,content:{shape:`rect`,fill:a?.bg??n.colors.backgroundLight,stroke:a?.text??n.colors.primary,strokeWidth:v,borderRadius:e.nodeShape===`pill`?i.h/2:10},position:{x:i.x,y:i.y,width:i.w,height:i.h}};T.push(o);let s=R(Math.round(22*_),t,!1),c=To(r.label,i.w,i.h,s),l={type:`text`,id:`node-label-${r.id}`,content:{text:r.label,style:{fontSize:c.fontSize,fontFamily:L(t,`body`),fontWeight:`bold`,color:a?.text??n.colors.text,textAlign:`center`,lineHeight:wo}},position:{x:i.x+i.w/2,y:i.y+i.h/2+c.firstLineOffset,anchor:`center`,width:c.textWidth}};T.push(l)}for(let e of E){let r=w(e),i=R(Math.round(20*_),t,!1),a={type:`text`,id:`node-label-${e.id}`,content:{text:e.label.split(`
|
|
22
|
+
`)[0]??``,style:{fontSize:i,fontFamily:L(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`center`}},position:{x:r.x+r.w/2,y:r.y+i,anchor:`center`,width:r.w}};T.push(a)}return T}function Po(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(typeof e.label!=`string`)continue;let r=Po(e.children);t.push({id:typeof e.id==`string`&&e.id?e.id:Fo(e.label),label:e.label,children:r,...e.isDir===!0||r.length>0?{isDir:!0}:{},...typeof e.comment==`string`&&e.comment?{comment:e.comment}:{}})}return t}function Fo(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Io(e,t){let{theme:n,viewport:r}=t,i=I(t,e.colorScheme),a=Po(e.items),o=R(48,t,!0),s=R(28,t,!1),c=[Li(`bg`,H(t,170))];if(a.length===0)return c.push({type:`text`,id:`tree-empty`,content:{text:e.title??`Empty tree`,style:{fontSize:o,fontFamily:L(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}),c;let l=e.title?o*2.2*100/r.height:0;return e.title&&c.push({type:`text`,id:`title`,content:{text:e.title,style:{fontSize:o,fontFamily:L(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:`${8+l/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),c.push({type:`tree`,id:`tree`,content:{items:a,style:{rowColor:n.colors.text,dirColor:i.accent??n.colors.primary,connectorColor:C(n.colors.text,.25),iconColor:i.accent??n.colors.primary,commentColor:n.colors.textMuted,fontSize:s,fontFamily:L(t,`body`),monoFontFamily:L(t,`mono`),indentPx:Math.round(s*1.4)}},position:{x:`10%`,y:`${8+l}%`,width:`80%`,height:`${Math.max(60,90-l)}%`},animation:{type:`fadeIn`,duration:1,delay:e.title?.4:0}}),c}var Lo=e=>Math.max(0,Math.min(1,e)),Ro=(e,t,n)=>Math.max(t,Math.min(n,e));function zo(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)||`item`}function Bo(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e!=`object`||!e)return;let r=e,i=typeof r.id==`string`&&r.id.trim()?r.id.trim():`track-${n+1}`,a=[];Array.isArray(r.events)&&r.events.forEach((e,t)=>{if(typeof e!=`object`||!e)return;let n=e;if(typeof n.label!=`string`)return;let r=typeof n.position==`number`?n.position:Number(n.position);if(!Number.isFinite(r))return;let o=typeof n.id==`string`&&n.id.trim()?n.id.trim():`${i}-event-${t+1}`,s=n.side===`above`||n.side===`below`?n.side:void 0,c=n.descriptionSide===`above`||n.descriptionSide===`below`?n.descriptionSide:void 0,l=n.marker===`filled`||n.marker===`hollow`||n.marker===`diamond`?n.marker:void 0;a.push({id:o,label:n.label,position:Lo(r),...typeof n.description==`string`&&n.description.trim()?{description:n.description.trim()}:{},...s?{side:s}:{},...c?{descriptionSide:c}:{},...n.callout===!1?{callout:!1}:{},...l?{marker:l}:{}})}),t.push({id:i,...typeof r.label==`string`&&r.label.trim()?{label:r.label.trim()}:{},...typeof r.endLabel==`string`&&r.endLabel.trim()?{endLabel:r.endLabel.trim()}:{},events:a})}),t}function Vo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r;typeof e.source!=`string`||typeof e.target!=`string`||!t.has(e.source)||!t.has(e.target)||e.source===e.target||n.push({source:e.source,target:e.target,...typeof e.label==`string`&&e.label.trim()?{label:e.label.trim()}:{}})}return n}function Ho(e,t,n,r,i,a){return{type:`path`,id:e,content:{d:`M ${t} ${n-r} L ${t+r} ${n} L ${t} ${n+r} L ${t-r} ${n} Z`,fill:i,stroke:i,strokeWidth:2},position:{x:t-r,y:n-r,width:r*2,height:r*2},animation:{type:`zoomIn`,duration:.35,delay:a}}}function Uo(e,t,n){if(Math.abs(e.y-t.y)<1){let r=(e.event.side??(e.eventIndex%2==0?`above`:`below`))===`above`?1:-1,i=e.y+r*n;return`M ${e.x} ${e.y} C ${e.x} ${i}, ${t.x} ${i}, ${t.x} ${t.y}`}let r=(e.y+t.y)/2;return`M ${e.x} ${e.y} C ${e.x} ${r}, ${t.x} ${r}, ${t.x} ${t.y}`}function Wo(e,t){let{theme:n,viewport:r}=t,i=I(t,e.colorScheme),a=Bo(e.tracks),o=[Li(`bg`,H(t,165))],s=R(44,t,!0),c=R(22,t,!1),l=R(24,t,!1),u=R(17,t,!1);if(e.title&&o.push({type:`text`,id:`timeline-title`,content:{text:e.title,style:{fontSize:s,fontFamily:L(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:B(t)}},position:{x:`50%`,y:Math.max(50,s*1.2),width:`82%`,anchor:`center`},animation:{type:`fadeIn`,duration:.7}}),a.length===0)return o.push({type:`text`,id:`timeline-empty`,content:{text:e.title?`No timeline events`:`Empty timeline`,style:{fontSize:R(36,t,!0),fontFamily:L(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,width:`80%`,anchor:`center`}}),o;let d=a.some(e=>!!e.label),f=Math.max(48,r.width*.065),p=d?Math.min(280,r.width*.18):0,m=f+p,h=r.width-f,g=Math.max(1,h-m),_=e.title?Math.max(s*2.2,r.height*.2):r.height*.09,v=r.height*.91,y=Math.max(1,v-_)/a.length,b=Math.max(6,Math.min(11,Math.min(r.width,r.height)/105)),x=C(i.text??n.colors.primary,.72),S=i.accent??n.colors.primary,w=C(S,.78),T=C(n.colors.text,.48),E=Math.max(1,...a.map(e=>e.events.filter(e=>e.callout!==!1).length)),D=Math.max(Math.min(150,r.width*.2),Math.min(330,g/Math.min(E,4)*.86)),O=Math.min(r.width,r.height)/1080,k=Math.min(l,24*O),A=Math.min(u,17*O),ee=a.map(e=>{let t=e.events.map(e=>Lo(e.position)).sort((e,t)=>e-t),n=1/0;for(let e=1;e<t.length;e++)n=Math.min(n,(t[e]-t[e-1])*g);return Number.isFinite(n)?Math.min(b,Math.max(3,n*.32)):b}),te=[],ne=new Map;a.forEach((e,r)=>{let i=_+y*(r+.5),a=.12+r*.12,s=zo(e.id),l={type:`path`,id:`timeline-track-${s}-${r}`,content:{d:`M ${m} ${i} L ${h} ${i}`,stroke:x,strokeWidth:Math.max(2,b*.32),fill:`none`,endMarker:`arrow`},position:{x:m,y:i-b,width:g,height:b*2},animation:{type:`fadeIn`,duration:.65,delay:a}};if(o.push(l),e.label){let l={type:`text`,id:`timeline-track-label-${s}-${r}`,content:{text:e.label,style:{fontSize:c,fontFamily:L(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`right`}},position:{x:f+p/2-16,y:i,width:Math.max(1,p-32),anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:a}};o.push(l)}e.endLabel&&o.push({type:`text`,id:`timeline-track-end-label-${s}-${r}`,content:{text:e.endLabel,style:{fontSize:A,fontFamily:L(t,`body`),color:n.colors.textMuted,textAlign:`left`,maxLines:2}},position:{x:h+b*1.6,y:i-A*.7,width:Math.max(48,f-b*2),anchor:`top-left`},animation:{type:`fadeIn`,duration:.5,delay:a}}),e.events.forEach((e,t)=>{let n={event:e,trackIndex:r,eventIndex:t,x:m+g*Lo(e.position),y:i};te.push(n),ne.has(e.id)||ne.set(e.id,n)})}),Vo(e.links,new Set(ne.keys())).forEach((e,i)=>{let a=ne.get(e.source),s=ne.get(e.target);if(!a||!s)return;let c=Math.min(90,Math.max(42,y*.28));if(o.push({type:`path`,id:`timeline-link-${zo(e.source)}-${zo(e.target)}-${i}`,content:{d:Uo(a,s,c),stroke:w,strokeWidth:Math.max(2,b*.26),fill:`none`,endMarker:`arrow`},position:{x:0,y:0,width:`100%`,height:`100%`},animation:{type:`fadeIn`,duration:.6,delay:.45+i*.08}}),e.label){let l=a.trackIndex===s.trackIndex,u=Math.min(320,Math.max(150,e.label.length*A*.55+24)),d=Math.min(A*1.25*2+8,U(e.label,A,u,1.25)+8),f=(a.x+s.x)/2,p=(a.event.side??(a.eventIndex%2==0?`above`:`below`))===`above`?1:-1,m=l?a.y+p*(c+A*.6):(a.y+s.y)/2;if(!l){let e=s.x-a.x,t=s.y-a.y,n=Math.max(1,Math.hypot(e,t)),i=u*.56,o=f+-t/n*i,c=m+e/n*i,l=o>=u/2+8&&o<=r.width-u/2-8&&c>=A*1.5&&c<=r.height-12?1:-1;f+=l*(-t/n)*i,m+=e/n*l*i}f=Ro(f,u/2+8,r.width-u/2-8),m=Ro(m,A*1.5,r.height-12),o.push({type:`text`,id:`timeline-link-label-${i}`,content:{text:e.label,style:{fontSize:A,fontFamily:L(t,`body`),color:n.colors.textMuted,textAlign:`center`,background:n.colors.background,backgroundOpacity:.88,padding:4,maxLines:2,verticalAlign:`middle`}},position:{x:f,y:m,width:u,height:d,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:.55+i*.08}})}});let re=Math.min(78,Math.max(34,y*.2));for(let e of te){let{event:i,trackIndex:a,eventIndex:s,x:c,y:l}=e,u=i.side??(s%2==0?`above`:`below`),d=u===`above`?-1:1,f=l+d*re,p=.28+a*.12+s*.07,m=`${zo(i.id)}-${a}-${s}`,h=ee[a]??b,g=Ro(c,D/2+8,r.width-D/2-8),_=(e,t,n)=>{o.push({type:`path`,id:e,content:{d:`M ${c} ${l} L ${g} ${t}`,stroke:T,strokeWidth:Math.max(1,b*.18),fill:`none`},position:{x:Math.min(c,g),y:Math.min(l,t),width:Math.max(2,Math.abs(g-c)),height:Math.max(2,Math.abs(t-l))},animation:{type:`fadeIn`,duration:.4,delay:n}})};if(i.callout!==!1){_(`timeline-stem-${m}`,f,p);let e=i.descriptionSide??u;if(i.description&&e!==u){let t=e===`above`?-1:1;_(`timeline-description-stem-${m}`,l+t*re,p+.03)}}let v=i.marker??`filled`;if(v===`diamond`)o.push(Ho(`timeline-marker-${m}`,c,l,h,S,p));else{let e={type:`shape`,id:`timeline-marker-${m}`,content:{shape:`circle`,fill:v===`hollow`?n.colors.background:S,stroke:S,strokeWidth:Math.max(1.5,h*.28)},position:{x:c-h,y:l-h,width:h*2,height:h*2},animation:{type:`zoomIn`,duration:.35,delay:p}};o.push(e)}if(i.callout!==!1){let e=1.2,a=Math.min(U(i.label,k,D,e),k*e*2),s=Math.max(1,Math.round(a/(k*e))),c=Ro(d>0?f+k*.9:f-(s-1)*k*e-k*.9,k,r.height-(s-1)*k*e-12);if(o.push({type:`text`,id:`timeline-event-label-${m}`,content:{text:i.label,style:{fontSize:k,fontFamily:L(t,`body`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,lineHeight:e,shadow:B(t),maxLines:2}},position:{x:g,y:c,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.08}}),i.description){let a=i.descriptionSide??u,d=a===`above`?-1:1,f=1.25,h=t.orientation===`portrait`?6:4,_=Math.min(U(i.description,A,D,f),A*f*h),v=Math.max(1,Math.round(_/(A*f))),y=l+d*re,b;b=a===u?d>0?c+s*k*e+A*.45:c-v*A*f-A*.45:d>0?y+A*.9:y-(v-1)*A*f-A*.9,b=Ro(b,A,r.height-(v-1)*A*f-12),o.push({type:`text`,id:`timeline-event-description-${m}`,content:{text:i.description,style:{fontSize:A,fontFamily:L(t,`body`),color:n.colors.textMuted,textAlign:`center`,lineHeight:f,maxLines:h}},position:{x:g,y:b,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.14}})}}}return o}var Go=`rectangle.rect.square.circle.ellipse.oval.line.arrow.path.text.triangle.right-triangle.diamond.rhombus.pentagon.hexagon.octagon.star.star4.star6.parallelogram.trapezoid.plus.cross.chevron.arrow-right.arrow-left.arrow-up.arrow-down.double-arrow.callout.speech.cylinder.cloud.heart.lightning.bolt`.split(`.`),Ko={rectangle:`rect`,rect:`rect`,square:`rect`,circle:`circle`,ellipse:`circle`,oval:`circle`,line:`line`,arrow:`arrow`,path:`path`,text:`text`,label:`text`,triangle:`triangle`,"right-triangle":`right-triangle`,righttriangle:`right-triangle`,diamond:`diamond`,rhombus:`diamond`,pentagon:`pentagon`,hexagon:`hexagon`,octagon:`octagon`,star:`star`,star5:`star`,star4:`star4`,star6:`star6`,parallelogram:`parallelogram`,trapezoid:`trapezoid`,plus:`plus`,cross:`plus`,chevron:`chevron`,"arrow-right":`arrow-right`,arrowright:`arrow-right`,rightarrow:`arrow-right`,"arrow-left":`arrow-left`,arrowleft:`arrow-left`,leftarrow:`arrow-left`,"arrow-up":`arrow-up`,arrowup:`arrow-up`,uparrow:`arrow-up`,"arrow-down":`arrow-down`,arrowdown:`arrow-down`,downarrow:`arrow-down`,"double-arrow":`double-arrow`,doublearrow:`double-arrow`,callout:`callout`,speech:`callout`,bubble:`callout`,cylinder:`cylinder`,can:`cylinder`,cloud:`cloud`,heart:`heart`,lightning:`lightning`,bolt:`lightning`};function qo(e){return e?Ko[e.toLowerCase()]??null:null}function Jo(e){return qo(e)!=null}var Yo={gapX:180,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80},Xo={rect:{w:160,h:90},circle:{w:120,h:120},line:{w:160,h:0},arrow:{w:160,h:0},path:{w:160,h:120},text:{w:200,h:48}},Zo={w:120,h:120};function Qo(e){return Xo[e]??Zo}function $o(e,t={}){let n={...Yo,...t},r=[],i=[],a=[],o=[];for(let t of e){let e=qo(t.template),n=t.templateOverrides??{},s=t.title??``,c=cs(t);if(!e){r.push(`Child "${t.id}" is not a shape (annotation "${t.template??`—`}") and was skipped`);continue}let l=q(n,`from`),u=q(n,`to`);if((e===`line`||e===`arrow`)&&(l||u)){o.push({id:t.id,kind:e,from:l??``,to:u??``,...s?{label:s}:{},...ss(n,e),source:t.id});continue}for(let e of t.connectsTo??[])o.push({id:`${t.id}->${e.target}${e.type?`:${e.type}`:``}`,kind:`arrow`,from:t.id,to:e.target,...e.type?{label:e.type}:{},...ss(n,`arrow`),source:t.id});let d=Qo(e),f=es(n,`x`)??(typeof t.x==`number`?t.x:void 0),p=es(n,`y`)??(typeof t.y==`number`?t.y:void 0),m={id:t.id,kind:e,x:f??0,y:p??0,width:es(n,`width`)??es(n,`w`)??d.w,height:es(n,`height`)??es(n,`h`)??d.h,pinned:f!=null&&p!=null,label:s,...c?{sublabel:c}:{},...ns(n)};if(e===`path`){let e=q(n,`d`);e&&(m.d=e)}e===`text`&&(m.text=q(n,`text`)??s??c??``),es(n,`borderRadius`)!=null&&(m.borderRadius=es(n,`borderRadius`)),i.push({shape:m,hasX:f!=null,hasY:p!=null}),(f==null||p==null)&&a.push(i.length-1)}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=Math.max(...a.map(e=>i[e].shape.width)),r=Math.max(...a.map(e=>i[e].shape.height)),o=Math.max(n.gapX,t+60),s=Math.max(n.gapY,r+50),c=n.gridOriginX,l=n.gridOriginY,u=i.filter(e=>e.shape.pinned);u.length>0&&(c=Math.min(...u.map(e=>e.shape.x)),l=Math.max(...u.map(e=>e.shape.y+e.shape.height))+n.gridPad),a.forEach((t,n)=>{let r=n%e,a=Math.floor(n/e);i[t].shape.x=c+r*o,i[t].shape.y=l+a*s})}let s=i.map(e=>e.shape),c=new Set(s.map(e=>e.id)),l=[],u=new Set;for(let e of o){if(!c.has(e.from)||!c.has(e.to)){let t=c.has(e.from)?e.to:e.from;r.push(`Connector "${e.source}" dropped: ${t?`no shape with id "${t}"`:`missing from/to`}`);continue}let t=`${e.kind}:${e.from}->${e.to}:${e.label??``}`;if(u.has(t))continue;u.add(t);let{source:n,...i}=e;l.push(i)}return{shapes:s,connectors:l,warnings:r}}function q(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function es(e,t){let n=q(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function ts(e){let t={},n=q(e,`stroke`),r=es(e,`strokeWidth`),i=q(e,`dasharray`);return n&&(t.stroke=n),r!=null&&(t.strokeWidth=r),i&&(t.dasharray=i),t}function ns(e){let t=q(e,`fill`);return{...ts(e),...t?{fill:t}:{}}}var rs={none:`none`,arrow:`arrow`,triangle:`arrow`,filled:`arrow`,open:`open`,v:`open`,diamond:`diamond`,circle:`circle`,dot:`circle`,square:`square`,box:`square`},is={straight:`straight`,direct:`straight`,orthogonal:`orthogonal`,elbow:`orthogonal`,step:`orthogonal`,curved:`curved`,curve:`curved`,bezier:`curved`};function as(e){return e?rs[e.toLowerCase()]:void 0}function os(e){return e?is[e.toLowerCase()]:void 0}function ss(e,t){let n=ts(e),r=n.dasharray??Be(q(e,`lineStyle`));return{...n,...r?{dasharray:r}:{},startMarker:as(q(e,`startStyle`))??`none`,endMarker:as(q(e,`endStyle`))??(t===`arrow`?`arrow`:`none`),routing:os(q(e,`routing`))??`straight`}}function cs(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(` `).trim()}var ls=80;function us(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=I(t,e.colorScheme),o=e.stroke??a.text??n.colors.text,s=e.fill??`none`,c=$o(i);if(c.shapes.length===0&&c.connectors.length===0)return[ms(e,t)];let l=Math.min(...c.shapes.map(e=>e.x)),u=Math.max(...c.shapes.map(e=>e.x+e.width)),d=Math.min(...c.shapes.map(e=>e.y)),f=Math.max(...c.shapes.map(e=>e.y+e.height)),p=e.title?120:0,m=Math.max(1,r.width-ls*2),h=Math.max(1,r.height-ls*2-p),g=Math.max(1,u-l),_=Math.max(1,f-d),v=Math.min(m/g,h/_,1.8),y=g*v,b=_*v,x=Math.max(ls/2,(r.height-p-b)/2),S=ls+(m-y)/2,C=x+p,w=e=>S+(e-l)*v,T=e=>C+(e-d)*v,E=Math.min(Math.max(v,1),1.5),D=[];e.title&&D.push({type:`text`,id:`drawing-title`,content:{text:e.title,style:{fontSize:R(40,t,!0),fontFamily:L(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`}},position:{x:`50%`,y:x+p/2-16,anchor:`center`}});let O=new Map;for(let e of c.shapes){let t=w(e.x),n=T(e.y),r=e.width*v,i=e.height*v;O.set(e.id,{cx:t+r/2,cy:n+i/2,rx:Math.max(1,r/2),ry:Math.max(1,i/2)})}for(let e of c.connectors){let n=O.get(e.from),r=O.get(e.to);if(!n||!r)continue;let{start:i,end:a}=Pe(n,r),s={type:`path`,id:`connector-${e.id}`,content:{d:Le(e.routing,i,a),stroke:e.stroke??o,strokeWidth:e.strokeWidth??Math.round(2*E),fill:`none`,...e.dasharray?{dasharray:e.dasharray}:{},...e.startMarker===`none`?{}:{startMarker:e.startMarker},...e.endMarker===`none`?{}:{endMarker:e.endMarker}},position:{x:0,y:0,width:`100%`,height:`100%`}};D.push(s),e.label&&D.push(ps(e,n,r,t,E))}for(let e of c.shapes){let n=w(e.x),r=T(e.y),i=e.width*v,a=e.height*v;D.push(...ds(e,n,r,i,a,t,o,s,E))}return D}function ds(e,t,n,r,i,a,o,s,c){let l=[],u=e.stroke??o,d=e.fill??s;if(e.kind===`text`)return l.push(fs(`shape-${e.id}`,e.text??e.label??``,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),l;if(e.kind===`rect`||e.kind===`circle`){let a={type:`shape`,id:`shape-${e.id}`,content:{shape:e.kind,fill:d,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),...e.kind===`rect`&&e.borderRadius!=null?{borderRadius:e.borderRadius}:{}},position:{x:t,y:n,width:r,height:i}};l.push(a)}else{let a=`M ${hs(t)} ${hs(n)} L ${hs(t+r)} ${hs(n+i)}`,o=a,s=`none`,f=`none`;e.kind===`path`?(o=e.d??a,s=d):e.kind===`arrow`?f=`arrow`:e.kind!==`line`&&(o=Ee(e.kind,t,n,r,i)??a,s=d);let p={type:`path`,id:`shape-${e.id}`,content:{d:o,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),fill:s,...e.dasharray?{dasharray:e.dasharray}:{},...f===`none`?{}:{endMarker:f}},position:{x:0,y:0,width:`100%`,height:`100%`}};l.push(p)}return e.label&&l.push(fs(`shape-label-${e.id}`,e.label,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),e.sublabel&&l.push(fs(`shape-sublabel-${e.id}`,e.sublabel,t+r/2,n+i+14*c,r,a,a.theme.colors.textMuted,!1,c)),l}function fs(e,t,n,r,i,a,o,s,c){return{type:`text`,id:e,content:{text:t,style:{fontSize:R(Math.round((s?22:18)*c),a,!1),fontFamily:L(a,`body`),...s?{fontWeight:`bold`}:{},color:o,textAlign:`center`}},position:{x:n,y:r,anchor:`center`,width:i}}}function ps(e,t,n,r,i){let a=R(Math.round(18*i),r,!1);return{type:`text`,id:`connector-label-${e.id}`,content:{text:e.label??``,style:{fontSize:a,fontFamily:L(r,`body`),color:r.theme.colors.textMuted,textAlign:`center`}},position:{x:(t.cx+n.cx)/2,y:(t.cy+n.cy)/2-a*.9,anchor:`center`}}}function ms(e,t){return{type:`text`,id:`drawing-empty`,content:{text:e.title??`Empty drawing`,style:{fontSize:R(36,t,!0),fontFamily:L(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}function hs(e){return Math.round(e*100)/100}var gs=`#1e293b`,_s={w:300,h:80},vs={w:160,h:90},ys={w:320,h:240};function bs(e,t,n={}){let r=n.ink??gs,i=[],a=[];for(let t of e){let e=t.templateOverrides??{},n=(t.template??``).toLowerCase(),o=Y(e,`x`)??0,s=Y(e,`y`)??0;if(n===`image`||n===`img`){let n=J(e,`src`);if(!n){a.push(`Layout image "${t.id}" has no src= and was skipped`);continue}let r={id:t.id,type:`image`,position:{x:o,y:s,width:Y(e,`width`)??ys.w,height:Y(e,`height`)??ys.h},content:{src:n,alt:J(e,`alt`)??``,...J(e,`fit`)?{fit:J(e,`fit`)}:{}}};i.push(r);continue}let c=qo(t.template);if(!c){a.push(`Layout child "${t.id}" is not a layer (annotation "${t.template??`—`}") and was skipped`);continue}if(c===`text`){let n=Ss(t)||t.title||``,a={id:t.id,type:`text`,position:{x:o,y:s,width:Y(e,`width`)??_s.w,height:Y(e,`height`)??_s.h},content:{text:n,style:xs(e,r)}};i.push(a);continue}let l=Y(e,`width`)??Y(e,`w`)??vs.w,u=Y(e,`height`)??Y(e,`h`)??vs.h;if(c===`rect`||c===`circle`){let n={id:t.id,type:`shape`,position:{x:o,y:s,width:l,height:u},content:{shape:c,...J(e,`fill`)?{fill:J(e,`fill`)}:{},...J(e,`stroke`)?{stroke:J(e,`stroke`)}:{},...Y(e,`strokeWidth`)==null?{}:{strokeWidth:Y(e,`strokeWidth`)},...J(e,`borderStyle`)?{borderStyle:J(e,`borderStyle`)}:{},...c===`rect`&&Y(e,`borderRadius`)!=null?{borderRadius:Y(e,`borderRadius`)}:{}}};i.push(n);continue}let d=`M ${Cs(o)} ${Cs(s)} L ${Cs(o+l)} ${Cs(s+u)}`,f=d,p=`none`,m=`none`;c===`path`?(f=J(e,`d`)??d,p=J(e,`fill`)??`none`):c===`arrow`?m=`arrow`:c!==`line`&&(f=Ee(c,o,s,l,u)??d,p=J(e,`fill`)??`none`);let h={id:t.id,type:`path`,position:{x:0,y:0,width:`100%`,height:`100%`},content:{d:f,stroke:J(e,`stroke`)??r,strokeWidth:Y(e,`strokeWidth`)??2,fill:p,...J(e,`dasharray`)?{dasharray:J(e,`dasharray`)}:{},...m===`none`?{}:{endMarker:m}}};i.push(h)}return{layers:i,warnings:a}}function xs(e,t){let n={fontSize:Y(e,`fontSize`)??32,color:J(e,`color`)??t},r=J(e,`fontFamily`);r&&(n.fontFamily=r);let i=J(e,`fontWeight`);(i===`bold`||i===`normal`)&&(n.fontWeight=i);let a=J(e,`fontStyle`);(a===`italic`||a===`normal`)&&(n.fontStyle=a);let o=J(e,`align`);(o===`left`||o===`center`||o===`right`)&&(n.textAlign=o);let s=J(e,`valign`);(s===`top`||s===`middle`||s===`bottom`)&&(n.verticalAlign=s);let c=Y(e,`lineHeight`);c!=null&&(n.lineHeight=c);let l=Y(e,`padding`);l!=null&&(n.padding=l);let u=J(e,`background`);return u&&(n.background=u),n}function J(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function Y(e,t){let n=J(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Ss(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(`
|
|
23
|
+
`).trim()}function Cs(e){return Math.round(e*100)/100}function ws(e,t){let{theme:n,viewport:r,children:i=[]}=t,{layers:a}=bs(i,r,{ink:n.colors.text});return a.length>0?a:[Ts(e,t)]}function Ts(e,t){return{type:`text`,id:`layout-empty`,content:{text:e.title??`Empty layout`,style:{fontSize:m(36,t,!0),fontFamily:L(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}var Es=/\{(\w+)(?::([^}|]+))?(?:\|([^}]*))?\}/g,Ds=/\{\{([^{}]*)\}\}/g,Os=` ESC_OPEN `,ks=` ESC_CLOSE `;function As(e){if(!e.contents)return[];let t=[],n=e=>{if(e.type===`image`){let n=e;t.push({url:n.url??``,alt:n.alt??``})}};for(let t of e.contents)i(t,e=>{n(e)});return t}function js(e){if(!e.contents)return[];let t=[];for(let n of e.contents)i(n,e=>{if(e.type===`listItem`){let n=o(e).replace(/\s+/g,` `).trim();return n&&t.push(n),!0}});return t}function Ms(e){return e.contents?e.contents.map(e=>o(e).trim()).filter(e=>e.length>0).join(` `):``}function Ns(e){return!e.children||e.children.length===0?``:e.children.map(e=>e.title?.trim()).filter(e=>!!e).join(`, `)}function Ps(e){return e.replace(Ds,(e,t)=>Os+t+ks)}function Fs(e){return e.replace(new RegExp(Os,`g`),`{`).replace(new RegExp(ks,`g`),`}`)}function Is(e,t){return Fs(Ps(e).replace(Es,(e,n,r,i)=>{let a=t(n,r);return a==null?e:a===``&&i!==void 0?i:a}))}function Ls(e,t,n,r,i){switch(e){case`title`:return n.title??``;case`content`:return Ms(n);case`children`:return Ns(n);case`attr`:{if(!t)return``;let e=n.templateOverrides?.[t]??n.templateData?.[t]??n.metadata?.[t];return e==null?``:String(e)}case`image`:{let e=t?parseInt(t,10):0;return!Number.isFinite(e)||e<0||e>=r.length?``:r[e].alt}case`item`:return i?t?t===`src`?i.src??``:t===`label`?i.label??``:``:i.text:null;case`index`:return i?String(i.index):null;default:return null}}function Rs(e,t,n,r){return Is(e,(e,i)=>Ls(e,i,t,n,r))}function zs(e,t,n,r){if(!e.includes(`{`))return e;let i=!1,a=Ps(e).replace(Es,(e,a,o,s)=>{if(a===`image`){let e=o?parseInt(o,10):0;return Number.isFinite(e)&&e>=0&&e<n.length?n[e].url:s===void 0?(i=!0,``):s}let c=Ls(a,o,t,n,r);return c==null?e:c===``&&s!==void 0?s:c});return i?null:Fs(a)}function Bs(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.match(/-?\d*\.?\d+/);if(t)return parseFloat(t[0])}return 0}function Vs(e,t){if(e==null)return t;if(typeof e==`number`)return e+t;let n=e.match(/^(\s*)(-?\d*\.?\d+)(.*)$/);if(n){let e=parseFloat(n[2])+t;return`${n[1]}${e}${n[3]}`}return e}function Hs(e,t,n){switch(e){case`images`:return n.map((e,t)=>({text:e.alt,src:e.url,label:e.alt,index:t+1}));case`children`:return(t.children??[]).map((e,t)=>({text:e.title??``,label:e.title??``,index:t+1}));case`listItems`:return js(t).map((e,t)=>({text:e,label:e,index:t+1}));default:return[]}}function Us(e,t,n){let r=e.repeat;if(!r){let r=Gs(e,t,n,void 0);return r?[r]:[]}let i=Hs(r.source,t,n),a=r.direction??`column`,o=r.gap??24,s=r.max!=null&&r.max>=0?Math.min(r.max,i.length):i.length,c=[],l=0;for(let r=0;r<s;r++){let s={...e.position};a===`row`?s.x=Vs(s.x,l):s.y=Vs(s.y,l);let u={...e,position:s,id:`${e.id}-${r}`};delete u.repeat;let d=Gs(u,t,n,i[r]);d&&c.push(d);let f=a===`row`?e.position.width:e.position.height;l+=Bs(f)+o}return c}function Ws(e,t){let n=As(t),r=[];for(let i of e)if(i.repeat)r.push(...Us(i,t,n));else{let e=Gs(i,t,n,void 0);e&&r.push(e)}return r}function Gs(e,t,n,r){switch(e.type){case`text`:return{...e,content:{...e.content,text:Rs(e.content.text,t,n,r)}};case`image`:{let i=zs(e.content.src,t,n,r);if(i==null)return null;let a={...e,content:{...e.content,src:i}};return e.content.alt&&e.content.alt.includes(`{`)&&(a.content.alt=Rs(e.content.alt,t,n,r)),a}default:return e}}function Ks(e){return(t,n)=>{let r=n.block??t;return r?Ws(e.layers,r):e.layers.slice()}}var qs=.6;function Js(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=!1,r=/^\((.*)\)$/.exec(t);if(r&&(n=!0,t=r[1].trim()),t=t.replace(/^([+-]?)\s*[$€£¥]\s*/,`$1`),t=t.replace(/%$/,``).trim(),t=t.replace(/,/g,``),/^[+-]?\d{1,3}(?: \d{3})+(?:\.\d+)?$/.test(t)&&(t=t.replace(/ /g,``)),!/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(t))return null;let i=Number(t);return Number.isFinite(i)?n?-i:i:null}function Ys(e,t){let n=0,r=0;for(let i of e){let e=(i[t]??``).trim();e&&(n+=1,Js(e)!==null&&(r+=1))}return r>0&&r/Math.max(1,n)>=qs}function Xs(e,t){let n=String(e).trim();if(!n)return null;let r=n.toLowerCase(),i=t.findIndex(e=>e.trim().toLowerCase()===r);if(i>=0)return i;if(/^\d+$/.test(n)){let e=Number(n);if(e<t.length)return e}return null}function Zs(e,t={}){let n=Array.isArray(e.headers)?e.headers:[],r=Array.isArray(e.rows)?e.rows:[];if(n.length===0||r.length===0)return null;let i=[],a=0;if(t.labelColumn!==void 0&&String(t.labelColumn).trim()!==``){let e=Xs(String(t.labelColumn),n);e===null?i.push(`labelColumn "${t.labelColumn}" matches no column; using the first column`):a=e}let o=[],s=(t.valueColumns??[]).map(e=>String(e)).filter(e=>e.trim()!==``);if(s.length>0)for(let e of s){let t=Xs(e,n);t===null?i.push(`valueColumns entry "${e}" matches no column; skipped`):o.includes(t)||o.push(t)}else o=n.map((e,t)=>t).filter(e=>e!==a&&Ys(r,e));return o.length===0?null:{labels:r.map(e=>(e[a]??``).trim()),labelHeader:n[a]??``,labelNumbers:r.map(e=>Js(e[a]??``)),series:o.map(e=>({name:(n[e]??`Column ${e+1}`).trim()||`Column ${e+1}`,values:r.map(t=>Js(t[e]??``))})),warnings:i}}function Qs(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function $s(e,t,n=5){let r=Number.isFinite(e)?e:0,i=Number.isFinite(t)?t:0;if(r>i&&([r,i]=[i,r]),r===i){let t=r===0?1:Qs(Math.abs(r),!0);r-=t,i+=t,e>=0&&r<0&&(r=0)}let a=Math.max(2,n),o=Qs(Qs(i-r,!1)/(a-1),!0),s=Math.floor(r/o)*o,c=Math.ceil(i/o)*o,l=[];for(let e=s;e<=c+o*1e-6;e+=o)l.push(Math.abs(e)<o*1e-6?0:Number(e.toPrecision(12)));return{ticks:l,niceMin:s,niceMax:c,step:o}}function ec(e,t){if(!Number.isFinite(e))return`—`;let n=e<0?`-`:``,r=Math.abs(e),i;return i=r>=1e6?`${n}${tc((r/1e6).toFixed(1))}M`:r>=1e3?`${n}${tc((r/1e3).toFixed(r>=1e4?0:1))}K`:`${n}${r.toLocaleString(`en-US`,{maximumFractionDigits:2})}`,t?`${i} ${t}`:i}function tc(e){return e.replace(/\.0$/,``)}function X(e){return Math.round(e*100)/100}function nc(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:X(e+n*Math.cos(i)),y:X(t+n*Math.sin(i))}}function rc(e,t,n,r,i,a){let o=a-i;if(o<=0)return``;o>=359.9&&(o=359.9);let s=i+o,c=+(o>180),l=nc(e,t,n,i),u=nc(e,t,n,s);if(r<=0)return[`M ${X(e)} ${X(t)}`,`L ${l.x} ${l.y}`,`A ${X(n)} ${X(n)} 0 ${c} 1 ${u.x} ${u.y}`,`Z`].join(` `);let d=nc(e,t,r,i),f=nc(e,t,r,s);return[`M ${l.x} ${l.y}`,`A ${X(n)} ${X(n)} 0 ${c} 1 ${u.x} ${u.y}`,`L ${f.x} ${f.y}`,`A ${X(r)} ${X(r)} 0 ${c} 0 ${d.x} ${d.y}`,`Z`].join(` `)}function ic(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`} ${X(e.x)} ${X(e.y)}`).join(` `)}function ac(e,t){if(e.length===0)return``;let n=ic(e),r=e[0],i=e[e.length-1];return`${n} L ${X(i.x)} ${X(t)} L ${X(r.x)} ${X(t)} Z`}function oc(e){let t=e.viewportWidth,n=e.viewportHeight,r=t*.06,i=n*.06,a=t-r*2,o=i,s;e.hasTitle&&(s={x:r,y:o,width:a,height:e.titleFontSize*2.2},o=s.y+s.height);let c,l=0;e.tableRowCount>0&&(l=Math.min(n*.4,(e.tableRowCount+1)*e.tableFontSize*2.4));let u=e.legendRows>0?e.legendRows*e.legendRowHeight:0,d={x:r,y:o,width:a,height:Math.max(40,n-i-o-u-l)};o=d.y+d.height;let f;u>0&&(f={x:r,y:o,width:a,height:u},o+=u),l>0&&(c={x:r,y:o,width:a,height:l});let p={x:d.x+e.leftGutter,y:d.y,width:Math.max(20,d.width-e.leftGutter),height:Math.max(20,d.height-e.bottomGutter)};return{titleBand:s,chartArea:d,plot:p,legendBand:f,tableBand:c}}function sc(e){let t=e.reduce((e,t)=>Math.max(e,t.values.length),0),n=Array(t).fill(0),r=Array(t).fill(0);return e.map(e=>Array.from({length:t},(t,i)=>{let a=e.values[i];if(a==null||!Number.isFinite(a))return{y0:n[i],y1:n[i]};if(a>=0){let e=n[i];return n[i]+=a,{y0:e,y1:n[i]}}let o=r[i];return r[i]+=a,{y0:r[i],y1:o}}))}function cc(e,t,n){let r=t*.9,i=t*1.6,a=t*2,o=e.map(e=>r+t*.5+e.length*t*.58),s=[],c=[],l=0;o.forEach((e,t)=>{let r=c.length>0?i:0;c.length>0&&l+r+e>n&&(s.push(c),c=[],l=0),c.push(t),l+=(c.length>1?i:0)+e}),c.length>0&&s.push(c);let u=[];return s.forEach((t,s)=>{let c=t.reduce((e,t,n)=>e+o[t]+(n>0?i:0),0),l=Math.max(0,(n-c)/2);t.forEach(t=>{u.push({label:e[t],index:t,x:l,y:s*a,swatchSize:r}),l+=o[t]+i})}),{items:u,rows:s.length,rowHeight:a}}function lc(e,t,n){if(e<=1)return 1;let r=n*6,i=t/e;return Math.max(1,Math.ceil(r/Math.max(1,i)))}var uc={bar:`barChart`,column:`columnChart`,pie:`pieChart`,donut:`donutChart`,line:`lineChart`,area:`areaChart`,scatter:`scatterChart`};function dc(e,t,n){let r=fc(t,n),i=r?Zs(r,t):null;if(!r||!i)return pc(t,n);let{theme:a,viewport:o}=n,s=uc[e],c=(t.title??``).trim(),l=R(44,n,!0),u=R(20,n,!1),d=R(22,n,!1),f=R(22,n,!1),p=R(20,n,!1),m=L(n,`body`),h=e===`pie`||e===`donut`,g=mc(e,t,i),_=hc(n,t.colorScheme,h?i.labels.length:i.series.length);if(h&&!i.series[0].values.some(e=>e!==null&&e>0))return pc(t,n);let v=o.width*.88,y=g.length>0?cc(g,f,v):null,b=gc(e,i,t,n,u,d),x=oc({viewportWidth:o.width,viewportHeight:o.height,hasTitle:c.length>0,titleFontSize:l,leftGutter:b.left,bottomGutter:b.bottom,legendRows:y?.rows??0,legendRowHeight:f*2,tableRowCount:t.showTable===!0?r.rows.length:0,tableFontSize:p}),S=Pi(n,s,`entrance`,`staggered`),w={kind:e,input:t,context:n,data:i,frame:x,colors:_,axisFontSize:u,labelFontSize:d,bodyFont:m,gridColor:C(a.colors.text,.12),axisTextColor:a.colors.textMuted,entrance:e=>({type:`fadeIn`,duration:.6,delay:S===`subtle`?.1:Math.min(1.2,.2+e*.08)})},T=[Li(`bg`,H(n,170))];switch(c&&x.titleBand&&T.push({type:`text`,id:`title`,content:{text:c,style:{fontSize:l,fontFamily:L(n,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:B(n)}},position:{x:x.titleBand.x+x.titleBand.width/2,y:x.titleBand.y+x.titleBand.height/2,width:x.titleBand.width,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),e){case`bar`:T.push(...xc(w));break;case`column`:T.push(...bc(w));break;case`pie`:case`donut`:T.push(...Sc(w));break;case`line`:case`area`:T.push(...Cc(w));break;case`scatter`:T.push(...wc(w));break}return y&&x.legendBand&&T.push(...Tc(w,y,x.legendBand,f)),t.showTable===!0&&x.tableBand&&T.push(Dc(r,x.tableBand,p,t,n)),T}function fc(e,t){return Array.isArray(e.headers)&&e.headers.length>0&&Array.isArray(e.rows)&&e.rows.length>0?{headers:e.headers,rows:e.rows}:to(e.contents??t.block?.contents)}function pc(e,t){return ua({...e,template:`content`,title:e.title??t.block?.title??``},t)}function mc(e,t,n){return t.showLegend===!1?[]:e===`pie`||e===`donut`?n.labels:n.series.length>1||t.showLegend===!0?n.series.map(e=>e.name):[]}function hc(e,t,n){let r=e.theme.colorSchemes,i=Object.keys(r),a=[I(e,t).accent],o=t&&i.includes(t)?i.indexOf(t):0;for(let e=1;e<i.length&&a.length<n;e++){let t=r[i[(o+e)%i.length]].accent;a.some(e=>e.toLowerCase()===t.toLowerCase())||a.push(t)}let s=a.length;for(let e=0;a.length<n;e++)a.push(C(a[e%s],.55));return a.slice(0,Math.max(1,n))}function gc(e,t,n,r,i,a){if(e===`pie`||e===`donut`)return{left:0,bottom:0};if(e===`bar`){let e=t.labels.reduce((e,t)=>Math.max(e,t.length),0);return{left:Math.min(r.viewport.width*.24,Math.max(a*3,e*a*.58+16)),bottom:i*2.4}}let o=_c(e,t,n).ticks.reduce((e,t)=>Math.max(e,ec(t,n.unit).length),0);return{left:Math.max(i*2.5,o*i*.6+16),bottom:a*2.6}}function _c(e,t,n){let r;r=(e===`bar`||e===`column`)&&n.stacked===!0?sc(t.series).flat().flatMap(e=>[e.y0,e.y1]):t.series.flatMap(e=>e.values.filter(e=>e!==null)),r.length===0&&(r=[0,1]);let i=Math.min(...r),a=Math.max(...r);return e!==`line`&&e!==`scatter`&&(i=Math.min(0,i),a=Math.max(0,a)),$s(i,a,5)}function vc(e,t,n){let{frame:r,gridColor:i,axisTextColor:a,axisFontSize:o,bodyFont:s,input:c}=e,l=[];return t.ticks.forEach((t,u)=>{let d=n(t);l.push({type:`shape`,id:`grid-${u}`,content:{shape:`rect`,fill:t===0?C(e.context.theme.colors.text,.35):i},position:{x:r.plot.x,y:d-(t===0?1:.5),width:r.plot.width,height:t===0?2:1}}),l.push({type:`text`,id:`tick-${u}`,content:{text:ec(t,c.unit),style:{fontSize:o,fontFamily:s,color:a,textAlign:`center`}},position:{x:r.chartArea.x+(r.plot.x-r.chartArea.x)/2,y:d,anchor:`center`}})}),l}function yc(e,t){let{frame:n,data:r,labelFontSize:i,axisTextColor:a,bodyFont:o}=e,s=lc(r.labels.length,n.plot.width,i),c=[];return r.labels.forEach((e,r)=>{r%s!==0||!e||c.push({type:`text`,id:`cat-${r}`,content:{text:e,style:{fontSize:i,fontFamily:o,color:a,textAlign:`center`}},position:{x:t(r),y:n.plot.y+n.plot.height+i*1.2,anchor:`center`}})}),c}function bc(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=_c(`column`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=vc(e,o,s),l=n.labels.length,u=t.plot.width/Math.max(1,l),d=u*.15;c.push(...yc(e,e=>t.plot.x+(e+.5)*u));let f=i.stacked===!0&&n.series.length>1,p=f?sc(n.series):null,m=u-d*2,h=f?m:Math.max(2,(m-4*(n.series.length-1))/n.series.length);return n.series.forEach((n,o)=>{n.values.forEach((n,m)=>{if(m>=l)return;let g=p?p[o][m]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!g||g.y0===g.y1)return;let _=s(g.y1),v=Math.max(1,s(g.y0)-_),y=f?t.plot.x+m*u+d:t.plot.x+m*u+d+o*(h+4);c.push({type:`shape`,id:`mark-${o}-${m}`,content:{shape:`rect`,fill:r[o],borderRadius:f?0:3},position:{x:y,y:_,width:h,height:v},animation:a(m+o)}),i.showValues===!0&&n!==null&&!f&&c.push(Ec(e,`val-${o}-${m}`,n,y+h/2,n>=0?_-e.axisFontSize*.9:_+v+e.axisFontSize*.9))})}),c}function xc(e){let{frame:t,data:n,colors:r,input:i,entrance:a,labelFontSize:o,axisFontSize:s,bodyFont:c,axisTextColor:l,gridColor:u}=e,d=_c(`bar`,n,i),f=s*.6,p=e=>ec(e,i.unit).length*s*.58,m=i.showValues===!0&&i.stacked!==!0,h=m?n.series.flatMap(e=>e.values).filter(e=>e!==null).reduce((e,t)=>Math.max(e,p(t)),0)+f:0,g=Math.max(20,t.plot.width-h),_=e=>t.plot.x+g*((e-d.niceMin)/(d.niceMax-d.niceMin)),v=[];d.ticks.forEach((n,r)=>{let a=_(n);v.push({type:`shape`,id:`grid-${r}`,content:{shape:`rect`,fill:n===0?C(e.context.theme.colors.text,.35):u},position:{x:a-(n===0?1:.5),y:t.plot.y,width:n===0?2:1,height:t.plot.height}}),v.push({type:`text`,id:`tick-${r}`,content:{text:ec(n,i.unit),style:{fontSize:s,fontFamily:c,color:l,textAlign:`center`}},position:{x:a,y:t.plot.y+t.plot.height+s*1.2,anchor:`center`}})});let y=n.labels.length,b=t.plot.height/Math.max(1,y),x=b*.15,S=i.stacked===!0&&n.series.length>1,w=S?sc(n.series):null,T=b-x*2,E=S?T:Math.max(2,(T-4*(n.series.length-1))/n.series.length);return n.labels.forEach((e,n)=>{e&&v.push({type:`text`,id:`cat-${n}`,content:{text:e,style:{fontSize:o,fontFamily:c,color:l,textAlign:`center`}},position:{x:t.chartArea.x+(t.plot.x-t.chartArea.x)/2,y:t.plot.y+(n+.5)*b,anchor:`center`}})}),n.series.forEach((n,i)=>{n.values.forEach((n,o)=>{if(o>=y)return;let s=w?w[i][o]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!s||s.y0===s.y1)return;let c=_(s.y0),l=Math.max(1,_(s.y1)-c),u=S?t.plot.y+o*b+x:t.plot.y+o*b+x+i*(E+4);if(v.push({type:`shape`,id:`mark-${i}-${o}`,content:{shape:`rect`,fill:r[i],borderRadius:S?0:3},position:{x:c,y:u,width:l,height:E},animation:a(o+i)}),m&&n!==null){let t=p(n)/2,r=n>=0?c+l+f+t:c-f-t;v.push(Ec(e,`val-${i}-${o}`,n,r,u+E/2))}})}),v}function Sc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o,context:s}=e,c=r.labels.map((e,t)=>({label:e,value:r.series[0].values[t],index:t})).filter(e=>e.value!==null&&Number.isFinite(e.value)&&e.value>0),l=c.reduce((e,t)=>e+t.value,0),u=n.chartArea.x+n.chartArea.width/2,d=n.chartArea.y+n.chartArea.height/2,f=Math.min(n.chartArea.width,n.chartArea.height)*.42,p=t===`donut`?f*.55:0,m=[],h=0;return c.forEach((t,n)=>{let r=t.value/l*360;if(m.push({type:`path`,id:`mark-${t.index}`,content:{d:rc(u,d,f,p,h,h+r),fill:i[t.index%i.length],stroke:s.theme.colors.background,strokeWidth:2},position:{x:u-f,y:d-f,width:f*2,height:f*2},animation:o(n)}),a.showValues===!0&&r>=14){let a=(h+r/2-90)*Math.PI/180,s=p>0?(p+f)/2:f*.68,c=`${Math.round(t.value/l*100)}%`;m.push({type:`text`,id:`val-${t.index}`,content:{text:c,style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:S(i[t.index%i.length]),textAlign:`center`}},position:{x:u+s*Math.cos(a),y:d+s*Math.sin(a),anchor:`center`},animation:o(n)})}h+=r}),m}function Cc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o}=e,s=_c(t,r,a),c=e=>n.plot.y+n.plot.height*(1-(e-s.niceMin)/(s.niceMax-s.niceMin)),l=r.labels.length,u=n.plot.width/Math.max(1,l),d=e=>n.plot.x+(e+.5)*u,f=vc(e,s,c);f.push(...yc(e,d));let p=c(Math.max(s.niceMin,Math.min(s.niceMax,0))),m=l<=30;return r.series.forEach((r,s)=>{let u=[],h=[];r.values.forEach((e,t)=>{if(!(t>=l)){if(e===null){h.length>0&&u.push(h),h=[];return}h.push({x:d(t),y:c(e)})}}),h.length>0&&u.push(h),u.forEach((e,r)=>{t===`area`&&e.length>1&&f.push({type:`path`,id:`area-${s}-${r}`,content:{d:ac(e,p),fill:i[s],fillOpacity:.25,stroke:`none`,strokeWidth:0},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)}),e.length>1&&f.push({type:`path`,id:`line-${s}-${r}`,content:{d:ic(e),stroke:i[s],strokeWidth:4,fill:`none`},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)})}),m&&r.values.forEach((t,n)=>{n>=l||t===null||(f.push({type:`shape`,id:`pt-${s}-${n}`,content:{shape:`circle`,fill:i[s]},position:{x:d(n)-5,y:c(t)-5,width:10,height:10},animation:o(s)}),a.showValues===!0&&f.push(Ec(e,`val-${s}-${n}`,t,d(n),c(t)-e.axisFontSize)))})}),f}function wc(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=_c(`scatter`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=vc(e,o,s),l=n.labelNumbers.filter(e=>e!==null).length,u=n.labels.length>0&&l/n.labels.length>=.6,d;if(u){let r=n.labelNumbers.filter(e=>e!==null),i=$s(Math.min(...r),Math.max(...r),5),a=i.niceMax-i.niceMin;d=e=>{let r=n.labelNumbers[e];return r===null?null:t.plot.x+t.plot.width*((r-i.niceMin)/a)},i.ticks.forEach((n,r)=>{let o=t.plot.x+t.plot.width*((n-i.niceMin)/a);c.push({type:`shape`,id:`xgrid-${r}`,content:{shape:`rect`,fill:e.gridColor},position:{x:o-.5,y:t.plot.y,width:1,height:t.plot.height}}),c.push({type:`text`,id:`xtick-${r}`,content:{text:ec(n),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,color:e.axisTextColor,textAlign:`center`}},position:{x:o,y:t.plot.y+t.plot.height+e.axisFontSize*1.2,anchor:`center`}})})}else{let r=t.plot.width/Math.max(1,n.labels.length);d=e=>t.plot.x+(e+.5)*r,c.push(...yc(e,e=>t.plot.x+(e+.5)*r))}return n.series.forEach((e,t)=>{e.values.forEach((e,n)=>{if(e===null)return;let i=d(n);i!==null&&c.push({type:`shape`,id:`mark-${t}-${n}`,content:{shape:`circle`,fill:r[t],fillOpacity:.85},position:{x:i-7,y:s(e)-7,width:14,height:14},animation:a(Math.floor(n/3)+t)})})}),c}function Tc(e,t,n,r){let i=[];return t.items.forEach((a,o)=>{let s=e.colors[a.index%e.colors.length],c=n.y+a.y+t.rowHeight/2;i.push({type:`shape`,id:`legend-swatch-${o}`,content:{shape:`rect`,fill:s,borderRadius:3},position:{x:n.x+a.x,y:c-a.swatchSize/2,width:a.swatchSize,height:a.swatchSize}}),i.push({type:`text`,id:`legend-label-${o}`,content:{text:a.label,style:{fontSize:r,fontFamily:e.bodyFont,color:e.context.theme.colors.text}},position:{x:n.x+a.x+a.swatchSize+r*.5,y:c-r*.62}})}),i}function Ec(e,t,n,r,i){return{type:`text`,id:t,content:{text:ec(n,e.input.unit),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:e.context.theme.colors.text,textAlign:`center`}},position:{x:r,y:i,anchor:`center`}}}function Dc(e,t,n,r,i){let{theme:a}=i,o=I(i,r.colorScheme);return{type:`table`,id:`table`,content:{headers:e.headers,rows:e.rows,align:e.align,style:{headerBackground:o.accent,headerColor:S(o.accent),cellBackground:C(a.colors.text,.04),cellColor:a.colors.text,borderColor:C(a.colors.text,.15),fontSize:n,fontFamily:L(i,`body`),headerFontFamily:L(i,`title`),borderRadius:8}},position:{x:t.x,y:t.y,width:t.width,height:t.height},animation:{type:`fadeIn`,duration:1,delay:.4}}}function Oc(e,t){return dc(`bar`,e,t)}function kc(e,t){return dc(`column`,e,t)}function Ac(e,t){return dc(`pie`,e,t)}function jc(e,t){return dc(`donut`,e,t)}function Mc(e,t){return dc(`line`,e,t)}function Nc(e,t){return dc(`area`,e,t)}function Pc(e,t){return dc(`scatter`,e,t)}var Fc={title:Ri,sectionHeader:Qi,bigText:sa,content:ua,statHighlight:da,quote:fa,factCard:pa,twoColumn:ma,dateEvent:ga,imageWithCaption:_a,leftFeature:ya,rightFeature:ba,map:xa,fullBleedQuote:Sa,list:ho,photoGrid:go,definitionCard:vo,comparisonBar:yo,pullQuote:bo,videoWithCaption:xo,videoPullQuote:So,dataTable:Co,barChart:Oc,columnChart:kc,pieChart:Ac,donutChart:jc,lineChart:Mc,areaChart:Nc,scatterChart:Pc,diagram:No,tree:Io,timeline:Wo,layout:ws,drawing:us};function Ic(e){let t={...Fc};if(e)for(let n of e)t[n.name]||(t[n.name]=Ks(n));return t}var Lc=[{type:`slowZoom`,direction:`in`},{type:`slowZoom`,direction:`out`},{type:`slowZoom`,panDirection:`left`},{type:`slowZoom`,panDirection:`right`}],Rc=8;function zc(e){return e===0||e===`0`||e===`0%`}function Bc(e){if(e.type!==`image`&&e.type!==`video`)return!1;let{position:t}=e;if(!zc(t.x)||!zc(t.y)||t.width!==`100%`||t.height!==`100%`)return!1;let n=e.content.fit;return n===void 0||n===`cover`}function Vc(e){return e.renderStyle.ambientMotion===!0}function Hc(e,t,n){let r=n.style.animationSpeed??1,i=Vc(n);return r===1&&!i?e:e.map(e=>{let n=e.animation;return!n&&i&&Bc(e)&&(n={...new Se(be(`${t.id}:${e.id}`)).pickRequired(Lc),duration:Math.max(Rc,t.duration??0)}),!n||n.type===`none`||r!==1&&(n={...n,...n.duration==null?{}:{duration:n.duration*r},...n.delay==null?{}:{delay:n.delay*r}}),n===e.animation?e:{...e,animation:n}})}function Uc(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min(i[n]+1,a[n-1]+1,i[n-1]+r)}[i,a]=[a,i]}return i[r]}function Wc(e,t,n){let r=n?.maxDistance??2,i,a=1/0,o=e.toLowerCase();for(let e of t){let t=Uc(o,e.toLowerCase());t<a&&(a=t,i=e)}if(i&&(a<=r||a<=Math.ceil(e.length*.4)))return n?.map?n.map(i):i}var Gc=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`],Kc=[`bottom`,`top`,`center`],qc=[`terrain`,`satellite`,`road`,`toner`,`watercolor`],Jc=[`neutral`,`somber`,`celebratory`],Yc=`theme color-scheme name — e.g. 'blue', 'green'`;function Xc(e=[]){return[{key:`title`,description:`Optional title above the chart`},{key:`labelColumn`,description:`Category/label column`,valueHint:`header name or 0-based index`},{key:`valueColumns`,description:`Value columns to plot`,coerce:`stringList`,valueHint:`comma-separated header names or 0-based indexes`},{key:`showTable`,description:`Render the source table beneath the chart`,coerce:`boolean`},{key:`showLegend`,description:`Show a series legend`,coerce:`boolean`},{key:`showValues`,description:`Print numeric value labels on marks`,coerce:`boolean`},{key:`unit`,description:`Unit suffix for tick/value labels (e.g. "km")`},{key:`colorScheme`,description:`Color scheme seeding the series color rotation`,valueHint:Yc},{key:`headers`,description:`Header cells (normally derived from the table)`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},...e]}var Zc={key:`stacked`,description:`Stack series instead of grouping them side by side`,coerce:`boolean`},Qc=[{key:`imageTreatment`,description:`Per-block photographic grade override ('none' opts out)`,values:[`none`,`mono`,`duotone`,`warm`,`cool`]},{key:`useBottomLayer`,description:`Show the doc's bottom persistent layers`,coerce:`boolean`},{key:`useTopLayer`,description:`Show the doc's top persistent layers`,coerce:`boolean`}],$c={title:[{key:`title`,description:`Main title text`},{key:`subtitle`,description:`Subtitle or tagline`},{key:`backgroundColor`,description:`Background color`,valueHint:`CSS color`}],sectionHeader:[{key:`title`,description:`Section title`},{key:`colorScheme`,description:`Fallback background color scheme`,valueHint:Yc},{key:`imageSrc`,description:`Optional background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Gc}],bigText:[{key:`title`,description:`The display text (rendered uppercase)`},{key:`imageSrc`,description:`Optional full-bleed background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Gc}],content:[{key:`title`,description:`Heading shown above the complete body`}],statHighlight:[{key:`stat`,description:`The statistic (e.g. "89%", "2x")`},{key:`description`,description:`What the stat means`},{key:`detail`,description:`Additional detail or context`},{key:`colorScheme`,description:`Color scheme for the stat`,valueHint:Yc}],quote:[{key:`title`,description:`Optional heading above the quote`},{key:`quote`,description:`The quote text`},{key:`attribution`,description:`Attribution (author, source)`}],pullQuote:[{key:`text`,description:`Quote text`},{key:`attribution`,description:`Attribution`}],twoColumn:[{key:`left`,description:`Left column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`right`,description:`Right column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`header`,description:`Optional header above the columns`},{key:`leftColor`,description:`Left column color scheme`,valueHint:Yc},{key:`rightColor`,description:`Right column color scheme`,valueHint:Yc}],dateEvent:[{key:`date`,description:`The date (e.g. "July 14, 1974")`},{key:`description`,description:`What happened`},{key:`footer`,description:`Optional footer text`},{key:`mood`,description:`Emotional tone`,values:Jc}],imageWithCaption:[{key:`imageSrc`,description:`Path to the image file`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Kc},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Gc},{key:`isTitle`,description:`Style the caption as a title`,coerce:`boolean`},{key:`subtitle`,description:`Subtitle (only when isTitle)`},{key:`imageCredit`,description:`Photo credit / artist name`},{key:`imageLicense`,description:`License identifier`}],leftFeature:el(),rightFeature:el(),map:[{key:`center`,description:`Map center as "lat,lng"`,coerce:`latLng`,required:!0},{key:`zoom`,description:`Zoom level (4-16)`,coerce:`number`},{key:`mapStyle`,description:`Map tile style`,values:qc},{key:`title`,description:`Optional title overlay`},{key:`caption`,description:`Optional caption`}],photoGrid:[{key:`images`,description:`Comma-separated image paths`,coerce:`stringList`},{key:`caption`,description:`Optional caption below the grid`},{key:`ambientMotion`,description:`Slow zoom/pan on the largest image`,values:Gc}],comparisonBar:[{key:`leftLabel`,description:`Left bar label`,required:!0},{key:`leftValue`,description:`Left bar numeric value`,coerce:`number`,required:!0},{key:`rightLabel`,description:`Right bar label`,required:!0},{key:`rightValue`,description:`Right bar numeric value`,coerce:`number`,required:!0},{key:`unit`,description:`Unit label (e.g. "km")`},{key:`colorScheme`,description:`Color scheme`,valueHint:Yc}],dataTable:[{key:`title`,description:`Optional title above the table`},{key:`headers`,description:`Comma-separated header cells`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},{key:`align`,description:`Per-column alignment (supply via a data fence)`},{key:`colorScheme`,description:`Header color scheme`,valueHint:Yc}],barChart:Xc([Zc]),columnChart:Xc([Zc]),pieChart:Xc(),donutChart:Xc(),lineChart:Xc(),areaChart:Xc(),scatterChart:Xc(),tree:[{key:`title`,description:`Optional title above the tree`},{key:`colorScheme`,description:`Folder-row color scheme`,valueHint:Yc},{key:`items`,description:`Tree items (derived from the tree fence)`}],timeline:[{key:`title`,description:`Optional title above the timeline`},{key:`colorScheme`,description:`Track and marker color scheme`,valueHint:Yc},{key:`tracks`,description:`Timeline tracks and events (supply via template data)`},{key:`links`,description:`Branch links between event ids (supply via template data)`}],videoWithCaption:[{key:`videoSrc`,description:`Path to the video file`,required:!0},{key:`posterSrc`,description:`Poster frame path`},{key:`videoAlt`,description:`Alt text for accessibility`},{key:`clipStart`,description:`Clip start time (seconds)`,coerce:`number`},{key:`clipEnd`,description:`Clip end time (seconds)`,coerce:`number`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Kc},{key:`videoCredit`,description:`Video credit / artist name`},{key:`videoLicense`,description:`License identifier`}]};function el(){return[{key:`imageSrc`,description:`Path to the feature image`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`imageWidth`,description:`Explicit display width in px`,coerce:`number`},{key:`imageHeight`,description:`Explicit display height in px`,coerce:`number`},{key:`title`,description:`Heading text next to the image`},{key:`body`,description:`Body text below the title`}]}function tl(e){let t=$c[e];if(t)return[...t,...Qc]}function nl(e){return new Map(e.map(e=>[e.key,e]))}function rl(e,t){let n={},r=[],i=e?tl(j(e)):void 0,a=i?nl(i):void 0;for(let[e,i]of Object.entries(t)){let{value:t,warning:o}=il(a?.get(e)?.coerce??`string`,i);o?(r.push(`"${e}": ${o}`),n[e]=i):n[e]=t}return{input:n,warnings:r}}function il(e,t){switch(e){case`number`:{let e=ae(t);return e==null?{value:t,warning:`not a number (${JSON.stringify(t)})`}:{value:e}}case`boolean`:return al(t);case`latLng`:return ol(t);case`labeledPair`:return{value:sl(t)};case`stringList`:return{value:cl(t)};default:return{value:t}}}function al(e){let t=e.trim().toLowerCase();return t===`true`||t===``?{value:!0}:t===`false`?{value:!1}:{value:e,warning:`not a boolean (${JSON.stringify(e)}) \u2014 expected true or false`}}function ol(e){let t=e.split(`,`);if(t.length===2){let e=ae(t[0]),n=ae(t[1]);if(e!=null&&n!=null)return{value:{lat:e,lng:n}}}return{value:e,warning:`not a "lat,lng" pair (${JSON.stringify(e)})`}}function sl(e){let t=e.indexOf(`|`);if(t<0)return{label:e.trim()};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return r?{label:n,sublabel:r}:{label:n}}function cl(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function ll(e,t){let n=j(e),r=$c[n];if(!r)return[];let i=[],a=nl([...r,...Qc]),o=new Set([...a.keys(),...Object.keys(oe)]);for(let[e,r]of Object.entries(t)){let t=a.get(e);if(!t){if(o.has(e))continue;let t=Wc(e,o);i.push({kind:`unknown-input`,key:e,message:`Unknown input "${e}" for template "${n}"`+(t?`. Did you mean "${t}"?`:``),...t?{suggestion:t}:{}});continue}if(t.values){let n=r.trim();n!==``&&!t.values.includes(n)&&i.push({kind:`invalid-input-value`,key:e,message:`Invalid value ${JSON.stringify(r)} for "${e}" \u2014 expected one of: ${t.values.join(`, `)}`})}else if(t.coerce&&t.coerce!==`string`){let{warning:n}=il(t.coerce,r);n&&i.push({kind:`invalid-input-value`,key:e,message:`"${e}": ${n}`})}}for(let e of r)e.required&&t[e.key]==null&&i.push({kind:`missing-input`,key:e.key,message:`Missing required input "${e.key}" for template "${n}"`});return i}var ul=600;function dl(e,t,n){let r=I(t,`blue`),{layout:i}=t,a=e.title??e.id??``,o=fl(e),s=[{type:`shape`,id:`fallback-bg`,content:{shape:`rect`,fill:r.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}];return a&&s.push({type:`text`,id:`fallback-title`,content:{text:a,style:{fontSize:R(56,t,!0),fontFamily:L(t,`title`),fontWeight:`bold`,color:r.text,textAlign:`center`}},position:{x:`50%`,y:o?`28%`:`50%`,anchor:`center`,width:i.maxTextWidth}}),o&&s.push({type:`text`,id:`fallback-body`,content:{text:o,style:{fontSize:R(28,t),fontFamily:L(t,`body`),color:r.text,textAlign:`center`}},position:{x:`50%`,y:`55%`,anchor:`center`,width:i.maxTextWidth}}),s.push({type:`text`,id:`fallback-notice`,content:{text:`\u26A0 ${n}`,style:{fontSize:R(18,t),fontFamily:L(t,`body`),color:C(r.text,.6),textAlign:`center`}},position:{x:`50%`,y:`92%`,anchor:`center`,width:i.maxTextWidth}}),s}function fl(e){if(!e.contents||e.contents.length===0)return``;let t=e.contents.map(e=>o(e)).join(`
|
|
24
|
+
`).trim();return t.length<=ul?t:`${t.slice(0,ul).trimEnd()}\u2026`}var pl={landscape:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},square:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},portrait:{wide:`title-stack`,tall:`title-stack`,square:`title-stack`,multiple:`title-stack`}},ml={landscape:{wide:`split`,tall:`split`,square:`split`,multiple:`split`},square:{wide:`text-stack`,tall:`split`,square:`text-stack`,multiple:`text-stack`},portrait:{wide:`text-stack`,tall:`text-stack`,square:`text-stack`,multiple:`text-stack`}},hl={landscape:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},square:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},portrait:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`}},gl={title:{summary:`Text-only by default; supplemental media gets a title band plus a reserved field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:pl},sectionHeader:{summary:`Uses its authored background image when present; otherwise supplemental media receives a title composition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:pl},bigText:{summary:`Uses its authored background image (behind a contrast bloom) when present; otherwise renders gigantic text on the theme surface.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:pl},content:{summary:`Preserves the complete heading and body; supplemental media receives a companion field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:ml},statHighlight:{summary:`Uses its optional accent image natively; otherwise supplemental media occupies a companion field.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},quote:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the quote.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},factCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the fact card.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},twoColumn:{summary:`Text comparison by default; supplemental media stacks below the dense two-column panel.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},dateEvent:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the event.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},imageWithCaption:{summary:`Requires one primary image and owns its full-bleed image/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},leftFeature:{summary:`Requires a primary image in the left feature cell; text occupies the right cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-left`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},rightFeature:{summary:`Requires a primary image in the right feature cell; text occupies the left cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-right`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},map:{summary:`The map canvas is the primary visual; other media must not reflow its geography.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`map-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},fullBleedQuote:{summary:`Despite its name this is text-only; supplemental media receives the same dramatic title treatment.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:pl},list:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the list.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},photoGrid:{summary:`Requires a primary image collection and owns the complete tiled media field.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`photo-grid`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},definitionCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the definition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:ml},comparisonBar:{summary:`Data bars are primary; supplemental media stacks below to preserve horizontal scale.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},pullQuote:{summary:`Requires and owns a full-bleed background image behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoWithCaption:{summary:`Requires one primary video and owns its full-bleed video/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoPullQuote:{summary:`Requires and owns a full-bleed video behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},dataTable:{summary:`The table remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},barChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},columnChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},pieChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},donutChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},lineChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},areaChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},scatterChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:hl},diagram:{summary:`The node-and-edge canvas is intrinsic media and retains its spatial coordinate system.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},tree:{summary:`The interactive tree canvas is intrinsic media and retains its full layout region.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},timeline:{summary:`The track canvas is intrinsic media and retains its shared horizontal time scale.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},layout:{summary:`The authored layer canvas is intrinsic media and must preserve absolute placement.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},drawing:{summary:`The drawing canvas is intrinsic media and must preserve authored geometry.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`}};function _l(e){if(e)return gl[e]}function Z(e,t,n,r,i){return{x:e.width*t,y:e.height*n,width:e.width*r,height:e.height*i}}function vl(e,t){if(e>1)return`multiple`;let n=t[0]??16/9;return n<.8?`tall`:n>1.25?`wide`:`square`}function yl(e,t){return t===`portrait`?{contentRect:Z(e,.06,.04,.88,.3),mediaRect:Z(e,.06,.39,.88,.55),fontScale:.76}:t===`square`?{contentRect:Z(e,.05,.04,.9,.33),mediaRect:Z(e,.07,.42,.86,.51),fontScale:.72}:{contentRect:Z(e,.04,.03,.92,.32),mediaRect:Z(e,.08,.4,.84,.52),fontScale:.72}}function bl(e,t){let n=t===`square`;return{contentRect:Z(e,n?.05:.04,.05,n?.42:.43,.9),mediaRect:Z(e,n?.52:.53,.07,.43,.86),fontScale:.72}}function xl(e,t,n){return t===`portrait`?{contentRect:Z(e,.06,.04,.88,n?.41:.36),mediaRect:Z(e,.06,n?.5:.45,.88,n?.44:.49),fontScale:n?.42:.44}:t===`square`?{contentRect:Z(e,.05,.04,.9,n?.43:.36),mediaRect:Z(e,.07,n?.52:.45,.86,n?.41:.48),fontScale:n?.45:.46}:{contentRect:Z(e,.05,.03,.9,n?.46:.35),mediaRect:Z(e,.07,n?.55:.43,.86,n?.38:.49),fontScale:n?.5:.48}}function Sl(e,t){let n=_(e);if(n===`portrait`)switch(t){case`tall`:return Z(e,.55,.5,.38,.44);case`square`:return Z(e,.49,.58,.44,.35);case`multiple`:return Z(e,.07,.67,.86,.27);case`wide`:return Z(e,.07,.71,.86,.23)}if(n===`square`)switch(t){case`tall`:return Z(e,.68,.1,.27,.8);case`square`:return Z(e,.55,.52,.4,.4);case`multiple`:return Z(e,.08,.62,.84,.31);case`wide`:return Z(e,.08,.68,.84,.27)}switch(t){case`tall`:return Z(e,.7,.1,.26,.8);case`square`:return Z(e,.62,.22,.34,.56);case`multiple`:return Z(e,.52,.5,.44,.42);case`wide`:return Z(e,.54,.58,.42,.34)}}function Cl(e,t){let n=_(t);switch(e){case`title-stack`:return yl(t,n);case`split`:return bl(t,n);case`text-stack`:return xl(t,n,!1);case`dense-stack`:return xl(t,n,!0)}}function Q(e,t){if(e===void 0)return 0;if(typeof e==`number`)return e;let n=e.match(/^\s*(-?\d+(?:\.\d+)?)%\s*$/);if(n)return Number(n[1])/100*t;let r=Number.parseFloat(e);return Number.isFinite(r)?r:0}function wl(e){return e===0||e===`0`||e===`0%`}function Tl(e,t){if(e.type!==`shape`&&e.type!==`image`)return!1;let{position:n}=e,r=n.width===`100%`||n.width===t.width,i=n.height===`100%`||n.height===t.height;return wl(n.x)&&wl(n.y)&&r&&i}function El(e,t,n){let r={...e,x:t.x+Q(e.x,n.width)/n.width*t.width,y:t.y+Q(e.y,n.height)/n.height*t.height};return e.width!==void 0&&(r.width=Q(e.width,n.width)/n.width*t.width),e.height!==void 0&&(r.height=Q(e.height,n.height)/n.height*t.height),r}function Dl(e,t,n,r){let i=n.width/t.width,a=n.height/t.height,o=Math.min(i,a);return e.map(e=>{let s={...e.position,x:n.x+Q(e.position.x,t.width)*i,y:n.y+Q(e.position.y,t.height)*a,...e.position.width===void 0?{}:{width:Q(e.position.width,t.width)*i},...e.position.height===void 0?{}:{height:Q(e.position.height,t.height)*a}},c={...e,id:`${r}-${e.id}`,position:s};return e.type===`path`?{...c,type:`path`,content:{...e.content,d:Ol(e.content.d,i,a,n.x,n.y),...e.content.strokeWidth===void 0?{}:{strokeWidth:e.content.strokeWidth*o}}}:e.type===`text`&&o!==1?{...c,type:`text`,content:{...e.content,style:{...e.content.style,fontSize:Math.max(10,e.content.style.fontSize*o)}}}:c})}function Ol(e,t,n,r,i){let a=e.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi);if(!a)return e;let o=``,s=0;return a.map(e=>{if(/^[a-zA-Z]$/.test(e))return o=e,s=0,e;let a=Number(e);if(!Number.isFinite(a)||o===o.toLowerCase())return s++,e;let c=s++,l=a;switch(o){case`M`:case`L`:case`T`:case`C`:case`S`:case`Q`:l=c%2==0?a*t+r:a*n+i;break;case`H`:l=a*t+r;break;case`V`:l=a*n+i;break;case`A`:{let e=c%7;e===0?l=a*t:e===1?l=a*n:e===5?l=a*t+r:e===6&&(l=a*n+i);break}}return String(Math.round(l*1e3)/1e3)}).join(` `)}function kl(e,t,n,r,i){return Al(e.map(e=>{if(Tl(e,n))return e;let i=El(e.position,t,n);return e.type===`text`?{...e,position:i,content:{...e.content,style:{...e.content.style,fontSize:Math.max(12,Math.round(e.content.style.fontSize*r)),...e.content.style.padding===void 0?{}:{padding:Math.round(e.content.style.padding*r)}}}}:{...e,position:i}}),i,t,n)}function Al(e,t,n,r){let i=n.x+n.width/2,a=n.y+n.height/2;if(t===`sectionHeader`)return e.map(e=>{if(e.id===`title`)return{...e,position:{...e.position,x:i,y:a,width:n.width*.9,anchor:`center`}};if(e.id===`line-top`||e.id===`line-bottom`){let t=e.id===`line-top`?-1:1;return{...e,position:{...e.position,x:i,y:a+t*n.height*.28,width:Math.min(n.width*.22,r.width*.2),height:2,anchor:`center`}}}return e});if(t!==`title`)return e;let o=e.find(e=>e.type===`text`&&e.id===`title`),s=e.find(e=>e.type===`text`&&e.id===`subtitle`);if(!o||o.type!==`text`)return e;let c=s?.type===`text`?s:void 0,l=n.width*.9,u=Math.max(12,Math.min(r.width,r.height)*.018),d=c?u:0,f=n.height*.78,p=o.content.style.fontSize,m=c?.content.style.fontSize??0,h=()=>{let e=U(o.content.text,p,l,o.content.style.lineHeight??1.15),t=c?U(c.content.text,m,l,c.content.style.lineHeight??1.5):0;return{titleHeight:e,subtitleHeight:t,total:e+d+t}},g=h();if(g.total>f){let e=Math.max(.5,f/g.total);p=Math.max(18,Math.round(p*e)),m=Math.max(14,Math.round(m*e)),g=h()}let _=n.y+(n.height-g.total)/2,v=_+g.titleHeight/2,y=_+g.titleHeight+d+g.subtitleHeight/2;return e.map(e=>e.id===`title`&&e.type===`text`?{...e,position:{...e.position,x:i,y:v,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:p}}}:e.id===`subtitle`&&e.type===`text`?{...e,position:{...e.position,x:i,y,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:m}}}:e.id===`accent-line`?{...e,position:{...e.position,x:i,y:Math.max(n.y+2,_-u*.75),width:Math.min(n.width*.18,r.width*.12),height:3,anchor:`center`}}:e)}function jl(e,t,n,r){let i=e.width?Q(e.width,t.width):n,a=e.height?Q(e.height,t.height):r,o=Q(e.x,t.width),s=Q(e.y,t.height),c=e.anchor??`top-left`;return c===`center`?(o-=i/2,s-=a/2):(c.endsWith(`right`)&&(o-=i),c.startsWith(`bottom`)&&(s-=a)),{x:o,y:s,width:i,height:a}}function Ml(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Nl(e,t){let n=e.filter(e=>e.type!==`shape`&&e.type!==`path`&&e.type!==`mermaid`).map(e=>jl(e.position,t,e.type===`text`?t.width*.45:t.width*.5,e.type===`text`?t.height*.2:t.height*.55));return n.length===0?Z(t,.06,.08,.88,.84):[Z(t,.52,.12,.44,.76),Z(t,.04,.12,.44,.76),Z(t,.15,.53,.7,.41)].reduce((e,t)=>n.reduce((e,n)=>e+Ml(t,n),0)<n.reduce((t,n)=>t+Ml(e,n),0)?t:e)}function Pl(e,t,n,r,i){let a=_l(t),o=vl(r,i),s=e.some(e=>e.type===`image`||e.type===`video`||e.type===`map`||e.type===`mermaid`),c=a?.unconsumedMedia===`retain-native-layout`||a?.unconsumedMedia===`reserve-when-no-native-media`&&s;if(a?.additionalMediaLayout===`overlay-inset`&&c)return{layers:e,mediaRect:Sl(n,o),framed:!0};let l=a?.unconsumedMedia===`reserved-slot`||a?.unconsumedMedia===`reserve-when-no-native-media`&&!s;if(!a||!l||!a.variants)return{layers:e,mediaRect:Nl(e,n),framed:!1};let u=_(n),d=Cl(a.variants[u][o],n);return{layers:kl(e,d.contentRect,n,d.fontScale,t??``),mediaRect:d.mediaRect,framed:!0}}function Fl(e,t={}){return Il(e,t,{registry:t.customTemplates&&t.customTemplates.length>0?Ic(t.customTemplates):Fc})}function Il(e,t,n){let r=t.theme??A,i=t.viewport??f.landscape,a=t.blockIndex??0,o=t.totalBlocks??1,c=t.persistentLayers===!1?void 0:t.persistentLayers??r.persistentLayers,l=e.layers;if(l&&l.length>0&&!u(e))return{layers:ql(Wl(s(l),e,r,i),e,r,c,n.expandedPersistentLayers),source:`authored`};if(!u(e)){let t=Wl([],e,r,i);return{layers:ql(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`}}let d=n.templateContext?s(n.templateContext):p(r,a,o,i);d.block=s(e);let m=Gl(e,d,n.registry);if(m.status===`ok`)return{layers:ql(Wl(n.applyRenderStyle===!1?m.layers:Hc(m.layers,e,r),e,r,i),e,r,c,n.expandedPersistentLayers),source:`template`};let h=Kl(e.template,m);if((t.failureMode??`fallback`)===`empty`){let t=Wl([],e,r,i);return{layers:ql(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`,diagnostic:h}}return{layers:ql(Wl(dl(e,d,h.message),e,r,i),e,r,c,n.expandedPersistentLayers),source:`fallback`,diagnostic:h}}function Ll(e){return(e.contents??[]).filter(e=>e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`).map(e=>e.value).filter(e=>e.trim().length>0)}function Rl(e){let t=e.template?j(e.template):void 0,n=(e.contents??[]).filter(e=>e.type===`code`),r=[];for(let e of n){if(t!==`diagram`&&an(e.lang)){let t=sn(e.value,{explicit:on(e.lang)});if(t.isDiagram&&t.diagram){r.push({kind:`spatial`,template:`diagram`,data:Aa(t.diagram),aspectRatio:16/9});continue}}if(t!==`tree`&&qr(e.lang)){let t=Yr(e.value,{explicit:Jr(e.lang)});if(t.isTree&&t.tree){r.push({kind:`spatial`,template:`tree`,data:Ra(t.tree),aspectRatio:3/4});continue}}if(t!==`timeline`&&yr(e.lang)){let t=xr(e.value,{explicit:br(e.lang)});t.isTimeline&&t.timeline&&r.push({kind:`spatial`,template:`timeline`,data:Ia(t.timeline),aspectRatio:16/9})}}return r}function zl(e,t){let n=new Set(e.filter(e=>e.type===`image`).map(e=>e.content.src)),r=new Set(e.filter(e=>e.type===`video`).map(e=>e.content.src)),i=new Set(e.filter(e=>e.type===`mermaid`).map(e=>e.content.source)),a=$a(t.contents),o=a.filter(e=>!r.has(e.src)),s=new Set(a.map(e=>e.src)),c=new Set(n),l=Za(t.contents).filter(e=>s.has(e.src)||c.has(e.src)?!1:(c.add(e.src),!0)),u=Ll(t).filter(e=>!i.has(e));return[...l.map(e=>({kind:`image`,src:e.src,alt:e.alt,...e.width&&e.height?{aspectRatio:e.width/e.height}:{}})),...o.map(e=>({kind:`video`,src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt,aspectRatio:16/9,...e.startAt==null?{}:{startAt:e.startAt},...e.clipStart==null?{}:{clipStart:e.clipStart},...e.clipEnd==null?{}:{clipEnd:e.clipEnd}})),...u.map(e=>({kind:`mermaid`,source:e,aspectRatio:16/9})),...Rl(t)]}function Bl(e,t,n,r){let i=Math.min(n.width,n.height),a=r?i*.025:0,o=t>1?i*.018:0,s={x:e.x+a,y:e.y+a,width:Math.max(0,e.width-a*2),height:Math.max(0,e.height-a*2)},c=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*(s.width/Math.max(1,s.height)))))),l=Math.ceil(t/c),u=(s.width-o*(c-1))/c,d=(s.height-o*(l-1))/l;return Array.from({length:t},(e,t)=>({x:s.x+t%c*(u+o),y:s.y+Math.floor(t/c)*(d+o),width:u,height:d}))}function Vl(e,t){let n=t.imageTreatment;if(n===`none`)return;let r=n?{type:n,strength:e.style.imageTreatment?.strength}:e.style.imageTreatment;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.colors.primary}:r}function Hl(e,t,n,r,i){if(e.kind===`image`){let a=Vl(r,n);return[{id:`${n.id}-embedded-image-${i}`,type:`image`,position:t,content:{src:e.src,alt:e.alt||n.title||`Embedded image`,fit:`contain`,...a?{treatment:a}:{}}}]}if(e.kind===`video`){let r=Math.max(0,e.clipStart??0);return[{id:`${n.id}-embedded-video-${i}`,type:`video`,position:t,content:{src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt||n.title||`Embedded video`,fit:`contain`,clipStart:r,clipEnd:Math.max(r,e.clipEnd??r+Math.max(0,n.duration)),...e.startAt==null?{}:{startAt:Math.max(0,e.startAt)}}}]}if(e.kind===`mermaid`)return[{id:`${n.id}-mermaid-${i}`,type:`mermaid`,position:t,content:{source:e.source,background:r.colors.backgroundLight,foreground:r.colors.text,padding:Math.max(12,Math.round(Math.min(t.width,t.height)*.025))}}];let a={width:t.width,height:t.height,name:`Embedded ${e.template}`},o=p(r,0,1,a);o.block=s(n);let c={id:`${n.id}-embedded-${e.template}-${i}`,duration:n.duration,audioSegment:n.audioSegment,...e.data};return Dl(e.template===`timeline`?Wo({...c,template:`timeline`},o):e.template===`tree`?Io({...c,template:`tree`},o):No({...c,template:`diagram`},o),a,t,`${n.id}-embedded-${e.template}-${i}`)}function Ul(e,t){let n=new Map($a(t.contents).filter(e=>e.startAt!=null||e.clipStart!=null||e.clipEnd!=null).map(e=>[e.src,e]));return n.size===0?e:e.map(e=>{if(e.type!==`video`)return e;let r=n.get(e.content.src);if(!r)return e;let i=Math.max(0,r.clipStart??e.content.clipStart);return{...e,content:{...e.content,clipStart:i,clipEnd:Math.max(i,r.clipEnd??(r.clipStart==null?e.content.clipEnd:i+Math.max(0,t.duration))),...r.startAt==null?{}:{startAt:Math.max(0,r.startAt)}}}})}function Wl(e,t,n,r){let i=Ul(e,t),a=zl(i,t);if(a.length===0)return i;let o=Pl(i,t.template?j(t.template):void 0,r,a.length,a.map(e=>e.aspectRatio)),s=Bl(o.mediaRect,a.length,r,o.framed),c={image:0,video:0,mermaid:0,spatial:0},l=a.flatMap((e,r)=>(c[e.kind]+=1,Hl(e,s[r],t,n,c[e.kind]))),u=o.framed?{id:`${t.id}-rich-media-frame`,type:`shape`,position:o.mediaRect,content:{shape:`rect`,fill:n.colors.backgroundLight,stroke:C(n.colors.text,.14),strokeWidth:2,borderRadius:Math.max(12,Math.round(Math.min(r.width,r.height)*.018))}}:void 0;return[...o.layers,...u?[u]:[],...l]}function Gl(e,t,n){let r=s(e),i=s(t),a=r.children;(!i.children||i.children.length===0)&&a?.length&&(i.children=a);let o=n[j(r.template)];if(!o)return{status:`unknown-template`,layers:[]};let{templateData:c,templateOverrides:l}=r,u=r,d=u.sourceHeading?uo(r.template,u.title??``,u.contents):null,f=rl(r.template,l??{}).input,p=d||c||l?{...d,...r,...c,...f}:r,m=Object.prototype.hasOwnProperty.call(f,`quote`)?f.quote:Object.prototype.hasOwnProperty.call(c??{},`quote`)?c?.quote:Object.prototype.hasOwnProperty.call(r,`quote`)?r.quote:void 0;if(j(r.template)===`quote`&&d&&!Object.prototype.hasOwnProperty.call(d,`title`)&&!(typeof m==`string`&&m.trim())){let e=p;e.quote=d.quote,!Object.prototype.hasOwnProperty.call(c??{},`title`)&&!Object.prototype.hasOwnProperty.call(f,`title`)&&delete e.title}try{let e=o(p,i);return Array.isArray(e)?{status:`ok`,layers:s(e)}:{status:`invalid-result`,layers:[],receivedType:typeof e}}catch(e){return{status:`error`,layers:[],error:e}}}function Kl(e,t){return t.status===`unknown-template`?{code:`unknown-template`,template:e,message:`Unknown template "${e}"`}:t.status===`invalid-result`?{code:`invalid-template-result`,template:e,receivedType:t.receivedType,message:`Template "${e}" returned ${t.receivedType}, not a layer array`}:{code:`template-error`,template:e,cause:t.error,message:`Template "${e}" failed`}}function ql(e,t,n,r,i){return r?Ti(e,t,i?.bottomLayers??Si(r.bottomLayers,n),i?.topLayers??Si(r.topLayers,n)):e}var Jl={title:{label:`Title`,description:`A bold opening slide with large title text, perfect for covers and chapters.`},sectionHeader:{label:`Section Header`,description:`A clean section break with a prominent title and optional background image.`},bigText:{label:`Big Text`,description:`Gigantic uppercase display text — thumbnail-style — on a theme surface or over an image with a contrast bloom.`},content:{label:`Content`,description:`Shows a heading and the complete body in a loss-averse content-first layout.`},statHighlight:{label:`Stat Highlight`,description:`Showcases a single key number or metric with supporting context.`},quote:{label:`Quote`,description:`Displays a stylized pull quote with decorative marks and attribution.`},factCard:{label:`Fact Card`,description:`Presents a focused fact or insight with a labeled header and body text.`},twoColumn:{label:`Two Column`,description:`Divides the slide into two equal side-by-side content columns.`},dateEvent:{label:`Date Event`,description:`Highlights a date-based event or milestone with a prominent date display.`},imageWithCaption:{label:`Image with Caption`,description:`Displays a full-bleed image with an optional caption below.`},leftFeature:{label:`Left Feature`,description:`Image on the left, title and body text stacked on the right.`},rightFeature:{label:`Right Feature`,description:`Image on the right, title and body text stacked on the left.`},map:{label:`Map`,description:`Embeds an interactive map centered on a geographic location.`},fullBleedQuote:{label:`Full Bleed Quote`,description:`A full-width quote that spans the entire slide for maximum impact.`},list:{label:`List`,description:`Renders a bulleted or numbered list in a clean, card-style layout.`},photoGrid:{label:`Photo Grid`,description:`Arranges multiple photos in a 2×2 or 3×3 mosaic grid.`},definitionCard:{label:`Definition Card`,description:`Shows a term and its definition in a structured, dictionary-style card.`},comparisonBar:{label:`Comparison Bar`,description:`Visualizes two or more values side-by-side with labeled horizontal bars.`},pullQuote:{label:`Pull Quote`,description:`A stylized pull quote with large decorative marks and centered text.`},videoWithCaption:{label:`Video with Caption`,description:`Embeds a video player with an optional caption below.`},videoPullQuote:{label:`Video Pull Quote`,description:`Combines a video panel with a highlighted pull quote side-by-side.`},dataTable:{label:`Data Table`,description:`Renders tabular data in a clean, styled table with a header row.`},barChart:{label:`Bar Chart`,description:`Horizontal bars from the block's markdown table — one bar per row.`},columnChart:{label:`Column Chart`,description:`Vertical columns from the block's markdown table — one column per row.`},pieChart:{label:`Pie Chart`,description:`A pie of the block's markdown table — each row becomes a labeled slice.`},donutChart:{label:`Donut Chart`,description:`A donut of the block's markdown table — each row becomes a labeled slice.`},lineChart:{label:`Line Chart`,description:`Lines from the block's markdown table — one line per value column.`},areaChart:{label:`Area Chart`,description:`Filled area lines from the block's markdown table — one area per value column.`},scatterChart:{label:`Scatter Chart`,description:`An x/y scatter plot from the block's markdown table's numeric columns.`},diagram:{label:`Diagram`,description:`Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.`},tree:{label:`Tree`,description:`Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.`},timeline:{label:`Timeline`,description:`Plots events across one or more horizontal tracks with callouts and optional branching links.`},layout:{label:`Layout`,description:`Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.`},drawing:{label:`Drawing`,description:`Free-form sketches — draw shapes, paths, and text directly on a 2D surface.`}},Yl={title:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},sectionHeader:{role:`divider`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},bigText:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},content:{role:`content`,bodyPolicy:`complete`,safeForContentFirst:!0,placement:`heading`},statHighlight:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},quote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},factCard:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},twoColumn:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},dateEvent:{role:`event`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},imageWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},leftFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},rightFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},map:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},fullBleedQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},list:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},photoGrid:{role:`media`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},definitionCard:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},comparisonBar:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pullQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoPullQuote:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},dataTable:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},barChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},columnChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pieChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},donutChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},lineChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},areaChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},scatterChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},diagram:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},tree:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},timeline:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},drawing:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},layout:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`}},Xl=120,Zl=26,Ql=62;function $l(e){let t=e.trim().length;if(t<=Zl)return Xl;let n=Xl*Math.sqrt(Zl/t);return Math.max(Ql,Math.round(n))}function eu(e){let{theme:t}=e;return t.id===`standard`&&x(t.colors.background)>.85}var tu=[{pos:0,alpha:.95},{pos:38,alpha:.86},{pos:58,alpha:.4},{pos:78,alpha:.1},{pos:100,alpha:0}];function nu(e){return`linear-gradient(0deg, ${tu.map(t=>`${C(e,t.alpha)} ${t.pos}%`).join(`, `)})`}function ru(e,t){let n=V(t,e.imageTreatment),{heroSrc:r,heroAlt:i,title:a,subtitle:o,ambientMotion:s,heroCredit:c,heroLicense:l}=e,{theme:u,layout:d}=t,f=!r&&eu(t),p=R($l(a),t,!0),m=R(40,t,!1),h=[];if(r){let e=Vi(s);h.push({type:`image`,id:`cover-hero`,content:{src:r,alt:i||a,fit:`cover`,credit:c,license:l,...n?{treatment:n}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e},{type:`shape`,id:`cover-gradient`,content:{shape:`rect`,fill:nu(u.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}})}else f?h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:u.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`cover-bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${C(u.colors.primary,.16)} 0%, ${C(u.colors.primary,.07)} 38%, ${C(u.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}):h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${u.colors.primary} 0%, ${u.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),h.push({type:`shape`,id:`cover-accent`,content:{shape:`rect`,fill:f?C(u.colors.primary,.24):`rgba(255, 255, 255, 0.2)`},position:{x:`35%`,y:o?`42%`:`58%`,width:`30%`,height:`2px`}});return h.push({type:`text`,id:`cover-title`,content:{text:a,style:{fontSize:p,fontFamily:L(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:!f}},position:{x:`50%`,y:r?o?`70%`:`75%`:o?d.primaryY:`50%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),o&&h.push({type:`text`,id:`cover-subtitle`,content:{text:o,style:{fontSize:m,fontFamily:L(t,`body`),fontWeight:f?`bold`:`normal`,color:f?C(u.colors.text,.78):u.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:r?`82%`:d.secondaryY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),h}function iu(e){return{heroSrc:e.heroSrc,heroAlt:e.heroAlt,title:e.title,subtitle:e.subtitle,ambientMotion:e.ambientMotion,heroCredit:e.heroCredit,heroLicense:e.heroLicense}}function au(e,t,n=`cover`){let r=iu(e),i={id:`cover-block`,duration:0,audioSegment:-1};if(n===`title`)return Ri({...i,template:`title`,title:r.title,subtitle:r.subtitle},t);if(n===`sectionHeader`)return Qi({...i,template:`sectionHeader`,title:r.title,imageSrc:r.heroSrc,imageAlt:r.heroAlt,ambientMotion:r.ambientMotion},t);if(n===`bigText`||n===`bigTextImage`){let e=n===`bigTextImage`&&!!r.heroSrc;return sa({...i,template:`bigText`,title:r.title,...e?{imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,ambientMotion:r.ambientMotion}:{}},t)}return n===`imageWithCaption`?r.heroSrc?_a({...i,template:`imageWithCaption`,imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,caption:r.title,subtitle:r.subtitle,ambientMotion:r.ambientMotion,imageCredit:r.heroCredit,imageLicense:r.heroLicense,isTitle:!0},t):Ri({...i,template:`title`,title:r.title,subtitle:r.subtitle},t):ru(r,t)}function ou(e,t,n,r,i,a,o,c,l,d){let f=Il(e,{theme:r,viewport:i,persistentLayers:a??!1,blockIndex:t,totalBlocks:n,failureMode:l},{registry:c,expandedPersistentLayers:o});f.diagnostic&&d?.(f.diagnostic,e,t);let p=u(e)?{id:e.id,startTime:0,duration:e.duration,audioSegment:e.audioSegment,...f.layers.length>0?{layers:f.layers}:{},transition:e.transition,template:e.template}:{...s(e),...f.layers.length>0?{layers:f.layers}:{}},m=v(p,r,t);return m!==p.transition&&(p.transition=m),p}function su(e,t={}){let n=t,r=n.theme??A,i=n.viewport??f.landscape,{persistentLayers:a,audioSegments:o,customTemplates:c,failureMode:l=`fallback`,onDiagnostic:u,splitLongBlocks:d=!0,mergeShortBlocks:p=!0}=n,m=e.length,h=c&&c.length>0?Ic(c):Fc,g=a===!1?void 0:a??r.persistentLayers,_=g?{bottomLayers:Si(g.bottomLayers,r),topLayers:Si(g.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=ou(e,n,m,r,i,g,_,h,l,u);return a.startTime=t,t+=a.duration,a})}let v=new Map;e.forEach((e,t)=>{let n=e.audioSegment??0;v.has(n)||v.set(n,[]),v.get(n).push({block:e,originalIndex:t})});let y=Array(e.length);for(let[e,t]of v){let n=o[e];if(!n){let e=0;for(let{block:n,originalIndex:a}of t){let t=ou(n,a,m,r,i,g,_,h,l,u);t.startTime=e,e+=t.duration,y[a]=t}continue}let a=[],c=[];for(let e of t)e.block.template===`sectionHeader`?a.push(e):c.push(e);let f=a.reduce((e,{block:t})=>e+(t.duration??0),0),v=c.reduce((e,{block:t})=>e+(t.duration??0),0),b=n.duration-f,x=v>0&&b>0?b/v:1,S=[];for(let{block:e,originalIndex:n}of t){let t=ou(e,n,m,r,i,g,_,h,l,u),a=e;S.push({block:t,originalIndex:n,templateBlock:a,hasSourceTiming:typeof a.sourceStartTime==`number`})}let C=S.some(e=>e.hasSourceTiming);S.sort((e,t)=>{if(C){let n=e.templateBlock.template===`sectionHeader`,r=t.templateBlock.template===`sectionHeader`;if(n&&!r)return-1;if(!n&&r)return 1;if(e.hasSourceTiming&&t.hasSourceTiming)return e.templateBlock.sourceStartTime-t.templateBlock.sourceStartTime;if(e.hasSourceTiming&&!t.hasSourceTiming)return-1;if(!e.hasSourceTiming&&t.hasSourceTiming)return 1}return e.originalIndex-t.originalIndex});let w=0;for(let e=0;e<S.length;e++){let t=S[e],{block:r,templateBlock:i}=t;if(t.hasSourceTiming){let e=i.sourceStartTime;r.startTime=n.startTime+e,typeof i.sourceDuration==`number`&&(r.duration=Math.max(5,i.sourceDuration)),w=e+r.duration}else if(i.template===`sectionHeader`)r.startTime=n.startTime+w,w+=r.duration;else{r.startTime=n.startTime+w;let e=r.duration*x;r.duration=e,w+=e}y[t.originalIndex]=r}let T=S.map(e=>y[e.originalIndex]).sort((e,t)=>e.startTime-t.startTime);for(let e=0;e<T.length-1;e++){let t=T[e],n=T[e+1],r=t.startTime+t.duration;r>n.startTime?t.duration=n.startTime-t.startTime:r<n.startTime-.5&&(t.duration=Math.max(.1,n.startTime-t.startTime))}let E=n.startTime+n.duration;for(;T.length>1;){let e=T[T.length-1],t=E-e.startTime;if(p&&t<5&&e.template!==`sectionHeader`){let t=T[T.length-2];t.duration=E-t.startTime,e.duration=0,e.startTime=E,T.pop()}else{e.startTime+e.duration<E&&(e.duration=E-e.startTime);break}}if(T.length===1){let e=T[0];e.startTime+e.duration<E&&(e.duration=E-e.startTime)}let D=p;for(;D;){D=!1;for(let e=T.length-1;e>=1;e--){let t=T[e];if(t.duration>0&&t.duration<5){let n=T[e-1];n.duration=t.startTime+t.duration-n.startTime,t.duration=0,t.startTime=E,T.splice(e,1),D=!0;break}}}if(d)for(let e=0;e<T.length;e++){let t=T[e];if(t.duration>20){let e=Math.ceil(t.duration/20),n=t.duration/e;if(n>=5){t.duration=n;for(let r=1;r<e;r++){let e={id:`${t.id}-split-${r}`,startTime:t.startTime+r*n,duration:n,audioSegment:t.audioSegment,layers:(t.layers??[]).map(e=>({...s(e),id:`${e.id}-split-${r}`})),transition:{type:`dissolve`,duration:1},template:t.template};y.push(e)}}}}}return p?y.filter(e=>e&&e.duration>0):y.filter(Boolean)}function cu(){return Object.keys(Fc)}function lu(e){return j(e)in Fc}var uu={width:1920,height:1080},du={label:`lb`,description:`ds`,viewport:`vp`,layers:`ly`,name:`nm`,type:`ty`,position:`po`,content:`ct`,animation:`am`,width:`wd`,height:`hg`,anchor:`an`,text:`tx`,style:`sy`,fontSize:`fz`,fontFamily:`ff`,fontWeight:`fw`,color:`cl`,textAlign:`al`,verticalAlign:`vl`,lineHeight:`lh`,shadow:`sd`,background:`bg`,backgroundOpacity:`bo`,backgroundGradient:`bj`,borderColor:`bc`,borderWidth:`bw`,borderStyle:`bs`,padding:`pd`,maxLines:`mx`,shape:`sp`,fill:`fl`,fillOpacity:`fo`,gradient:`gr`,stroke:`sk`,strokeWidth:`sw`,borderRadius:`br`,shapeKind:`kd`,dasharray:`da`,arrow:`ar`,startMarker:`st`,endMarker:`em`,src:`sc`,alt:`at`,fit:`ft`,credit:`cr`,license:`lc`,from:`fr`,angle:`ag`},fu=Object.fromEntries(Object.entries(du).map(([e,t])=>[t,e]));function pu(e,t){if(Array.isArray(e))return e.map(e=>pu(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=pu(i,t);return n}return e}function mu(e){return!e||e.width===uu.width&&e.height===uu.height}function hu(e){if(!e)return;let t=bu(e[E]);if(!t)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r={name:t.name,label:t.label,viewport:t.viewport??{...uu},layers:t.layers};t.description!==void 0&&(r.description=t.description);let i=y(r);i.template&&n.push(i.template)}return n.length>0?n:void 0}function gu(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let e={lb:t.label};t.description&&(e.ds=t.description),mu(t.viewport)||(e.vp=t.viewport),e.ly=pu(t.layers,du),n[t.name]=e}return JSON.stringify(n,null,t?.pretty?2:void 0)}function _u(e){return Object.entries(e).map(([e,t])=>{let n=t&&typeof t==`object`?t:{},r={name:e,label:n.lb,viewport:n.vp??{...uu},layers:pu(n.ly??[],fu)};return typeof n.ds==`string`&&(r.description=n.ds),r})}function vu(e){return Array.isArray(e)?e:e&&typeof e==`object`?_u(e):null}function yu(e){try{return JSON.parse(e)}catch{return}}function bu(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return _u(e);if(typeof e!=`string`)return null;let t=yu(e.trim());if(t!==void 0)return vu(t);try{let t=yu(We(e));if(t!==void 0)return vu(t)}catch{}return null}function xu(e){if(e==null)return;let t=e;if(typeof t==`string`){let e=t.trim();if(!e)return;try{t=JSON.parse(e)}catch{return}}if(Array.isArray(t))return t;if(t&&typeof t==`object`)return Object.values(t)}function Su(e){if(!e)return;let t=xu(e[k]);if(!t)return;let n=[];for(let e of t){let t=D(e);t.valid&&t.theme&&n.push(t.theme)}return n.length>0?n:void 0}function Cu(e,t){if(!e||e.length===0)return;let n={};for(let t of e)n[t.id]=t;return JSON.stringify(n,null,t?.pretty?2:void 0)}var wu=new Set([`json`,`yaml`,`yml`]);function Tu(e){if(!e.lang||!wu.has(e.lang.toLowerCase()))return!1;let t=e.meta??``;return/\bdata\b/.test(t)}function Eu(e){if(e.lang?.toLowerCase()===`json`)try{let t=JSON.parse(e.value);return typeof t!=`object`||!t||Array.isArray(t)?{error:`JSON data fence must contain a top-level object ({"key": …})`}:{data:t}}catch(e){return{error:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}try{return{data:ju(e.value)}}catch(e){return{error:`invalid YAML: ${e instanceof Error?e.message:String(e)}`}}}function Du(e,t){let n=JSON.stringify(t,null,2),r=e.findIndex(e=>e.type===`code`&&Tu(e));if(r<0){let t={type:`code`,lang:`json`,meta:`data`,value:n};return[...e,t]}let i=[...e];return i[r]={...e[r],value:n},i}function Ou(e){let t=e.trim();if(t.length>=2){let e=t[0];if((e===`"`||e===`'`)&&t.endsWith(e))return t.slice(1,-1)}return t===`true`?!0:t===`false`?!1:t===`null`||t===`~`?null:t!==``&&!isNaN(Number(t))?Number(t):t}function ku(e){let t=[],n=``,r=null;for(let i of e)r?(n+=i,i===r&&(r=null)):i===`"`||i===`'`?(r=i,n+=i):i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t.map(e=>e.trim()).filter(e=>e!==``)}function Au(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?ku(t.slice(1,-1)).map(Ou):Ou(t)}function ju(e){let t={},n=e.split(`
|
|
25
|
+
`),r=null,i=null,a=-1;for(let e=0;e<n.length;e++){let o=n[e],s=o.trim();if(!s||s.startsWith(`#`))continue;let c=o.length-o.trimStart().length;if(c>0){if(!r)throw Error(`line ${e+1}: unexpected indented line without a preceding "key:" line`);if(a<0&&(a=c),c>a)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);if(s.startsWith(`- `)){if(i===`map`)throw Error(`line ${e+1}: cannot mix list items and mapping keys under "${r}"`);i=`list`,t[r].push(Au(s.slice(2)));continue}if(i===`list`)throw Error(`line ${e+1}: cannot mix mapping keys and list items under "${r}"`);let n=s.indexOf(`:`);if(n<1)throw Error(`line ${e+1}: expected "key: value"`);let o=s.slice(n+1).trim();if(o===``)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);i!==`map`&&(i=`map`,t[r]={}),t[r][s.slice(0,n).trim()]=Au(o);continue}r=null,i=null,a=-1;let l=s.indexOf(`:`);if(l<1)throw Error(`line ${e+1}: expected "key: value"`);let u=s.slice(0,l).trim(),d=s.slice(l+1).trim();d===``?(t[u]=[],r=u):t[u]=Au(d)}return t}function Mu(e){return e?.find(e=>e.type===`table`)}function Nu(e){let t=e=>e.children.map(e=>o(e).trim()),[n,...r]=e.children;return{headers:n?t(n):[],rows:r.map(t),...e.align&&e.align.some(e=>e!=null)?{align:e.align}:{}}}function Pu(e){let t=fe(e.trim()),n=t.length>0&&t[0].indexOf(`=`)>0,r=n||t.length===0?void 0:t[0],i=+!n,a={};for(let e=i;e<t.length;e++){let n=de(t[e]);n&&(a[n.key]=n.value)}return{template:r,params:a}}function Fu(e){if(e.type!==`paragraph`)return null;let t=e.children??[];if(t.length!==1||t[0].type!==`text`)return null;let n=ge(t[0].value.trim());return!n||n.index!==0?null:Pu(n.inner)}var Iu=new Set([`audio`,`video`,`media`]);function Lu(e){return e!=null&&Iu.has(e)}function Ru(e){return e==null?null:he(e)}function zu(e){let t=e.placement??e.presentation;if(t===`content`)return`content`;if(t===`pip`||t===`picture-in-picture`)return`picture-in-picture`;if(t===`overlay`||t===`full-frame`)return`overlay`;if(e.pip===``||e.pip===`true`)return`picture-in-picture`;if(e.overlay===``||e.overlay===`true`)return`overlay`}function Bu(e){return e!==`false`&&e!==`0`}function Vu(e){return e===`small`||e===`large`?e:void 0}function Hu(e){return e===`square`||e===`wide`?e:void 0}function Uu(e){return e===`top-left`||e===`top-right`||e===`bottom-left`||e===`bottom-right`?e:void 0}function Wu(e,t){let{template:n,params:r}=e;if(!n||!Iu.has(n))return null;let i=r.src;if(!i)return null;let a=n===`video`?`video`:`audio`,o=r.anchor===`document`||r.span===`document`?`document`:`block`,s={id:t,src:i,kind:a,startAt:Ru(r.startAt??r.startTime)??0,anchor:o},c=a===`video`?zu(r):void 0;c&&c!==`content`&&(s.placement=c);let l=Vu(r.pipSize),u=Hu(r.pipShape),d=Uu(r.pipPosition);if(l&&(s.pipSize=l),u&&(s.pipShape=u),d&&(s.pipPosition=d),a===`video`&&c&&c!==`content`&&r.lockToBlock!=null){let e=Bu(r.lockToBlock);s.lockToBlock=e,s.anchor=e?`block`:`document`,e&&(s.startAt=0)}let f=Ru(r.clipStart),p=Ru(r.clipEnd);return f!=null&&(s.clipStart=f),p!=null&&(s.clipEnd=p),s.lockToBlock===!0&&delete s.clipEnd,(r.spillover===`true`||r.spillover===``)&&(s.spillover=!0),s}function Gu(e){let t=e=>{for(let n of e){if(n.type!==`htmlElement`)continue;if(n.tagName===`video`)return n;let e=t(n.children);if(e)return e}return null};return t(e)}function Ku(e){if(e.type===`htmlBlock`){if(!/^\s*<video\b/i.test(e.rawHtml))return null;let t=Gu(e.htmlChildren);return t?{element:t,raw:e.rawHtml.trim()}:null}if(e.type!==`paragraph`||!e.children.every(e=>e.type===`htmlInline`))return null;let t=e.children.map(e=>e.type===`htmlInline`?e.rawHtml:``).join(``);if(!/^\s*<video\b[\s\S]*<\/video>\s*$/i.test(t))return null;for(let n of e.children){if(n.type!==`htmlInline`)continue;let e=Gu(n.htmlChildren);if(e)return{element:e,raw:t.trim()}}return null}function qu(e,t){let n=Ku(e);if(!n)return null;let{element:r}=n,i=zu({placement:r.attributes[`data-squisq-video-placement`]??``});if(!i||i===`content`)return null;let a=r.attributes.src;if(!a)return null;let o=Bu(r.attributes[`data-squisq-video-lock-to-block`]),s={id:t,src:a,kind:`video`,placement:i,lockToBlock:o,startAt:o?0:Ru(r.attributes[`data-squisq-video-start-at`])??0,anchor:o?`block`:`document`},c=Vu(r.attributes[`data-squisq-video-pip-size`]),l=Hu(r.attributes[`data-squisq-video-pip-shape`]),u=Uu(r.attributes[`data-squisq-video-pip-position`]);c&&(s.pipSize=c),l&&(s.pipShape=l),u&&(s.pipPosition=u);let d=Ru(r.attributes[`data-squisq-video-clip-start`]),f=Ru(r.attributes[`data-squisq-video-clip-end`]);return d!=null&&(s.clipStart=d),!o&&f!=null&&(s.clipEnd=f),s}function Ju(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(let c of e??[]){let e=Fu(c),l=e?Wu(e,``):qu(c,``);if(l){l.id=t(l.src,o++);let e=c.position?.start.line;if(e!=null&&(l.sourceLine=e),n!==void 0){let e=Ku(c),t=c.type===`paragraph`&&c.children?.[0]?.type===`text`?c.children[0].value.trim():e?.raw;l.origin={blockId:n,index:s,...t===void 0?{}:{raw:t},...e?{format:`html`}:{}}}(l.anchor===`document`?i:r).push(l)}else a.push(c);s++}return{media:r,documentMedia:i,remaining:a}}function Yu(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function Xu(e,t){let n=e.template,r=e.params,i=Object.keys(r).length>0,a={id:t.makeId(e),startTime:0,duration:t.defaultDuration,audioSegment:0,template:j(n),standaloneAnnotation:!0,sourceAnnotation:{template:n,...i?{params:r}:{}},...r.title?{title:r.title}:{}};return i&&(a.templateOverrides=r,Yu(a,ce(r).blockMeta)),a}function Zu(e,t){let n=[],r=[],i=null;for(let a of e??[]){let e=Fu(a);if(e!=null&&e.template!=null&&!Lu(e.template)){let n=Xu(e,t);r.push(n),i=n}else i?(i.contents??=[]).push(a):n.push(a)}return{leading:n,blocks:r}}function Qu(e){if(e.type!==`paragraph`)return null;let t=e.children;if(t.length===0)return null;let n=t[t.length-1];return n.type===`text`?n.value:null}function $u(e){if(Fu(e)?.template)return!0;let t=Qu(e);if(t==null)return!1;let n=ge(t);return!!n&&n.index>0&&!!Pu(n.inner).template}function ed(e,t,n){let r=[...e],i=r[t];if(i.type!==`paragraph`)return r;let a=[...i.children],o=a[a.length-1];if(o.type!==`text`)return r;let s=o.value.slice(0,n);return s.length===0&&a.length===1?r.splice(t,1):(a[a.length-1]={...o,value:s},r[t]={...i,children:a}),r}function td(e){if(!e||e.length===0)return null;let t=e.length-1,n=e[t],r=null,i=null,a=Fu(n);if(a?.template&&n.type===`paragraph`){let o=n.children[0];r={template:a.template,params:a.params,origin:{kind:`paragraph`,index:t,raw:o&&o.type===`text`?o.value.trim():``}},i=e.slice(0,t)}else{let a=Qu(n),o=a==null?null:ge(a);if(a!=null&&o&&o.index>0){let n=Pu(o.inner);n.template&&(r={template:n.template,params:n.params,origin:{kind:`trailing`,index:t,suffix:a.slice(o.index)}},i=ed(e,t,o.index))}}if(!r||!i)return null;for(let n=0;n<t;n++)if($u(e[n]))return null;return{data:r,strippedContents:i}}var nd=/[^\w\s-]/g,rd=/[\s_]+/g,id=/-+/g,ad=/^-|-$/g;function od(e){return e.toLowerCase().replace(nd,``).replace(rd,`-`).replace(id,`-`).replace(ad,``)||`block`}function sd(){let e=new Map,t=(t,n)=>{let r=od(o(t)),i=e.get(r)??0;return e.set(r,i+1),i===0?r:`${r}-${i+1}`};return t.reserve=t=>{e.set(t,Math.max(e.get(t)??0,1))},t.fromText=t=>{let n=od(t),r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`},t}function cd(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function ld(e){if(!e)return{};let t=e.templateAnnotation?.params?ce(e.templateAnnotation.params).blockMeta:{},n=e.attributes?.blockMeta??{};return{...t,...n}}function ud(e){return e.promotedBodyAnnotation?.params?ce(e.promotedBodyAnnotation.params).blockMeta:e.sourceHeading?ld(e.sourceHeading):e.sourceAnnotation?.params?ce(e.sourceAnnotation.params).blockMeta:{}}function dd(e){return ud(e)}function fd(e){for(let t of e){if(!t.sourceHeading||t.sourceHeading.templateAnnotation?.template)continue;let e=td(t.contents);if(!e)continue;let{template:n,params:r}=e.data;Lu(n)||!lu(n)||(t.template=j(n),Object.keys(r).length>0&&(t.templateOverrides=r,cd(t,ce(r).blockMeta)),t.contents=e.strippedContents,t.promotedBodyAnnotation=e.data)}}function pd(e,t,n){let r=[];for(let i of e){i.children&&i.children.length>0&&(i.children=pd(i.children,t,n));let{leading:e,blocks:a}=Zu(i.contents,{makeId:t,defaultDuration:n});if(a.length===0){r.push(i);continue}i.contents=e,(i.children?.length??0)>0&&!se(i.template)?(i.children=[...a,...i.children],r.push(i)):r.push(i,...a)}return r}function md(e,t){let r=t?.articleId??`markdown-doc`,i=t?.defaultTemplate??`sectionHeader`,a=t?.defaultDuration??5,s=t?.generateId?null:sd(),c=t?.generateId??s,l=[],u=[],d=0,f=[],p=[],m=null;function h(){m&&p.length>0&&(m.contents=(m.contents??[]).concat(p),p=[])}function g(e){let t=e?.attributes?.id,n=t||(e?c(e,d++):`preamble`);t&&s&&s.reserve(t);let r=e?.templateAnnotation,l=r?.template??(e?i:void 0),u=l==null?void 0:j(l),f=e?o(e):void 0,p={id:n,startTime:0,duration:a,audioSegment:0,template:u,...e?{sourceHeading:e}:{},...f?{title:f}:{}};r?.params&&(p.templateOverrides=r.params,cd(p,ce(r.params).blockMeta));let m=e?.attributes;return m&&(m.blockMeta&&cd(p,m.blockMeta),m.classes&&m.classes.length>0&&(p.classes=m.classes),m.metadata&&Object.keys(m.metadata).length>0&&(p.metadata=m.metadata)),p}for(let t of e.children)if(t.type===`heading`){let e=t,n=e.depth;h();let r=g(e);if(f.length===0)m&&!m.sourceHeading&&l.push(m),l.push(r),f.push({block:r,depth:n});else{for(;f.length>0&&f[f.length-1].depth>=n;)f.pop();if(f.length===0)l.push(r),f.push({block:r,depth:n});else{let e=f[f.length-1].block;e.children||=[],e.children.push(r),f.push({block:r,depth:n})}}m=r}else m||=g(null),p.push(t);h(),m&&!m.sourceHeading&&!l.includes(m)&&l.push(m);let _=[];for(let e of hd(l)){let{media:t,documentMedia:n,remaining:r}=Ju(e.contents,(t,n)=>`${e.id}-media-${n}-${t.replace(/[^a-zA-Z0-9]+/g,`-`)}`,e.id);t.length>0&&(e.media=t),n.length>0&&_.push(...n),e.contents&&=r}l.length>0&&!l[0].sourceHeading&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift(),fd(hd(l)),l=pd(l,e=>{let t=e.params.title??e.template??`block`;return s?s.fromText(t):od(t)},a),l.length>0&&!l[0].sourceHeading&&!l[0].standaloneAnnotation&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift();let v=hd(l);for(let e of v)bd(e,u);for(let e of v)xd(e,u),Cd(e,u),Sd(e,u);(t?.autoTemplates??!0)&&!Td(e)&&Ed(l,j(i),{featureIndex:0});for(let e of v)wd(e,u);let y=new Map;for(let e of v)y.has(e.id)?u.push({severity:`error`,code:`duplicate-id`,message:`Duplicate block id "${e.id}" \u2014 later connections and links are ambiguous`,blockId:e.id,...yd(e)}):y.set(e.id,e);for(let e of v)for(let t of e.connectsTo??[])y.has(t.target)||u.push({severity:`warning`,code:`unresolved-connection`,message:`Block "${e.id}" connects to unknown target "${t.target}"`,blockId:e.id,...yd(e)});let b=[];for(let e of v){if(ud(e).duration!=null)continue;let t=Dd(e);if(t.length>0){let n=ui(t);e.duration=Math.max(3,n.seconds)}else e.duration=a}let x=0;for(let e of v){ud(e).startTime??(e.startTime=x);let t=Dd(e);if(t.length>0){let n=kd(t);if(n.length>0){let t=e.duration/n.length;for(let e=0;e<n.length;e++)b.push({text:n[e],startTime:x+e*t,endTime:x+(e+1)*t,audioSegment:0})}}x+=e.duration}let S=new Map(v.map(e=>[e.id,e]));for(let e of _)e.lockToBlock===!1&&e.origin?.format===`html`&&!/\bdata-squisq-video-start-at\s*=/i.test(e.origin.raw??``)&&(e.startAt=S.get(e.origin.blockId)?.startTime??0);let C=b.length>0?{phrases:b,...t?.captionsGeneratedAt?{generatedAt:t.captionsGeneratedAt}:{},version:1}:void 0,w=hu(e.frontmatter),T=Su(e.frontmatter),E=n(e.frontmatter),D={articleId:r,duration:x,blocks:l,audio:{segments:[]},...C?{captions:C}:{},...e.frontmatter?{frontmatter:e.frontmatter}:{},...E?{themeId:E}:{},...w?{customTemplates:w}:{},...T?{customThemes:T}:{},...u.length>0?{diagnostics:u}:{},..._.length>0?{documentMedia:_}:{}};if(t?.generateCoverBlock??!0){let n=Pd(e,l,t?.fileName);n&&(D.startBlock=n)}return D}function hd(e){let t=[];for(let n of e)t.push(n),n.children&&t.push(...hd(n.children));return t}function gd(e){let t=[];for(let n of e)t.push(n),n.children&&!se(n.template)&&t.push(...gd(n.children));return t}function _d(e){let t=0;for(let n of e)t+=1,n.children&&(t+=_d(n.children));return t}function vd(e){return e.sourceHeading?.depth??0}function yd(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function bd(e,t){let n;for(let r of e.contents??[]){if(r.type!==`code`||!Tu(r))continue;let i=Eu(r);if(i.error){t.push({severity:`error`,code:`data-fence-parse`,message:`Data fence in block "${e.id}": ${i.error}`,blockId:e.id,...r.position?{line:r.position.start.line}:yd(e)});continue}n={...n,...i.data}}if(ve.has(j(e.template??``))){let t=t=>n&&t in n||e.templateOverrides&&t in e.templateOverrides;if(!t(`headers`)&&!t(`rows`)){let t=Mu(e.contents);t&&(n={...Nu(t),...n})}}n&&Object.keys(n).length>0&&(e.templateData=n)}function xd(e,t){if(j(e.template??``)!==`diagram`||e.children&&e.children.length>0||e.templateData&&`nodes`in e.templateData)return;let n=(e.contents??[]).filter(e=>e.type===`code`);if(n.length!==1||!an(n[0].lang))return;let r=Dt(n[0].value);if(r.nodes.length===0){t.push({severity:`warning`,code:`ascii-diagram-parse`,message:`Diagram block "${e.id}": code fence did not parse as an ASCII diagram`,blockId:e.id});return}let{nodes:i,edges:a}=Aa(r);e.templateData={nodes:i,edges:a,...e.templateData}}function Sd(e,t){if(j(e.template??``)!==`tree`||e.templateData&&`items`in e.templateData)return;let n=uo(`tree`,e.title??``,e.contents);if(!n||!Array.isArray(n.items)||n.items.length===0){t.push({severity:`warning`,code:`tree-parse`,message:`Tree block "${e.id}": body did not parse as a tree`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function Cd(e,t){if(j(e.template??``)!==`timeline`||e.templateData&&`tracks`in e.templateData)return;let n=uo(`timeline`,e.title??``,e.contents);if(!n||!Array.isArray(n.tracks)||n.tracks.length===0){t.push({severity:`warning`,code:`timeline-parse`,message:`Timeline block "${e.id}": body did not parse as an ASCII timeline`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function wd(e,t){if(j(e.template??``)!==`timeline`||!e.templateData||!(`tracks`in e.templateData))return;let n=(e.contents??[]).filter(e=>e.type===`code`&&yr(e.lang));if(n.length===1)for(let r of In(n[0].value).warnings){let n=/^unresolved-link\((.+)\)$/.exec(r);t.push({severity:`warning`,code:n?`timeline-unresolved-link`:`timeline-parse-warning`,message:n?`Timeline block "${e.id}": unresolved branch ${n[1]}`:`Timeline block "${e.id}": ${r}`,blockId:e.id})}}function Td(e){let t=e.frontmatter?.[`squisq-auto-templates`];return t===!1||t===`false`||t===`off`||t===`no`||t===0}function Ed(e,t,n){for(let r of e){let e=!!r.sourceHeading?.templateAnnotation?.template||!!r.promotedBodyAnnotation;if(r.sourceHeading&&!e&&r.template===t){let e=si(ii(r.contents??[]),n.featureIndex);if(e&&lo(e,r.contents)){let t=uo(e,r.title??``,r.contents,{preserveSourceHeading:!0});t&&((e===`leftFeature`||e===`rightFeature`)&&(n.featureIndex+=1),r.template=e,r.autoTemplate=!0,r.templateData={...t,...r.templateData})}}r.children&&r.children.length>0&&!se(r.template)&&Ed(r.children,t,n)}}function Dd(e){if(!e.contents||e.contents.length===0)return``;let t=j(e.template??``),n=t===`diagram`&&e.templateData!==void 0&&`nodes`in e.templateData||t===`timeline`&&e.templateData!==void 0&&`tracks`in e.templateData||t===`tree`&&e.templateData!==void 0&&`items`in e.templateData;return e.contents.filter(e=>!(n&&e.type===`code`)).map(e=>o(e)).join(`
|
|
26
|
+
`).trim()}var Od=12;function kd(e){let t=e.split(/\n+/).map(e=>e.trim()).filter(e=>e.length>0),n=/(?<=[.!?])\s+/,r=[];for(let e of t){let t=e.split(n).map(e=>e.trim()).filter(e=>e.length>0);r.push(...t)}if(r.length===0)return[];let i=[];for(let e of r)if(e.split(/\s+/).length>Od){let t=Math.floor(e.length/2),n=/[,;]\s+|\s+—\s+|\s+-\s+/g,r=-1,a=1/0,o;for(;(o=n.exec(e))!==null;){let e=Math.abs(o.index-t);e<a&&(a=e,r=o.index+o[0].length)}r>0&&r<e.length-5?(i.push(e.slice(0,r).trim()),i.push(e.slice(r).trim())):i.push(e)}else i.push(e);let a=[i[0]];for(let e=1;e<i.length;e++)i[e].length<15&&a.length>0?a[a.length-1]+=` `+i[e]:a.push(i[e]);return a}function Ad(e){for(let t of e){if(t.type!==`htmlElement`)continue;if(t.tagName===`img`&&t.attributes.src)return{url:t.attributes.src,alt:t.attributes.alt};let e=Ad(t.children);if(e)return e}}function jd(e){if(e.type===`image`){let t=e;return{url:t.url,alt:t.alt}}if(e.type===`htmlBlock`||e.type===`htmlInline`){let t=e;if(t.htmlChildren){let e=Ad(t.htmlChildren);if(e)return e}}if(`children`in e&&Array.isArray(e.children))for(let t of e.children){let e=jd(t);if(e)return e}}function Md(e){let t;for(let n of e){let e=n.sourceHeading?.depth;if(e!==void 0&&(n.title??o(n.sourceHeading))&&(!t||e<t.sourceHeading.depth)&&(t=n,e===1))break}return t}function Nd(e){if(!e)return;let t=(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(t)return t.charAt(0).toUpperCase()+t.slice(1)}function Pd(e,t,n){let r=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():void 0,i=Md(t),a=i?i.title??o(i.sourceHeading):void 0,s=r||a||Nd(n);if(!s)return;let c=i??t[0],l=c?.contents?.[0]?.type===`paragraph`?o(c.contents[0]):void 0,u=jd(e);return{title:s,...l?{subtitle:l}:{},...u?{heroSrc:u.url,heroAlt:u.alt??s}:{},ambientMotion:`zoomIn`}}var Fd=/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,Id=1.4;function Ld(e){let t=e.replace(Fd,``);if(!t)return 1;if(/^[-+]?[\d.,]+$/.test(t)){let e=parseFloat(t.replace(/,/g,``));if(!Number.isNaN(e)&&Number.isFinite(e))return Math.max(1,Math.round(xe(t)*Id))}if(/^[A-Z]{2,5}$/.test(t)&&!/[AEIOUY]/.test(t))return t.length;let n=t.toLowerCase().split(/[^a-z']+/).filter(e=>e.length>0);if(n.length===0)return 1;let r=0;for(let e of n)r+=Rd(e.replace(/'/g,``));return Math.max(1,r)}function Rd(e){if(!e)return 0;let t=e.match(/[aeiouy]+/g),n=t?t.length:0;return n===0?1:(n>1&&/[^aeiouy]e$/.test(e)&&--n,n>1&&/[^aeiouy]ed$/.test(e)&&!/[td]ed$/.test(e)&&--n,n>1&&/[^aeiouy]es$/.test(e)&&!/(?:[sxz]|[cs]h)es$/.test(e)&&--n,/[^aeiouy]le$/.test(e)&&(n+=1),Math.max(1,n))}function zd(e,t){let n=t&&e.title?e.title.trim():``,r=Dd(e);return n&&r?`${n}
|
|
27
|
+
${r}`:n||r}function Bd(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
28
|
+
|
|
29
|
+
`,i=[];for(let t of gd(e.blocks)){let e=zd(t,n);e&&i.push({blockId:t.id,heading:t.title||void 0,text:e})}let a=``,o=[];for(let e=0;e<i.length;e++){e>0&&(a+=r);let t=a.length;a+=i[e].text,o.push({blockId:i[e].blockId,...i[e].heading===void 0?{}:{heading:i[e].heading},tokenStart:0,tokenEnd:0,charStart:t,charEnd:a.length})}let s=[],c=/\S+/g,l=0,u;for(;(u=c.exec(a))!==null;){let e=u.index,t=e+u[0].length;for(;l<o.length-1&&e>=o[l].charEnd;)l++;let n=Hd(u[0]);s.push({text:u[0],charOffset:e,charEnd:t,blockId:o[l]?.blockId??``,blockIndex:l,syllables:n?Ld(u[0]):0,spokenWordEquiv:n?xe(Ud(u[0])):0,pauseAfter:0,spoken:n})}for(let e of o)e.tokenStart=s.length,e.tokenEnd=0;for(let e=0;e<s.length;e++){let t=o[s[e].blockIndex];t&&(e<t.tokenStart&&(t.tokenStart=e),t.tokenEnd=e+1)}for(let e of o)e.tokenStart>e.tokenEnd&&(e.tokenStart=e.tokenEnd);for(let e=0;e<s.length;e++){let t=s[e],n=s[e+1];!n||n.blockIndex!==t.blockIndex?t.pauseAfter=3:a.slice(t.charEnd,n.charOffset).includes(`
|
|
30
|
+
`)?t.pauseAfter=2:Wd(t.text)&&(t.pauseAfter=1)}let d=Array(s.length+1);d[0]=0;for(let e=0;e<s.length;e++)d[e+1]=d[e]+s[e].syllables;return{sourceText:a,tokens:s,blocks:o,totalSyllables:d[s.length],cumulativeSyllables:d}}var Vd=/["')\]}»”’]+$/;function Hd(e){return/[\p{L}\p{N}]/u.test(e)}function Ud(e){return e.replace(/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,``)}function Wd(e){let t=e.replace(Vd,``),n=t.charAt(t.length-1);return n?n===`,`||n===`.`||n===`;`||n===`:`||n===`!`||n===`?`:!1}function Gd(e,t,n){return e<t?t:e>n?n:e}function Kd(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Gd(t,0,n),i=Math.floor(r);return i>=n?e.totalSyllables:e.cumulativeSyllables[i]+(r-i)*e.tokens[i].syllables}function qd(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Gd(t,0,e.totalSyllables),i=0,a=n;for(;i<a;){let t=i+a+1>>1;e.cumulativeSyllables[t]<=r?i=t:a=t-1}if(i>=n)return n;let o=r-e.cumulativeSyllables[i],s=e.tokens[i].syllables;return i+(s>0?o/s:0)}function Jd(e,t){if(e.length===0)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i].tSec<=t?n=i:r=i-1}return e[n].tSec<=t?n:0}function Yd(e,t,n,r){let i=t.words.map(t=>{let n=e.tokens[t.tokenIndex];return{id:`word-${t.tokenIndex}`,time:t.tSec,charOffset:n?.charOffset??0,textFragment:n?.text??``}}),a=t.blocks.map(e=>({...e.blockId?{blockId:e.blockId}:{},...e.heading===void 0?{}:{heading:e.heading},blockIndex:e.blockIndex,charStart:e.charStart,charEnd:e.charEnd,startSec:e.startSec,endSec:e.endSec}));return{version:3,sourceText:e.sourceText,duration:Number.isFinite(n)&&n>=0?n:0,bookmarks:i,blocks:a,...Zd(r?.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},generator:{name:`squisq-teleprompter`,method:`dsp-align`,...r?.baseWpm===void 0?{}:{baseWpm:r.baseWpm}}}}function Xd(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function Zd(e){return typeof e==`number`&&Number.isFinite(e)}function Qd(e){try{let t=typeof e==`string`?e:new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e)),n=JSON.parse(t);if(typeof n!=`object`||!n)return null;let r=n;if(typeof r.sourceText!=`string`||!Xd(r.duration))return null;let i=Array.isArray(r.bookmarks)?r.bookmarks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!Xd(t.time)||!Xd(t.charOffset)?[]:[{id:typeof t.id==`string`?t.id:`bookmark-${t.charOffset}`,time:t.time,charOffset:t.charOffset,...typeof t.textFragment==`string`?{textFragment:t.textFragment}:{}}]}):[],a=Array.isArray(r.blocks)?r.blocks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!Xd(t.startSec)||!Xd(t.endSec)||!Xd(t.charStart)||!Xd(t.charEnd)?[]:[{...typeof t.blockId==`string`?{blockId:t.blockId}:{},...typeof t.heading==`string`?{heading:t.heading}:{},blockIndex:Xd(t.blockIndex)?t.blockIndex:0,charStart:t.charStart,charEnd:t.charEnd,startSec:t.startSec,endSec:Math.max(t.startSec,t.endSec)}]}):[];a=a.sort((e,t)=>e.startSec-t.startSec);let o=0;for(let e of a)e.startSec<o&&(e.startSec=o),e.endSec<e.startSec&&(e.endSec=e.startSec),o=e.startSec;return{version:3,sourceText:r.sourceText,duration:r.duration,bookmarks:i,blocks:a,...Zd(r.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},...typeof r.generator==`object`&&r.generator!==null?{generator:r.generator}:{}}}catch{return null}}var $d=``,ef=RegExp(`${$d}([a-z]+):([a-zA-Z0-9-]+)${$d}`,`g`);function tf(e,t){return`${$d}${e}:${t}${$d}`}function nf(e){return e.includes($d)}function rf(e){return e.replace(ef,``)}function af(e){let t=[],n=0;ef.lastIndex=0;let r;for(;(r=ef.exec(e))!==null;)r.index>n&&t.push({type:`text`,text:e.slice(n,r.index)}),t.push({type:`icon`,family:r[1],name:r[2]}),n=r.index+r[0].length;return n<e.length&&t.push({type:`text`,text:e.slice(n)}),t}function of(e,t){return`fa-${e} fa-${t}`}function sf(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:cf(e),style:lf(e)}}function cf(e){let{type:t,direction:n,panDirection:r}=e;switch(t){case`fadeIn`:return`anim-fadeIn`;case`fadeOut`:return`anim-fadeOut`;case`slowZoom`:return r===`left`?`anim-slowZoom-panLeft`:r===`right`?`anim-slowZoom-panRight`:n===`out`?`anim-slowZoom-out`:`anim-slowZoom-in`;case`zoomIn`:return`anim-zoomIn`;case`zoomOut`:return`anim-zoomOut`;case`panLeft`:return`anim-panLeft`;case`panRight`:return`anim-panRight`;case`typewriter`:return`anim-typewriter`;default:return``}}function lf(e){let t={};return e.duration!==void 0&&(t[`--anim-duration`]=`${e.duration}s`),e.delay!==void 0&&(t[`--anim-delay`]=`${e.delay}s`),e.easing&&(t[`--anim-easing`]=e.easing),t}function uf(e){switch(e){case`slowZoom`:case`panLeft`:case`panRight`:return 8;case`typewriter`:return 3;case`fadeIn`:case`fadeOut`:return 1;case`zoomIn`:case`zoomOut`:return .5;default:return 1}}function df(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${pf(e,n)}-${r}`}var ff={airplane:`airplane`,blinds:`blindsHorizontal`,box:`box`,checker:`checkerboard`,checkerboard:`checkerboard`,circle:`shapeCircle`,clock:`clock`,comb:`combHorizontal`,conveyor:`conveyor`,cover:`coverLeft`,crush:`crush`,cube:`cube`,curtains:`curtains`,cut:`cut`,diamond:`shapeDiamond`,dissolve:`dissolve`,doors:`doors`,drape:`drape`,fade:`fade`,fallOver:`fallOver`,ferris:`ferrisWheel`,ferrisWheel:`ferrisWheel`,flash:`flash`,flip:`flip`,flyThrough:`flyThrough`,flythrough:`flyThrough`,fracture:`fracture`,gallery:`gallery`,glitter:`glitter`,honeycomb:`honeycomb`,morph:`morph`,newsflash:`newsflash`,orbit:`orbit`,origami:`origami`,pageCurl:`pageCurl`,pageCurlDouble:`pageCurlDouble`,pageCurlSingle:`pageCurlSingle`,pan:`panLeft`,peelOff:`peelOff`,plus:`shapePlus`,prestige:`prestige`,prism:`prism`,pull:`pullLeft`,push:`pushLeft`,random:`random`,randomBar:`randomBarsHorizontal`,randomBars:`randomBarsVertical`,reveal:`revealLeft`,ripple:`ripple`,rotate:`rotate`,shape:`shapeCircle`,shred:`shred`,slideDown:`slideDown`,slideLeft:`slideLeft`,slideRight:`slideRight`,slideUp:`slideUp`,split:`splitHorizontal`,strips:`stripsLeft`,switch:`switch`,uncover:`uncoverLeft`,vortex:`vortex`,warp:`warp`,wedge:`wedge`,wheel:`wheel`,wheelReverse:`wheelReverse`,wind:`wind`,window:`window`,wipe:`wipeLeft`,zoom:`zoom`};function pf(e,t){switch(e){case`randomBars`:case`randomBar`:return hf(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return hf(`comb`,t,`Horizontal`);case`blinds`:return hf(`blinds`,t,`Horizontal`);case`split`:return hf(`split`,t,`Horizontal`);case`push`:return mf(`push`,t,`Left`);case`wipe`:return mf(`wipe`,t,`Left`);case`cover`:return mf(`cover`,t,`Left`);case`uncover`:return mf(`uncover`,t,`Left`);case`pull`:return mf(`pull`,t,`Left`);case`reveal`:return mf(`reveal`,t,`Left`);case`strips`:return mf(`strips`,t,`Left`);case`pan`:return mf(`pan`,t,`Left`);default:return ff[e]}}function mf(e,t,n){return`${e}${gf(t,n)}`}function hf(e,t,n){return`${e}${_f(t,n)}`}function gf(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function _f(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function vf(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var yf=40,bf=e=>Math.max(0,Math.min(1,e)),xf=e=>Math.round(e*100)/100;function Sf(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=bf(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${xf(t)})`,`contrast(${xf(1+.05*t)})`);break;case`duotone`:{let r=ie(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${xf(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-yf)}deg)`,`saturate(${xf(1+t)})`);break}case`warm`:n.push(`sepia(${xf(.4*t)})`,`saturate(${xf(1+.15*t)})`);break;case`cool`:n.push(`saturate(${xf(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${xf(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var Cf=Object.freeze([{id:`cover`,label:`Hero cover`,description:`The classic Squisq cover with title, subtitle, and optional hero image.`},{id:`title`,label:`Title`,description:`A theme-led title card without a full-bleed image.`},{id:`sectionHeader`,label:`Section header`,description:`A bold section divider using the hero image when one is available.`},{id:`imageWithCaption`,label:`Image with title`,description:`A full-bleed image with the title and subtitle overlaid.`,requiresHeroImage:!0},{id:`bigText`,label:`Big text`,description:`The title in gigantic uppercase type on a clean theme surface — thumbnail-ready.`},{id:`bigTextImage`,label:`Big text on image`,description:`The title in gigantic uppercase type over the hero image, with a contrast bloom behind the text.`,requiresHeroImage:!0}]),wf=Object.freeze({enabled:{canonical:`squisq-cover-slide`,legacy:`cover-slide`},template:{canonical:`squisq-cover-template`,legacy:`cover-template`},duration:{canonical:`squisq-cover-duration`,legacy:`cover-duration`},playback:{canonical:`squisq-cover-playback`,legacy:`cover-playback`}}),Tf=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function Ef(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function Df(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function Of(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s-]+/g,``);if(t===`cover`||t===`hero`||t===`managedcover`)return`cover`;if(t===`title`||t===`titleblock`)return`title`;if(t===`sectionheader`||t===`section`)return`sectionHeader`;if(t===`imagewithcaption`||t===`imagetitle`||t===`fullbleedimage`)return`imageWithCaption`;if(t===`bigtextimage`||t===`largetextimage`||t===`bigtextonimage`)return`bigTextImage`;if(t===`bigtext`||t===`largetext`)return`bigText`}function kf(e){let t=typeof e==`number`?e:typeof e==`string`&&e.trim().length>0?Number(e):NaN;if(!(!Number.isFinite(t)||t<0||t>60))return t}function Af(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s]+/g,`-`);if([`overlay`,`over`,`concurrent`,`play-over`].includes(t))return`overlay`;if([`preroll`,`pre-roll`,`delay`,`push`,`shift`].includes(t))return`preroll`}function jf(e,t={}){let n={enabled:Df(Ef(e,wf.enabled))??Tf.enabled,template:Of(Ef(e,wf.template))??Tf.template,duration:kf(Ef(e,wf.duration))??Tf.duration,playback:Af(Ef(e,wf.playback))??Tf.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:kf(t.duration)??n.duration,playback:t.playback??n.playback}}var Mf=[`transition`,`transitionDuration`,`transitionDirection`],Nf=`sectionHeader`;function Pf(e,t={}){let n=j(t.defaultTemplate??Nf),r=[],i=new Set(hd(e.blocks).map(e=>e.id)),a=new Map,o=[];for(let t of e.documentMedia??[])if(t.origin&&i.has(t.origin.blockId)){let e=a.get(t.origin.blockId)??[];e.push(t),a.set(t.origin.blockId,e)}else o.push(t);for(let e of o)r.push(Rf(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!If(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=zf(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(Ff(e));let o=[...e.media??[],...a.get(e.id)??[]],c=[...e.contents??[]];if(o.length>0){let e=o.filter(e=>e.origin).sort((e,t)=>e.origin.index-t.origin.index);for(let t of e)c.splice(Math.min(t.origin.index,c.length),0,Rf(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(Rf(e))}if(i&&Lf(c,t),r.push(...c),e.children)for(let t of e.children)s(t)}for(let t of e.blocks)s(t);let c=gu(e.customTemplates),l=e.frontmatter;if(c)l={...l??{},[E]:c};else if(l&&`squisq-custom-templates`in l){let{[E]:e,...t}=l;l=t}let u=Cu(e.customThemes);if(u)l={...l??{},[k]:u};else if(l&&`squisq-custom-themes`in l){let{[k]:e,...t}=l;l=t}return{type:`document`,children:r,...l&&Object.keys(l).length>0?{frontmatter:l}:{}}}function Ff(e){return{type:`paragraph`,children:[{type:`text`,value:ue(e.sourceAnnotation?.template,e.templateOverrides)}]}}function If(e,t){let n=j(e.template??``)===j(t.template),r=Hf(e.templateOverrides??{},t.params??{});return!(n&&r)}function Lf(e,t){if(t.origin.kind===`paragraph`){e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.raw}]});return}let n=e[e.length-1];if(n&&n.type===`paragraph`){let r=n.children??[],i=r[r.length-1];if(i&&i.type===`text`){let a=[...r];a[a.length-1]={...i,value:i.value+t.origin.suffix},e[e.length-1]={...n,children:a};return}}e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.suffix.replace(/^\s+/,``)}]})}function Rf(e){if(e.origin?.format===`html`&&e.origin.raw)return{type:`htmlBlock`,rawHtml:e.origin.raw,htmlChildren:a(e.origin.raw)};if(e.origin?.raw)return{type:`paragraph`,children:[{type:`text`,value:e.origin.raw}]};let t={src:e.src};return e.placement&&(t.placement=e.placement),e.pipSize&&(t.pipSize=e.pipSize),e.pipShape&&(t.pipShape=e.pipShape),e.pipPosition&&(t.pipPosition=e.pipPosition),e.lockToBlock!=null&&(t.lockToBlock=String(e.lockToBlock)),e.anchor===`document`&&(t.anchor=`document`),e.startAt&&(t.startAt=String(e.startAt)),e.clipStart!=null&&(t.clipStart=String(e.clipStart)),e.clipEnd!=null&&(t.clipEnd=String(e.clipEnd)),e.spillover&&(t.spillover=`true`),{type:`paragraph`,children:[{type:`text`,value:ue(e.kind,t)}]}}function zf(e,t,n){let{attributes:r,transitionParams:i}=Uf(e,t),a=t.templateAnnotation,o=Bf(e,a,n),s=e.templateOverrides&&Object.keys(e.templateOverrides).length>0?e.templateOverrides:void 0,c;return(o!==void 0||s!==void 0)&&(c={...o===void 0?{}:{template:o},...s?{params:s}:{}}),i&&(c={...c??{},params:{...c?.params??{},...i}}),Vf(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function Bf(e,t,n){if(!e.template||e.autoTemplate===!0)return t?.template;let r=j(e.template);if(t?.template&&j(t.template)===r)return t.template;if(r!==n)return e.template}function Vf(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&Hf(e.params,t.params)}function Hf(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n])}function Uf(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=Wf(t.attributes)??{};return{attributes:{...r,blockMeta:{...r.blockMeta??{},transition:n}},transitionParams:{transition:n.type,...n.duration===void 0?{}:{transitionDuration:String(n.duration)},...n.direction?{transitionDirection:n.direction}:{}}}}function Wf(e){if(!e?.params)return e;let t={...e.params};for(let e of Mf)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function Gf(e){if(e.type===`inlineIcon`){let t=e;return tf(t.family,t.name)}if(`value`in e&&typeof e.value==`string`)return e.value;let n=t(e),r=e.type===`list`||e.type===`listItem`?`
|
|
31
|
+
`:``;return n.map(Gf).join(r)}function Kf(e){if(!e||e.length===0)return``;let t=[];for(let n of e)n.type===`code`&&n.lang?.trim().toLowerCase()===`mermaid`||t.push(Gf(n));return t.join(`
|
|
32
|
+
`).trim()}function qf(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function Jf(e){if(!e||e.length===0)return[];let n=[];function r(e){if(!e||typeof e!=`object`)return;let t=e;if(t.type===`htmlElement`&&t.tagName.toLowerCase()===`img`){let e=t.attributes,r=e?.src;typeof r==`string`&&r&&n.push({src:r,alt:typeof e?.alt==`string`?e.alt:``,width:qf(e?.width),height:qf(e?.height)})}if(Array.isArray(t.children))for(let e of t.children)r(e)}function i(e){if(`type`in e&&e.type===`image`&&`url`in e){let t=e;t.url&&n.push({src:t.url,alt:t.alt??``})}if(`type`in e&&(e.type===`htmlBlock`||e.type===`htmlInline`)){let t=e;for(let e of t.htmlChildren??[])r(e)}for(let n of t(e))i(n)}for(let t of e)i(t);return n}function Yf(e){let t=new Set,n=[];function r(e){for(let i of e){for(let e of Jf(i.contents))t.has(e.src)||(t.add(e.src),n.push(e));i.children&&r(i.children)}}return r(e),n}function Xf(e){if(!e)return[];let t=[];for(let n of e)if(n.type===`list`)for(let e of n.children){let n=o(e).trim();n&&t.push(n)}return t}function Zf(e,t,n){let r=Kf(n.contents);switch(e){case`statHighlight`:return uo(e,t,n.contents)??{stat:t,description:r||t};case`quote`:return{quote:r||t};case`fullBleedQuote`:case`pullQuote`:return uo(e,t,n.contents)??{text:r||t};case`factCard`:return{fact:t,explanation:r||t};case`comparisonBar`:return{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40};case`list`:{let e=Xf(n.contents);return{items:e.length>0?e:[`Item 1`,`Item 2`,`Item 3`]}}case`definitionCard`:return{term:t,definition:r||t};case`dateEvent`:return{date:t,description:r||t};case`leftFeature`:case`rightFeature`:{let e=Jf(n.contents)[0];return{imageSrc:e?.src??``,imageAlt:e?.alt||t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:r||t}}default:return{}}}function Qf(e,t,n,r){let i=e.sourceHeading?o(e.sourceHeading):e.title||r||``,a=e.template===`sectionHeader`&&e.autoTemplate!==!0&&e.sourceHeading&&!e.sourceHeading.templateAnnotation?.template?`content`:e.template??`content`,s=n?.has(a)??!1,c=lu(a)||s?a:`sectionHeader`,l=Zf(c,i,e),u=tp(e.templateOverrides),d=u?rl(c,u).input:void 0,{id:f,startTime:p,duration:m,audioSegment:h,layers:g,transition:_,template:v,title:y,children:b,contents:x,sourceHeading:S,templateOverrides:C,templateData:w,...T}=e;return{id:e.id,template:c,duration:e.duration,audioSegment:0,transition:e.transition??(t>0?{type:`fade`,duration:.5}:void 0),title:i,...e.contents?{contents:e.contents}:{},...s&&e.children?{children:e.children}:{},...l,...T,...ep(e.templateData),...d}}var $f=new Set(Object.keys(oe));function ep(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if($f.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}function tp(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if($f.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}var np=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`];function rp(e){return e?(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).trim():``}function ip(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function ap(e,t){let n=gd(e.blocks),r=Yf(e.blocks),i=new Set,a=e.customTemplates?new Set(e.customTemplates.map(e=>e.name)):void 0,o=ip(e,t?.documentTitle),s=[],c=0;for(let e=0;e<n.length;e++){let t=n[e],r=Jf(t.contents),l=Qf(t,e,a,o);if(r.length>0&&l.template===`sectionHeader`){let e=r[0];i.add(e.src),l.template=`imageWithCaption`,l.imageSrc=e.src,l.imageAlt=e.alt,l.caption=l.title,l.captionPosition=`bottom`,l.ambientMotion=np[c++%np.length]}else if(r.length>0){let e=r[0];i.add(e.src),l.accentImage||={src:e.src,alt:e.alt,position:`left-strip`,ambientMotion:np[c++%np.length]}}s.push(l)}let l=t?.interleaveImages??!0?r.filter(e=>!i.has(e.src)):[];if(l.length>0&&s.length>0){let e=Math.max(2,Math.floor(s.length/(l.length+1))),t=0;for(let n=0;n<l.length;n++){let r=Math.min((n+1)*e+t,s.length),i=l[n];s.splice(r,0,{id:`img-interleave-${n}`,template:`imageWithCaption`,duration:5,audioSegment:0,imageSrc:i.src,imageAlt:i.alt,ambientMotion:np[c++%np.length],transition:{type:`fade`,duration:.5}}),t++}}let u=0;for(let e of s)e.startTime=u,u+=e.duration;let d=e.audio?.segments?.length>0?e.audio:{segments:u>0?[{src:``,name:`preview`,duration:u,startTime:0}]:[]};return{...e,duration:u,blocks:s,audio:d}}function op(e,t,r){let i=t??e?.themeId??n(e?.frontmatter),a=e?.customThemes??Su(e?.frontmatter);return(i?a?.find(e=>e.id===i):void 0)||O(i,r)}function sp(e){return e.sourceHeading?.templateAnnotation?.template||e.autoTemplate&&e.template?!0:!e.sourceHeading&&u(e)}function cp(e){return e.sourceHeading?.templateAnnotation?.template??e.template}function lp(e){if(!sp(e))return{templated:!1};let t=e.sourceHeading?.templateAnnotation,n=cp(e)??`sectionHeader`,r=j(n),i=rl(n,{...t?.params??{},...e.templateOverrides??{}}).input,a,s=null;if(t){let t=o(e.sourceHeading);s=uo(n,t,e.contents,{placeholders:!0}),a={id:e.id,template:n,startTime:0,duration:1,audioSegment:0,title:t,contents:e.contents,children:e.children,...s??{}}}else a={...e,startTime:e.startTime??0,duration:e.duration??1,audioSegment:e.audioSegment??0,template:n};let c={...a,...e.templateData??{},...i},l=Object.prototype.hasOwnProperty.call(i,`quote`)?i.quote:e.templateData?.quote;if(r===`quote`&&s&&!Object.prototype.hasOwnProperty.call(s,`title`)&&!(typeof l==`string`&&l.trim())){let t=c;t.quote=s.quote,!Object.prototype.hasOwnProperty.call(e.templateData??{},`title`)&&!Object.prototype.hasOwnProperty.call(i,`title`)&&delete t.title}return{templated:!0,templateName:r,templateBlock:c}}function up(e){let t=e.contents;if(!t||t.length===0)return;let n=t.map(e=>o(e)).join(`
|
|
33
|
+
`).trim();return n?{text:n,markdown:t}:void 0}function dp(e){if(e?.src)return{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}function fp(e,t,n){return{kind:`canvas-embed`,variant:e,slots:{media:{type:`canvas`,spatial:e,block:n??t.block,aspect:{width:t.viewport.width,height:t.viewport.height}}}}}var pp=e=>{let t=e,n=e.contents?.find(e=>e.type===`paragraph`),r=t.subtitle??(n?o(n):void 0);return{kind:`hero`,variant:`title`,slots:{title:t.title,subtitle:r},emphasis:`lead`,hints:t.backgroundColor?{backgroundColor:t.backgroundColor}:void 0}},mp=e=>{let t=e,n=t.imageSrc?{type:`image`,src:t.imageSrc,alt:t.imageAlt??``}:void 0;return{kind:`banner`,slots:{title:t.title,media:n},colorScheme:t.colorScheme,mediaBackground:!!t.imageSrc}},hp=e=>{let t=e,n=t.imageSrc?{type:`image`,src:t.imageSrc,alt:t.imageAlt??``}:void 0;return{kind:`hero`,variant:n?`media`:`title`,slots:{title:t.title,media:n},emphasis:`lead`,mediaBackground:!!n}},gp=e=>({kind:`prose`,slots:{title:e.title,body:up(e)}}),_p=e=>{let t=e;return{kind:`stat-band`,variant:`single`,slots:{items:[{value:t.stat,title:t.description,body:t.detail}],media:dp(t.accentImage)},emphasis:`strong`,colorScheme:t.colorScheme}},vp=e=>{let t=e;return{kind:`quote-band`,variant:`plain`,slots:{title:t.title,body:{text:t.quote??``},attribution:t.attribution,media:dp(t.accentImage)}}},yp=e=>{let t=e;return{kind:`callout`,variant:`fact`,slots:{title:t.fact,body:{text:t.explanation??``},meta:t.source,media:dp(t.accentImage)}}},bp=e=>{let t=e;return{kind:`card-grid`,variant:`two-column`,slots:{title:t.header,items:[{title:t.left?.label,body:t.left?.sublabel,accentScheme:t.leftColor},{title:t.right?.label,body:t.right?.sublabel,accentScheme:t.rightColor}]}}},xp=e=>{let t=e;return{kind:`timeline-rail`,slots:{milestone:{date:t.date??``,description:t.description??``,footer:t.footer,mood:t.mood},media:dp(t.accentImage)}}},Sp=e=>{let t=e,n={type:`image`,src:t.imageSrc,alt:t.imageAlt??``,credit:t.imageCredit,license:t.imageLicense};return t.isTitle?{kind:`hero`,variant:`media`,slots:{title:t.caption,subtitle:t.subtitle,media:n},emphasis:`lead`,mediaBackground:!0}:{kind:`media-figure`,variant:`image`,slots:{media:n,caption:t.caption}}};function Cp(e,t){return{kind:`feature-split`,variant:t===`left`?`media-left`:`media-right`,slots:{title:e.title,body:e.body?{text:e.body}:void 0,media:{type:`image`,src:e.imageSrc,alt:e.imageAlt??``,width:e.imageWidth,height:e.imageHeight}}}}var wp=e=>Cp(e,`left`),Tp=e=>Cp(e,`right`),Ep=e=>{let t=e;return{kind:`quote-band`,variant:`display`,slots:{body:{text:t.text??``}},emphasis:`strong`,colorScheme:t.colorScheme}},Dp=e=>{let t=e,n=e.contents,r=Ya(n);return{kind:`item-list`,slots:{title:t.title,items:(t.items??[]).map((e,t)=>({body:e,...r[t]?.text===e?{markdown:r[t].markdown}:{}})),media:dp(t.accentImage)},colorScheme:t.colorScheme}},Op=e=>{let t=e,n=t.images??[];return{kind:`gallery`,slots:{...n.length===0?{title:e.title,body:up(e)}:void 0,caption:t.caption,items:n.map(e=>({media:{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}))}}},kp=e=>{let t=e;return{kind:`callout`,variant:`definition`,slots:{title:t.term,body:{text:t.definition??``},meta:t.origin,media:dp(t.accentImage)},colorScheme:t.colorScheme}},Ap=e=>{let t=e;return{kind:`stat-band`,variant:`comparison`,slots:{items:[{title:t.leftLabel,value:t.leftValue},{title:t.rightLabel,value:t.rightValue}],meta:t.unit},emphasis:`strong`,colorScheme:t.colorScheme}},jp=e=>{let t=e,n=t.backgroundImage;return{kind:`quote-band`,variant:`full-bleed`,slots:{body:{text:t.text??``},attribution:t.attribution,media:n?.src?{type:`image`,src:n.src,alt:n.alt??``,credit:n.credit,license:n.license}:void 0},emphasis:`strong`,mediaBackground:!!n?.src}},Mp=e=>{let t=e;return{kind:`media-figure`,variant:`video`,slots:{media:{type:`video`,src:t.videoSrc,posterSrc:t.posterSrc,alt:t.videoAlt??``,clipStart:t.clipStart,clipEnd:t.clipEnd,credit:t.videoCredit,license:t.videoLicense},caption:t.caption}}},Np=e=>{let t=e,n=t.backgroundVideo;return{kind:`quote-band`,variant:`full-bleed`,slots:{body:{text:t.text??``},attribution:t.attribution,media:n?.src?{type:`video`,src:n.src,posterSrc:n.posterSrc,alt:n.alt??``,clipStart:n.clipStart,clipEnd:n.clipEnd,credit:n.credit,license:n.license}:void 0},emphasis:`strong`,mediaBackground:!!n?.src}},Pp=e=>{let t=e;return{kind:`table-section`,slots:{title:t.title,table:{headers:t.headers??[],rows:t.rows??[],align:t.align}},colorScheme:t.colorScheme}},Fp=(e,t)=>{let n=e;return Array.isArray(n.headers)&&Array.isArray(n.rows)&&Zs({headers:n.headers,rows:n.rows},n)!==null?fp(`chart`,t,e):gp(e,t)},Ip={title:pp,sectionHeader:mp,bigText:hp,content:gp,statHighlight:_p,quote:vp,factCard:yp,twoColumn:bp,dateEvent:xp,imageWithCaption:Sp,leftFeature:wp,rightFeature:Tp,map:(e,t)=>fp(`map`,t,e),fullBleedQuote:Ep,list:Dp,photoGrid:Op,definitionCard:kp,comparisonBar:Ap,pullQuote:jp,videoWithCaption:Mp,videoPullQuote:Np,dataTable:Pp,barChart:Fp,columnChart:Fp,pieChart:Fp,donutChart:Fp,lineChart:Fp,areaChart:Fp,scatterChart:Fp,diagram:(e,t)=>fp(`diagram`,t,e),tree:(e,t)=>fp(`tree`,t,e),timeline:(e,t)=>fp(`timeline`,t,e),layout:(e,t)=>fp(`layout`,t,e),drawing:(e,t)=>fp(`drawing`,t,e)};function Lp(e,t){let n=e?.pageStyle??te(e??A);return!t?.spacing||t.spacing===n.tokens.sectionSpacing?n:{...n,tokens:{...n.tokens,sectionSpacing:t.spacing}}}var Rp=new Set([`banner`,`stat-band`,`quote-band`,`callout`,`card-grid`,`item-list`,`timeline-rail`,`footer`]),zp=new Set([`banner`,`quote-band`,`stat-band`,`footer`]),Bp=new Set([`callout`,`card-grid`,`stat-band`,`item-list`,`timeline-rail`,`table-section`]);function Vp(e){return e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`}function Hp(e,t){if(Vp(e))return!0;if(!t||t.length===0||e.type!==`code`)return!1;let n=e.lang?.trim().toLowerCase();return!!n&&t.includes(n)}function Up(e){for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(e.type===`htmlElement`&&typeof e.tagName==`string`&&[`img`,`video`,`audio`].includes(e.tagName.toLowerCase())||Array.isArray(e.children)&&Up(e.children))return!0}return!1}function Wp(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`image`||(t.type===`htmlBlock`||t.type===`htmlInline`)&&Array.isArray(t.htmlChildren)&&Up(t.htmlChildren)?!0:Array.isArray(t.children)&&t.children.some(Wp)}function Gp(e,t,n){if(!e.contents||e.contents.length===0)return;let r=!!t.slots.media||!!t.slots.items?.some(e=>e.media!==void 0),i=e.contents.filter(e=>Hp(e,n)||!r&&Wp(e));if(i.length!==0)return{text:i.map(e=>o(e)).join(`
|
|
34
|
+
`).trim(),markdown:i}}function Kp(e,t,n){let r=Gp(e,t,n);return r?{...t,slots:{...t.slots,richContent:r}}:t}function qp(e,t,n,r){if(sp(e)){let i=lp(e),a=i.templateName,s=Ip[a];if(s)return{draft:Kp(e,s(i.templateBlock,{block:e,viewport:t}),r),source:`template`,templateName:a};let c=n?.find(e=>e.name===a);if(c)return{draft:Kp(e,{kind:`canvas-embed`,variant:`custom`,slots:{media:{type:`canvas`,spatial:`custom`,block:i.templateBlock,aspect:{width:c.viewport?.width??t.width,height:c.viewport?.height??t.height}}}},r),source:`custom-template`,templateName:a};let l={code:`unknown-template`,template:a,message:`Unknown template "${a}"`};return{draft:Kp(e,{kind:`callout`,variant:`diagnostic`,slots:{title:(e.sourceHeading?o(e.sourceHeading):void 0)??l.message,body:{text:Ga(e.contents)},meta:l.message},emphasis:`quiet`},r),source:`fallback`,templateName:a,diagnostic:l}}if(e.layers&&e.layers.length>0)return{draft:Kp(e,{kind:`canvas-embed`,variant:`authored`,slots:{media:{type:`canvas`,spatial:`authored`,block:e,aspect:{width:t.width,height:t.height}}}},r),source:`authored`};let i=e.sourceHeading;return{draft:{kind:`prose`,slots:{title:i?o(i):void 0,headingLevel:i?.depth,body:e.contents&&e.contents.length>0?{text:Ga(e.contents),markdown:e.contents}:void 0}},source:`prose`}}function Jp(e,t,n){let r=n?e.templates?.[n]:void 0,i=e.sections?.[t];return r?i?{...i,...r,hints:{...i.hints,...r.hints}}:r:i}function Yp(e,t,n,r,i,a){let{draft:o,override:s}=e,c={...o.hints,...s?.hints},l={kind:s?.kind??o.kind,variant:s?.variant??o.variant,blockId:e.block?.id??`cover`,template:e.source===`template`||e.source===`custom-template`||e.source===`fallback`?e.templateName:void 0,slots:o.slots,emphasis:i,accent:a,background:r,index:t,totalSections:n,depth:e.depth,source:e.source};return e.diagnostic&&(l.diagnostic=e.diagnostic),Object.keys(c).length>0&&(l.hints=c),l}function Xp(e,t){return t?e.colorSchemes?.[t]:void 0}function Zp(e,t){let n=Object.keys(t.colorSchemes??{}),r=e.accentRotation.schemes;return!r||r.length===0?n:r.filter(e=>n.includes(e))}function Qp(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=Lp(n),a=qp(e,r,t.customTemplates,t.widgetFenceLangs),o=Jp(i,a.draft.kind,a.templateName),s=o?.background??(a.draft.mediaBackground?`media`:`base`),c=o?.emphasis??a.draft.emphasis??`standard`,l=a.draft.colorScheme?{schemeName:a.draft.colorScheme,scheme:Xp(n,a.draft.colorScheme),role:`block`}:{role:i.accentRotation.strategy===`none`?`none`:`primary`};return{section:Yp({...a,override:o,block:e,depth:0},t.blockIndex??0,t.totalBlocks??1,s,c,l),block:e,source:a.source,diagnostic:a.diagnostic}}function $p(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=Lp(n,t.transformPage),a=t.customTemplates??e.customTemplates,s=[];if(t.cover){let e=t.cover;s.push({draft:{kind:`hero`,variant:`cover`,slots:{title:e.title,subtitle:e.subtitle,media:e.heroSrc?{type:`image`,src:e.heroSrc,alt:e.heroAlt??``,credit:e.heroCredit,license:e.heroLicense}:void 0},emphasis:`lead`,mediaBackground:!!e.heroSrc},source:`cover`,depth:0})}let c=(e,n)=>{for(let i of e){let e=qp(i,r,a,t.widgetFenceLangs);s.push({...e,block:i,depth:n}),!(e.draft.kind===`canvas-embed`&&se(e.templateName))&&i.children&&i.children.length>0&&c(i.children,n+1)}};if(c(e.blocks??[],0),t.cover&&s.length>1){let e=t.cover,n=s[1];if(n.draft.kind===`hero`&&n.draft.slots.title===e.title){let e=s[0].draft.slots.media;e&&!n.draft.slots.media&&(n.draft={...n.draft,slots:{...n.draft.slots,media:e},mediaBackground:!0}),s.splice(0,1)}else if(n.draft.kind===`prose`&&n.draft.slots.title===e.title){let t={...n.draft.slots};delete t.title,delete t.headingLevel;let r=t.body?.markdown;e.subtitle&&r&&r.length>0&&r[0].type===`paragraph`&&o(r[0])===e.subtitle&&(r=r.slice(1)),r&&r.length>0?(t.body={text:r.map(e=>o(e)).join(`
|
|
35
|
+
`).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override=Jp(i,e.draft.kind,e.templateName);let l=s.length,u=i.tokens.backgroundRhythm,d=i.accentRotation.strategy,p=Zp(i,n),m=d===`alternate-two`?Math.min(2,p.length):p.length,h=0,g=0,_=0,v=0,y=i.tokens.headingTreatment.eyebrow,b=[];for(let e=0;e<s.length;e++){let r=s[e],i=r.override?.kind??r.draft.kind,a;r.override?.background?a=r.override.background:r.draft.mediaBackground?a=`media`:i===`prose`||u===`flat`?a=`base`:u===`accent-bands`&&zp.has(i)?a=`accent`:u===`tinted-panels`?a=Bp.has(i)?`alternate`:`base`:u===`alternate`||u===`accent-bands`?(a=h%2==1?`alternate`:`base`,h++):a=`base`;let o;if(r.draft.colorScheme)o={schemeName:r.draft.colorScheme,scheme:Xp(n,r.draft.colorScheme),role:`block`};else if(Rp.has(i)&&(d===`cycle`||d===`alternate-two`)&&m>0){let e=p[g%m];g++,o={schemeName:e,scheme:Xp(n,e),role:`rotation`}}else o=d===`none`?{role:`none`}:{role:`primary`};let c=r.override?.emphasis??r.draft.emphasis??`standard`;t.transformPage?.emphasisCurve===`front-loaded`&&i!==`hero`&&i!==`prose`&&_<2&&(c===`standard`&&(c=`strong`),_++),(y===`numbered`||y===`mono-tag`)&&(i===`hero`||i===`banner`)&&(v++,r.draft.slots.eyebrow||(r.draft.slots={...r.draft.slots,eyebrow:String(v).padStart(2,`0`)}));let f=Yp(r,e,l,a,c,o);b.push({section:f,block:r.block,source:r.source,diagnostic:r.diagnostic})}return b}var em=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E")`;function tm(e,t){let n=e??A,r=t??Lp(n),i=n.colors,a=n.typography;return{"--squisq-page-bg":i.background,"--squisq-page-bg-alt":i.backgroundLight,"--squisq-page-text":i.text,"--squisq-page-text-muted":i.textMuted,"--squisq-page-primary":i.primary,"--squisq-page-secondary":i.secondary,"--squisq-page-highlight":i.highlight,"--squisq-page-title-font":w(a.titleFont,`Georgia, serif`),"--squisq-page-body-font":w(a.bodyFont,`system-ui, sans-serif`),"--squisq-page-mono-font":w(a.monoFont,`ui-monospace, SFMono-Regular, Menlo, monospace`),"--squisq-page-line-height":String(a.lineHeight??1.65),"--squisq-page-title-weight":a.titleWeight===`normal`?`400`:`700`,"--squisq-page-content-max":`${r.tokens.contentMaxWidth}px`,"--squisq-page-wide-max":`${r.tokens.wideMaxWidth}px`,"--squisq-page-radius":`${r.tokens.cornerRadius}px`,"--squisq-page-accent":i.primary,"--squisq-page-accent-bg":i.backgroundLight,"--squisq-page-accent-text":i.text}}function nm(e){let t=e.tokens,n={"data-family":e.family,"data-spacing":t.sectionSpacing,"data-divider":t.divider,"data-rhythm":t.backgroundRhythm,"data-hero-style":t.heroStyle,"data-eyebrow":t.headingTreatment.eyebrow,"data-heading-scale":t.headingTreatment.scale,"data-framing":t.imageFraming,"data-shadow":t.shadow,"data-quote-mark":t.quoteMark,"data-numerals":t.numeralStyle};return t.headingTreatment.case&&t.headingTreatment.case!==`none`&&(n[`data-heading-case`]=t.headingTreatment.case),t.headingTreatment.underline&&t.headingTreatment.underline!==`none`&&(n[`data-underline`]=t.headingTreatment.underline),t.pattern&&t.pattern!==`none`&&(n[`data-pattern`]=t.pattern),n}var rm=`
|
|
36
36
|
.squisq-page-hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
|
|
37
37
|
.squisq-page-feature { grid-template-columns: 1fr; }
|
|
38
38
|
.squisq-page-feature--media-right .squisq-page-feature-media { order: 0; }
|
|
@@ -42,7 +42,7 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
42
42
|
.squisq-page-milestone { grid-template-columns: 1fr; gap: 0.5rem; }
|
|
43
43
|
.squisq-page-milestone-rail { display: none; }
|
|
44
44
|
.squisq-page-section-inner { padding-inline: 18px; }
|
|
45
|
-
`,
|
|
45
|
+
`,im=`
|
|
46
46
|
/* \u2500\u2500 Base \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
47
47
|
.squisq-page {
|
|
48
48
|
background: var(--squisq-page-bg);
|
|
@@ -78,7 +78,7 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
78
78
|
transparent 1px 14px
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
|
-
.squisq-page[data-pattern='noise'] { background-image: ${
|
|
81
|
+
.squisq-page[data-pattern='noise'] { background-image: ${em}; }
|
|
82
82
|
|
|
83
83
|
/* Spacing scale */
|
|
84
84
|
.squisq-page[data-spacing='compact'] { --squisq-page-section-pad: 2.25rem; }
|
|
@@ -562,22 +562,22 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
562
562
|
|
|
563
563
|
/* \u2500\u2500 Responsive \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
564
564
|
@container squisq-page (max-width: 720px) {
|
|
565
|
-
${
|
|
565
|
+
${rm}
|
|
566
566
|
}
|
|
567
567
|
@supports not (container-type: inline-size) {
|
|
568
568
|
@media (max-width: 720px) {
|
|
569
|
-
${
|
|
569
|
+
${rm}
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
`;function
|
|
572
|
+
`;function am(e){let t=tm(e);return`.squisq-page {
|
|
573
573
|
${Object.entries(t).map(([e,t])=>` ${e}: ${t};`).join(`
|
|
574
574
|
`)}
|
|
575
575
|
}
|
|
576
|
-
${tm}`}var rm=.5,im=.8,am=1;function om(e){let t=e.title?e.title.trim():``,n=wd(e);return t&&n?`${t}
|
|
577
|
-
${n}`:t||n}function
|
|
578
|
-
`)}function
|
|
579
|
-
`).map(e=>e.trim()).filter(e=>e.length>0)}function
|
|
580
|
-
`)}};function ch(e,t,n){let{rect:r,labelLines:i,isContainer:a}=t,o=r.c1-r.c0-1;e.set(r.r0,r.c0,n.tl,`border`),e.set(r.r0,r.c1,n.tr,`border`);let s=a&&i.length>0?Ue(` ${i[0]} `):null;if(s&&s.length<=o-2){let t=Math.floor((o-s.length)/2);for(let i=0;i<o;i++){let a=i>=t&&i<t+s.length,o=a?s[i-t]:n.h;e.set(r.r0,r.c0+1+i,o,a?`label`:`border`)}}else for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r0,t,n.h,`border`);e.set(r.r1,r.c0,n.bl,`border`),e.set(r.r1,r.c1,n.br,`border`);for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r1,t,n.h,`border`);for(let t=r.r0+1;t<=r.r1-1;t++)e.set(t,r.c0,n.v,`border`),e.set(t,r.c1,n.v,`border`);let c=a?i.slice(1):i;if(c.length>0){let t=r.r1-r.r0-1,n=a?r.r0+1:r.r0+1+Math.max(0,Math.floor((t-c.length)/2));c.forEach((t,i)=>{let a=Ue(t),s=Math.max(0,Math.floor((o-a.length)/2));for(let t=0;t<a.length&&s+t<o;t++)e.set(n+i,r.c0+1+s+t,a[t],`label`)})}}function lh(e,t,n,r){let i=[...t].sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),a=new Set,o=[];for(let e=0;e<i.length;e++){if(a.has(e))continue;let t=i[e];if(!n.has(t.source)||!n.has(t.target))continue;let r=!1;if(t.directed){let n=i.findIndex((n,r)=>r>e&&!a.has(r)&&n.directed&&n.source===t.target&&n.target===t.source&&(n.label??``)===(t.label??``));n>=0&&(a.add(n),r=!0)}let s=uh(n.get(t.source).rect,n.get(t.target).rect);o.push({edge:t,sourceId:t.source,targetId:t.target,exitSide:s.exit,enterSide:s.enter,biDir:r})}let s=dh(o,n),c=[];o.forEach((t,i)=>fh(e,t,i,n,s,r,(e,t)=>c.push({candidates:e,label:t})));for(let t of c){let n=Ue(t.label),r=!1;for(let i of[`right`,`left`]){if(r)break;for(let{row:a,col:o}of t.candidates){if(e.kindAt(a,o)!==`line-v`)continue;let t=i===`right`?o+2:o-1-n.length;if(t<0)continue;let s=i===`right`?o+1:o-1,c=e.kindAt(a,s)===`empty`;for(let r=0;c&&r<n.length;r++)e.kindAt(a,t+r)!==`empty`&&(c=!1);if(c&&i===`left`&&t>0&&(c=e.kindAt(a,t-1)===`empty`),c){for(let r=0;r<n.length;r++)e.set(a,t+r,n[r],`label`);r=!0;break}}}}}function uh(e,t){if(t.r0>e.r1)return{exit:`bottom`,enter:`top`};if(t.r1<e.r0)return{exit:`top`,enter:`bottom`};if(t.c0>e.c1)return{exit:`right`,enter:`left`};if(t.c1<e.c0)return{exit:`left`,enter:`right`};let n=[{side:`top`,gap:Math.abs(e.r0-t.r0)},{side:`bottom`,gap:Math.abs(t.r1-e.r1)},{side:`left`,gap:Math.abs(e.c0-t.c0)},{side:`right`,gap:Math.abs(t.c1-e.c1)}];return n.sort((e,t)=>e.gap-t.gap),{exit:n[0].side,enter:n[0].side}}function dh(e,t){let n=new Map;e.forEach((e,t)=>{let r=`${e.sourceId}|${e.exitSide}`,i=`${e.targetId}|${e.enterSide}`;n.set(r,[...n.get(r)??[],{key:`${t}:exit`,otherId:e.targetId}]),n.set(i,[...n.get(i)??[],{key:`${t}:enter`,otherId:e.sourceId}])});let r=new Map;for(let[e,i]of[...n.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let[n,a]=e.split(`|`),o=t.get(n);i.sort((e,n)=>{let r=t.get(e.otherId).rect,i=t.get(n.otherId).rect;return r.r0-i.r0||r.c0-i.c0||e.otherId.localeCompare(n.otherId)});let s=a===`top`||a===`bottom`,c=s?o.rect.c0+1:o.rect.r0+1,l=s?o.rect.c1-1:o.rect.r1-1,u=Math.max(1,l-c+1),d=i.length;if(d===1)r.set(i[0].key,{pos:c+Math.floor((u-1)/2),index:0,count:1});else{let e=2*d-1,t=c+Math.max(0,Math.floor((u-e)/2));i.forEach((e,n)=>{r.set(e.key,{pos:Math.min(l,t+2*n),index:n,count:d})})}}return r}function fh(e,t,n,r,i,a,o){let s=r.get(t.sourceId).rect,c=r.get(t.targetId).rect,l=i.get(`${n}:exit`),u=i.get(`${n}:enter`),d=l.pos,f=u.pos,p=u.count>l.count?u:l,m=p.index-Math.floor((p.count-1)/2),h={canvas:e,directed:t.edge.directed,biDir:t.biDir,label:Qm(t.edge.label),vocab:a,junction:(t,n,r)=>{let i=r===`top`?a.stemUp:r===`bottom`?a.stemDown:r===`left`?a.stemLeft:a.stemRight;e.set(t,n,i,`junction`)},stagger:m,deferSideLabel:o};t.exitSide===`bottom`&&t.enterSide===`top`?hh(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?hh(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?gh(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?gh(h,s,c,d,f,-1):_h(h,s,c,t.exitSide)}function ph(e,t){let n=Math.min(e,t),r=Math.max(e,t),i=[];for(let e=n;e<=r;e++)i.push(e);let a=Math.floor((n+r)/2);return i.sort((e,t)=>Math.abs(e-a)-Math.abs(t-a)||e-t)}function mh(e,t,n){return Math.max(t,Math.min(n,e))}function hh(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d,stagger:f}=e,p=a===1?t.r1:t.r0,m=a===1?n.r0:n.r1,h=p+a,g=m-a,_=(g-h)*a+1,v=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);for(let t=r;t<=i;t++)o.drawEdgeCell(t,e,u.v,`line-v`,u)};if(r>=n.c0+1&&r<=n.c1-1&&r>=t.c0+1&&r<=t.c1-1||_<2){let i=mh(r,t.c0+1,t.c1-1),f=mh(r,n.c0+1,n.c1-1);d(p,i,a===1?`bottom`:`top`),d(m,f,a===1?`top`:`bottom`),i===f&&_>=1&&(v(i,h,g),s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&_>=2&&o.drawEdgeCell(h,i,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&e.deferSideLabel(ph(h,g).map(e=>({row:e,col:i})),l));return}let y=mh(Math.floor((p+m)/2)+f,Math.min(h,g),Math.max(h,g));d(p,r,a===1?`bottom`:`top`),d(m,i,a===1?`top`:`bottom`),Math.abs(y-p)>=2&&v(r,h,y-a),Math.abs(m-y)>=2&&v(i,y+a,g);let b=!1;if(r===i)o.drawEdgeCell(y,r,u.v,`line-v`,u);else{let e=i>r,t=a===1?e?u.turnUpRight:u.turnUpLeft:e?u.turnDownRight:u.turnDownLeft,n=a===1?e?u.turnDownLeft:u.turnDownRight:e?u.turnUpLeft:u.turnUpRight;o.drawEdgeCell(y,r,t,`turn`,u),o.drawEdgeCell(y,i,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i),d=[];for(let e=s+1;e<=c-1;e++)d.push(u.h);let f=l?Ue(` ${l} `):null;if(f&&$m(f)&&d.length>=f.length+2){let e=Math.floor((d.length-f.length)/2);d=d.map((t,n)=>n>=e&&n<e+f.length?f[n-e]:t),b=!0}d.forEach((e,t)=>{o.drawEdgeCell(y,s+1+t,e,e===u.h?`line-h`:`label`,u)})}if(s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&o.drawEdgeCell(h,r,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&!b){let t=[];if(r===i)for(let e of ph(h,g))t.push({row:e,col:r});else{let e=(y-a-h)*a+1,n=(g-(y+a))*a+1;if(e>=1)for(let e of ph(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of ph(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function gh(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d}=e,f=a===1?t.c1:t.c0,p=a===1?n.c0:n.c1,m=f+a,h=p-a,g=(h-m)*a+1,_=(e,t,n,r,i=0,a=0)=>{let s=Math.min(t,n),c=Math.max(t,n),d=[];for(let e=s;e<=c;e++)d.push(u.h);let f=r&&l?Ue(` ${l} `):null;if(f&&$m(f)){let e=i,t=d.length-1-a-e+1;if(t>=f.length+2){let n=e+Math.floor((t-f.length)/2);d=d.map((e,t)=>t>=n&&t<n+f.length?f[t-n]:e)}}d.forEach((t,n)=>{o.drawEdgeCell(e,s+n,t,t===u.h?`line-h`:`label`,u)})};if(r>=n.r0+1&&r<=n.r1-1&&r>=t.r0+1&&r<=t.r1-1||g<2){let e=mh(r,t.r0+1,t.r1-1),i=mh(r,n.r0+1,n.r1-1);d(e,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),e===i&&g>=1&&(_(e,m,h,!0,(a===1?c:s)?1:0,(a===1?s:c)?1:0),s&&o.drawEdgeCell(e,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&g>=2&&o.drawEdgeCell(e,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u));return}let v=mh(Math.floor((f+p)/2)+e.stagger,Math.min(m,h),Math.max(m,h));if(d(r,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),Math.abs(v-f)>=2&&_(r,m,v-a,!0,a===1&&c?1:0,a===-1&&c?1:0),Math.abs(p-v)>=2&&_(i,v+a,h,!1),r===i)o.drawEdgeCell(r,v,u.h,`line-h`,u);else{let e=i>r,t=a===1?e?u.turnDownLeft:u.turnUpLeft:e?u.turnDownRight:u.turnUpRight,n=a===1?e?u.turnUpRight:u.turnDownRight:e?u.turnUpLeft:u.turnDownLeft;o.drawEdgeCell(r,v,t,`turn`,u),o.drawEdgeCell(i,v,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i);for(let e=s+1;e<=c-1;e++)o.drawEdgeCell(e,v,u.v,`line-v`,u)}s&&o.drawEdgeCell(i,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&o.drawEdgeCell(r,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u)}function _h(e,t,n,r){let{canvas:i,directed:a,vocab:o,junction:s}=e;if(r===`top`||r===`bottom`){let e=Math.max(t.c0+1,n.c0+1),c=Math.min(t.c1-1,n.c1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`top`?t.r0:t.r1,d=r===`top`?n.r0:n.r1;if(u===d)return;s(u,l,r),s(d,l,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(e,l,o.v,`line-v`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(e,l,d>u?o.arrowDown:o.arrowUp,`arrow`,o)}}else{let e=Math.max(t.r0+1,n.r0+1),c=Math.min(t.r1-1,n.r1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`left`?t.c0:t.c1,d=r===`left`?n.c0:n.c1;if(u===d)return;s(l,u,r),s(l,d,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(l,e,o.h,`line-h`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(l,e,d>u?o.arrowRight:o.arrowLeft,`arrow`,o)}}}var vh=2,yh=8,bh=12,xh=4,Sh=4;function Ch(e){return!an(e).isDiagram&&Th(At(jt(e),!0)).length>=vh}function wh(e){let t=jt(e),n=Th(At(t,!0));if(n.length<vh)return null;let r=Eh(t,n),i={nodes:r,edges:Ah(t,n,r),style:Fh(t),warnings:[`repaired`]};return{diagram:i,art:th(i)}}function Th(e){let t=new Set,n=[];for(let r of e){let e=`${r.r0},${r.c0},${r.r1},${r.c1}`;t.has(e)||(t.add(e),n.push(r))}return n.sort((e,t)=>e.r0-t.r0||e.c0-t.c0)}function Eh(e,t){let n=e[0]?.length??0,r=t.map(()=>[]),i=new Map(t.map((e,t)=>[e,t])),a=[];for(let e of t){let t=a.find(t=>t.some(t=>t.r0<=e.r1&&e.r0<=t.r1));t||(t=[],a.push(t)),t.push(e)}for(let t of a){t.sort((e,t)=>e.c0-t.c0);let a=Math.min(...t.map(e=>e.r0+1)),o=Math.max(...t.map(e=>e.r1-1));for(let s=a;s<=o;s++){let a=t.filter(e=>s>e.r0&&s<e.r1);if(a.length===0)continue;let o=e[s].join(``).split(/[│┃║]/).map(Dh).filter(e=>e.length>0);if(o.length===a.length)a.forEach((e,t)=>{let n=i.get(e);n!==void 0&&o[t]&&r[n].push(o[t])});else for(let t of a){let a=i.get(t);if(a===void 0)continue;let o=Dh(e[s].slice(t.c0+1,Math.min(t.c1,n)).join(``));o&&r[a].push(o)}}}let o=new Map,s=[...a].sort((e,t)=>Math.min(...e.map(e=>e.r0))-Math.min(...t.map(e=>e.r0))),c=0;for(let e of s){o.set(e,c);let t=Math.max(...e.map(e=>e.r1-e.r0+1));c+=t+xh}let l=new Map;for(let e of a)for(let t of e)l.set(t,e);let u=t.map((e,t)=>Math.max(e.c1-e.c0+1,...r[t].map(e=>e.length+4),3)),d=new Map(t.map((e,t)=>[e,t])),f=new Map;for(let e of a){let t=[...e].sort((e,t)=>e.c0-t.c0),n=Math.min(...e.map(e=>e.c0));for(let e of t)f.set(e,n),n+=(u[d.get(e)??0]??3)+Sh}let p=t.map((e,n)=>Oh(t,n)),m=new Map,h=t.map((e,t)=>{let n=kh(r[t][0]??``),i=m.get(n)??0;m.set(n,i+1),i>0&&(n=`${n}-${i+1}`);let a=l.get(e),s=p[t]>=0,c=a&&!s?o.get(a)??e.r0:e.r0,u=s?e.c0:f.get(e)??e.c0;return{id:n,label:r[t].join(`
|
|
581
|
-
`),col:u,row:c,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1}});return h.forEach((e,t)=>{p[t]>=0&&(e.containerId=h[p[t]].id)}),h}function
|
|
582
|
-
`)}function
|
|
583
|
-
`)}var
|
|
576
|
+
${im}`}var om=[1,1.5,2];function sm(e){let t=typeof e==`number`?e:typeof e==`string`?Number(e.trim().replace(/%$/,``)):NaN;if(!Number.isFinite(t))return;let n=t>3?t/100:t;return om.find(e=>Math.abs(e-n)<.001)}var cm=new Set([`content`,`list`,`quote`,`definitionCard`,`factCard`,`dateEvent`]),lm=160,um=360;function dm(e){return!e.template||!cm.has(e.template)?1:e.textLength<lm?2:e.textLength<um?1.5:1}function fm(e,t){let n=e.map(e=>e.explicit===void 0?t===`auto`?dm(e):1:e.explicit),r=new Map;if(e.forEach((e,t)=>{let i=n[t];if(i===1)return;let a=e.explicit===void 0?1:2;r.set(i,(r.get(i)??0)+a)}),r.size<=1)return n;let i=2,a=-1;for(let[e,t]of r)(t>a||t===a&&e>i)&&(i=e,a=t);return e.map((e,t)=>e.explicit===void 0?n[t]===1?1:i:e.explicit)}var pm=32,mm=64,hm=/^[a-z0-9][a-z0-9-]*$/;function gm(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim().replace(/%$/,``);if(t.length===0)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function _m(e){return`${Math.round(e*1e3)/1e3}%`}function vm(e,t,n){if(!e||typeof e!=`object`){n.push({path:t,message:`cell must be an object`});return}let r=e,i=gm(r.x),a=gm(r.y),o=gm(r.width),s=gm(r.height);if(i===void 0||i<0||i>100){n.push({path:`${t}.x`,message:`x must be a percent between 0 and 100`});return}if(a===void 0||a<0||a>100){n.push({path:`${t}.y`,message:`y must be a percent between 0 and 100`});return}if(o===void 0||o<=0||o>100){n.push({path:`${t}.width`,message:`width must be a percent greater than 0`});return}if(s===void 0||s<=0||s>100){n.push({path:`${t}.height`,message:`height must be a percent greater than 0`});return}let c={x:_m(i),y:_m(a),width:_m(o),height:_m(s)};if(r.block!==void 0){let e=typeof r.block==`string`?Number(r.block):r.block;if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>mm){n.push({path:`${t}.block`,message:`block must be an integer between 1 and ${mm}`});return}c.block=e}if(r.zoom!==void 0){let e=sm(r.zoom);if(e===void 0){n.push({path:`${t}.zoom`,message:`zoom must be 1, 1.5, or 2 (or 100/150/200 percent)`});return}c.zoom=e}return c}function ym(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`must be an array of cells`});return}if(e.length<1||e.length>pm){n.push({path:t,message:`must contain between 1 and ${pm} cells`});return}let r=[];for(let i=0;i<e.length;i++){let a=vm(e[i],`${t}[${i}]`,n);if(!a)return;r.push(a)}return r}function bm(e,t){if(!e||typeof e!=`object`){t.push({path:`titleSlot`,message:`titleSlot must be an object`});return}let n=e,r=n.placement===`bottom`?`bottom`:n.placement===`top`?`top`:void 0;if(r===void 0&&n.placement!==void 0){t.push({path:`titleSlot.placement`,message:`placement must be 'top' or 'bottom'`});return}let i=gm(n.height);if(i===void 0||i<=0||i>40){t.push({path:`titleSlot.height`,message:`height must be a percent between 0 and 40`});return}return{placement:r??`top`,height:_m(i)}}function xm(e){let t=[];if(!e||typeof e!=`object`)return{valid:!1,errors:[{path:``,message:`definition must be an object`}]};let n=e,r=typeof n.name==`string`?n.name.trim().toLowerCase():``;hm.test(r)||t.push({path:`name`,message:`name must be a slug (lowercase letters, digits, hyphens)`});let i=typeof n.label==`string`?n.label.trim():``;i.length===0&&t.push({path:`label`,message:`label must be a non-empty string`});let a=n.cells,o,s,c;!a||typeof a!=`object`?t.push({path:`cells`,message:`cells must be an object with a landscape array`}):(o=ym(a.landscape,`cells.landscape`,t),a.portrait!==void 0&&(s=ym(a.portrait,`cells.portrait`,t)),a.square!==void 0&&(c=ym(a.square,`cells.square`,t)),o&&(s&&s.length!==o.length&&t.push({path:`cells.portrait`,message:`portrait must define the same number of cells as landscape`}),c&&c.length!==o.length&&t.push({path:`cells.square`,message:`square must define the same number of cells as landscape`})));let l;if(n.titleSlot!==void 0&&(l=bm(n.titleSlot,t)),t.length>0||!o)return{valid:!1,errors:t};let u={name:r,label:i,cells:{landscape:o,...s?{portrait:s}:{},...c?{square:c}:{}}};return typeof n.description==`string`&&n.description.trim()&&(u.description=n.description.trim()),l&&(u.titleSlot=l),n.auto===!1&&(u.auto=!1),{valid:!0,errors:t,layout:u}}function Sm(e){return e.cells.landscape.length}function Cm(e){return e.map(e=>({x:e.y,y:e.x,width:e.height,height:e.width,...e.block===void 0?{}:{block:e.block},...e.zoom===void 0?{}:{zoom:e.zoom}}))}function wm(e,t,n){return(t===`portrait`?e.cells.portrait??Cm(e.cells.landscape):t===`square`?e.cells.square??e.cells.landscape:e.cells.landscape).map(e=>{let t=gm(e.x)??0,r=gm(e.y)??0,i=gm(e.width)??0,a=gm(e.height)??0,o={rect:{x:n.x+t/100*n.width,y:n.y+r/100*n.height,width:Math.max(1,i/100*n.width),height:Math.max(1,a/100*n.height)}};e.block!==void 0&&(o.block=e.block);let s=sm(e.zoom);return s!==void 0&&(o.zoom=s),o})}var Tm=`squisq-dashboard-layouts`,Em={label:`lb`,description:`ds`,cells:`ce`,landscape:`ls`,portrait:`pt`,square:`sq`,width:`wd`,height:`hg`,block:`bk`,zoom:`zo`,titleSlot:`ts`,placement:`pl`,auto:`au`},Dm=Object.fromEntries(Object.entries(Em).map(([e,t])=>[t,e]));function Om(e,t){if(Array.isArray(e))return e.map(e=>Om(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=Om(i,t);return n}return e}function km(e){if(!e)return;let t=Pm(e[Tm]);if(!t)return;let n=[];for(let e of t){let t=xm(e);t.layout&&n.push(t.layout)}return n.length>0?n:void 0}function Am(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let{name:e,...r}=t;n[e]=Om(r,Em)}return JSON.stringify(n,null,t?.pretty?2:void 0)}function jm(e){return Object.entries(e).map(([e,t])=>({name:e,...Om(t&&typeof t==`object`?t:{},Dm)}))}function Mm(e){return Array.isArray(e)?e:e&&typeof e==`object`?jm(e):null}function Nm(e){try{return JSON.parse(e)}catch{return}}function Pm(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return jm(e);if(typeof e!=`string`)return null;let t=Nm(e.trim());return t===void 0?null:Mm(t)}var Fm=2;function $(e){return`${Math.round(e*1e3)/1e3}%`}function Im(e,t,n=Fm){let r=(100-(e-1)*n)/e,i=(100-(t-1)*n)/t,a=[];for(let o=0;o<t;o++)for(let t=0;t<e;t++)a.push({x:$(t*(r+n)),y:$(o*(i+n)),width:$(r),height:$(i)});return a}function Lm(e,t,n=Fm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:$(e),height:`100%`}];for(let e=0;e<t;e++)o.push({x:$(r),y:$(e*(a+n)),width:$(i),height:$(a)});return o}function Rm(e,t,n=Fm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:`100%`,height:$(e)}];for(let e=0;e<t;e++)o.push({x:$(e*(a+n)),y:$(r),width:$(a),height:$(i)});return o}function zm(e,t=Fm){let n=e+t,r=(100-n-t)/2,i=(100-t)/2,a=[{x:`0%`,y:`0%`,width:$(e),height:`100%`}];for(let e=0;e<2;e++)for(let o=0;o<2;o++)a.push({x:$(n+o*(r+t)),y:$(e*(i+t)),width:$(r),height:$(i)});return a}var Bm=Object.freeze([{name:`focus-1`,label:`Focus`,description:`One block fills the dashboard.`,cells:{landscape:[{x:`0%`,y:`0%`,width:`100%`,height:`100%`}]}},{name:`split-2`,label:`Split`,description:`Two blocks side by side.`,cells:{landscape:Im(2,1)}},{name:`hero-left`,label:`Hero + 2`,description:`A large lead block with two companions.`,cells:{landscape:Lm(58,2),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(46)},{x:`0%`,y:$(48),width:`100%`,height:$(25)},{x:`0%`,y:$(75),width:`100%`,height:$(25)}]}},{name:`grid-2x2`,label:`Grid 2×2`,description:`Four blocks in a balanced grid.`,cells:{landscape:Im(2,2)}},{name:`hero-top`,label:`Hero band`,description:`A wide lead band with three blocks below.`,cells:{landscape:Rm(46,3),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(40)},{x:`0%`,y:$(42),width:`100%`,height:$(18)},{x:`0%`,y:$(62),width:`100%`,height:$(18)},{x:`0%`,y:$(82),width:`100%`,height:$(18)}]},auto:!1},{name:`mosaic-5`,label:`Mosaic`,description:`A hero block beside a 2×2 grid.`,cells:{landscape:zm(58),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(40)},{x:`0%`,y:$(42),width:$(49),height:$(27)},{x:$(51),y:$(42),width:$(49),height:$(27)},{x:`0%`,y:$(71),width:$(49),height:$(29)},{x:$(51),y:$(71),width:$(49),height:$(29)}]}},{name:`grid-3x2`,label:`Grid 3×2`,description:`Six blocks in three columns.`,cells:{landscape:Im(3,2)}},{name:`grid-3x3`,label:`Grid 3×3`,description:`Nine blocks in a square grid.`,cells:{landscape:Im(3,3),square:Im(3,3)}},{name:`grid-4x3`,label:`Grid 4×3`,description:`Twelve blocks in four columns.`,cells:{landscape:Im(4,3)}},{name:`grid-4x4`,label:`Grid 4×4`,description:`Sixteen blocks — the densest wall.`,cells:{landscape:Im(4,4)}}]);function Vm(e,t){return{id:e.name,label:e.label,...e.description?{description:e.description}:{},capacity:Sm(e),custom:t}}function Hm(){return Bm.map(e=>Vm(e,!1))}function Um(e){let t=km(e?.frontmatter)??[],n=new Set(t.map(e=>e.name));return[...t.map(e=>Vm(e,!0)),...Bm.filter(e=>!n.has(e.name)).map(e=>Vm(e,!1))]}var Wm=`auto`;function Gm(e,t){let n=e.trim().toLowerCase();if(n)return t?.find(e=>e.name===n)??Bm.find(e=>e.name===n)}function Km(e,t,n){let r=[...(n??[]).filter(e=>e.auto!==!1),...Bm.filter(e=>e.auto!==!1)].sort((e,t)=>Sm(e)-Sm(t)),i=Math.max(1,e),a=r.find(e=>Sm(e)>=i);if(a)return a;let o=r.reduce((e,t)=>Math.max(e,Sm(t)),0);return r.find(e=>Sm(e)===o)??Bm[0]}var qm=[`basic`,`card`,`panel`,`accent`],Jm=`basic`,Ym=Object.freeze([{id:`basic`,label:`Basic`,description:`Blocks fill their cells edge to edge.`},{id:`card`,label:`Cards`,description:`Each block sits on a raised, rounded card.`},{id:`panel`,label:`Panels`,description:`Flat outlined panels with an accent rule.`},{id:`accent`,label:`Accent cards`,description:`Cards tinted with the theme's accent colors in rotation.`}]);function Xm(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`none`||t==="default"||t===`flat`?`basic`:t===`cards`?`card`:t===`panels`||t===`outline`?`panel`:t===`accents`||t===`accent-cards`?`accent`:qm.includes(t)?t:void 0}function Zm(e,t,n){return Math.min(n,Math.max(t,e))}function Qm(e){return x(e)>.45}function $m(e,t){let n=t.colors.background;return e===`basic`||e===`panel`?n:Qm(n)?b(n,.05):re(n,.04)}function eh(e,t){let n=Object.values(e.colorSchemes??{});if(n.length===0)return e.colors.primary;let r=n[(t%n.length+n.length)%n.length];return r.accent||r.text||e.colors.primary}function th(e,t,n){let r=Math.max(1,Math.min(n.width,n.height)),i=t.style?.borderRadius??14;return e===`panel`?{edge:Zm(r*.014,3,12),radius:Zm(i*.45,0,r*.05)}:{edge:Zm(r*.03,6,26),radius:Zm(i,6,r*.1)}}function nh(e,t){if(!(e<=0))return`${Math.round(e/Math.max(1,t.width)*1e5)/1e3}% / ${Math.round(e/Math.max(1,t.height)*1e5)/1e3}%`}function rh(e,t){let{theme:n,rect:r,index:i}=t;if(e===`basic`)return null;let{edge:a,radius:o}=th(e,n,r),s={x:r.x+a,y:r.y+a,width:Math.max(1,r.width-a*2),height:Math.max(1,r.height-a*2)},c={x:a,y:a,width:s.width,height:s.height},l=Math.max(1,Math.min(r.width,r.height)),u=Math.max(1,Math.round(l*.004)),d=eh(n,i),f=[];e!==`panel`&&[{spread:.45,dy:.5,alpha:.05},{spread:.25,dy:.42,alpha:.05},{spread:.08,dy:.3,alpha:.06}].forEach((e,t)=>{let r=a*e.spread,i=a*e.dy;f.push({type:`shape`,id:`cell-shadow-${t}`,content:{shape:`rect`,fill:C(n.colors.text,e.alpha),borderRadius:o+r},position:{x:c.x-r,y:c.y-r+i,width:c.width+r*2,height:c.height+r*2}})}),f.push({type:`shape`,id:`cell-surface`,content:{shape:`rect`,fill:n.colors.background,borderRadius:o},position:{x:c.x,y:c.y,width:c.width,height:c.height}});let p=[];if(e===`accent`&&p.push({type:`shape`,id:`cell-accent-wash`,content:{shape:`rect`,fill:C(d,.1),borderRadius:o},position:{x:0,y:0,width:`100%`,height:`100%`}}),e===`accent`||e===`panel`){let e=Math.max(2,Math.round(l*.014));p.push({type:`shape`,id:`cell-accent-bar`,content:{shape:`rect`,fill:d},position:{x:0,y:0,width:`100%`,height:e}})}let m=e===`panel`?u:Math.max(1,u*.6);p.push({type:`shape`,id:`cell-border`,content:{shape:`rect`,fill:`none`,stroke:e===`panel`?C(d,.45):C(n.colors.text,.14),strokeWidth:m,borderRadius:o},position:{x:m/2,y:m/2,width:Math.max(1,c.width-m),height:Math.max(1,c.height-m)}});let h={cardRect:s,contentRect:s,layers:f,overlayLayers:p,radius:o},g=nh(o,s);return g&&(h.contentRadiusPct=g),h}function ih(e){return e!==`basic`}function ah(e,t){let n=e[0];if(!n||n.type!==`shape`)return[...e];let{content:r,position:i}=n,a=typeof r.fill==`string`?r.fill.trim().toLowerCase():``;return!(r.shape===`rect`&&(i.x===0||i.x===`0%`)&&(i.y===0||i.y===`0%`)&&i.width===`100%`&&i.height===`100%`)||r.gradient||r.pattern||a!==t.colors.background.trim().toLowerCase()?[...e]:e.slice(1)}var oh=Object.freeze({layout:{canonical:`squisq-dashboard-layout`,legacy:`dashboard-layout`},showTitle:{canonical:`squisq-dashboard-title`,legacy:`dashboard-title`},zoom:{canonical:`squisq-dashboard-zoom`,legacy:`dashboard-zoom`},style:{canonical:`squisq-dashboard-style`,legacy:`dashboard-style`}}),sh=Object.freeze({layout:Wm,showTitle:!0,zoom:`auto`,style:Jm});function ch(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function lh(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function uh(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`auto`||t==="default"?Wm:t}function dh(e){if(typeof e==`boolean`)return e?`auto`:`off`;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`auto`,`on`,`true`,`yes`].includes(t))return`auto`;if([`off`,`false`,`no`,`none`,`100`,`100%`,`1`].includes(t))return`off`}function fh(e,t={}){let n={layout:uh(ch(e,oh.layout))??sh.layout,showTitle:lh(ch(e,oh.showTitle))??sh.showTitle,zoom:dh(ch(e,oh.zoom))??sh.zoom,style:Xm(ch(e,oh.style))??sh.style};return{layout:uh(t.layout)??n.layout,showTitle:t.showTitle??n.showTitle,zoom:t.zoom??n.zoom,style:Xm(t.style)??n.style}}var ph={placement:`top`,height:`9%`},mh=.015,hh=.02;function gh(e){let t=Number(e.trim().replace(/%$/,``));return Number.isFinite(t)?t:0}function _h(e,t){return`${Math.round(e/Math.max(1,t)*1e5)/1e3}%`}function vh(e,t){return{left:_h(e.x,t.width),top:_h(e.y,t.height),width:_h(e.width,t.width),height:_h(e.height,t.height)}}function yh(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function bh(e,t){if(e.length===0||!t)return e;let n=e[0],r=typeof n.title==`string`?n.title.trim().toLowerCase():``;if(!r||r!==t.trim().toLowerCase())return e;let i=n.template,a=i===`title`||i===`sectionHeader`||i===`cover`,o=Array.isArray(n.contents)&&n.contents.length>0;return a||!o?e.slice(1):e}function xh(e,t,n,r,i,a){let o=p(r,0,1,i),s=h(i),c=Math.min(44*s,t.height*.52),l=Math.max(4,Math.round(6*s)),u=a+l+Math.max(10,Math.round(l*2.5));return[{type:`shape`,id:`dashboard-title-accent`,content:{shape:`rect`,fill:r.colors.primary},position:{x:a,y:`26%`,width:l,height:`48%`}},{type:`text`,id:`dashboard-title-text`,content:{text:e,style:{fontSize:c,fontFamily:L(o,`title`),fontWeight:`bold`,color:r.colors.text,textAlign:`left`,verticalAlign:`middle`,maxLines:1}},position:{x:u,y:0,width:Math.max(1,t.width-u-a),height:`100%`}},{type:`shape`,id:`dashboard-title-rule`,content:{shape:`rect`,fill:C(r.colors.text,.14)},position:{x:0,y:n.placement===`bottom`?0:t.height-2,width:`100%`,height:2}}]}function Sh(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=_(r),a=t.customLayouts??km(e.frontmatter),o=t.customTemplates??e.customTemplates,s=[],c=fh(e.frontmatter,{layout:typeof t.layout==`string`?t.layout:void 0,showTitle:t.showTitle,zoom:t.zoom,...t.style===void 0?{}:{style:t.style}}),l=c.style,u,d=`auto`;if(t.layout&&typeof t.layout==`object`){let e=xm(t.layout);e.layout?(u=e.layout,d=`option`):s.push({type:`unknown-layout`,message:`Inline dashboard layout definition is invalid; falling back to auto.`,requestedLayout:t.layout.name})}else if(c.layout!==`auto`){let e=Gm(c.layout,a);e?(u=e,d=typeof t.layout==`string`&&t.layout.trim()?`option`:`frontmatter`):s.push({type:`unknown-layout`,message:`Unknown dashboard layout "${c.layout}"; falling back to auto.`,requestedLayout:c.layout})}let m=ap(e,{documentTitle:t.documentTitle,interleaveImages:!1}).blocks??[];m.length===0&&s.push({type:`empty-doc`,message:`The document has no renderable blocks; the dashboard has no cells.`});let h=c.showTitle?yh(e,t.documentTitle):``,g=h.length>0;g&&(m=bh(m,h)),u||(u=Km(m.length,i,a),d=`auto`);let v=hh*Math.min(r.width,r.height),y={x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-v*2)},b=null;if(g){let e=u.titleSlot??ph,t=Math.min(40,Math.max(2,gh(e.height)))/100*r.height,i=mh*r.height,a=e.placement===`bottom`?{x:0,y:r.height-t,width:r.width,height:t}:{x:0,y:0,width:r.width,height:t};y=e.placement===`bottom`?{x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)}:{x:v,y:t+i,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)};let o={width:Math.max(1,Math.round(a.width)),height:Math.max(1,Math.round(a.height)),name:`Dashboard title`};b={text:h,rect:a,rectPct:vh(a,r),viewport:o,layers:xh(h,o,e,n,r,v)}}let x=wm(u,i,y),S=[],C=new Set;x.forEach((e,t)=>{if(e.block===void 0)return;let n=e.block-1;if(n<0||n>=m.length){s.push({type:`invalid-cell-assignment`,message:`Cell ${t+1} of layout "${u.name}" requests block ${e.block}, but the document has ${m.length} block(s); the cell is left empty.`});return}C.add(n),S.push({cellIndex:t,rect:e.rect,candidateIndex:n,explicitZoom:e.zoom})});let w=new Set,T=0;x.forEach((e,t)=>{if(e.block===void 0){for(;T<m.length&&C.has(T);)T++;T>=m.length||(w.add(T),S.push({cellIndex:t,rect:e.rect,candidateIndex:T,explicitZoom:e.zoom}),T++)}});let E=[];for(let e=0;e<m.length;e++)!C.has(e)&&!w.has(e)&&E.push(e);E.length>0&&s.push({type:`overflow`,message:`${E.length} block(s) exceed the "${u.name}" layout's ${x.length} cell(s) and are not rendered.`,hiddenBlockIds:E.map(e=>String(m[e].id??e))});let D=S.sort((e,t)=>e.cellIndex-t.cellIndex),O=fm(D.map(({candidateIndex:e,explicitZoom:t})=>{let n=m[e],r=typeof n.title==`string`?n.title:``;return{template:j(n.template??``),textLength:r.length+Dd(n).length,...t===void 0?{}:{explicit:t}}}),c.zoom),k=o&&o.length>0?Ic(o):Fc,ee=D.map(({cellIndex:e,rect:i,candidateIndex:a},o)=>{let s=m[a],c=O[o],u=rh(l,{theme:n,rect:i,index:e}),d=u?u.contentRect:i,f={width:Math.max(1,Math.round(d.width)),height:Math.max(1,Math.round(d.height)),name:`Dashboard cell ${e+1}`},h=p(n,a,m.length,f);c!==1&&(h.fontScale*=c);let g=Il(s,{theme:n,viewport:f,persistentLayers:!1,blockIndex:a,totalBlocks:m.length,failureMode:t.failureMode},{registry:k,templateContext:h}),_=ih(l)?ah(g.layers,n):g.layers,v;if(u){let t={width:Math.max(1,Math.round(i.width)),height:Math.max(1,Math.round(i.height)),name:`Dashboard cell ${e+1} frame`};v={rect:i,rectPct:vh(i,r),viewport:t,layers:u.layers,overlayLayers:u.overlayLayers,overlayViewport:{width:f.width,height:f.height,name:`Dashboard cell ${e+1} overlay`},...u.contentRadiusPct?{contentRadiusPct:u.contentRadiusPct}:{}}}return{index:e,block:s,blockIndex:a,layers:_,rect:d,rectPct:vh(d,r),...v?{frame:v}:{},viewport:f,zoom:c,source:g.source,...g.diagnostic?{diagnostic:g.diagnostic}:{}}}),te=wi(e,n),ne=$m(l,n),re={fill:ne,bottomLayers:[{type:`shape`,id:`dashboard-backdrop`,content:{shape:`rect`,fill:ne},position:{x:0,y:0,width:`100%`,height:`100%`}},...Si(te?.bottomLayers,n)],topLayers:Si(te?.topLayers,n)};return{layout:u,layoutSource:d,style:l,viewport:r,cells:ee,title:b,backdrop:re,diagnostics:s}}function Ch(e){let t=[...e.backdrop.bottomLayers];for(let n of e.cells)n.frame&&t.push(...Dl(n.frame.layers,n.frame.viewport,n.frame.rect,`cell-${n.index}-frame`)),t.push(...Dl(n.layers,n.viewport,n.rect,`cell-${n.index}`)),n.frame&&n.frame.overlayLayers.length>0&&t.push(...Dl(n.frame.overlayLayers,n.frame.overlayViewport,n.rect,`cell-${n.index}-overlay`));return e.title&&t.push(...Dl(e.title.layers,e.title.viewport,e.title.rect,`dashboard-title`)),t.push(...e.backdrop.topLayers),t}var wh=.5,Th=.8,Eh=1;function Dh(e){let t=e.title?e.title.trim():``,n=Dd(e);return t&&n?`${t}
|
|
577
|
+
${n}`:t||n}function Oh(e,t){let n=new Map,r=new Set(e.map(e=>e.id)),i=[],a=new Map(e.map(e=>[e.id,e]));for(let e of t.blocks)e.blockId&&a.has(e.blockId)&&r.has(e.blockId)?(n.set(e.blockId,{startSec:e.startSec,endSec:e.endSec}),r.delete(e.blockId)):i.push(e);if(i.length>0&&r.size>0){let a=[];for(let n of i){let i=t.sourceText.slice(n.charStart,n.charEnd);for(let t of e){if(!r.has(t.id))continue;let e=Ph(i,Dh(t));e>=wh&&a.push({score:e,entry:n,blockId:t.id})}}a.sort((e,t)=>t.score-e.score||e.entry.blockIndex-t.entry.blockIndex);let o=new Set;for(let e of a)o.has(e.entry)||!r.has(e.blockId)||(n.set(e.blockId,{startSec:e.entry.startSec,endSec:e.entry.endSec}),o.add(e.entry),r.delete(e.blockId));let s=i.filter(e=>!o.has(e));if(s.length>0&&s.length===r.size){let t=e.filter(e=>r.has(e.id));s.sort((e,t)=>e.blockIndex-t.blockIndex),t.forEach((e,t)=>{let r=s[t];n.set(e.id,{startSec:r.startSec,endSec:r.endSec})})}}return n}function kh(e,t){let n=Bd(e);if(n.blocks.length===0||Ph(n.sourceText,t.sourceText)<Th)return null;let r=new Map,i=n.blocks.map(e=>ye(n.sourceText,e.charStart,t.duration));return n.blocks.forEach((e,n)=>{r.set(e.blockId,{startSec:i[n],endSec:n+1<i.length?i[n+1]:t.duration})}),r}function Ah(e,t){return e.map(e=>{let n=t.ranges.get(e.id),r=dd(e),i={...e};if(n){let a=t.clipStart+n.startSec+t.shift,o=Math.max(0,n.endSec-n.startSec);i.startTime=r.startTime??a,i.duration=r.duration??o;let s=i.startTime+i.duration;t.shift=s-(t.clipStart+n.endSec);let c=r.duration!=null&&Math.abs(r.duration-o)>Eh,l=r.startTime!=null&&Math.abs(r.startTime-a)>Eh;(c||l)&&t.diagnostics.push({severity:`info`,code:`narration-pin-conflict`,message:`Block timing is pinned (duration=/startTime=) but the recorded narration says ~${o.toFixed(1)}s starting at ~${a.toFixed(1)}s. The pin wins and later blocks follow it, while the recorded voice keeps its own schedule \u2014 playback drifts from the take past this block. Remove the pin to follow the narration.`,blockId:e.id}),t.cursor=Math.max(t.cursor,s)}else i.startTime=t.cursor,t.cursor+=i.duration;return e.children&&e.children.length>0&&(i.children=Ah(e.children,t)),i})}async function jh(e,t){let n=(e.documentMedia??[]).filter(e=>e.anchor===`document`);for(let r of n){if(!r.src)continue;let n=await t.readFile(`${r.src}.timing.json`);if(!n)continue;let i=Qd(n);if(!i)continue;let a=gd(e.blocks),o=i.blocks.length>0?Oh(a,i):kh(e,i);if(!o||o.size===0)continue;let s={clipStart:r.startAt,ranges:o,diagnostics:[],cursor:0,shift:0},c=Ah(e.blocks,s),l=Math.max(r.startAt+i.duration,s.cursor);return{doc:{...e,blocks:c,duration:l,...s.diagnostics.length>0?{diagnostics:[...e.diagnostics??[],...s.diagnostics]}:{}},applied:!0,clipSrc:r.src}}return{doc:e,applied:!1}}function Mh(e){try{let t=new TextDecoder().decode(e),n=JSON.parse(t);return n&&typeof n.sourceText==`string`&&typeof n.duration==`number`?{sourceText:n.sourceText,bookmarks:Array.isArray(n.bookmarks)?n.bookmarks:[],duration:n.duration}:null}catch{return null}}function Nh(e){let t=e.toLowerCase().replace(/[^\w\s]/g,` `).split(/\s+/).filter(e=>e.length>2);return new Set(t)}function Ph(e,t){let n=Nh(e),r=Nh(t);if(n.size===0||r.size===0)return 0;let i=0;for(let e of n)r.has(e)&&i++;let a=new Set([...n,...r]).size;return a>0?i/a:0}function Fh(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function Ih(e){let t=[];if(e.title&&t.push(e.title),e.contents)for(let n of e.contents)t.push(o(n));return t.join(`
|
|
578
|
+
`)}function Lh(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...Lh(n.children)):t.push(n);return t}var Rh=[`.mp3`,`.wav`,`.ogg`,`.m4a`],zh=[`.webm`,`.mp4`];function Bh(e){let t=e.toLowerCase();return Rh.some(e=>t.endsWith(e))?!0:zh.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function Vh(e){let t=e.toLowerCase();for(let n of[...Rh,...zh])if(t.endsWith(n))return e.slice(0,-n.length);return e}function Hh(e){try{let t=new TextDecoder().decode(e),n=JSON.parse(t);return n&&n.version===2&&n.sections?n.sections:null}catch{return null}}async function Uh(e){let t=(await e.listFiles()).filter(e=>Bh(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=Hh(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=Vh(t),n=``;for(let[t,i]of Object.entries(r))e.endsWith(`-${t}`)&&t.length>n.length&&(n=t,a=i)}if(!a){let t=`${i.path}.timing.json`,n=await e.readFile(t);n&&(a=Mh(n))}n.push({path:i.path,filename:t,timing:a})}return n}function Wh(e,t){let n=[],r=Lh(e);for(let e of r){let r=e.templateOverrides?.audio;if(!r)continue;let i=t.find(e=>e.filename===r||e.path===r||e.path.endsWith(`/${r}`));i&&n.push({block:e,audio:i})}return n}var Gh=.35,Kh=.5;function qh(e,t){let n=Lh(e);if(n.length===0||t.length===0)return[];let r=[];for(let e=0;e<t.length;e++){let i=t[e];for(let t=0;t<n.length;t++){let a=n[t],o=Ih(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=Ph(i.timing.sourceText,o)),s<Gh&&a.title){let e=Fh(a.title);Fh(Vh(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,Kh+.1))}s>=Gh&&r.push({block:a,blockIndex:t,audio:i,audioIndex:e,score:s})}}r.sort((e,t)=>t.score-e.score);let i=new Set,a=new Set,o=[];for(let e of r)i.has(e.blockIndex)||a.has(e.audioIndex)||(i.add(e.blockIndex),a.add(e.audioIndex),o.push({block:e.block,audio:e.audio,score:e.score}));return o}async function Jh(e,t){let n=await jh(e,t);e=n.doc;let r=await Uh(t),i=new Set(ee(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=Wh(e.blocks,a);if(o.length===0&&!n.applied&&(o=qh(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=Lh(e.blocks),c=new Map(s.map((e,t)=>[e.id,t]));o.sort((e,t)=>(c.get(e.block.id)??0)-(c.get(t.block.id)??0));let l=[],u=new Map,d=0;for(let e=0;e<o.length;e++){let{block:t,audio:n}=o[e],r=n.timing?.duration??30;l.push({src:n.path,name:t.title??t.id,duration:r,startTime:d}),u.set(t.id,e),d+=r}let f=Yh(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function Yh(e,t,n){return e.map(e=>{let r=t.get(e.id)??n??e.audioSegment,i={...e,audioSegment:r};return e.children&&(i.children=Yh(e.children,t,r)),i})}function Xh(e,t){return Zh(_e(e),t)}function Zh(e,t){let n=md(e),r=[...n.diagnostics??[]],i=hd(n.blocks),a=Qh(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{eg(e,t,a,r),ig(e,t,r),ag(e,r),tg(e,t,o,r),sg(e,r),$h(e)&&og(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return lg(e,r),t?.assets&&mg(e,i,ug(t.assets),r),r.sort((e,t)=>(e.line??2**53-1)-(t.line??2**53-1)),{diagnostics:r,errorCount:r.filter(e=>e.severity===`error`).length,warningCount:r.filter(e=>e.severity===`warning`).length,infoCount:r.filter(e=>e.severity===`info`).length,doc:n}}function Qh(e,t){return new Set([...Object.keys(Fc),...Object.keys(me),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function $h(e){return j(e.template??``)===`drawing`}function eg(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&$h(t)){if(Jo(i))return;let t=Wc(i,new Set(Go),{map:j});r.push({severity:`warning`,code:`unknown-shape`,message:`Unknown shape "${i}" in drawing \u2014 the child will be skipped`+(t?`. Did you mean "${t}"?`:``),blockId:e.id,...gg(e)});return}if(Jo(i)){r.push({severity:`warning`,code:`shape-outside-drawing`,message:`Shape "${i}" is only recognized on a child heading of a {[drawing]} block`,blockId:e.id,...gg(e)});return}if(n.has(i)||n.has(j(i)))return;let a=Wc(i,n,{map:j});r.push({severity:`warning`,code:`unknown-template`,message:`Unknown template "${i}" \u2014 the block will render as a plain fallback card`+(a?`. Did you mean "${a}"?`:``),blockId:e.id,...gg(e)})}function tg(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&$h(t)||Jo(i))return;let a=j(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of ll(a,o))t.kind===`missing-input`&&ng(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...gg(e)})}function ng(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=uo(e,t.title??``,t.contents);return r!=null&&n in r}var rg=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function ig(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=ce(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...gg(e)})}if(t&&$h(t)&&Jo(e.template)){let t=e.templateOverrides??{};for(let r of rg){let i=t[r];if(i==null)continue;let a=i.replace(/,\s*$/,``).trim();a!==``&&!Number.isFinite(Number(a))&&n.push({severity:`warning`,code:`invalid-attribute`,message:`Drawing shape "${e.id}": "${r}" is not a number (${JSON.stringify(i)})`,blockId:e.id,...gg(e)})}}}function ag(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(oe)){let a=n[i],o=r[i];a==null||o==null||a===o||t.push({severity:`info`,code:`conflicting-annotation-key`,message:`"${i}" is set in both {[\u2026]} (${a}) and {\u2026} (${o}) \u2014 the {\u2026} value wins.`,blockId:e.id,...gg(e)})}}function og(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=qo(e.sourceHeading?.templateAnnotation?.template);if(n!==`line`&&n!==`arrow`)continue;let i=e.templateOverrides??{};for(let n of[`from`,`to`]){let a=i[n];if(a==null)continue;let o=a.replace(/,\s*$/,``).trim();o&&!r.has(o)&&t.push({severity:`warning`,code:`unresolved-connection`,message:`Drawing connector "${e.id}" references unknown ${n} "${o}"`,blockId:e.id,...gg(e)})}}}function sg(e,t){if(e.sourceHeading?.templateAnnotation?.template||e.sourceAnnotation?.template)for(let n of e.contents??[]){if(n.type!==`code`)continue;let r=n.lang?.toLowerCase();if(r!==`json`&&r!==`yaml`&&r!==`yml`||Tu(n))continue;let i=Eu(n);!i.data||Object.keys(i.data).length===0||t.push({severity:`info`,code:`possible-data-fence`,message:`This ${r} block renders as code \u2014 add "data" to the fence (\`\`\`${r} data) if it's meant as template input.`,blockId:e.id,...n.position?{line:n.position.start.line}:gg(e)})}}var cg=/\{\[/;function lg(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);cg.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${_g(r)}" contains "{[\u2026]}" text that was not recognized \u2014 check the quoting, or whether the token is a known inline icon`,...t.position?{line:t.position.start.line}:{}});return}if(e.type===`paragraph`&&a){let t=Fu(e);if(t&&t.template!=null)return}if(e.type===`text`&&cg.test(e.value)){n.push({severity:`warning`,code:`unparsed-annotation`,message:`Body text contains "{[…]}" — template annotations are recognized on headings and as standalone paragraphs (or the token is not a known inline icon)`,...e.position?{line:e.position.start.line}:i==null?{}:{line:i}});return}if(e.type!==`code`)for(let n of t(e))r(n,i,!1)};for(let t of e.children)r(t,t.position?.start.line,!0)}function ug(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var dg=/^[a-z][a-z0-9+.-]*:/i;function fg(e){return e.length>0&&!dg.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var pg=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function mg(e,n,r,i){let a=(e,t,n)=>{!fg(e)||r(e)||i.push({severity:`warning`,code:`missing-asset`,message:`Referenced asset "${e}" was not found in the bundle`,...n?{blockId:n}:{},...t==null?{}:{line:t}})},o=new Set,s=e=>{e.type===`image`&&(o.add(e.url),a(e.url,e.position?.start.line)),(e.type===`htmlBlock`||e.type===`htmlInline`)&&hg(e.htmlChildren,t=>{o.add(t),a(t,e.position?.start.line)});for(let n of t(e))s(n)};for(let t of e.children)s(t);for(let e of n){let t=new Set,n=[{value:e.templateOverrides,derived:!1},{value:e.templateData,derived:!0}];for(let{value:r,derived:i}of n){if(!r)continue;for(let n of pg){let s=r[n];typeof s==`string`&&(i||t.add(s),(!i||!o.has(s)&&!t.has(s))&&a(s,e.sourceHeading?.position?.start.line,e.id))}let n=r.images,s=typeof n==`string`?n.split(`,`).map(e=>e.trim()):Array.isArray(n)?n.filter(e=>typeof e==`string`):[];for(let n of s)i||t.add(n),(!i||!o.has(n)&&!t.has(n))&&a(n,e.sourceHeading?.position?.start.line,e.id)}}}function hg(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),hg(n.children,t))}function gg(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function _g(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function vg(e){return e.split(`
|
|
579
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function yg(e){if(e===void 0)return;let t=e.replace(/\s+/gu,` `).trim();return t.length>0?t:void 0}function bg(e){return e.length<=40}var xg=1;function Sg(e,t={}){let n=(t.style??e.style)===`ascii`?xt:bt;if(e.nodes.length===0)return``;let r=wg(e.nodes,e.edges),i=new Og,a=[...r.values()].sort((e,t)=>e.depth-t.depth||e.rect.r0-t.rect.r0||e.rect.c0-t.rect.c0);for(let e of a)kg(i,e,n);return Ag(i,e.edges,r,n),i.emit()}function Cg(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map;for(let t of e)r.set(t.id,{top:0,bottom:0,left:0,right:0});let i=e=>({r0:e.row,c0:e.col,r1:e.row+e.hRows-1,c1:e.col+e.wCols-1});for(let e of t){let t=n.get(e.source),a=n.get(e.target);if(!t||!a||t===a)continue;let{exit:o,enter:s}=jg(i(t),i(a));r.get(e.source)[o]++,r.get(e.target)[s]++}return r}function wg(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=Cg(e,t),i=new Map,a=[];for(let t of e)if(t.containerId&&n.has(t.containerId)&&t.containerId!==t.id){let e=i.get(t.containerId)??[];e.push(t.id),i.set(t.containerId,e)}else a.push(t.id);let o=new Map,s=(e,t,n)=>{let r=o.get(e);r&&(r.rect=Eg(r.rect,t,n));for(let r of i.get(e)??[])s(r,t,n)},c=(e,t)=>{let r=[...e].sort((e,t)=>{let r=n.get(e),i=n.get(t);return r.row-i.row||r.col-i.col||r.id.localeCompare(i.id)}),i=[];for(let e of r){let n=t(e),r=0;for(;;){let t=i.find(e=>Tg(n,e,xg));if(!t||r++>64)break;let a=t.c1+xg+1-n.c0,o=t.r1+xg+1-n.r0;a<o?(s(e,0,a),n=Eg(n,0,a)):(s(e,o,0),n=Eg(n,o,0))}i.push(n)}return i},l=(e,t)=>{let a=n.get(e),s=vg(a.label),u=i.get(e)??[];if(u.length===0){let n=s.reduce((e,t)=>Math.max(e,Ke(t)),0),i=r.get(e)??{top:0,bottom:0,left:0,right:0},c=Math.max(i.top,i.bottom),l=Math.max(i.left,i.right),u=Math.max(a.wCols,n+4,3,c>0?2*c+1:0),d=Math.max(a.hRows,s.length+2,3,l>0?2*l+1:0),f={r0:a.row,c0:a.col,r1:a.row+d-1,c1:a.col+u-1};return o.set(e,{node:a,rect:f,labelLines:s,isContainer:!1,depth:t}),f}let d=Dg(c(u,e=>l(e,t+1))),f=Math.max(0,s.length-1),p=Ke(s[0]??``),m={r0:d.r0-2-f,c0:d.c0-2,r1:d.r1+2,c1:d.c1+2},h=s.slice(1).reduce((e,t)=>Math.max(e,Ke(t)),0),g=Math.max(p>0?p+6:3,h>0?h+4:3);return m.c1-m.c0+1<g&&(m.c1=m.c0+g-1),m.c1-m.c0+1<a.wCols&&(m.c1=m.c0+a.wCols-1),o.set(e,{node:a,rect:m,labelLines:s,isContainer:!0,depth:t}),m};c(a,e=>l(e,0));let u=1/0,d=1/0;for(let e of o.values())u=Math.min(u,e.rect.r0),d=Math.min(d,e.rect.c0);let f=u<0?-u:0,p=d<0?-d:0;if(f>0||p>0)for(let e of o.values())e.rect=Eg(e.rect,f,p);return o}function Tg(e,t,n){return e.r0-n<=t.r1&&t.r0-n<=e.r1&&e.c0-n<=t.c1&&t.c0-n<=e.c1}function Eg(e,t,n){return{r0:e.r0+t,c0:e.c0+n,r1:e.r1+t,c1:e.c1+n}}function Dg(e){return e.reduce((e,t)=>({r0:Math.min(e.r0,t.r0),c0:Math.min(e.c0,t.c0),r1:Math.max(e.r1,t.r1),c1:Math.max(e.c1,t.c1)}))}var Og=class{constructor(){this.rows=[],this.kinds=[]}ensure(e,t){for(;this.rows.length<=e;)this.rows.push([]),this.kinds.push([]);let n=this.rows[e],r=this.kinds[e];for(;n.length<=t;)n.push(` `),r.push(`empty`)}kindAt(e,t){return this.kinds[e]?.[t]??`empty`}set(e,t,n,r){e<0||t<0||(this.ensure(e,t),this.rows[e][t]=n,this.kinds[e][t]=r)}drawEdgeCell(e,t,n,r,i){if(e<0||t<0)return;this.ensure(e,t);let a=this.kinds[e][t];if(!(a===`border`||a===`label`||a===`junction`)){if(r===`arrow`){this.rows[e][t]=n,this.kinds[e][t]=r;return}if(a!==`arrow`){if(a===`line-h`&&r===`line-v`||a===`line-v`&&r===`line-h`){this.rows[e][t]=i.cross,this.kinds[e][t]=`turn`;return}a===`empty`&&(this.rows[e][t]=n,this.kinds[e][t]=r)}}}emit(){let e=this.rows.map(e=>e.join(``).replace(/\s+$/u,``));for(;e.length>0&&e[e.length-1]===``;)e.pop();return e.join(`
|
|
580
|
+
`)}};function kg(e,t,n){let{rect:r,labelLines:i,isContainer:a}=t,o=r.c1-r.c0-1;e.set(r.r0,r.c0,n.tl,`border`),e.set(r.r0,r.c1,n.tr,`border`);let s=a&&i.length>0?Ge(` ${i[0]} `):null;if(s&&s.length<=o-2){let t=Math.floor((o-s.length)/2);for(let i=0;i<o;i++){let a=i>=t&&i<t+s.length,o=a?s[i-t]:n.h;e.set(r.r0,r.c0+1+i,o,a?`label`:`border`)}}else for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r0,t,n.h,`border`);e.set(r.r1,r.c0,n.bl,`border`),e.set(r.r1,r.c1,n.br,`border`);for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r1,t,n.h,`border`);for(let t=r.r0+1;t<=r.r1-1;t++)e.set(t,r.c0,n.v,`border`),e.set(t,r.c1,n.v,`border`);let c=a?i.slice(1):i;if(c.length>0){let t=r.r1-r.r0-1,n=a?r.r0+1:r.r0+1+Math.max(0,Math.floor((t-c.length)/2));c.forEach((t,i)=>{let a=Ge(t),s=Math.max(0,Math.floor((o-a.length)/2));for(let t=0;t<a.length&&s+t<o;t++)e.set(n+i,r.c0+1+s+t,a[t],`label`)})}}function Ag(e,t,n,r){let i=[...t].sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),a=new Set,o=[];for(let e=0;e<i.length;e++){if(a.has(e))continue;let t=i[e];if(!n.has(t.source)||!n.has(t.target))continue;let r=!1;if(t.directed){let n=i.findIndex((n,r)=>r>e&&!a.has(r)&&n.directed&&n.source===t.target&&n.target===t.source&&(n.label??``)===(t.label??``));n>=0&&(a.add(n),r=!0)}let s=jg(n.get(t.source).rect,n.get(t.target).rect);o.push({edge:t,sourceId:t.source,targetId:t.target,exitSide:s.exit,enterSide:s.enter,biDir:r})}let s=Mg(o,n),c=[];o.forEach((t,i)=>Ng(e,t,i,n,s,r,(e,t)=>c.push({candidates:e,label:t})));for(let t of c){let n=Ge(t.label),r=!1;for(let i of[`right`,`left`]){if(r)break;for(let{row:a,col:o}of t.candidates){if(e.kindAt(a,o)!==`line-v`)continue;let t=i===`right`?o+2:o-1-n.length;if(t<0)continue;let s=i===`right`?o+1:o-1,c=e.kindAt(a,s)===`empty`;for(let r=0;c&&r<n.length;r++)e.kindAt(a,t+r)!==`empty`&&(c=!1);if(c&&i===`left`&&t>0&&(c=e.kindAt(a,t-1)===`empty`),c){for(let r=0;r<n.length;r++)e.set(a,t+r,n[r],`label`);r=!0;break}}}}}function jg(e,t){if(t.r0>e.r1)return{exit:`bottom`,enter:`top`};if(t.r1<e.r0)return{exit:`top`,enter:`bottom`};if(t.c0>e.c1)return{exit:`right`,enter:`left`};if(t.c1<e.c0)return{exit:`left`,enter:`right`};let n=[{side:`top`,gap:Math.abs(e.r0-t.r0)},{side:`bottom`,gap:Math.abs(t.r1-e.r1)},{side:`left`,gap:Math.abs(e.c0-t.c0)},{side:`right`,gap:Math.abs(t.c1-e.c1)}];return n.sort((e,t)=>e.gap-t.gap),{exit:n[0].side,enter:n[0].side}}function Mg(e,t){let n=new Map;e.forEach((e,t)=>{let r=`${e.sourceId}|${e.exitSide}`,i=`${e.targetId}|${e.enterSide}`;n.set(r,[...n.get(r)??[],{key:`${t}:exit`,otherId:e.targetId}]),n.set(i,[...n.get(i)??[],{key:`${t}:enter`,otherId:e.sourceId}])});let r=new Map;for(let[e,i]of[...n.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let[n,a]=e.split(`|`),o=t.get(n);i.sort((e,n)=>{let r=t.get(e.otherId).rect,i=t.get(n.otherId).rect;return r.r0-i.r0||r.c0-i.c0||e.otherId.localeCompare(n.otherId)});let s=a===`top`||a===`bottom`,c=s?o.rect.c0+1:o.rect.r0+1,l=s?o.rect.c1-1:o.rect.r1-1,u=Math.max(1,l-c+1),d=i.length;if(d===1)r.set(i[0].key,{pos:c+Math.floor((u-1)/2),index:0,count:1});else{let e=2*d-1,t=c+Math.max(0,Math.floor((u-e)/2));i.forEach((e,n)=>{r.set(e.key,{pos:Math.min(l,t+2*n),index:n,count:d})})}}return r}function Ng(e,t,n,r,i,a,o){let s=r.get(t.sourceId).rect,c=r.get(t.targetId).rect,l=i.get(`${n}:exit`),u=i.get(`${n}:enter`),d=l.pos,f=u.pos,p=u.count>l.count?u:l,m=p.index-Math.floor((p.count-1)/2),h={canvas:e,directed:t.edge.directed,biDir:t.biDir,label:yg(t.edge.label),vocab:a,junction:(t,n,r)=>{let i=r===`top`?a.stemUp:r===`bottom`?a.stemDown:r===`left`?a.stemLeft:a.stemRight;e.set(t,n,i,`junction`)},stagger:m,deferSideLabel:o};t.exitSide===`bottom`&&t.enterSide===`top`?Ig(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?Ig(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?Lg(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?Lg(h,s,c,d,f,-1):Rg(h,s,c,t.exitSide)}function Pg(e,t){let n=Math.min(e,t),r=Math.max(e,t),i=[];for(let e=n;e<=r;e++)i.push(e);let a=Math.floor((n+r)/2);return i.sort((e,t)=>Math.abs(e-a)-Math.abs(t-a)||e-t)}function Fg(e,t,n){return Math.max(t,Math.min(n,e))}function Ig(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d,stagger:f}=e,p=a===1?t.r1:t.r0,m=a===1?n.r0:n.r1,h=p+a,g=m-a,_=(g-h)*a+1,v=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);for(let t=r;t<=i;t++)o.drawEdgeCell(t,e,u.v,`line-v`,u)};if(r>=n.c0+1&&r<=n.c1-1&&r>=t.c0+1&&r<=t.c1-1||_<2){let i=Fg(r,t.c0+1,t.c1-1),f=Fg(r,n.c0+1,n.c1-1);d(p,i,a===1?`bottom`:`top`),d(m,f,a===1?`top`:`bottom`),i===f&&_>=1&&(v(i,h,g),s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&_>=2&&o.drawEdgeCell(h,i,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&e.deferSideLabel(Pg(h,g).map(e=>({row:e,col:i})),l));return}let y=Fg(Math.floor((p+m)/2)+f,Math.min(h,g),Math.max(h,g));d(p,r,a===1?`bottom`:`top`),d(m,i,a===1?`top`:`bottom`),Math.abs(y-p)>=2&&v(r,h,y-a),Math.abs(m-y)>=2&&v(i,y+a,g);let b=!1;if(r===i)o.drawEdgeCell(y,r,u.v,`line-v`,u);else{let e=i>r,t=a===1?e?u.turnUpRight:u.turnUpLeft:e?u.turnDownRight:u.turnDownLeft,n=a===1?e?u.turnDownLeft:u.turnDownRight:e?u.turnUpLeft:u.turnUpRight;o.drawEdgeCell(y,r,t,`turn`,u),o.drawEdgeCell(y,i,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i),d=[];for(let e=s+1;e<=c-1;e++)d.push(u.h);let f=l?Ge(` ${l} `):null;if(f&&bg(f)&&d.length>=f.length+2){let e=Math.floor((d.length-f.length)/2);d=d.map((t,n)=>n>=e&&n<e+f.length?f[n-e]:t),b=!0}d.forEach((e,t)=>{o.drawEdgeCell(y,s+1+t,e,e===u.h?`line-h`:`label`,u)})}if(s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&o.drawEdgeCell(h,r,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&!b){let t=[];if(r===i)for(let e of Pg(h,g))t.push({row:e,col:r});else{let e=(y-a-h)*a+1,n=(g-(y+a))*a+1;if(e>=1)for(let e of Pg(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of Pg(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function Lg(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d}=e,f=a===1?t.c1:t.c0,p=a===1?n.c0:n.c1,m=f+a,h=p-a,g=(h-m)*a+1,_=(e,t,n,r,i=0,a=0)=>{let s=Math.min(t,n),c=Math.max(t,n),d=[];for(let e=s;e<=c;e++)d.push(u.h);let f=r&&l?Ge(` ${l} `):null;if(f&&bg(f)){let e=i,t=d.length-1-a-e+1;if(t>=f.length+2){let n=e+Math.floor((t-f.length)/2);d=d.map((e,t)=>t>=n&&t<n+f.length?f[t-n]:e)}}d.forEach((t,n)=>{o.drawEdgeCell(e,s+n,t,t===u.h?`line-h`:`label`,u)})};if(r>=n.r0+1&&r<=n.r1-1&&r>=t.r0+1&&r<=t.r1-1||g<2){let e=Fg(r,t.r0+1,t.r1-1),i=Fg(r,n.r0+1,n.r1-1);d(e,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),e===i&&g>=1&&(_(e,m,h,!0,(a===1?c:s)?1:0,(a===1?s:c)?1:0),s&&o.drawEdgeCell(e,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&g>=2&&o.drawEdgeCell(e,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u));return}let v=Fg(Math.floor((f+p)/2)+e.stagger,Math.min(m,h),Math.max(m,h));if(d(r,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),Math.abs(v-f)>=2&&_(r,m,v-a,!0,a===1&&c?1:0,a===-1&&c?1:0),Math.abs(p-v)>=2&&_(i,v+a,h,!1),r===i)o.drawEdgeCell(r,v,u.h,`line-h`,u);else{let e=i>r,t=a===1?e?u.turnDownLeft:u.turnUpLeft:e?u.turnDownRight:u.turnUpRight,n=a===1?e?u.turnUpRight:u.turnDownRight:e?u.turnUpLeft:u.turnDownLeft;o.drawEdgeCell(r,v,t,`turn`,u),o.drawEdgeCell(i,v,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i);for(let e=s+1;e<=c-1;e++)o.drawEdgeCell(e,v,u.v,`line-v`,u)}s&&o.drawEdgeCell(i,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&o.drawEdgeCell(r,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u)}function Rg(e,t,n,r){let{canvas:i,directed:a,vocab:o,junction:s}=e;if(r===`top`||r===`bottom`){let e=Math.max(t.c0+1,n.c0+1),c=Math.min(t.c1-1,n.c1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`top`?t.r0:t.r1,d=r===`top`?n.r0:n.r1;if(u===d)return;s(u,l,r),s(d,l,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(e,l,o.v,`line-v`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(e,l,d>u?o.arrowDown:o.arrowUp,`arrow`,o)}}else{let e=Math.max(t.r0+1,n.r0+1),c=Math.min(t.r1-1,n.r1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`left`?t.c0:t.c1,d=r===`left`?n.c0:n.c1;if(u===d)return;s(l,u,r),s(l,d,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(l,e,o.h,`line-h`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(l,e,d>u?o.arrowRight:o.arrowLeft,`arrow`,o)}}}var zg=2,Bg=8,Vg=12,Hg=4,Ug=4;function Wg(e){return!sn(e).isDiagram&&Kg(Mt(Nt(e),!0)).length>=zg}function Gg(e){let t=Nt(e),n=Kg(Mt(t,!0));if(n.length<zg)return null;let r=qg(t,n),i={nodes:r,edges:Zg(t,n,r),style:n_(t),warnings:[`repaired`]};return{diagram:i,art:Sg(i)}}function Kg(e){let t=new Set,n=[];for(let r of e){let e=`${r.r0},${r.c0},${r.r1},${r.c1}`;t.has(e)||(t.add(e),n.push(r))}return n.sort((e,t)=>e.r0-t.r0||e.c0-t.c0)}function qg(e,t){let n=e[0]?.length??0,r=t.map(()=>[]),i=new Map(t.map((e,t)=>[e,t])),a=[];for(let e of t){let t=a.find(t=>t.some(t=>t.r0<=e.r1&&e.r0<=t.r1));t||(t=[],a.push(t)),t.push(e)}for(let t of a){t.sort((e,t)=>e.c0-t.c0);let a=Math.min(...t.map(e=>e.r0+1)),o=Math.max(...t.map(e=>e.r1-1));for(let s=a;s<=o;s++){let a=t.filter(e=>s>e.r0&&s<e.r1);if(a.length===0)continue;let o=e[s].join(``).split(/[│┃║]/).map(Jg).filter(e=>e.length>0);if(o.length===a.length)a.forEach((e,t)=>{let n=i.get(e);n!==void 0&&o[t]&&r[n].push(o[t])});else for(let t of a){let a=i.get(t);if(a===void 0)continue;let o=Jg(e[s].slice(t.c0+1,Math.min(t.c1,n)).join(``));o&&r[a].push(o)}}}let o=new Map,s=[...a].sort((e,t)=>Math.min(...e.map(e=>e.r0))-Math.min(...t.map(e=>e.r0))),c=0;for(let e of s){o.set(e,c);let t=Math.max(...e.map(e=>e.r1-e.r0+1));c+=t+Hg}let l=new Map;for(let e of a)for(let t of e)l.set(t,e);let u=t.map((e,t)=>Math.max(e.c1-e.c0+1,...r[t].map(e=>e.length+4),3)),d=new Map(t.map((e,t)=>[e,t])),f=new Map;for(let e of a){let t=[...e].sort((e,t)=>e.c0-t.c0),n=Math.min(...e.map(e=>e.c0));for(let e of t)f.set(e,n),n+=(u[d.get(e)??0]??3)+Ug}let p=t.map((e,n)=>Yg(t,n)),m=new Map,h=t.map((e,t)=>{let n=Xg(r[t][0]??``),i=m.get(n)??0;m.set(n,i+1),i>0&&(n=`${n}-${i+1}`);let a=l.get(e),s=p[t]>=0,c=a&&!s?o.get(a)??e.r0:e.r0,u=s?e.c0:f.get(e)??e.c0;return{id:n,label:r[t].join(`
|
|
581
|
+
`),col:u,row:c,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1}});return h.forEach((e,t)=>{p[t]>=0&&(e.containerId=h[p[t]].id)}),h}function Jg(e){let t=``;for(let n of e){let e=n.codePointAt(0)??0;e>=9472&&e<=9599||F(n)!==null?t+=` `:t+=n}return t.replace(/\s+/g,` `).trim()}function Yg(e,t){let n=e[t],r=-1,i=1/0;for(let a=0;a<e.length;a++){if(a===t)continue;let o=e[a];if(o.r0<n.r0&&o.c0<n.c0&&o.r1>n.r1&&o.c1>n.c1){let e=(o.r1-o.r0)*(o.c1-o.c0);e<i&&(i=e,r=a)}}return r}function Xg(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Zg(e,t,n){let r=e.length,i=e[0]?.length??0,a=(t,n)=>t>=0&&t<r&&n>=0&&n<i?e[t][n]:` `,o=e=>dt(e)||P(e)||ft(e)||F(e)!==null,s=(e,t)=>Math.max(e.c0,t.c0)<=Math.min(e.c1,t.c1),c=(e,t)=>Math.max(e.r0,t.r0)<=Math.min(e.r1,t.r1),l=[],u=new Set,d=(e,t,r)=>{if(e===t)return;let i=`${n[e].id}|${n[t].id}`;u.has(i)||(u.add(i),l.push({source:n[e].id,target:n[t].id,directed:r}))};for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++){if(e===n)continue;let r=t[e],i=t[n];if(r.r1<i.r0&&i.r0-r.r1<=Bg&&s(r,i)){let s=Math.max(r.c0,i.c0),c=Math.min(r.c1,i.c1);if(Qg(a,r.r1+1,i.r0-1,s-1,c+1,o)&&!e_(t,e,n,s,c)){let t=$g(a,r.r1+1,i.r0,s-1,c+1,`down`);d(e,n,t)}}if(r.c1<i.c0&&i.c0-r.c1<=Vg&&c(r,i)&&e<n){let o=Math.max(r.r0,i.r0),s=Math.min(r.r1,i.r1),c=$g(a,o-1,s+1,r.c1+1,i.c0,`right`),l=$g(a,o-1,s+1,r.c1+1,i.c0,`left`);(c||l)&&!t_(t,e,n,o,s)&&(l&&!c?d(n,e,!0):d(e,n,!0))}}return l}function Qg(e,t,n,r,i,a){for(let o=t;o<=n;o++)for(let t=r;t<=i;t++)if(a(e(o,t)))return!0;return!1}function $g(e,t,n,r,i,a){for(let o=t;o<=n;o++)for(let t=r;t<=i;t++)if(F(e(o,t))===a)return!0;return!1}function e_(e,t,n,r,i){let a=e[t],o=e[n];return e.some((e,s)=>s===t||s===n?!1:e.r0>a.r1&&e.r1<o.r0&&Math.max(e.c0,r)<=Math.min(e.c1,i))}function t_(e,t,n,r,i){let a=e[t],o=e[n];return e.some((e,s)=>s===t||s===n?!1:e.c0>a.c1&&e.c1<o.c0&&Math.max(e.r0,r)<=Math.min(e.r1,i))}function n_(e){let t=0,n=0;for(let r of e)for(let e of r){let r=e.codePointAt(0)??0;r>=9472&&r<=9599?t++:(e===`+`||e===`|`||e===`-`)&&n++}return n>t?`ascii`:`unicode`}var r_={rail:`─`,arrow:`►`,marker:{filled:`●`,hollow:`○`,diamond:`◆`}},i_={rail:`-`,arrow:`>`,marker:{filled:`*`,hollow:`o`,diamond:`*`}},a_=48,o_=64,s_=3,c_=3;function l_(e,t={}){let n=t.style??e.style,r=n===`ascii`?i_:r_,{tracks:i,links:a}=__(e,n);if(i.length===0)return``;let o=Math.min(...i.map(e=>e.startColumn)),s=Math.max(...i.map(e=>e.endColumn)),c=Math.max(1,s-o),l=Math.max(a_,Math.min(o_,Math.ceil(c)),...i.map(e=>e.events.length*s_)),u=i.map(e=>f_(e)),d=Math.max(...u.map(h_)),f=[];if(i.forEach((e,t)=>{t>0&&f.push(``),f.push(...u_(e,n,r,u[t],d,l,o,c))}),a.length>0){f.push(``);for(let e of a)f.push(g_(e,n))}return f.join(`
|
|
582
|
+
`)}function u_(e,t,n,r,i,a,o,s){let c=`${r}${` `.repeat(Math.max(0,i-h_(r)))}`,l=p_(e.events,a,o,s),u=Array.from({length:a+1},()=>n.rail);for(let{event:e,offset:t}of l)u[t]=n.marker[e.marker];let d=l.map(({event:e,offset:t})=>({event:e,column:i+t,text:d_(e)})),f=t===`ascii`?{above:`^`,below:`v`}:{above:`▲`,below:`▼`},p=m_(d.filter(({event:e})=>e.side===`above`),f.above),m=m_(d.filter(({event:e})=>e.side===`below`),f.below),h=`${c}${u.join(``)}${n.rail.repeat(c_)}${n.arrow}${e.endLabel?` ${e.endLabel}`:``}`;return[...p,h,...m]}function d_(e){let t=e.description?`${e.label} :: ${e.description}`:e.label,n=e.descriptionSide?` descriptionSide=${e.descriptionSide}`:``,r=e.callout===!1?` callout=false`:``;return`${t} {#${e.id} column=${E_(e.column)}${n}${r}}`}function f_(e){let t=`{#${e.id} start=${E_(e.startColumn)} end=${E_(e.endColumn)}}`;return e.label?`${e.label} ${t}: `:`${t}: `}function p_(e,t,n,r){let i=-1;return e.map((a,o)=>{let s=Math.round((a.column-n)/r*t),c=e.length-o-1,l=Math.max(0,t-c),u=Math.max(i+1,Math.min(l,Math.max(0,s)));return i=u,{event:a,offset:u}})}function m_(e,t){let n=[],r=[];for(let t of e){let e=t.column+2+h_(t.text),i=r.findIndex(e=>t.column>e+1);i<0&&(i=n.length,n.push([]),r.push(-1)),n[i].push(t),r[i]=e}return n.map(e=>{let n=[];for(let r of e){for(;n.length<r.column;)n.push(` `);n.push(t,` `,...Array.from(r.text))}return n.join(``).trimEnd()})}function h_(e){return Array.from(e).length}function g_(e,t){let n=t===`ascii`?`->`:`→`;return`branch: ${e.source} ${n} ${e.target}${e.label?` : ${e.label}`:``}`}function __(e,t){let n=e.tracks.map((e,t)=>({track:e,index:t})).filter(({track:e})=>Array.isArray(e.events)&&e.events.length>0).sort((e,t)=>w_(e.track.row,e.index)-w_(t.track.row,t.index)||e.index-t.index||e.track.id.localeCompare(t.track.id)),r=new Set,i=new Set,a=new Map,o=new Map,s=[],c=0;for(let{track:e}of n){let n=y_(e.label),l=y_(e.endLabel),u=S_(x_(e.id,x_(n,`track_${s.length+1}`)),r),d=e.events.map((e,t)=>({event:e,index:t})).sort((e,t)=>w_(e.event.column,e.index)-w_(t.event.column,t.index)||e.index-t.index||e.event.id.localeCompare(t.event.id)),f=[];for(let e=0;e<d.length;e++){let n=d[e].event,r=`Event ${e+1}`,s=y_(n.label)||r,l=S_(x_(n.id,x_(s,`event_${++c}`)),i),u=y_(n.description),p=u&&(n.descriptionSide===`above`||n.descriptionSide===`below`)?n.descriptionSide:void 0,m=T_(n.column,e),h=n.side===`below`?`below`:n.side===`above`||e%2==0?`above`:`below`,g=v_(n.marker,t);f.push({id:l,label:s,...u?{description:u}:{},...p?{descriptionSide:p}:{},column:m,side:h,...n.callout===!1?{callout:!1}:{},marker:g}),n.id&&!a.has(n.id)&&a.set(n.id,l),a.set(l,l),o.set(C_(s),l)}let p=f.map(e=>e.column),m=p.length>0?Math.min(...p):0,h=p.length>0?Math.max(...p):m+1;s.push({id:u,...n?{label:n}:{},...l?{endLabel:l}:{},startColumn:T_(e.startColumn,m),endColumn:T_(e.endColumn,h),events:f})}let l=e=>a.get(e)??o.get(C_(e)),u=[];for(let t of Array.isArray(e.links)?e.links:[]){let e=l(t.source),n=l(t.target);if(!e||!n)continue;let r=b_(t.label);u.push({source:e,target:n,...r?{label:r}:{}})}return u.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),{tracks:s,links:u}}function v_(e,t){return e===`hollow`?`hollow`:e===`diamond`&&t!==`ascii`?`diamond`:`filled`}function y_(e){return e?e.normalize(`NFC`).replace(/[\r\n\t]+/g,` `).replace(/[\u25cf\u25cb\u25c9\u25c6\u25c7\u2022]+/gu,`·`).replace(/\*/g,`∗`).replace(/::/g,`∶`).replace(/\s+/g,` `).trim().replace(/^[\u2500\u2501\u2550\u254c\u254d\u2504\u2505\u2508\u2509-]+/u,e=>Array.from(e,e=>e===`-`?`−`:`–`).join(``)):``}function b_(e){return y_(e).replace(/\s+/g,` `).trim()}function x_(e,t){return(e??``).normalize(`NFC`).replace(/[\r\n\t\s]+/g,`_`).replace(/[^A-Za-z0-9_.~-]+/g,`_`).replace(/^_+|_+$/g,``)||t}function S_(e,t){if(!t.has(e))return t.add(e),e;let n=2,r=`${e}_${n}`;for(;t.has(r);)r=`${e}_${++n}`;return t.add(r),r}function C_(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function w_(e,t){return Number.isFinite(e)?e:t}function T_(e,t){let n=w_(e,t);return Math.max(0,Object.is(n,-0)?0:n)}function E_(e){return String(Object.is(e,-0)?0:e)}function D_(e){return e.replace(/\s+/gu,` `).trim()}function O_(e,t={}){let n=(t.style??e.style)===`ascii`?Pr:Nr,r=[],i=e=>{let t=D_(e.label),n=e.comment?D_(e.comment):``;return n?`${t} # ${n}`:t},a=(e,t)=>{e.forEach((o,s)=>{let c=s===e.length-1;r.push(t+(c?n.elbow:n.tee)+i(o)),a(o.children,t+(c?n.gap:n.rail))})};for(let t of e.roots)r.push(i(t)),a(t.children,``);return r.join(`
|
|
583
|
+
`)}var k_=e({ASCII_CHAR_H:()=>28,ASCII_CHAR_W:()=>14,ASCII_DIAGRAM_FENCE_LANGS:()=>Qt,ASCII_TIMELINE_FENCE_LANGS:()=>fr,BASE_INPUT_DESCRIPTORS:()=>Qc,BLOCK_MEDIA_LAYOUT_POLICIES:()=>gl,BUILTIN_DASHBOARD_LAYOUTS:()=>Bm,CONTAINER_TEMPLATES:()=>pe,COVER_SLIDE_FRONTMATTER_KEYS:()=>wf,COVER_SLIDE_TEMPLATE_OPTIONS:()=>Cf,DASHBOARD_AUTO_LAYOUT_ID:()=>Wm,DASHBOARD_FRONTMATTER_KEYS:()=>oh,DASHBOARD_STYLES:()=>Ym,DASHBOARD_STYLE_IDS:()=>qm,DASHBOARD_ZOOM_LEVELS:()=>om,DEFAULT_COVER_SLIDE_SETTINGS:()=>Tf,DEFAULT_DASHBOARD_SETTINGS:()=>sh,DEFAULT_DASHBOARD_STYLE:()=>Jm,DEFAULT_LAYOUT:()=>Bi,DEFAULT_THEME:()=>A,DIAGRAM_LABEL_HORIZONTAL_PADDING:()=>24,DIAGRAM_LABEL_LINE_HEIGHT:()=>wo,DIAGRAM_LABEL_MIN_FONT_SIZE:()=>10,DIAGRAM_LABEL_VERTICAL_PADDING:()=>16,FRONTMATTER_CUSTOM_TEMPLATES_KEY:()=>E,FRONTMATTER_CUSTOM_THEMES_KEY:()=>k,FRONTMATTER_DASHBOARD_LAYOUTS_KEY:()=>Tm,MAX_COVER_SLIDE_DURATION_SECONDS:()=>60,PAGE_BASE_CSS:()=>im,PATH_SHAPE_KINDS:()=>Ce,SHAPE_NAMES:()=>Go,TABLE_FED_TEMPLATES:()=>ve,TEMPLATE_AUTHORING_METADATA:()=>Yl,TEMPLATE_INPUT_DESCRIPTORS:()=>$c,TEMPLATE_METADATA:()=>Jl,TREE_FENCE_LANGS:()=>Vr,VIEWPORT_PRESETS:()=>f,adjustY:()=>W,anchorPoint:()=>Me,applyNarrationTiming:()=>jh,applyRenderStyleToLayers:()=>Hc,asciiCellToCanvas:()=>Oa,asciiDiagramFromBlocks:()=>Fa,asciiDiagramFromTemplateData:()=>Pa,asciiDiagramToTemplateData:()=>Aa,asciiTimelineToTemplateData:()=>Ia,autoTemplatePreservesContent:()=>lo,bigText:()=>sa,buildDashboardCellChrome:()=>rh,buildPageCss:()=>am,buildPageCssVars:()=>tm,buildPreviewDoc:()=>ap,buildRegistry:()=>Ic,canvasToAsciiCell:()=>ka,chooseDashboardLayout:()=>Km,clipEndpoints:()=>Ae,clipPoint:()=>ke,coerceTemplateParams:()=>rl,comparisonBar:()=>yo,composeDashboardLayers:()=>Ch,computeDiagramLayout:()=>wa,computeDrawingLayout:()=>$o,computeLayoutLayers:()=>bs,connectorPath:()=>Le,contentBlock:()=>ua,countBlocks:()=>_d,coverBlock:()=>ru,createAccentLayers:()=>Gi,createTemplateContext:()=>p,cssFilterForTreatment:()=>Sf,dashboardCanvasFill:()=>$m,dashboardCellAccent:()=>eh,dataTable:()=>Co,dateEvent:()=>ga,definitionCard:()=>vo,deriveTemplateInputs:()=>uo,desiredCellZoom:()=>dm,detectAsciiDiagram:()=>sn,detectAsciiTimeline:()=>xr,detectTree:()=>Yr,diagramBlock:()=>No,docToMarkdown:()=>Pf,documentTitleFromFileName:()=>rp,drawingBlock:()=>us,expandCoverBlock:()=>au,expandDocBlocks:()=>su,expandPersistentLayers:()=>Si,extractBlockquoteText:()=>no,extractBodyPlainText:()=>Ga,extractEmbeddedVideos:()=>$a,extractFirstEmbeddedVideo:()=>eo,extractFirstImage:()=>Qa,extractImages:()=>Za,extractListItems:()=>Ka,extractRichListItems:()=>Ya,extractTableData:()=>Nu,extractTableFromContents:()=>to,factCard:()=>pa,fallbackBlockLayers:()=>dl,findFirstList:()=>Ua,findFirstTable:()=>Mu,fitBigTextSize:()=>aa,fitDiagramLabel:()=>To,flattenBlocks:()=>hd,flattenRenderableBlocks:()=>gd,fullBleedQuote:()=>Sa,getAccentLayout:()=>Wi,getAnimationProgress:()=>vf,getAnimationStyle:()=>sf,getAvailableTemplates:()=>cu,getAvailableThemes:()=>T,getBlockBodyText:()=>Dd,getBlockDepth:()=>vd,getBlockMediaLayoutPolicy:()=>_l,getDashboardLayoutSummaries:()=>Hm,getDefaultAnimation:()=>ji,getDefaultAnimationDuration:()=>uf,getLayoutHints:()=>g,getOverlayOpacity:()=>Mi,getPersistentLayersFromTheme:()=>Ci,getPinnedBlockMeta:()=>dd,getTemplateHint:()=>Pi,getThemeFont:()=>L,getThemeSummaries:()=>ne,getTransitionClass:()=>df,getTwoColumnPositions:()=>c,getViewport:()=>d,getViewportOrientation:()=>_,hasTemplate:()=>lu,imageWithCaption:()=>_a,isAsciiDiagramFence:()=>cn,isAsciiTimelineFence:()=>Sr,isContainerTemplate:()=>se,isDataFence:()=>Tu,isEligibleAsciiFenceLang:()=>an,isEligibleAsciiTimelineFenceLang:()=>yr,isEligibleTreeFenceLang:()=>qr,isExplicitDiagramLang:()=>on,isExplicitTimelineLang:()=>br,isExplicitTreeLang:()=>Jr,isRepairableDiagram:()=>Wg,isShapeName:()=>Jo,isTemplateBlock:()=>u,isTemplatedPageBlock:()=>sp,isTreeFence:()=>Xr,isWrappedFlowTimelineSource:()=>vn,layoutBlock:()=>ws,layoutCapacity:()=>Sm,leftFeature:()=>ya,lineStyleDasharray:()=>Be,lintTemplateParams:()=>ll,listBlock:()=>ho,listDashboardLayouts:()=>Um,mapBlock:()=>xa,markdownToDoc:()=>md,markerPath:()=>Oe,materializeBlockLayers:()=>Fl,materializeDashboard:()=>Sh,materializePageSection:()=>Qp,materializePageSections:()=>$p,nearestSnapPoint:()=>Ne,normalizeDashboardZoom:()=>sm,normalizeShapeKind:()=>qo,pageStyleDataAttributes:()=>nm,parseAsciiDiagram:()=>Dt,parseAsciiTimeline:()=>In,parseAsciiTimelineWithStats:()=>Ln,parseDataFence:()=>Eu,parseTree:()=>Fr,parseWrappedFlowTimeline:()=>_n,parseYamlSubset:()=>ju,photoGrid:()=>go,pullQuote:()=>bo,quoteBlock:()=>fa,readCustomTemplatesFromFrontmatter:()=>hu,readCustomThemesFromFrontmatter:()=>Su,readDashboardLayoutsFromFrontmatter:()=>km,renderAsciiDiagram:()=>Sg,renderAsciiTimeline:()=>l_,renderTree:()=>O_,repairAsciiDiagram:()=>Gg,replaceDataFence:()=>Du,resolveAudioMapping:()=>Jh,resolveColorScheme:()=>I,resolveCoverSlideSettings:()=>jf,resolveDashboardLayoutDefinition:()=>Gm,resolveDashboardSettings:()=>fh,resolveDashboardStyleId:()=>Xm,resolveDashboardZooms:()=>fm,resolveLayoutCells:()=>wm,resolvePageBlock:()=>lp,resolvePageStyle:()=>Lp,resolvePersistentLayers:()=>wi,resolveTemplateName:()=>j,resolveTheme:()=>O,resolveThemeForDoc:()=>op,rightFeature:()=>ba,scaleAnimationDuration:()=>Ai,scaledFontSize:()=>m,scoreTextSimilarity:()=>Ph,sectionExtractors:()=>Ip,sectionHeader:()=>Qi,shapePath:()=>Ee,shouldUseShadow:()=>B,snapEndpoints:()=>Pe,snapPoints:()=>je,statHighlight:()=>da,stripBlockBackdropLayer:()=>ah,stripsBlockBackdrop:()=>ih,templateRegistry:()=>Fc,themeWantsAmbientMotion:()=>Vc,themedEntrance:()=>z,themedFontSize:()=>R,themedImageTreatment:()=>V,themedScrim:()=>Ni,themedSurfaceGradient:()=>H,timelineBlock:()=>Wo,titleBlock:()=>Ri,transposeCells:()=>Cm,treeBlock:()=>Io,treeFromMarkdownList:()=>Ha,treeFromTemplateData:()=>Ba,treeToTemplateData:()=>Ra,twoColumn:()=>ma,validateDashboardLayoutDefinition:()=>xm,validateMarkdownDoc:()=>Zh,validateMarkdownSource:()=>Xh,videoPullQuote:()=>So,videoWithCaption:()=>xo,wrapWithPersistentLayers:()=>Ti,writeCustomTemplatesToFrontmatter:()=>gu,writeCustomThemesToFrontmatter:()=>Cu,writeDashboardLayoutsToFrontmatter:()=>Am});export{no as $,Lp as A,In as At,Oa as B,Pe as Bt,Sg as C,yr as Ct,Jh as D,Jr as Dt,Gg as E,br as Et,rf as F,He as Ft,ka as G,Ia as H,Da as I,Le as It,_d as J,$o as K,Ea as L,Oe as Lt,nf as M,ii as Mt,of as N,ci as Nt,jf as O,vn as Ot,af as P,Me as Pt,Kd as Q,wo as R,Ne as Rt,nm as S,an as St,O_ as T,on as Tt,Bd as U,Aa as V,Yd as W,au as X,uo as Y,su as Z,df as _,gu as _t,oh as a,hd as at,Sh as b,xr as bt,sh as c,dd as ct,tm as d,Fl as dt,Ga as et,ap as f,hu as ft,sf as g,qd as gt,rp as h,Jd as ht,Wm as i,To as it,op as j,Fr as jt,Xm as k,Dt as kt,Jm as l,lu as lt,Pf as m,wi as mt,wf as n,Ka as nt,Ym as o,gd as ot,Sf as p,Su as pt,bs as q,Cf as r,to as rt,Tf as s,cu as st,k_ as t,Za as tt,im as u,md as ut,Wg as v,Cu as vt,l_ as w,qr as wt,$p as x,Yr as xt,Um as y,sn as yt,Jl as z,Ee as zt};
|