@betteroffice/pptx-react 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,9 +28,20 @@ export function Presentation({ file, fontBytes }: {
28
28
  }
29
29
  ```
30
30
 
31
- `fonts` is required. Each entry is a family name and the bytes of a TTF or OTF file, for example
31
+ `fonts` is required. Byte faces supply a family name and the bytes of a TTF or OTF file, for example
32
32
  fetched from your server or loaded with `loadBundledFontBytes` from
33
33
  [`@betteroffice/fonts`](https://www.npmjs.com/package/@betteroffice/fonts).
34
+ You can also pass a bundled face from `@betteroffice/fonts` as a descriptor; the editor decodes it in its
35
+ worker without loading the main-thread decoder. The face serves the font it substitutes
36
+ (`face.metricCompatWith`, here Arial), or its own family when it substitutes none. `baseUrl` is where you self-host the font assets; omit it
37
+ when your bundler emits the package's assets:
38
+
39
+ ```tsx
40
+ import { resolveMetricCompatFace } from '@betteroffice/fonts';
41
+
42
+ const arial = resolveMetricCompatFace('Arial', false, false)!;
43
+ <PptxEditor file={file} fonts={[{ face: arial, baseUrl }]} />
44
+ ```
34
45
 
35
46
  ## Key options
36
47
 
@@ -40,7 +51,7 @@ optional except `fonts`.
40
51
  | prop | type | description |
41
52
  | --- | --- | --- |
42
53
  | `file` | `Uint8Array \| ArrayBuffer` | Presentation bytes to open. |
43
- | `fonts` | `ReadonlyArray<PptxFontFace>` | Font families and bytes for text layout. |
54
+ | `fonts` | `ReadonlyArray<PptxFontFace \| PptxBundledFont>` | Font bytes or bundled face descriptors for text layout. |
44
55
  | `readOnly` | `boolean` | Block user edits while retaining navigation and selection. |
45
56
  | `initialSlide` | `number` | Initial slide, numbered from 1 and clamped to the deck. |
46
57
  | `fileName` | `string` | Download name; defaults to `presentation.pptx`. |
@@ -66,7 +77,7 @@ optional except `fonts`.
66
77
  `PptxFontFace` and `DeckSnapshot` are exported by `@betteroffice/pptx`; editor and plugin types are
67
78
  exported by `@betteroffice/pptx-react`. `ReactNode` is a React type.
68
79
 
69
- Deprecated: `legacySyncApi` keeps the synchronous API on the in-thread engine and is removed in 0.6.0;
80
+ Deprecated: `legacySyncApi` keeps the synchronous API on the in-thread engine and is removed in 0.7.0;
70
81
  omit it to use the default async editor. Also omit the deprecated `experimentalWorkerOpen` prop.
71
82
 
72
83
  ## Editor API
@@ -92,12 +103,12 @@ The toolbar and Ctrl/Cmd+S invoke `onSaveRequest` before serialization. Its resu
92
103
  `onSave` receives the bytes, and the editor downloads the file using `fileName` when `downloadOnSave`
93
104
  is `true` (the default without `onSave`).
94
105
 
95
- Calling `save()` directly returns bytes without invoking those save callbacks.
106
+ On the default async API, `api.save()` skips `onSaveRequest` and never downloads; it returns the bytes and hands them to `onSave`.
96
107
 
97
108
  ## Toolbar
98
109
 
99
- The toolbar composition API is experimental. `api.commands` is shared by the built-in controls and
100
- host toolbar parts. Replace controls with
110
+ The toolbar composition API can change in minor releases. `api.commands` is shared by the
111
+ built-in controls and host toolbar parts. Replace controls with
101
112
  `toolbar`, or hide the region with `showToolbar={false}`.
102
113
  See [Compose the PPTX toolbar](https://docs.betteroffice.dev/docs/javascript#compose-the-pptx-toolbar)
103
114
  for composition, external controls, command state, and overflow.
@@ -108,10 +119,33 @@ use `EditorToolbar` with `mode="commands"`.
108
119
  ## Plugins
109
120
 
110
121
  `definePptxPlugin` defines tools installed through `plugins`, with permissions supplied by
111
- `pluginGrants`. This plugin API is experimental and may change in minor releases.
122
+ `pluginGrants`. This plugin API can change in minor releases.
112
123
  See [Host PPTX editor plugins](https://docs.betteroffice.dev/docs/javascript#host-pptx-editor-plugins)
113
124
  for panels, overlays, lifecycle, permissions, and error handling.
114
125
 
126
+ Plugins read `snapshot.focused` and `snapshot.locale`, and receive
127
+ `focus-change` and `locale-change`. Focus covers the document surface; docked panels
128
+ and toolbar controls are outside. Locale is the canonical `i18n._lang`, defaulting to `en`.
129
+ `geometry.viewport` is the visible document area in overlay-layer pixels;
130
+ `viewport-change` reports scroll, resize, or zoom changes, with `null` when no layout is shown.
131
+
132
+ Granted mutating built-in commands require `document: "write"`. A trusted `click`, `keydown`,
133
+ or `pointerup` in the plugin's own UI, including its contributed toolbar buttons, admits
134
+ that plugin's mutating calls until the event finishes dispatching, including the handler
135
+ and microtasks queued before it settles, whichever of the plugin's code paths makes them.
136
+ Another plugin's calls and calls after the window closes refuse with `unsupported-policy`.
137
+
138
+ `geometry.getAnchorGeometry(target)` accepts a `PptxGeometryTarget`: `selection`, or `range`
139
+ with `version`, `slideId`, `shapeId`, `storyId`, `anchor`, and `focus` in UTF-16 story offsets.
140
+ Selection anchors are live-only: a retained context whose selection has changed, including direction,
141
+ returns `layout-unavailable`; use a range target to keep a position.
142
+ Its `PptxAnchorGeometryResult` returns line rectangles, a focus-end anchor (a caret with
143
+ empty `rects` when collapsed), and the slide's `pageRect` in overlay pixels, plus `version`
144
+ and `layoutId`. Failures are `stale-version`, `missing-target`, or `layout-unavailable`.
145
+ A layout that is no longer presented answers `layout-unavailable` before anything else; then a range from another version answers `stale-version`; then a missing selection answers `missing-target`, and a target on another slide or a slide without displayed bounds answers `layout-unavailable`.
146
+ Shape and slide selections return their bounds. `readAnchorGeometries(targets)` returns
147
+ the same answers in order as a promise, without pending results. Both APIs are experimental.
148
+
115
149
  ## Version-checked edit batches
116
150
 
117
151
  `readContent`, `findText`, `validateEdits`, and `applyEdits` on the editor API return promises and run
@@ -0,0 +1 @@
1
+ function c(o){try{let t=new DataView(o.buffer,o.byteOffset,o.byteLength);if(t.byteLength<12)return;let n=0;if(t.getUint32(0)===1953784678){let e=t.getUint32(4),r=t.getUint32(8);if(e!==65536&&e!==131072||r===0||12+r*4+(e===131072?12:0)>t.byteLength)return;n=t.getUint32(12);}if(n+12>t.byteLength)return;let u=t.getUint32(n);if(u!==65536&&u!==1953658213&&u!==1330926671)return;let a=t.getUint16(n+4);if(n+12+a*16>t.byteLength)return;let i,f;for(let e=0;e<a;e++){let r=n+12+e*16,l=t.getUint32(r),g=t.getUint32(r+8),s=t.getUint32(r+12);if(g+s>t.byteLength)return;if(l===1330851634){if(i)return;i={offset:g,length:s};}else if(l===1751474532){if(f)return;f={offset:g,length:s};}}if(i){if(i.length<64)return;let e=t.getUint16(i.offset+62);return {weight:Math.max(1,Math.min(1e3,t.getUint16(i.offset+4))),bold:(e&32)!==0,italic:(e&1)!==0,oblique:(e&512)!==0}}if(f){if(f.length<46)return;let e=t.getUint16(f.offset+44);return {weight:e&1?700:400,bold:(e&1)!==0,italic:(e&2)!==0,oblique:!1}}}catch{return}}export{c as a};
@@ -0,0 +1 @@
1
+ import {d,P,G as G$1,R,H,$,U as U$1,K,aa,W,h,Q,m as m$1,n,ca,ea,_,k as k$1,l,M as M$1,D,Z,Y,O,V,ba as ba$1,J as J$1,X,T,S,b,p,o,r,q}from'./chunk-LFHLWZA4.js';import {a}from'./chunk-PSW72ZJN.js';import {m,a as a$1,c,j,k as k$2,d as d$1,h as h$1,f,e,g}from'./chunk-PS7ULZVL.js';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createContext,forwardRef,useRef,useId,useState,useCallback,useImperativeHandle,useEffect,useContext,useSyncExternalStore,useReducer,useMemo,useLayoutEffect}from'react';import {createPortal}from'react-dom';var ho={open:["editor.openError","editor.openErrorDescription"],stopped:["editor.stoppedError","editor.stoppedErrorDescription"],load:["editor.loadError","editor.loadErrorDescription"]},So={position:"absolute",inset:0,zIndex:3,justifyContent:"center",padding:24,background:"#ffffff"},vo={position:"absolute",left:0,right:0,bottom:0,zIndex:3,padding:"10px 16px",borderTop:"1px solid #e0e0e0",background:"#fafafa"},Pt={marginTop:4,padding:"6px 16px",border:"1px solid #dadce0",borderRadius:6,background:"#ffffff",color:"#202124",font:"inherit",cursor:"pointer"};function Jn({kind:e,details:o,onReload:t,children:n,className:r,style:a}){let{t:l}=d(),[s,c]=ho[e];return jsxs("div",{"data-testid":"pptx-error","data-failure":e,role:"alert",className:r,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,boxSizing:"border-box",textAlign:"center",color:"#202124",font:"14px ui-sans-serif, system-ui, sans-serif",...e==="stopped"?vo:So,...a},children:[jsx("strong",{style:{fontSize:e==="stopped"?14:16,fontWeight:600},children:l(s)}),jsx("span",{style:{maxWidth:420,color:"#5f6368"},children:l(c)}),t&&jsx("button",{type:"button",onClick:t,style:Pt,children:l("editor.reloadPage")}),n,o&&jsxs("details",{style:{maxWidth:480,color:"#5f6368",fontSize:12},children:[jsx("summary",{style:{cursor:"pointer"},children:l("editor.showDetails")}),jsx("pre",{style:{margin:"8px 0 0",whiteSpace:"pre-wrap",wordBreak:"break-word",textAlign:"start"},children:o})]})]})}var Qn=Pt;var J=createContext(null);function nr(){let e=useContext(J);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}var se=createContext(null),Tt=createContext(false);function wt({value:e,label:o,onChange:t,onClear:n,icon:r="textColor",none:a=false,clearLabel:l,disabled:s=false,description:c$1,testId:i}){let[x,p]=useState(false),h=m(),f=Z(s,c$1);return jsxs("span",{style:{display:"inline-flex",alignItems:"center",height:28},children:[jsxs("label",{title:Y(o,null,f.reason),"aria-label":o,style:{display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:6,background:x&&!s?a$1.hover:"transparent",color:x&&!s?a$1.ink:a$1.inkMuted,cursor:s?"default":"pointer",opacity:s?c:1,boxSizing:"border-box",position:"relative",...d$1(h.focusRing)},onMouseEnter:()=>p(true),onMouseLeave:()=>p(false),children:[jsx(U$1,{name:r}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:7,right:7,bottom:5,height:3,borderRadius:1,boxShadow:`inset 0 0 0 1px ${a$1.line}`,background:a?"transparent":e,border:a?`1px solid ${a$1.inkMuted}`:0,boxSizing:"border-box"}}),a?jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:7,bottom:6,width:14,height:1,background:"#d93025",transform:"rotate(-18deg)"}}):null,f.node,jsx("input",{"data-testid":i,type:"color",...h.focusProps,value:e,...f.props,"aria-label":o,onClick:b=>{s&&b.preventDefault();},onKeyDown:b=>{s&&(b.key==="Enter"||b.key===" ")&&b.preventDefault();},onChange:b=>{s||t?.(b.target.value);},style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]}),n?jsx("button",{type:"button",disabled:s,"aria-label":l??o,title:l??o,onMouseDown:b=>b.preventDefault(),onClick:n,style:{appearance:"none",width:15,height:28,padding:0,border:0,borderRadius:6,background:"transparent",color:a$1.inkMuted,cursor:s?"default":"pointer",opacity:s?c:1,font:"500 14px ui-sans-serif, system-ui, sans-serif"},children:"\xD7"}):null]})}function Se({value:e,options:o,label:t,onCommit:n,disabled:r=false,description:a,width:l=72,inputStyle:s,testId:c$1}){let i=Z(r,a),[x,p]=useState(e),[h,f]=useState(false),[b,S]=useState(null),[y,E]=useState(null),F=m(),[O,z]=useState({top:0,left:0,width:l}),P=useRef(null),K=useRef(null),N=useRef(null),d=useRef(false);useEffect(()=>{d.current=false,p(e);},[e]);let v=useCallback(()=>f(false),[]);useEffect(()=>{if(!h||!P.current)return;let m=P.current.getBoundingClientRect();z({top:m.bottom+4,left:m.left,width:Math.max(m.width,l)});},[h,l]),useEffect(()=>{if(!h)return;let m=D=>{let oe=D.target;!P.current?.contains(oe)&&!K.current?.contains(oe)&&v();},L=D=>{D.key==="Escape"&&(d.current=false,p(e),v());};return document.addEventListener("mousedown",m),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",L);}},[h,v,e]);let R=useCallback(()=>{d.current&&(d.current=false,p(e),!r&&n&&x.trim()&&n(x.trim()));},[r,n,x,e]);return jsxs("div",{ref:P,style:{display:"inline-flex",alignItems:"center",width:l,height:28,border:`1px solid ${a$1.line}`,borderRadius:6,background:a$1.surface,opacity:r?c:1,boxSizing:"border-box",flex:"0 0 auto",...d$1(F.focusRing)},children:[jsx("input",{ref:N,"data-testid":c$1,role:"combobox","aria-label":t,"aria-autocomplete":"list","aria-expanded":h,...i.props,readOnly:r,title:i.reason?Y(t,null,i.reason):void 0,value:x,onFocus:m=>{F.focusProps.onFocus(m),!r&&(f(true),m.currentTarget.select());},onChange:m=>{d.current=true,p(m.target.value);},onKeyDown:m=>{r||(m.key==="Enter"?(R(),v(),m.currentTarget.blur()):m.key==="Escape"?(d.current=false,p(e)):m.key==="ArrowDown"&&(f(true),m.preventDefault()));},onBlur:m=>{if(F.focusProps.onBlur(m),r){d.current=false,p(e);return}requestAnimationFrame(()=>{K.current?.contains(document.activeElement)||R();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:a$1.ink,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...s}}),i.node,jsx("button",{type:"button",disabled:r,tabIndex:-1,"aria-label":t,title:t,onMouseDown:m=>m.preventDefault(),onClick:()=>{r||(f(m=>!m),N.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:a$1.inkMuted,cursor:r?"default":"pointer"},children:jsx(U$1,{name:"chevronDown",size:18})}),h&&!r&&jsx("div",{ref:K,role:"listbox","aria-label":t,style:{position:"fixed",top:O.top,left:O.left,zIndex:1e4,width:O.width,maxHeight:260,overflowY:"auto",...j},children:o.map(m=>jsxs("button",{type:"button",role:"option","aria-selected":m.value===e,onMouseDown:L=>L.preventDefault(),onClick:()=>{d.current=false,p(m.label),n?.(m.value),v();},onMouseEnter:()=>S(m.value),onMouseLeave:()=>S(null),onFocus:()=>E(m.value),onBlur:()=>E(null),style:{...k$2({hovered:b===m.value,focusRing:y===m.value}),gap:6,minHeight:28,padding:"4px 8px 4px 4px"},children:[jsx("span",{style:{display:"inline-flex",width:18,flex:"0 0 auto"},children:m.value===e&&jsx(U$1,{name:"check",size:18})}),m.label]},m.value))})]})}var Re="pointer",Mt=false;function Fe(){if(Mt||typeof document>"u")return;Mt=true;let e=()=>{Re="pointer";};document.addEventListener("pointerdown",e,true),document.addEventListener("mousedown",e,true),document.addEventListener("keydown",()=>{Re="keyboard";},true);}function To(e,o){Fe(),!(Re!=="pointer"||o.ok&&o.status==="opened")&&requestAnimationFrame(()=>K(e)?.focusEditor());}function U(e,o,t){Fe(),e.execute(o,t).then(n=>To(e,n));}Fe();var ko={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",textColor:"textColor",insertSlide:"newSlide",insertImage:"insertImage",shapeFill:"fillColor",shapeStrokeColor:"borderColor",shapeStrokeWidth:"borderWidth",zOrder:"bringToFront",save:"save",exportPng:"image",undo:"undo",redo:"redo"},Ce={l:{icon:"alignLeft",labelKey:"toolbar.align.left",testId:"left"},ctr:{icon:"alignCenter",labelKey:"toolbar.align.center",testId:"center"},r:{icon:"alignRight",labelKey:"toolbar.align.right",testId:"right"},just:{icon:"alignJustify",labelKey:"toolbar.align.justify",testId:"justify"}},ze={forward:{icon:"bringForward",labelKey:"toolbar.bringForward"},backward:{icon:"sendBackward",labelKey:"toolbar.sendBackward"},front:{icon:"bringToFront",labelKey:"toolbar.bringToFront"},back:{icon:"sendToBack",labelKey:"toolbar.sendToBack"}},Rt=["forward","backward","front","back"],Io={bold:"pptx-bold",italic:"pptx-italic",underline:"pptx-underline",strikethrough:"pptx-strikethrough",insertSlide:"pptx-new-slide",insertImage:"pptx-insert-image",save:"pptx-save",exportPng:"pptx-export-png",undo:"pptx-undo",redo:"pptx-redo"};function M(e){return e.enabled?void 0:e.disabledReason.message}function G(e){return e&&typeof e=="object"?e:null}function Ke(e,o){let t=G(o)?.value;return e==="alignment"&&typeof t=="string"?Ce[t]?.icon:e==="zOrder"&&typeof t=="string"?ze[t]?.icon:e==="tool"&&typeof t=="string"?t==="select"?"select":t==="textBox"?"textBox":"shape":e==="fontSizeStep"?G(o)?.direction==="increase"?"add":"remove":ko[e]}function Ft(e,o,t,n){let r=G(o)?.value;if(e==="alignment"&&typeof r=="string"){let a=Ce[r];if(a)return t(a.labelKey)}if(e==="zOrder"&&typeof r=="string"){let a=ze[r];if(a)return t(a.labelKey)}if(e==="tool"&&typeof r=="string"){if(r==="select")return t("commands.selectTool");if(r==="textBox")return t("toolbar.textBoxTool");let a=h.find(l=>`shape:${l.geometry}`===r);if(a)return t(a.labelKey)}return e==="fontSizeStep"?t(G(o)?.direction==="increase"?"toolbar.increaseFontSize":"toolbar.decreaseFontSize"):n}function Mo(e,o){let t=G(o)?.value;if(e==="alignment"&&typeof t=="string"){let n=Ce[t];return n?`pptx-align-${n.testId}`:void 0}if(e==="tool"&&t==="select")return "pptx-tool-select";if(e==="tool"&&t==="textBox")return "pptx-tool-text-box";if(e==="fontSizeStep")return G(o)?.direction==="increase"?"pptx-font-size-increase":"pptx-font-size-decrease";if(!(e==="insertSlide"&&G(o)?.layoutPartPath!==void 0))return Io[e]}function Ae(e,o){return e==="tool"&&G(o)?.value==="select"}function At(e,o){return K(e)?.prepare(o)??{execute:t=>e.execute(o,t)}}function Pe(e,o,t,n,r){let a=e.getState(t,n),l=Ke(t,n);return {kind:"item",id:r,label:Ft(t,n,o,o(e.getDescriptor(t).labelKey)),icon:l?jsx(U$1,{name:l,size:16}):void 0,...Ae(t,n)?{shortcut:"Esc",ariaShortcut:"Escape"}:O(e,t,o,n),checked:a.active,disabled:!a.enabled,description:M(a),onSelect:()=>{e.execute(t,n??H(t));}}}function Lo(e,o,t){return (t.options??[]).map((n,r)=>({kind:"item",id:`${o}-${r}`,label:n.label,radio:true,checked:n.state.active===true,disabled:!n.state.enabled,description:n.state.enabled?void 0:n.state.disabledReason.message,onSelect:()=>{e.execute(o,n.args);}}))}function Oo(e,o,t,n){let r=e.getState(t),a=M(r),l=Lo(e,t,r);if(t==="insertSlide"&&l.unshift(Pe(e,o,"insertSlide",{},"insertSlide-current"),{kind:"separator",id:"insertSlide-separator"}),t==="fontSize"&&n.prompt){let s=n.prompt;l.push({kind:"item",id:"fontSize-custom",label:o("commands.customFontSize"),disabled:!r.enabled,description:a,onSelect:()=>{let c=At(e,"fontSize");s({title:o("toolbar.fontSize"),label:o("commands.fontSizePoints"),initialValue:typeof r.value=="number"?String(r.value):"",valid:i=>/^\d+(\.\d+)?$/.test(i)&&e.getState("fontSize",{points:Number(i)}).enabled,submit:i=>{c.execute({points:Number(i)});}});}});}return {kind:"submenu",id:t,label:o(e.getDescriptor(t).labelKey),disabled:!r.enabled,description:a,entries:l}}var zt={shapeFill:"toolbar.noFill",shapeStrokeColor:"toolbar.noBorder"};function ve(e){return {color:e}}function Ro(e,o,t,n){let r=e.getState(t),a=!r.enabled,l=M(r),s=typeof r.value=="string"?r.value:null,c=o(e.getDescriptor(t).labelKey),i=[],x=zt[t];if(x&&i.push({kind:"item",id:`${t}-clear`,label:o(x),radio:true,checked:r.value===null,disabled:a,description:l,onSelect:()=>{e.execute(t,ve(null));}}),n.prompt){let p=n.prompt;i.push({kind:"item",id:`${t}-custom`,label:o("commands.customColor"),disabled:a,description:l,onSelect:()=>{let h=At(e,t);p({title:c,label:o("commands.hexColor"),placeholder:"#1A73E8",initialValue:s??"",valid:f=>/^#?[0-9a-f]{6}$/i.test(f),submit:f=>{h.execute(ve(`#${f.replace(/^#/,"").toLowerCase()}`));}});}});}return {kind:"submenu",id:t,label:c,disabled:a,description:l,entries:i}}function Fo(e,o){let t=e.getState("zOrder");return {kind:"submenu",id:"zOrder",label:o(e.getDescriptor("zOrder").labelKey),disabled:!t.enabled,description:M(t),entries:Rt.map(n=>Pe(e,o,"zOrder",{value:n},`zOrder-${n}`))}}var Kt=new Set(["fontFamily","fontSize","alignment","insertSlide","tool","shapeStrokeWidth","shapeAdjustment","zoom","proposalSelect"]);function Ao(e,o,t,n,r={}){{if(Kt.has(t))return Oo(e,o,t,r);if(t==="textColor"||t==="shapeFill"||t==="shapeStrokeColor")return Ro(e,o,t,r);if(t==="zOrder")return Fo(e,o)}return Pe(e,o,t,n,t)}function zo(e,o,t){let n=P(),{t:r}=d(),a=useContext(V)?.prompt;W(e,()=>[Ao(n,r,o,t,{prompt:a})]);}function k(e){let{id:o,children:t,label:n,className:r,style:a}=e,l=P(),s=e.args,c=G$1(o)?null:o,i=R(o,s??(c?H(c):null)),{t:x}=d();if(!c&&i.descriptor===null)return null;let p=c?Ke(c,s):void 0,h=n??(c?Ft(c,s,x,i.label):i.label),f=jsx($,{active:i.state.active,disabled:!i.state.enabled,description:M(i.state),title:h,shortcut:(c&&Ae(c,s)?"Esc":i.shortcut)??void 0,ariaShortcut:(c&&Ae(c,s)?"Escape":i.ariaShortcut)??void 0,className:r,style:!p&&!t?{padding:"0 8px",...a}:a,testId:c?Mo(c,s):void 0,onClick:()=>{i.execute();},children:t??(p?jsx(U$1,{name:p}):h)});return G$1(o)?jsx("span",{"data-plugin-activation":K(l)?.pluginActivation(o),style:{display:"contents"},children:f}):f}function Ne({id:e,children:o,className:t,style:n}){let r=useRef(null);return zo(r,e),jsx("span",{ref:r,className:t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...n},children:o})}function Ko(){let e=P(),o=Q("fontFamily"),{t}=d();return jsx(ca,{title:t("toolbar.fontFamily"),disabled:!o.enabled,description:M(o),menuWidth:210,testId:"pptx-font-family",style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:o.value??t("toolbar.mixed")}),jsx(U$1,{name:"chevronDown",size:18})]}),children:n=>(o.options??[]).map(r=>jsx(ea,{label:r.label,radio:true,selected:o.value===r.args.family,onClick:()=>U(e,"fontFamily",r.args),close:n},r.args.family))})}function De(e){return Number.parseFloat(e.replace("%","").trim())}function No(){let e=P(),o=Q("fontSize"),{t}=d();return jsx(Se,{value:typeof o.value=="number"?String(o.value):"",options:(o.options??[]).map(n=>({value:String(n.args.points),label:n.label})),label:t("toolbar.fontSize"),disabled:!o.enabled,description:M(o),onCommit:n=>{let r=De(n);Number.isFinite(r)&&r>=k$1&&r<=l&&U(e,"fontSize",{points:r});},width:50,inputStyle:{textAlign:"center"},testId:"pptx-font-size"})}function Do(){let e=P(),o=Q("zoom"),{t}=d(),n$1=t("toolbar.fit"),r=o.value??"fit",a=r==="fit"?n$1:`${Math.round(r*100)}%`;return jsx(Se,{value:a,options:(o.options??[]).map(l=>({value:l.label,label:l.label})),label:t("toolbar.zoomValue",{value:a}),disabled:!o.enabled,description:M(o),onCommit:l=>{if(l===n$1){U(e,"zoom",{scale:"fit"});return}let s=De(l)/100;Number.isFinite(s)&&s>=m$1&&s<=n&&U(e,"zoom",{scale:s});},width:76,testId:"pptx-zoom"})}function Ho(){let e=P(),o=Q("alignment"),{t}=d();return jsx(Fragment,{children:(o.options??[]).map(n=>jsx(Bo,{store:e,value:n.args.value,t},n.args.value))})}function Bo({store:e,value:o,t}){let n=Q("alignment",{value:o}),r=Ce[o];return jsx(_,{title:t(r.labelKey),active:n.active,disabled:!n.enabled,description:M(n),onClick:()=>{e.execute("alignment",{value:o});},testId:`pptx-align-${r.testId}`,children:jsx(U$1,{name:r.icon})})}function Wo(){let e=P(),o=Q("insertSlide"),t=R("insertSlide",{}),{t:n}=d(),r=o.options??[];return jsxs(Fragment,{children:[jsx(_,{title:n("toolbar.newSlide"),disabled:!t.state.enabled,description:M(t.state),onClick:()=>{t.execute();},style:{borderRadius:"6px 0 0 6px"},testId:"pptx-new-slide",children:jsx(U$1,{name:"newSlide"})}),jsx(ca,{title:n("toolbar.newSlideWithLayout"),disabled:!o.enabled||r.length===0,description:M(o),menuWidth:230,testId:"pptx-new-slide-layout",style:{minWidth:20,width:20,padding:0,borderRadius:"0 6px 6px 0"},trigger:jsx(U$1,{name:"chevronDown",size:18}),children:a=>r.map((l,s)=>jsx(ea,{label:l.label,radio:true,selected:(l.args.layoutPartPath??null)===(o.value??null),onClick:()=>{e.execute("insertSlide",l.args);},close:a},l.args.layoutPartPath??`default-${s}`))})]})}function He(){let e=P(),o=Q("tool"),t=Q("tool",{value:"shape:rect"}),{t:n}=d(),r=useRef(null),a=useId();W(r,()=>[{kind:"submenu",id:a,label:n("toolbar.shapeTool"),disabled:!t.enabled,description:M(t),entries:h.map(s=>Pe(e,n,"tool",{value:`shape:${s.geometry}`},`${a}-${s.geometry}`))}]);let l=o.value??"select";return jsx("span",{ref:r,style:{display:"inline-flex",flex:"0 0 auto"},children:jsx(ca,{title:n("toolbar.shapeTool"),active:l.startsWith("shape:"),disabled:!t.enabled,description:M(t),menuWidth:264,testId:"pptx-tool-shape",style:{minWidth:46,padding:"0 4px"},trigger:jsxs(Fragment,{children:[jsx(U$1,{name:"shape"}),jsx(U$1,{name:"chevronDown",size:18})]}),children:s=>jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 44px)",gap:4,padding:2},children:h.map(c=>{let i=`shape:${c.geometry}`;return jsx("button",{type:"button",role:"menuitemradio",tabIndex:-1,"aria-checked":l===i,"data-testid":`pptx-shape-${c.geometry}`,"aria-label":n(c.labelKey),title:n(c.labelKey),onClick:()=>{s(),U(e,"tool",{value:i});},style:{appearance:"none",display:"grid",placeItems:"center",width:44,height:38,padding:5,border:`1px solid ${a$1.line}`,borderRadius:6,background:l===i?a$1.selected:a$1.surface,color:a$1.ink,cursor:"pointer"},children:jsx(Jo,{geometry:c.geometry})},c.geometry)})})})})}function jo(){let e=P(),o=Q("shapeStrokeWidth"),{t}=d();return jsx(ca,{title:t("toolbar.borderWidth"),disabled:!o.enabled,description:M(o),menuWidth:170,testId:"pptx-shape-border-width",trigger:jsx(U$1,{name:"borderWidth"}),children:n=>(o.options??[]).map(r=>jsx(ea,{label:r.label,radio:true,selected:o.value===r.args.points,icon:r.args.points===null?void 0:jsx("span",{"aria-hidden":"true",style:{width:18,borderTop:`${Math.min(r.args.points,5)}px solid currentColor`}}),onClick:()=>{e.execute("shapeStrokeWidth",r.args);},close:n},String(r.args.points)))})}function _o(){let e=P(),o=Q("shapeAdjustment"),{t}=d(),n=o.value;if(!n)return null;let r=o.options??[],a=r.length>0?r[r.length-1].args.value:1,l=a<1;return jsx(Se,{value:`${Math.round(n.value*100)}%`,options:r.map(s=>({value:String(Math.round(s.args.value*100)),label:s.label})),label:t(l?"toolbar.cornerRadius":"toolbar.shapeAdjustment"),disabled:!o.enabled,description:M(o),onCommit:s=>{let c=De(s);Number.isFinite(c)&&U(e,"shapeAdjustment",{name:n.name,value:Math.max(0,Math.min(a*100,c))/100});},width:68,inputStyle:{textAlign:"center"},testId:l?"pptx-shape-corner-radius":"pptx-shape-adjustment"})}function Zo({className:e}){let o=P(),t=Q("proposalSelect"),{t:n}=d(),r=!t.enabled;return jsx("select",{className:e,"aria-label":n("proposals.canvasTitle"),"aria-disabled":r||void 0,title:M(t),value:t.value??"",onChange:a=>{r||o.execute("proposalSelect",{proposalId:a.target.value});},style:{maxWidth:220,font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:(t.options??[]).map(a=>jsx("option",{value:a.args.proposalId,children:a.label},a.args.proposalId))})}function $o({id:e,className:o}){let t=null;switch(e){case "fontFamily":t=jsx(Ko,{});break;case "fontSize":t=jsx(No,{});break;case "alignment":t=jsx(Ho,{});break;case "insertSlide":t=jsx(Wo,{});break;case "tool":t=jsxs(Fragment,{children:[jsx(Lt,{value:"select"}),jsx(Lt,{value:"textBox"}),jsx(He,{})]});break;case "shapeStrokeWidth":t=jsx(jo,{});break;case "shapeAdjustment":t=jsx(_o,{});break;case "zoom":t=jsx(Do,{});break;case "proposalSelect":t=jsx(Zo,{});break}return e==="tool"?jsx("span",{className:o,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto"},children:t}):jsx(Ne,{id:e,className:o,children:t})}function Lt({value:e}){return jsx(k,{id:"tool",args:{value:e}})}var Uo={textColor:"pptx-text-color",shapeFill:"pptx-shape-fill",shapeStrokeColor:"pptx-shape-border-color"},Go={textColor:"#000000",shapeFill:"#d9eaf7",shapeStrokeColor:"#202124"};function Vo({id:e}){let o=P(),t=Q(e),{t:n}=d(),r=zt[e],a=typeof t.value=="string"?t.value:null,l=!t.enabled;return jsx(Ne,{id:e,children:jsx(wt,{value:a??Go[e],label:n(o.getDescriptor(e).labelKey),clearLabel:r?n(r):void 0,icon:Ke(e,void 0),none:!!r&&!a,disabled:l,description:M(t),onChange:s=>U(o,e,ve(s)),onClear:r?()=>{o.execute(e,ve(null));}:void 0,testId:Uo[e]})})}function Yo(){let e=P(),o=Q("zOrder"),{t}=d();return jsx(Ne,{id:"zOrder",children:jsx(ca,{title:t("toolbar.arrange"),disabled:!o.enabled,description:M(o),menuWidth:190,testId:"pptx-shape-arrange",trigger:jsx(U$1,{name:"bringToFront"}),children:n=>Rt.map(r=>jsx(qo,{store:e,value:r,close:n,t},r))})})}function qo({store:e,value:o,close:t,t:n}){let r=Q("zOrder",{value:o}),a=ze[o];return jsx(ea,{label:n(a.labelKey),icon:jsx(U$1,{name:a.icon,size:16}),disabled:!r.enabled,description:M(r),onClick:()=>{e.execute("zOrder",{value:o});},close:t})}function Xo(){return jsxs(Fragment,{children:[jsx(k,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(k,{id:"fontSizeStep",args:{direction:"increase"}})]})}function B(e){let{id:o,className:t}=e;if(G$1(o))return jsx(k,{id:o,className:t});let n=e.args;if(n===void 0){if(Kt.has(o))return jsx($o,{id:o,className:t});switch(o){case "textColor":case "shapeFill":case "shapeStrokeColor":return jsx(Vo,{id:o});case "zOrder":return jsx(Yo,{});case "fontSizeStep":return jsx(Xo,{});}}return jsx(k,{id:o,args:n,className:t})}function Jo({geometry:e}){let o={rect:"M3 5h18v14H3Z",roundRect:"M7 5h10a4 4 0 0 1 4 4v6a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a4 4 0 0 1 4-4Z",ellipse:"M3 12a9 7 0 1 0 18 0 9 7 0 1 0-18 0",triangle:"m12 4 9 16H3Z",rtTriangle:"M4 4v16h16Z",diamond:"m12 3 9 9-9 9-9-9Z",parallelogram:"M7 5h14l-4 14H3Z",trapezoid:"M7 5h10l4 14H3Z",pentagon:"m12 3 9 7-4 11H7L3 10Z",hexagon:"m7 4 10 0 5 8-5 8H7l-5-8Z",octagon:"m7 3 10 0 4 4v10l-4 4H7l-4-4V7Z",star5:"m12 2.5 2.8 6 6.5.6-5 4.3 1.6 6.4-5.7-3.4-5.7 3.4 1.6-6.4-5-4.3 6.5-.6Z",rightArrow:"M3 8h11V4l7 8-7 8v-4H3Z",leftArrow:"m21 8H10V4l-7 8 7 8v-4h11Z",upArrow:"M8 21V10H4l8-7 8 7h-4v11Z",downArrow:"M8 3v11H4l8 7 8-7h-4V3Z",chevron:"M4 4h9l7 8-7 8H4l7-8Z"}[e];return jsx("svg",{width:"30",height:"24",viewBox:"0 0 24 24",fill:"rgba(60, 64, 67, 0.08)",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:o})})}var tn=Object.freeze([]);function Dt(){let e=P(),o=K(e),t=useCallback(()=>o?.pluginToolbar()??tn,[o]),n=useSyncExternalStore(e.subscribe,t,t),{t:r}=d();return n.length===0?null:jsx(aa,{label:r("plugins.toolbarGroup"),children:n.map(a=>jsx(k,{id:a},a))})}var on={load:()=>import('./chunk-NEDOIGPO.js').then(e=>e.MenuList)},Te,Be;function Ht(){return Te}function We(){return Be??(Be=on.load().then(e=>Te=e,e=>{throw Be=void 0,e})),Be}function Bt(){if(Te)return ()=>{};let e=()=>{We().catch(()=>{});};if(typeof requestIdleCallback=="function"){let t=requestIdleCallback(e);return ()=>cancelIdleCallback(t)}let o=setTimeout(e,0);return ()=>clearTimeout(o)}function Wt(e){let o=t=>{if(!Te){if(t.key==="Escape"||t.key==="Tab"){e(t.key);return}t.preventDefault(),t.stopPropagation();}};return document.addEventListener("keydown",o,true),()=>document.removeEventListener("keydown",o,true)}var Zt=forwardRef(function({label:o,trigger:t,entries:n,colors:r,triggerClassName:a$1,triggerStyle:l,testId:s,onItemSelected:c},i){let x=useRef(null),p=useRef(new Set),h=useId(),[f,b]=useState(null),[,S]=useState(0),y=Ht(),[E,F]=useState(false),O=m(),z={...a,...r},P=useCallback(()=>b(null),[]);useImperativeHandle(i,()=>({focus:()=>x.current?.focus({preventScroll:true}),close:P}),[P]);let K=useCallback(d=>(p.current.add(d),()=>{p.current.delete(d);}),[]);useEffect(()=>{if(!f)return;let d=m=>{let L=m.target;if(!x.current?.contains(L)){for(let D of p.current)if(D.contains(L))return;P();}},v=()=>{let m=document.activeElement,L=[...p.current].some(D=>D.contains(m));P(),L&&x.current?.focus({preventScroll:true});},R=Wt(()=>P());return document.addEventListener("mousedown",d,true),window.addEventListener("resize",v),()=>{R(),document.removeEventListener("mousedown",d,true),window.removeEventListener("resize",v);}},[f,P]),useEffect(()=>Bt(),[]),useEffect(()=>{if(!f||y)return;let d=true;return We().then(()=>{d&&S(v=>v+1);},()=>{d&&(P(),x.current?.focus({preventScroll:true}));}),()=>{d=false;}},[f,P,y]);let N=useCallback(()=>x.current?.getBoundingClientRect()??null,[]);return jsxs("span",{style:{display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:x,type:"button",className:a$1,style:typeof l=="function"?l({hovered:E,open:f!==null,focusRing:O.focusRing}):l,...O.focusProps,onMouseEnter:()=>F(true),onMouseLeave:()=>F(false),"data-testid":s,"aria-label":o,title:o,"aria-haspopup":"menu","aria-expanded":f!==null,"aria-controls":f?h:void 0,onMouseDown:d=>d.preventDefault(),onClick:()=>b(d=>d?null:"menu"),onKeyDown:d=>{d.key==="Enter"||d.key===" "||d.key==="ArrowDown"?(d.preventDefault(),b("first")):d.key==="ArrowUp"&&(d.preventDefault(),b("last"));},children:t}),f&&y&&jsx(y,{id:h,label:o,entries:n,anchor:N,mode:"below",colors:z,initialFocus:f,onClose:d=>{P(),d!=="tab"&&x.current?.focus({preventScroll:true});},onSelect:(d,v)=>{P(),v==="keyboard"&&x.current?.focus({preventScroll:true}),d.onSelect(),c?.(v);},registerMenu:K})]})});var un={position:"absolute",visibility:"hidden",pointerEvents:"none",insetInlineStart:"0"},Ut={overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin"},cn=new WeakMap,Gt=new WeakMap,Vt=["a[href]","button",'input:not([type="hidden"])',"select","textarea","summary","[tabindex]",'[contenteditable]:not([contenteditable="false"])'].join(", ");function Xt(e,o){if(o.length===0)return false;let t=Array.from(e.querySelectorAll(Vt));return e.matches(Vt)&&t.push(e),t.every(n=>o.some(r=>r.contains(n)))}function Yt(e){let o=getComputedStyle(e),t=(parseFloat(o.marginLeft)||0)+(parseFloat(o.marginRight)||0);return e.getBoundingClientRect().width+t}function mn(e){let o=getComputedStyle(e),t=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0);return e.getBoundingClientRect().width-t}function Ue(e,o,t,n){let r=t.get(e);if(n===!!r)return false;let a=Object.keys(o);if(n){let l={};for(let s of a)l[s]=e.style[s],e.style[s]=o[s]??"";t.set(e,l);}else {for(let l of a)e.style[l]=r?.[l]??"";t.delete(e);}return true}function Ee(e,o){Ue(e,un,cn,o)&&(o?e.setAttribute("aria-hidden","true"):e.removeAttribute("aria-hidden"),e.inert=o);}function qt(e,o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect();n.left<t.left?e.scrollLeft-=t.left-n.left:n.right>t.right&&(e.scrollLeft+=Math.min(n.right-t.right,n.left-t.left));}function pn(e,o){return e.length===o.length&&e.every((t,n)=>t===o[n])}function Jt(e){let o=useRef(e);o.current=e;let[t,n]=useState([]),r=useRef(t);r.current=t;let a=useRef(e.moreWidth??32),l=useCallback(()=>{let{items:s,more:c,canHide:i,onFocusHidden:x}=o.current,p=s.current,h=p?.parentElement;if(!p||!h)return;let f=p.scrollLeft,b=c.current;b&&(a.current=Yt(b));let S=Array.from(p.children).filter(d=>d instanceof HTMLElement);for(let d of S)Ee(d,false);let y=parseFloat(getComputedStyle(p).columnGap)||0,E=mn(h),F=b?.style.position;b&&(b.style.position="absolute");let O=S.map(Yt);b&&(b.style.position=F??"");let z=O.reduce((d,v)=>d+v,0)+y*Math.max(0,S.length-1),P=[],K=false;if(z>E+.5){let d=E-a.current,v=S.map(L=>i(L)),R=S.reduce((L,D,oe)=>v[oe]?L:L+O[oe]+y,0),m=false;S.forEach((L,D)=>{if(v[D]){if(!m&&R+O[D]<=d){R+=O[D]+y;return}m=true,P.push(L);}}),K=R-y>(P.length>0?d:E)+.5;}Ue(p,Ut,Gt,K);for(let d of S)Ee(d,P.includes(d));for(let d of r.current)S.includes(d)||Ee(d,false);p.scrollLeft=f;let N=document.activeElement;N&&P.some(d=>d.contains(N))?x?.():K&&N&&p.contains(N)&&qt(p,N),pn(P,r.current)||(r.current=P,n(P));},[]);return useLayoutEffect(()=>{l();}),useLayoutEffect(()=>{let s=o.current.items.current;if(!s)return;let c=new Set,i=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>l()),x=()=>{if(i)for(let f of [s,s.parentElement,...Array.from(s.children)])f&&!c.has(f)&&(c.add(f),i.observe(f));};x();let p=typeof MutationObserver>"u"?null:new MutationObserver(()=>{x(),l();});p?.observe(s,{childList:true});let h=f=>{f.target instanceof Element&&qt(s,f.target);};return s.addEventListener("focusin",h),window.addEventListener("resize",l),document.fonts?.ready?.then(l,()=>{}),()=>{i?.disconnect(),p?.disconnect(),s.removeEventListener("focusin",h),window.removeEventListener("resize",l),Ue(s,Ut,Gt,false);for(let f of Array.from(s.children))f instanceof HTMLElement&&Ee(f,false);}},[l]),{hidden:t,remeasure:l}}var gn="input, button:not([disabled])",to={height:30,padding:"0 12px"};function no({prompt:e,onClose:o}){let{t}=d(),n=m(),r=m(),[a,l]=useState(e.initialValue??""),s=useRef(null),c=useRef(null),i=useId(),x=useId(),p=a.trim(),h=e.valid(p);return useLayoutEffect(()=>{c.current?.focus(),c.current?.select();},[]),jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(32, 33, 36, 0.32)"},onMouseDown:b=>{b.target===b.currentTarget&&o();},children:jsxs("form",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":i,onKeyDown:b=>{if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),o();return}if(b.key!=="Tab")return;let S=Array.from(s.current?.querySelectorAll(gn)??[]);if(S.length===0)return;let y=S.indexOf(document.activeElement),E=b.shiftKey?y<=0?S.length-1:y-1:y===S.length-1?0:y+1;b.preventDefault(),S[E].focus();},onSubmit:b=>{b.preventDefault(),h&&(o(),e.submit(p));},style:{width:"min(320px, 100%)",boxSizing:"border-box",padding:16,borderRadius:8,background:a$1.surface,color:a$1.ink,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.18)",font:"400 13px ui-sans-serif, system-ui, sans-serif"},children:[jsx("h2",{id:i,style:{margin:"0 0 12px",fontSize:15,fontWeight:600},children:e.title}),jsx("label",{htmlFor:x,style:{display:"block",marginBottom:4,fontSize:12},children:e.label}),jsx("input",{id:x,ref:c,value:a,placeholder:e.placeholder,"aria-invalid":p!==""&&!h,onChange:b=>l(b.target.value),style:{width:"100%",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${a$1.line}`,borderRadius:6,background:a$1.surface,color:a$1.ink,outlineColor:a$1.accent}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[jsx("button",{type:"button",onClick:o,...n.focusProps,style:{...f({focusRing:n.focusRing}),...to,border:`1px solid ${a$1.line}`,color:a$1.ink},children:t("commands.cancel")}),jsx("button",{type:"submit",disabled:!h,...r.focusProps,style:{...g({disabled:!h,focusRing:r.focusRing}),...to},children:t("commands.apply")})]})]})})}function hn(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"||e.tagName==="OPTION")}function Sn(e,o){return e===o?0:e.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Ye({children:e,className:o,style:t,testId:n}){let{t:r}=d(),a=P(),l=useRef(null),s=useRef(null),c=useRef(null),i=useRef(new Set),[x,p]=useReducer(d=>d+1,0),[,h]=useReducer(d=>d+1,0),[f$1,b]=useState(false),[S,y]=useState(null),E=useRef(false),F=useMemo(()=>({register(d){return i.current.add(d),p(),()=>{i.current.delete(d),p();}},overflowing:()=>E.current,changed(){E.current&&h();},prompt:y,anchor:()=>s.current?.querySelector("button")??null}),[]),O=useCallback(d=>{let v=[];for(let R of i.current){let m=R.element();m&&d.contains(m)&&v.push({element:m,source:R});}return v.sort((R,m)=>Sn(R.element,m.element))},[]),{hidden:z,remeasure:P$1}=Jt({items:l,more:s,canHide:d=>d.getAttribute("role")==="separator"||Xt(d,O(d).map(({element:v})=>v)),onFocusHidden:()=>b(true)});useLayoutEffect(()=>{P$1();},[x,P$1]),useLayoutEffect(()=>{!f$1||z.length===0||(b(false),c.current?.focus());},[f$1,z]),E.current=z.length>0,useEffect(()=>{if(z.length!==0)return a.subscribe(h)},[z.length,a]);let K$1=[];z.forEach((d,v)=>{let R=O(d).flatMap(({source:L})=>L.entries());if(R.length===0)return;let m=d.getAttribute("role")==="group"?d.getAttribute("aria-label"):null;K$1.push({kind:"group",id:`unit-${v}`,label:m??void 0,entries:R});});let N=K$1.flatMap((d,v)=>v===0?[d]:[{kind:"separator",id:`separator-${v}`},d]);return jsxs("div",{className:o,role:"toolbar","aria-label":r("toolbar.label"),"data-testid":n,onMouseDown:d=>{hn(d.target)||d.preventDefault();},style:{display:"flex",alignItems:"center",minWidth:0,...h$1,margin:"0 8px 4px",boxSizing:"border-box",...t},children:[jsx(V.Provider,{value:F,children:jsx("div",{ref:l,"data-toolbar-items":"",style:{position:"relative",display:"flex",alignItems:"center",flex:"1 1 auto",minWidth:0,overflow:"hidden"},children:e})}),z.length>0&&jsx("span",{ref:s,style:{display:"inline-flex",flex:"0 0 auto",marginLeft:4},children:jsx(Zt,{ref:c,label:r("toolbar.more"),trigger:jsx(U$1,{name:"more"}),entries:N,triggerStyle:f,testId:"pptx-toolbar-more",onItemSelected:d=>{d==="pointer"&&K(a)?.focusEditor();}})}),S&&jsx(no,{prompt:S,onClose:()=>{y(null),c.current?.focus();}})]})}function ba({label:e,onSelect:o,disabled:t,description:n,checked:r,children:a}){let l=useRef(null),s=useId();return W(l,()=>[{kind:"item",id:s,label:e,checked:r,disabled:t,description:t?n:void 0,onSelect:o}]),jsx("span",{ref:l,style:{display:"inline-flex",alignItems:"center",flex:"0 0 auto"},children:a})}function lo({children:e$1}){let{t:o}=d(),t=X(),n=useRef(null),r=useRef(null),a=T(),l=useCallback(y=>{r.current=y,a(y);},[a]),s=useId(),c=o("commands.moreControls"),[i,x]=useState(null),[p,h]=useState(null),[f,b]=useState({});W(n,()=>[{kind:"item",id:s,label:c,onSelect:()=>x({anchor:t?.anchor()??null,width:n.current?.getBoundingClientRect().width??0})}]);let S=useCallback(y=>{let E=i?.anchor;x(null),y&&E?.focus({preventScroll:true});},[i]);return useLayoutEffect(()=>{let y=r.current;if(!i||!y){h(null);return}let E=i.anchor?.getBoundingClientRect(),F=y.offsetWidth,O=Math.max(8,Math.min((E?.right??8)-F,window.innerWidth-F-8));h({top:(E?.bottom??8)+4,left:O}),b(e(i.anchor)),y.querySelector("button, input, select, textarea, a[href], [tabindex]")?.focus();},[i]),useEffect(()=>{if(!i)return;let y=F=>{r.current?.contains(F.target)||S(false);},E=()=>S(false);return document.addEventListener("mousedown",y),window.addEventListener("resize",E),()=>{document.removeEventListener("mousedown",y),window.removeEventListener("resize",E);}},[i,S]),jsxs(V.Provider,{value:null,children:[jsx("span",{ref:n,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",width:i?i.width:void 0},children:i?null:e$1}),i&&createPortal(jsx("div",{dir:"ltr",ref:l,role:"dialog","aria-label":c,tabIndex:-1,onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),S(true));},onBlur:y=>{let E=y.relatedTarget;E&&!r.current?.contains(E)&&S(false);},style:{position:"fixed",top:p?.top??0,left:p?.left??0,visibility:p?"visible":"hidden",zIndex:1e4,display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,maxWidth:"calc(100vw - 16px)",...j,...f},children:e$1}),document.body)]})}var kn={bold:"onFormat",italic:"onFormat",underline:"onFormat",strikethrough:"onFormat",fontFamily:"onFormat",fontSize:"onFormat",fontSizeStep:"onFormat",textColor:"onFormat",alignment:"onFormat",shapeFill:"onShapeFormat",shapeStrokeColor:"onShapeFormat",shapeStrokeWidth:"onShapeFormat",shapeAdjustment:"onShapeFormat",zOrder:"onShapeFormat",insertSlide:"onInsertSlide",insertImage:"onInsertImage",tool:"onToolChange",save:"onSave",exportPng:"onExportPng",undo:"onUndo",redo:"onRedo",zoom:"onZoomChange"},qe={ok:true,status:"requested"};function In(e,o$1){let t=e.currentFormatting??{},n=e.currentShapeFormatting??{};return {status:"ready",readOnly:false,reviewing:false,pendingInput:false,canUndo:e.canUndo??false,canRedo:e.canRedo??false,slide:{id:"",layoutPartPath:e.currentLayoutPartPath??null},layouts:(e.slideLayouts??[]).map((r,a)=>({args:{layoutPartPath:r.partPath},label:r.label??o$1("toolbar.layoutOption",{number:a+1})})),text:e.textSelectionActive?{kind:"range",bold:t.bold??false,italic:t.italic??false,underline:t.underline??false,strikethrough:t.strikethrough??false,fontFamily:t.fontFamily??null,fontSize:t.fontSize??null,color:t.textColor??null,alignment:t.align??null}:null,shape:e.shapeSelectionActive||e.shapeArrangeActive?{formattable:!!e.shapeSelectionActive,geometry:n.geometry??null,fill:n.fillColor??null,stroke:n.strokeColor??null,strokeWidth:n.strokeWidthPt??null,adjustments:n.adjustments??{},order:null}:null,tool:e.activeTool??"select",zoom:e.zoom??"fit",fontFamilies:e.fontFamilies??o,fontSizes:e.fontSizes??p,proposals:null,hostDisabled:r=>{let a=kn[r];return !!e.disabled||!a||!e[a]},translate:o$1}}function Mn(e,o,t){let n=o;switch(e){case "bold":case "italic":case "underline":case "strikethrough":return e;case "fontFamily":return {type:"fontFamily",value:n.family};case "fontSize":return {type:"fontSize",value:n.points};case "fontSizeStep":{let r$1=t.text&&t.text!=="unsupported"?t.text.fontSize:null;return {type:"fontSize",value:r(r$1??q,t.fontSizes,n.direction==="increase"?1:-1)}}case "textColor":return {type:"textColor",value:n.color};case "alignment":return {type:"align",value:n.value};default:return null}}function Ln(e,o){let t=o;switch(e){case "shapeFill":return {type:"fillColor",value:t.color};case "shapeStrokeColor":return {type:"strokeColor",value:t.color};case "shapeStrokeWidth":return {type:"strokeWidth",value:t.points};case "shapeAdjustment":return {type:"adjust",name:t.name,value:t.value};case "zOrder":return {type:"zOrder",value:t.value};default:return null}}function On(e,o,t,n){let r=Mn(o,t,n);if(r)return e.onFormat?.(r),qe;let a=Ln(o,t);if(a)return e.onShapeFormat?.(a),qe;let l=t;switch(o){case "insertSlide":e.onInsertSlide?.(l.layoutPartPath);break;case "insertImage":e.onInsertImage?.();break;case "tool":e.onToolChange?.(l.value);break;case "save":e.onSave?.();break;case "exportPng":e.onExportPng?.();break;case "undo":e.onUndo?.();break;case "redo":e.onRedo?.();break;case "zoom":e.onZoomChange?.(l.scale);break}return qe}function co(e){let{t:o}=d(),t=useRef({props:e,t:o});t.current={props:e,t:o};let[n]=useState(()=>{let r=J$1(),a={environment:()=>In(t.current.props,t.current.t),ordered:()=>false,admit:l=>Promise.resolve().then(l),perform:(l,s,c)=>On(t.current.props,l,s,c),capture:()=>({generation:0}),resume:()=>null,chrome:()=>({i18n:void 0}),focusEditor:()=>{}};return r.attach(a),r});return useLayoutEffect(()=>{n.refresh();}),n.store}function we(e){return e==="mixed"?void 0:e}function uo(e){let o={};for(let t of Object.keys(e))e[t]!==void 0&&(o[t]=e[t]);return o}function Rn(e){let o=i=>e.getState(i),t=(i,x)=>{e.execute(i,x);},n=o("fontFamily"),r=o("fontSize"),a=o("textColor"),l=o("alignment"),s=o("shapeAdjustment").value,c=o("insertSlide");return {currentFormatting:uo({bold:we(o("bold").active),italic:we(o("italic").active),underline:we(o("underline").active),strikethrough:we(o("strikethrough").active),fontFamily:n.value??void 0,fontSize:r.value??void 0,textColor:a.value??void 0,align:l.value??void 0}),textSelectionActive:o("bold").enabled,onFormat:i=>{typeof i=="string"?t(i,null):i.type==="fontFamily"?t("fontFamily",{family:i.value}):i.type==="fontSize"?t("fontSize",{points:i.value}):i.type==="textColor"?t("textColor",{color:i.value}):t("alignment",{value:i.value});},currentShapeFormatting:uo({fillColor:o("shapeFill").value,strokeColor:o("shapeStrokeColor").value,strokeWidthPt:o("shapeStrokeWidth").value,adjustments:s?{[s.name]:s.value}:void 0}),shapeSelectionActive:o("shapeFill").enabled,shapeArrangeActive:o("zOrder").enabled,onShapeFormat:i=>{i.type==="fillColor"?t("shapeFill",{color:i.value}):i.type==="strokeColor"?t("shapeStrokeColor",{color:i.value}):i.type==="strokeWidth"?t("shapeStrokeWidth",{points:i.value}):i.type==="adjust"?t("shapeAdjustment",{name:i.name,value:i.value}):t("zOrder",{value:i.value});},onInsertSlide:i=>t("insertSlide",i===void 0?{}:{layoutPartPath:i}),onInsertImage:()=>t("insertImage",null),slideLayouts:(c.options??[]).map(i=>({partPath:i.args.layoutPartPath??null,label:i.label})),currentLayoutPartPath:c.value??null,onSave:()=>t("save",null),onExportPng:()=>t("exportPng",null),onUndo:()=>t("undo",null),onRedo:()=>t("redo",null),canUndo:o("undo").enabled,canRedo:o("redo").enabled,zoom:o("zoom").value??"fit",onZoomChange:i=>t("zoom",{scale:i}),activeTool:o("tool").value??"select",onToolChange:i=>t("tool",{value:i}),fontFamilies:(n.options??[]).map(i=>i.args.family),fontSizes:(r.options??[]).map(i=>i.args.points),disabled:!o("save").enabled}}function mo(e){let[o,t]=useReducer(n=>n+1,0);return useEffect(()=>e.subscribe(t),[e]),useMemo(()=>Rn(e),[e,o])}var Fn=["currentFormatting","textSelectionActive","onFormat","currentShapeFormatting","shapeSelectionActive","shapeArrangeActive","onShapeFormat","onInsertSlide","onInsertImage","slideLayouts","currentLayoutPartPath","onSave","onExportPng","onUndo","onRedo","canUndo","canRedo","zoom","onZoomChange","activeTool","onToolChange","fontFamilies","fontSizes","disabled"];function Xe(e,o){let t=Fn.filter(n=>e[n]!==void 0);if(t.length>0)throw new Error(`${o} in command mode reads state from the editor's commands; remove ${t.join(", ")} or use mode="legacy".`)}function fo(){let{t:e}=d();return jsxs(Fragment,{children:[jsxs(aa,{label:e("toolbar.groups.history"),children:[jsx(k,{id:"undo"}),jsx(k,{id:"redo"})]}),jsx(ba$1,{}),jsxs(aa,{label:e("toolbar.groups.file"),children:[jsx(k,{id:"save"}),jsx(k,{id:"exportPng"})]}),jsx(aa,{label:e("toolbar.groups.slides"),children:jsx(B,{id:"insertSlide"})}),jsx(ba$1,{}),jsx(aa,{label:e("toolbar.groups.zoom"),children:jsx(B,{id:"zoom"})}),jsx(ba$1,{}),jsxs(aa,{label:e("toolbar.groups.tools"),children:[jsx(k,{id:"tool",args:{value:"select"}}),jsx(k,{id:"tool",args:{value:"textBox"}}),jsx(k,{id:"insertImage"}),jsx(He,{})]}),jsx(ba$1,{}),jsxs(aa,{label:e("toolbar.groups.font"),children:[jsx(B,{id:"fontFamily"}),jsx(k,{id:"fontSizeStep",args:{direction:"decrease"}}),jsx(B,{id:"fontSize"}),jsx(k,{id:"fontSizeStep",args:{direction:"increase"}})]}),jsx(ba$1,{}),jsxs(aa,{label:e("toolbar.groups.text"),children:[jsx(k,{id:"bold"}),jsx(k,{id:"italic"}),jsx(k,{id:"underline"}),jsx(k,{id:"strikethrough"}),jsx(B,{id:"textColor"})]}),jsx(ba$1,{}),jsx(aa,{label:e("toolbar.groups.alignment"),children:jsx(B,{id:"alignment"})}),jsx(ba$1,{}),jsxs(aa,{label:e("toolbar.groups.shape"),children:[jsx(B,{id:"shapeFill"}),jsx(B,{id:"shapeStrokeColor"}),jsx(B,{id:"shapeStrokeWidth"}),jsx(B,{id:"shapeAdjustment"}),jsx(B,{id:"zOrder"})]}),jsx(Dt,{})]})}function An(e){let o={};for(let t of Object.keys(e))e[t]!==void 0&&(o[t]=e[t]);return o}function zn(e){let o=useContext(J),t=o?{...o,...An(e)}:e,n=co(t);return jsx(M$1.Provider,{value:n,children:jsxs(Ye,{className:t.className,style:t.style,testId:"pptx-formatting-toolbar",children:[jsx(fo,{}),t.children?jsx(lo,{children:t.children}):null]})})}function Kn(e){return Xe(e,"Toolbar"),jsx(Ye,{className:e.className,style:e.style,testId:"pptx-formatting-toolbar",children:e.children??jsx(fo,{})})}function Je(e){let o=useContext(se);return (e.mode??o??"legacy")==="commands"?jsx(Kn,{...e,mode:"commands"}):jsx(zn,{...e})}var bo={display:"flex",flexDirection:"column",flex:"0 0 auto"};function Wn({i18n:e,children:o}){let t=K(P()),n=S(),r=useRef(null);return useLayoutEffect(()=>{let a=r.current;if(!(!a||!t))return t.registerChrome(a)},[t]),jsx("div",{ref:r,style:{display:"contents"},children:jsx(b,{i18n:e??n?.i18n,children:o})})}function jn(e){Xe(e,"EditorToolbar");let{children:o,className:t,style:n,i18n:r}=e,a=mo(P()),l=useContext(Tt),s=jsx(se.Provider,{value:"commands",children:jsx(J.Provider,{value:a,children:jsx("div",{className:t,"data-testid":"pptx-editor-toolbar",style:{...bo,...n},children:o??jsx(Je,{mode:"commands"})})})});return l?s:jsx(Wn,{i18n:r,children:s})}function _n({children:e,className:o,style:t,...n}){return jsx(se.Provider,{value:"legacy",children:jsx(J.Provider,{value:n,children:jsx("div",{className:o,"data-testid":"pptx-editor-toolbar",style:{...bo,...t},children:e})})})}function Zn(e){return e.mode==="commands"?jsx(jn,{...e}):jsx(_n,{...e})}var $n=Zn;$n.Toolbar=Je;var yo=new WeakMap,Un=/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9])?$/,Gn=new Set(["left","right","bottom"]),xo=e=>e!==null&&typeof e=="object"?Object.freeze({...e}):e;function Vn(e){return Array.isArray(e?.shortcuts)?Object.freeze({...e,shortcuts:Object.freeze([...e.shortcuts])}):xo(e)}function $a(e){let o={...e};o.panel!==void 0&&(o.panel=xo(o.panel)),Array.isArray(o.commands)&&(o.commands=Object.freeze(o.commands.map(Vn))),Array.isArray(o.toolbar)&&(o.toolbar=Object.freeze([...o.toolbar]));let t=Object.freeze(o),n=Object.freeze(t.revision===void 0?{id:t.id}:{id:t.id,revision:t.revision});return yo.set(n,t),n}function Ua(e){return e!==null&&typeof e=="object"?yo.get(e)??null:null}function go(e){return typeof e=="function"||e!==null&&typeof e=="object"}var Yn=/^f([1-9]|1[0-2])$/i;function qn(e){let o=D(e);if(o===null)return false;let t=o.split("+"),n=t[t.length-1];return t.includes("Mod")||t.includes("Alt")||Yn.test(n)}function Qe(e){return e===void 0||typeof e=="function"}function Ga(e){if(typeof e.createState!="function")return new TypeError("createState must be a function");if(!Qe(e.initialize)||!Qe(e.onEvent))return new TypeError("initialize and onEvent must be functions");if(e.overlay!==void 0&&!go(e.overlay))return new TypeError("overlay must be a component");let o=e.panel;if(o!==void 0&&(typeof o?.title!="string"||!Gn.has(o.placement)||!go(o.render)||o.preferredSize!==void 0&&!(Number.isFinite(o.preferredSize)&&o.preferredSize>0)))return new TypeError("panel needs a title, a left, right or bottom placement and a renderer");let t=e.commands??[];if(!Array.isArray(t))return new TypeError("commands must be an array");let n=new Set;for(let a of t){if(!Un.test(a?.id??""))return new TypeError(`Invalid command id ${JSON.stringify(a?.id)}`);if(n.has(a.id))return new TypeError(`Duplicate command id "${a.id}"`);if(n.add(a.id),typeof a.label!="string"||typeof a.mutatesDocument!="boolean"||typeof a.execute!="function"||!Qe(a.getState))return new TypeError(`Command "${a.id}" needs a label, mutatesDocument and execute`);let l=a.shortcuts??[];if(!Array.isArray(l)||l.some(s=>!qn(s)))return new TypeError(`Command "${a.id}" has an invalid shortcut`)}let r=e.toolbar??[];return !Array.isArray(r)||r.some(a=>!n.has(a))?new TypeError("toolbar may only list the plugin\u2019s own command ids"):null}export{Jn as a,Qn as b,J as c,nr as d,Tt as e,k as f,$o as g,B as h,Dt as i,Ht as j,We as k,Bt as l,Wt as m,ba as n,Je as o,$n as p,$a as q,Ua as r,Ga as s};
@@ -0,0 +1 @@
1
+ var c="legacySyncApi";export{c as a};
@@ -0,0 +1 @@
1
+ import {useMemo,useRef}from'react';var g="Font faces failed to load; text uses fallback fonts.";function F(){console.warn(g);}function P(n){return useMemo(()=>{let t=false;return ()=>{t||(t=true,F());}},[n])}async function h(n,t,o,s=F,a){if(!n.length||typeof FontFace>"u")return;let f=await Promise.all(n.map(async e=>{let r=await import('./chunk-TVOFTLAK.js').then(u=>u.readFontTraits(e.bytes)).catch(()=>{}),i=r?String(r.weight):e.bold?"700":"400",l=r?r.italic?"italic":r.oblique?"oblique":"normal":e.italic?"italic":"normal";return {font:e,weight:i,style:l}})),c=new Map;for(let e of f){let r=JSON.stringify([e.font.family,e.weight,e.style]),i=c.get(r);i?i.push(e):c.set(r,[e]);}let p=await Promise.allSettled([...c.values()].map(async e=>{let r;for(let{font:i,weight:l,style:u}of e){let d,y=i.bytes.slice().buffer;try{d=await new FontFace(i.family,y,{style:u,weight:l}).load();}catch(m){r=m;continue}if(!o())return;document.fonts.add(d),t.push(d),a?.({family:i.family,source:y,descriptors:{style:u,weight:l}});return}throw r}));o()&&p.some(e=>e.status==="rejected")&&s();}async function v(n,t=()=>true,o){let s=[];return typeof document<"u"&&await h(n,s,t,o),s}function k(n){let t=useRef(n);return t.current===n||(t.current.length!==n.length||!t.current.every((o,s)=>{let a=n[s];return o.family===a.family&&(o.bold??false)===(a.bold??false)&&(o.italic??false)===(a.italic??false)&&(o.bytes===a.bytes||o.bytes.length===a.bytes.length&&o.bytes.every((f,c)=>f===a.bytes[c]))}))&&(t.current=n),t.current}export{P as a,h as b,v as c,k as d};