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