@allyhub/sdk 0.15.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/node_modules/@allyhub/audio/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/audio/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/place.d.ts +26 -0
- package/dist/node_modules/@allyhub/audio/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +15 -3
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +70 -11
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +15 -4
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +4 -0
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +9 -0
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +53 -10
- package/dist/node_modules/@allyhub/piece/dist/source.js +1 -1
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +10 -11
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +7 -0
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/blobs.d.ts +9 -0
- package/dist/node_modules/@allyhub/protocol/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.d.ts +77 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +39 -9
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +15 -15
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +441 -5
- package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +4 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +5 -5
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +45 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +134 -0
- package/dist/node_modules/@allyhub/protocol/dist/paywall.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/dist/purposes.d.ts +47 -0
- package/dist/node_modules/@allyhub/protocol/dist/purposes.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +52 -5
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.d.ts +34 -0
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/sites.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +21 -52
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.d.ts +264 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.d.ts +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.d.ts +97 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +3 -2
- package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +26 -20
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +71 -0
- package/dist/node_modules/@allyhub/protocol/dist/turns.js +2 -0
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +12 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/dynamic.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/logical.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +10 -0
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/components.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +3 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +5 -0
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/dist/free.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/docs/batches.md +4 -4
- package/docs/contract.md +5 -5
- package/docs/defaults.md +2 -2
- package/docs/docs.md +16 -5
- package/docs/footage.md +8 -8
- package/docs/image.md +5 -5
- package/docs/layers.md +12 -10
- package/docs/linkedin.md +1 -1
- package/docs/modeling.md +3 -3
- package/docs/pictures.md +4 -4
- package/docs/project.md +11 -7
- package/docs/scenery.md +3 -3
- package/docs/sheets.md +5 -5
- package/docs/slides.md +3 -3
- package/docs/sound.md +7 -7
- package/docs/speech.md +7 -7
- package/docs/video.md +3 -3
- package/docs/websites.md +3 -3
- package/docs/x.md +2 -2
- package/package.json +1 -1
|
@@ -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
|
|
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}}
|
|
@@ -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";
|
package/docs/batches.md
CHANGED
|
@@ -8,7 +8,7 @@ A piece's `matrix` says which versions of it are made. Each version is a **combo
|
|
|
8
8
|
|
|
9
9
|
- `lang` is the one dimension AllyHub reads: it picks the file of each item's script in that language and `assets/text/<lang>.json`, the first value being the default language. Its values are lowercase language tags (`en`, `zh-cn`). Without `lang`, a piece's languages are its script's and the shared text's, `allyhub.config.ts`'s `locales` first.
|
|
10
10
|
- Other dimensions are the piece's: its parts function reads them from `ctx.combo`.
|
|
11
|
-
- A name starts with a lowercase letter (then letters, digits, `_`, `-`); a value is letters, digits, `.`, `_`, `-`, each listed once. `size`, `format`, `piece`, `output`, `token`, `structure` and `id`
|
|
11
|
+
- A name starts with a lowercase letter (then letters, digits, `_`, `-`); a value is letters, digits, `.`, `_`, `-`, each listed once. `size`, `format`, `piece`, `output`, `token`, `structure` and `id` are reserved: give dimensions and slots other names. A wrong name or value is AK-M001.
|
|
12
12
|
- A combo's **key** is its names sorted, each `name=value`, joined with commas: `audience=dev,lang=en` (`default` when there are none). It filters commands' `--combo` (`--combo lang=zh-cn`); the rendered files carry its values, after the name of the piece's folder (`.allyhub/out/launch/launch.dev.en.mp4`).
|
|
13
13
|
|
|
14
14
|
## Slots
|
|
@@ -61,7 +61,7 @@ export default video({
|
|
|
61
61
|
| `seed` | number or string | 1 | Decides between equally good choices |
|
|
62
62
|
| `differ` | `{ slots?, first? }` | none | Any two chosen combos differ in at least `slots` slots (another structure counts as one); `first`: their openings differ, the first n slots of each structure, or these slots |
|
|
63
63
|
| `rules` | `[{ if?, require?, exclude? }]` | none | Over slots, dimensions and `structure`; a value is a name, `#tag` or a list of either. When every `if` holds, every `require` must hold and no `exclude` may. Each has a `require` or an `exclude` |
|
|
64
|
-
| `combos` | `Combo[]` | none: sampled | The slot combinations to make, chosen by the agent ([below](#the-agents-own-combos))
|
|
64
|
+
| `combos` | `Combo[]` | none: sampled | The slot combinations to make, chosen by the agent ([below](#the-agents-own-combos)), in place of `pick` and `seed` |
|
|
65
65
|
|
|
66
66
|
- A rule's condition on a slot a combo's structure lacks never holds. A condition on a dimension is kept when the slot combinations are crossed with the dimensions: a crossing it rules out is not made.
|
|
67
67
|
- A candidate's tags are what `#tag` matches. A part's own `tags` are labels for people and tools; rules do not read them.
|
|
@@ -87,11 +87,11 @@ Without `combos`, sampling chooses `pick` slot combinations, the same for the sa
|
|
|
87
87
|
5. differ most from the nearest earlier pick;
|
|
88
88
|
6. then the seed decides.
|
|
89
89
|
|
|
90
|
-
Each pick keeps a reason in a few words. Sampling looks at
|
|
90
|
+
Each pick keeps a reason in a few words. Sampling looks at up to 100,000 slot combinations before the rules (more is AK-X002).
|
|
91
91
|
|
|
92
92
|
## The agent's own combos
|
|
93
93
|
|
|
94
|
-
`combos` names the slot combinations to make, in order: each names `structure` when the piece declares structures, and one candidate per slot of it
|
|
94
|
+
`combos` names the slot combinations to make, in order: each names `structure` when the piece declares structures, and one candidate per slot of it; the dimensions are crossed with them. Nothing is sampled.
|
|
95
95
|
|
|
96
96
|
```ts file=ads/chosen/chosen.ts
|
|
97
97
|
import { part, video } from "@allyhub/sdk";
|
package/docs/contract.md
CHANGED
|
@@ -5,11 +5,11 @@ What the build, the check and the render rely on. Everything else is the piece's
|
|
|
5
5
|
## A frame depends only on its time
|
|
6
6
|
|
|
7
7
|
- A piece is drawn in a page, a moment at a time, in any order: the check draws moments out of order and compares them with the same moments drawn in order (AK-D002), and the render draws parts on several pages at once and keeps what it drew in the part cache.
|
|
8
|
-
- A layer's `mount` lays it out once; its `render(el, t, …)` sets every property that moves from `t` alone ([layers.md](layers.md)).
|
|
8
|
+
- A layer's `mount` lays it out once; its `render(el, t, …)` sets every property that moves from `t` alone ([layers.md](layers.md)). Each `render` call works from `t` and what `mount` made. A deck mounts a slide's components when the slide is shown and may let the slide go and mount them again later, on a new element: what `mount` made that the page does not free with the element (a WebGL context, a worker, a timer) is let go in `unmount(el, …)`, and each mount starts afresh.
|
|
9
9
|
- Piece code sees the moment's clock, not the wall's: `Date`, `Date.now()` and `performance.now()` read the moment being drawn (time 0 is 2026-01-01T00:00:00Z); `Math.random()` and `crypto.getRandomValues()` are seeded by the piece's id, the combo, the part and the frame; `requestAnimationFrame` callbacks run at the moment; `setTimeout` and `setInterval` never fire. Use `rand(seed)` and the noise functions for randomness of your own.
|
|
10
|
-
- CSS animations and transitions run on the browser's clock:
|
|
10
|
+
- CSS animations and transitions run on the browser's clock: drive the picture from `t` in `render`.
|
|
11
11
|
- Work a layer must finish before anything is drawn (a 3D scenery's build, a picture decoding) goes through `ctx.wait(promise)`. Loading may take `loadLimit` seconds (AK-P002), one moment `seekLimit` seconds (AK-P003) ([defaults.md](defaults.md)).
|
|
12
|
-
- A part is rendered once and reused in every combo that has it: a layer reads the combo's dimensions and its own part's slot
|
|
12
|
+
- A part is rendered once and reused in every combo that has it: a layer reads the combo's dimensions and its own part's slot (another slot's pick is AK-X005, [batches.md](batches.md)).
|
|
13
13
|
|
|
14
14
|
## It is drawn offline
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ What the build, the check and the render rely on. Everything else is the piece's
|
|
|
21
21
|
## What goes wrong is a problem, not a wrong picture
|
|
22
22
|
|
|
23
23
|
- Every command reads the problems of each page it drew with and prints them, each under its rule: a layer that throws at 0.8 s (AK-R001), work it waits for that fails or does not settle, a picture that does not load (AK-A005), a 3D scenery that does not build (AK-W001). `ctx.report({ code, message })` reports one of a layer's own.
|
|
24
|
-
- A render
|
|
24
|
+
- A render makes a file from a drawing that raised no problem; it lists any other with why, and keeps it out of the part cache.
|
|
25
25
|
- What piece code prints with `console.log`, `info`, `warn`, `error` and `debug` is collected with where it ran (the module, a part, a layer, its moment) and printed by the commands after their own output. It changes no frame.
|
|
26
26
|
|
|
27
27
|
## Checks are for objective errors
|
|
@@ -44,7 +44,7 @@ What the build, the check and the render rely on. Everything else is the piece's
|
|
|
44
44
|
| `AK-X…` | The matrix and its combos |
|
|
45
45
|
| `AK-W…` | 3D sceneries |
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
A render makes its file once its errors are fixed. A warning is reported and the render goes on. What is a matter of judgment (text near a face, a loudness step between parts, a still stretch, a cut seam) is never a problem: it is a fact, with its numbers, which `allyhub inspect` prints for the agent to weigh.
|
|
48
48
|
|
|
49
49
|
## Defaults can be changed
|
|
50
50
|
|
package/docs/defaults.md
CHANGED
|
@@ -655,7 +655,7 @@ A camera filming the picture: a mark's values when it is asked for without them.
|
|
|
655
655
|
|
|
656
656
|
### `SHARE_ENCODE`
|
|
657
657
|
|
|
658
|
-
How `allyhub render` and an editor's
|
|
658
|
+
How `allyhub render` and an editor's Download encode an mp4 when nothing chooses otherwise, ready to share on social media: H.264's crf, and the most video bitrate in kbit/s for a frame of `width` × `height` at `fps`, scaled by the pixels a second of the video's own (16000 at 1080p 60, 32000 at 4K 30). `--param crf`, `--param max-bitrate` (0 for none).
|
|
659
659
|
|
|
660
660
|
| Key | Value |
|
|
661
661
|
| --- | --- |
|
|
@@ -667,7 +667,7 @@ How `allyhub render` and an editor's Export encode an mp4 when nothing chooses o
|
|
|
667
667
|
|
|
668
668
|
### `GIF_ENCODE`
|
|
669
669
|
|
|
670
|
-
How `allyhub render` and an editor's
|
|
670
|
+
How `allyhub render` and an editor's Download make a GIF when nothing chooses otherwise: its width in pixels (its height in proportion) and its frames a second, each never more than the video's own. `--param gif-width`, `--param gif-fps` (0 for the video's own).
|
|
671
671
|
|
|
672
672
|
| Key | Value |
|
|
673
673
|
| --- | --- |
|