@allyhub/sdk 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/node_modules/@allyhub/audio/dist/index.d.ts +1 -0
  3. package/dist/node_modules/@allyhub/audio/dist/index.js +1 -1
  4. package/dist/node_modules/@allyhub/audio/dist/place.d.ts +26 -0
  5. package/dist/node_modules/@allyhub/audio/dist/place.js +2 -0
  6. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  7. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  8. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  9. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +15 -3
  10. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  11. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +40 -7
  12. package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
  13. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +4 -0
  14. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  15. package/dist/node_modules/@allyhub/image-draw/dist/stage.js +1 -1
  16. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  17. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  18. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  19. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  20. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  21. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +15 -0
  22. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -0
  23. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  24. package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +9 -0
  25. package/dist/node_modules/@allyhub/piece/dist/page/runtimes.js +2 -0
  26. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +51 -10
  27. package/dist/node_modules/@allyhub/piece/dist/source.js +1 -1
  28. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  29. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +0 -6
  30. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  31. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +39 -0
  32. package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
  33. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +3 -0
  34. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  35. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +30 -0
  36. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
  37. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +6 -0
  38. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  39. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  40. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  41. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  42. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  43. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +12 -0
  44. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  45. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  46. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  47. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/dynamic.js +1 -1
  48. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  49. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/logical.js +1 -1
  50. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  51. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  52. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  53. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +1 -1
  54. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  55. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  56. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  57. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  58. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  59. package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +10 -0
  60. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  61. package/dist/node_modules/@allyhub/slides-core/dist/api.js +1 -1
  62. package/dist/node_modules/@allyhub/slides-core/dist/components.js +1 -1
  63. package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +3 -1
  64. package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +5 -0
  65. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  66. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  67. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  68. package/dist/node_modules/@allyhub/video-sdk/dist/free.d.ts +1 -1
  69. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  70. package/docs/docs.md +11 -0
  71. package/docs/layers.md +2 -0
  72. package/docs/slides.md +1 -1
  73. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{pathSteps as E}from"./path.js";import{EMU_PER_PT as h}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,"fly-in":.5,"float-in":1,split:.5,wipe:.5,zoom:.5,disappear:0,"fade-out":.5,"fly-out":.5,"float-out":1,"split-out":.5,"wipe-out":.5,"zoom-out":.5,pulse:.5,"grow-shrink":2,spin:2,transparency:.5,path:2};const I=new Set(["disappear","fade-out","fly-out","float-out","split-out","wipe-out","zoom-out"]),A=new Set(["appear","fade","fly-in","float-in","split","wipe","zoom"]);export const isExit=t=>I.has(t),isEntrance=t=>A.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,split:1.5,reveal:2,cut:0,cover:1,uncover:1,zoom:1,morph:2};const x=["from-right","from-top","from-left","from-bottom"],w=[...x,"from-top-right","from-bottom-right","from-top-left","from-bottom-left"];export const TRANSITION_OPTIONS={fade:{directions:[],throughBlack:!0},push:{directions:x,throughBlack:!1},wipe:{directions:x,throughBlack:!1},split:{directions:["vertical-out","vertical-in","horizontal-out","horizontal-in"],throughBlack:!1},reveal:{directions:["from-right","from-left"],throughBlack:!0},cut:{directions:[],throughBlack:!0},cover:{directions:w,throughBlack:!1},uncover:{directions:w,throughBlack:!1},zoom:{directions:["in","out","rotate"],throughBlack:!1},morph:{directions:[],throughBlack:!1}};const S=["vertical-out","vertical-in","horizontal-out","horizontal-in"];export const EFFECT_OPTIONS={appear:{directions:[]},fade:{directions:[]},"fly-in":{directions:["from-bottom","from-top","from-left","from-right"]},"float-in":{directions:["up","down"]},split:{directions:S},wipe:{directions:["from-bottom","from-top","from-left","from-right"]},zoom:{directions:[]},disappear:{directions:[]},"fade-out":{directions:[]},"fly-out":{directions:["from-bottom","from-top","from-left","from-right"]},"float-out":{directions:["up","down"]},"split-out":{directions:S},"wipe-out":{directions:["from-bottom","from-top","from-left","from-right"]},"zoom-out":{directions:[]},pulse:{directions:[]},"grow-shrink":{directions:["both","horizontal","vertical"],amounts:[1.1,.5,1.5,4],amount:1.5},spin:{directions:["clockwise","counterclockwise"],amounts:[90,180,360,720],amount:360},transparency:{directions:[],amounts:[.25,.5,.75,1],amount:.5},path:{directions:[]}},effectTakes=(t,e)=>EFFECT_OPTIONS[t].directions.includes(e),transitionTakes=(t,e)=>TRANSITION_OPTIONS[t].directions.includes(e),resolveTransition=t=>{const e=TRANSITION_OPTIONS[t.type];return{type:t.type,direction:t.direction!==void 0&&e.directions.includes(t.direction)?t.direction:e.directions[0]??"from-right",throughBlack:t.through_black===!0&&e.throughBlack,duration:t.duration??TRANSITION_DURATIONS[t.type]}};const B={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1},"from-top-right":{x:1,y:-1},"from-bottom-right":{x:1,y:1},"from-top-left":{x:-1,y:-1},"from-bottom-left":{x:-1,y:1}},m=t=>B[t]??{x:0,y:1},l={opacity:1,x:0,y:0,scale:1,rotate:0};export function barn(t,e){const n=t==="vertical-out"||t==="vertical-in";if(t==="vertical-out"||t==="horizontal-out"){const s=(1-e)/2;return{clip:n?{top:0,right:s,bottom:0,left:s}:{top:s,right:0,bottom:s,left:0}}}const f=e/2,i=1-f,r=[[0,0],[f,0],[f,1],[i,1],[i,0],[1,0],[1,1],[0,1]];return{polygon:n?r:r.map(([s,c])=>[c,s])}}export function transitionAt(t,e){const o={incoming:{...l},outgoing:{...l},outgoingOver:!1,black:!1},f=e<.5;switch(t.type){case"fade":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:f?1-2*e:0},incoming:{...l,opacity:f?0:2*e-1}}:{...o,incoming:{...l,opacity:e}};case"cut":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:0},incoming:{...l,opacity:e>=1?1:0}}:o;case"push":{const i=m(t.direction);return{...o,incoming:{...l,x:i.x*(1-e),y:i.y*(1-e)},outgoing:{...l,x:-i.x*e,y:-i.y*e}}}case"cover":{const i=m(t.direction);return{...o,incoming:{...l,x:i.x*(1-e),y:i.y*(1-e)}}}case"uncover":{const i=m(t.direction);return{...o,outgoingOver:!0,outgoing:{...l,x:-i.x*e,y:-i.y*e}}}case"reveal":{const i=m(t.direction);return t.throughBlack?{...o,outgoingOver:!0,black:!0,outgoing:{...l,x:-i.x*Math.min(1,2*e),opacity:f?1-2*e:0},incoming:{...l,opacity:f?0:2*e-1}}:{...o,outgoingOver:!0,outgoing:{...l,x:-i.x*e,opacity:1-e}}}case"wipe":return{...o,incoming:{...l,clip:O(t.direction,1-e)}};case"split":return{...o,incoming:{...l,...barn(t.direction,e)}};case"zoom":return t.direction==="out"?{...o,outgoingOver:!0,outgoing:{...l,scale:1-e,opacity:1-e}}:{...o,incoming:{...l,scale:e,opacity:t.direction==="rotate"?1:e,rotate:t.direction==="rotate"?-720*(1-e):0}};case"morph":return o}}export function morphFrame(t,e,n){const o=n*n*(3-2*n),f=(i,r)=>i+(r-i)*o;return{left:f(t.left,e.left),top:f(t.top,e.top),width:f(t.width,e.width),height:f(t.height,e.height)}}export const TEXT_DELAY=.1;const T=new Intl.Segmenter(void 0,{granularity:"grapheme"});export function textUnits(t,e){return e==="word"?t.split(/\s+/u).filter(n=>n!==""):[...T.segment(t)].map(n=>n.segment).filter(n=>!/^\s+$/u.test(n))}export function unitsAcross(t,e){const n=[];let o=[];return t.forEach((f,i)=>{if(e==="letter"){for(const r of T.segment(f))/^\s+$/u.test(r.segment)||n.push([{piece:i,start:r.index,end:r.index+r.segment.length}]);return}for(const r of f.matchAll(/\s+|\S+/gu))/^\s/u.test(r[0])?(o.length>0&&n.push(o),o=[]):o.push({piece:i,start:r.index,end:r.index+r[0].length})}),o.length>0&&n.push(o),n}export const roundOf=t=>t.iterate?t.duration*(1+Math.max(0,t.iterate.units-1)*t.iterate.delay):t.duration,spanOf=t=>roundOf(t)*(typeof t.repeat=="number"?t.repeat:1);export function resolveAnimation(t,e=1){const n=t.path===void 0?void 0:E(t.path);if(t.path!==void 0&&!n||t.effect==="path"&&!n)return;const o=EFFECT_OPTIONS[t.effect],f=o.amount===void 0?void 0:t.amount??o.amount;return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction!==void 0&&o.directions.includes(t.direction)?t.direction:o.directions[0]??"from-bottom",...f===void 0?{}:{amount:t.effect==="transparency"?Math.min(1,f):f},start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...t.animate_text===void 0?{}:{iterate:{by:t.animate_text,delay:t.text_delay??TEXT_DELAY,units:Math.max(1,e)}},...t.repeat===void 0||t.repeat===1?{}:{repeat:t.repeat},...t.rewind?{rewind:!0}:{},...n?{path:n.map(i=>i.op==="close"?i:i.op!=="curve"?{...i,x:i.x*h,y:i.y*h}:{op:"curve",x1:i.x1*h,y1:i.y1*h,x2:i.x2*h,y2:i.y2*h,x:i.x*h,y:i.y*h})}:{}}}export function slideClock(t,e,n,o=0,f=0){const i=new Set(t.filter(a=>isEntrance(a.effect)).map(a=>a.shape)),r=[...e].filter(([a])=>!i.has(a)).map(([,a])=>a);let s=f+Math.max(0,...r);if(t.length===0)return{timed:[],rests:[Math.max(n,f,...r)]};const c=[],d=[];let u=0,p=f;for(const a of t){a.start==="on-click"?(c.push(s),u++,s+=o,p=s):a.start==="after-previous"&&(p=s);const g=p+a.delay,v=g+spanOf(a);d.push({...a,step:u,from:g,to:v}),s=Math.max(s,v);const b=e.get(a.shape);b!==void 0&&isEntrance(a.effect)&&(s=Math.max(s,g+b))}c.push(s);for(const a of d)a.repeat==="until-next-click"?a.stop=c[a.step]??s:a.repeat==="until-end-of-slide"&&(a.stop=s);return{timed:d,rests:c}}export const SLIDE_SECONDS=4,componentSeconds=t=>t.dur??SLIDE_SECONDS,DECK_FPS=30;const M=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export const inTransition=(t,e)=>t<e-1e-6;export function clockOf(t,e){const n=e?0:t.transition?.duration??0,o=slideClock(t.animations,new Map(t.shapes.flatMap(s=>s.component?[[s.name,componentSeconds(s.component)-1/DECK_FPS]]:[])),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,n),f=o.rests.map(M),i=s=>o.timed.find(c=>c.shape===s&&isEntrance(c.effect))?.from??n,r=new Map;for(const s of t.shapes){if(s.media?.playback?.start!=="on-click")continue;const c=f.at(-1)??n;r.set(s.name,c),f.push(M(c+1/DECK_FPS))}return{timed:o.timed,rests:f,lead:n,comesOn:i,goesOff:s=>o.timed.find(c=>c.shape===s&&isExit(c.effect))?.to,playsAt:s=>r.get(s)??i(s)}}const k=1e-6,y={hidden:!1,opacity:1,x:0,y:0,scale:1,sx:1,sy:1,rotate:0},N=t=>1-(1-t)*(1-t);function _(t){const e=[];let n={x:0,y:0};for(const o of t){if(o.op==="close")continue;if(o.op!=="curve"){n={x:o.x,y:o.y},e.push(n);continue}const f=n;for(let i=1;i<=24;i++){const r=i/24,s=1-r,c=(d,u,p,a)=>s*s*s*d+3*s*s*r*u+3*s*r*r*p+r*r*r*a;e.push({x:c(f.x,o.x1,o.x2,o.x),y:c(f.y,o.y1,o.y2,o.y)})}n={x:o.x,y:o.y}}return e}export function pathPoint(t,e){const n=_(t),[o]=n;if(!o)return{x:0,y:0};let f=0;for(let r=1;r<n.length;r++){const[s,c]=[n[r-1]??o,n[r]??o];f+=Math.hypot(c.x-s.x,c.y-s.y)}let i=f*e;for(let r=1;r<n.length;r++){const[s,c]=[n[r-1]??o,n[r]??o],d=Math.hypot(c.x-s.x,c.y-s.y);if(i<=d&&d>0){const u=i/d;return{x:s.x+(c.x-s.x)*u,y:s.y+(c.y-s.y)*u}}i-=d}return n.at(-1)??o}function P(t,e,n){return t==="from-left"?{x:-(e.left+e.width),y:0}:t==="from-right"?{x:n.width-e.left,y:0}:t==="from-top"?{x:0,y:-(e.top+e.height)}:{x:0,y:n.height-e.top}}function O(t,e){const n={top:0,right:0,bottom:0,left:0};return t==="from-left"?n.right=e:t==="from-right"?n.left=e:t==="from-top"?n.bottom=e:n.top=e,n}const D={"vertical-out":"vertical-in","vertical-in":"vertical-out","horizontal-out":"horizontal-in","horizontal-in":"horizontal-out"};function z(t,e,n,o){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:e};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:e,opacity:e};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:O(t.direction,1-e)};if(t.effect==="split")return barn(t.direction,e);if(t.effect==="split-out")return barn(D[t.direction]??"vertical-in",e);if(t.effect==="float-in"||t.effect==="float-out"){const f=.1*o.height*(1-e),i=t.effect==="float-in"==(t.direction==="down")?-1:1;return{opacity:e,y:i*f}}if(t.effect==="fly-in"||t.effect==="fly-out"){const f=P(t.direction,n,o);return{x:f.x*(1-e),y:f.y*(1-e)}}return{}}export function drawnAt(t,e,n,o,f){const[i]=t;let r=i&&isEntrance(i.effect)?{...y,hidden:!0}:{...y};const s=c=>e<c-k;for(const c of t){const d=f!==void 0&&c.iterate?f*c.iterate.delay*c.duration:0;if(s(c.from+d))break;const u=R(c,e,d);if(u!==void 0)if(c.effect==="path"&&c.path){const p=pathPoint(c.path,u);r={...r,x:p.x,y:p.y}}else if(c.effect==="pulse")r={...r,scale:1+.05*Math.sin(u*Math.PI)};else if(c.effect==="grow-shrink"){const p=1+((c.amount??1.5)-1)*u;r={...r,sx:r.sx*(c.direction==="vertical"?1:p),sy:r.sy*(c.direction==="horizontal"?1:p)}}else if(c.effect==="spin"){const p=(c.amount??360)*u;r={...r,rotate:r.rotate+(c.direction==="counterclockwise"?-p:p)}}else c.effect==="transparency"?r={...r,opacity:r.opacity*(1-(c.amount??.5)*u)}:isExit(c.effect)?r=u>=1?{...y,hidden:!0}:{...r,...z(c,1-(c.effect==="fly-out"?u*u:u),n,o)}:r={...y,...u<1?z(c,c.effect==="fly-in"?N(u):u,n,o):{}}}return r}function R(t,e,n){const o=roundOf(t),f=r=>t.duration>0?Math.min(1,Math.max(0,(r-n)/t.duration)):1,i=typeof t.repeat=="string"?t.stop??1/0:t.to;if(e>=i-k){if(t.rewind)return;const r=typeof t.repeat=="number"?t.repeat%1:0;return r>k?f(o*r):1}return o<=0?1:f((e-t.from)%o)}export function animationTargets(t){const e=new Map;for(const n of t){const o=JSON.stringify([n.shape,n.paragraph??null]),f=e.get(o);f?f.animations.push(n):e.set(o,{shape:n.shape,...n.paragraph===void 0?{}:{paragraph:n.paragraph},animations:[n]})}return[...e.values()]}
2
+ import{pathSteps as E}from"./path.js";import{EMU_PER_PT as m}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,"fly-in":.5,"float-in":1,split:.5,wipe:.5,zoom:.5,disappear:0,"fade-out":.5,"fly-out":.5,"float-out":1,"split-out":.5,"wipe-out":.5,"zoom-out":.5,pulse:.5,"grow-shrink":2,spin:2,transparency:.5,path:2};const I=new Set(["disappear","fade-out","fly-out","float-out","split-out","wipe-out","zoom-out"]),A=new Set(["appear","fade","fly-in","float-in","split","wipe","zoom"]);export const isExit=t=>I.has(t),isEntrance=t=>A.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,split:1.5,reveal:2,cut:0,cover:1,uncover:1,zoom:1,morph:2};const x=["from-right","from-top","from-left","from-bottom"],w=[...x,"from-top-right","from-bottom-right","from-top-left","from-bottom-left"];export const TRANSITION_OPTIONS={fade:{directions:[],throughBlack:!0},push:{directions:x,throughBlack:!1},wipe:{directions:x,throughBlack:!1},split:{directions:["vertical-out","vertical-in","horizontal-out","horizontal-in"],throughBlack:!1},reveal:{directions:["from-right","from-left"],throughBlack:!0},cut:{directions:[],throughBlack:!0},cover:{directions:w,throughBlack:!1},uncover:{directions:w,throughBlack:!1},zoom:{directions:["in","out","rotate"],throughBlack:!1},morph:{directions:[],throughBlack:!1}};const S=["vertical-out","vertical-in","horizontal-out","horizontal-in"];export const EFFECT_OPTIONS={appear:{directions:[]},fade:{directions:[]},"fly-in":{directions:["from-bottom","from-top","from-left","from-right"]},"float-in":{directions:["up","down"]},split:{directions:S},wipe:{directions:["from-bottom","from-top","from-left","from-right"]},zoom:{directions:[]},disappear:{directions:[]},"fade-out":{directions:[]},"fly-out":{directions:["from-bottom","from-top","from-left","from-right"]},"float-out":{directions:["up","down"]},"split-out":{directions:S},"wipe-out":{directions:["from-bottom","from-top","from-left","from-right"]},"zoom-out":{directions:[]},pulse:{directions:[]},"grow-shrink":{directions:["both","horizontal","vertical"],amounts:[1.1,.5,1.5,4],amount:1.5},spin:{directions:["clockwise","counterclockwise"],amounts:[90,180,360,720],amount:360},transparency:{directions:[],amounts:[.25,.5,.75,1],amount:.5},path:{directions:[]}},effectTakes=(t,e)=>EFFECT_OPTIONS[t].directions.includes(e),transitionTakes=(t,e)=>TRANSITION_OPTIONS[t].directions.includes(e),resolveTransition=t=>{const e=TRANSITION_OPTIONS[t.type];return{type:t.type,direction:t.direction!==void 0&&e.directions.includes(t.direction)?t.direction:e.directions[0]??"from-right",throughBlack:t.through_black===!0&&e.throughBlack,duration:t.duration??TRANSITION_DURATIONS[t.type]}};const B={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1},"from-top-right":{x:1,y:-1},"from-bottom-right":{x:1,y:1},"from-top-left":{x:-1,y:-1},"from-bottom-left":{x:-1,y:1}},h=t=>B[t]??{x:0,y:1},l={opacity:1,x:0,y:0,scale:1,rotate:0};export function barn(t,e){const n=t==="vertical-out"||t==="vertical-in";if(t==="vertical-out"||t==="horizontal-out"){const f=(1-e)/2;return{clip:n?{top:0,right:f,bottom:0,left:f}:{top:f,right:0,bottom:f,left:0}}}const s=e/2,c=1-s,r=[[0,0],[s,0],[s,1],[c,1],[c,0],[1,0],[1,1],[0,1]];return{polygon:n?r:r.map(([f,i])=>[i,f])}}export function transitionAt(t,e){const o={incoming:{...l},outgoing:{...l},outgoingOver:!1,black:!1},s=e<.5;switch(t.type){case"fade":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:s?1-2*e:0},incoming:{...l,opacity:s?0:2*e-1}}:{...o,incoming:{...l,opacity:e}};case"cut":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:0},incoming:{...l,opacity:e>=1?1:0}}:o;case"push":{const c=h(t.direction);return{...o,incoming:{...l,x:c.x*(1-e),y:c.y*(1-e)},outgoing:{...l,x:-c.x*e,y:-c.y*e}}}case"cover":{const c=h(t.direction);return{...o,incoming:{...l,x:c.x*(1-e),y:c.y*(1-e)}}}case"uncover":{const c=h(t.direction);return{...o,outgoingOver:!0,outgoing:{...l,x:-c.x*e,y:-c.y*e}}}case"reveal":{const c=h(t.direction);return t.throughBlack?{...o,outgoingOver:!0,black:!0,outgoing:{...l,x:-c.x*Math.min(1,2*e),opacity:s?1-2*e:0},incoming:{...l,opacity:s?0:2*e-1}}:{...o,outgoingOver:!0,outgoing:{...l,x:-c.x*e,opacity:1-e}}}case"wipe":return{...o,incoming:{...l,clip:O(t.direction,1-e)}};case"split":return{...o,incoming:{...l,...barn(t.direction,e)}};case"zoom":return t.direction==="out"?{...o,outgoingOver:!0,outgoing:{...l,scale:1-e,opacity:1-e}}:{...o,incoming:{...l,scale:e,opacity:t.direction==="rotate"?1:e,rotate:t.direction==="rotate"?-720*(1-e):0}};case"morph":return o}}export function morphFrame(t,e,n){const o=n*n*(3-2*n),s=(c,r)=>c+(r-c)*o;return{left:s(t.left,e.left),top:s(t.top,e.top),width:s(t.width,e.width),height:s(t.height,e.height)}}export const TEXT_DELAY=.1;const T=new Intl.Segmenter(void 0,{granularity:"grapheme"});export function textUnits(t,e){return e==="word"?t.split(/\s+/u).filter(n=>n!==""):[...T.segment(t)].map(n=>n.segment).filter(n=>!/^\s+$/u.test(n))}export function unitsAcross(t,e){const n=[];let o=[];return t.forEach((s,c)=>{if(e==="letter"){for(const r of T.segment(s))/^\s+$/u.test(r.segment)||n.push([{piece:c,start:r.index,end:r.index+r.segment.length}]);return}for(const r of s.matchAll(/\s+|\S+/gu))/^\s/u.test(r[0])?(o.length>0&&n.push(o),o=[]):o.push({piece:c,start:r.index,end:r.index+r[0].length})}),o.length>0&&n.push(o),n}export const roundOf=t=>t.iterate?t.duration*(1+Math.max(0,t.iterate.units-1)*t.iterate.delay):t.duration,spanOf=t=>roundOf(t)*(typeof t.repeat=="number"?t.repeat:1);export function resolveAnimation(t,e=1){const n=t.path===void 0?void 0:E(t.path);if(t.path!==void 0&&!n||t.effect==="path"&&!n)return;const o=EFFECT_OPTIONS[t.effect],s=o.amount===void 0?void 0:t.amount??o.amount;return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction!==void 0&&o.directions.includes(t.direction)?t.direction:o.directions[0]??"from-bottom",...s===void 0?{}:{amount:t.effect==="transparency"?Math.min(1,s):s},start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...t.animate_text===void 0?{}:{iterate:{by:t.animate_text,delay:t.text_delay??TEXT_DELAY,units:Math.max(1,e)}},...t.repeat===void 0||t.repeat===1?{}:{repeat:t.repeat},...t.rewind?{rewind:!0}:{},...n?{path:n.map(c=>c.op==="close"?c:c.op!=="curve"?{...c,x:c.x*m,y:c.y*m}:{op:"curve",x1:c.x1*m,y1:c.y1*m,x2:c.x2*m,y2:c.y2*m,x:c.x*m,y:c.y*m})}:{}}}export function slideClock(t,e,n,o=0,s=0){const c=new Set(t.filter(a=>isEntrance(a.effect)).map(a=>a.shape)),r=[...e].filter(([a])=>!c.has(a)).map(([,a])=>a);let f=s+Math.max(0,...r);if(t.length===0)return{timed:[],rests:[Math.max(n,s,...r)]};const i=[],d=[];let u=0,p=s;for(const a of t){a.start==="on-click"?(i.push(f),u++,f+=o,p=f):a.start==="after-previous"&&(p=f);const g=p+a.delay,v=g+spanOf(a);d.push({...a,step:u,from:g,to:v}),f=Math.max(f,v);const b=e.get(a.shape);b!==void 0&&isEntrance(a.effect)&&(f=Math.max(f,g+b))}i.push(f);for(const a of d)a.repeat==="until-next-click"?a.stop=i[a.step]??f:a.repeat==="until-end-of-slide"&&(a.stop=f);return{timed:d,rests:i}}export const SLIDE_SECONDS=4,componentSeconds=t=>t.dur??SLIDE_SECONDS,DECK_FPS=30;const M=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export const inTransition=(t,e)=>t<e-1e-6;export function clockOf(t,e){const n=e?0:t.transition?.duration??0,o=slideClock(t.animations,new Map(t.shapes.flatMap(f=>{if(f.component)return[[f.name,componentSeconds(f.component)-1/DECK_FPS]];const i=f.item?.playback?.trim;return i?.end===void 0?[]:[[f.name,Math.max(0,i.end-(i.start??0))-1/DECK_FPS]]})),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,n),s=o.rests.map(M),c=f=>o.timed.find(i=>i.shape===f&&isEntrance(i.effect))?.from??n,r=new Map;for(const f of t.shapes){if((f.media??f.item)?.playback?.start!=="on-click")continue;const i=s.at(-1)??n;r.set(f.name,i),s.push(M(i+1/DECK_FPS))}return{timed:o.timed,rests:s,lead:n,comesOn:c,goesOff:f=>o.timed.find(i=>i.shape===f&&isExit(i.effect))?.to,playsAt:f=>r.get(f)??c(f)}}const k=1e-6,y={hidden:!1,opacity:1,x:0,y:0,scale:1,sx:1,sy:1,rotate:0},N=t=>1-(1-t)*(1-t);function _(t){const e=[];let n={x:0,y:0};for(const o of t){if(o.op==="close")continue;if(o.op!=="curve"){n={x:o.x,y:o.y},e.push(n);continue}const s=n;for(let c=1;c<=24;c++){const r=c/24,f=1-r,i=(d,u,p,a)=>f*f*f*d+3*f*f*r*u+3*f*r*r*p+r*r*r*a;e.push({x:i(s.x,o.x1,o.x2,o.x),y:i(s.y,o.y1,o.y2,o.y)})}n={x:o.x,y:o.y}}return e}export function pathPoint(t,e){const n=_(t),[o]=n;if(!o)return{x:0,y:0};let s=0;for(let r=1;r<n.length;r++){const[f,i]=[n[r-1]??o,n[r]??o];s+=Math.hypot(i.x-f.x,i.y-f.y)}let c=s*e;for(let r=1;r<n.length;r++){const[f,i]=[n[r-1]??o,n[r]??o],d=Math.hypot(i.x-f.x,i.y-f.y);if(c<=d&&d>0){const u=c/d;return{x:f.x+(i.x-f.x)*u,y:f.y+(i.y-f.y)*u}}c-=d}return n.at(-1)??o}function P(t,e,n){return t==="from-left"?{x:-(e.left+e.width),y:0}:t==="from-right"?{x:n.width-e.left,y:0}:t==="from-top"?{x:0,y:-(e.top+e.height)}:{x:0,y:n.height-e.top}}function O(t,e){const n={top:0,right:0,bottom:0,left:0};return t==="from-left"?n.right=e:t==="from-right"?n.left=e:t==="from-top"?n.bottom=e:n.top=e,n}const D={"vertical-out":"vertical-in","vertical-in":"vertical-out","horizontal-out":"horizontal-in","horizontal-in":"horizontal-out"};function z(t,e,n,o){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:e};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:e,opacity:e};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:O(t.direction,1-e)};if(t.effect==="split")return barn(t.direction,e);if(t.effect==="split-out")return barn(D[t.direction]??"vertical-in",e);if(t.effect==="float-in"||t.effect==="float-out"){const s=.1*o.height*(1-e),c=t.effect==="float-in"==(t.direction==="down")?-1:1;return{opacity:e,y:c*s}}if(t.effect==="fly-in"||t.effect==="fly-out"){const s=P(t.direction,n,o);return{x:s.x*(1-e),y:s.y*(1-e)}}return{}}export function drawnAt(t,e,n,o,s){const[c]=t;let r=c&&isEntrance(c.effect)?{...y,hidden:!0}:{...y};const f=i=>e<i-k;for(const i of t){const d=s!==void 0&&i.iterate?s*i.iterate.delay*i.duration:0;if(f(i.from+d))break;const u=R(i,e,d);if(u!==void 0)if(i.effect==="path"&&i.path){const p=pathPoint(i.path,u);r={...r,x:p.x,y:p.y}}else if(i.effect==="pulse")r={...r,scale:1+.05*Math.sin(u*Math.PI)};else if(i.effect==="grow-shrink"){const p=1+((i.amount??1.5)-1)*u;r={...r,sx:r.sx*(i.direction==="vertical"?1:p),sy:r.sy*(i.direction==="horizontal"?1:p)}}else if(i.effect==="spin"){const p=(i.amount??360)*u;r={...r,rotate:r.rotate+(i.direction==="counterclockwise"?-p:p)}}else i.effect==="transparency"?r={...r,opacity:r.opacity*(1-(i.amount??.5)*u)}:isExit(i.effect)?r=u>=1?{...y,hidden:!0}:{...r,...z(i,1-(i.effect==="fly-out"?u*u:u),n,o)}:r={...y,...u<1?z(i,i.effect==="fly-in"?N(u):u,n,o):{}}}return r}function R(t,e,n){const o=roundOf(t),s=r=>t.duration>0?Math.min(1,Math.max(0,(r-n)/t.duration)):1,c=typeof t.repeat=="string"?t.stop??1/0:t.to;if(e>=c-k){if(t.rewind)return;const r=typeof t.repeat=="number"?t.repeat%1:0;return r>k?s(o*r):1}return o<=0?1:s((e-t.from)%o)}export function animationTargets(t){const e=new Map;for(const n of t){const o=JSON.stringify([n.shape,n.paragraph??null]),s=e.get(o);s?s.animations.push(n):e.set(o,{shape:n.shape,...n.paragraph===void 0?{}:{paragraph:n.paragraph},animations:[n]})}return[...e.values()]}
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
2
  import{themeColor as P,themeColorOf as T}from"@allyhub/chart";import{presetAdjustments as te}from"@allyhub/ooxml/geometry";import{connectorBetween as re,connectorEnds as se,siteOn as ie,sitesOf as ne}from"./connect.js";import{framedComponent as oe}from"@allyhub/piece";import{COLOR_TRANSFORMS as F,colorOfFile as ae,GRADIENT_PATHS as z,inGroup as I,THEME_COLORS as A}from"@allyhub/formats";import{MSO_ARROWHEAD as C,MSO_ARROWHEAD_SIZE as S,MSO_CONNECTOR as he,MSO_LINE as de,MSO_LINE_CAP as le,MSO_LINE_COMPOUND as fe,MSO_LINE_JOIN as ce,MSO_PATTERN_TYPE as ue,TILE_ALIGNMENT as pe,MSO_SHAPE as D,MSO_SHAPE_TYPE as _e,MSO_TEXT_ORIENTATION as G,PP_PLACEHOLDER as H}from"./enums.js";import{Chart as ge}from"./chart-api.js";import{AUTOSHAPE_STYLE as g,SHADOW_DEFAULTS as U,LINE_DEFAULTS as x,PATTERN_DEFAULTS as O,TILE_DEFAULTS as B,INNER_SHADOW_DEFAULTS as me,GLOW_DEFAULTS as v,REFLECTION_DEFAULTS as we,PLAYBACK_DEFAULTS as W,CONNECTOR_GEOMETRIES as be,CONNECTOR_STYLE as Y,FOOTER_IDX as ye,isConnectorGeometry as M,OFFICE_TEXT_STYLES as xe,placeholderLevels as Ee,TEXT_INSETS as w,TEXTBOX_FRAME as Se}from"./office.js";import{masterPlaceholder as X}from"./placeholders.js";import{strict as a}from"./strict.js";import{DEFAULT_TABLE_STYLE as Oe,TABLE_STYLES as $e,tableStyleOf as Z}from"./table-style.js";import{EMU_PER_PT as R,SLIDE_SIZES as j,length as l,lengthOr as $}from"./units.js";class ke extends Error{constructor(e){super(`${e} (allyhub slides capabilities lists what the API holds).`),this.name="Unsupported"}}export const refuse=i=>{throw new ke(i)};const Te=/^#?[0-9a-f]{6}$/iu,J=i=>{if(!Te.test(i))throw new Error(`rgb ${i} is not RRGGBB.`);return`#${i.replace("#","").toUpperCase()}`};function N(i,e){if(typeof i!="string")return i;const t=ae(i);if(t===void 0)throw new Error(`${e} is a theme colour (accent1), one lighter or darker (accent1 lighter 40%) or #RRGGBB, not ${i}.`);return t}export const OFFICE_COLOR_MAP={...Object.fromEntries(A.map(i=>[i,i])),tx1:"dk1",bg1:"lt1",tx2:"dk2",bg2:"lt2"};const Ae=["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function K(i){const e={};for(const[t,r]of Object.entries(i))if(r!==void 0){if(!Ae.includes(t))throw new Error(`A colour map maps bg1, tx1, bg2, tx2, accent1 to accent6, hlink and folHlink, not ${t}.`);if(!A.includes(r))throw new Error(`A colour map's ${t} is one of the theme's colours (${A.join(", ")}), not ${r}.`);e[t]=r}return e}export const RGBColor=Object.assign(function(e,t,r){for(const o of[e,t,r])if(!Number.isInteger(o)||o<0||o>255)throw new Error(`RGBColor(${String(e)}, ${String(t)}, ${String(r)}): each is 0 to 255.`);const s=`#${[e,t,r].map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase()}`;return new.target===void 0?s:new String(s)},{from_string:i=>J(i)});export class ColorFormat{read;write;constructor(e,t){return this.read=e,this.write=t,a(this,"ColorFormat")}get theme_color(){const e=this.read();return e===void 0?void 0:T(e)}set theme_color(e){const t=this.read();e!==void 0&&typeof t=="object"&&"transforms"in t?this.write(t.transforms.length>0?{theme_color:e,transforms:t.transforms}:e):this.write(e===void 0?void 0:P(e,this.brightness))}get transforms(){const e=this.read();return typeof e=="object"&&"transforms"in e?[...e.transforms??[]]:[]}set transforms(e){const t=this.read();if(t===void 0)throw new TypeError("There is no colour to transform: set theme_color or rgb first.");for(const s of e)if(!F.includes(s.name))throw new Error(`A colour's transform is one of ${F.join(", ")}, not ${s.name}.`);const r=e.map(s=>({name:s.name,value:s.value}));if(typeof t=="object"&&"rgb"in t)this.write(r.length>0?{rgb:t.rgb,transforms:r}:{rgb:t.rgb});else{const s=T(t)??"dk1";this.write(r.length>0?{theme_color:s,transforms:r}:s)}}get brightness(){const e=this.read();return typeof e=="object"&&"brightness"in e?e.brightness:0}set brightness(e){if(!(e>=-1&&e<=1))throw new RangeError(`brightness ${String(e)} is not a number from -1.0 to 1.0.`);const t=this.read();if(t===void 0)throw new TypeError("There is no colour to set the brightness of: set theme_color first.");const r=T(t);if(r!==void 0)this.write(P(r,e));else if(e!==0)throw new TypeError("Only a theme colour has a brightness here, so an RGB colour does not: set theme_color first, or rgb to the colour it makes.")}get rgb(){const e=this.read();return typeof e=="object"&&"rgb"in e?e.rgb:void 0}set rgb(e){this.write(e===void 0?void 0:{rgb:J(e)})}}export class Font{def;constructor(e){return this.def=e,a(this,"Font")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get strike(){const e=this.def.strike;return e==="sngStrike"?!0:e}set strike(e){this._set("strike",e==="noStrike"?!1:e==="sngStrike"?!0:e)}get caps(){return this.def.caps}set caps(e){this._set("caps",e)}get baseline(){return this.def.baseline}set baseline(e){this._set("baseline",e)}get highlight(){return this.def.highlight}set highlight(e){this._set("highlight",e)}get name(){return this.def.name}set name(e){this._set("name",e)}get size(){return $(this.def.size)}set size(e){if(e!==void 0&&e<12700)throw new Error(`A font size is a Length of Pt(1) and over: Pt(${String(e)}) for ${String(e)} points; ${String(e)} alone is ${String(e)} EMU.`);this._set("size",e)}get bold(){return this.def.bold}set bold(e){this._set("bold",e)}get italic(){return this.def.italic}set italic(e){this._set("italic",e)}get underline(){const e=this.def.underline;return e==="sng"?!0:e}set underline(e){this._set("underline",e==="none"?!1:e==="sng"?!0:e)}get spacing(){return $(this.def.spacing)}set spacing(e){this._set("spacing",e)}get color(){return new ColorFormat(()=>this.def.color,e=>{this._set("color",e)})}}export class Hyperlink{def;constructor(e){return this.def=e,a(this,"_Hyperlink")}get address(){return this.def.font?.link}set address(e){this.def.font??={},e===void 0?Reflect.deleteProperty(this.def.font,"link"):this.def.font.link=e}}export class Run{def;constructor(e){return this.def=e,a(this,"_Run")}get text(){return this.def.text}set text(e){this.def.text=e}get font(){return this.def.font??={},new Font(this.def.font)}get hyperlink(){return new Hyperlink(this.def)}}const Me=i=>{if(!Number.isFinite(i)||i<=0)throw new Error(`line_spacing ${String(i)} is not over 0.`);return Number.isInteger(i)&&i>=R?{fixed:i}:{lines:i}},Re=i=>i===void 0?void 0:"lines"in i?i.lines:l(i.fixed),q=i=>{if(!Number.isFinite(i)||i<0)throw new Error(`A paragraph's space ${String(i)} is under 0.`);return i===0||Number.isInteger(i)&&i>=R?i:{lines:i}},Q=i=>i===void 0?void 0:typeof i=="number"?l(i):i.lines,V=i=>i.split(/\n|\v/u).flatMap((e,t)=>[...t>0?[{text:"\v"}]:[],...e===""?[]:[{text:e}]]);class ee{_set(e,t){t===void 0?Reflect.deleteProperty(this.fmt,e):this.fmt[e]=t}get alignment(){return this.fmt.alignment}set alignment(e){this._set("alignment",e)}get line_spacing(){return Re(this.fmt.line_spacing)}set line_spacing(e){this._set("line_spacing",e===void 0?void 0:Me(e))}get space_before(){return Q(this.fmt.space_before)}set space_before(e){this._set("space_before",e===void 0?void 0:q(e))}get space_after(){return Q(this.fmt.space_after)}set space_after(e){this._set("space_after",e===void 0?void 0:q(e))}get font(){return this.fmt.font??={},new Font(this.fmt.font)}}export class Paragraph extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"_Paragraph")}get text(){return this.fmt.runs.map(e=>e.text).join("")}set text(e){this.fmt.runs=V(e)}get runs(){return this.fmt.runs.filter(e=>e.text!=="\v").map(e=>new Run(e))}add_run(){const e={text:""};return this.fmt.runs.push(e),new Run(e)}add_line_break(){this.fmt.runs.push({text:"\v"})}clear(){return this.fmt.runs=[],this}get level(){return this.fmt.level}set level(e){if(!Number.isInteger(e)||e<0||e>8)throw new Error(`level ${String(e)} is not 0 to 8.`);this.fmt.level=e}}export class ListLevel extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"ListLevel")}get numbered(){return this.fmt.numbered}set numbered(e){this._set("numbered",e)}get bullet(){return this.fmt.bullet}set bullet(e){this._set("bullet",e)}get bullet_font(){return this.fmt.bullet_font}set bullet_font(e){this._set("bullet_font",e)}get bullet_color(){return this.fmt.bullet_color}set bullet_color(e){this._set("bullet_color",e==null?e:N(e,"bullet_color"))}get bullet_size(){return this.fmt.bullet_size}set bullet_size(e){if(typeof e=="number"&&!(e>=.25&&e<=4))throw new Error(`bullet_size is a share of the text's size, 0.25 to 4, not ${String(e)}.`);this._set("bullet_size",e)}get start_at(){return this.fmt.start_at}set start_at(e){if(e!==void 0&&!(Number.isInteger(e)&&e>=1&&e<=32767))throw new Error(`start_at is a whole number from 1 to 32767, not ${String(e)}.`);this._set("start_at",e)}get margin_left(){return $(this.fmt.margin_left)}set margin_left(e){this._set("margin_left",e)}get indent(){return $(this.fmt.indent)}set indent(e){this._set("indent",e)}}const k=i=>Object.freeze(i.map(e=>new ListLevel(e))),je=()=>Array.from({length:9},()=>({})),E=()=>({paragraphs:[],levels:je()});export class TextFrame{def;constructor(e){return this.def=e,a(this,"TextFrame")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get text(){return this.def.paragraphs.map(e=>e.runs.map(t=>t.text).join("")).join(`
3
3
  `)}set text(e){this.def.paragraphs=e.split(`
4
- `).map(t=>({runs:V(t),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(e=>new Paragraph(e))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const e={runs:[],level:0};return this.def.paragraphs.push(e),new Paragraph(e)}clear(){const e=this.def.paragraphs[0];this.def.paragraphs=e?[{...e,runs:[]}]:[]}fit_text(e,t=18,r,s){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(t*R),...e===void 0?{}:{name:e},...r===void 0?{}:{bold:r},...s===void 0?{}:{italic:s}}}get list_style(){return k(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(e){this._set("vertical_anchor",e)}get orientation(){return this.def.orientation}set orientation(e){if(e!==void 0&&!Object.values(G).includes(e))throw new Error(`orientation is one of MSO_TEXT_ORIENTATION's ${Object.values(G).join(", ")}, not ${e}.`);this._set("orientation",e)}get auto_size(){return this.def.auto_size}set auto_size(e){this._set("auto_size",e)}get word_wrap(){return this.def.word_wrap}set word_wrap(e){this._set("word_wrap",e)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(e){this.def.margin_left=e}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(e){this.def.margin_top=e}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(e){this.def.margin_right=e}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(e){this.def.margin_bottom=e}}export class FillFormat{read;write;start;shape;base;constructor(e,t,r="lt1",s,n=""){return this.read=e,this.write=t,this.start=r,this.shape=s,this.base=n,a(this,"FillFormat")}_only(e){if(this.shape)for(const t of["gradient","pattern","picture_fill"])t!==e&&Reflect.deleteProperty(this.shape,t)}solid(){const e=this.read();this._only("solid"),e==null&&this.write(this.start)}background(){this._only("solid"),this.write(null)}patterned(){const e=this._shape("a pattern");this._only("pattern"),e.pattern??={preset:"pct5",fg:O.fg,bg:O.bg}}get pattern(){return this._pattern().preset}set pattern(e){this._pattern().preset=p(ue,"MSO_PATTERN_TYPE","pattern",e)}_pattern(){const{pattern:e}=this._shape("a pattern");if(!e)throw new TypeError("This fill is no pattern: call fill.patterned() first.");return e}get back_color(){const e=this._pattern();return new ColorFormat(()=>e.bg,t=>{e.bg=t??O.bg})}picture(e,t={}){const r=this._shape("a picture");this._only("picture_fill"),r.picture_fill={path:e,base:this.base,...t.tile?{tile:{...B,...t.tile,align:p(pe,"TILE_ALIGNMENT","tile.align",t.tile.align??B.align)}}:{},...t.transparency===void 0?{}:{transparency:t.transparency}}}_shape(e){if(!this.shape)throw new TypeError(`Only a shape's fill has ${e}.`);return this.shape}gradient(){this._only("gradient"),this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_path(){return this._gradient().path??"linear"}set gradient_path(e){const t=this._gradient();e==="linear"?delete t.path:z.includes(e)?t.path=e:refuse(`gradient_path is "linear", ${z.map(r=>`"${r}"`).join(", ")}, not ${e}.`)}get gradient_focus(){return{...this._gradient().focus??{left:.5,top:.5,right:.5,bottom:.5}}}set gradient_focus(e){this._gradient().focus={...e}}get gradient_angle(){return this._gradient().angle}set gradient_angle(e){this._gradient().angle=e}get gradient_stops(){return this._gradient().stops.map(e=>new GradientStop(e))}set gradient_stops(e){if(e.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=e.map(t=>t instanceof GradientStop?GradientStop.defOf(t):{...t,color:N(t.color,"A gradient stop's colour")})}_gradient(){const{gradient:e}=this._shape("a gradient");if(!e)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return e}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);this._shape("a transparency").fill_transparency=e}get type(){if(this.shape?.picture_fill)return"picture";if(this.shape?.pattern)return"patterned";if(this.shape?.gradient)return"gradient";const e=this.read();return e===void 0?void 0:e===null?"background":"solid"}get fore_color(){const e=this.shape?.pattern;if(e)return new ColorFormat(()=>e.fg,r=>{e.fg=r??O.fg});const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,r=>{this.write(r??this.start)})}}export class GradientStop{stop;constructor(e){return this.stop=e,a(this,"GradientStop")}static defOf(e){return{...e.stop}}get color(){return new ColorFormat(()=>this.stop.color,e=>{e!==void 0&&(this.stop.color=e)})}get position(){return this.stop.at}set position(e){if(!(e>=0&&e<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(e)}.`);this.stop.at=e}get transparency(){return this.stop.transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);e===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=e}}export class ShadowFormat{def;inner;constructor(e,t=!1){return this.def=e,this.inner=t,a(this,"ShadowFormat")}_shadow(){return this.inner?(this.def.inner_shadow??={...me},this.def.inner_shadow):(this.def.shadow??={...U},this.def.shadow)}get visible(){return this.inner?this.def.inner_shadow!==void 0:this.def.shadow!==void 0&&this.def.shadow!==null}set visible(e){e?this._shadow():this.inner?Reflect.deleteProperty(this.def,"inner_shadow"):this.def.shadow=null}get inherit(){return this.def.shadow===void 0}set inherit(e){e?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(e){this._shadow().blur=e}get distance(){return l(this._shadow().distance)}set distance(e){this._shadow().distance=e}get angle(){return this._shadow().angle}set angle(e){this._shadow().angle=e}get transparency(){return this._shadow().transparency}set transparency(e){this._shadow().transparency=e}get color(){const e=this._shadow();return new ColorFormat(()=>e.color,t=>{e.color=t??U.color})}}export class GlowFormat{def;constructor(e){return this.def=e,a(this,"GlowFormat")}_glow(){return this.def.glow??={...v},this.def.glow}get visible(){return this.def.glow!==void 0}set visible(e){e?this._glow():Reflect.deleteProperty(this.def,"glow")}get radius(){return l(this.def.glow?.size??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"glow"):this._glow().size=e}get transparency(){return this._glow().transparency}set transparency(e){this._glow().transparency=e}get color(){const e=this._glow();return new ColorFormat(()=>e.color,t=>{e.color=t??v.color})}}export class SoftEdgeFormat{def;constructor(e){return this.def=e,a(this,"SoftEdgeFormat")}get radius(){return l(this.def.soft_edges??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"soft_edges"):this.def.soft_edges=e}}export class ReflectionFormat{def;constructor(e){return this.def=e,a(this,"ReflectionFormat")}_reflection(){return this.def.reflection??={...we},this.def.reflection}get visible(){return this.def.reflection!==void 0}set visible(e){e?this._reflection():Reflect.deleteProperty(this.def,"reflection")}get transparency(){return this._reflection().transparency}set transparency(e){this._reflection().transparency=e}get size(){return this._reflection().size}set size(e){this._reflection().size=e}get offset(){return l(this._reflection().distance)}set offset(e){this._reflection().distance=e}get blur(){return l(this._reflection().blur)}set blur(e){this._reflection().blur=e}}export class LineFormat{def;constructor(e){return this.def=e,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,e=>{this.def.line=e??null})}get fill(){return new FillFormat(()=>this.def.line,e=>{this.def.line=e},"dk1")}get width(){return l(this.def.line_width??0)}set width(e){this.def.line_width=e}get dash_style(){return this.def.line_dash??null}set dash_style(e){e===null?delete this.def.line_dash:this.def.line_dash=p(de,"MSO_LINE","dash_style",e)}get cap_type(){return this.def.line_cap??x.cap}set cap_type(e){const t=p(le,"MSO_LINE_CAP","cap_type",e);t===x.cap?delete this.def.line_cap:this.def.line_cap=t}get join_type(){return this.def.line_join??x.join}set join_type(e){const t=p(ce,"MSO_LINE_JOIN","join_type",e);t===x.join?delete this.def.line_join:this.def.line_join=t}get compound_type(){return this.def.line_compound??x.compound}set compound_type(e){const t=p(fe,"MSO_LINE_COMPOUND","compound_type",e);t===x.compound?delete this.def.line_compound:this.def.line_compound=t}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(e){this.def.line_begin=p(C,"MSO_ARROWHEAD","begin_arrow",e)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(e){this.def.line_end=p(C,"MSO_ARROWHEAD","end_arrow",e)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(e){this.def.line_begin_size={...this.def.line_begin_size,w:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_width",e)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(e){this.def.line_begin_size={...this.def.line_begin_size,len:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_length",e)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(e){this.def.line_end_size={...this.def.line_end_size,w:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_width",e)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(e){this.def.line_end_size={...this.def.line_end_size,len:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_length",e)}}}function p(i,e,t,r){if(Object.values(i).includes(r))return r;throw new Error(`${t}: ${String(r)} is not one of ${e}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(e){return this.holder=e,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,e=>{this.holder.background=e??"bg1"})}}export const adjustmentDefaults=i=>te(i).map(e=>e.value/1e5);export class Adjustments{def;constructor(e){return this.def=e,a(this,"Adjustments",{index:t=>this._values()[t],setIndex:(t,r)=>{this._set(t,Number(r))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(e,t){const r=this._values();if(e<0||e>=r.length)throw new RangeError(`adjustments[${String(e)}]: ${this.def.geometry??"this shape"} has ${String(r.length)}.`);if(!Number.isFinite(t))throw new Error(`adjustments[${String(e)}] = ${String(t)} is not a number.`);r[e]=t,this.def.adjustments=r}}const Ne={left:0,top:0,width:0,height:0};export class Shape{def;inherit;base;constructor(e,t=()=>{},r=""){return this.def=e,this.inherit=t,this.base=r,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??Ne}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(e){this.def.name=e}get shape_type(){return this.def.path?"freeform":this.def.kind==="audio"?"movie":M(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new ge(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(e){this._own().left=e}get top(){return l(this._frame().top)}set top(e){this._own().top=e}get width(){return l(this._frame().width)}set width(e){this._own().width=e}get height(){return l(this._frame().height)}set height(e){this._own().height=e}get rotation(){return this.def.rotation??0}set rotation(e){if(!Number.isFinite(e))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const t=(Math.trunc(e*6e4)%216e5+216e5)%216e5/6e4;t===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=t}get flip_h(){return this.def.flip?.h===!0}set flip_h(e){this._flip("h",e)}get flip_v(){return this.def.flip?.v===!0}set flip_v(e){this._flip("v",e)}_flip(e,t){const r={...this.def.flip};t?r[e]=!0:Reflect.deleteProperty(r,e),Object.keys(r).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=r}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e},"lt1",this.def,this.base)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get inner_shadow(){return new ShadowFormat(this.def,!0)}get glow(){return new GlowFormat(this.def)}get soft_edge(){return new SoftEdgeFormat(this.def)}get reflection(){return new ReflectionFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(e){if(this.def.path||!M(this.def.geometry))throw new Error(`${this.def.name}.${e}: it is not a connector (add_connector makes one).`);return se(this._frame(),this.def.flip,this.def.rotation)}_move(e,t){const r=re(e,t,this.def.rotation);this.def.frame=r.frame,r.flip?this.def.flip=r.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(e){const[t,r]=this._ends("begin_x");this._move([e,t[1]],r)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(e){const[t,r]=this._ends("begin_y");this._move([t[0],e],r)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(e){const[t,r]=this._ends("end_x");this._move(t,[e,r[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(e){const[t,r]=this._ends("end_y");this._move(t,[r[0],e])}begin_connect(e,t){this._connect("begin",e,t)}end_connect(e,t){this._connect("end",e,t)}_connect(e,t,r){const s=`${e}_connect`,[n,o]=this._ends(s);if(!(t instanceof Shape))throw new Error(`${this.def.name}.${s}(): its shape is a Shape.`);const h=t._def,f={frame:t._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},c=ne(f).length;if(!Number.isInteger(r)||r<0||r>=c)throw new Error(`${this.def.name}.${s}(): ${h.name} has connection sites 0 to ${String(c-1)}; ${String(r)} is not one.`);const u=ie(f,r)??(e==="begin"?n:o);this.def.connect={...this.def.connect,[e]:{shape:h.name,site:r}},this._move(e==="begin"?u:n,e==="begin"?o:u)}}const Le=i=>typeof i=="number"&&Number.isFinite(i),_=(i,e,t,r)=>{for(const[s,n]of Object.entries({left:i,top:e,width:t,height:r}))if(!Le(n))throw new Error(`${s} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(t<0||r<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(e),width:Math.trunc(t),height:Math.trunc(r)}},Pe=new Set(Object.values(D));export class FreeformBuilder{steps;sx;sy;make;constructor(e,t,r){return this.steps=[{op:"move",x:e[0],y:e[1]}],[this.sx,this.sy]=typeof t=="number"?[t,t]:t,this.make=r,a(this,"FreeformBuilder")}add_line_segments(e,t=!0){for(const[r,s]of e)this.steps.push({op:"line",x:r,y:s});return t&&this.steps.push({op:"close"}),this}add_curve_segment(e,t,r,s,n,o){if(![e,t,r,s,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:e,y1:t,x2:r,y2:s,x:n,y:o}),this}move_to(e,t){return this.steps.push({op:"move",x:e,y:t}),this}convert_to_shape(e=0,t=0){this.steps.length<2&&refuse("convert_to_shape(): a freeform needs a segment.");const r=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),s=r.map(d=>d[0]),n=r.map(d=>d[1]),o=Math.min(...s),h=Math.min(...n),f=Math.max(...s)-o,c=Math.max(...n)-h;f===0&&c===0&&refuse("convert_to_shape(): a freeform's points are all one point.");const u=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:c,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...u(d.x,d.y)};const m=u(d.x1,d.y1),y=u(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...u(d.x,d.y)}})},_(Math.round(o*this.sx)+e,Math.round(h*this.sy)+t,Math.round(f*this.sx),Math.round(c*this.sy)))}}export class GroupShape{list;_name;make;constructor(e,t,r){return this.list=e,this._name=t,this.make=r,a(this,"GroupShape")}members(){return this.list.filter(e=>I(e.group,this._name))}box(){const e=this.members().flatMap(s=>s.frame?[s.frame]:[]),t=Math.min(...e.map(s=>s.left)),r=Math.min(...e.map(s=>s.top));return{left:e.length>0?t:0,top:e.length>0?r:0,right:Math.max(0,...e.map(s=>s.left+s.width)),bottom:Math.max(0,...e.map(s=>s.top+s.height))}}get shapes(){return this.make(this._name)}get shape_type(){return _e.GROUP}get name(){return this._name.split("/").pop()??this._name}set name(e){const t=this._name.lastIndexOf("/"),r=t<0?e:`${this._name.slice(0,t)}/${e}`;for(const s of this.members())s.group=`${r}${(s.group??"").slice(this._name.length)}`;this._name=r}get left(){return l(this.box().left)}set left(e){const t=e-this.box().left;for(const r of this.members())r.frame&&(r.frame.left+=t)}get top(){return l(this.box().top)}set top(e){const t=e-this.box().top;for(const r of this.members())r.frame&&(r.frame.top+=t)}get width(){const e=this.box();return l(e.right-e.left)}get height(){const e=this.box();return l(e.bottom-e.top)}}export class Cell{def;table;row;col;constructor(e,t,r,s){return this.def=e,this.table=t,this.row=r,this.col=s,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e})}get borders(){return this.def.borders??{}}set borders(e){this.def.borders=Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r,color:N(r.color,`A cell's ${t} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(e){this.def.text.margin_left=e}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(e){this.def.text.margin_right=e}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(e){this.def.text.margin_top=e}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(e){this.def.text.margin_bottom=e}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(e){e===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=e}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(e){const t=[this.row,e.row].sort((f,c)=>f-c),r=[this.col,e.col].sort((f,c)=>f-c),[s=0,n=0]=t,[o=0,h=0]=r;for(let f=s;f<=n;f++)for(let c=o;c<=h;c++){const u=this.table.rows[f]?.cells[c];u&&(f===s&&c===o?(h>o&&(u.span_width=h-o+1),n>s&&(u.span_height=n-s+1)):u.spanned=!0)}}split(){const e=this.span_width,t=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let r=this.row;r<this.row+t;r++)for(let s=this.col;s<this.col+e;s++){const n=this.table.rows[r]?.cells[s];n&&delete n.spanned}}}export class Column{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(e){this.def.columns[this.at]=e}}export class Row{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Row")}get row(){const e=this.def.rows[this.at];if(!e)throw new Error(`The table has no row ${String(this.at)}.`);return e}get height(){return l(this.row.height)}set height(e){this.row.height=e}}export class Table{def;constructor(e){return this.def=e,a(this,"Table")}cell(e,t){const r=this.def.rows[e]?.cells[t];if(!r)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(r,this.def,e,t)}*iter_cells(){for(let e=0;e<this.def.rows.length;e++)for(let t=0;t<this.def.columns.length;t++)yield this.cell(e,t)}get columns(){return this.def.columns.map((e,t)=>new Column(this.def,t))}get rows(){return this.def.rows.map((e,t)=>new Row(this.def,t))}get style(){return Z(this.def.style)?.name??null}set style(e){if(e===null){delete this.def.style;return}const t=Z(e)??refuse(`Table.style: ${e} is none of PowerPoint's built-in table styles (${$e.slice(0,3).map(r=>r.name).join(", ")}…).`);this.def.style=t.id}flag(e){return this.def[e]===!0}get first_row(){return this.flag("first_row")}set first_row(e){this.def.first_row=e}get first_col(){return this.flag("first_col")}set first_col(e){this.def.first_col=e}get last_row(){return this.flag("last_row")}set last_row(e){this.def.last_row=e}get last_col(){return this.flag("last_col")}set last_col(e){this.def.last_col=e}get horz_banding(){return this.flag("horz_banding")}set horz_banding(e){this.def.horz_banding=e}get vert_banding(){return this.flag("vert_banding")}set vert_banding(e){this.def.vert_banding=e}}function Fe(i,e,t=[]){const r=new Set([...i,...t].map(n=>n.name));let s=1;for(;r.has(`${e}-${String(s)}`);)s++;return`${e}-${String(s)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(e,t,r,s=()=>{},n=()=>[],o){return this.list=e,this.base=t,this.components=r,this.inherit=s,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}_at(e){const t=this.list[e];return t?this._wrap(t):void 0}*[Symbol.iterator](){for(const e of this.list)yield this._wrap(e)}get length(){return this.list.length}get(e){const t=this.list.find(r=>r.name===e);return t?this._wrap(t):void 0}get title(){const e=this.list.find(t=>t.placeholder?.type==="title"||t.placeholder?.type==="ctrTitle");return e?this._wrap(e):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(e,t){const r={name:Fe(this.list,e,this.under()),...t,...this.group===void 0?{}:{group:this.group}};return this.list.push(r),this._wrap(r)}add_textbox(e,t,r,s){return this._add("textbox",{kind:"textbox",frame:_(e,t,r,s),text:{...E(),...Se}})}add_picture(e,t,r,s,n){return(s===void 0||n===void 0)&&refuse("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(t,r,s??0,n??0),media:{path:e,base:this.base}})}add_movie(e,t,r,s,n,o={}){return this._add("movie",{kind:"movie",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time},...o.playback?{playback:{...o.playback}}:{}}})}add_audio(e,t,r,s=W.icon,n=W.icon,o={}){return this._add("audio",{kind:"audio",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.playback?{playback:{...o.playback}}:{}}})}add_shape(e,t,r,s,n){Pe.has(e)||refuse(`add_shape(): ${e} is not one of MSO_SHAPE's ${Object.keys(D).join(", ")}`);const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("shape",{kind:"autoshape",frame:_(t,r,s,n),geometry:e,fill:g.fill,line:g.line,line_width:g.line_width,text:o})}add_table(e,t,r,s,n,o){(e<1||t<1)&&refuse("add_table(): a table has at least a row and a column.");const h=Math.floor(n/t),f=Math.floor(o/e);return this._add("table",{kind:"table",frame:_(r,s,n,o),table:{style:Oe,first_row:!0,horz_banding:!0,columns:Array.from({length:t},()=>h),rows:Array.from({length:e},()=>({height:f,cells:Array.from({length:t},()=>({text:E()}))}))}})}add_chart(e,t,r,s,n,o){return this._add("chart",{kind:"chart",frame:_(t,r,s,n),chart:{type:e,categories:[...o.categories],series:o._series()}})}add_group_shape(){const e=this.group===void 0?"":`${this.group}/`;let t=1;for(;this.list.some(r=>I(r.group,`${e}group-${String(t)}`));)t++;return new GroupShape(this.list,`${e}group-${String(t)}`,r=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,r))}build_freeform(e=0,t=0,r=1){return new FreeformBuilder([e,t],r,(s,n)=>{const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:s,fill:g.fill,line:g.line,line_width:g.line_width,text:o})})}add_connector(e,t,r,s,n){M(e)||refuse(`add_connector(): ${e} is not one of MSO_CONNECTOR's ${Object.keys(he).join(", ")}, nor a connector's preset (${be.join(", ")})`);const o=_(Math.min(t,s),Math.min(r,n),Math.abs(s-t),Math.abs(n-r)),h=s<t,f=n<r;return this._add("connector",{kind:"autoshape",frame:o,geometry:e,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:Y.line,line_width:Y.line_width})}add_component(e,t,r,s,n,o={},h={}){if(!Object.hasOwn(this.components(),e))throw new Error(`add_component(): the presentation has no component ${e}; add it with prs.components.add("${e}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${e} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(e,{kind:"component",frame:_(t,r,s,n),component:{name:e,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(e,t=()=>{}){return this.list=e,this.inherit=t,a(this,"placeholders",{index:r=>this.get(r)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}*[Symbol.iterator](){for(const e of this.list)e.kind==="placeholder"&&(yield this._wrap(e))}get length(){return this.list.filter(e=>e.kind==="placeholder").length}get(e){const t=this.list.find(r=>r.kind==="placeholder"&&(typeof e=="number"?r.placeholder?.idx===e:r.name===e||r.placeholder?.type===e));return t?this._wrap(t):void 0}add(e,t,r,s,n,o={}){const h=typeof t=="object"?t:o,f=typeof t=="object"?void 0:t;Object.values(H).includes(e)||refuse(`placeholders.add(): ${e} is not one of PP_PLACEHOLDER's ${Object.keys(H).join(", ")}`);const c=this.list.filter(b=>b.kind==="placeholder"),u=new Set(c.map(b=>b.placeholder?.idx));let d=e==="title"||e==="ctrTitle"?0:ye[e]??1;for(u.has(d)&&d===0&&(d=1);u.has(d);)d++;const m=h.name??NAME_OF_TYPE[e];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,r,s,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const L={name:m,kind:"placeholder",placeholder:{type:e,idx:d,...h.orient==="vert"?{orient:"vert"}:{}},...y.length===4?{frame:_(f??0,r??0,s??0,n??0)}:{},text:{paragraphs:[],levels:Ee(e)}};return this.list.push(L),this._wrap(L)}}export class SlideLayout{def;master;ctx;constructor(e,t,r){return this.def=e,this.master=t,this.ctx=r,a(this,"SlideLayout")}get _def(){return this.def}inherit=e=>e.placeholder?X(this.master._def,e.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(e){e?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get color_map(){return this.def.color_map&&{...this.def.color_map}}set color_map(e){e===void 0?delete this.def.color_map:this.def.color_map=K(e)}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideLayouts",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(e,t){return this.list.find(r=>r.name===e)??t}index(e){const t=this.list.indexOf(e);if(t<0)throw new Error(`${e.name} is not among these layouts.`);return t}add(e,t){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const r=this.make(e);return t?.(r),r}}export class TextStyles{def;constructor(e){return this.def=e,a(this,"text_styles")}get title_style(){return k(this.def.title)}get body_style(){return k(this.def.body)}get other_style(){return k(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(e,t,r){return this.def=e,this.ctx=t,this.allLayouts=r,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get color_map(){return{...OFFICE_COLOR_MAP,...this.def.color_map}}set color_map(e){const t=K(e),r=Object.fromEntries(Object.entries(t).filter(([s,n])=>OFFICE_COLOR_MAP[s]!==n));Object.keys(r).length===0?delete this.def.color_map:this.def.color_map=r}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,e=>{if(this.allLayouts.some(s=>s.name===e))throw new Error(`Two layouts are "${e}": a layout's name is unique in the deck, as its slides file names it.`);const t={name:e,master:this.def.name,shapes:[]};this.def.layouts.push(t);const r=new SlideLayout(t,this,this.ctx);return this.layouts.push(r),this.allLayouts.push(r),r})}}export class SlideMasters{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideMasters",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(e){return this.list.indexOf(e)}add(e,t){const r=this.make(e);return t?.(r),r}}export class GeneratedSlide{own;def;layout;constructor(e,t,r){this.def=e,this.layout=t,this.own=t._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:E()}));const s=n=>{const o=t._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?X(t.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,r.base,r.components,s,()=>[...t.slide_master._def.shapes,...t._def.shapes]),this._placeholders=new Placeholders(this.own,s),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const e=this.def;return a({notes_text_frame:a({get text(){return e.notes??""},set text(t){e.notes=t}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(e){e===void 0?delete this.def.transition:this.def.transition=e}get animations(){return new Animations(this.def.animations??=[])}_done(){const e={},t=[];for(const r of this.own)r.kind==="placeholder"&&r.placeholder?(r.text?.paragraphs.some(s=>s.runs.length>0)&&(e[r.placeholder.idx]=r.text.paragraphs),r.frame&&t.push({...r,text:E()})):t.push(r);return{...this.def,shapes:t,text:e}}}export class Animations{list;constructor(e){return this.list=e,a(this,"Animations")}add(e,t,r={}){this.list.push({shape:typeof e=="string"?e:e.name,effect:t,...r})}get length(){return this.list.length}}class ze{gen;constructor(e){return this.gen=e,a(this,"slides")}add_slide(e,t){return this.gen._add(e,t)}}export class Generator{list=[];prs;ctx;constructor(e,t){return this.prs=e,this.ctx=t,a(this,"Generator")}data(e){return this.ctx.data(e)}get slides(){return new ze(this)}_add(e,t){const r=typeof e=="string"?this.prs._layout(e):e;if(!r)throw new Error(`add_slide(): the presentation has no layout ${typeof e=="string"?e:e.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(t))throw new Error(`add_slide(): ${t} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===t))throw new Error(`add_slide(): two slides are ${t}.`);const s=new GeneratedSlide({id:t,layout:r.name,shapes:[],text:{}},r,this.prs._ctx);return this.list.push(s),s}_made(){return this.list.map(e=>e._done())}}const Ie=()=>JSON.parse(JSON.stringify(xe));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(e,t){return this.def={slide_width:e[0],slide_height:e[1],masters:[],components:{},generators:{}},this._ctx={base:t,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(e){this.def.slide_width=e}get slide_height(){return l(this.def.slide_height)}set slide_height(e){this.def.slide_height=e}get slide_masters(){return new SlideMasters(this.masters,e=>{if(this.masters.some(s=>s.name===e))throw new Error(`Two masters are "${e}".`);const t={name:e,background:"bg1",text_styles:Ie(),shapes:[],layouts:[]};this.def.masters.push(t);const r=new SlideMaster(t,this._ctx,this.layouts);return this.masters.push(r),r})}get slide_master(){const e=this.masters[0];if(!e)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return e}get slide_layouts(){const e=this.masters[0];return e?e.slide_layouts:new SlideLayouts([])}get slides(){return refuse("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return refuse("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(e){this.def.theme=e}get components(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.components,e))throw new Error(`Two components are "${e}".`);const r=oe(e,t);if(!r)throw new Error(`Component ${e} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[e]=r}},"components")}get generators(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.generators,e))throw new Error(`Two generators are "${e}".`);this.def.generators[e]={name:e,make:r=>{const s=new Generator(this,r);return t(s),s._made()}}}},"generators")}_layout(e){return this.layouts.find(t=>t.name===e)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(e,t)=>{const[r,s]=typeof e=="function"?[{},e]:[e,t];if(typeof s!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(r.script!==void 0&&!r.script.includes("{locale}"))throw new Error(`presentation(): script ${r.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof r.size=="string"&&!Object.hasOwn(j,r.size))throw new Error(`presentation(): size ${r.size} is not one of ${Object.keys(j).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:r,build:s,written:{file:i}}};export function evaluateDeck(i){const e=i.options.size??"16:9",t=typeof e=="string"?j[e]:[e.width,e.height],r=i.written.file.split("/").slice(0,-1).join("/"),s=new Presentation(t,r);return i.options.theme&&(s.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(s),s._def}
4
+ `).map(t=>({runs:V(t),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(e=>new Paragraph(e))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const e={runs:[],level:0};return this.def.paragraphs.push(e),new Paragraph(e)}clear(){const e=this.def.paragraphs[0];this.def.paragraphs=e?[{...e,runs:[]}]:[]}fit_text(e,t=18,r,s){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(t*R),...e===void 0?{}:{name:e},...r===void 0?{}:{bold:r},...s===void 0?{}:{italic:s}}}get list_style(){return k(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(e){this._set("vertical_anchor",e)}get orientation(){return this.def.orientation}set orientation(e){if(e!==void 0&&!Object.values(G).includes(e))throw new Error(`orientation is one of MSO_TEXT_ORIENTATION's ${Object.values(G).join(", ")}, not ${e}.`);this._set("orientation",e)}get auto_size(){return this.def.auto_size}set auto_size(e){this._set("auto_size",e)}get word_wrap(){return this.def.word_wrap}set word_wrap(e){this._set("word_wrap",e)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(e){this.def.margin_left=e}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(e){this.def.margin_top=e}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(e){this.def.margin_right=e}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(e){this.def.margin_bottom=e}}export class FillFormat{read;write;start;shape;base;constructor(e,t,r="lt1",s,n=""){return this.read=e,this.write=t,this.start=r,this.shape=s,this.base=n,a(this,"FillFormat")}_only(e){if(this.shape)for(const t of["gradient","pattern","picture_fill"])t!==e&&Reflect.deleteProperty(this.shape,t)}solid(){const e=this.read();this._only("solid"),e==null&&this.write(this.start)}background(){this._only("solid"),this.write(null)}patterned(){const e=this._shape("a pattern");this._only("pattern"),e.pattern??={preset:"pct5",fg:O.fg,bg:O.bg}}get pattern(){return this._pattern().preset}set pattern(e){this._pattern().preset=p(ue,"MSO_PATTERN_TYPE","pattern",e)}_pattern(){const{pattern:e}=this._shape("a pattern");if(!e)throw new TypeError("This fill is no pattern: call fill.patterned() first.");return e}get back_color(){const e=this._pattern();return new ColorFormat(()=>e.bg,t=>{e.bg=t??O.bg})}picture(e,t={}){const r=this._shape("a picture");this._only("picture_fill"),r.picture_fill={path:e,base:this.base,...t.tile?{tile:{...B,...t.tile,align:p(pe,"TILE_ALIGNMENT","tile.align",t.tile.align??B.align)}}:{},...t.transparency===void 0?{}:{transparency:t.transparency}}}_shape(e){if(!this.shape)throw new TypeError(`Only a shape's fill has ${e}.`);return this.shape}gradient(){this._only("gradient"),this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_path(){return this._gradient().path??"linear"}set gradient_path(e){const t=this._gradient();e==="linear"?delete t.path:z.includes(e)?t.path=e:refuse(`gradient_path is "linear", ${z.map(r=>`"${r}"`).join(", ")}, not ${e}.`)}get gradient_focus(){return{...this._gradient().focus??{left:.5,top:.5,right:.5,bottom:.5}}}set gradient_focus(e){this._gradient().focus={...e}}get gradient_angle(){return this._gradient().angle}set gradient_angle(e){this._gradient().angle=e}get gradient_stops(){return this._gradient().stops.map(e=>new GradientStop(e))}set gradient_stops(e){if(e.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=e.map(t=>t instanceof GradientStop?GradientStop.defOf(t):{...t,color:N(t.color,"A gradient stop's colour")})}_gradient(){const{gradient:e}=this._shape("a gradient");if(!e)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return e}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);this._shape("a transparency").fill_transparency=e}get type(){if(this.shape?.picture_fill)return"picture";if(this.shape?.pattern)return"patterned";if(this.shape?.gradient)return"gradient";const e=this.read();return e===void 0?void 0:e===null?"background":"solid"}get fore_color(){const e=this.shape?.pattern;if(e)return new ColorFormat(()=>e.fg,r=>{e.fg=r??O.fg});const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,r=>{this.write(r??this.start)})}}export class GradientStop{stop;constructor(e){return this.stop=e,a(this,"GradientStop")}static defOf(e){return{...e.stop}}get color(){return new ColorFormat(()=>this.stop.color,e=>{e!==void 0&&(this.stop.color=e)})}get position(){return this.stop.at}set position(e){if(!(e>=0&&e<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(e)}.`);this.stop.at=e}get transparency(){return this.stop.transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);e===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=e}}export class ShadowFormat{def;inner;constructor(e,t=!1){return this.def=e,this.inner=t,a(this,"ShadowFormat")}_shadow(){return this.inner?(this.def.inner_shadow??={...me},this.def.inner_shadow):(this.def.shadow??={...U},this.def.shadow)}get visible(){return this.inner?this.def.inner_shadow!==void 0:this.def.shadow!==void 0&&this.def.shadow!==null}set visible(e){e?this._shadow():this.inner?Reflect.deleteProperty(this.def,"inner_shadow"):this.def.shadow=null}get inherit(){return this.def.shadow===void 0}set inherit(e){e?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(e){this._shadow().blur=e}get distance(){return l(this._shadow().distance)}set distance(e){this._shadow().distance=e}get angle(){return this._shadow().angle}set angle(e){this._shadow().angle=e}get transparency(){return this._shadow().transparency}set transparency(e){this._shadow().transparency=e}get color(){const e=this._shadow();return new ColorFormat(()=>e.color,t=>{e.color=t??U.color})}}export class GlowFormat{def;constructor(e){return this.def=e,a(this,"GlowFormat")}_glow(){return this.def.glow??={...v},this.def.glow}get visible(){return this.def.glow!==void 0}set visible(e){e?this._glow():Reflect.deleteProperty(this.def,"glow")}get radius(){return l(this.def.glow?.size??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"glow"):this._glow().size=e}get transparency(){return this._glow().transparency}set transparency(e){this._glow().transparency=e}get color(){const e=this._glow();return new ColorFormat(()=>e.color,t=>{e.color=t??v.color})}}export class SoftEdgeFormat{def;constructor(e){return this.def=e,a(this,"SoftEdgeFormat")}get radius(){return l(this.def.soft_edges??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"soft_edges"):this.def.soft_edges=e}}export class ReflectionFormat{def;constructor(e){return this.def=e,a(this,"ReflectionFormat")}_reflection(){return this.def.reflection??={...we},this.def.reflection}get visible(){return this.def.reflection!==void 0}set visible(e){e?this._reflection():Reflect.deleteProperty(this.def,"reflection")}get transparency(){return this._reflection().transparency}set transparency(e){this._reflection().transparency=e}get size(){return this._reflection().size}set size(e){this._reflection().size=e}get offset(){return l(this._reflection().distance)}set offset(e){this._reflection().distance=e}get blur(){return l(this._reflection().blur)}set blur(e){this._reflection().blur=e}}export class LineFormat{def;constructor(e){return this.def=e,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,e=>{this.def.line=e??null})}get fill(){return new FillFormat(()=>this.def.line,e=>{this.def.line=e},"dk1")}get width(){return l(this.def.line_width??0)}set width(e){this.def.line_width=e}get dash_style(){return this.def.line_dash??null}set dash_style(e){e===null?delete this.def.line_dash:this.def.line_dash=p(de,"MSO_LINE","dash_style",e)}get cap_type(){return this.def.line_cap??x.cap}set cap_type(e){const t=p(le,"MSO_LINE_CAP","cap_type",e);t===x.cap?delete this.def.line_cap:this.def.line_cap=t}get join_type(){return this.def.line_join??x.join}set join_type(e){const t=p(ce,"MSO_LINE_JOIN","join_type",e);t===x.join?delete this.def.line_join:this.def.line_join=t}get compound_type(){return this.def.line_compound??x.compound}set compound_type(e){const t=p(fe,"MSO_LINE_COMPOUND","compound_type",e);t===x.compound?delete this.def.line_compound:this.def.line_compound=t}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(e){this.def.line_begin=p(C,"MSO_ARROWHEAD","begin_arrow",e)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(e){this.def.line_end=p(C,"MSO_ARROWHEAD","end_arrow",e)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(e){this.def.line_begin_size={...this.def.line_begin_size,w:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_width",e)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(e){this.def.line_begin_size={...this.def.line_begin_size,len:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_length",e)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(e){this.def.line_end_size={...this.def.line_end_size,w:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_width",e)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(e){this.def.line_end_size={...this.def.line_end_size,len:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_length",e)}}}function p(i,e,t,r){if(Object.values(i).includes(r))return r;throw new Error(`${t}: ${String(r)} is not one of ${e}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(e){return this.holder=e,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,e=>{this.holder.background=e??"bg1"})}}export const adjustmentDefaults=i=>te(i).map(e=>e.value/1e5);export class Adjustments{def;constructor(e){return this.def=e,a(this,"Adjustments",{index:t=>this._values()[t],setIndex:(t,r)=>{this._set(t,Number(r))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(e,t){const r=this._values();if(e<0||e>=r.length)throw new RangeError(`adjustments[${String(e)}]: ${this.def.geometry??"this shape"} has ${String(r.length)}.`);if(!Number.isFinite(t))throw new Error(`adjustments[${String(e)}] = ${String(t)} is not a number.`);r[e]=t,this.def.adjustments=r}}const Ne={left:0,top:0,width:0,height:0};export class Shape{def;inherit;base;constructor(e,t=()=>{},r=""){return this.def=e,this.inherit=t,this.base=r,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??Ne}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(e){this.def.name=e}get shape_type(){return this.def.path?"freeform":this.def.kind==="audio"||this.def.kind==="item"?"movie":M(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new ge(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(e){this._own().left=e}get top(){return l(this._frame().top)}set top(e){this._own().top=e}get width(){return l(this._frame().width)}set width(e){this._own().width=e}get height(){return l(this._frame().height)}set height(e){this._own().height=e}get rotation(){return this.def.rotation??0}set rotation(e){if(!Number.isFinite(e))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const t=(Math.trunc(e*6e4)%216e5+216e5)%216e5/6e4;t===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=t}get flip_h(){return this.def.flip?.h===!0}set flip_h(e){this._flip("h",e)}get flip_v(){return this.def.flip?.v===!0}set flip_v(e){this._flip("v",e)}_flip(e,t){const r={...this.def.flip};t?r[e]=!0:Reflect.deleteProperty(r,e),Object.keys(r).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=r}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e},"lt1",this.def,this.base)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get inner_shadow(){return new ShadowFormat(this.def,!0)}get glow(){return new GlowFormat(this.def)}get soft_edge(){return new SoftEdgeFormat(this.def)}get reflection(){return new ReflectionFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(e){if(this.def.path||!M(this.def.geometry))throw new Error(`${this.def.name}.${e}: it is not a connector (add_connector makes one).`);return se(this._frame(),this.def.flip,this.def.rotation)}_move(e,t){const r=re(e,t,this.def.rotation);this.def.frame=r.frame,r.flip?this.def.flip=r.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(e){const[t,r]=this._ends("begin_x");this._move([e,t[1]],r)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(e){const[t,r]=this._ends("begin_y");this._move([t[0],e],r)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(e){const[t,r]=this._ends("end_x");this._move(t,[e,r[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(e){const[t,r]=this._ends("end_y");this._move(t,[r[0],e])}begin_connect(e,t){this._connect("begin",e,t)}end_connect(e,t){this._connect("end",e,t)}_connect(e,t,r){const s=`${e}_connect`,[n,o]=this._ends(s);if(!(t instanceof Shape))throw new Error(`${this.def.name}.${s}(): its shape is a Shape.`);const h=t._def,f={frame:t._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},c=ne(f).length;if(!Number.isInteger(r)||r<0||r>=c)throw new Error(`${this.def.name}.${s}(): ${h.name} has connection sites 0 to ${String(c-1)}; ${String(r)} is not one.`);const u=ie(f,r)??(e==="begin"?n:o);this.def.connect={...this.def.connect,[e]:{shape:h.name,site:r}},this._move(e==="begin"?u:n,e==="begin"?o:u)}}const Le=i=>typeof i=="number"&&Number.isFinite(i),_=(i,e,t,r)=>{for(const[s,n]of Object.entries({left:i,top:e,width:t,height:r}))if(!Le(n))throw new Error(`${s} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(t<0||r<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(e),width:Math.trunc(t),height:Math.trunc(r)}},Pe=new Set(Object.values(D));export class FreeformBuilder{steps;sx;sy;make;constructor(e,t,r){return this.steps=[{op:"move",x:e[0],y:e[1]}],[this.sx,this.sy]=typeof t=="number"?[t,t]:t,this.make=r,a(this,"FreeformBuilder")}add_line_segments(e,t=!0){for(const[r,s]of e)this.steps.push({op:"line",x:r,y:s});return t&&this.steps.push({op:"close"}),this}add_curve_segment(e,t,r,s,n,o){if(![e,t,r,s,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:e,y1:t,x2:r,y2:s,x:n,y:o}),this}move_to(e,t){return this.steps.push({op:"move",x:e,y:t}),this}convert_to_shape(e=0,t=0){this.steps.length<2&&refuse("convert_to_shape(): a freeform needs a segment.");const r=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),s=r.map(d=>d[0]),n=r.map(d=>d[1]),o=Math.min(...s),h=Math.min(...n),f=Math.max(...s)-o,c=Math.max(...n)-h;f===0&&c===0&&refuse("convert_to_shape(): a freeform's points are all one point.");const u=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:c,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...u(d.x,d.y)};const m=u(d.x1,d.y1),y=u(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...u(d.x,d.y)}})},_(Math.round(o*this.sx)+e,Math.round(h*this.sy)+t,Math.round(f*this.sx),Math.round(c*this.sy)))}}export class GroupShape{list;_name;make;constructor(e,t,r){return this.list=e,this._name=t,this.make=r,a(this,"GroupShape")}members(){return this.list.filter(e=>I(e.group,this._name))}box(){const e=this.members().flatMap(s=>s.frame?[s.frame]:[]),t=Math.min(...e.map(s=>s.left)),r=Math.min(...e.map(s=>s.top));return{left:e.length>0?t:0,top:e.length>0?r:0,right:Math.max(0,...e.map(s=>s.left+s.width)),bottom:Math.max(0,...e.map(s=>s.top+s.height))}}get shapes(){return this.make(this._name)}get shape_type(){return _e.GROUP}get name(){return this._name.split("/").pop()??this._name}set name(e){const t=this._name.lastIndexOf("/"),r=t<0?e:`${this._name.slice(0,t)}/${e}`;for(const s of this.members())s.group=`${r}${(s.group??"").slice(this._name.length)}`;this._name=r}get left(){return l(this.box().left)}set left(e){const t=e-this.box().left;for(const r of this.members())r.frame&&(r.frame.left+=t)}get top(){return l(this.box().top)}set top(e){const t=e-this.box().top;for(const r of this.members())r.frame&&(r.frame.top+=t)}get width(){const e=this.box();return l(e.right-e.left)}get height(){const e=this.box();return l(e.bottom-e.top)}}export class Cell{def;table;row;col;constructor(e,t,r,s){return this.def=e,this.table=t,this.row=r,this.col=s,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e})}get borders(){return this.def.borders??{}}set borders(e){this.def.borders=Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r,color:N(r.color,`A cell's ${t} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(e){this.def.text.margin_left=e}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(e){this.def.text.margin_right=e}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(e){this.def.text.margin_top=e}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(e){this.def.text.margin_bottom=e}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(e){e===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=e}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(e){const t=[this.row,e.row].sort((f,c)=>f-c),r=[this.col,e.col].sort((f,c)=>f-c),[s=0,n=0]=t,[o=0,h=0]=r;for(let f=s;f<=n;f++)for(let c=o;c<=h;c++){const u=this.table.rows[f]?.cells[c];u&&(f===s&&c===o?(h>o&&(u.span_width=h-o+1),n>s&&(u.span_height=n-s+1)):u.spanned=!0)}}split(){const e=this.span_width,t=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let r=this.row;r<this.row+t;r++)for(let s=this.col;s<this.col+e;s++){const n=this.table.rows[r]?.cells[s];n&&delete n.spanned}}}export class Column{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(e){this.def.columns[this.at]=e}}export class Row{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Row")}get row(){const e=this.def.rows[this.at];if(!e)throw new Error(`The table has no row ${String(this.at)}.`);return e}get height(){return l(this.row.height)}set height(e){this.row.height=e}}export class Table{def;constructor(e){return this.def=e,a(this,"Table")}cell(e,t){const r=this.def.rows[e]?.cells[t];if(!r)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(r,this.def,e,t)}*iter_cells(){for(let e=0;e<this.def.rows.length;e++)for(let t=0;t<this.def.columns.length;t++)yield this.cell(e,t)}get columns(){return this.def.columns.map((e,t)=>new Column(this.def,t))}get rows(){return this.def.rows.map((e,t)=>new Row(this.def,t))}get style(){return Z(this.def.style)?.name??null}set style(e){if(e===null){delete this.def.style;return}const t=Z(e)??refuse(`Table.style: ${e} is none of PowerPoint's built-in table styles (${$e.slice(0,3).map(r=>r.name).join(", ")}…).`);this.def.style=t.id}flag(e){return this.def[e]===!0}get first_row(){return this.flag("first_row")}set first_row(e){this.def.first_row=e}get first_col(){return this.flag("first_col")}set first_col(e){this.def.first_col=e}get last_row(){return this.flag("last_row")}set last_row(e){this.def.last_row=e}get last_col(){return this.flag("last_col")}set last_col(e){this.def.last_col=e}get horz_banding(){return this.flag("horz_banding")}set horz_banding(e){this.def.horz_banding=e}get vert_banding(){return this.flag("vert_banding")}set vert_banding(e){this.def.vert_banding=e}}function Fe(i,e,t=[]){const r=new Set([...i,...t].map(n=>n.name));let s=1;for(;r.has(`${e}-${String(s)}`);)s++;return`${e}-${String(s)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(e,t,r,s=()=>{},n=()=>[],o){return this.list=e,this.base=t,this.components=r,this.inherit=s,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}_at(e){const t=this.list[e];return t?this._wrap(t):void 0}*[Symbol.iterator](){for(const e of this.list)yield this._wrap(e)}get length(){return this.list.length}get(e){const t=this.list.find(r=>r.name===e);return t?this._wrap(t):void 0}get title(){const e=this.list.find(t=>t.placeholder?.type==="title"||t.placeholder?.type==="ctrTitle");return e?this._wrap(e):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(e,t){const r={name:Fe(this.list,e,this.under()),...t,...this.group===void 0?{}:{group:this.group}};return this.list.push(r),this._wrap(r)}add_textbox(e,t,r,s){return this._add("textbox",{kind:"textbox",frame:_(e,t,r,s),text:{...E(),...Se}})}add_picture(e,t,r,s,n){return(s===void 0||n===void 0)&&refuse("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(t,r,s??0,n??0),media:{path:e,base:this.base}})}add_movie(e,t,r,s,n,o={}){return this._add("movie",{kind:"movie",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time},...o.playback?{playback:{...o.playback}}:{}}})}add_audio(e,t,r,s=W.icon,n=W.icon,o={}){return this._add("audio",{kind:"audio",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.playback?{playback:{...o.playback}}:{}}})}add_shape(e,t,r,s,n){Pe.has(e)||refuse(`add_shape(): ${e} is not one of MSO_SHAPE's ${Object.keys(D).join(", ")}`);const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("shape",{kind:"autoshape",frame:_(t,r,s,n),geometry:e,fill:g.fill,line:g.line,line_width:g.line_width,text:o})}add_table(e,t,r,s,n,o){(e<1||t<1)&&refuse("add_table(): a table has at least a row and a column.");const h=Math.floor(n/t),f=Math.floor(o/e);return this._add("table",{kind:"table",frame:_(r,s,n,o),table:{style:Oe,first_row:!0,horz_banding:!0,columns:Array.from({length:t},()=>h),rows:Array.from({length:e},()=>({height:f,cells:Array.from({length:t},()=>({text:E()}))}))}})}add_chart(e,t,r,s,n,o){return this._add("chart",{kind:"chart",frame:_(t,r,s,n),chart:{type:e,categories:[...o.categories],series:o._series()}})}add_group_shape(){const e=this.group===void 0?"":`${this.group}/`;let t=1;for(;this.list.some(r=>I(r.group,`${e}group-${String(t)}`));)t++;return new GroupShape(this.list,`${e}group-${String(t)}`,r=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,r))}build_freeform(e=0,t=0,r=1){return new FreeformBuilder([e,t],r,(s,n)=>{const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:s,fill:g.fill,line:g.line,line_width:g.line_width,text:o})})}add_connector(e,t,r,s,n){M(e)||refuse(`add_connector(): ${e} is not one of MSO_CONNECTOR's ${Object.keys(he).join(", ")}, nor a connector's preset (${be.join(", ")})`);const o=_(Math.min(t,s),Math.min(r,n),Math.abs(s-t),Math.abs(n-r)),h=s<t,f=n<r;return this._add("connector",{kind:"autoshape",frame:o,geometry:e,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:Y.line,line_width:Y.line_width})}add_component(e,t,r,s,n,o={},h={}){if(!Object.hasOwn(this.components(),e))throw new Error(`add_component(): the presentation has no component ${e}; add it with prs.components.add("${e}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${e} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(e,{kind:"component",frame:_(t,r,s,n),component:{name:e,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(e,t=()=>{}){return this.list=e,this.inherit=t,a(this,"placeholders",{index:r=>this.get(r)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}*[Symbol.iterator](){for(const e of this.list)e.kind==="placeholder"&&(yield this._wrap(e))}get length(){return this.list.filter(e=>e.kind==="placeholder").length}get(e){const t=this.list.find(r=>r.kind==="placeholder"&&(typeof e=="number"?r.placeholder?.idx===e:r.name===e||r.placeholder?.type===e));return t?this._wrap(t):void 0}add(e,t,r,s,n,o={}){const h=typeof t=="object"?t:o,f=typeof t=="object"?void 0:t;Object.values(H).includes(e)||refuse(`placeholders.add(): ${e} is not one of PP_PLACEHOLDER's ${Object.keys(H).join(", ")}`);const c=this.list.filter(b=>b.kind==="placeholder"),u=new Set(c.map(b=>b.placeholder?.idx));let d=e==="title"||e==="ctrTitle"?0:ye[e]??1;for(u.has(d)&&d===0&&(d=1);u.has(d);)d++;const m=h.name??NAME_OF_TYPE[e];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,r,s,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const L={name:m,kind:"placeholder",placeholder:{type:e,idx:d,...h.orient==="vert"?{orient:"vert"}:{}},...y.length===4?{frame:_(f??0,r??0,s??0,n??0)}:{},text:{paragraphs:[],levels:Ee(e)}};return this.list.push(L),this._wrap(L)}}export class SlideLayout{def;master;ctx;constructor(e,t,r){return this.def=e,this.master=t,this.ctx=r,a(this,"SlideLayout")}get _def(){return this.def}inherit=e=>e.placeholder?X(this.master._def,e.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(e){e?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get color_map(){return this.def.color_map&&{...this.def.color_map}}set color_map(e){e===void 0?delete this.def.color_map:this.def.color_map=K(e)}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideLayouts",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(e,t){return this.list.find(r=>r.name===e)??t}index(e){const t=this.list.indexOf(e);if(t<0)throw new Error(`${e.name} is not among these layouts.`);return t}add(e,t){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const r=this.make(e);return t?.(r),r}}export class TextStyles{def;constructor(e){return this.def=e,a(this,"text_styles")}get title_style(){return k(this.def.title)}get body_style(){return k(this.def.body)}get other_style(){return k(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(e,t,r){return this.def=e,this.ctx=t,this.allLayouts=r,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get color_map(){return{...OFFICE_COLOR_MAP,...this.def.color_map}}set color_map(e){const t=K(e),r=Object.fromEntries(Object.entries(t).filter(([s,n])=>OFFICE_COLOR_MAP[s]!==n));Object.keys(r).length===0?delete this.def.color_map:this.def.color_map=r}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,e=>{if(this.allLayouts.some(s=>s.name===e))throw new Error(`Two layouts are "${e}": a layout's name is unique in the deck, as its slides file names it.`);const t={name:e,master:this.def.name,shapes:[]};this.def.layouts.push(t);const r=new SlideLayout(t,this,this.ctx);return this.layouts.push(r),this.allLayouts.push(r),r})}}export class SlideMasters{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideMasters",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(e){return this.list.indexOf(e)}add(e,t){const r=this.make(e);return t?.(r),r}}export class GeneratedSlide{own;def;layout;constructor(e,t,r){this.def=e,this.layout=t,this.own=t._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:E()}));const s=n=>{const o=t._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?X(t.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,r.base,r.components,s,()=>[...t.slide_master._def.shapes,...t._def.shapes]),this._placeholders=new Placeholders(this.own,s),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const e=this.def;return a({notes_text_frame:a({get text(){return e.notes??""},set text(t){e.notes=t}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(e){e===void 0?delete this.def.transition:this.def.transition=e}get animations(){return new Animations(this.def.animations??=[])}_done(){const e={},t=[];for(const r of this.own)r.kind==="placeholder"&&r.placeholder?(r.text?.paragraphs.some(s=>s.runs.length>0)&&(e[r.placeholder.idx]=r.text.paragraphs),r.frame&&t.push({...r,text:E()})):t.push(r);return{...this.def,shapes:t,text:e}}}export class Animations{list;constructor(e){return this.list=e,a(this,"Animations")}add(e,t,r={}){this.list.push({shape:typeof e=="string"?e:e.name,effect:t,...r})}get length(){return this.list.length}}class ze{gen;constructor(e){return this.gen=e,a(this,"slides")}add_slide(e,t){return this.gen._add(e,t)}}export class Generator{list=[];prs;ctx;constructor(e,t){return this.prs=e,this.ctx=t,a(this,"Generator")}data(e){return this.ctx.data(e)}get slides(){return new ze(this)}_add(e,t){const r=typeof e=="string"?this.prs._layout(e):e;if(!r)throw new Error(`add_slide(): the presentation has no layout ${typeof e=="string"?e:e.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(t))throw new Error(`add_slide(): ${t} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===t))throw new Error(`add_slide(): two slides are ${t}.`);const s=new GeneratedSlide({id:t,layout:r.name,shapes:[],text:{}},r,this.prs._ctx);return this.list.push(s),s}_made(){return this.list.map(e=>e._done())}}const Ie=()=>JSON.parse(JSON.stringify(xe));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(e,t){return this.def={slide_width:e[0],slide_height:e[1],masters:[],components:{},generators:{}},this._ctx={base:t,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(e){this.def.slide_width=e}get slide_height(){return l(this.def.slide_height)}set slide_height(e){this.def.slide_height=e}get slide_masters(){return new SlideMasters(this.masters,e=>{if(this.masters.some(s=>s.name===e))throw new Error(`Two masters are "${e}".`);const t={name:e,background:"bg1",text_styles:Ie(),shapes:[],layouts:[]};this.def.masters.push(t);const r=new SlideMaster(t,this._ctx,this.layouts);return this.masters.push(r),r})}get slide_master(){const e=this.masters[0];if(!e)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return e}get slide_layouts(){const e=this.masters[0];return e?e.slide_layouts:new SlideLayouts([])}get slides(){return refuse("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return refuse("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(e){this.def.theme=e}get components(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.components,e))throw new Error(`Two components are "${e}".`);const r=oe(e,t);if(!r)throw new Error(`Component ${e} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[e]=r}},"components")}get generators(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.generators,e))throw new Error(`Two generators are "${e}".`);this.def.generators[e]={name:e,make:r=>{const s=new Generator(this,r);return t(s),s._made()}}}},"generators")}_layout(e){return this.layouts.find(t=>t.name===e)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(e,t)=>{const[r,s]=typeof e=="function"?[{},e]:[e,t];if(typeof s!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(r.script!==void 0&&!r.script.includes("{locale}"))throw new Error(`presentation(): script ${r.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof r.size=="string"&&!Object.hasOwn(j,r.size))throw new Error(`presentation(): size ${r.size} is not one of ${Object.keys(j).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:r,build:s,written:{file:i}}};export function evaluateDeck(i){const e=i.options.size??"16:9",t=typeof e=="string"?j[e]:[e.width,e.height],r=i.written.file.split("/").slice(0,-1).join("/"),s=new Presentation(t,r);return i.options.theme&&(s.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(s),s._def}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{clockOf as a}from"./animation.js";export function componentTime(t,n,r){const o=a(t,r);return Math.max(0,(o.rests.at(-1)??0)-o.comesOn(n))}export function componentAt(t,n,r){if(t.component)return{name:t.component.name,props:t.component.props,width:Math.max(1,Math.round(t.frame.width*n)),height:Math.max(1,Math.round(t.frame.height*n)),t:r}}export function deckComponentAt(t,n){const r=t.width>0?n/t.width:0,o=new Map(t.slides.map(e=>[e.id,e])),i=t.slides[0]?.id;return(e,m)=>{const c=o.get(e);return c&&m.component?componentAt(m,r,componentTime(c,m.name,e===i)):void 0}}export function deckComponents(t,n){const r=deckComponentAt(t,n);return t.slides.flatMap(o=>o.shapes.flatMap(i=>{const e=r(o.id,i);return e?[{slide:o.id,shape:i.name,at:e}]:[]}))}
2
+ import{clockOf as c}from"./animation.js";export function componentTime(t,n,i){const o=c(t,i);return Math.max(0,(o.rests.at(-1)??0)-o.comesOn(n))}export function componentAt(t,n,i){if(t.kind==="item"&&t.item)return{name:`/${t.item.path}`,props:{},width:Math.max(1,Math.round(t.frame.width*n)),height:Math.max(1,Math.round(t.frame.height*n)),t:t.item.playback?.trim?.start??0};if(t.component)return{name:t.component.name,props:t.component.props,width:Math.max(1,Math.round(t.frame.width*n)),height:Math.max(1,Math.round(t.frame.height*n)),t:i}}export function deckComponentAt(t,n){const i=t.width>0?n/t.width:0,o=new Map(t.slides.map(r=>[r.id,r])),e=t.slides[0]?.id;return(r,m)=>{const a=o.get(r);return a&&(m.component||m.kind==="item")?componentAt(m,i,componentTime(a,m.name,r===e)):void 0}}export function deckComponents(t,n){const i=deckComponentAt(t,n);return t.slides.flatMap(o=>o.shapes.flatMap(e=>{const r=i(o.id,e);return r?[{slide:o.id,shape:e.name,at:r}]:[]}))}
@@ -99,7 +99,7 @@ export interface TextFrameDef {
99
99
  /** Which way its text runs (`a:bodyPr/@vert`): across, turned, East Asian vertical, stacked. */
100
100
  orientation?: TextOrientation;
101
101
  }
102
- export type ShapeKind = "placeholder" | "textbox" | "picture" | "movie" | "audio" | "autoshape" | "table" | "chart" | "component";
102
+ export type ShapeKind = "placeholder" | "textbox" | "picture" | "movie" | "audio" | "autoshape" | "table" | "chart" | "component" | "item";
103
103
  /** A table cell's edge (`a:lnL`, `a:lnR`, `a:lnT`, `a:lnB`). */
104
104
  export interface CellBorder {
105
105
  color: Color;
@@ -398,5 +398,7 @@ export interface DrawnDeck<Slide = unknown, DeckTheme = unknown> {
398
398
  fitted: Record<string, number>;
399
399
  /** The deck's language, its combo's. */
400
400
  lang?: string;
401
+ /** The seconds of each item its slides draw live, by its entry (docs/design/references.md). */
402
+ items?: Record<string, number>;
401
403
  }
402
404
  //# sourceMappingURL=model.d.ts.map
@@ -133,6 +133,11 @@ export interface ResolvedShape {
133
133
  props: Record<string, unknown>;
134
134
  dur?: number;
135
135
  };
136
+ /** Another item drawn live (docs/design/references.md): its entry, a project path, and how it plays. */
137
+ item?: {
138
+ path: string;
139
+ playback?: PlaybackDef;
140
+ };
136
141
  /** What the slides file set on its text (`text`), over what it inherits: a placeholder's own. */
137
142
  fileText?: NonNullable<ShapeFile["text"]>;
138
143
  sources: {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{CAPS as ze,colorOfFile as de,groupLevels as Ae,SHOW_JUMPS as Te,showJumpOf as je,slideLinkOf as Ee,UNDERLINES as Fe}from"@allyhub/formats";import{readMarks as Ne,markRuns as Le}from"@allyhub/piece";import{chartOfFile as Me}from"@allyhub/chart";import{AUTOSHAPE_STYLE as R,SHADOW_DEFAULTS as I,PATTERN_DEFAULTS as se,TILE_DEFAULTS as W,INNER_SHADOW_DEFAULTS as H,GLOW_DEFAULTS as q,REFLECTION_DEFAULTS as X,CONNECTOR_STYLE as fe,DRAWN_TEXTBOX_FRAME as ce,TEXT_FALLBACK as ue,TEXT_INSETS as B,isConnectorGeometry as Ce,placeholderFrame as Pe,styleKindOf as Re}from"./office.js";import{resolveAnimation as De,resolveTransition as Ue,unitsAcross as Ie,EFFECT_OPTIONS as We,TRANSITION_OPTIONS as He}from"./animation.js";import{glued as Ge}from"./connect.js";import{pathSteps as Xe}from"./path.js";import{CHART_AXIS_WORDS as Be}from"./script.js";import{cellLook as Ke,tableStyleOf as Q}from"./table-style.js";import{masterPlaceholder as Je}from"./placeholders.js";import{DECK_FONTS as Ye,OFFICE_THEME as Ve,themeOver as Ze}from"./theme.js";import{Pt as S}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const l=[];for(const r of[...i.split("/"),...t.split("/")])r===""||r==="."||(r===".."?l.pop():l.push(r));return l.join("/")}const pe={left:0,top:0,width:0,height:0};function qe(i,t){const l={...i.color_map,...t.color_map};return Object.keys(l).length>0?{color_map:l}:{}}const K=()=>Array.from({length:9},()=>({...ue,font:{...ue.font},margin_left:0}));export function levelsOver(i,...t){return i.map((l,r)=>{let o={...l,font:{...l.font}};for(const y of t){const a=y?.[r];a&&(o={...o,...a.alignment===void 0?{}:{alignment:a.alignment},...a.line_spacing===void 0?{}:{line_spacing:a.line_spacing},...a.space_before===void 0?{}:{space_before:a.space_before},...a.space_after===void 0?{}:{space_after:a.space_after},...a.margin_left===void 0?{}:{margin_left:a.margin_left},...a.indent===void 0?{}:{indent:a.indent},font:{...o.font,...a.font}},a.numbered!==void 0&&(o.numbered=a.numbered,delete o.bullet),a.bullet===null?(delete o.bullet,delete o.numbered):a.bullet!==void 0?(delete o.numbered,o.bullet={char:a.bullet,...a.bullet_font===void 0?{}:{font:a.bullet_font}}):a.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:a.bullet_font}),o=bulletLookOver(o,a))}return o})}export function bulletLookOver(i,t){const l={...i};return t.bullet_color===null?delete l.bullet_color:t.bullet_color!==void 0&&(l.bullet_color=t.bullet_color),t.bullet_size===null?delete l.bullet_size:t.bullet_size!==void 0&&(l.bullet_size=t.bullet_size),t.start_at!==void 0&&(l.start_at=t.start_at),l}function ee(i,...t){const l=t.filter(o=>o!==void 0),r=o=>{for(let y=l.length-1;y>=0;y--){const a=l[y]?.[o];if(a!==void 0)return a}};return{vertical_anchor:r("vertical_anchor")??i.vertical_anchor,orientation:r("orientation")??"horz",auto_size:r("auto_size")??i.auto_size,word_wrap:r("word_wrap")??i.word_wrap,margins:{left:r("margin_left")??B.left,top:r("margin_top")??B.top,right:r("margin_right")??B.right,bottom:r("margin_bottom")??B.bottom}}}const he={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(K(),i.text_styles.other);function ne(i,t){return{...ee(he,t),levels:levelsOver(K(),i.text_styles.other,t.levels)}}function Qe(i,t,...l){return{...ee(Pe(t),...l),levels:levelsOver(K(),i.text_styles[Re(t)],...l.map(r=>r?.levels))}}const en=Array.from({length:9},()=>({font:{color:R.font_color}})),me={vertical_anchor:R.vertical_anchor};function _e(i,t){return{...ee(he,t),levels:levelsOver(K(),i.text_styles.other,en,t.levels)}}const J=i=>{const t={...i};return delete t.paragraphs,t},Y=i=>({paragraphs:[],levels:[],...i}),C=i=>i==="none"?null:colorOfFile(i),nn=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,tn=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="([^"\n]*)"/gu,V=57344,on=256,ge="",rn=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const spaceOfFile=i=>typeof i=="number"?S(i):{lines:i.lines},colorOfFile=i=>de(i)??"dk1";function te(i){const{shadow:t,gradient:l,inner_shadow:r,glow:o,reflection:y}=i;return{...r?{inner_shadow:{color:r.color===void 0?H.color:colorOfFile(r.color),blur:r.blur===void 0?H.blur:S(r.blur),distance:r.distance===void 0?H.distance:S(r.distance),angle:r.angle??H.angle,transparency:r.transparency??H.transparency}}:{},...o?{glow:{color:o.color===void 0?q.color:colorOfFile(o.color),size:o.size===void 0?q.size:S(o.size),transparency:o.transparency??q.transparency}}:{},...i.soft_edges===void 0?{}:{soft_edges:S(i.soft_edges)},...y?{reflection:{transparency:y.transparency??X.transparency,size:y.size??X.size,distance:y.distance===void 0?X.distance:S(y.distance),blur:y.blur===void 0?X.blur:S(y.blur)}}:{},...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...l?{gradient:{angle:l.angle??0,...l.path===void 0?{}:{path:l.path},...l.focus===void 0?{}:{focus:{left:l.focus.left??.5,top:l.focus.top??.5,right:l.focus.right??.5,bottom:l.focus.bottom??.5}},stops:l.stops.map(a=>({at:a.at,color:colorOfFile(a.color),...a.transparency===void 0?{}:{transparency:a.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?I.color:colorOfFile(t.color),blur:t.blur===void 0?I.blur:S(t.blur),distance:t.distance===void 0?I.distance:S(t.distance),angle:t.angle??I.angle,transparency:t.transparency??I.transparency}}:{}}}const an=i=>({...i.tile?{tile:{...i.tile}}:{},...i.transparency===void 0?{}:{transparency:i.transparency}});function be(i,t){const{pattern:l,picture_fill:r}=i;return{...l?{pattern:{preset:l.preset,fg:colorOfFile(l.fg??se.fg),bg:colorOfFile(l.bg??se.bg)}}:{},...r?{picture_fill:{path:joinPath(t,r.path),...r.tile?{tile:{scale_x:r.tile.scale_x??W.scale_x,scale_y:r.tile.scale_y??W.scale_y,offset_x:r.tile.x===void 0?W.offset_x:S(r.tile.x),offset_y:r.tile.y===void 0?W.offset_y:S(r.tile.y),align:r.tile.align??W.align}}:{},...r.transparency===void 0?{}:{transparency:r.transparency}}}:{}}}function ye(i,t,l=[]){const r=Q(i.style);return{...i,rows:i.rows.map((o,y)=>({height:o.height,cells:o.cells.map((a,E)=>{const N=l[y],v=r?Ke(r,i,y,E,i.rows.length,i.columns.length,y+(a.span_height??1)-1,E+(a.span_width??1)-1):void 0,F=ne(t,a.text),L=v&&(v.bold!==void 0||v.text!==void 0)?{...F,levels:F.levels.map(P=>({...P,font:{...P.font,...v.bold===void 0?{}:{bold:v.bold},...v.text===void 0?{}:{color:v.text}}}))}:F;return{...a,text:{paragraphs:a.text.paragraphs,style:Z({...L,auto_size:"shape"},N),own:J(a.text),empty:!1},...N?{fileText:N}:{}}})}))}}function Z(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},...t.orientation===void 0?{}:{orientation:t.orientation},levels:i.levels.map(l=>{const r={...l.font,...t.size===void 0?{}:{size:S(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.caps===void 0?{}:{caps:t.caps},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(r.color=colorOfFile(t.color));const o={...l,font:r,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:spaceOfFile(t.space_before)},...t.space_after===void 0?{}:{space_after:spaceOfFile(t.space_after)}};return t.bullet_color!==void 0&&(o.bullet_color=colorOfFile(t.bullet_color)),t.bullet_size!==void 0&&(o.bullet_size=t.bullet_size),t.start_at!==void 0&&(o.start_at=t.start_at),t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&l.margin_left===0?{...o,margin_left:$e,indent:-$e}:o})}:i}function ln(i,t){if(!t)return[...i];const l=t.numbered!==void 0||t.bullet!==void 0;return i.map(r=>{const o={...r};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,t.bullet_color!==void 0&&delete o.bullet_color,t.bullet_size!==void 0&&delete o.bullet_size,t.start_at!==void 0&&delete o.start_at,l&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}const dn=i=>Fe.includes(i),sn=i=>ze.includes(i);function fn(i){const t={};for(const[,l,r=""]of i.matchAll(tn))if(l==="font")t.name=r.trim();else if(l==="link")t.link=r.trim();else if(l==="highlight")t.highlight=r.trim().toUpperCase();else if(l==="bold")t.bold=r.trim()!=="false";else if(l==="italic")t.italic=r.trim()!=="false";else if(l==="strike"){const o=r.trim();t.strike=o==="dblStrike"?o:o!=="false"}else if(l==="underline"){const o=r.trim();t.underline=dn(o)&&o!=="sng"?o:o!=="false"}else if(l==="caps"){const o=r.trim();sn(o)&&(t.caps=o)}else if(l==="size"){const o=Number(r);Number.isFinite(o)&&o>0&&(t.size=S(o))}else if(l==="baseline"){const o=Number(r);Number.isFinite(o)&&(t.baseline=o)}else if(l==="spacing"){const o=Number(r);Number.isFinite(o)&&(t.spacing=S(o))}else{const o=de(r.trim());o!==void 0&&(t.color=o)}return t}const $e=342900;export function paragraphsOfWords(i,t=0,l=Ye.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(r=>{const o=[],y=r.replace(nn,(v,F,L)=>(o.push(fn(F)),`${String.fromCharCode(V+o.length-1)}${L}${ge}`)),a=Ne(y);let E;const N=Le(a.text,a.marks).flatMap(v=>{const F=v.kinds.includes("code"),L={...v.kinds.includes("strong")?{bold:!0}:{},...v.kinds.includes("em")?{italic:!0}:{},...F?{name:l}:{}};return[...v.text.matchAll(rn)].flatMap(P=>{const D=P[0],U=D.charCodeAt(0);if(D===ge)return E=void 0,[];if(U>=V&&U<V+on)return E=o[U-V],[];const G={...E,...L};return[{text:D,...Object.keys(G).length>0?{font:G}:{},...F?{code:!0}:{}}]})});return{runs:N.length>0?N:[{text:""}],level:t}}):i.flatMap(r=>paragraphsOfWords(r,Array.isArray(r)?Math.min(t+1,8):t,l))}const ke=i=>({left:S(i.x),top:S(i.y),width:S(i.w),height:S(i.h)}),cn=new Set(["dt","ftr","sldNum"]),we=i=>({...i.locked?{locked:!0}:{},...i.link===void 0?{}:{link:i.link},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function xe(i,t,l){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const r=t.gradient&&te({gradient:t.gradient}).gradient;r&&(i.background_gradient=r),t.picture!==void 0&&(i.background_picture=joinPath(l,t.picture))}const un=i=>{const t=Q(i.style);return{...t?{style:t.id}:{},...i.first_row===void 0?{}:{first_row:i.first_row},...i.last_row===void 0?{}:{last_row:i.last_row},...i.first_col===void 0?{}:{first_col:i.first_col},...i.last_col===void 0?{}:{last_col:i.last_col},...i.horz_banding===void 0?{}:{horz_banding:i.horz_banding},...i.vert_banding===void 0?{}:{vert_banding:i.vert_banding}}},Se=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:l,words:r,prefix:o,base:y}=i,a=[],E=Ze(i.theme??Ve,t.theme),N=new Map;for(const e of t.masters)for(const n of e.layouts)N.set(n.name,{layout:n,master:e});const v=[],F=(e,n,s)=>{const h=He[n.type];return n.direction!==void 0&&!h.directions.includes(n.direction)&&a.push({slide:e,path:`${s}.transition.direction`,message:h.directions.length===0?`A ${n.type} transition has no direction (${n.direction}).`:`A ${n.type} transition goes ${h.directions.join(", ")}, not ${n.direction}.`}),n.through_black===!0&&!h.throughBlack&&a.push({slide:e,path:`${s}.transition.through_black`,message:`A ${n.type} transition does not go through black: only a fade, a cut and a reveal do.`}),Ue(n)},L=(e,n,s)=>({name:e.name,kind:e.kind,frame:{...e.frame??pe},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?_e(s,e.text):ne(s,e.text),own:J(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.pattern?{pattern:e.pattern}:{},...e.picture_fill?{picture_fill:{...an(e.picture_fill),path:joinPath(e.picture_fill.base,e.picture_fill.path)}}:{},...e.shadow===void 0?{}:{shadow:e.shadow},...e.inner_shadow?{inner_shadow:e.inner_shadow}:{},...e.glow?{glow:e.glow}:{},...e.soft_edges===void 0?{}:{soft_edges:e.soft_edges},...e.reflection?{reflection:e.reflection}:{},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_cap===void 0?{}:{line_cap:e.line_cap},...e.line_join===void 0?{}:{line_join:e.line_join},...e.line_compound===void 0?{}:{line_compound:e.line_compound},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size},...e.path?{path:e.path}:{},...e.table?{table:ye(e.table,s)}:{},...e.chart?{chart:e.chart}:{},...e.link===void 0?{}:{link:e.link},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster},...e.media.playback?{playback:e.media.playback}:{}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),P=(e,n)=>{const s=e.placeholder?.type??"body",h=Je(n,s),g=e.frame??h?.frame??pe;return{name:e.name,kind:"placeholder",frame:{...g},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:Qe(n,s,h?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!h?"layout":"master"},text:{from:"layout"}}}},D=(e,n,s,h)=>{const g=t.components[e];if(!g){a.push({...s,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const $ of Object.keys(n??{}))Object.hasOwn(g.props,$)||a.push({...s,message:`Component ${e} has no prop ${$} a person sets (it has ${Object.keys(g.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...h===void 0?{}:{dur:h}}},U=(e,n,s,h,g)=>{const $={slide:h,shape:e,path:s};if(!n.frame){a.push({...$,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const T=ke(n.frame),u={frame:{from:"slide",path:`${s}.frame`}},x={name:e,frame:T,level:"slide",...n.fill===void 0?{}:{fill:C(n.fill)},...te(n),...be(n,y),...n.line===void 0?{}:{line:C(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_cap===void 0?{}:{line_cap:n.line_cap},...n.line_join===void 0?{}:{line_join:n.line_join},...n.line_compound===void 0?{}:{line_compound:n.line_compound},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.line_begin_size===void 0?{}:{line_begin_size:n.line_begin_size},...n.line_end_size===void 0?{}:{line_end_size:n.line_end_size},...n.group===void 0?{}:{group:n.group},...we(n)};if(n.textbox)return{...x,kind:"textbox",text:{paragraphs:paragraphsOfWords(r(`${o}.${h}.${e}`),0,E.fonts.code),style:Z(ne(g,Y(ce)),n.text),own:J(Y(ce)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...u,text:{from:"slide",path:`${s}.text`}}};if(n.picture!==void 0){const p=Se(n.crop);return{...x,kind:"picture",media:{path:joinPath(y,n.picture),...p?{crop:p}:{}},sources:{...u,media:{from:"slide",path:`${s}.picture`}}}}if(n.movie!==void 0)return{...x,kind:"movie",media:{path:joinPath(y,n.movie),...n.poster===void 0?{}:{poster:n.poster},...n.playback?{playback:n.playback}:{}},sources:{...u,media:{from:"slide",path:`${s}.movie`}}};if(n.audio!==void 0)return{...x,kind:"audio",media:{path:joinPath(y,n.audio),...n.playback?{playback:n.playback}:{}},sources:{...u,media:{from:"slide",path:`${s}.audio`}}};if(n.chart){const p=`${o}.${h}.${e}`,j=c=>typeof c=="string"?c:void 0,w=Object.fromEntries(Be.flatMap(c=>{const d=j(r(`${p}.${c}`));return d===void 0?[]:[[c,d]]})),O=Me(n.chart,{title:j(r(p))??j(r(`${p}.title`)),axisTitles:w,base:y,rows:c=>i.data?.(c),problem:c=>{a.push({...$,message:`Chart ${e}: ${c}`})}});return O?{...x,kind:"chart",chart:O,sources:u}:void 0}if(n.table){const p=n.table;p.style!==void 0&&!Q(p.style)&&a.push({...$,message:`Table ${e}'s style ${p.style} is none of PowerPoint's built-in table styles: name one as its gallery does (Medium Style 2 - Accent 1, Light Style 1, No Style, Table Grid) or by its id.`});const j=T.width/p.columns.reduce((f,m)=>f+m,0),w=T.height/p.rows.reduce((f,m)=>f+m.height,0),O=r(`${o}.${h}.${e}`),c=Array.isArray(O)?O:[],d=new Map;for(const f of p.merged??[]){const m=f.rows??1,_=f.columns??1;for(let k=f.row;k<f.row+m;k++)for(let z=f.column;z<f.column+_;z++)d.set(`${String(k)},${String(z)}`,"under");d.set(`${String(f.row)},${String(f.column)}`,{w:_,h:m})}return c.length>p.rows.length&&a.push({...$,message:`Table ${e} has ${String(p.rows.length)} rows and its words ${String(c.length)}.`}),{...x,kind:"table",table:ye({...un(p),columns:p.columns.map(f=>Math.round(f*j)),rows:p.rows.map((f,m)=>{const _=c[m],k=Array.isArray(_)?_:_===void 0?[]:[_];return{height:Math.round(f.height*w),cells:p.columns.map((z,M)=>{const A=d.get(`${String(m)},${String(M)}`);return{text:{levels:[],paragraphs:A==="under"?[]:paragraphsOfWords(k[M],0,E.fonts.code)},...A==="under"?{spanned:!0}:{},...A!==void 0&&A!=="under"&&A.w>1?{span_width:A.w}:{},...A!==void 0&&A!=="under"&&A.h>1?{span_height:A.h}:{},...f.fill===void 0?{}:{fill:colorOfFile(f.fill)},...f.line===void 0?{}:{borders:{bottom:{color:colorOfFile(f.line),width:S(1)}}}}})}})},g,p.rows.map(f=>f.text)),sources:u}}const b=n.path&&Xe(n.path.d);if(n.path&&!b){a.push({...$,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&b){const p=!n.path&&Ce(n.geometry);return{...x,kind:"autoshape",...n.path&&b?{path:{w:n.path.w,h:n.path.h,steps:b}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...p?{line:n.line===void 0?fe.line:C(n.line),line_width:n.line_width===void 0?fe.line_width:S(n.line_width)}:{fill:n.fill===void 0?R.fill:C(n.fill),line:n.line===void 0?R.line:C(n.line),line_width:n.line_width===void 0?R.line_width:S(n.line_width)},...n.text&&!p?{fileText:{...n.text}}:{},...p?{}:{text:{paragraphs:paragraphsOfWords(r(`${o}.${h}.${e}`)).map(j=>n.text?.align===void 0?{alignment:R.alignment,...j}:j),style:Z(_e(g,Y(me)),n.text),own:J(Y(me)),empty:!1}},sources:{...u,fill:{from:"slide",path:`${s}.fill`}}}}if(n.component!==void 0){const p=D(n.component,n.props,$,n.dur);return p?{...x,kind:"component",component:p,sources:u}:void 0}},G=(e,n,s)=>{if(n.frame&&(e.frame=ke(n.frame),e.sources.frame={from:"slide",path:`${s}.frame`}),Object.assign(e,we(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=Z(e.text.style,n.text),e.text.paragraphs=ln(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${s}.text`}),n.line!==void 0&&(e.line=C(n.line),e.sources.line={from:"slide",path:`${s}.line`}),n.line_width!==void 0&&(e.line_width=S(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_cap!==void 0&&(e.line_cap=n.line_cap),n.line_join!==void 0&&(e.line_join=n.line_join),n.line_compound!==void 0&&(e.line_compound=n.line_compound),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.line_begin_size!==void 0&&(e.line_begin_size=n.line_begin_size),n.line_end_size!==void 0&&(e.line_end_size=n.line_end_size),(n.fill!==void 0||n.gradient!==void 0||n.pattern!==void 0||n.picture_fill!==void 0)&&(delete e.gradient,delete e.pattern,delete e.picture_fill),n.fill!==void 0&&(e.fill=C(n.fill),e.sources.fill={from:"slide",path:`${s}.fill`}),Object.assign(e,te(n),be(n,y)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const h=Se(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath(y,n.picture??n.movie??""),...h?{crop:h}:{},...n.poster===void 0?{}:{poster:n.poster},...n.playback&&n.movie!==void 0?{playback:n.playback}:{}},e.sources.media={from:"slide",path:`${s}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}else n.playback&&e.media&&(e.kind==="movie"||e.kind==="audio")&&(e.media={...e.media,playback:{...e.media.playback,...n.playback}})},ie=(e,n,s,h,g)=>{const $=N.get(n);if(!$){a.push({slide:e,path:`slides.${String(s)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...N.keys()].join(", ")||"none"}).`});return}const{layout:T,master:u}=$,x=[...(T.display_master_shapes===!1?[]:u.shapes).filter(p=>p.kind!=="placeholder").map(p=>L(p,"master",u)),...T.shapes.filter(p=>p.kind!=="placeholder").map(p=>L(p,"layout",u))],b=T.shapes.filter(p=>p.kind==="placeholder").map((p,j)=>({shape:P(p,u),order:j}));return{slide:{id:e,layout:T.name,master:u.name,hidden:h,background:T.background??u.background,...qe(u,T),shapes:x,animations:[],file:{index:s,...g===void 0?{}:{generate:g}}},placed:b,master:u}},oe=(e,n,s)=>{if(!n)return;const h=T=>{const u=n[T];if(u===void 0)return e.connect?.[T];const x=u==="none"?void 0:s(u.shape);return u==="none"||x===void 0?void 0:{shape:x,site:u.site}},g=h("begin"),$=h("end");g||$?e.connect={...g?{begin:g}:{},...$?{end:$}:{}}:delete e.connect},re=(e,n,s,h,g,$,T,u,x,b=()=>{})=>{const p=new Set(s.map(c=>c.shape.name));let j=s.length;for(const[c,d]of Object.entries(h??{})){const f=$(c);if(f===void 0)continue;const m=`${g}.shapes.${c}`,_=d.textbox!==void 0||d.geometry!==void 0||d.path!==void 0||d.table!==void 0||d.chart!==void 0||d.component!==void 0||d.audio!==void 0||(d.picture!==void 0||d.movie!==void 0)&&!p.has(f),k=s.find(M=>M.shape.name===f);if(k&&!_){G(k.shape,d,m),oe(k.shape,d.connect,$),k.shown=!0,d.z!==void 0&&(k.z=d.z);continue}if(k){a.push({slide:e.id,shape:f,path:m,message:`Slide ${e.id} has a ${k.shape.kind} ${f} already: a shape of its own needs another name.`});continue}if(!_){a.push({slide:e.id,shape:f,path:m,message:`Slide ${e.id} has no shape ${f} to change (its layout's placeholders and its own shapes are ${[...p].join(", ")||"none"}).`});continue}const z=U(f,d,m,e.id,n);z&&oe(z,d.connect,$),z&&(s.push({shape:z,order:j++,...d.z===void 0?{}:{z:d.z}}),p.add(f))}const w=s.filter(c=>c.shown===!0||!cn.has(c.shape.placeholder?.type??"")||T(c.shape)!==void 0);s.splice(0,s.length,...w),s.sort((c,d)=>(c.z??0)-(d.z??0)||c.order-d.order);const O=(c,d)=>{const f=_=>{const k=_.shape.group;return k===void 0?void 0:Ae(k)[d]},m=new Map(c.flatMap((_,k)=>{const z=f(_);return z===void 0?[]:[[z,k]]}));return c.flatMap((_,k)=>{const z=f(_);return z===void 0?[_]:m.get(z)===k?O(c.filter(M=>f(M)===z),d+1):[]})};s.splice(0,s.length,...O(s,0));for(const c of s){const d=b(c.shape);d!==void 0&&(c.shape.alt=d);const f=c.shape.text;if(c.shape.kind==="placeholder"&&f){const m=T(c.shape);f.paragraphs=paragraphsOfWords(m,0,E.fonts.code),f.empty=f.paragraphs.length===0||f.paragraphs.every(_=>_.runs.every(k=>k.text===""))}}e.shapes.push(...s.map(c=>c.shape));for(const c of e.shapes){const d=c.connect;if(!d)continue;const f=Ge(c,m=>e.shapes.find(_=>_.name===m&&_.level===c.level&&_!==c));c.frame=f.frame,f.flip?c.flip=f.flip:delete c.flip;for(const m of f.lost){const _=d[m];_&&c.level==="slide"&&a.push({slide:e.id,shape:c.name,message:`Connector ${c.name}'s ${m} is glued to site ${String(_.site)} of ${_.shape}, which slide ${e.id} has not: it stays where it is.`})}}u!==void 0&&u.trim()!==""&&(e.notes=u);for(const[c,d]of(x??[]).entries()){const f=$(d.shape);if(f===void 0)continue;const m={slide:e.id,shape:f,path:`${g}.animations.${String(c)}`},_=e.shapes.find(A=>A.name===f&&A.level==="slide");if(!_){a.push({...m,message:`Slide ${e.id} has no shape ${f} to animate (it has ${e.shapes.filter(A=>A.level==="slide").map(A=>A.name).join(", ")}).`});continue}if(d.paragraph!==void 0&&d.paragraph>=(_.text?.paragraphs.length??0)){a.push({...m,message:`Shape ${f} has no paragraph ${String(d.paragraph)} to animate (it has ${String(_.text?.paragraphs.length??0)}).`});continue}const k=We[d.effect];d.direction!==void 0&&!k.directions.includes(d.direction)&&a.push({...m,path:`${m.path}.direction`,message:k.directions.length===0?`${f}'s ${d.effect} has no direction (${d.direction}).`:`${f}'s ${d.effect} goes ${k.directions.join(", ")}, not ${d.direction}.`}),d.amount!==void 0&&k.amount===void 0?a.push({...m,path:`${m.path}.amount`,message:`${f}'s ${d.effect} has no amount: only a Grow/Shrink, a spin and a Transparency do.`}):d.effect==="transparency"&&(d.amount??0)>1&&a.push({...m,path:`${m.path}.amount`,message:`${f}'s transparency is a share, at most 1 (it is ${String(d.amount)}).`}),d.animate_text!==void 0&&!_.text&&a.push({...m,path:`${m.path}.animate_text`,message:`${f} has no text to animate by ${d.animate_text}: it plays as one.`});const z=d.animate_text,M=De({...d,shape:f,..._.text?{}:{animate_text:void 0}},z===void 0?1:(d.paragraph===void 0?_.text?.paragraphs??[]:[_.text?.paragraphs[d.paragraph]]).reduce((A,ve)=>A+Ie(ve?.runs.map(Oe=>Oe.text)??[],z).length,0));M?e.animations.push(M):a.push({...m,message:`The animation of ${f} needs a path that starts with M and says only M, L and C, absolute.`})}},ae=new Set;l.slides.forEach((e,n)=>{const s=`slides.${String(n)}`;if(e.layout!==void 0){const u=ie(e.id,e.layout,n,e.hidden===!0);if(!u)return;const x=r(`${o}.${e.id}.notes`);e.transition&&(u.slide.transition=F(e.id,e.transition,s)),e.advance_after!==void 0&&(u.slide.advance=e.advance_after),e.section!==void 0&&(u.slide.section=e.section),xe(u.slide,e.background,y),re(u.slide,u.master,u.placed,e.shapes,s,b=>b,b=>r(`${o}.${e.id}.${b.name}`),typeof x=="string"?x:void 0,e.animations,b=>{const p=r(`${o}.${e.id}.alt.${b.name}`);return typeof p=="string"?p:void 0}),v.push(u.slide),ae.add(e.id);return}const h=e.generate??"",g=t.generators[h];if(g===void 0){a.push({slide:e.id,path:`${s}.generate`,message:`There is no generator ${h} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(g)){a.push({slide:e.id,path:`${s}.generate`,message:`Generator ${h} threw: ${g.error}`,...g.stack===void 0?{}:{stack:g.stack}});return}const $=g,T=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const u of $){const x=`${e.id}/${u.id}`,b=ie(x,u.layout,n,T.has(u.id),h);if(!b)continue;for(const w of u.shapes){const O=w.placeholder?b.placed.find(c=>c.shape.placeholder?.idx===w.placeholder?.idx):void 0;if(O)w.frame&&(O.shape.frame={...w.frame}),O.shape.sources.frame={from:"code"},O.shown=!0;else{const c=L(w,"layout",b.master);b.placed.push({shape:{...c,level:"slide",sources:{frame:{from:"code"}}},order:b.placed.length})}}const p=`${u.id}/`,j=u.transition??(u===$[0]?e.transition:void 0);xe(b.slide,e.background,y),j&&(b.slide.transition=F(b.slide.id,j,s)),u===$[0]&&e.section!==void 0&&(b.slide.section=e.section),re(b.slide,b.master,b.placed,e.shapes,s,w=>w.startsWith(p)?w.slice(p.length):void 0,w=>{const O=w.placeholder===void 0?void 0:u.text[w.placeholder.idx];return O===void 0?void 0:O.map(c=>c.runs.map(d=>d.text).join(""))},u.notes,[...(u.animations??[]).map(w=>({...w,shape:`${p}${w.shape}`})),...e.animations??[]]);for(const w of b.slide.shapes){const O=w.placeholder===void 0?void 0:u.text[w.placeholder.idx];O&&w.text&&(w.text.paragraphs=O,w.text.empty=!1)}v.push(b.slide),ae.add(x)}for(const u of Object.keys(e.shapes??{})){const[x]=u.split("/");x!==void 0&&!$.some(b=>b.id===x)&&a.push({slide:e.id,path:`${s}.shapes.${u}`,message:`Generator ${h} makes no slide ${x}: ${u} changes nothing.`})}});const le=new Set(v.map(e=>e.id));for(const e of v)for(const n of e.shapes){if(n.level!=="slide")continue;const s=[...n.link===void 0?[]:[n.link],...(n.text?.paragraphs??[]).flatMap(h=>h.runs.flatMap(g=>g.font?.link===void 0?[]:[g.font.link]))];for(const h of new Set(s)){const g=Ee(h);(g!==void 0?!le.has(g):h.startsWith("ppaction://")&&je(h)===void 0)&&a.push({slide:e.id,shape:n.name,message:g!==void 0?`Shape ${n.name} links to slide ${g}, which the deck has not (it has ${[...le].join(", ")}).`:`Shape ${n.name} links to ${h}: a show jump is ppaction://hlinkshowjump?jump= and ${Te.join(", ")}.`})}}return v.forEach((e,n)=>{for(const s of e.shapes)s.placeholder?.type==="sldNum"&&s.text&&(s.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],s.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:E,slides:v},problems:a}}
2
+ import{CAPS as Ae,colorOfFile as fe,groupLevels as ze,SHOW_JUMPS as Te,showJumpOf as je,slideLinkOf as Ee,UNDERLINES as Fe}from"@allyhub/formats";import{readMarks as Ne,markRuns as Me}from"@allyhub/piece";import{shownPath as Le}from"@allyhub/formats";import{chartOfFile as Ce}from"@allyhub/chart";import{AUTOSHAPE_STYLE as D,SHADOW_DEFAULTS as W,PATTERN_DEFAULTS as ce,TILE_DEFAULTS as H,INNER_SHADOW_DEFAULTS as G,GLOW_DEFAULTS as ee,REFLECTION_DEFAULTS as K,CONNECTOR_STYLE as ue,DRAWN_TEXTBOX_FRAME as pe,TEXT_FALLBACK as he,TEXT_INSETS as J,isConnectorGeometry as Pe,placeholderFrame as Re,styleKindOf as De}from"./office.js";import{resolveAnimation as Ue,resolveTransition as Ie,unitsAcross as We,EFFECT_OPTIONS as He,TRANSITION_OPTIONS as Ge}from"./animation.js";import{glued as Xe}from"./connect.js";import{pathSteps as Be}from"./path.js";import{CHART_AXIS_WORDS as Ke}from"./script.js";import{cellLook as Je,tableStyleOf as ne}from"./table-style.js";import{masterPlaceholder as Ye}from"./placeholders.js";import{DECK_FONTS as Ve,OFFICE_THEME as Ze,themeOver as qe}from"./theme.js";import{Pt as v}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const d=[];for(const a of[...i.split("/"),...t.split("/")])a===""||a==="."||(a===".."?d.pop():d.push(a));return d.join("/")}const me={left:0,top:0,width:0,height:0};function Qe(i,t){const d={...i.color_map,...t.color_map};return Object.keys(d).length>0?{color_map:d}:{}}const Y=()=>Array.from({length:9},()=>({...he,font:{...he.font},margin_left:0}));export function levelsOver(i,...t){return i.map((d,a)=>{let o={...d,font:{...d.font}};for(const g of t){const r=g?.[a];r&&(o={...o,...r.alignment===void 0?{}:{alignment:r.alignment},...r.line_spacing===void 0?{}:{line_spacing:r.line_spacing},...r.space_before===void 0?{}:{space_before:r.space_before},...r.space_after===void 0?{}:{space_after:r.space_after},...r.margin_left===void 0?{}:{margin_left:r.margin_left},...r.indent===void 0?{}:{indent:r.indent},font:{...o.font,...r.font}},r.numbered!==void 0&&(o.numbered=r.numbered,delete o.bullet),r.bullet===null?(delete o.bullet,delete o.numbered):r.bullet!==void 0?(delete o.numbered,o.bullet={char:r.bullet,...r.bullet_font===void 0?{}:{font:r.bullet_font}}):r.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:r.bullet_font}),o=bulletLookOver(o,r))}return o})}export function bulletLookOver(i,t){const d={...i};return t.bullet_color===null?delete d.bullet_color:t.bullet_color!==void 0&&(d.bullet_color=t.bullet_color),t.bullet_size===null?delete d.bullet_size:t.bullet_size!==void 0&&(d.bullet_size=t.bullet_size),t.start_at!==void 0&&(d.start_at=t.start_at),d}function te(i,...t){const d=t.filter(o=>o!==void 0),a=o=>{for(let g=d.length-1;g>=0;g--){const r=d[g]?.[o];if(r!==void 0)return r}};return{vertical_anchor:a("vertical_anchor")??i.vertical_anchor,orientation:a("orientation")??"horz",auto_size:a("auto_size")??i.auto_size,word_wrap:a("word_wrap")??i.word_wrap,margins:{left:a("margin_left")??J.left,top:a("margin_top")??J.top,right:a("margin_right")??J.right,bottom:a("margin_bottom")??J.bottom}}}const _e={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(Y(),i.text_styles.other);function ie(i,t){return{...te(_e,t),levels:levelsOver(Y(),i.text_styles.other,t.levels)}}function en(i,t,...d){return{...te(Re(t),...d),levels:levelsOver(Y(),i.text_styles[De(t)],...d.map(a=>a?.levels))}}const nn=Array.from({length:9},()=>({font:{color:D.font_color}})),ge={vertical_anchor:D.vertical_anchor};function be(i,t){return{...te(_e,t),levels:levelsOver(Y(),i.text_styles.other,nn,t.levels)}}const V=i=>{const t={...i};return delete t.paragraphs,t},Z=i=>({paragraphs:[],levels:[],...i}),P=i=>i==="none"?null:colorOfFile(i),tn=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,on=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="([^"\n]*)"/gu,q=57344,an=256,ye="",rn=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const spaceOfFile=i=>typeof i=="number"?v(i):{lines:i.lines},colorOfFile=i=>fe(i)??"dk1";function oe(i){const{shadow:t,gradient:d,inner_shadow:a,glow:o,reflection:g}=i;return{...a?{inner_shadow:{color:a.color===void 0?G.color:colorOfFile(a.color),blur:a.blur===void 0?G.blur:v(a.blur),distance:a.distance===void 0?G.distance:v(a.distance),angle:a.angle??G.angle,transparency:a.transparency??G.transparency}}:{},...o?{glow:{color:o.color===void 0?ee.color:colorOfFile(o.color),size:o.size===void 0?ee.size:v(o.size),transparency:o.transparency??ee.transparency}}:{},...i.soft_edges===void 0?{}:{soft_edges:v(i.soft_edges)},...g?{reflection:{transparency:g.transparency??K.transparency,size:g.size??K.size,distance:g.distance===void 0?K.distance:v(g.distance),blur:g.blur===void 0?K.blur:v(g.blur)}}:{},...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...d?{gradient:{angle:d.angle??0,...d.path===void 0?{}:{path:d.path},...d.focus===void 0?{}:{focus:{left:d.focus.left??.5,top:d.focus.top??.5,right:d.focus.right??.5,bottom:d.focus.bottom??.5}},stops:d.stops.map(r=>({at:r.at,color:colorOfFile(r.color),...r.transparency===void 0?{}:{transparency:r.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?W.color:colorOfFile(t.color),blur:t.blur===void 0?W.blur:v(t.blur),distance:t.distance===void 0?W.distance:v(t.distance),angle:t.angle??W.angle,transparency:t.transparency??W.transparency}}:{}}}const dn=i=>({...i.tile?{tile:{...i.tile}}:{},...i.transparency===void 0?{}:{transparency:i.transparency}});function $e(i,t){const{pattern:d,picture_fill:a}=i;return{...d?{pattern:{preset:d.preset,fg:colorOfFile(d.fg??ce.fg),bg:colorOfFile(d.bg??ce.bg)}}:{},...a?{picture_fill:{path:joinPath(t,a.path),...a.tile?{tile:{scale_x:a.tile.scale_x??H.scale_x,scale_y:a.tile.scale_y??H.scale_y,offset_x:a.tile.x===void 0?H.offset_x:v(a.tile.x),offset_y:a.tile.y===void 0?H.offset_y:v(a.tile.y),align:a.tile.align??H.align}}:{},...a.transparency===void 0?{}:{transparency:a.transparency}}}:{}}}function ke(i,t,d=[]){const a=ne(i.style);return{...i,rows:i.rows.map((o,g)=>({height:o.height,cells:o.cells.map((r,j)=>{const N=d[g],_=a?Je(a,i,g,j,i.rows.length,i.columns.length,g+(r.span_height??1)-1,j+(r.span_width??1)-1):void 0,E=ie(t,r.text),C=_&&(_.bold!==void 0||_.text!==void 0)?{...E,levels:E.levels.map(R=>({...R,font:{...R.font,..._.bold===void 0?{}:{bold:_.bold},..._.text===void 0?{}:{color:_.text}}}))}:E;return{...r,text:{paragraphs:r.text.paragraphs,style:Q({...C,auto_size:"shape"},N),own:V(r.text),empty:!1},...N?{fileText:N}:{}}})}))}}function Q(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},...t.orientation===void 0?{}:{orientation:t.orientation},levels:i.levels.map(d=>{const a={...d.font,...t.size===void 0?{}:{size:v(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.caps===void 0?{}:{caps:t.caps},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(a.color=colorOfFile(t.color));const o={...d,font:a,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:spaceOfFile(t.space_before)},...t.space_after===void 0?{}:{space_after:spaceOfFile(t.space_after)}};return t.bullet_color!==void 0&&(o.bullet_color=colorOfFile(t.bullet_color)),t.bullet_size!==void 0&&(o.bullet_size=t.bullet_size),t.start_at!==void 0&&(o.start_at=t.start_at),t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&d.margin_left===0?{...o,margin_left:we,indent:-we}:o})}:i}function ln(i,t){if(!t)return[...i];const d=t.numbered!==void 0||t.bullet!==void 0;return i.map(a=>{const o={...a};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,t.bullet_color!==void 0&&delete o.bullet_color,t.bullet_size!==void 0&&delete o.bullet_size,t.start_at!==void 0&&delete o.start_at,d&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}const sn=i=>Fe.includes(i),fn=i=>Ae.includes(i);function cn(i){const t={};for(const[,d,a=""]of i.matchAll(on))if(d==="font")t.name=a.trim();else if(d==="link")t.link=a.trim();else if(d==="highlight")t.highlight=a.trim().toUpperCase();else if(d==="bold")t.bold=a.trim()!=="false";else if(d==="italic")t.italic=a.trim()!=="false";else if(d==="strike"){const o=a.trim();t.strike=o==="dblStrike"?o:o!=="false"}else if(d==="underline"){const o=a.trim();t.underline=sn(o)&&o!=="sng"?o:o!=="false"}else if(d==="caps"){const o=a.trim();fn(o)&&(t.caps=o)}else if(d==="size"){const o=Number(a);Number.isFinite(o)&&o>0&&(t.size=v(o))}else if(d==="baseline"){const o=Number(a);Number.isFinite(o)&&(t.baseline=o)}else if(d==="spacing"){const o=Number(a);Number.isFinite(o)&&(t.spacing=v(o))}else{const o=fe(a.trim());o!==void 0&&(t.color=o)}return t}const we=342900;export function paragraphsOfWords(i,t=0,d=Ve.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(a=>{const o=[],g=a.replace(tn,(_,E,C)=>(o.push(cn(E)),`${String.fromCharCode(q+o.length-1)}${C}${ye}`)),r=Ne(g);let j;const N=Me(r.text,r.marks).flatMap(_=>{const E=_.kinds.includes("code"),C={..._.kinds.includes("strong")?{bold:!0}:{},..._.kinds.includes("em")?{italic:!0}:{},...E?{name:d}:{}};return[..._.text.matchAll(rn)].flatMap(R=>{const U=R[0],I=U.charCodeAt(0);if(U===ye)return j=void 0,[];if(I>=q&&I<q+an)return j=o[I-q],[];const X={...j,...C};return[{text:U,...Object.keys(X).length>0?{font:X}:{},...E?{code:!0}:{}}]})});return{runs:N.length>0?N:[{text:""}],level:t}}):i.flatMap(a=>paragraphsOfWords(a,Array.isArray(a)?Math.min(t+1,8):t,d))}const xe=i=>({left:v(i.x),top:v(i.y),width:v(i.w),height:v(i.h)}),un=new Set(["dt","ftr","sldNum"]),Se=i=>({...i.locked?{locked:!0}:{},...i.link===void 0?{}:{link:i.link},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function Oe(i,t,d){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const a=t.gradient&&oe({gradient:t.gradient}).gradient;a&&(i.background_gradient=a),t.picture!==void 0&&(i.background_picture=joinPath(d,t.picture))}function pn(i,t,d){if(i.data===void 0)return;let a;try{const _=t(Le(i.data));a=Array.isArray(_)?_:t(i.data)}catch(_){d(`${i.data} cannot be read: ${_ instanceof Error?_.message:String(_)}`);return}if(!Array.isArray(a)||a.length===0){d(`${i.data} holds no rows.`);return}const o=a,g=Object.keys(o[0]??{}),r=i.fields??g,j=r.filter(_=>!g.includes(_));if(j.length>0){d(`${i.data} has no column ${j.join(", ")} (it has ${g.join(", ")}).`);return}const N=_=>typeof _=="string"||typeof _=="number"||typeof _=="boolean"?String(_):"";return[...i.head===!1?[]:[[...r]],...o.map(_=>r.map(E=>N(_[E])))]}const hn=i=>{const t=ne(i.style);return{...t?{style:t.id}:{},...i.first_row===void 0?{}:{first_row:i.first_row},...i.last_row===void 0?{}:{last_row:i.last_row},...i.first_col===void 0?{}:{first_col:i.first_col},...i.last_col===void 0?{}:{last_col:i.last_col},...i.horz_banding===void 0?{}:{horz_banding:i.horz_banding},...i.vert_banding===void 0?{}:{vert_banding:i.vert_banding}}},ve=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:d,words:a,prefix:o,base:g}=i,r=[],j=qe(i.theme??Ze,t.theme),N=new Map;for(const e of t.masters)for(const n of e.layouts)N.set(n.name,{layout:n,master:e});const _=[],E=(e,n,l)=>{const m=Ge[n.type];return n.direction!==void 0&&!m.directions.includes(n.direction)&&r.push({slide:e,path:`${l}.transition.direction`,message:m.directions.length===0?`A ${n.type} transition has no direction (${n.direction}).`:`A ${n.type} transition goes ${m.directions.join(", ")}, not ${n.direction}.`}),n.through_black===!0&&!m.throughBlack&&r.push({slide:e,path:`${l}.transition.through_black`,message:`A ${n.type} transition does not go through black: only a fade, a cut and a reveal do.`}),Ie(n)},C=(e,n,l)=>({name:e.name,kind:e.kind,frame:{...e.frame??me},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?be(l,e.text):ie(l,e.text),own:V(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.pattern?{pattern:e.pattern}:{},...e.picture_fill?{picture_fill:{...dn(e.picture_fill),path:joinPath(e.picture_fill.base,e.picture_fill.path)}}:{},...e.shadow===void 0?{}:{shadow:e.shadow},...e.inner_shadow?{inner_shadow:e.inner_shadow}:{},...e.glow?{glow:e.glow}:{},...e.soft_edges===void 0?{}:{soft_edges:e.soft_edges},...e.reflection?{reflection:e.reflection}:{},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_cap===void 0?{}:{line_cap:e.line_cap},...e.line_join===void 0?{}:{line_join:e.line_join},...e.line_compound===void 0?{}:{line_compound:e.line_compound},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size},...e.path?{path:e.path}:{},...e.table?{table:ke(e.table,l)}:{},...e.chart?{chart:e.chart}:{},...e.link===void 0?{}:{link:e.link},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster},...e.media.playback?{playback:e.media.playback}:{}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),R=(e,n)=>{const l=e.placeholder?.type??"body",m=Ye(n,l),b=e.frame??m?.frame??me;return{name:e.name,kind:"placeholder",frame:{...b},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:en(n,l,m?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!m?"layout":"master"},text:{from:"layout"}}}},U=(e,n,l,m)=>{const b=t.components[e];if(!b){r.push({...l,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const w of Object.keys(n??{}))Object.hasOwn(b.props,w)||r.push({...l,message:`Component ${e} has no prop ${w} a person sets (it has ${Object.keys(b.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...m===void 0?{}:{dur:m}}},I=(e,n,l,m,b)=>{const w={slide:m,shape:e,path:l};if(!n.frame){r.push({...w,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const z=xe(n.frame),c={frame:{from:"slide",path:`${l}.frame`}},S={name:e,frame:z,level:"slide",...n.fill===void 0?{}:{fill:P(n.fill)},...oe(n),...$e(n,g),...n.line===void 0?{}:{line:P(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_cap===void 0?{}:{line_cap:n.line_cap},...n.line_join===void 0?{}:{line_join:n.line_join},...n.line_compound===void 0?{}:{line_compound:n.line_compound},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.line_begin_size===void 0?{}:{line_begin_size:n.line_begin_size},...n.line_end_size===void 0?{}:{line_end_size:n.line_end_size},...n.group===void 0?{}:{group:n.group},...Se(n)};if(n.textbox)return{...S,kind:"textbox",text:{paragraphs:paragraphsOfWords(a(`${o}.${m}.${e}`),0,j.fonts.code),style:Q(ie(b,Z(pe)),n.text),own:V(Z(pe)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...c,text:{from:"slide",path:`${l}.text`}}};if(n.picture!==void 0){const u=ve(n.crop);return{...S,kind:"picture",media:{path:joinPath(g,n.picture),...u?{crop:u}:{}},sources:{...c,media:{from:"slide",path:`${l}.picture`}}}}if(n.item!==void 0)return{...S,kind:"item",item:{path:joinPath(g,n.item),...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.item`}}};if(n.movie!==void 0)return{...S,kind:"movie",media:{path:joinPath(g,n.movie),...n.poster===void 0?{}:{poster:n.poster},...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.movie`}}};if(n.audio!==void 0)return{...S,kind:"audio",media:{path:joinPath(g,n.audio),...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.audio`}}};if(n.chart){const u=`${o}.${m}.${e}`,A=p=>typeof p=="string"?p:void 0,x=Object.fromEntries(Ke.flatMap(p=>{const s=A(a(`${u}.${p}`));return s===void 0?[]:[[p,s]]})),T=Ce(n.chart,{title:A(a(u))??A(a(`${u}.title`)),axisTitles:x,base:g,rows:p=>i.data?.(p),problem:p=>{r.push({...w,message:`Chart ${e}: ${p}`})}});return T?{...S,kind:"chart",chart:T,sources:c}:void 0}if(n.table){const u=n.table;u.style!==void 0&&!ne(u.style)&&r.push({...w,message:`Table ${e}'s style ${u.style} is none of PowerPoint's built-in table styles: name one as its gallery does (Medium Style 2 - Accent 1, Light Style 1, No Style, Table Grid) or by its id.`});const A=u.data===void 0?void 0:pn(u,f=>i.data?.(f),f=>{r.push({...w,message:`Table ${e}: ${f}`})});if(u.data!==void 0&&A===void 0)return;const x=A===void 0?u.rows:A.map((f,y)=>u.rows[Math.min(y,u.rows.length-1)]??u.rows[0]),T=z.width/u.columns.reduce((f,y)=>f+y,0),p=z.height/x.reduce((f,y)=>f+(y?.height??0),0),s=a(`${o}.${m}.${e}`),h=A??(Array.isArray(s)?s:[]),k=new Map;for(const f of u.merged??[]){const y=f.rows??1,O=f.columns??1;for(let M=f.row;M<f.row+y;M++)for(let F=f.column;F<f.column+O;F++)k.set(`${String(M)},${String(F)}`,"under");k.set(`${String(f.row)},${String(f.column)}`,{w:O,h:y})}return A===void 0&&h.length>u.rows.length&&r.push({...w,message:`Table ${e} has ${String(u.rows.length)} rows and its words ${String(h.length)}.`}),{...S,kind:"table",table:ke({...hn(u),columns:u.columns.map(f=>Math.round(f*T)),rows:x.flatMap((f,y)=>{if(!f)return[];const O=h[y],M=Array.isArray(O)?O:O===void 0?[]:[O];return{height:Math.round(f.height*p),cells:u.columns.map((F,B)=>{const L=k.get(`${String(y)},${String(B)}`);return{text:{levels:[],paragraphs:L==="under"?[]:paragraphsOfWords(M[B],0,j.fonts.code)},...L==="under"?{spanned:!0}:{},...L!==void 0&&L!=="under"&&L.w>1?{span_width:L.w}:{},...L!==void 0&&L!=="under"&&L.h>1?{span_height:L.h}:{},...f.fill===void 0?{}:{fill:colorOfFile(f.fill)},...f.line===void 0?{}:{borders:{bottom:{color:colorOfFile(f.line),width:v(1)}}}}})}})},b,x.map(f=>f?.text)),sources:c}}const $=n.path&&Be(n.path.d);if(n.path&&!$){r.push({...w,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&$){const u=!n.path&&Pe(n.geometry);return{...S,kind:"autoshape",...n.path&&$?{path:{w:n.path.w,h:n.path.h,steps:$}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...u?{line:n.line===void 0?ue.line:P(n.line),line_width:n.line_width===void 0?ue.line_width:v(n.line_width)}:{fill:n.fill===void 0?D.fill:P(n.fill),line:n.line===void 0?D.line:P(n.line),line_width:n.line_width===void 0?D.line_width:v(n.line_width)},...n.text&&!u?{fileText:{...n.text}}:{},...u?{}:{text:{paragraphs:paragraphsOfWords(a(`${o}.${m}.${e}`)).map(A=>n.text?.align===void 0?{alignment:D.alignment,...A}:A),style:Q(be(b,Z(ge)),n.text),own:V(Z(ge)),empty:!1}},sources:{...c,fill:{from:"slide",path:`${l}.fill`}}}}if(n.component!==void 0){const u=U(n.component,n.props,w,n.dur);return u?{...S,kind:"component",component:u,sources:c}:void 0}},X=(e,n,l)=>{if(n.frame&&(e.frame=xe(n.frame),e.sources.frame={from:"slide",path:`${l}.frame`}),Object.assign(e,Se(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=Q(e.text.style,n.text),e.text.paragraphs=ln(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${l}.text`}),n.line!==void 0&&(e.line=P(n.line),e.sources.line={from:"slide",path:`${l}.line`}),n.line_width!==void 0&&(e.line_width=v(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_cap!==void 0&&(e.line_cap=n.line_cap),n.line_join!==void 0&&(e.line_join=n.line_join),n.line_compound!==void 0&&(e.line_compound=n.line_compound),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.line_begin_size!==void 0&&(e.line_begin_size=n.line_begin_size),n.line_end_size!==void 0&&(e.line_end_size=n.line_end_size),(n.fill!==void 0||n.gradient!==void 0||n.pattern!==void 0||n.picture_fill!==void 0)&&(delete e.gradient,delete e.pattern,delete e.picture_fill),n.fill!==void 0&&(e.fill=P(n.fill),e.sources.fill={from:"slide",path:`${l}.fill`}),Object.assign(e,oe(n),$e(n,g)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const m=ve(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath(g,n.picture??n.movie??""),...m?{crop:m}:{},...n.poster===void 0?{}:{poster:n.poster},...n.playback&&n.movie!==void 0?{playback:n.playback}:{}},e.sources.media={from:"slide",path:`${l}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}else n.playback&&e.media&&(e.kind==="movie"||e.kind==="audio")&&(e.media={...e.media,playback:{...e.media.playback,...n.playback}})},ae=(e,n,l,m,b)=>{const w=N.get(n);if(!w){r.push({slide:e,path:`slides.${String(l)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...N.keys()].join(", ")||"none"}).`});return}const{layout:z,master:c}=w,S=[...(z.display_master_shapes===!1?[]:c.shapes).filter(u=>u.kind!=="placeholder").map(u=>C(u,"master",c)),...z.shapes.filter(u=>u.kind!=="placeholder").map(u=>C(u,"layout",c))],$=z.shapes.filter(u=>u.kind==="placeholder").map((u,A)=>({shape:R(u,c),order:A}));return{slide:{id:e,layout:z.name,master:c.name,hidden:m,background:z.background??c.background,...Qe(c,z),shapes:S,animations:[],file:{index:l,...b===void 0?{}:{generate:b}}},placed:$,master:c}},re=(e,n,l)=>{if(!n)return;const m=z=>{const c=n[z];if(c===void 0)return e.connect?.[z];const S=c==="none"?void 0:l(c.shape);return c==="none"||S===void 0?void 0:{shape:S,site:c.site}},b=m("begin"),w=m("end");b||w?e.connect={...b?{begin:b}:{},...w?{end:w}:{}}:delete e.connect},de=(e,n,l,m,b,w,z,c,S,$=()=>{})=>{const u=new Set(l.map(p=>p.shape.name));let A=l.length;for(const[p,s]of Object.entries(m??{})){const h=w(p);if(h===void 0)continue;const k=`${b}.shapes.${p}`,f=s.textbox!==void 0||s.geometry!==void 0||s.path!==void 0||s.table!==void 0||s.chart!==void 0||s.component!==void 0||s.audio!==void 0||s.item!==void 0||(s.picture!==void 0||s.movie!==void 0)&&!u.has(h),y=l.find(M=>M.shape.name===h);if(y&&!f){X(y.shape,s,k),re(y.shape,s.connect,w),y.shown=!0,s.z!==void 0&&(y.z=s.z);continue}if(y){r.push({slide:e.id,shape:h,path:k,message:`Slide ${e.id} has a ${y.shape.kind} ${h} already: a shape of its own needs another name.`});continue}if(!f){r.push({slide:e.id,shape:h,path:k,message:`Slide ${e.id} has no shape ${h} to change (its layout's placeholders and its own shapes are ${[...u].join(", ")||"none"}).`});continue}const O=I(h,s,k,e.id,n);O&&re(O,s.connect,w),O&&(l.push({shape:O,order:A++,...s.z===void 0?{}:{z:s.z}}),u.add(h))}const x=l.filter(p=>p.shown===!0||!un.has(p.shape.placeholder?.type??"")||z(p.shape)!==void 0);l.splice(0,l.length,...x),l.sort((p,s)=>(p.z??0)-(s.z??0)||p.order-s.order);const T=(p,s)=>{const h=f=>{const y=f.shape.group;return y===void 0?void 0:ze(y)[s]},k=new Map(p.flatMap((f,y)=>{const O=h(f);return O===void 0?[]:[[O,y]]}));return p.flatMap((f,y)=>{const O=h(f);return O===void 0?[f]:k.get(O)===y?T(p.filter(M=>h(M)===O),s+1):[]})};l.splice(0,l.length,...T(l,0));for(const p of l){const s=$(p.shape);s!==void 0&&(p.shape.alt=s);const h=p.shape.text;if(p.shape.kind==="placeholder"&&h){const k=z(p.shape);h.paragraphs=paragraphsOfWords(k,0,j.fonts.code),h.empty=h.paragraphs.length===0||h.paragraphs.every(f=>f.runs.every(y=>y.text===""))}}e.shapes.push(...l.map(p=>p.shape));for(const p of e.shapes){const s=p.connect;if(!s)continue;const h=Xe(p,k=>e.shapes.find(f=>f.name===k&&f.level===p.level&&f!==p));p.frame=h.frame,h.flip?p.flip=h.flip:delete p.flip;for(const k of h.lost){const f=s[k];f&&p.level==="slide"&&r.push({slide:e.id,shape:p.name,message:`Connector ${p.name}'s ${k} is glued to site ${String(f.site)} of ${f.shape}, which slide ${e.id} has not: it stays where it is.`})}}c!==void 0&&c.trim()!==""&&(e.notes=c);for(const[p,s]of(S??[]).entries()){const h=w(s.shape);if(h===void 0)continue;const k={slide:e.id,shape:h,path:`${b}.animations.${String(p)}`},f=e.shapes.find(F=>F.name===h&&F.level==="slide");if(!f){r.push({...k,message:`Slide ${e.id} has no shape ${h} to animate (it has ${e.shapes.filter(F=>F.level==="slide").map(F=>F.name).join(", ")}).`});continue}if(s.paragraph!==void 0&&s.paragraph>=(f.text?.paragraphs.length??0)){r.push({...k,message:`Shape ${h} has no paragraph ${String(s.paragraph)} to animate (it has ${String(f.text?.paragraphs.length??0)}).`});continue}const y=He[s.effect];s.direction!==void 0&&!y.directions.includes(s.direction)&&r.push({...k,path:`${k.path}.direction`,message:y.directions.length===0?`${h}'s ${s.effect} has no direction (${s.direction}).`:`${h}'s ${s.effect} goes ${y.directions.join(", ")}, not ${s.direction}.`}),s.amount!==void 0&&y.amount===void 0?r.push({...k,path:`${k.path}.amount`,message:`${h}'s ${s.effect} has no amount: only a Grow/Shrink, a spin and a Transparency do.`}):s.effect==="transparency"&&(s.amount??0)>1&&r.push({...k,path:`${k.path}.amount`,message:`${h}'s transparency is a share, at most 1 (it is ${String(s.amount)}).`}),s.animate_text!==void 0&&!f.text&&r.push({...k,path:`${k.path}.animate_text`,message:`${h} has no text to animate by ${s.animate_text}: it plays as one.`});const O=s.animate_text,M=Ue({...s,shape:h,...f.text?{}:{animate_text:void 0}},O===void 0?1:(s.paragraph===void 0?f.text?.paragraphs??[]:[f.text?.paragraphs[s.paragraph]]).reduce((F,B)=>F+We(B?.runs.map(L=>L.text)??[],O).length,0));M?e.animations.push(M):r.push({...k,message:`The animation of ${h} needs a path that starts with M and says only M, L and C, absolute.`})}},le=new Set;d.slides.forEach((e,n)=>{const l=`slides.${String(n)}`;if(e.layout!==void 0){const c=ae(e.id,e.layout,n,e.hidden===!0);if(!c)return;const S=a(`${o}.${e.id}.notes`);e.transition&&(c.slide.transition=E(e.id,e.transition,l)),e.advance_after!==void 0&&(c.slide.advance=e.advance_after),e.section!==void 0&&(c.slide.section=e.section),Oe(c.slide,e.background,g),de(c.slide,c.master,c.placed,e.shapes,l,$=>$,$=>a(`${o}.${e.id}.${$.name}`),typeof S=="string"?S:void 0,e.animations,$=>{const u=a(`${o}.${e.id}.alt.${$.name}`);return typeof u=="string"?u:void 0}),_.push(c.slide),le.add(e.id);return}const m=e.generate??"",b=t.generators[m];if(b===void 0){r.push({slide:e.id,path:`${l}.generate`,message:`There is no generator ${m} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(b)){r.push({slide:e.id,path:`${l}.generate`,message:`Generator ${m} threw: ${b.error}`,...b.stack===void 0?{}:{stack:b.stack}});return}const w=b,z=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const c of w){const S=`${e.id}/${c.id}`,$=ae(S,c.layout,n,z.has(c.id),m);if(!$)continue;for(const x of c.shapes){const T=x.placeholder?$.placed.find(p=>p.shape.placeholder?.idx===x.placeholder?.idx):void 0;if(T)x.frame&&(T.shape.frame={...x.frame}),T.shape.sources.frame={from:"code"},T.shown=!0;else{const p=C(x,"layout",$.master);$.placed.push({shape:{...p,level:"slide",sources:{frame:{from:"code"}}},order:$.placed.length})}}const u=`${c.id}/`,A=c.transition??(c===w[0]?e.transition:void 0);Oe($.slide,e.background,g),A&&($.slide.transition=E($.slide.id,A,l)),c===w[0]&&e.section!==void 0&&($.slide.section=e.section),de($.slide,$.master,$.placed,e.shapes,l,x=>x.startsWith(u)?x.slice(u.length):void 0,x=>{const T=x.placeholder===void 0?void 0:c.text[x.placeholder.idx];return T===void 0?void 0:T.map(p=>p.runs.map(s=>s.text).join(""))},c.notes,[...(c.animations??[]).map(x=>({...x,shape:`${u}${x.shape}`})),...e.animations??[]]);for(const x of $.slide.shapes){const T=x.placeholder===void 0?void 0:c.text[x.placeholder.idx];T&&x.text&&(x.text.paragraphs=T,x.text.empty=!1)}_.push($.slide),le.add(S)}for(const c of Object.keys(e.shapes??{})){const[S]=c.split("/");S!==void 0&&!w.some($=>$.id===S)&&r.push({slide:e.id,path:`${l}.shapes.${c}`,message:`Generator ${m} makes no slide ${S}: ${c} changes nothing.`})}});const se=new Set(_.map(e=>e.id));for(const e of _)for(const n of e.shapes){if(n.level!=="slide")continue;const l=[...n.link===void 0?[]:[n.link],...(n.text?.paragraphs??[]).flatMap(m=>m.runs.flatMap(b=>b.font?.link===void 0?[]:[b.font.link]))];for(const m of new Set(l)){const b=Ee(m);(b!==void 0?!se.has(b):m.startsWith("ppaction://")&&je(m)===void 0)&&r.push({slide:e.id,shape:n.name,message:b!==void 0?`Shape ${n.name} links to slide ${b}, which the deck has not (it has ${[...se].join(", ")}).`:`Shape ${n.name} links to ${m}: a show jump is ppaction://hlinkshowjump?jump= and ${Te.join(", ")}.`})}}return _.forEach((e,n)=>{for(const l of e.shapes)l.placeholder?.type==="sldNum"&&l.text&&(l.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],l.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:j,slides:_},problems:r}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/slides-core",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/video-core",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -8,7 +8,7 @@ export { FIT_LINES_PRECISION, fitLines, textLines, type FitLines, type FitLinesO
8
8
  export { custom, defineComponent, LAYER_OPTIONS, type Component, type ComponentDefinition, type ComponentInfo, type CustomOptions, type FrameDefinition, type LayerDefinition, type ComponentFrame, type Label, type LayerOptions, type StageContext, } from "@allyhub/image-sdk/define";
9
9
  export { adjustment, fill, group, shape, textLayer, type AdjustmentOptions, type FillOptions, type GroupOptions, type ShapeOptions, type TextLayerOptions, } from "@allyhub/image-sdk";
10
10
  export { say, type BoxKey, type FootageBackground, type FootageBox, type PerOrient, type PunchIn, type Pullback, type Reframe, type FootageLayer, type FootageOptions, type GraphicLayer, type Layer, type LayerSpec, type LayerTiming, type PartAnchors, type PartOptions, type PartSpec, type Rect, type RoomTone, type SayOptions, type SaySpeech, type SoundSpec, type SpeechSpec, type Take, type TakeSpeech, type VideoSpeech, type VideoTake, type Direction, type TransitionChannel, type TransitionInput, type TransitionPicture, type TransitionSpec, type TransitionType, type WordRef, } from "./parts.js";
11
- export type { InlineMark, MarkedText, EmbeddedVideo, CaptionOptions, CaptionTrackCue, CaptionWord, FaceOnFrame, FaceTrack, MediaInfo, MediaKind, PixelRect, TrackedFace, Word, } from "@allyhub/piece";
11
+ export type { InlineMark, MarkedText, EmbeddedItem, EmbeddedVideo, CaptionOptions, CaptionTrackCue, CaptionWord, FaceOnFrame, FaceTrack, MediaInfo, MediaKind, PixelRect, TrackedFace, Word, } from "@allyhub/piece";
12
12
  /** What ctx.video(piece, el) gives: another video item, drawn inside an element. */
13
13
  export { defineConfig, definePiece, paged, type Combo, type Dims, type Format, type FormatEntry, type FormatSpec, type ItemPiece, type Matrix, type MediaRef, type MessageHint, type MotionBlur, type MusicOptions, type PieceContext, type PieceDefinition, type PieceOptions, type PieceWritten, type PostProcess, type CaptureOptions, type ProjectConfig, type Video, type VideoBuild, type VideoItem, type VideoOptions, type VideoPiece, type VideoPieceOptions, } from "./piece.js";
14
14
  export type { ListItem, ListPrefix, MessageInputs, MessageKey, MessageLists, MessageReader, Messages, } from "@allyhub/image-sdk/messages";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/video-sdk",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/docs/docs.md CHANGED
@@ -61,6 +61,7 @@ Tags with plain string attributes (`name="value"`, or the bare name for `toggle`
61
61
  | `<Callout icon color bg>` | A line set apart in a box, with `icon` before it when given (none when absent). Inside it: the line, then the blocks under it |
62
62
  | `<img src alt title width align id />` | A picture with a width in px or a place (`align`: `center` or `right`); `title` is its caption, `id` what a reference names it by. Without those, write `![alt](src)` |
63
63
  | `<Table widths head caption id>` around one GFM table | Column widths in px, comma-separated, an empty entry for a column that shares what is left by its content (`widths="120,,200"`); `head` is `row` (the default), `column`, `both` or `none`; `caption` is set over it, `id` is what a reference names it by |
64
+ | `<Table data fields widths head caption id />` | A table whose rows a project file holds, from the doc's folder: a sheet's table (`../../sales/sales.yaml#Regions`, computed as the sheet computes it), a CSV, or a YAML or JSON file of rows. A row of the file is a row, under a head row of its columns' names, each value as its source shows it (a sheet's number formats); `fields` its columns in their order, comma-separated (default all of them). The editor draws it and its cells are changed where they come from; the PDF, Word and Markdown hold its rows. A file it cannot read, or a column it does not have, is AK-M008 at its line |
64
65
  | `<Chart type …>` around one GFM table, or `<Chart type data … />` | A chart drawn from numbers ([below](#charts)) |
65
66
  | `<Columns>` around two or more `<Column width>` | Blocks side by side ([below](#columns)) |
66
67
  | `<Card title subtitle>` | Blocks in a card: a hairline border, rounded, its title bold and its `subtitle` quieter over the blocks inside it. Word draws it as a table of one cell, its corners square (Word's borders have none) |
@@ -241,6 +242,16 @@ A figure drawn by code is a component (`defineComponent`, [layers.md](layers.md#
241
242
  | `align` | `center` or `right` |
242
243
  | any other | A prop, read by its type: a `number()` from its digits, a `boolean()` from `true` or `false`, a `list()` or `object()` from JSON, anything else as written |
243
244
 
245
+ Another item of the project, a deck's slide or a video's moment, is placed with `<Item>`: drawn by its own kind, fitted to the frame, in the doc's language where it has it.
246
+
247
+ ```mdx
248
+ <Item of="../../launch/deck.ts#pricing" width="640" height="360" title="Pricing, from the launch deck" />
249
+
250
+ <Item of="../../launch/teaser.ts#demo" at="1.5" alt="The demo part of the teaser" />
251
+ ```
252
+
253
+ `of` is the item's entry from the doc's folder, and after `#` a part of it: a deck's slide, by its id or its place from 1; a video's part. `at` is seconds into that part (default its still, a slide as it settles; with no part, seconds into the item). `width`, `height`, `alt`, `title`, `align` and `id` are a component's; an item has no props. The editor draws it live; the PDF, Word and a read view show a still of it, as a component's. `allyhub inspect uses` lists it; a part the item does not have is said where it is drawn, and an item that uses the doc back is AK-M016.
254
+
244
255
  It is drawn as a slide's component is, with the project's look (`var(--ak-color-*)`, `var(--ak-font-*)`, and the look's theme as `var(--ak-theme-*)`), its fonts and files. The editor draws it live, its props a field each when it is clicked; the PDF, Word and a read view show a still of it, drawn once and kept by what it shows. A wrong module, export or prop is AK-M008 at its line; an exception in its code is AK-R001.
245
256
 
246
257
  ### Kept as written
package/docs/layers.md CHANGED
@@ -235,6 +235,8 @@ left = pad, right = W − pad
235
235
 
236
236
  `await ctx.video(piece, el)` draws another video item of the project (the piece this module imported) inside `el`, in its own format and, where it has it, this video's language. It gives `{ id, duration, width, height, seek(t), at(ref) }`: `seek(t)` draws its moment `t`, `at(ref)` finds its own anchor or part's key in its seconds. It draws its graphic layers over its background; what it reads counts as this video's. A chain of videos that reaches itself is AK-M010. Put it behind `ctx.wait`. More in [footage.md](footage.md).
237
237
 
238
+ `await ctx.item(piece, el)` draws any item of the project the same way, by its own kind: a video as `ctx.video` does, a deck by its slides (`import q3 from "../decks/q3"`). It gives what `ctx.video` gives and its `kind`; a deck's `at("pricing")` is the moment its slide comes on and `at("pricing/2")` the rest after its second build (`/0` before any). The build finds the item by the import, in the video's module or a module of the project it imports, and `allyhub inspect uses` lists it; an item that uses the video back is AK-M016. It draws the item's graphics, not its sound.
239
+
238
240
  ## `@allyhub/sdk/dom`
239
241
 
240
242
  | Helper | What it does |