pptx-vanilla-viewer 2.14.0 → 2.16.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 CHANGED
@@ -7,6 +7,52 @@ A release listed with no entries carried no Conventional Commit in this package'
7
7
  scope: scripts/release-plan.mjs re-releases a package whenever any of its files
8
8
  change, not only on conventional ones.
9
9
 
10
+ ## [2.15.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.15.0) - 2026-09-10
11
+
12
+ ### Features
13
+
14
+ - **shared:** Fit the combined a:camera/a:rot override to PowerPoint's orthographic model (by @ChristopherVR) ([4379b7f](https://github.com/ChristopherVR/pptx-viewer/commit/4379b7ff4951598a0d796450b60c264ddcfacebb))
15
+ - **core:** SmartArt corner-anchored hierarchies and the layout-definition type split (by @ChristopherVR) ([b3c9506](https://github.com/ChristopherVR/pptx-viewer/commit/b3c9506b5ca7858eb4e3ec6e28be987c3cacdcad))
16
+ - **shared:** Fit the twelve a:bevelT profiles to COM cross-sections and drop the metal/circle routing (by @ChristopherVR) ([f5519eb](https://github.com/ChristopherVR/pptx-viewer/commit/f5519eb61eddbae104ccc2aa0b130504f2e9c8a5))
17
+ - **core:** SmartArt anchor-aware predicates, nested cycles and centred-fan hierarchies (by @ChristopherVR) ([eee2c98](https://github.com/ChristopherVR/pptx-viewer/commit/eee2c98e43d24ea7dabeda8e627c025828f1cb39))
18
+ - **core:** Wire the hierarchy arranger to the resolved-orientation module (by @ChristopherVR) ([ab035ea](https://github.com/ChristopherVR/pptx-viewer/commit/ab035ea9c4e1c64f3a3d7ef7fd5aabe130dfa45f))
19
+ - **core:** SmartArt hub aspect fitting and ancestor userS resolution (by @ChristopherVR) ([9f9b534](https://github.com/ChristopherVR/pptx-viewer/commit/9f9b53469e3c59ee07968405acb408cce7d0522b))
20
+
21
+ ### Bug Fixes
22
+
23
+ - **core:** Terminate .ppt shape names so PowerPoint opens named shapes (by @ChristopherVR) ([7d8f842](https://github.com/ChristopherVR/pptx-viewer/commit/7d8f8423c95d4fe5fc88ad0a77d2281369b001ac))
24
+ - **shared:** Size the WordArt envelope band from the line's real ascent (by @ChristopherVR) ([9d6267b](https://github.com/ChristopherVR/pptx-viewer/commit/9d6267b32a4602e4717a2cfa8734374875d50c05))
25
+ - **core:** Restore the generation-template call sites swept into eee2c98e4 (by @ChristopherVR) ([ffee234](https://github.com/ChristopherVR/pptx-viewer/commit/ffee2341f16c225a065e3886cc23a4b58a3ccdf4))
26
+
27
+ ### Testing
28
+
29
+ - **core:** Make the SmartArt gallery gate opt-in and give the .ppt password test its PBKDF2 budget (by @ChristopherVR) ([0ff5e2b](https://github.com/ChristopherVR/pptx-viewer/commit/0ff5e2bc5a51513bf1d975148cda96407e03ba53))
30
+
31
+ ## [2.14.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.14.0) - 2026-09-10
32
+
33
+ ### Features
34
+
35
+ - **shared:** Make every dense panel usable at 360px in all five bindings (by @ChristopherVR) ([f560f4a](https://github.com/ChristopherVR/pptx-viewer/commit/f560f4a5e0d0efc83819f3ea0d30816dcc878a59))
36
+ - **shared:** COM-calibrate the a:lightRig elevation table for all 27 rigs (by @ChristopherVR) ([e0db035](https://github.com/ChristopherVR/pptx-viewer/commit/e0db03513aa2099e6a235dd47f50cc618c456f1d))
37
+ - **core:** Read OLE embeds back from legacy .ppt decks (by @ChristopherVR) ([2f1a9a6](https://github.com/ChristopherVR/pptx-viewer/commit/2f1a9a601ffc9a2e7dff691622ccddf3eb109e8e))
38
+ - **shared:** Tile GIF, video, notes-PDF and print captures past the canvas cap (by @ChristopherVR) ([4cdd3e5](https://github.com/ChristopherVR/pptx-viewer/commit/4cdd3e55cc8eb3ffc96d22060521f0f36efe997f))
39
+ - **core:** SmartArt hang ratios, cascade reserve, generation margins and hub font fit (by @ChristopherVR) ([8ccd7cc](https://github.com/ChristopherVR/pptx-viewer/commit/8ccd7ccec858642fe568cfe310128dd263db3721))
40
+ - **shared:** Decide GIF and video capture scale and cap once for all bindings (by @ChristopherVR) ([ad3adfa](https://github.com/ChristopherVR/pptx-viewer/commit/ad3adfa527fe288d380cd22132543f51e30c3027))
41
+ - **shared:** Warp WordArt envelope glyphs by their real outlines (by @ChristopherVR) ([1e67d70](https://github.com/ChristopherVR/pptx-viewer/commit/1e67d70a0cb9c5fb9ab967c69987fd39fa267d59))
42
+
43
+ ### Bug Fixes
44
+
45
+ - **react,vue,angular,svelte,vanilla:** Guard OLE editor state after unmount and steady three e2e specs (by @ChristopherVR) ([6bc1e4c](https://github.com/ChristopherVR/pptx-viewer/commit/6bc1e4c27e98f4f132358a64ea5cb694a9b39af2))
46
+ - **angular,vanilla:** Give the AI history menu its 44px touch targets and steady two e2e specs (by @ChristopherVR) ([8e06a7f](https://github.com/ChristopherVR/pptx-viewer/commit/8e06a7f74e0a1e5636c22dc897176f3990daa737))
47
+
48
+ ### Documentation
49
+
50
+ - **shared:** Record the metal/circle re-measurement and the failed decoupling (by @ChristopherVR) ([57fd7c2](https://github.com/ChristopherVR/pptx-viewer/commit/57fd7c2c944ab171f985903cb11e0da8c389e891))
51
+
52
+ ### Testing
53
+
54
+ - **core:** Pin PowerPoint's property-order dependence for combined rotated group edits (by @ChristopherVR) ([dc6692e](https://github.com/ChristopherVR/pptx-viewer/commit/dc6692ebaaaeb6fe28ce635e9ec3c69f4e46c89d))
55
+
10
56
  ## [2.13.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.13.0) - 2026-09-10
11
57
 
12
58
  ### Features
@@ -0,0 +1 @@
1
+ 'use strict';var chunkE4XP3H6S_cjs=require('./chunk-E4XP3H6S.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkE4XP3H6S_cjs.so(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-focus-row"),f=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkE4XP3H6S_cjs.Tn(p,o.getSlides())){let b=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-focus-actions"),d=chunkE4XP3H6S_cjs.Un(p,o.getSlides());if(d){let r=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkE4XP3H6S_cjs.so(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkE4XP3H6S_cjs.Vn(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-focus-pick"),b=chunkE4XP3H6S_cjs.so(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkE4XP3H6S_cjs.so(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-history-head"),x=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkE4XP3H6S_cjs.so(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-history-body"),m=chunkE4XP3H6S_cjs.eo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkE4XP3H6S_cjs.Xn({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=chunkE4XP3H6S_cjs.eo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkE4XP3H6S_cjs.eo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkE4XP3H6S_cjs.eo(t,"li","pptxv-ai-history-row"),r=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-history-text"),k=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkE4XP3H6S_cjs.so(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(chunkE4XP3H6S_cjs.so(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=chunkE4XP3H6S_cjs.ao(t.toolName,t.input,h?"present":"past"),c=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-tool"),p=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-tool-head"),m=chunkE4XP3H6S_cjs.so(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkE4XP3H6S_cjs.eo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkE4XP3H6S_cjs.eo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkE4XP3H6S_cjs.so(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkE4XP3H6S_cjs.so(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkE4XP3H6S_cjs.$n(t.input);if(g){let f=chunkE4XP3H6S_cjs.eo(o,"details","pptxv-ai-tool-details"),C=chunkE4XP3H6S_cjs.eo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkE4XP3H6S_cjs._n(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=chunkE4XP3H6S_cjs.Pn(a);if(x.length===0&&!h)continue;let c=chunkE4XP3H6S_cjs.eo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkE4XP3H6S_cjs.so(o,h?"comment":"sparkles"));let m=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-proposals-header"),x=chunkE4XP3H6S_cjs.eo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkE4XP3H6S_cjs.eo(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkE4XP3H6S_cjs.eo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkE4XP3H6S_cjs.eo(o,"li");g.textContent=chunkE4XP3H6S_cjs.Mn(s),l.appendChild(g);}a.appendChild(l);}let c=chunkE4XP3H6S_cjs.eo(o,"div","pptxv-ai-proposal-actions"),p=chunkE4XP3H6S_cjs.eo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkE4XP3H6S_cjs.so(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkE4XP3H6S_cjs.eo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkE4XP3H6S_cjs.so(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-header"),h=chunkE4XP3H6S_cjs.eo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkE4XP3H6S_cjs.so(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkE4XP3H6S_cjs.so(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkE4XP3H6S_cjs.eo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkE4XP3H6S_cjs.eo(t,"form","pptxv-ai-composer"),d=chunkE4XP3H6S_cjs.eo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkE4XP3H6S_cjs.eo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkE4XP3H6S_cjs.so(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkE4XP3H6S_cjs.Yn)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:chunkE4XP3H6S_cjs.Wn(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>chunkE4XP3H6S_cjs.Pn(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=chunkE4XP3H6S_cjs.bo(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}exports.createAiPanel=wt;
@@ -0,0 +1 @@
1
+ import {eo,so,Yn,Wn,Xn,Pn,bo,Tn,Un,Vn,ao,$n,_n,Mn}from'./chunk-2PATLFBX.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=eo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=eo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(so(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=eo(t,"div","pptxv-ai-focus-row"),f=eo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Tn(p,o.getSlides())){let b=eo(t,"span","pptxv-ai-focus-chip");(m||l)&&b.classList.add("is-strong"),b.title=r.title,b.textContent=r.label,g.appendChild(b);}if(l){let r=eo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=eo(t,"div","pptxv-ai-focus-actions"),d=Un(p,o.getSlides());if(d){let r=eo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(so(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Vn(d.slideIndex,d.elementIdA,d.elementIdB))),C.appendChild(r);}let y=h("crosshair",n("pptx.ai.pickElement"),()=>s?i.stopPicking():i.startPicking());if(y.setAttribute("aria-pressed",String(s)),y.classList.toggle("is-active",s),C.appendChild(y),m?C.appendChild(h("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):l?C.appendChild(h("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):C.appendChild(h("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),g.appendChild(C),a.appendChild(g),s){let r=eo(t,"div","pptxv-ai-focus-pick"),b=so(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=eo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=eo(t,"button","pptxv-ai-focus-pick-done");T.type="button",T.textContent=n("pptx.ai.pickDone"),T.addEventListener("click",()=>i.stopPicking()),r.append(b,k,T),a.appendChild(r);}},c=i.subscribe(x);return x(),{el:a,destroy(){c(),a.remove();}}}function O(o){let{doc:t,t:n}=o,i=eo(t,"button","pptxv-ai-chats");i.type="button",i.append(so(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=eo(t,"div","pptxv-ai-history");a.hidden=true;let h=eo(t,"div","pptxv-ai-history-head"),x=eo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=eo(t,"button","pptxv-ai-history-new");c.type="button",c.append(so(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=eo(t,"div","pptxv-ai-history-body"),m=eo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Xn({deckId:o.deckId,store:o.store,getMessages:o.getMessages,setMessages:o.setMessages,untitledLabel:n("pptx.ai.untitledChat"),onChatsChanged:()=>s()});function s(){p.replaceChildren();let f=l.chats();if(f.length===0){let d=eo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=eo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=eo(t,"li","pptxv-ai-history-row"),r=eo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=eo(t,"span","pptxv-ai-history-text"),k=eo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=eo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(so(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=eo(t,"button","pptxv-ai-history-delete");P.type="button",P.title=n("pptx.ai.deleteChat"),P.setAttribute("aria-label",n("pptx.ai.deleteChat")),P.appendChild(so(t,"trash")),P.addEventListener("click",()=>{l.deleteChat(d.id);}),y.append(r,P),C.appendChild(y);}p.appendChild(C);}s(),i.addEventListener("click",()=>{a.hidden=!a.hidden;}),c.addEventListener("click",()=>{l.newChat(),a.hidden=true;});let g=f=>{a.hidden||!(f.target instanceof Node)||!a.contains(f.target)&&!i.contains(f.target)&&(a.hidden=true);};return t.addEventListener("mousedown",g),{button:i,el:a,notifyMessagesChanged:()=>l.notifyMessagesChanged(),destroy(){t.removeEventListener("mousedown",g),l.dispose(),i.remove(),a.remove();}}}var _={view:"eye",text:"text-box",shape:"shapes",theme:"font-color",table:"table",slide:"layout",chart:"chart",move:"move-right",delete:"trash",search:"search",nav:"move-right",animation:"play",notes:"sticky-note",tool:"wrench"};function W(o,t,n){let i=t.state==="output-error",a=t.state==="output-available",h=!i&&!a,x=ao(t.toolName,t.input,h?"present":"past"),c=eo(o,"div","pptxv-ai-tool"),p=eo(o,"div","pptxv-ai-tool-head"),m=so(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=eo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=eo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(so(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(so(o,"check"),o.createTextNode(n("pptx.ai.toolDone")))):(s.classList.add("is-running"),s.textContent=n("pptx.ai.toolRunning")),p.append(m,l,s),c.appendChild(p),i&&t.errorText){let f=eo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=$n(t.input);if(g){let f=eo(o,"details","pptxv-ai-tool-details"),C=eo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=eo(o,"div","pptxv-ai-tool-raw");d.textContent=`${_n(t.toolName)}: ${g}`,f.append(C,d),c.appendChild(f);}return c}function q(o,t,n,i){t.replaceChildren();for(let a of n){if(a.role==="system")continue;let h=a.role==="user",x=Pn(a);if(x.length===0&&!h)continue;let c=eo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=eo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(so(o,h?"comment":"sparkles"));let m=eo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=eo(o,"div","pptxv-ai-msg-text");s.textContent=l.text,m.appendChild(s);}else m.appendChild(W(o,l,i));c.append(p,m),t.appendChild(c);}}function G(o,t,n,i,a){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let h=eo(o,"div","pptxv-ai-proposals-header"),x=eo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=eo(o,"button","pptxv-ai-proposal-btn is-accept-all");c.type="button",c.textContent=i("pptx.ai.acceptAll"),c.addEventListener("click",()=>a.acceptAll()),h.appendChild(c);}t.appendChild(h);for(let c of n)t.appendChild(tt(o,c,i,a));}function tt(o,t,n,i){let a=eo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=eo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=eo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=eo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=eo(o,"li");g.textContent=Mn(s),l.appendChild(g);}a.appendChild(l);}let c=eo(o,"div","pptxv-ai-proposal-actions"),p=eo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(so(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=eo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(so(o,"close"),o.createTextNode(n("pptx.ai.reject"))),m.addEventListener("click",()=>i.reject(t.id)),c.append(p,m),a.appendChild(c),a}async function wt(o){let{doc:t,host:n,t:i}=o;n.replaceChildren();let a=eo(t,"div","pptxv-ai-header"),h=eo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=eo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(so(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(so(t,"sparkles"),h,x);let c,p=o.controller,m=p?K({doc:t,t:i,controller:p,getSlides:()=>o.bridge.getSlides(),onSendDirective:u=>{c?.sendMessage(u);}}):null,l=eo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=eo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=eo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=eo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=eo(t,"form","pptxv-ai-composer"),d=eo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=eo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(so(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Yn)({bridge:o.bridge,config:o.config});}catch{return s.textContent=i("pptx.ai.unavailableTitle"),d.disabled=true,y.disabled=true,m?.destroy(),{destroy:()=>n.replaceChildren()}}let r=c,b=O({doc:t,t:i,deckId:Wn(o.bridge),store:o.historyStore,getMessages:()=>r.getSnapshot().messages,setMessages:u=>r.setMessages(u)});a.insertBefore(b.button,x),n.appendChild(b.el);let k=r.subscribe(()=>b.notifyMessagesChanged()),T=new Set,P=u=>{if(!p)return;let A=u.messages.flatMap(Y=>Pn(Y).filter(Z=>Z.kind==="tool")).at(-1);if(!A||A.kind!=="tool"||A.state==="input-streaming"||T.has(A.toolCallId))return;T.add(A.toolCallId);let L=bo(A.toolName,A.input);L&&L.slideIndex!==void 0&&o.goToSlide?.(L.slideIndex),p.flashToolTarget(L);},M=u=>{q(t,l,u.messages,i),s.hidden=u.messages.length>0,u.messages.length===0&&l.appendChild(s),G(t,g,r.proposals.list(),i,{accept:A=>{p?.flashToolTarget(null),r.proposals.apply(A),M(r.getSnapshot());},reject:A=>{r.proposals.revert(A),M(r.getSnapshot());},acceptAll:()=>{p?.flashToolTarget(null),r.proposals.acceptAll(),M(r.getSnapshot());}});let w=u.status==="submitted"||u.status==="streaming";n.classList.toggle("is-busy",w),y.setAttribute("aria-label",i(w?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!u.error,f.textContent=u.error?i("pptx.ai.errorPrefix"):"",l.scrollTop=l.scrollHeight,P(u);},S=()=>{if(n.classList.contains("is-busy")){r.stop();return}let u=d.value.trim();u&&(d.value="",r.sendMessage(u));};C.addEventListener("submit",u=>{u.preventDefault(),S();}),d.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),S());});let I=p?.getPrefill().nonce??0,J=()=>{if(!p)return;let u=p.getPrefill();u.nonce!==I&&(I=u.nonce,d.value=u.text,d.focus());},Q=p?.subscribe(J),X=r.subscribe(M);return M(r.getSnapshot()),{changeAnimator:r.changeAnimator,destroy(){X(),k(),b.destroy(),Q?.(),m?.destroy(),n.replaceChildren();}}}export{wt as createAiPanel};