@bendyline/gezel-service 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/NOTICE.md +1 -1
  2. package/dist/bin/gezeld.js +51635 -50059
  3. package/dist/handboek-content/README.md +24 -2
  4. package/dist/handboek-content/conceptual/connected-apps.md +2 -0
  5. package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +144 -0
  6. package/dist/handboek-content/technical/cli-reference.md +11 -0
  7. package/dist/handboek-content/technical/how-we-test-models.md +57 -9
  8. package/dist/handboek-content/technical/model-scorecard.md +27 -9
  9. package/dist/handboek-content/technical/npm-packages.md +67 -0
  10. package/dist/handboek-content/technical/security-model.md +18 -1
  11. package/dist/handboek-content/technical/where-files-live.md +3 -0
  12. package/dist/handboek-content/technical/writing-scripts-with-gezel-sdk.md +106 -0
  13. package/dist/handboek-content/whats-new/1.26223.md +82 -0
  14. package/dist/handboek-content/whats-new/whats-new-index.md +28 -0
  15. package/dist/handboek.d.ts +53 -26
  16. package/dist/handboek.js +103 -26
  17. package/dist/index-store/static-index-worker.js +476 -82
  18. package/dist/index.d.ts +206 -11
  19. package/dist/index.js +51615 -50051
  20. package/dist/ui/assets/{TerminalCodeEditor-CB-AXtKI.js → TerminalCodeEditor-DQICIlaI.js} +2 -2
  21. package/dist/ui/assets/{_.contribution-C6KlZ1yR.js → _.contribution-BXBGjh98.js} +1 -1
  22. package/dist/ui/assets/{chunk-6N2J7C2B-DIF7DJtk.js → chunk-6N2J7C2B-Du7clJkV.js} +1 -1
  23. package/dist/ui/assets/chunk-ILCJ3WFD-fHFoZ9wm.js +4 -0
  24. package/dist/ui/assets/{chunk-S5PCVMKU-CmFF6ff9.js → chunk-S5PCVMKU-DopU3Q9j.js} +2 -2
  25. package/dist/ui/assets/chunk-USU6HTKB-B-ElCUQS.js +1 -0
  26. package/dist/ui/assets/{chunk-WATAOG4Y-perfmDXF.js → chunk-WATAOG4Y-BnCgSncI.js} +1 -1
  27. package/dist/ui/assets/{cpp.contribution-BBBWN3Dm.js → cpp.contribution-UC-hXlnG.js} +1 -1
  28. package/dist/ui/assets/{csharp.contribution-jBA6TWhG.js → csharp.contribution-VSLdDbxa.js} +1 -1
  29. package/dist/ui/assets/{css.contribution-DQSNU6vC.js → css.contribution-DC9uQgZx.js} +1 -1
  30. package/dist/ui/assets/{cssMode-68UP_lrS.js → cssMode-DZsXawIN.js} +1 -1
  31. package/dist/ui/assets/{csv-Ctux8fO7.js → csv-RAgECoUg.js} +1 -1
  32. package/dist/ui/assets/dist-D6I_6t8i.js +195 -0
  33. package/dist/ui/assets/dist-a57vyaRu.js +2 -0
  34. package/dist/ui/assets/{doc-BdMAKGDm.js → doc-B7NXSLxH.js} +33 -23
  35. package/dist/ui/assets/{dockerfile.contribution-CSpSPKgK.js → dockerfile.contribution-PUE2MRJF.js} +1 -1
  36. package/dist/ui/assets/docx-IZY6hX8A.js +2 -0
  37. package/dist/ui/assets/{epub-oLed1tAU.js → epub-00L2M424.js} +1 -1
  38. package/dist/ui/assets/extract-UTAOG7LV-BZ_L7lLL.js +1 -0
  39. package/dist/ui/assets/{go.contribution-BjibqVfF.js → go.contribution-CsrBAk1W.js} +1 -1
  40. package/dist/ui/assets/{handlebars-Dq5dJ5WJ.js → handlebars-Bqyi6xyi.js} +1 -1
  41. package/dist/ui/assets/handlebars.contribution-C6VLDI51.js +2 -0
  42. package/dist/ui/assets/{html-fQ6X2xaa.js → html-Cgejr9YM.js} +24 -24
  43. package/dist/ui/assets/{html-Bgyk9kiZ.js → html-NLb64cMt.js} +1 -1
  44. package/dist/ui/assets/html.contribution-BP2a6izy.js +2 -0
  45. package/dist/ui/assets/{htmlMode-D5UKInqK.js → htmlMode-Utzysyes.js} +1 -1
  46. package/dist/ui/assets/{index-CPXp6BEZ.js → index-B_NFDPxp.js} +197 -195
  47. package/dist/ui/assets/index-CgP6VwNS.css +1 -0
  48. package/dist/ui/assets/infer-v-bCXeT9.js +2 -0
  49. package/dist/ui/assets/{ini.contribution-BiJ4T5K-.js → ini.contribution-CfehzoVj.js} +1 -1
  50. package/dist/ui/assets/{java.contribution-B8o1lBqP.js → java.contribution-CXk8bwAp.js} +1 -1
  51. package/dist/ui/assets/{javascript-COWkS1tr.js → javascript-BcbxETop.js} +1 -1
  52. package/dist/ui/assets/javascript.contribution-BRDuHf7J.js +2 -0
  53. package/dist/ui/assets/{jsonMode-CWWZvfzr.js → jsonMode-BORbF5qz.js} +1 -1
  54. package/dist/ui/assets/{kotlin.contribution-CxSOPQ6P.js → kotlin.contribution-CbKeqa_3.js} +1 -1
  55. package/dist/ui/assets/layouts-2A7QNF6Y-D94iKLLQ.js +1 -0
  56. package/dist/ui/assets/{less.contribution-Cthyflev.js → less.contribution-BgNGBZAo.js} +1 -1
  57. package/dist/ui/assets/{lua.contribution-894DRgPR.js → lua.contribution-CtZNsqOj.js} +1 -1
  58. package/dist/ui/assets/{markdown.contribution-d_TBTsNA.js → markdown.contribution-CNyxmHy1.js} +1 -1
  59. package/dist/ui/assets/{monaco-PebRhLpo.js → monaco-Ryh-SF_b.js} +3 -3
  60. package/dist/ui/assets/{monaco-base-4S0M5BiY.js → monaco-base-C-4W0je-.js} +1 -1
  61. package/dist/ui/assets/{monaco-setup-7hp0Z9jn.js → monaco-setup-BW0DQ8MV.js} +1 -1
  62. package/dist/ui/assets/{monaco.contribution-DQjPk7Rx.js → monaco.contribution-279M9-Uu.js} +2 -2
  63. package/dist/ui/assets/{monaco.contribution-CKDvyGVE.js → monaco.contribution-Bu1oyef5.js} +2 -2
  64. package/dist/ui/assets/{monaco.contribution-BL_zgiu2.js → monaco.contribution-C57BAnnI.js} +2 -2
  65. package/dist/ui/assets/{monaco.contribution-D61txvUB.js → monaco.contribution-o3cuP4Wp.js} +2 -2
  66. package/dist/ui/assets/{pdf-CwJ6ZJmB.js → pdf-66KslaXf.js} +1 -1
  67. package/dist/ui/assets/{php.contribution-B8kn8QoR.js → php.contribution-BulxzIpe.js} +1 -1
  68. package/dist/ui/assets/pptx-CsdVR0xn.js +6 -0
  69. package/dist/ui/assets/{python-CHygH1eM.js → python-D4zGC71G.js} +1 -1
  70. package/dist/ui/assets/python.contribution-CDI1t73R.js +2 -0
  71. package/dist/ui/assets/{ruby.contribution-BQdPKFM2.js → ruby.contribution-DVOdhLt8.js} +1 -1
  72. package/dist/ui/assets/{rust.contribution-D7wKqShc.js → rust.contribution-DLR9kg2m.js} +1 -1
  73. package/dist/ui/assets/{scss.contribution-kSTLMoty.js → scss.contribution-CYIIxBxH.js} +1 -1
  74. package/dist/ui/assets/{shell.contribution-BQnT3BBJ.js → shell.contribution-D0KjHQ5E.js} +1 -1
  75. package/dist/ui/assets/{sql.contribution-C9z55nWb.js → sql.contribution-CKhLelqr.js} +1 -1
  76. package/dist/ui/assets/{swift.contribution-BZoW5ZZj.js → swift.contribution-DiAAMfJp.js} +1 -1
  77. package/dist/ui/assets/{terminal-monaco-setup-DbSXji0d.js → terminal-monaco-setup-Dhxpm7Z8.js} +1 -1
  78. package/dist/ui/assets/{tsMode-jPpKNC6E.js → tsMode-DFEqg3P9.js} +1 -1
  79. package/dist/ui/assets/{typescript-Djn_8BHF.js → typescript-X_x8S3Dp.js} +1 -1
  80. package/dist/ui/assets/typescript.contribution-jI3BakLa.js +2 -0
  81. package/dist/ui/assets/xlsx-CdLmEC42.js +4 -0
  82. package/dist/ui/assets/{xml-DmE4Aqa-.js → xml-ANmRi8ZZ.js} +1 -1
  83. package/dist/ui/assets/xml.contribution-D5t83zAi.js +2 -0
  84. package/dist/ui/assets/{yaml-BjmK3C-c.js → yaml-R4WpJved.js} +1 -1
  85. package/dist/ui/assets/yaml.contribution-DV8dAjKa.js +2 -0
  86. package/dist/ui/index.html +15 -15
  87. package/package.json +13 -15
  88. package/dist/postinstall.d.ts +0 -2
  89. package/dist/postinstall.js +0 -40
  90. package/dist/ui/assets/chunk-ILCJ3WFD-uwKSpQd8.js +0 -4
  91. package/dist/ui/assets/chunk-USU6HTKB-hbaA8KyS.js +0 -1
  92. package/dist/ui/assets/dist-i9jV8CX8.js +0 -2
  93. package/dist/ui/assets/dist-jh33rACm.js +0 -195
  94. package/dist/ui/assets/docx-CNW-xqHT.js +0 -2
  95. package/dist/ui/assets/extract-UTAOG7LV-WxmEnrrc.js +0 -1
  96. package/dist/ui/assets/handlebars.contribution-DDSQBNPu.js +0 -2
  97. package/dist/ui/assets/html.contribution-DrClfj2L.js +0 -2
  98. package/dist/ui/assets/index-Caz-FRQy.css +0 -1
  99. package/dist/ui/assets/infer-Cc7ks6NX.js +0 -2
  100. package/dist/ui/assets/javascript.contribution-DMEzq0y4.js +0 -2
  101. package/dist/ui/assets/layouts-2A7QNF6Y-DR7-KboS.js +0 -1
  102. package/dist/ui/assets/pptx-Bmj2v9CT.js +0 -6
  103. package/dist/ui/assets/python.contribution-CmwCxp-v.js +0 -2
  104. package/dist/ui/assets/typescript.contribution-D4JmB9tz.js +0 -2
  105. package/dist/ui/assets/xlsx-BCnO44v8.js +0 -4
  106. package/dist/ui/assets/xml.contribution-BepqhMeK.js +0 -2
  107. package/dist/ui/assets/yaml.contribution-BwT8qEVt.js +0 -2
  108. package/postinstall.mjs +0 -8
@@ -21,16 +21,18 @@ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p
21
21
  `).reduce((e,r)=>e+wo(r,t,n),0)}function wo(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 To=180,Eo=64,Do=80;function Oo(e){let t=xa(e.children??[]);return{nodes:t.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:To,h:Eo,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 ko(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:To,h:typeof e.h==`number`&&Number.isFinite(e.h)&&e.h>0?e.h:Eo,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 Ao(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=e.colorScheme?L(t,e.colorScheme):void 0,o=i.length>0?Oo(t):e.nodes&&e.nodes.length>0?ko(e):{nodes:[],edges:[]};if(o.nodes.length===0)return[{type:`text`,id:`diagram-empty`,content:{text:e.title??`Empty diagram`,style:{fontSize:z(36,t,!0),fontFamily:R(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-Do*2),p=Math.max(1,r.height-Do*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(Do/2,(r.height-d-b)/2),S=Do+(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:z(40,t,!0),fontFamily:R(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=Re(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=Me(i,o),l=r.sourceAnchor?Ae(i,r.sourceAnchor):c.start,u=r.targetAnchor?Ae(o,r.targetAnchor):c.end,d={type:`path`,id:`edge-${r.id}`,content:{d:Fe(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=z(Math.round(18*_),t,!1),c={type:`text`,id:`edge-label-${r.id}`,content:{text:r.label,style:{fontSize:s,fontFamily:R(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=z(Math.round(22*_),t,!1),c=So(r.label,i.w,i.h,s),l={type:`text`,id:`node-label-${r.id}`,content:{text:r.label,style:{fontSize:c.fontSize,fontFamily:R(t,`body`),fontWeight:`bold`,color:a?.text??n.colors.text,textAlign:`center`,lineHeight:xo}},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=z(Math.round(20*_),t,!1),a={type:`text`,id:`node-label-${e.id}`,content:{text:e.label.split(`
22
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
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}=n,f=e.length,m=s&&s.length>0?Nc(s):Mc,h=a===!1?void 0:a??r.persistentLayers,g=h?{bottomLayers:yi(h.bottomLayers,r),topLayers:yi(h.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=ru(e,n,f,r,i,h,g,m,c,l);return a.startTime=t,t+=a.duration,a})}let _=new Map;e.forEach((e,t)=>{let n=e.audioSegment??0;_.has(n)||_.set(n,[]),_.get(n).push({block:e,originalIndex:t})});let v=Array(e.length);for(let[e,t]of _){let n=o[e];if(!n){let e=0;for(let{block:n,originalIndex:a}of t){let t=ru(n,a,f,r,i,h,g,m,c,l);t.startTime=e,e+=t.duration,v[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),_=s.reduce((e,{block:t})=>e+(t.duration??0),0),y=n.duration-p,b=_>0&&y>0?y/_:1,x=[];for(let{block:e,originalIndex:n}of t){let t=ru(e,n,f,r,i,h,g,m,c,l),a=e;x.push({block:t,originalIndex:n,templateBlock:a,hasSourceTiming:typeof a.sourceStartTime==`number`})}let S=x.some(e=>e.hasSourceTiming);x.sort((e,t)=>{if(S){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 C=0;for(let e=0;e<x.length;e++){let t=x[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)),C=e+r.duration}else if(i.template===`sectionHeader`)r.startTime=n.startTime+C,C+=r.duration;else{r.startTime=n.startTime+C;let e=r.duration*b;r.duration=e,C+=e}v[t.originalIndex]=r}let w=x.map(e=>v[e.originalIndex]).sort((e,t)=>e.startTime-t.startTime);for(let e=0;e<w.length-1;e++){let t=w[e],n=w[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 T=n.startTime+n.duration;for(;w.length>1;){let e=w[w.length-1];if(T-e.startTime<5&&e.template!==`sectionHeader`){let t=w[w.length-2];t.duration=T-t.startTime,e.duration=0,e.startTime=T,w.pop()}else{e.startTime+e.duration<T&&(e.duration=T-e.startTime);break}}if(w.length===1){let e=w[0];e.startTime+e.duration<T&&(e.duration=T-e.startTime)}let E=!0;for(;E;){E=!1;for(let e=w.length-1;e>=1;e--){let t=w[e];if(t.duration>0&&t.duration<5){let n=w[e-1];n.duration=t.startTime+t.duration-n.startTime,t.duration=0,t.startTime=T,w.splice(e,1),E=!0;break}}}if(u)for(let e=0;e<w.length;e++){let t=w[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};v.push(e)}}}}}return v.filter(e=>e&&e.duration>0)}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(`
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
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
26
  `).trim()}var Td=12;function Ed(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>Td){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 Dd(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=Dd(t.children);if(e)return e}}function Od(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=Dd(t.htmlChildren);if(e)return e}}if(`children`in e&&Array.isArray(e.children))for(let t of e.children){let e=Od(t);if(e)return e}}function kd(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 Ad(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 jd(e,t,n){let r=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():void 0,i=kd(t),a=i?i.title??o(i.sourceHeading):void 0,s=r||a||Ad(n);if(!s)return;let c=i??t[0],l=c?.contents?.[0]?.type===`paragraph`?o(c.contents[0]):void 0,u=Od(e);return{title:s,...l?{subtitle:l}:{},...u?{heroSrc:u.url,heroAlt:u.alt??s}:{},ambientMotion:`zoomIn`}}var Md=/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,Nd=1.4;function Pd(e){let t=e.replace(Md,``);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(ye(t)*Nd))}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+=Fd(e.replace(/'/g,``));return Math.max(1,r)}function Fd(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 Id(e,t){let n=t&&e.title?e.title.trim():``,r=wd(e);return n&&r?`${n}
27
27
  ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
28
28
 
29
29
  `,i=[];for(let t of pd(e.blocks)){let e=Id(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=zd(u[0]);s.push({text:u[0],charOffset:e,charEnd:t,blockId:o[l]?.blockId??``,blockIndex:l,syllables:n?Pd(u[0]):0,spokenWordEquiv:n?ye(Bd(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: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}}function Xd(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:Zd(e),style:Qd(e)}}function Zd(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 Qd(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 $d(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 ef(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${nf(e,n)}-${r}`}var tf={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 nf(e,t){switch(e){case`randomBars`:case`randomBar`:return af(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return af(`comb`,t,`Horizontal`);case`blinds`:return af(`blinds`,t,`Horizontal`);case`split`:return af(`split`,t,`Horizontal`);case`push`:return rf(`push`,t,`Left`);case`wipe`:return rf(`wipe`,t,`Left`);case`cover`:return rf(`cover`,t,`Left`);case`uncover`:return rf(`uncover`,t,`Left`);case`pull`:return rf(`pull`,t,`Left`);case`reveal`:return rf(`reveal`,t,`Left`);case`strips`:return rf(`strips`,t,`Left`);case`pan`:return rf(`pan`,t,`Left`);default:return tf[e]}}function rf(e,t,n){return`${e}${of(t,n)}`}function af(e,t,n){return`${e}${sf(t,n)}`}function of(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function sf(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function cf(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var lf=40,uf=e=>Math.max(0,Math.min(1,e)),df=e=>Math.round(e*100)/100;function ff(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=uf(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${df(t)})`,`contrast(${df(1+.05*t)})`);break;case`duotone`:{let r=ne(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${df(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-lf)}deg)`,`saturate(${df(1+t)})`);break}case`warm`:n.push(`sepia(${df(.4*t)})`,`saturate(${df(1+.15*t)})`);break;case`cool`:n.push(`saturate(${df(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${df(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var pf=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}]),mf=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`}}),hf=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function gf(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function _f(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 vf(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 yf(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 bf(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 xf(e,t={}){let n={enabled:_f(gf(e,mf.enabled))??hf.enabled,template:vf(gf(e,mf.template))??hf.template,duration:yf(gf(e,mf.duration))??hf.duration,playback:bf(gf(e,mf.playback))??hf.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:yf(t.duration)??n.duration,playback:t.playback??n.playback}}var Sf=[`transition`,`transitionDuration`,`transitionDirection`],Cf=`sectionHeader`;function wf(e,t={}){let n=j(t.defaultTemplate??Cf),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(Of(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!Ef(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=kf(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(Tf(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,Of(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(Of(e))}if(i&&Df(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 Tf(e){return{type:`paragraph`,children:[{type:`text`,value:ce(e.sourceAnnotation?.template,e.templateOverrides)}]}}function Ef(e,t){let n=j(e.template??``)===j(t.template),r=Mf(e.templateOverrides??{},t.params??{});return!(n&&r)}function Df(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 Of(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 kf(e,t,n){let{attributes:r,transitionParams:i}=Nf(e,t),a=t.templateAnnotation,o=Af(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}}),jf(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function Af(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 jf(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&Mf(e.params,t.params)}function Mf(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 Nf(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=Pf(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 Pf(e){if(!e?.params)return e;let t={...e.params};for(let e of Sf)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function Ff(e,t,r){let i=t??e?.themeId??n(e?.frontmatter),a=e?.customThemes??yu(e?.frontmatter);return(i?a?.find(e=>e.id===i):void 0)||D(i,r)}function If(e){return e.sourceHeading?.templateAnnotation?.template||e.autoTemplate&&e.template?!0:!e.sourceHeading&&l(e)}function Lf(e){return e.sourceHeading?.templateAnnotation?.template??e.template}function Rf(e){if(!If(e))return{templated:!1};let t=e.sourceHeading?.templateAnnotation,n=Lf(e)??`sectionHeader`,r=j(n),i=el(n,{...t?.params??{},...e.templateOverrides??{}}).input,a,s=null;if(t){let t=o(e.sourceHeading);s=so(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 zf(e){let t=e.contents;if(!t||t.length===0)return;let n=t.map(e=>o(e)).join(`
31
- `).trim();return n?{text:n,markdown:t}:void 0}function Bf(e){if(e?.src)return{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}function Vf(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 Hf=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}},Uf=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}},Wf=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}},Gf=e=>({kind:`prose`,slots:{title:e.title,body:zf(e)}}),Kf=e=>{let t=e;return{kind:`stat-band`,variant:`single`,slots:{items:[{value:t.stat,title:t.description,body:t.detail}],media:Bf(t.accentImage)},emphasis:`strong`,colorScheme:t.colorScheme}},qf=e=>{let t=e;return{kind:`quote-band`,variant:`plain`,slots:{title:t.title,body:{text:t.quote??``},attribution:t.attribution,media:Bf(t.accentImage)}}},Jf=e=>{let t=e;return{kind:`callout`,variant:`fact`,slots:{title:t.fact,body:{text:t.explanation??``},meta:t.source,media:Bf(t.accentImage)}}},Yf=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}]}}},Xf=e=>{let t=e;return{kind:`timeline-rail`,slots:{milestone:{date:t.date??``,description:t.description??``,footer:t.footer,mood:t.mood},media:Bf(t.accentImage)}}},Zf=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 Qf(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 $f=e=>Qf(e,`left`),ep=e=>Qf(e,`right`),tp=e=>{let t=e;return{kind:`quote-band`,variant:`display`,slots:{body:{text:t.text??``}},emphasis:`strong`,colorScheme:t.colorScheme}},np=e=>{let t=e,n=e.contents,r=Ka(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:Bf(t.accentImage)},colorScheme:t.colorScheme}},rp=e=>{let t=e,n=t.images??[];return{kind:`gallery`,slots:{...n.length===0?{title:e.title,body:zf(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}}))}}},ip=e=>{let t=e;return{kind:`callout`,variant:`definition`,slots:{title:t.term,body:{text:t.definition??``},meta:t.origin,media:Bf(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}},op=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}},sp=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}}},cp=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}},lp=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}},up=(e,t)=>{let n=e;return Array.isArray(n.headers)&&Array.isArray(n.rows)&&Js({headers:n.headers,rows:n.rows},n)!==null?Vf(`chart`,t,e):Gf(e,t)},dp={title:Hf,sectionHeader:Uf,bigText:Wf,content:Gf,statHighlight:Kf,quote:qf,factCard:Jf,twoColumn:Yf,dateEvent:Xf,imageWithCaption:Zf,leftFeature:$f,rightFeature:ep,map:(e,t)=>Vf(`map`,t,e),fullBleedQuote:tp,list:np,photoGrid:rp,definitionCard:ip,comparisonBar:ap,pullQuote:op,videoWithCaption:sp,videoPullQuote:cp,dataTable:lp,barChart:up,columnChart:up,pieChart:up,donutChart:up,lineChart:up,areaChart:up,scatterChart:up,diagram:(e,t)=>Vf(`diagram`,t,e),tree:(e,t)=>Vf(`tree`,t,e),timeline:(e,t)=>Vf(`timeline`,t,e),layout:(e,t)=>Vf(`layout`,t,e),drawing:(e,t)=>Vf(`drawing`,t,e)};function fp(e,t){let n=e?.pageStyle??ee(e??k);return!t?.spacing||t.spacing===n.tokens.sectionSpacing?n:{...n,tokens:{...n.tokens,sectionSpacing:t.spacing}}}var pp=new Set([`banner`,`stat-band`,`quote-band`,`callout`,`card-grid`,`item-list`,`timeline-rail`,`footer`]),mp=new Set([`banner`,`quote-band`,`stat-band`,`footer`]),hp=new Set([`callout`,`card-grid`,`stat-band`,`item-list`,`timeline-rail`,`table-section`]);function gp(e){return e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`}function _p(e,t){if(gp(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 vp(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)&&vp(e.children))return!0}return!1}function yp(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)&&vp(t.htmlChildren)?!0:Array.isArray(t.children)&&t.children.some(yp)}function bp(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=>_p(e,n)||!r&&yp(e));if(i.length!==0)return{text:i.map(e=>o(e)).join(`
32
- `).trim(),markdown:i}}function xp(e,t,n){let r=bp(e,t,n);return r?{...t,slots:{...t.slots,richContent:r}}:t}function Sp(e,t,n,r){if(If(e)){let i=Rf(e),a=i.templateName,s=dp[a];if(s)return{draft:xp(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:xp(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:xp(e,{kind:`callout`,variant:`diagnostic`,slots:{title:(e.sourceHeading?o(e.sourceHeading):void 0)??l.message,body:{text:Ha(e.contents)},meta:l.message},emphasis:`quiet`},r),source:`fallback`,templateName:a,diagnostic:l}}if(e.layers&&e.layers.length>0)return{draft:xp(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:Ha(e.contents),markdown:e.contents}:void 0}},source:`prose`}}function Cp(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 wp(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 Tp(e,t){return t?e.colorSchemes?.[t]:void 0}function Ep(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 Dp(e,t={}){let n=t.theme??k,r=t.viewport??p.landscape,i=fp(n),a=Sp(e,r,t.customTemplates,t.widgetFenceLangs),o=Cp(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:Tp(n,a.draft.colorScheme),role:`block`}:{role:i.accentRotation.strategy===`none`?`none`:`primary`};return{section:wp({...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 Op(e,t={}){let n=t.theme??k,r=t.viewport??p.landscape,i=fp(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=Sp(i,r,a,t.widgetFenceLangs);s.push({...e,block:i,depth:n}),!(e.draft.kind===`canvas-embed`&&ae(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(`
33
- `).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override=Cp(i,e.draft.kind,e.templateName);let l=s.length,u=i.tokens.backgroundRhythm,d=i.accentRotation.strategy,f=Ep(i,n),m=d===`alternate-two`?Math.min(2,f.length):f.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`&&mp.has(i)?a=`accent`:u===`tinted-panels`?a=hp.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:Tp(n,r.draft.colorScheme),role:`block`};else if(pp.has(i)&&(d===`cycle`||d===`alternate-two`)&&m>0){let e=f[g%m];g++,o={schemeName:e,scheme:Tp(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 p=wp(r,e,l,a,c,o);b.push({section:p,block:r.block,source:r.source,diagnostic:r.diagnostic})}return b}var kp=`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 Ap(e,t){let n=e??k,r=t??fp(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":C(a.titleFont,`Georgia, serif`),"--squisq-page-body-font":C(a.bodyFont,`system-ui, sans-serif`),"--squisq-page-mono-font":C(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 jp(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 Mp=`
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(Hf).join(r)}function Uf(e){if(!e||e.length===0)return``;let t=[];for(let n of e)n.type===`code`&&n.lang?.trim().toLowerCase()===`mermaid`||t.push(Hf(n));return t.join(`
32
+ `).trim()}function Wf(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function Gf(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:Wf(e?.width),height:Wf(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 Kf(e){let t=new Set,n=[];function r(e){for(let i of e){for(let e of Gf(i.contents))t.has(e.src)||(t.add(e.src),n.push(e));i.children&&r(i.children)}}return r(e),n}function qf(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 Jf(e,t,n){let r=Uf(n.contents);switch(e){case`statHighlight`:return so(e,t,n.contents)??{stat:t,description:r||t};case`quote`:return{quote:r||t};case`fullBleedQuote`:case`pullQuote`:return so(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=qf(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=Gf(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 Yf(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=ou(a)||s?a:`sectionHeader`,l=Jf(c,i,e),u=Qf(e.templateOverrides),d=u?el(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,...Zf(e.templateData),...d}}var Xf=new Set(Object.keys(ie));function Zf(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(Xf.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}function Qf(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(Xf.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}var $f=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`];function ep(e){return e?(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).trim():``}function tp(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function np(e,t){let n=pd(e.blocks),r=Kf(e.blocks),i=new Set,a=e.customTemplates?new Set(e.customTemplates.map(e=>e.name)):void 0,o=tp(e,t?.documentTitle),s=[],c=0;for(let e=0;e<n.length;e++){let t=n[e],r=Gf(t.contents),l=Yf(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=$f[c++%$f.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:$f[c++%$f.length]}}s.push(l)}let l=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:$f[c++%$f.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 rp(e,t,r){let i=t??e?.themeId??n(e?.frontmatter),a=e?.customThemes??yu(e?.frontmatter);return(i?a?.find(e=>e.id===i):void 0)||D(i,r)}function ip(e){return e.sourceHeading?.templateAnnotation?.template||e.autoTemplate&&e.template?!0:!e.sourceHeading&&l(e)}function ap(e){return e.sourceHeading?.templateAnnotation?.template??e.template}function op(e){if(!ip(e))return{templated:!1};let t=e.sourceHeading?.templateAnnotation,n=ap(e)??`sectionHeader`,r=j(n),i=el(n,{...t?.params??{},...e.templateOverrides??{}}).input,a,s=null;if(t){let t=o(e.sourceHeading);s=so(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 sp(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 cp(e){if(e?.src)return{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}function lp(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 up=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}},dp=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}},fp=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}},pp=e=>({kind:`prose`,slots:{title:e.title,body:sp(e)}}),mp=e=>{let t=e;return{kind:`stat-band`,variant:`single`,slots:{items:[{value:t.stat,title:t.description,body:t.detail}],media:cp(t.accentImage)},emphasis:`strong`,colorScheme:t.colorScheme}},hp=e=>{let t=e;return{kind:`quote-band`,variant:`plain`,slots:{title:t.title,body:{text:t.quote??``},attribution:t.attribution,media:cp(t.accentImage)}}},gp=e=>{let t=e;return{kind:`callout`,variant:`fact`,slots:{title:t.fact,body:{text:t.explanation??``},meta:t.source,media:cp(t.accentImage)}}},_p=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}]}}},vp=e=>{let t=e;return{kind:`timeline-rail`,slots:{milestone:{date:t.date??``,description:t.description??``,footer:t.footer,mood:t.mood},media:cp(t.accentImage)}}},yp=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 bp(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 xp=e=>bp(e,`left`),Sp=e=>bp(e,`right`),Cp=e=>{let t=e;return{kind:`quote-band`,variant:`display`,slots:{body:{text:t.text??``}},emphasis:`strong`,colorScheme:t.colorScheme}},wp=e=>{let t=e,n=e.contents,r=Ka(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:cp(t.accentImage)},colorScheme:t.colorScheme}},Tp=e=>{let t=e,n=t.images??[];return{kind:`gallery`,slots:{...n.length===0?{title:e.title,body:sp(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}}))}}},Ep=e=>{let t=e;return{kind:`callout`,variant:`definition`,slots:{title:t.term,body:{text:t.definition??``},meta:t.origin,media:cp(t.accentImage)},colorScheme:t.colorScheme}},Dp=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}},Op=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}},kp=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}}},Ap=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}},jp=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}},Mp=(e,t)=>{let n=e;return Array.isArray(n.headers)&&Array.isArray(n.rows)&&Js({headers:n.headers,rows:n.rows},n)!==null?lp(`chart`,t,e):pp(e,t)},Np={title:up,sectionHeader:dp,bigText:fp,content:pp,statHighlight:mp,quote:hp,factCard:gp,twoColumn:_p,dateEvent:vp,imageWithCaption:yp,leftFeature:xp,rightFeature:Sp,map:(e,t)=>lp(`map`,t,e),fullBleedQuote:Cp,list:wp,photoGrid:Tp,definitionCard:Ep,comparisonBar:Dp,pullQuote:Op,videoWithCaption:kp,videoPullQuote:Ap,dataTable:jp,barChart:Mp,columnChart:Mp,pieChart:Mp,donutChart:Mp,lineChart:Mp,areaChart:Mp,scatterChart:Mp,diagram:(e,t)=>lp(`diagram`,t,e),tree:(e,t)=>lp(`tree`,t,e),timeline:(e,t)=>lp(`timeline`,t,e),layout:(e,t)=>lp(`layout`,t,e),drawing:(e,t)=>lp(`drawing`,t,e)};function Pp(e,t){let n=e?.pageStyle??ee(e??k);return!t?.spacing||t.spacing===n.tokens.sectionSpacing?n:{...n,tokens:{...n.tokens,sectionSpacing:t.spacing}}}var Fp=new Set([`banner`,`stat-band`,`quote-band`,`callout`,`card-grid`,`item-list`,`timeline-rail`,`footer`]),Ip=new Set([`banner`,`quote-band`,`stat-band`,`footer`]),Lp=new Set([`callout`,`card-grid`,`stat-band`,`item-list`,`timeline-rail`,`table-section`]);function Rp(e){return e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`}function zp(e,t){if(Rp(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 Bp(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)&&Bp(e.children))return!0}return!1}function Vp(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)&&Bp(t.htmlChildren)?!0:Array.isArray(t.children)&&t.children.some(Vp)}function Hp(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=>zp(e,n)||!r&&Vp(e));if(i.length!==0)return{text:i.map(e=>o(e)).join(`
34
+ `).trim(),markdown:i}}function Up(e,t,n){let r=Hp(e,t,n);return r?{...t,slots:{...t.slots,richContent:r}}:t}function Wp(e,t,n,r){if(ip(e)){let i=op(e),a=i.templateName,s=Np[a];if(s)return{draft:Up(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:Up(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:Up(e,{kind:`callout`,variant:`diagnostic`,slots:{title:(e.sourceHeading?o(e.sourceHeading):void 0)??l.message,body:{text:Ha(e.contents)},meta:l.message},emphasis:`quiet`},r),source:`fallback`,templateName:a,diagnostic:l}}if(e.layers&&e.layers.length>0)return{draft:Up(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:Ha(e.contents),markdown:e.contents}:void 0}},source:`prose`}}function Gp(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 Kp(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 qp(e,t){return t?e.colorSchemes?.[t]:void 0}function Jp(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 Yp(e,t={}){let n=t.theme??k,r=t.viewport??p.landscape,i=Pp(n),a=Wp(e,r,t.customTemplates,t.widgetFenceLangs),o=Gp(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:qp(n,a.draft.colorScheme),role:`block`}:{role:i.accentRotation.strategy===`none`?`none`:`primary`};return{section:Kp({...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 Xp(e,t={}){let n=t.theme??k,r=t.viewport??p.landscape,i=Pp(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=Wp(i,r,a,t.widgetFenceLangs);s.push({...e,block:i,depth:n}),!(e.draft.kind===`canvas-embed`&&ae(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=Gp(i,e.draft.kind,e.templateName);let l=s.length,u=i.tokens.backgroundRhythm,d=i.accentRotation.strategy,f=Jp(i,n),m=d===`alternate-two`?Math.min(2,f.length):f.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`&&Ip.has(i)?a=`accent`:u===`tinted-panels`?a=Lp.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:qp(n,r.draft.colorScheme),role:`block`};else if(Fp.has(i)&&(d===`cycle`||d===`alternate-two`)&&m>0){let e=f[g%m];g++,o={schemeName:e,scheme:qp(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 p=Kp(r,e,l,a,c,o);b.push({section:p,block:r.block,source:r.source,diagnostic:r.diagnostic})}return b}var Zp=`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 Qp(e,t){let n=e??k,r=t??Pp(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":C(a.titleFont,`Georgia, serif`),"--squisq-page-body-font":C(a.bodyFont,`system-ui, sans-serif`),"--squisq-page-mono-font":C(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 $p(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 em=`
34
36
  .squisq-page-hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
35
37
  .squisq-page-feature { grid-template-columns: 1fr; }
36
38
  .squisq-page-feature--media-right .squisq-page-feature-media { order: 0; }
@@ -40,7 +42,7 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
40
42
  .squisq-page-milestone { grid-template-columns: 1fr; gap: 0.5rem; }
41
43
  .squisq-page-milestone-rail { display: none; }
42
44
  .squisq-page-section-inner { padding-inline: 18px; }
43
- `,Np=`
45
+ `,tm=`
44
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 */
45
47
  .squisq-page {
46
48
  background: var(--squisq-page-bg);
@@ -76,7 +78,7 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
76
78
  transparent 1px 14px
77
79
  );
78
80
  }
79
- .squisq-page[data-pattern='noise'] { background-image: ${kp}; }
81
+ .squisq-page[data-pattern='noise'] { background-image: ${Zp}; }
80
82
 
81
83
  /* Spacing scale */
82
84
  .squisq-page[data-spacing='compact'] { --squisq-page-section-pad: 2.25rem; }
@@ -382,21 +384,29 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
382
384
  .squisq-page-items { list-style: none; margin: 0; padding: 0; counter-reset: squisq-item; max-width: 40em; }
383
385
  .squisq-page-items li {
384
386
  counter-increment: squisq-item;
385
- position: relative;
386
- padding: 0.9em 0 0.9em 3.4em;
387
+ /* Grid + baseline alignment keeps the marker locked to the first text line
388
+ regardless of marker size, body font, or line-height \u2014 an absolutely
389
+ positioned marker with a fixed top offset drifts as soon as either
390
+ changes. */
391
+ display: grid;
392
+ grid-template-columns: 3.4em 1fr;
393
+ align-items: baseline;
394
+ padding: 0.9em 0;
387
395
  font-size: 1.1rem;
388
396
  }
389
397
  .squisq-page-items li + li { border-top: 1px solid var(--squisq-page-divider-color); }
390
398
  .squisq-page-items li::before {
391
399
  content: counter(squisq-item, decimal-leading-zero);
392
- position: absolute;
393
- left: 0;
394
- top: 0.85em;
395
400
  font-family: var(--squisq-page-title-font);
396
401
  font-weight: 700;
397
402
  color: var(--squisq-page-accent);
398
403
  font-size: 1.15em;
399
404
  }
405
+ /* Item bodies are rendered markdown: neutralize UA paragraph margins (which
406
+ would otherwise push the first line below the marker) and space blocks. */
407
+ .squisq-page-item-body { min-width: 0; }
408
+ .squisq-page-item-body > * { margin: 0; }
409
+ .squisq-page-item-body > * + * { margin-top: 0.6em; }
400
410
  .squisq-page[data-numerals='mono'] .squisq-page-items li::before { font-family: var(--squisq-page-mono-font); }
401
411
  .squisq-page-items-title { font-size: 1.9rem; }
402
412
 
@@ -552,22 +562,22 @@ ${r}`:n||r}function Ld(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
552
562
 
553
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 */
554
564
  @container squisq-page (max-width: 720px) {
555
- ${Mp}
565
+ ${em}
556
566
  }
557
567
  @supports not (container-type: inline-size) {
558
568
  @media (max-width: 720px) {
559
- ${Mp}
569
+ ${em}
560
570
  }
561
571
  }
562
- `;function Pp(e){let t=Ap(e);return`.squisq-page {
572
+ `;function nm(e){let t=Qp(e);return`.squisq-page {
563
573
  ${Object.entries(t).map(([e,t])=>` ${e}: ${t};`).join(`
564
574
  `)}
565
575
  }
566
- ${Np}`}var Fp=.5,Ip=.8,Lp=1;function Rp(e){let t=e.title?e.title.trim():``,n=wd(e);return t&&n?`${t}
567
- ${n}`:t||n}function zp(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=Gp(i,Rp(t));e>=Fp&&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 Bp(e,t){let n=Ld(e);if(n.blocks.length===0||Gp(n.sourceText,t.sourceText)<Ip)return null;let r=new Map,i=n.blocks.map(e=>_e(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 Vp(e,t){return e.map(e=>{let n=t.ranges.get(e.id),r=cd(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)>Lp,l=r.startTime!=null&&Math.abs(r.startTime-a)>Lp;(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=Vp(e.children,t)),i})}async function Hp(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=Yd(n);if(!i)continue;let a=pd(e.blocks),o=i.blocks.length>0?zp(a,i):Bp(e,i);if(!o||o.size===0)continue;let s={clipStart:r.startAt,ranges:o,diagnostics:[],cursor:0,shift:0},c=Vp(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 Up(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 Wp(e){let t=e.toLowerCase().replace(/[^\w\s]/g,` `).split(/\s+/).filter(e=>e.length>2);return new Set(t)}function Gp(e,t){let n=Wp(e),r=Wp(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 Kp(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function qp(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(`
568
- `)}function Jp(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...Jp(n.children)):t.push(n);return t}var Yp=[`.mp3`,`.wav`,`.ogg`,`.m4a`],Xp=[`.webm`,`.mp4`];function Zp(e){let t=e.toLowerCase();return Yp.some(e=>t.endsWith(e))?!0:Xp.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function Qp(e){let t=e.toLowerCase();for(let n of[...Yp,...Xp])if(t.endsWith(n))return e.slice(0,-n.length);return e}function $p(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 em(e){let t=(await e.listFiles()).filter(e=>Zp(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=$p(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=Qp(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=Up(n))}n.push({path:i.path,filename:t,timing:a})}return n}function tm(e,t){let n=[],r=Jp(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 nm=.35,rm=.5;function im(e,t){let n=Jp(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=qp(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=Gp(i.timing.sourceText,o)),s<nm&&a.title){let e=Kp(a.title);Kp(Qp(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,rm+.1))}s>=nm&&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 am(e,t){let n=await Hp(e,t);e=n.doc;let r=await em(t),i=new Set(A(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=tm(e.blocks,a);if(o.length===0&&!n.applied&&(o=im(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=Jp(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=om(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function om(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=om(e.children,t,r)),i})}function sm(e,t){return cm(he(e),t)}function cm(e,t){let n=dd(e),r=[...n.diagnostics??[]],i=fd(n.blocks),a=lm(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{dm(e,t,a,r),hm(e,t,r),gm(e,r),fm(e,t,o,r),vm(e,r),um(e)&&_m(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return bm(e,r),t?.assets&&Tm(e,i,xm(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 lm(e,t){return new Set([...Object.keys(Mc),...Object.keys(fe),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function um(e){return j(e.template??``)===`drawing`}function dm(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&um(t)){if(Go(i))return;let t=Vc(i,new Set(Ho),{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,...Dm(e)});return}if(Go(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,...Dm(e)});return}if(n.has(i)||n.has(j(i)))return;let a=Vc(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,...Dm(e)})}function fm(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&um(t)||Go(i))return;let a=j(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of ol(a,o))t.kind===`missing-input`&&pm(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...Dm(e)})}function pm(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=so(e,t.title??``,t.contents);return r!=null&&n in r}var mm=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function hm(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=oe(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...Dm(e)})}if(t&&um(t)&&Go(e.template)){let t=e.templateOverrides??{};for(let r of mm){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,...Dm(e)})}}}function gm(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(ie)){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,...Dm(e)})}}function _m(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=Wo(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,...Dm(e)})}}}function vm(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`||Su(n))continue;let i=Cu(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}:Dm(e)})}}var ym=/\{\[/;function bm(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);ym.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${Om(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=Mu(e);if(t&&t.template!=null)return}if(e.type===`text`&&ym.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 xm(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var Sm=/^[a-z][a-z0-9+.-]*:/i;function Cm(e){return e.length>0&&!Sm.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var wm=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function Tm(e,n,r,i){let a=(e,t,n)=>{!Cm(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`)&&Em(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 wm){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 Em(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),Em(n.children,t))}function Dm(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Om(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function km(e){return e.split(`
569
- `).map(e=>e.trim()).filter(e=>e.length>0)}function Am(e){if(e===void 0)return;let t=e.replace(/\s+/gu,` `).trim();return t.length>0?t:void 0}function jm(e){return e.length<=40}var Mm=1;function Nm(e,t={}){let n=(t.style??e.style)===`ascii`?yt:vt;if(e.nodes.length===0)return``;let r=Fm(e.nodes,e.edges),i=new zm,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)Bm(i,e,n);return Vm(i,e.edges,r,n),i.emit()}function Pm(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}=Hm(i(t),i(a));r.get(e.source)[o]++,r.get(e.target)[s]++}return r}function Fm(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=Pm(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=Lm(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=>Im(n,e,Mm));if(!t||r++>64)break;let a=t.c1+Mm+1-n.c0,o=t.r1+Mm+1-n.r0;a<o?(s(e,0,a),n=Lm(n,0,a)):(s(e,o,0),n=Lm(n,o,0))}i.push(n)}return i},l=(e,t)=>{let a=n.get(e),s=km(a.label),u=i.get(e)??[];if(u.length===0){let n=s.reduce((e,t)=>Math.max(e,We(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=Rm(c(u,e=>l(e,t+1))),f=Math.max(0,s.length-1),p=We(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,We(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=Lm(e.rect,f,p);return o}function Im(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 Lm(e,t,n){return{r0:e.r0+t,c0:e.c0+n,r1:e.r1+t,c1:e.c1+n}}function Rm(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 zm=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(`
570
- `)}};function Bm(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 Vm(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=Hm(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=Um(o,n),c=[];o.forEach((t,i)=>Wm(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 Hm(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 Um(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 Wm(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:Am(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`?qm(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?qm(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?Jm(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?Jm(h,s,c,d,f,-1):Ym(h,s,c,t.exitSide)}function Gm(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 Km(e,t,n){return Math.max(t,Math.min(n,e))}function qm(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=Km(r,t.c0+1,t.c1-1),f=Km(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(Gm(h,g).map(e=>({row:e,col:i})),l));return}let y=Km(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&&jm(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 Gm(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 Gm(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of Gm(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function Jm(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&&jm(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=Km(r,t.r0+1,t.r1-1),i=Km(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=Km(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 Ym(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 Xm=2,Zm=8,Qm=12,$m=4,eh=4;function th(e){return!an(e).isDiagram&&rh(At(jt(e),!0)).length>=Xm}function nh(e){let t=jt(e),n=rh(At(t,!0));if(n.length<Xm)return null;let r=ih(t,n),i={nodes:r,edges:ch(t,n,r),style:ph(t),warnings:[`repaired`]};return{diagram:i,art:Nm(i)}}function rh(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 ih(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(ah).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=ah(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+$m}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)+eh}let p=t.map((e,n)=>oh(t,n)),m=new Map,h=t.map((e,t)=>{let n=sh(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(`
571
- `),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 ah(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 oh(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 sh(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function ch(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=>lt(e)||P(e)||ut(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<=Zm&&s(r,i)){let s=Math.max(r.c0,i.c0),c=Math.min(r.c1,i.c1);if(lh(a,r.r1+1,i.r0-1,s-1,c+1,o)&&!dh(t,e,n,s,c)){let t=uh(a,r.r1+1,i.r0,s-1,c+1,`down`);d(e,n,t)}}if(r.c1<i.c0&&i.c0-r.c1<=Qm&&c(r,i)&&e<n){let o=Math.max(r.r0,i.r0),s=Math.min(r.r1,i.r1),c=uh(a,o-1,s+1,r.c1+1,i.c0,`right`),l=uh(a,o-1,s+1,r.c1+1,i.c0,`left`);(c||l)&&!fh(t,e,n,o,s)&&(l&&!c?d(n,e,!0):d(e,n,!0))}}return l}function lh(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 uh(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 dh(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 fh(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 ph(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 mh={rail:`─`,arrow:`►`,marker:{filled:`●`,hollow:`○`,diamond:`◆`}},hh={rail:`-`,arrow:`>`,marker:{filled:`*`,hollow:`o`,diamond:`*`}},gh=48,_h=64,vh=3,yh=3;function bh(e,t={}){let n=t.style??e.style,r=n===`ascii`?hh:mh,{tracks:i,links:a}=Oh(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(gh,Math.min(_h,Math.ceil(c)),...i.map(e=>e.events.length*vh)),u=i.map(e=>Ch(e)),d=Math.max(...u.map(Eh)),f=[];if(i.forEach((e,t)=>{t>0&&f.push(``),f.push(...xh(e,n,r,u[t],d,l,o,c))}),a.length>0){f.push(``);for(let e of a)f.push(Dh(e,n))}return f.join(`
572
- `)}function xh(e,t,n,r,i,a,o,s){let c=`${r}${` `.repeat(Math.max(0,i-Eh(r)))}`,l=wh(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:Sh(e)})),f=t===`ascii`?{above:`^`,below:`v`}:{above:`▲`,below:`▼`},p=Th(d.filter(({event:e})=>e.side===`above`),f.above),m=Th(d.filter(({event:e})=>e.side===`below`),f.below),h=`${c}${u.join(``)}${n.rail.repeat(yh)}${n.arrow}${e.endLabel?` ${e.endLabel}`:``}`;return[...p,h,...m]}function Sh(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=${Lh(e.column)}${n}${r}}`}function Ch(e){let t=`{#${e.id} start=${Lh(e.startColumn)} end=${Lh(e.endColumn)}}`;return e.label?`${e.label} ${t}: `:`${t}: `}function wh(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 Th(e,t){let n=[],r=[];for(let t of e){let e=t.column+2+Eh(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 Eh(e){return Array.from(e).length}function Dh(e,t){let n=t===`ascii`?`->`:`→`;return`branch: ${e.source} ${n} ${e.target}${e.label?` : ${e.label}`:``}`}function Oh(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)=>Fh(e.track.row,e.index)-Fh(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=Ah(e.label),l=Ah(e.endLabel),u=Nh(Mh(e.id,Mh(n,`track_${s.length+1}`)),r),d=e.events.map((e,t)=>({event:e,index:t})).sort((e,t)=>Fh(e.event.column,e.index)-Fh(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=Ah(n.label)||r,l=Nh(Mh(n.id,Mh(s,`event_${++c}`)),i),u=Ah(n.description),p=u&&(n.descriptionSide===`above`||n.descriptionSide===`below`)?n.descriptionSide:void 0,m=Ih(n.column,e),h=n.side===`below`?`below`:n.side===`above`||e%2==0?`above`:`below`,g=kh(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(Ph(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:Ih(e.startColumn,m),endColumn:Ih(e.endColumn,h),events:f})}let l=e=>a.get(e)??o.get(Ph(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=jh(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 kh(e,t){return e===`hollow`?`hollow`:e===`diamond`&&t!==`ascii`?`diamond`:`filled`}function Ah(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 jh(e){return Ah(e).replace(/\s+/g,` `).trim()}function Mh(e,t){return(e??``).normalize(`NFC`).replace(/[\r\n\t\s]+/g,`_`).replace(/[^A-Za-z0-9_.~-]+/g,`_`).replace(/^_+|_+$/g,``)||t}function Nh(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 Ph(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function Fh(e,t){return Number.isFinite(e)?e:t}function Ih(e,t){let n=Fh(e,t);return Math.max(0,Object.is(n,-0)?0:n)}function Lh(e){return String(Object.is(e,-0)?0:e)}function Rh(e){return e.replace(/\s+/gu,` `).trim()}function zh(e,t={}){let n=(t.style??e.style)===`ascii`?jr:Ar,r=[],i=e=>{let t=Rh(e.label),n=e.comment?Rh(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(`
573
- `)}var Bh=e({ASCII_CHAR_H:()=>28,ASCII_CHAR_W:()=>14,ASCII_DIAGRAM_FENCE_LANGS:()=>Xt,ASCII_TIMELINE_FENCE_LANGS:()=>lr,BASE_INPUT_DESCRIPTORS:()=>Yc,BLOCK_MEDIA_LAYOUT_POLICIES:()=>pl,CONTAINER_TEMPLATES:()=>de,COVER_SLIDE_FRONTMATTER_KEYS:()=>mf,COVER_SLIDE_TEMPLATE_OPTIONS:()=>pf,DEFAULT_COVER_SLIDE_SETTINGS:()=>hf,DEFAULT_LAYOUT:()=>Li,DEFAULT_THEME:()=>k,DIAGRAM_LABEL_HORIZONTAL_PADDING:()=>24,DIAGRAM_LABEL_LINE_HEIGHT:()=>xo,DIAGRAM_LABEL_MIN_FONT_SIZE:()=>10,DIAGRAM_LABEL_VERTICAL_PADDING:()=>16,FRONTMATTER_CUSTOM_TEMPLATES_KEY:()=>T,FRONTMATTER_CUSTOM_THEMES_KEY:()=>O,MAX_COVER_SLIDE_DURATION_SECONDS:()=>60,PAGE_BASE_CSS:()=>Np,PATH_SHAPE_KINDS:()=>xe,SHAPE_NAMES:()=>Ho,TABLE_FED_TEMPLATES:()=>ge,TEMPLATE_AUTHORING_METADATA:()=>Kl,TEMPLATE_INPUT_DESCRIPTORS:()=>Xc,TEMPLATE_METADATA:()=>Gl,TREE_FENCE_LANGS:()=>Rr,VIEWPORT_PRESETS:()=>p,adjustY:()=>G,anchorPoint:()=>Ae,applyNarrationTiming:()=>Hp,applyRenderStyleToLayers:()=>zc,asciiCellToCanvas:()=>Ta,asciiDiagramFromBlocks:()=>Ma,asciiDiagramFromTemplateData:()=>ja,asciiDiagramToTemplateData:()=>Da,asciiTimelineToTemplateData:()=>Na,autoTemplatePreservesContent:()=>oo,bigText:()=>ia,buildPageCss:()=>Pp,buildPageCssVars:()=>Ap,buildRegistry:()=>Nc,canvasToAsciiCell:()=>Ea,clipEndpoints:()=>Oe,clipPoint:()=>De,coerceTemplateParams:()=>el,comparisonBar:()=>go,computeDiagramLayout:()=>xa,computeDrawingLayout:()=>Xo,computeLayoutLayers:()=>_s,connectorPath:()=>Fe,contentBlock:()=>sa,countBlocks:()=>md,coverBlock:()=>eu,createAccentLayers:()=>Hi,createTemplateContext:()=>s,cssFilterForTreatment:()=>ff,dataTable:()=>bo,dateEvent:()=>pa,definitionCard:()=>ho,deriveTemplateInputs:()=>so,detectAsciiDiagram:()=>an,detectAsciiTimeline:()=>vr,detectTree:()=>Kr,diagramBlock:()=>Ao,docToMarkdown:()=>wf,drawingBlock:()=>ss,expandCoverBlock:()=>nu,expandDocBlocks:()=>iu,expandPersistentLayers:()=>yi,extractBlockquoteText:()=>$a,extractBodyPlainText:()=>Ha,extractEmbeddedVideos:()=>Xa,extractFirstEmbeddedVideo:()=>Za,extractFirstImage:()=>Ya,extractImages:()=>Ja,extractListItems:()=>Ua,extractRichListItems:()=>Ka,extractTableData:()=>Au,extractTableFromContents:()=>Qa,factCard:()=>ua,fallbackBlockLayers:()=>cl,findFirstList:()=>Ba,findFirstTable:()=>ku,fitBigTextSize:()=>na,fitDiagramLabel:()=>So,flattenBlocks:()=>fd,flattenRenderableBlocks:()=>pd,fullBleedQuote:()=>ya,getAccentLayout:()=>Vi,getAnimationProgress:()=>cf,getAnimationStyle:()=>Xd,getAvailableTemplates:()=>au,getAvailableThemes:()=>w,getBlockBodyText:()=>wd,getBlockDepth:()=>hd,getBlockMediaLayoutPolicy:()=>ml,getDefaultAnimation:()=>Oi,getDefaultAnimationDuration:()=>$d,getLayoutHints:()=>m,getOverlayOpacity:()=>ki,getPersistentLayersFromTheme:()=>bi,getPinnedBlockMeta:()=>cd,getTemplateHint:()=>ji,getThemeFont:()=>R,getThemeSummaries:()=>te,getTransitionClass:()=>ef,getTwoColumnPositions:()=>h,getViewport:()=>c,getViewportOrientation:()=>f,hasTemplate:()=>ou,imageWithCaption:()=>ma,isAsciiDiagramFence:()=>on,isAsciiTimelineFence:()=>yr,isContainerTemplate:()=>ae,isDataFence:()=>Su,isEligibleAsciiFenceLang:()=>nn,isEligibleAsciiTimelineFenceLang:()=>gr,isEligibleTreeFenceLang:()=>Wr,isExplicitDiagramLang:()=>rn,isExplicitTimelineLang:()=>_r,isExplicitTreeLang:()=>Gr,isRepairableDiagram:()=>th,isShapeName:()=>Go,isTemplateBlock:()=>l,isTemplatedPageBlock:()=>If,isTreeFence:()=>qr,isWrappedFlowTimelineSource:()=>gn,layoutBlock:()=>xs,leftFeature:()=>ga,lineStyleDasharray:()=>Re,lintTemplateParams:()=>ol,listBlock:()=>fo,mapBlock:()=>va,markdownToDoc:()=>dd,markerPath:()=>Ee,materializeBlockLayers:()=>Ml,materializePageSection:()=>Dp,materializePageSections:()=>Op,nearestSnapPoint:()=>je,normalizeShapeKind:()=>Wo,pageStyleDataAttributes:()=>jp,parseAsciiDiagram:()=>Tt,parseAsciiTimeline:()=>Nn,parseAsciiTimelineWithStats:()=>Pn,parseDataFence:()=>Cu,parseTree:()=>Mr,parseWrappedFlowTimeline:()=>hn,parseYamlSubset:()=>Ou,photoGrid:()=>po,pullQuote:()=>_o,quoteBlock:()=>la,readCustomTemplatesFromFrontmatter:()=>fu,readCustomThemesFromFrontmatter:()=>yu,renderAsciiDiagram:()=>Nm,renderAsciiTimeline:()=>bh,renderTree:()=>zh,repairAsciiDiagram:()=>nh,replaceDataFence:()=>wu,resolveAudioMapping:()=>am,resolveColorScheme:()=>L,resolveCoverSlideSettings:()=>xf,resolvePageBlock:()=>Rf,resolvePageStyle:()=>fp,resolvePersistentLayers:()=>xi,resolveTemplateName:()=>j,resolveTheme:()=>D,resolveThemeForDoc:()=>Ff,rightFeature:()=>_a,scaleAnimationDuration:()=>Di,scaledFontSize:()=>u,scoreTextSimilarity:()=>Gp,sectionExtractors:()=>dp,sectionHeader:()=>Yi,shapePath:()=>we,shouldUseShadow:()=>V,snapEndpoints:()=>Me,snapPoints:()=>ke,statHighlight:()=>ca,templateRegistry:()=>Mc,themeWantsAmbientMotion:()=>Rc,themedEntrance:()=>B,themedFontSize:()=>z,themedImageTreatment:()=>H,themedScrim:()=>Ai,themedSurfaceGradient:()=>U,timelineBlock:()=>Vo,titleBlock:()=>Fi,treeBlock:()=>No,treeFromMarkdownList:()=>za,treeFromTemplateData:()=>La,treeToTemplateData:()=>Fa,twoColumn:()=>da,validateMarkdownDoc:()=>cm,validateMarkdownSource:()=>sm,videoPullQuote:()=>yo,videoWithCaption:()=>vo,wrapWithPersistentLayers:()=>Si,writeCustomTemplatesToFrontmatter:()=>pu,writeCustomThemesToFrontmatter:()=>bu});export{fu as $,Kd as A,$a as B,Ca as C,Fe as Ct,Da as D,Me as Dt,Ta as E,we as Et,md as F,So as G,Ja as H,so as I,au as J,fd as K,nu as L,el as M,Xo as N,Na as O,_s as P,Ml as Q,iu as R,wa as S,Be as St,Gl as T,je as Tt,Ua as U,Ha as V,Qa as W,ou as X,cd as Y,dd as Z,nh as _,Nn as _t,Np as a,bu as at,fp as b,ai as bt,wf as c,Kr as ct,th as d,Wr as dt,yu as et,Op as f,rn as ft,zh as g,Tt as gt,bh as h,gn as ht,hf as i,pu as it,Ea as j,Ld as k,Xd as l,nn as lt,Nm as m,Gr as mt,mf as n,Gd as nt,Ap as o,an as ot,jp as p,_r as pt,pd as q,pf as r,Wd as rt,ff as s,vr as st,Bh as t,xi as tt,ef as u,gr as ut,am as v,Mr as vt,xo as w,Ee as wt,Ff as x,Ae as xt,xf as y,ti as yt,Ud as z};
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 sm(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=pm(i,om(t));e>=rm&&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 cm(e,t){let n=Ld(e);if(n.blocks.length===0||pm(n.sourceText,t.sourceText)<im)return null;let r=new Map,i=n.blocks.map(e=>_e(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 lm(e,t){return e.map(e=>{let n=t.ranges.get(e.id),r=cd(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)>am,l=r.startTime!=null&&Math.abs(r.startTime-a)>am;(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=lm(e.children,t)),i})}async function um(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=Yd(n);if(!i)continue;let a=pd(e.blocks),o=i.blocks.length>0?sm(a,i):cm(e,i);if(!o||o.size===0)continue;let s={clipStart:r.startAt,ranges:o,diagnostics:[],cursor:0,shift:0},c=lm(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 dm(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 fm(e){let t=e.toLowerCase().replace(/[^\w\s]/g,` `).split(/\s+/).filter(e=>e.length>2);return new Set(t)}function pm(e,t){let n=fm(e),r=fm(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 mm(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function hm(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 gm(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...gm(n.children)):t.push(n);return t}var _m=[`.mp3`,`.wav`,`.ogg`,`.m4a`],vm=[`.webm`,`.mp4`];function ym(e){let t=e.toLowerCase();return _m.some(e=>t.endsWith(e))?!0:vm.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function bm(e){let t=e.toLowerCase();for(let n of[..._m,...vm])if(t.endsWith(n))return e.slice(0,-n.length);return e}function xm(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 Sm(e){let t=(await e.listFiles()).filter(e=>ym(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=xm(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=bm(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=dm(n))}n.push({path:i.path,filename:t,timing:a})}return n}function Cm(e,t){let n=[],r=gm(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 wm=.35,Tm=.5;function Em(e,t){let n=gm(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=hm(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=pm(i.timing.sourceText,o)),s<wm&&a.title){let e=mm(a.title);mm(bm(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,Tm+.1))}s>=wm&&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 Dm(e,t){let n=await um(e,t);e=n.doc;let r=await Sm(t),i=new Set(A(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=Cm(e.blocks,a);if(o.length===0&&!n.applied&&(o=Em(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=gm(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=Om(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function Om(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=Om(e.children,t,r)),i})}function km(e,t){return Am(he(e),t)}function Am(e,t){let n=dd(e),r=[...n.diagnostics??[]],i=fd(n.blocks),a=jm(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{Nm(e,t,a,r),Lm(e,t,r),Rm(e,r),Pm(e,t,o,r),Bm(e,r),Mm(e)&&zm(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return Hm(e,r),t?.assets&&qm(e,i,Um(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 jm(e,t){return new Set([...Object.keys(Mc),...Object.keys(fe),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function Mm(e){return j(e.template??``)===`drawing`}function Nm(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&Mm(t)){if(Go(i))return;let t=Vc(i,new Set(Ho),{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,...Ym(e)});return}if(Go(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,...Ym(e)});return}if(n.has(i)||n.has(j(i)))return;let a=Vc(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,...Ym(e)})}function Pm(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&Mm(t)||Go(i))return;let a=j(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of ol(a,o))t.kind===`missing-input`&&Fm(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...Ym(e)})}function Fm(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=so(e,t.title??``,t.contents);return r!=null&&n in r}var Im=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function Lm(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=oe(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...Ym(e)})}if(t&&Mm(t)&&Go(e.template)){let t=e.templateOverrides??{};for(let r of Im){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,...Ym(e)})}}}function Rm(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(ie)){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,...Ym(e)})}}function zm(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=Wo(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,...Ym(e)})}}}function Bm(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`||Su(n))continue;let i=Cu(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}:Ym(e)})}}var Vm=/\{\[/;function Hm(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);Vm.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${Xm(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=Mu(e);if(t&&t.template!=null)return}if(e.type===`text`&&Vm.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 Um(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var Wm=/^[a-z][a-z0-9+.-]*:/i;function Gm(e){return e.length>0&&!Wm.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var Km=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function qm(e,n,r,i){let a=(e,t,n)=>{!Gm(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`)&&Jm(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 Km){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 Jm(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),Jm(n.children,t))}function Ym(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Xm(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Zm(e){return e.split(`
579
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function Qm(e){if(e===void 0)return;let t=e.replace(/\s+/gu,` `).trim();return t.length>0?t:void 0}function $m(e){return e.length<=40}var eh=1;function th(e,t={}){let n=(t.style??e.style)===`ascii`?yt:vt;if(e.nodes.length===0)return``;let r=rh(e.nodes,e.edges),i=new sh,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)ch(i,e,n);return lh(i,e.edges,r,n),i.emit()}function nh(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}=uh(i(t),i(a));r.get(e.source)[o]++,r.get(e.target)[s]++}return r}function rh(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=nh(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=ah(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=>ih(n,e,eh));if(!t||r++>64)break;let a=t.c1+eh+1-n.c0,o=t.r1+eh+1-n.r0;a<o?(s(e,0,a),n=ah(n,0,a)):(s(e,o,0),n=ah(n,o,0))}i.push(n)}return i},l=(e,t)=>{let a=n.get(e),s=Zm(a.label),u=i.get(e)??[];if(u.length===0){let n=s.reduce((e,t)=>Math.max(e,We(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=oh(c(u,e=>l(e,t+1))),f=Math.max(0,s.length-1),p=We(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,We(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=ah(e.rect,f,p);return o}function ih(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 ah(e,t,n){return{r0:e.r0+t,c0:e.c0+n,r1:e.r1+t,c1:e.c1+n}}function oh(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 sh=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 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 Dh(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 Oh(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 kh(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Ah(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=>lt(e)||P(e)||ut(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<=yh&&s(r,i)){let s=Math.max(r.c0,i.c0),c=Math.min(r.c1,i.c1);if(jh(a,r.r1+1,i.r0-1,s-1,c+1,o)&&!Nh(t,e,n,s,c)){let t=Mh(a,r.r1+1,i.r0,s-1,c+1,`down`);d(e,n,t)}}if(r.c1<i.c0&&i.c0-r.c1<=bh&&c(r,i)&&e<n){let o=Math.max(r.r0,i.r0),s=Math.min(r.r1,i.r1),c=Mh(a,o-1,s+1,r.c1+1,i.c0,`right`),l=Mh(a,o-1,s+1,r.c1+1,i.c0,`left`);(c||l)&&!Ph(t,e,n,o,s)&&(l&&!c?d(n,e,!0):d(e,n,!0))}}return l}function jh(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 Mh(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 Nh(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 Ph(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 Fh(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 Ih={rail:`─`,arrow:`►`,marker:{filled:`●`,hollow:`○`,diamond:`◆`}},Lh={rail:`-`,arrow:`>`,marker:{filled:`*`,hollow:`o`,diamond:`*`}},Rh=48,zh=64,Bh=3,Vh=3;function Hh(e,t={}){let n=t.style??e.style,r=n===`ascii`?Lh:Ih,{tracks:i,links:a}=Xh(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(Rh,Math.min(zh,Math.ceil(c)),...i.map(e=>e.events.length*Bh)),u=i.map(e=>Gh(e)),d=Math.max(...u.map(Jh)),f=[];if(i.forEach((e,t)=>{t>0&&f.push(``),f.push(...Uh(e,n,r,u[t],d,l,o,c))}),a.length>0){f.push(``);for(let e of a)f.push(Yh(e,n))}return f.join(`
582
+ `)}function Uh(e,t,n,r,i,a,o,s){let c=`${r}${` `.repeat(Math.max(0,i-Jh(r)))}`,l=Kh(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:Wh(e)})),f=t===`ascii`?{above:`^`,below:`v`}:{above:`▲`,below:`▼`},p=qh(d.filter(({event:e})=>e.side===`above`),f.above),m=qh(d.filter(({event:e})=>e.side===`below`),f.below),h=`${c}${u.join(``)}${n.rail.repeat(Vh)}${n.arrow}${e.endLabel?` ${e.endLabel}`:``}`;return[...p,h,...m]}function Wh(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=${ag(e.column)}${n}${r}}`}function Gh(e){let t=`{#${e.id} start=${ag(e.startColumn)} end=${ag(e.endColumn)}}`;return e.label?`${e.label} ${t}: `:`${t}: `}function Kh(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 qh(e,t){let n=[],r=[];for(let t of e){let e=t.column+2+Jh(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 Jh(e){return Array.from(e).length}function Yh(e,t){let n=t===`ascii`?`->`:`→`;return`branch: ${e.source} ${n} ${e.target}${e.label?` : ${e.label}`:``}`}function Xh(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)=>rg(e.track.row,e.index)-rg(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=Qh(e.label),l=Qh(e.endLabel),u=tg(eg(e.id,eg(n,`track_${s.length+1}`)),r),d=e.events.map((e,t)=>({event:e,index:t})).sort((e,t)=>rg(e.event.column,e.index)-rg(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=Qh(n.label)||r,l=tg(eg(n.id,eg(s,`event_${++c}`)),i),u=Qh(n.description),p=u&&(n.descriptionSide===`above`||n.descriptionSide===`below`)?n.descriptionSide:void 0,m=ig(n.column,e),h=n.side===`below`?`below`:n.side===`above`||e%2==0?`above`:`below`,g=Zh(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(ng(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:ig(e.startColumn,m),endColumn:ig(e.endColumn,h),events:f})}let l=e=>a.get(e)??o.get(ng(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=$h(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 Zh(e,t){return e===`hollow`?`hollow`:e===`diamond`&&t!==`ascii`?`diamond`:`filled`}function Qh(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 $h(e){return Qh(e).replace(/\s+/g,` `).trim()}function eg(e,t){return(e??``).normalize(`NFC`).replace(/[\r\n\t\s]+/g,`_`).replace(/[^A-Za-z0-9_.~-]+/g,`_`).replace(/^_+|_+$/g,``)||t}function tg(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 ng(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function rg(e,t){return Number.isFinite(e)?e:t}function ig(e,t){let n=rg(e,t);return Math.max(0,Object.is(n,-0)?0:n)}function ag(e){return String(Object.is(e,-0)?0:e)}function og(e){return e.replace(/\s+/gu,` `).trim()}function sg(e,t={}){let n=(t.style??e.style)===`ascii`?jr:Ar,r=[],i=e=>{let t=og(e.label),n=e.comment?og(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 cg=e({ASCII_CHAR_H:()=>28,ASCII_CHAR_W:()=>14,ASCII_DIAGRAM_FENCE_LANGS:()=>Xt,ASCII_TIMELINE_FENCE_LANGS:()=>lr,BASE_INPUT_DESCRIPTORS:()=>Yc,BLOCK_MEDIA_LAYOUT_POLICIES:()=>pl,CONTAINER_TEMPLATES:()=>de,COVER_SLIDE_FRONTMATTER_KEYS:()=>xf,COVER_SLIDE_TEMPLATE_OPTIONS:()=>bf,DEFAULT_COVER_SLIDE_SETTINGS:()=>Sf,DEFAULT_LAYOUT:()=>Li,DEFAULT_THEME:()=>k,DIAGRAM_LABEL_HORIZONTAL_PADDING:()=>24,DIAGRAM_LABEL_LINE_HEIGHT:()=>xo,DIAGRAM_LABEL_MIN_FONT_SIZE:()=>10,DIAGRAM_LABEL_VERTICAL_PADDING:()=>16,FRONTMATTER_CUSTOM_TEMPLATES_KEY:()=>T,FRONTMATTER_CUSTOM_THEMES_KEY:()=>O,MAX_COVER_SLIDE_DURATION_SECONDS:()=>60,PAGE_BASE_CSS:()=>tm,PATH_SHAPE_KINDS:()=>xe,SHAPE_NAMES:()=>Ho,TABLE_FED_TEMPLATES:()=>ge,TEMPLATE_AUTHORING_METADATA:()=>Kl,TEMPLATE_INPUT_DESCRIPTORS:()=>Xc,TEMPLATE_METADATA:()=>Gl,TREE_FENCE_LANGS:()=>Rr,VIEWPORT_PRESETS:()=>p,adjustY:()=>G,anchorPoint:()=>Ae,applyNarrationTiming:()=>um,applyRenderStyleToLayers:()=>zc,asciiCellToCanvas:()=>Ta,asciiDiagramFromBlocks:()=>Ma,asciiDiagramFromTemplateData:()=>ja,asciiDiagramToTemplateData:()=>Da,asciiTimelineToTemplateData:()=>Na,autoTemplatePreservesContent:()=>oo,bigText:()=>ia,buildPageCss:()=>nm,buildPageCssVars:()=>Qp,buildPreviewDoc:()=>np,buildRegistry:()=>Nc,canvasToAsciiCell:()=>Ea,clipEndpoints:()=>Oe,clipPoint:()=>De,coerceTemplateParams:()=>el,comparisonBar:()=>go,computeDiagramLayout:()=>xa,computeDrawingLayout:()=>Xo,computeLayoutLayers:()=>_s,connectorPath:()=>Fe,contentBlock:()=>sa,countBlocks:()=>md,coverBlock:()=>eu,createAccentLayers:()=>Hi,createTemplateContext:()=>s,cssFilterForTreatment:()=>yf,dataTable:()=>bo,dateEvent:()=>pa,definitionCard:()=>ho,deriveTemplateInputs:()=>so,detectAsciiDiagram:()=>an,detectAsciiTimeline:()=>vr,detectTree:()=>Kr,diagramBlock:()=>Ao,docToMarkdown:()=>jf,documentTitleFromFileName:()=>ep,drawingBlock:()=>ss,expandCoverBlock:()=>nu,expandDocBlocks:()=>iu,expandPersistentLayers:()=>yi,extractBlockquoteText:()=>$a,extractBodyPlainText:()=>Ha,extractEmbeddedVideos:()=>Xa,extractFirstEmbeddedVideo:()=>Za,extractFirstImage:()=>Ya,extractImages:()=>Ja,extractListItems:()=>Ua,extractRichListItems:()=>Ka,extractTableData:()=>Au,extractTableFromContents:()=>Qa,factCard:()=>ua,fallbackBlockLayers:()=>cl,findFirstList:()=>Ba,findFirstTable:()=>ku,fitBigTextSize:()=>na,fitDiagramLabel:()=>So,flattenBlocks:()=>fd,flattenRenderableBlocks:()=>pd,fullBleedQuote:()=>ya,getAccentLayout:()=>Vi,getAnimationProgress:()=>hf,getAnimationStyle:()=>rf,getAvailableTemplates:()=>au,getAvailableThemes:()=>w,getBlockBodyText:()=>wd,getBlockDepth:()=>hd,getBlockMediaLayoutPolicy:()=>ml,getDefaultAnimation:()=>Oi,getDefaultAnimationDuration:()=>sf,getLayoutHints:()=>m,getOverlayOpacity:()=>ki,getPersistentLayersFromTheme:()=>bi,getPinnedBlockMeta:()=>cd,getTemplateHint:()=>ji,getThemeFont:()=>R,getThemeSummaries:()=>te,getTransitionClass:()=>cf,getTwoColumnPositions:()=>h,getViewport:()=>c,getViewportOrientation:()=>f,hasTemplate:()=>ou,imageWithCaption:()=>ma,isAsciiDiagramFence:()=>on,isAsciiTimelineFence:()=>yr,isContainerTemplate:()=>ae,isDataFence:()=>Su,isEligibleAsciiFenceLang:()=>nn,isEligibleAsciiTimelineFenceLang:()=>gr,isEligibleTreeFenceLang:()=>Wr,isExplicitDiagramLang:()=>rn,isExplicitTimelineLang:()=>_r,isExplicitTreeLang:()=>Gr,isRepairableDiagram:()=>Ch,isShapeName:()=>Go,isTemplateBlock:()=>l,isTemplatedPageBlock:()=>ip,isTreeFence:()=>qr,isWrappedFlowTimelineSource:()=>gn,layoutBlock:()=>xs,leftFeature:()=>ga,lineStyleDasharray:()=>Re,lintTemplateParams:()=>ol,listBlock:()=>fo,mapBlock:()=>va,markdownToDoc:()=>dd,markerPath:()=>Ee,materializeBlockLayers:()=>Ml,materializePageSection:()=>Yp,materializePageSections:()=>Xp,nearestSnapPoint:()=>je,normalizeShapeKind:()=>Wo,pageStyleDataAttributes:()=>$p,parseAsciiDiagram:()=>Tt,parseAsciiTimeline:()=>Nn,parseAsciiTimelineWithStats:()=>Pn,parseDataFence:()=>Cu,parseTree:()=>Mr,parseWrappedFlowTimeline:()=>hn,parseYamlSubset:()=>Ou,photoGrid:()=>po,pullQuote:()=>_o,quoteBlock:()=>la,readCustomTemplatesFromFrontmatter:()=>fu,readCustomThemesFromFrontmatter:()=>yu,renderAsciiDiagram:()=>th,renderAsciiTimeline:()=>Hh,renderTree:()=>sg,repairAsciiDiagram:()=>wh,replaceDataFence:()=>wu,resolveAudioMapping:()=>Dm,resolveColorScheme:()=>L,resolveCoverSlideSettings:()=>Of,resolvePageBlock:()=>op,resolvePageStyle:()=>Pp,resolvePersistentLayers:()=>xi,resolveTemplateName:()=>j,resolveTheme:()=>D,resolveThemeForDoc:()=>rp,rightFeature:()=>_a,scaleAnimationDuration:()=>Di,scaledFontSize:()=>u,scoreTextSimilarity:()=>pm,sectionExtractors:()=>Np,sectionHeader:()=>Yi,shapePath:()=>we,shouldUseShadow:()=>V,snapEndpoints:()=>Me,snapPoints:()=>ke,statHighlight:()=>ca,templateRegistry:()=>Mc,themeWantsAmbientMotion:()=>Rc,themedEntrance:()=>B,themedFontSize:()=>z,themedImageTreatment:()=>H,themedScrim:()=>Ai,themedSurfaceGradient:()=>U,timelineBlock:()=>Vo,titleBlock:()=>Fi,treeBlock:()=>No,treeFromMarkdownList:()=>za,treeFromTemplateData:()=>La,treeToTemplateData:()=>Fa,twoColumn:()=>da,validateMarkdownDoc:()=>Am,validateMarkdownSource:()=>km,videoPullQuote:()=>yo,videoWithCaption:()=>vo,wrapWithPersistentLayers:()=>Si,writeCustomTemplatesToFrontmatter:()=>pu,writeCustomThemesToFrontmatter:()=>bu});export{au as $,xo as A,je as At,md as B,rp as C,Mr as Ct,ef as D,Be as Dt,tf as E,Ae as Et,Ld as F,$a as G,nu as H,Kd as I,Ua as J,Ha as K,Ea as L,Ta as M,Me as Mt,Da as N,wa as O,Fe as Ot,Na as P,pd as Q,Xo as R,Pp as S,Nn as St,nf as T,ai as Tt,iu as U,so as V,Ud as W,So as X,Qa as Y,fd as Z,Hh as _,rn as _t,tm as a,yu as at,Dm as b,gn as bt,yf as c,Wd as ct,rf as d,an as dt,cd as et,cf as f,vr as ft,th as g,Wr as gt,$p as h,gr as ht,Sf as i,fu as it,Gl as j,we as jt,Ca as k,Ee as kt,jf as l,pu as lt,Xp as m,nn as mt,xf as n,dd as nt,Qp as o,xi as ot,Ch as p,Kr as pt,Ja as q,bf as r,Ml as rt,np as s,Gd as st,cg as t,ou as tt,ep as u,bu as ut,sg as v,_r as vt,$d as w,ti as wt,Of as x,Tt as xt,wh as y,Gr as yt,_s as z};