pptx-vanilla-viewer 1.0.0 → 1.2.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
@@ -4,6 +4,31 @@ All notable changes to this project are documented here.
4
4
  This file is generated from [Conventional Commits](https://www.conventionalcommits.org)
5
5
  by [git-cliff](https://git-cliff.org); do not edit it by hand.
6
6
 
7
+ ## [1.1.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@1.1.0) - 2026-07-23
8
+
9
+ ## [1.0.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@1.0.0) - 2026-07-23
10
+
11
+ ### Features
12
+
13
+ - **shared:** Ai config, loader and bridge contracts (by @ChristopherVR) ([1c40e28](https://github.com/ChristopherVR/pptx-viewer/commit/1c40e28b1661895e2993b01c11bea6262459cb88))
14
+ - **vanilla:** Ai bridge over the viewer controller (by @ChristopherVR) ([a031301](https://github.com/ChristopherVR/pptx-viewer/commit/a031301511bfb13762b49a70541fdeb2183dd497))
15
+ - **shared:** Indexeddb-first ai chat history store (by @ChristopherVR) ([88920f2](https://github.com/ChristopherVR/pptx-viewer/commit/88920f20eb00e72b84efa9ef2cb500dfd6d20db4))
16
+ - **shared:** Rebuild AI assistant tools on pptx-viewer-mcp (by @ChristopherVR) ([da1c31e](https://github.com/ChristopherVR/pptx-viewer/commit/da1c31ee88c0b60a82628003c8a1b16245f028ed))
17
+ - **core:** Upgrade emf-converter to 2.0.0 (breaking) (by @ChristopherVR) ([effa4e5](https://github.com/ChristopherVR/pptx-viewer/commit/effa4e5338b2b01796a3671f505bcb4563de74cc))
18
+
19
+ ### Documentation
20
+
21
+ - Friendly 2.0.0 changelog for root and packages (by @ChristopherVR) ([f56564d](https://github.com/ChristopherVR/pptx-viewer/commit/f56564de0dea3f3aa6f0bdf5ad5ed1bf6e9d4823))
22
+
23
+ ### Testing
24
+
25
+ - **vanilla:** Ai panel gating and proposals (by @ChristopherVR) ([f7613fd](https://github.com/ChristopherVR/pptx-viewer/commit/f7613fdca28b0cb84c7ddaeb96e49dc27a49b3e8))
26
+ - **shared:** Opt-in live gpt-4o-mini ai integration test (by @ChristopherVR) ([48622f1](https://github.com/ChristopherVR/pptx-viewer/commit/48622f135a5f2ee4c28d97d08478d3c203745f47))
27
+
28
+ ### Build & CI
29
+
30
+ - **shared:** Keep the ai SDK external across bindings (by @ChristopherVR) ([fa5e6b7](https://github.com/ChristopherVR/pptx-viewer/commit/fa5e6b77e6586764d9e7717439f574291810e93b))
31
+
7
32
  ## [0.17.5](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@0.17.5) - 2026-07-19
8
33
 
9
34
  ## [0.17.4](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@0.17.4) - 2026-07-19
@@ -0,0 +1 @@
1
+ 'use strict';var chunkS5V27BHI_cjs=require('./chunk-S5V27BHI.cjs');require('./chunk-EWJAZ6TW.cjs'),require('./chunk-4VDLQK6F.cjs');function j(e){let{doc:t,t:n,controller:i}=e,p=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-focus"),m=(c,s,d)=>{let r=chunkS5V27BHI_cjs.Ke(t,"button","pptxv-ai-focus-btn");return r.type="button",r.title=s,r.setAttribute("aria-label",s),r.appendChild(chunkS5V27BHI_cjs.Te(t,c)),r.addEventListener("click",d),r},x=()=>{p.replaceChildren();let c=i.getEffectiveTargets(),s=i.hasPicks(),d=i.isPinned(),r=i.isPicking(),f=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-focus-row"),b=chunkS5V27BHI_cjs.Ke(t,"span","pptxv-ai-focus-label");b.textContent=n("pptx.ai.focusScope"),f.appendChild(b);for(let h of chunkS5V27BHI_cjs.Fe(c,e.getSlides())){let T=chunkS5V27BHI_cjs.Ke(t,"span","pptxv-ai-focus-chip");(s||d)&&T.classList.add("is-strong"),T.title=h.title,T.textContent=h.label,f.appendChild(T);}if(d){let h=chunkS5V27BHI_cjs.Ke(t,"span","pptxv-ai-focus-pinned");h.textContent=n("pptx.ai.pinnedFocus"),f.appendChild(h);}let u=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-focus-actions"),C=chunkS5V27BHI_cjs.Ge(c,e.getSlides());if(C){let h=chunkS5V27BHI_cjs.Ke(t,"button","pptxv-ai-focus-merge");h.type="button",h.append(chunkS5V27BHI_cjs.Te(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),h.addEventListener("click",()=>e.onSendDirective(chunkS5V27BHI_cjs.He(C.slideIndex,C.elementIdA,C.elementIdB))),u.appendChild(h);}let v=m("crosshair",n("pptx.ai.pickElement"),()=>r?i.stopPicking():i.startPicking());if(v.setAttribute("aria-pressed",String(r)),v.classList.toggle("is-active",r),u.appendChild(v),s?u.appendChild(m("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):d?u.appendChild(m("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):u.appendChild(m("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),f.appendChild(u),p.appendChild(f),r){let h=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-focus-pick"),T=chunkS5V27BHI_cjs.Te(t,"crosshair");T.classList.add("pptxv-ai-focus-pick-icon");let A=chunkS5V27BHI_cjs.Ke(t,"span","pptxv-ai-focus-pick-hint");A.textContent=n("pptx.ai.pickElementHint");let P=chunkS5V27BHI_cjs.Ke(t,"button","pptxv-ai-focus-pick-done");P.type="button",P.textContent=n("pptx.ai.pickDone"),P.addEventListener("click",()=>i.stopPicking()),h.append(T,A,P),p.appendChild(h);}},a=i.subscribe(x);return x(),{el:p,destroy(){a(),p.remove();}}}var J={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 R(e,t,n){let i=t.state==="output-error",p=t.state==="output-available",m=!i&&!p,x=chunkS5V27BHI_cjs.af(t.toolName,t.input,m?"present":"past"),a=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-tool"),c=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-tool-head"),s=chunkS5V27BHI_cjs.Te(e,J[x.icon]??"wrench");s.classList.add("pptxv-ai-tool-icon");let d=chunkS5V27BHI_cjs.Ke(e,"span","pptxv-ai-tool-name");d.textContent=x.label;let r=chunkS5V27BHI_cjs.Ke(e,"span","pptxv-ai-tool-state");if(i?(r.classList.add("is-error"),r.append(chunkS5V27BHI_cjs.Te(e,"alert"),e.createTextNode(n("pptx.ai.toolFailed")))):p?(r.classList.add("is-done"),r.append(chunkS5V27BHI_cjs.Te(e,"check"),e.createTextNode(n("pptx.ai.toolDone")))):(r.classList.add("is-running"),r.textContent=n("pptx.ai.toolRunning")),c.append(s,d,r),a.appendChild(c),i&&t.errorText){let b=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-tool-error");b.textContent=t.errorText,a.appendChild(b);}let f=chunkS5V27BHI_cjs.$e(t.input);if(f){let b=chunkS5V27BHI_cjs.Ke(e,"details","pptxv-ai-tool-details"),u=chunkS5V27BHI_cjs.Ke(e,"summary");u.textContent=n("pptx.ai.toolDetails");let C=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-tool-raw");C.textContent=`${chunkS5V27BHI_cjs._e(t.toolName)}: ${f}`,b.append(u,C),a.appendChild(b);}return a}function U(e,t,n,i){t.replaceChildren();for(let p of n){if(p.role==="system")continue;let m=p.role==="user",x=chunkS5V27BHI_cjs.Ze(p);if(x.length===0&&!m)continue;let a=chunkS5V27BHI_cjs.Ke(e,"div",`pptxv-ai-msg pptxv-ai-msg-${p.role}`),c=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-msg-avatar");c.setAttribute("aria-label",i(m?"pptx.ai.you":"pptx.ai.assistant")),c.appendChild(chunkS5V27BHI_cjs.Te(e,m?"comment":"sparkles"));let s=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-msg-body");for(let d of x)if(d.kind==="text"){let r=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-msg-text");r.textContent=d.text,s.appendChild(r);}else s.appendChild(R(e,d,i));a.append(c,s),t.appendChild(a);}}function $(e,t,n,i,p){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let m=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-proposals-header"),x=chunkS5V27BHI_cjs.Ke(e,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),m.appendChild(x),n.length>1){let a=chunkS5V27BHI_cjs.Ke(e,"button","pptxv-ai-proposal-btn is-accept-all");a.type="button",a.textContent=i("pptx.ai.acceptAll"),a.addEventListener("click",()=>p.acceptAll()),m.appendChild(a);}t.appendChild(m);for(let a of n)t.appendChild(Q(e,a,i,p));}function Q(e,t,n,i){let p=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-proposal");p.dataset.proposalId=t.id;let m=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-proposal-eyebrow");m.textContent=n("pptx.ai.proposedChange"),p.appendChild(m);let x=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,p.appendChild(x),t.summary.length>0){let d=chunkS5V27BHI_cjs.Ke(e,"ul","pptxv-ai-proposal-summary");for(let r of t.summary){let f=chunkS5V27BHI_cjs.Ke(e,"li");f.textContent=chunkS5V27BHI_cjs.Ve(r),d.appendChild(f);}p.appendChild(d);}let a=chunkS5V27BHI_cjs.Ke(e,"div","pptxv-ai-proposal-actions"),c=chunkS5V27BHI_cjs.Ke(e,"button","pptxv-ai-proposal-btn is-accept");c.type="button",c.append(chunkS5V27BHI_cjs.Te(e,"check"),e.createTextNode(n("pptx.ai.accept"))),c.addEventListener("click",()=>i.accept(t.id));let s=chunkS5V27BHI_cjs.Ke(e,"button","pptxv-ai-proposal-btn is-reject");return s.type="button",s.append(chunkS5V27BHI_cjs.Te(e,"close"),e.createTextNode(n("pptx.ai.reject"))),s.addEventListener("click",()=>i.reject(t.id)),a.append(c,s),p.appendChild(a),p}async function gt(e){let{doc:t,host:n,t:i}=e;n.replaceChildren();let p=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-header"),m=chunkS5V27BHI_cjs.Ke(t,"span","pptxv-ai-title");m.textContent=i("pptx.ai.title"),p.append(chunkS5V27BHI_cjs.Te(t,"sparkles"),m);let x,a=e.controller,c=a?j({doc:t,t:i,controller:a,getSlides:()=>e.bridge.getSlides(),onSendDirective:l=>{x?.sendMessage(l);}}):null,s=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-messages");s.setAttribute("role","log"),s.setAttribute("aria-live","polite");let d=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-empty");d.textContent=i("pptx.ai.emptyHint"),s.appendChild(d);let r=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-proposals");r.hidden=true;let f=chunkS5V27BHI_cjs.Ke(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let b=chunkS5V27BHI_cjs.Ke(t,"form","pptxv-ai-composer"),u=chunkS5V27BHI_cjs.Ke(t,"textarea","pptxv-ai-input");u.rows=2,u.placeholder=i("pptx.ai.placeholder");let C=chunkS5V27BHI_cjs.Ke(t,"button","pptxv-ai-send");C.type="submit",C.setAttribute("aria-label",i("pptx.ai.send")),C.appendChild(chunkS5V27BHI_cjs.Te(t,"send")),b.append(u,C),n.append(p,...c?[c.el]:[],s,r,f,b);try{x=await(e.createChat??chunkS5V27BHI_cjs.Ye)({bridge:e.bridge,config:e.config});}catch{return d.textContent=i("pptx.ai.unavailableTitle"),u.disabled=true,C.disabled=true,c?.destroy(),{destroy:()=>n.replaceChildren()}}let v=x,h=new Set,T=l=>{if(!a)return;let y=l.messages.flatMap(q=>chunkS5V27BHI_cjs.Ze(q).filter(G=>G.kind==="tool")).at(-1);if(!y||y.kind!=="tool"||y.state==="input-streaming"||h.has(y.toolCallId))return;h.add(y.toolCallId);let k=chunkS5V27BHI_cjs.bf(y.toolName,y.input);k&&k.slideIndex!==void 0&&e.goToSlide?.(k.slideIndex),a.flashToolTarget(k);},A=l=>{U(t,s,l.messages,i),d.hidden=l.messages.length>0,l.messages.length===0&&s.appendChild(d),$(t,r,v.proposals.list(),i,{accept:y=>{a?.flashToolTarget(null),v.proposals.apply(y),A(v.getSnapshot());},reject:y=>{v.proposals.revert(y),A(v.getSnapshot());},acceptAll:()=>{a?.flashToolTarget(null),v.proposals.acceptAll(),A(v.getSnapshot());}});let S=l.status==="submitted"||l.status==="streaming";n.classList.toggle("is-busy",S),C.setAttribute("aria-label",i(S?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!l.error,f.textContent=l.error?i("pptx.ai.errorPrefix"):"",s.scrollTop=s.scrollHeight,T(l);},P=()=>{if(n.classList.contains("is-busy")){v.stop();return}let l=u.value.trim();l&&(u.value="",v.sendMessage(l));};b.addEventListener("submit",l=>{l.preventDefault(),P();}),u.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),P());});let w=a?.getPrefill().nonce??0,z=()=>{if(!a)return;let l=a.getPrefill();l.nonce!==w&&(w=l.nonce,u.value=l.text,u.focus());},K=a?.subscribe(z),O=v.subscribe(A);return A(v.getSnapshot()),{changeAnimator:v.changeAnimator,destroy(){O(),K?.(),c?.destroy(),n.replaceChildren();}}}exports.createAiPanel=gt;
@@ -1 +1 @@
1
- import {Fe,Oe,Te,Ue,Ye,Ae,Be,Ce,Xe,We,Ve,Qe}from'./chunk-GV4Y4WU5.js';import'./chunk-26ILGYI6.js';import'./chunk-WOT6VMZA.js';function j(e){let{doc:t,t:n,controller:i}=e,p=Fe(t,"div","pptxv-ai-focus"),m=(c,s,d)=>{let r=Fe(t,"button","pptxv-ai-focus-btn");return r.type="button",r.title=s,r.setAttribute("aria-label",s),r.appendChild(Oe(t,c)),r.addEventListener("click",d),r},x=()=>{p.replaceChildren();let c=i.getEffectiveTargets(),s=i.hasPicks(),d=i.isPinned(),r=i.isPicking(),f=Fe(t,"div","pptxv-ai-focus-row"),b=Fe(t,"span","pptxv-ai-focus-label");b.textContent=n("pptx.ai.focusScope"),f.appendChild(b);for(let h of Ae(c,e.getSlides())){let T=Fe(t,"span","pptxv-ai-focus-chip");(s||d)&&T.classList.add("is-strong"),T.title=h.title,T.textContent=h.label,f.appendChild(T);}if(d){let h=Fe(t,"span","pptxv-ai-focus-pinned");h.textContent=n("pptx.ai.pinnedFocus"),f.appendChild(h);}let u=Fe(t,"div","pptxv-ai-focus-actions"),C=Be(c,e.getSlides());if(C){let h=Fe(t,"button","pptxv-ai-focus-merge");h.type="button",h.append(Oe(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),h.addEventListener("click",()=>e.onSendDirective(Ce(C.slideIndex,C.elementIdA,C.elementIdB))),u.appendChild(h);}let v=m("crosshair",n("pptx.ai.pickElement"),()=>r?i.stopPicking():i.startPicking());if(v.setAttribute("aria-pressed",String(r)),v.classList.toggle("is-active",r),u.appendChild(v),s?u.appendChild(m("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):d?u.appendChild(m("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):u.appendChild(m("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),f.appendChild(u),p.appendChild(f),r){let h=Fe(t,"div","pptxv-ai-focus-pick"),T=Oe(t,"crosshair");T.classList.add("pptxv-ai-focus-pick-icon");let A=Fe(t,"span","pptxv-ai-focus-pick-hint");A.textContent=n("pptx.ai.pickElementHint");let P=Fe(t,"button","pptxv-ai-focus-pick-done");P.type="button",P.textContent=n("pptx.ai.pickDone"),P.addEventListener("click",()=>i.stopPicking()),h.append(T,A,P),p.appendChild(h);}},a=i.subscribe(x);return x(),{el:p,destroy(){a(),p.remove();}}}var J={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 R(e,t,n){let i=t.state==="output-error",p=t.state==="output-available",m=!i&&!p,x=Xe(t.toolName,t.input,m?"present":"past"),a=Fe(e,"div","pptxv-ai-tool"),c=Fe(e,"div","pptxv-ai-tool-head"),s=Oe(e,J[x.icon]??"wrench");s.classList.add("pptxv-ai-tool-icon");let d=Fe(e,"span","pptxv-ai-tool-name");d.textContent=x.label;let r=Fe(e,"span","pptxv-ai-tool-state");if(i?(r.classList.add("is-error"),r.append(Oe(e,"alert"),e.createTextNode(n("pptx.ai.toolFailed")))):p?(r.classList.add("is-done"),r.append(Oe(e,"check"),e.createTextNode(n("pptx.ai.toolDone")))):(r.classList.add("is-running"),r.textContent=n("pptx.ai.toolRunning")),c.append(s,d,r),a.appendChild(c),i&&t.errorText){let b=Fe(e,"div","pptxv-ai-tool-error");b.textContent=t.errorText,a.appendChild(b);}let f=We(t.input);if(f){let b=Fe(e,"details","pptxv-ai-tool-details"),u=Fe(e,"summary");u.textContent=n("pptx.ai.toolDetails");let C=Fe(e,"div","pptxv-ai-tool-raw");C.textContent=`${Ve(t.toolName)}: ${f}`,b.append(u,C),a.appendChild(b);}return a}function U(e,t,n,i){t.replaceChildren();for(let p of n){if(p.role==="system")continue;let m=p.role==="user",x=Ue(p);if(x.length===0&&!m)continue;let a=Fe(e,"div",`pptxv-ai-msg pptxv-ai-msg-${p.role}`),c=Fe(e,"div","pptxv-ai-msg-avatar");c.setAttribute("aria-label",i(m?"pptx.ai.you":"pptx.ai.assistant")),c.appendChild(Oe(e,m?"comment":"sparkles"));let s=Fe(e,"div","pptxv-ai-msg-body");for(let d of x)if(d.kind==="text"){let r=Fe(e,"div","pptxv-ai-msg-text");r.textContent=d.text,s.appendChild(r);}else s.appendChild(R(e,d,i));a.append(c,s),t.appendChild(a);}}function $(e,t,n,i,p){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let m=Fe(e,"div","pptxv-ai-proposals-header"),x=Fe(e,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),m.appendChild(x),n.length>1){let a=Fe(e,"button","pptxv-ai-proposal-btn is-accept-all");a.type="button",a.textContent=i("pptx.ai.acceptAll"),a.addEventListener("click",()=>p.acceptAll()),m.appendChild(a);}t.appendChild(m);for(let a of n)t.appendChild(Q(e,a,i,p));}function Q(e,t,n,i){let p=Fe(e,"div","pptxv-ai-proposal");p.dataset.proposalId=t.id;let m=Fe(e,"div","pptxv-ai-proposal-eyebrow");m.textContent=n("pptx.ai.proposedChange"),p.appendChild(m);let x=Fe(e,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,p.appendChild(x),t.summary.length>0){let d=Fe(e,"ul","pptxv-ai-proposal-summary");for(let r of t.summary){let f=Fe(e,"li");f.textContent=Qe(r),d.appendChild(f);}p.appendChild(d);}let a=Fe(e,"div","pptxv-ai-proposal-actions"),c=Fe(e,"button","pptxv-ai-proposal-btn is-accept");c.type="button",c.append(Oe(e,"check"),e.createTextNode(n("pptx.ai.accept"))),c.addEventListener("click",()=>i.accept(t.id));let s=Fe(e,"button","pptxv-ai-proposal-btn is-reject");return s.type="button",s.append(Oe(e,"close"),e.createTextNode(n("pptx.ai.reject"))),s.addEventListener("click",()=>i.reject(t.id)),a.append(c,s),p.appendChild(a),p}async function gt(e){let{doc:t,host:n,t:i}=e;n.replaceChildren();let p=Fe(t,"div","pptxv-ai-header"),m=Fe(t,"span","pptxv-ai-title");m.textContent=i("pptx.ai.title"),p.append(Oe(t,"sparkles"),m);let x,a=e.controller,c=a?j({doc:t,t:i,controller:a,getSlides:()=>e.bridge.getSlides(),onSendDirective:l=>{x?.sendMessage(l);}}):null,s=Fe(t,"div","pptxv-ai-messages");s.setAttribute("role","log"),s.setAttribute("aria-live","polite");let d=Fe(t,"div","pptxv-ai-empty");d.textContent=i("pptx.ai.emptyHint"),s.appendChild(d);let r=Fe(t,"div","pptxv-ai-proposals");r.hidden=true;let f=Fe(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let b=Fe(t,"form","pptxv-ai-composer"),u=Fe(t,"textarea","pptxv-ai-input");u.rows=2,u.placeholder=i("pptx.ai.placeholder");let C=Fe(t,"button","pptxv-ai-send");C.type="submit",C.setAttribute("aria-label",i("pptx.ai.send")),C.appendChild(Oe(t,"send")),b.append(u,C),n.append(p,...c?[c.el]:[],s,r,f,b);try{x=await(e.createChat??Te)({bridge:e.bridge,config:e.config});}catch{return d.textContent=i("pptx.ai.unavailableTitle"),u.disabled=true,C.disabled=true,c?.destroy(),{destroy:()=>n.replaceChildren()}}let v=x,h=new Set,T=l=>{if(!a)return;let y=l.messages.flatMap(q=>Ue(q).filter(G=>G.kind==="tool")).at(-1);if(!y||y.kind!=="tool"||y.state==="input-streaming"||h.has(y.toolCallId))return;h.add(y.toolCallId);let k=Ye(y.toolName,y.input);k&&k.slideIndex!==void 0&&e.goToSlide?.(k.slideIndex),a.flashToolTarget(k);},A=l=>{U(t,s,l.messages,i),d.hidden=l.messages.length>0,l.messages.length===0&&s.appendChild(d),$(t,r,v.proposals.list(),i,{accept:y=>{a?.flashToolTarget(null),v.proposals.apply(y),A(v.getSnapshot());},reject:y=>{v.proposals.revert(y),A(v.getSnapshot());},acceptAll:()=>{a?.flashToolTarget(null),v.proposals.acceptAll(),A(v.getSnapshot());}});let S=l.status==="submitted"||l.status==="streaming";n.classList.toggle("is-busy",S),C.setAttribute("aria-label",i(S?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!l.error,f.textContent=l.error?i("pptx.ai.errorPrefix"):"",s.scrollTop=s.scrollHeight,T(l);},P=()=>{if(n.classList.contains("is-busy")){v.stop();return}let l=u.value.trim();l&&(u.value="",v.sendMessage(l));};b.addEventListener("submit",l=>{l.preventDefault(),P();}),u.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),P());});let w=a?.getPrefill().nonce??0,z=()=>{if(!a)return;let l=a.getPrefill();l.nonce!==w&&(w=l.nonce,u.value=l.text,u.focus());},K=a?.subscribe(z),O=v.subscribe(A);return A(v.getSnapshot()),{changeAnimator:v.changeAnimator,destroy(){O(),K?.(),c?.destroy(),n.replaceChildren();}}}export{gt as createAiPanel};
1
+ import {Ke,Te,Ye,Ze,bf,Fe,Ge,He,af,$e,_e,Ve}from'./chunk-OXGXYSLL.js';import'./chunk-26ILGYI6.js';import'./chunk-WOT6VMZA.js';function j(e){let{doc:t,t:n,controller:i}=e,p=Ke(t,"div","pptxv-ai-focus"),m=(c,s,d)=>{let r=Ke(t,"button","pptxv-ai-focus-btn");return r.type="button",r.title=s,r.setAttribute("aria-label",s),r.appendChild(Te(t,c)),r.addEventListener("click",d),r},x=()=>{p.replaceChildren();let c=i.getEffectiveTargets(),s=i.hasPicks(),d=i.isPinned(),r=i.isPicking(),f=Ke(t,"div","pptxv-ai-focus-row"),b=Ke(t,"span","pptxv-ai-focus-label");b.textContent=n("pptx.ai.focusScope"),f.appendChild(b);for(let h of Fe(c,e.getSlides())){let T=Ke(t,"span","pptxv-ai-focus-chip");(s||d)&&T.classList.add("is-strong"),T.title=h.title,T.textContent=h.label,f.appendChild(T);}if(d){let h=Ke(t,"span","pptxv-ai-focus-pinned");h.textContent=n("pptx.ai.pinnedFocus"),f.appendChild(h);}let u=Ke(t,"div","pptxv-ai-focus-actions"),C=Ge(c,e.getSlides());if(C){let h=Ke(t,"button","pptxv-ai-focus-merge");h.type="button",h.append(Te(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),h.addEventListener("click",()=>e.onSendDirective(He(C.slideIndex,C.elementIdA,C.elementIdB))),u.appendChild(h);}let v=m("crosshair",n("pptx.ai.pickElement"),()=>r?i.stopPicking():i.startPicking());if(v.setAttribute("aria-pressed",String(r)),v.classList.toggle("is-active",r),u.appendChild(v),s?u.appendChild(m("close",n("pptx.ai.pickClear"),()=>i.clearPicks())):d?u.appendChild(m("pin-off",n("pptx.ai.clearFocus"),()=>i.clearPinnedFocus())):u.appendChild(m("pin",n("pptx.ai.pinFocus"),()=>i.pinFocus())),f.appendChild(u),p.appendChild(f),r){let h=Ke(t,"div","pptxv-ai-focus-pick"),T=Te(t,"crosshair");T.classList.add("pptxv-ai-focus-pick-icon");let A=Ke(t,"span","pptxv-ai-focus-pick-hint");A.textContent=n("pptx.ai.pickElementHint");let P=Ke(t,"button","pptxv-ai-focus-pick-done");P.type="button",P.textContent=n("pptx.ai.pickDone"),P.addEventListener("click",()=>i.stopPicking()),h.append(T,A,P),p.appendChild(h);}},a=i.subscribe(x);return x(),{el:p,destroy(){a(),p.remove();}}}var J={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 R(e,t,n){let i=t.state==="output-error",p=t.state==="output-available",m=!i&&!p,x=af(t.toolName,t.input,m?"present":"past"),a=Ke(e,"div","pptxv-ai-tool"),c=Ke(e,"div","pptxv-ai-tool-head"),s=Te(e,J[x.icon]??"wrench");s.classList.add("pptxv-ai-tool-icon");let d=Ke(e,"span","pptxv-ai-tool-name");d.textContent=x.label;let r=Ke(e,"span","pptxv-ai-tool-state");if(i?(r.classList.add("is-error"),r.append(Te(e,"alert"),e.createTextNode(n("pptx.ai.toolFailed")))):p?(r.classList.add("is-done"),r.append(Te(e,"check"),e.createTextNode(n("pptx.ai.toolDone")))):(r.classList.add("is-running"),r.textContent=n("pptx.ai.toolRunning")),c.append(s,d,r),a.appendChild(c),i&&t.errorText){let b=Ke(e,"div","pptxv-ai-tool-error");b.textContent=t.errorText,a.appendChild(b);}let f=$e(t.input);if(f){let b=Ke(e,"details","pptxv-ai-tool-details"),u=Ke(e,"summary");u.textContent=n("pptx.ai.toolDetails");let C=Ke(e,"div","pptxv-ai-tool-raw");C.textContent=`${_e(t.toolName)}: ${f}`,b.append(u,C),a.appendChild(b);}return a}function U(e,t,n,i){t.replaceChildren();for(let p of n){if(p.role==="system")continue;let m=p.role==="user",x=Ze(p);if(x.length===0&&!m)continue;let a=Ke(e,"div",`pptxv-ai-msg pptxv-ai-msg-${p.role}`),c=Ke(e,"div","pptxv-ai-msg-avatar");c.setAttribute("aria-label",i(m?"pptx.ai.you":"pptx.ai.assistant")),c.appendChild(Te(e,m?"comment":"sparkles"));let s=Ke(e,"div","pptxv-ai-msg-body");for(let d of x)if(d.kind==="text"){let r=Ke(e,"div","pptxv-ai-msg-text");r.textContent=d.text,s.appendChild(r);}else s.appendChild(R(e,d,i));a.append(c,s),t.appendChild(a);}}function $(e,t,n,i,p){if(t.replaceChildren(),t.hidden=n.length===0,n.length===0)return;let m=Ke(e,"div","pptxv-ai-proposals-header"),x=Ke(e,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),m.appendChild(x),n.length>1){let a=Ke(e,"button","pptxv-ai-proposal-btn is-accept-all");a.type="button",a.textContent=i("pptx.ai.acceptAll"),a.addEventListener("click",()=>p.acceptAll()),m.appendChild(a);}t.appendChild(m);for(let a of n)t.appendChild(Q(e,a,i,p));}function Q(e,t,n,i){let p=Ke(e,"div","pptxv-ai-proposal");p.dataset.proposalId=t.id;let m=Ke(e,"div","pptxv-ai-proposal-eyebrow");m.textContent=n("pptx.ai.proposedChange"),p.appendChild(m);let x=Ke(e,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,p.appendChild(x),t.summary.length>0){let d=Ke(e,"ul","pptxv-ai-proposal-summary");for(let r of t.summary){let f=Ke(e,"li");f.textContent=Ve(r),d.appendChild(f);}p.appendChild(d);}let a=Ke(e,"div","pptxv-ai-proposal-actions"),c=Ke(e,"button","pptxv-ai-proposal-btn is-accept");c.type="button",c.append(Te(e,"check"),e.createTextNode(n("pptx.ai.accept"))),c.addEventListener("click",()=>i.accept(t.id));let s=Ke(e,"button","pptxv-ai-proposal-btn is-reject");return s.type="button",s.append(Te(e,"close"),e.createTextNode(n("pptx.ai.reject"))),s.addEventListener("click",()=>i.reject(t.id)),a.append(c,s),p.appendChild(a),p}async function gt(e){let{doc:t,host:n,t:i}=e;n.replaceChildren();let p=Ke(t,"div","pptxv-ai-header"),m=Ke(t,"span","pptxv-ai-title");m.textContent=i("pptx.ai.title"),p.append(Te(t,"sparkles"),m);let x,a=e.controller,c=a?j({doc:t,t:i,controller:a,getSlides:()=>e.bridge.getSlides(),onSendDirective:l=>{x?.sendMessage(l);}}):null,s=Ke(t,"div","pptxv-ai-messages");s.setAttribute("role","log"),s.setAttribute("aria-live","polite");let d=Ke(t,"div","pptxv-ai-empty");d.textContent=i("pptx.ai.emptyHint"),s.appendChild(d);let r=Ke(t,"div","pptxv-ai-proposals");r.hidden=true;let f=Ke(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let b=Ke(t,"form","pptxv-ai-composer"),u=Ke(t,"textarea","pptxv-ai-input");u.rows=2,u.placeholder=i("pptx.ai.placeholder");let C=Ke(t,"button","pptxv-ai-send");C.type="submit",C.setAttribute("aria-label",i("pptx.ai.send")),C.appendChild(Te(t,"send")),b.append(u,C),n.append(p,...c?[c.el]:[],s,r,f,b);try{x=await(e.createChat??Ye)({bridge:e.bridge,config:e.config});}catch{return d.textContent=i("pptx.ai.unavailableTitle"),u.disabled=true,C.disabled=true,c?.destroy(),{destroy:()=>n.replaceChildren()}}let v=x,h=new Set,T=l=>{if(!a)return;let y=l.messages.flatMap(q=>Ze(q).filter(G=>G.kind==="tool")).at(-1);if(!y||y.kind!=="tool"||y.state==="input-streaming"||h.has(y.toolCallId))return;h.add(y.toolCallId);let k=bf(y.toolName,y.input);k&&k.slideIndex!==void 0&&e.goToSlide?.(k.slideIndex),a.flashToolTarget(k);},A=l=>{U(t,s,l.messages,i),d.hidden=l.messages.length>0,l.messages.length===0&&s.appendChild(d),$(t,r,v.proposals.list(),i,{accept:y=>{a?.flashToolTarget(null),v.proposals.apply(y),A(v.getSnapshot());},reject:y=>{v.proposals.revert(y),A(v.getSnapshot());},acceptAll:()=>{a?.flashToolTarget(null),v.proposals.acceptAll(),A(v.getSnapshot());}});let S=l.status==="submitted"||l.status==="streaming";n.classList.toggle("is-busy",S),C.setAttribute("aria-label",i(S?"pptx.ai.stop":"pptx.ai.send")),f.hidden=!l.error,f.textContent=l.error?i("pptx.ai.errorPrefix"):"",s.scrollTop=s.scrollHeight,T(l);},P=()=>{if(n.classList.contains("is-busy")){v.stop();return}let l=u.value.trim();l&&(u.value="",v.sendMessage(l));};b.addEventListener("submit",l=>{l.preventDefault(),P();}),u.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),P());});let w=a?.getPrefill().nonce??0,z=()=>{if(!a)return;let l=a.getPrefill();l.nonce!==w&&(w=l.nonce,u.value=l.text,u.focus());},K=a?.subscribe(z),O=v.subscribe(A);return A(v.getSnapshot()),{changeAnimator:v.changeAnimator,destroy(){O(),K?.(),c?.destroy(),n.replaceChildren();}}}export{gt as createAiPanel};