pptx-vanilla-viewer 2.10.0 → 2.12.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,46 @@ 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.11.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.11.0) - 2026-09-10
11
+
12
+ ### Features
13
+
14
+ - **core:** Fit SmartArt layouts to PowerPoint's measured geometry (by @ChristopherVR) ([4f689ef](https://github.com/ChristopherVR/pptx-viewer/commit/4f689eff63edce2fa584929c54224142e3a20faf))
15
+
16
+ ### Testing
17
+
18
+ - **vanilla,svelte:** Poll for the asynchronous OLE workbook commit (by @ChristopherVR) ([17842d4](https://github.com/ChristopherVR/pptx-viewer/commit/17842d4116a8b0693866f4fa66832b8be416d2e6))
19
+
20
+ ## [2.10.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.10.0) - 2026-09-09
21
+
22
+ ### Features
23
+
24
+ - **core:** Check salt-less modify verifiers instead of unlocking blindly (by @ChristopherVR) ([7c7f1da](https://github.com/ChristopherVR/pptx-viewer/commit/7c7f1da9f43e2d0836e675777d0f3036a0792c4e))
25
+ - **core:** Model the c15 filtered-title and Value From Cells chart extensions (by @ChristopherVR) ([880fa81](https://github.com/ChristopherVR/pptx-viewer/commit/880fa81e9f2149216e1fcbb057dc316dc02e640f))
26
+ - **core:** Ship PowerPoint's built-in stock sound gallery for effects and transitions (by @ChristopherVR) ([41854e5](https://github.com/ChristopherVR/pptx-viewer/commit/41854e561f3b56bbb177e761aadcfb66e608aba7))
27
+ - **core:** Write legacy binary .ppt (PowerPoint 97-2003) from the save pipeline (by @ChristopherVR) ([d3360c1](https://github.com/ChristopherVR/pptx-viewer/commit/d3360c18d30ab616ee0ba533a3cdf0357fa1e390))
28
+ - **core:** Edit embedded OLE content in place across all five bindings (by @ChristopherVR) ([3f51347](https://github.com/ChristopherVR/pptx-viewer/commit/3f513476e979cc2401cf0f20e5e000bc7af0a0ec))
29
+ - **core:** Edit legacy Word 97-2003 (.doc) OLE documents in place (by @ChristopherVR) ([cfad261](https://github.com/ChristopherVR/pptx-viewer/commit/cfad261b07d1ad5fb79b122fd8eeff29cfe3ab5e))
30
+ - **core:** Interpret SmartArt layouts against a COM-authored ground-truth corpus (by @ChristopherVR) ([d1b43a5](https://github.com/ChristopherVR/pptx-viewer/commit/d1b43a5203b499ac1b18c7da58a3d4a7c38ba640))
31
+
32
+ ### Bug Fixes
33
+
34
+ - **vanilla:** Wire setAnimationStockSound into the chrome callbacks (by @ChristopherVR) ([f122477](https://github.com/ChristopherVR/pptx-viewer/commit/f122477df073d322277db28a709ebe9b03708eba))
35
+ - **core:** Break the OLE nested-deck import cycle and declare the effect-sound fixture (by @ChristopherVR) ([7a99ea6](https://github.com/ChristopherVR/pptx-viewer/commit/7a99ea6acb31f4511bc68a504d971f0d6a20e954))
36
+ - **core:** Make SDK-authored .ppt decks open in PowerPoint (by @ChristopherVR) ([7433ee5](https://github.com/ChristopherVR/pptx-viewer/commit/7433ee510abc76bfdbe546874cb117387f381f18))
37
+ - **core:** Build the validator enum table through a pure call (by @ChristopherVR) ([d4977ea](https://github.com/ChristopherVR/pptx-viewer/commit/d4977eae77aff80a8b2b87bf87f8f76d89afb9c6))
38
+ - **core:** Replace a stray NUL byte inside a string literal (by @ChristopherVR) ([40bdda3](https://github.com/ChristopherVR/pptx-viewer/commit/40bdda3b5a066a89afcbf6beeabf4aa55837adad))
39
+ - **shared:** Sync the OLE content-dirty flag and settle three stale test premises (by @ChristopherVR) ([5302473](https://github.com/ChristopherVR/pptx-viewer/commit/53024730770ddbc50e997347c68c3a7737a686e3))
40
+ - **core:** Place cached SmartArt shapes at their raw offsets and keep a lone column in bounds (by @ChristopherVR) ([09ecba9](https://github.com/ChristopherVR/pptx-viewer/commit/09ecba9d245aa34d85e4a05eedb474775a413239))
41
+ - **shared:** Give the accessibility title field a name distinct from the chart title (by @ChristopherVR) ([37bbe6a](https://github.com/ChristopherVR/pptx-viewer/commit/37bbe6aa4b973feea6b04ffec7d80dc3a676e405))
42
+ - **shared:** Keep a plain Fly In on its directional preset when a real box is available (by @ChristopherVR) ([a026049](https://github.com/ChristopherVR/pptx-viewer/commit/a0260492322fe52a67b3d7fc01002ddf8f737211))
43
+
44
+ ### Dependencies
45
+
46
+ - **deps:** Bump the minor-and-patch group with 3 updates (by @dependabot[bot]) ([6e40989](https://github.com/ChristopherVR/pptx-viewer/commit/6e409896e58d8e60a6a94ae3c4d51c6b6a5e7108))
47
+ - **deps:** Merge dependabot #212 (by @ChristopherVR) ([a69fe7e](https://github.com/ChristopherVR/pptx-viewer/commit/a69fe7eaad513d06808570b31bf032f4310bafbd))
48
+ - **deps:** Update every dependency to its latest in-range version (by @ChristopherVR) ([1f242b7](https://github.com/ChristopherVR/pptx-viewer/commit/1f242b71b25a902f4ea817a45853c5f1a19db2c0))
49
+
10
50
  ## [2.9.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.9.0) - 2026-09-06
11
51
 
12
52
  ### Features
@@ -0,0 +1 @@
1
+ 'use strict';var chunkWTF4OTWQ_cjs=require('./chunk-WTF4OTWQ.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkWTF4OTWQ_cjs.io(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-focus-row"),f=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkWTF4OTWQ_cjs.Kn(p,o.getSlides())){let b=chunkWTF4OTWQ_cjs.Xn(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=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-focus-actions"),d=chunkWTF4OTWQ_cjs.Ln(p,o.getSlides());if(d){let r=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkWTF4OTWQ_cjs.io(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkWTF4OTWQ_cjs.Mn(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=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-focus-pick"),b=chunkWTF4OTWQ_cjs.io(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkWTF4OTWQ_cjs.Xn(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=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkWTF4OTWQ_cjs.io(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-history-head"),x=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkWTF4OTWQ_cjs.io(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-history-body"),m=chunkWTF4OTWQ_cjs.Xn(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkWTF4OTWQ_cjs.On({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=chunkWTF4OTWQ_cjs.Xn(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkWTF4OTWQ_cjs.Xn(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkWTF4OTWQ_cjs.Xn(t,"li","pptxv-ai-history-row"),r=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-history-text"),k=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkWTF4OTWQ_cjs.io(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkWTF4OTWQ_cjs.Xn(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(chunkWTF4OTWQ_cjs.io(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=chunkWTF4OTWQ_cjs.Tn(t.toolName,t.input,h?"present":"past"),c=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-tool"),p=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-tool-head"),m=chunkWTF4OTWQ_cjs.io(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkWTF4OTWQ_cjs.Xn(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkWTF4OTWQ_cjs.Xn(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkWTF4OTWQ_cjs.io(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkWTF4OTWQ_cjs.io(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=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkWTF4OTWQ_cjs.Sn(t.input);if(g){let f=chunkWTF4OTWQ_cjs.Xn(o,"details","pptxv-ai-tool-details"),C=chunkWTF4OTWQ_cjs.Xn(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkWTF4OTWQ_cjs.Rn(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=chunkWTF4OTWQ_cjs.Gn(a);if(x.length===0&&!h)continue;let c=chunkWTF4OTWQ_cjs.Xn(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkWTF4OTWQ_cjs.io(o,h?"comment":"sparkles"));let m=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkWTF4OTWQ_cjs.Xn(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=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-proposals-header"),x=chunkWTF4OTWQ_cjs.Xn(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkWTF4OTWQ_cjs.Xn(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=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkWTF4OTWQ_cjs.Xn(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkWTF4OTWQ_cjs.Xn(o,"li");g.textContent=chunkWTF4OTWQ_cjs.Dn(s),l.appendChild(g);}a.appendChild(l);}let c=chunkWTF4OTWQ_cjs.Xn(o,"div","pptxv-ai-proposal-actions"),p=chunkWTF4OTWQ_cjs.Xn(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkWTF4OTWQ_cjs.io(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkWTF4OTWQ_cjs.Xn(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkWTF4OTWQ_cjs.io(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=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-header"),h=chunkWTF4OTWQ_cjs.Xn(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkWTF4OTWQ_cjs.io(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkWTF4OTWQ_cjs.io(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=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkWTF4OTWQ_cjs.Xn(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkWTF4OTWQ_cjs.Xn(t,"form","pptxv-ai-composer"),d=chunkWTF4OTWQ_cjs.Xn(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkWTF4OTWQ_cjs.Xn(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkWTF4OTWQ_cjs.io(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkWTF4OTWQ_cjs.Pn)({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:chunkWTF4OTWQ_cjs.Nn(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=>chunkWTF4OTWQ_cjs.Gn(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=chunkWTF4OTWQ_cjs.Un(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;
@@ -1 +1 @@
1
- import {Wn,ho,On,Mn,Nn,Fn,Tn,Jn,Kn,Ln,Sn,Rn,Qn,Cn}from'./chunk-3FYW54YJ.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Wn(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Wn(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(ho(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Wn(t,"div","pptxv-ai-focus-row"),f=Wn(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Jn(p,o.getSlides())){let b=Wn(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=Wn(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Wn(t,"div","pptxv-ai-focus-actions"),d=Kn(p,o.getSlides());if(d){let r=Wn(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(ho(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Ln(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=Wn(t,"div","pptxv-ai-focus-pick"),b=ho(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Wn(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Wn(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=Wn(t,"button","pptxv-ai-chats");i.type="button",i.append(ho(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Wn(t,"div","pptxv-ai-history");a.hidden=true;let h=Wn(t,"div","pptxv-ai-history-head"),x=Wn(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Wn(t,"button","pptxv-ai-history-new");c.type="button",c.append(ho(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Wn(t,"div","pptxv-ai-history-body"),m=Wn(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Nn({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=Wn(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Wn(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Wn(t,"li","pptxv-ai-history-row"),r=Wn(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Wn(t,"span","pptxv-ai-history-text"),k=Wn(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Wn(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(ho(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Wn(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(ho(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=Sn(t.toolName,t.input,h?"present":"past"),c=Wn(o,"div","pptxv-ai-tool"),p=Wn(o,"div","pptxv-ai-tool-head"),m=ho(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Wn(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Wn(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(ho(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(ho(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=Wn(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=Rn(t.input);if(g){let f=Wn(o,"details","pptxv-ai-tool-details"),C=Wn(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Wn(o,"div","pptxv-ai-tool-raw");d.textContent=`${Qn(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=Fn(a);if(x.length===0&&!h)continue;let c=Wn(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Wn(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(ho(o,h?"comment":"sparkles"));let m=Wn(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Wn(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=Wn(o,"div","pptxv-ai-proposals-header"),x=Wn(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Wn(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=Wn(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Wn(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Wn(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Wn(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Wn(o,"li");g.textContent=Cn(s),l.appendChild(g);}a.appendChild(l);}let c=Wn(o,"div","pptxv-ai-proposal-actions"),p=Wn(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(ho(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Wn(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(ho(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=Wn(t,"div","pptxv-ai-header"),h=Wn(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Wn(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(ho(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(ho(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=Wn(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Wn(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Wn(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Wn(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Wn(t,"form","pptxv-ai-composer"),d=Wn(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Wn(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(ho(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??On)({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:Mn(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=>Fn(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=Tn(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};
1
+ import {Xn,io,Pn,Nn,On,Gn,Un,Kn,Ln,Mn,Tn,Sn,Rn,Dn}from'./chunk-56CORRDB.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=Xn(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=Xn(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(io(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=Xn(t,"div","pptxv-ai-focus-row"),f=Xn(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Kn(p,o.getSlides())){let b=Xn(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=Xn(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=Xn(t,"div","pptxv-ai-focus-actions"),d=Ln(p,o.getSlides());if(d){let r=Xn(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(io(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Mn(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=Xn(t,"div","pptxv-ai-focus-pick"),b=io(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=Xn(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=Xn(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=Xn(t,"button","pptxv-ai-chats");i.type="button",i.append(io(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=Xn(t,"div","pptxv-ai-history");a.hidden=true;let h=Xn(t,"div","pptxv-ai-history-head"),x=Xn(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=Xn(t,"button","pptxv-ai-history-new");c.type="button",c.append(io(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=Xn(t,"div","pptxv-ai-history-body"),m=Xn(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=On({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=Xn(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=Xn(t,"ul","pptxv-ai-history-list");for(let d of f){let y=Xn(t,"li","pptxv-ai-history-row"),r=Xn(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=Xn(t,"span","pptxv-ai-history-text"),k=Xn(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=Xn(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(io(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=Xn(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(io(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=Tn(t.toolName,t.input,h?"present":"past"),c=Xn(o,"div","pptxv-ai-tool"),p=Xn(o,"div","pptxv-ai-tool-head"),m=io(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=Xn(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=Xn(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(io(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(io(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=Xn(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=Sn(t.input);if(g){let f=Xn(o,"details","pptxv-ai-tool-details"),C=Xn(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=Xn(o,"div","pptxv-ai-tool-raw");d.textContent=`${Rn(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=Gn(a);if(x.length===0&&!h)continue;let c=Xn(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=Xn(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(io(o,h?"comment":"sparkles"));let m=Xn(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=Xn(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=Xn(o,"div","pptxv-ai-proposals-header"),x=Xn(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=Xn(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=Xn(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=Xn(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=Xn(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=Xn(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=Xn(o,"li");g.textContent=Dn(s),l.appendChild(g);}a.appendChild(l);}let c=Xn(o,"div","pptxv-ai-proposal-actions"),p=Xn(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(io(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=Xn(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(io(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=Xn(t,"div","pptxv-ai-header"),h=Xn(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=Xn(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(io(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(io(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=Xn(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=Xn(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=Xn(t,"div","pptxv-ai-proposals");g.hidden=true;let f=Xn(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=Xn(t,"form","pptxv-ai-composer"),d=Xn(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=Xn(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(io(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Pn)({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:Nn(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=>Gn(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=Un(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};