pptx-vanilla-viewer 2.16.0 → 2.16.2

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,37 @@ 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.16.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.16.1) - 2026-09-11
11
+
12
+ ### Bug Fixes
13
+
14
+ - Preserve unchanged table text during merge and split (by @Sudhansh6) ([22df796](https://github.com/ChristopherVR/pptx-viewer/commit/22df7968570c89f03b72766b10473401cc179e9c))
15
+ - Keep split available for a single merged table cell (by @Sudhansh6) ([38727de](https://github.com/ChristopherVR/pptx-viewer/commit/38727de2d0bd2105d4e263c12bc6fdbe7b013cb8))
16
+ - **vanilla:** Close the chart title editor only once (by @Sudhansh6) ([7c32006](https://github.com/ChristopherVR/pptx-viewer/commit/7c32006798112af8ef54e7d54911d8b50264b29b))
17
+
18
+ ## [2.16.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.16.0) - 2026-09-10
19
+
20
+ ### Features
21
+
22
+ - **core:** SmartArt fanned-root hanging forests and choose-wrapped text templates (by @ChristopherVR) ([f303bbb](https://github.com/ChristopherVR/pptx-viewer/commit/f303bbbcc535052a3d5fbc4ba5e1898e3e300781))
23
+ - **core:** Size repeater-rendered SmartArt satellites from the diagram-wide userS (by @ChristopherVR) ([fc5e931](https://github.com/ChristopherVR/pptx-viewer/commit/fc5e9313d1876daec8c64632c3579a7bddf8a02a))
24
+ - **core:** Reserve the fan-axis hang gap in transposed tailed hierarchies (by @ChristopherVR) ([0a367d5](https://github.com/ChristopherVR/pptx-viewer/commit/0a367d519e49cd538da2c0a4cf4408a4d94b3a94))
25
+ - **core:** Size nested SmartArt hub-and-satellite rings from the diagram-wide userS (by @ChristopherVR) ([228d624](https://github.com/ChristopherVR/pptx-viewer/commit/228d6242cc07f1946cc82efcffea5d06cf3cbf4e))
26
+
27
+ ### Bug Fixes
28
+
29
+ - **shared,vanilla:** Space WordArt envelope glyphs across the box and keep paragraph bands apart (by @ChristopherVR) ([e165d72](https://github.com/ChristopherVR/pptx-viewer/commit/e165d7210ba360a79a384206c5459a7630db19a8))
30
+ - **core:** Preserve table inline content order on save (by @Sudhansh6) ([4f38ac3](https://github.com/ChristopherVR/pptx-viewer/commit/4f38ac34fbe7bb92d365159c7951e14cce48ae7d))
31
+ - **vanilla:** Give the AI composer send button its 44px touch target (by @ChristopherVR) ([b9bbe73](https://github.com/ChristopherVR/pptx-viewer/commit/b9bbe73f188d76594e127e02018f145d7cef81e1))
32
+ - **shared,core:** Resolve the open code-scanning alerts (by @ChristopherVR) ([e66f068](https://github.com/ChristopherVR/pptx-viewer/commit/e66f06864f472dcd7d94b31435bb8bd1f7054be5))
33
+ - **core:** Preserve empty soft line breaks on load (by @Sudhansh6) ([be9f5f5](https://github.com/ChristopherVR/pptx-viewer/commit/be9f5f59849434f76cc074ea1d49024460ad9164))
34
+ - **core:** Drop the removed ensureItems argument after the soft-break fix (by @ChristopherVR) ([83f9b37](https://github.com/ChristopherVR/pptx-viewer/commit/83f9b37cf590952abeba2e3e7138e4ed7fab81ca))
35
+ - Preserve rich table cells during row and column edits (by @Sudhansh6) ([e83c2eb](https://github.com/ChristopherVR/pptx-viewer/commit/e83c2ebe92b78a7d32ed1d90ebe6765573a2c148))
36
+
37
+ ### Refactor
38
+
39
+ - **shared:** Move the WordArt canvas measurement helpers to their own module (by @ChristopherVR) ([ed9f400](https://github.com/ChristopherVR/pptx-viewer/commit/ed9f4009b523985c28ea5740404191d3118a03a4))
40
+
10
41
  ## [2.15.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.15.0) - 2026-09-10
11
42
 
12
43
  ### Features
@@ -0,0 +1 @@
1
+ 'use strict';var chunkHXCHK6RW_cjs=require('./chunk-HXCHK6RW.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkHXCHK6RW_cjs.to(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-focus-row"),f=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkHXCHK6RW_cjs.Un(p,o.getSlides())){let b=chunkHXCHK6RW_cjs.fo(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=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-focus-actions"),d=chunkHXCHK6RW_cjs.Vn(p,o.getSlides());if(d){let r=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkHXCHK6RW_cjs.to(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkHXCHK6RW_cjs.Wn(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=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-focus-pick"),b=chunkHXCHK6RW_cjs.to(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkHXCHK6RW_cjs.fo(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=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkHXCHK6RW_cjs.to(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-history-head"),x=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkHXCHK6RW_cjs.to(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-history-body"),m=chunkHXCHK6RW_cjs.fo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkHXCHK6RW_cjs.Yn({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=chunkHXCHK6RW_cjs.fo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkHXCHK6RW_cjs.fo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkHXCHK6RW_cjs.fo(t,"li","pptxv-ai-history-row"),r=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-history-text"),k=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkHXCHK6RW_cjs.to(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkHXCHK6RW_cjs.fo(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(chunkHXCHK6RW_cjs.to(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=chunkHXCHK6RW_cjs.bo(t.toolName,t.input,h?"present":"past"),c=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-tool"),p=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-tool-head"),m=chunkHXCHK6RW_cjs.to(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkHXCHK6RW_cjs.fo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkHXCHK6RW_cjs.fo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkHXCHK6RW_cjs.to(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkHXCHK6RW_cjs.to(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=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkHXCHK6RW_cjs.ao(t.input);if(g){let f=chunkHXCHK6RW_cjs.fo(o,"details","pptxv-ai-tool-details"),C=chunkHXCHK6RW_cjs.fo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkHXCHK6RW_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=chunkHXCHK6RW_cjs.Qn(a);if(x.length===0&&!h)continue;let c=chunkHXCHK6RW_cjs.fo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkHXCHK6RW_cjs.to(o,h?"comment":"sparkles"));let m=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkHXCHK6RW_cjs.fo(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=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-proposals-header"),x=chunkHXCHK6RW_cjs.fo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkHXCHK6RW_cjs.fo(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=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkHXCHK6RW_cjs.fo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkHXCHK6RW_cjs.fo(o,"li");g.textContent=chunkHXCHK6RW_cjs.Nn(s),l.appendChild(g);}a.appendChild(l);}let c=chunkHXCHK6RW_cjs.fo(o,"div","pptxv-ai-proposal-actions"),p=chunkHXCHK6RW_cjs.fo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkHXCHK6RW_cjs.to(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkHXCHK6RW_cjs.fo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkHXCHK6RW_cjs.to(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=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-header"),h=chunkHXCHK6RW_cjs.fo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkHXCHK6RW_cjs.to(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkHXCHK6RW_cjs.to(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=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkHXCHK6RW_cjs.fo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkHXCHK6RW_cjs.fo(t,"form","pptxv-ai-composer"),d=chunkHXCHK6RW_cjs.fo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkHXCHK6RW_cjs.fo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkHXCHK6RW_cjs.to(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkHXCHK6RW_cjs.Zn)({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:chunkHXCHK6RW_cjs.Xn(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=>chunkHXCHK6RW_cjs.Qn(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=chunkHXCHK6RW_cjs.co(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 {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};
1
+ import {fo,to,Zn,Xn,Yn,Qn,co,Un,Vn,Wn,bo,ao,$n,Nn}from'./chunk-ISUSKCQM.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=fo(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=fo(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(to(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=fo(t,"div","pptxv-ai-focus-row"),f=fo(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of Un(p,o.getSlides())){let b=fo(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=fo(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=fo(t,"div","pptxv-ai-focus-actions"),d=Vn(p,o.getSlides());if(d){let r=fo(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(to(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(Wn(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=fo(t,"div","pptxv-ai-focus-pick"),b=to(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=fo(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=fo(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=fo(t,"button","pptxv-ai-chats");i.type="button",i.append(to(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=fo(t,"div","pptxv-ai-history");a.hidden=true;let h=fo(t,"div","pptxv-ai-history-head"),x=fo(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=fo(t,"button","pptxv-ai-history-new");c.type="button",c.append(to(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=fo(t,"div","pptxv-ai-history-body"),m=fo(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Yn({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=fo(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=fo(t,"ul","pptxv-ai-history-list");for(let d of f){let y=fo(t,"li","pptxv-ai-history-row"),r=fo(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=fo(t,"span","pptxv-ai-history-text"),k=fo(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=fo(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(to(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=fo(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(to(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=bo(t.toolName,t.input,h?"present":"past"),c=fo(o,"div","pptxv-ai-tool"),p=fo(o,"div","pptxv-ai-tool-head"),m=to(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=fo(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=fo(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(to(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(to(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=fo(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=ao(t.input);if(g){let f=fo(o,"details","pptxv-ai-tool-details"),C=fo(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=fo(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=Qn(a);if(x.length===0&&!h)continue;let c=fo(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=fo(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(to(o,h?"comment":"sparkles"));let m=fo(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=fo(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=fo(o,"div","pptxv-ai-proposals-header"),x=fo(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=fo(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=fo(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=fo(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=fo(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=fo(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=fo(o,"li");g.textContent=Nn(s),l.appendChild(g);}a.appendChild(l);}let c=fo(o,"div","pptxv-ai-proposal-actions"),p=fo(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(to(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=fo(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(to(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=fo(t,"div","pptxv-ai-header"),h=fo(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=fo(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(to(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(to(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=fo(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=fo(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=fo(t,"div","pptxv-ai-proposals");g.hidden=true;let f=fo(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=fo(t,"form","pptxv-ai-composer"),d=fo(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=fo(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(to(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Zn)({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:Xn(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=>Qn(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=co(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};