pptx-vanilla-viewer 2.2.0 → 2.4.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 +50 -0
- package/dist/{ai-panel-3IIPXB2F.js → ai-panel-FN3ICKK4.js} +1 -1
- package/dist/ai-panel-SWFPPLI4.cjs +1 -0
- package/dist/{chunk-PF5W56XU.cjs → chunk-OBWXMT2T.cjs} +363 -279
- package/dist/{chunk-3XQHIDTV.js → chunk-SG47CFJD.js} +363 -279
- package/dist/index.cjs +238 -75
- package/dist/index.d.ts +198 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +237 -74
- package/dist/styles.css +170 -0
- package/package.json +1 -1
- package/dist/ai-panel-M3W65ORV.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,56 @@ 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.3.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.3.0) - 2026-09-02
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **vanilla:** Crop to shape, ActiveX overlay, pattern fills, placeholder prompts and loop-continuously (by @ChristopherVR) ([92e8b04](https://github.com/ChristopherVR/pptx-viewer/commit/92e8b04aaf2c2df280311f7a681cc36bf348516f))
|
|
15
|
+
- **shared:** Add the pptx.effects.rotateWithShape key and export DEFAULT_FONT_SIZE (by @ChristopherVR) ([2021a28](https://github.com/ChristopherVR/pptx-viewer/commit/2021a28c4442b5769f3faaed1cb7abc27b7316a3))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- **vanilla:** Paint open arrowheads as strokes and restyle every text run from AI edits (by @ChristopherVR) ([7557e41](https://github.com/ChristopherVR/pptx-viewer/commit/7557e4117e4c4a43cacf339f0c4bc4875676daf4))
|
|
20
|
+
- **vanilla:** Localise the outer-shadow "Rotate with Shape" label (by @ChristopherVR) ([d0ad3b8](https://github.com/ChristopherVR/pptx-viewer/commit/d0ad3b8078721eed4b3e0b084376e500cf04a70a))
|
|
21
|
+
- **shared:** Stop eaLnBrk splitting Latin words mid-word (by @ChristopherVR) ([c3eedb9](https://github.com/ChristopherVR/pptx-viewer/commit/c3eedb9e7adaccfcd5fc954518d554218f1050e2))
|
|
22
|
+
- **shared:** Resolve Google webfonts from a bundled catalogue instead of probing the API (by @ChristopherVR) ([43bda70](https://github.com/ChristopherVR/pptx-viewer/commit/43bda70309f0e9b2cd80dc3ae2ec5cdecda41548))
|
|
23
|
+
|
|
24
|
+
### Refactor
|
|
25
|
+
|
|
26
|
+
- **vanilla:** Repoint onto the wave-2 shared modules (by @ChristopherVR) ([65a982b](https://github.com/ChristopherVR/pptx-viewer/commit/65a982b2207139622f09ba0270784f68e7da7d2e))
|
|
27
|
+
- **shared:** Make editor-geometry nudge helpers alias editor-keymap (by @ChristopherVR) ([87cf256](https://github.com/ChristopherVR/pptx-viewer/commit/87cf256d9bf0565dd6b70e264c6a558416d31ef5))
|
|
28
|
+
|
|
29
|
+
### Documentation
|
|
30
|
+
|
|
31
|
+
- **vanilla:** Describe webfont resolution as a catalogue lookup (by @ChristopherVR) ([128275d](https://github.com/ChristopherVR/pptx-viewer/commit/128275d98e7dc7851e8a8469c9fcba1cf789e93f))
|
|
32
|
+
|
|
33
|
+
## [2.2.0](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.2.0) - 2026-09-02
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
- **core:** Parse and save bar3D shape, radar style and surface wireframe (by @ChristopherVR) ([1f46205](https://github.com/ChristopherVR/pptx-viewer/commit/1f46205a1f1280df55baf990a3ed496e308233a2))
|
|
38
|
+
- **shared:** Google fonts webfont fallback for referenced families (by @nikko82) ([49571a5](https://github.com/ChristopherVR/pptx-viewer/commit/49571a5d192d54f992dd34cfdf3b60d8780c79ad))
|
|
39
|
+
- **vanilla:** Load google-hosted webfonts for missing families (by @nikko82) ([8876311](https://github.com/ChristopherVR/pptx-viewer/commit/88763116c1f10efd2cde9eb1f331d74e7b886240))
|
|
40
|
+
- **shared:** Morph matching heuristics for media, twins, and group twins (by @nikko82) ([d5ba90b](https://github.com/ChristopherVR/pptx-viewer/commit/d5ba90b2bbc4ed8866e2367bb7751c00a3cc9f8f))
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
- **core:** Close OpenXML round-trip gaps in charts, pictures, tables, text and structure (by @ChristopherVR) ([9780265](https://github.com/ChristopherVR/pptx-viewer/commit/9780265ead99aba7f9e3fde80c0527eaed4f8d17))
|
|
45
|
+
- **shared:** Equation reverse conversion, chart manual layout and editor decision helpers (by @ChristopherVR) ([bffc2b3](https://github.com/ChristopherVR/pptx-viewer/commit/bffc2b380f125787cd39b20096127ab4eb9d6bbf))
|
|
46
|
+
- **shared:** Stop the webfont resolver dropping families the injected stylesheet satisfied (by @ChristopherVR) ([25a9a78](https://github.com/ChristopherVR/pptx-viewer/commit/25a9a781ade7bb3f2dc79847f2ade3284237b7c5))
|
|
47
|
+
- **core:** Write gridline elements on generated chart axes (by @ChristopherVR) ([0d03c1a](https://github.com/ChristopherVR/pptx-viewer/commit/0d03c1a17c29499e234cc7e836a55e2d29bd2716))
|
|
48
|
+
- **shared:** Honour c:majorGridlines when drawing value-axis gridlines (by @ChristopherVR) ([8b9dd88](https://github.com/ChristopherVR/pptx-viewer/commit/8b9dd88cbe32f873ed8246903105aba0a7ad7e3b))
|
|
49
|
+
- **core:** Snapshot baked-in a14 corrections next to the live values (by @ChristopherVR) ([9e6cc01](https://github.com/ChristopherVR/pptx-viewer/commit/9e6cc01181e481d6e3132cc086c6f85c1c80fd44))
|
|
50
|
+
- **shared:** Stop re-applying a14 corrections PowerPoint already baked in (by @ChristopherVR) ([52766e7](https://github.com/ChristopherVR/pptx-viewer/commit/52766e78250805a4a03353dc22b1ed637f0c750f))
|
|
51
|
+
|
|
52
|
+
### Refactor
|
|
53
|
+
|
|
54
|
+
- **shared:** Extract binding-duplicated engines, option lists and parity descriptors (by @ChristopherVR) ([b0acb02](https://github.com/ChristopherVR/pptx-viewer/commit/b0acb02210b17266f44eed013c2d801d3992257e))
|
|
55
|
+
|
|
56
|
+
### Testing
|
|
57
|
+
|
|
58
|
+
- **e2e:** Pin the webfont fallback probe across the five bindings (by @nikko82) ([aabb9dd](https://github.com/ChristopherVR/pptx-viewer/commit/aabb9dd226fc08df63f270aef080936d9f602268))
|
|
59
|
+
|
|
10
60
|
## [2.1.5](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-vanilla-viewer@2.1.5) - 2026-09-01
|
|
11
61
|
|
|
12
62
|
### Dependencies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {sl,Dl,Ll,Jl,Kl,Il,Pl,nl,ol,pl,Ol,Nl,Ml,Fl}from'./chunk-3XQHIDTV.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=sl(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=sl(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Dl(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=sl(t,"div","pptxv-ai-focus-row"),f=sl(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of nl(p,o.getSlides())){let b=sl(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=sl(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=sl(t,"div","pptxv-ai-focus-actions"),d=ol(p,o.getSlides());if(d){let r=sl(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Dl(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(pl(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=sl(t,"div","pptxv-ai-focus-pick"),b=Dl(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=sl(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=sl(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=sl(t,"button","pptxv-ai-chats");i.type="button",i.append(Dl(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=sl(t,"div","pptxv-ai-history");a.hidden=true;let h=sl(t,"div","pptxv-ai-history-head"),x=sl(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=sl(t,"button","pptxv-ai-history-new");c.type="button",c.append(Dl(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=sl(t,"div","pptxv-ai-history-body"),m=sl(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=Kl({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=sl(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=sl(t,"ul","pptxv-ai-history-list");for(let d of f){let y=sl(t,"li","pptxv-ai-history-row"),r=sl(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=sl(t,"span","pptxv-ai-history-text"),k=sl(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=sl(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Dl(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=sl(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(Dl(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=Ol(t.toolName,t.input,h?"present":"past"),c=sl(o,"div","pptxv-ai-tool"),p=sl(o,"div","pptxv-ai-tool-head"),m=Dl(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=sl(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=sl(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Dl(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Dl(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=sl(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=Nl(t.input);if(g){let f=sl(o,"details","pptxv-ai-tool-details"),C=sl(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=sl(o,"div","pptxv-ai-tool-raw");d.textContent=`${Ml(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=Il(a);if(x.length===0&&!h)continue;let c=sl(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=sl(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Dl(o,h?"comment":"sparkles"));let m=sl(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=sl(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=sl(o,"div","pptxv-ai-proposals-header"),x=sl(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=sl(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=sl(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=sl(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=sl(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=sl(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=sl(o,"li");g.textContent=Fl(s),l.appendChild(g);}a.appendChild(l);}let c=sl(o,"div","pptxv-ai-proposal-actions"),p=sl(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Dl(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=sl(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Dl(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=sl(t,"div","pptxv-ai-header"),h=sl(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=sl(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Dl(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Dl(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=sl(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=sl(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=sl(t,"div","pptxv-ai-proposals");g.hidden=true;let f=sl(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=sl(t,"form","pptxv-ai-composer"),d=sl(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=sl(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Dl(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??Ll)({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:Jl(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=>Il(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=Pl(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 {wm,Hm,om,mm,nm,fm,tm,jm,km,lm,sm,rm,qm,cm}from'./chunk-SG47CFJD.js';import'./chunk-62D2TNHX.js';function K(o){let{doc:t,t:n,controller:i}=o,a=wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=wm(t,"div","pptxv-ai-focus-row"),f=wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of jm(p,o.getSlides())){let b=wm(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=wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=wm(t,"div","pptxv-ai-focus-actions"),d=km(p,o.getSlides());if(d){let r=wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(lm(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=wm(t,"div","pptxv-ai-focus-pick"),b=Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=wm(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=wm(t,"button","pptxv-ai-chats");i.type="button",i.append(Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=wm(t,"div","pptxv-ai-history");a.hidden=true;let h=wm(t,"div","pptxv-ai-history-head"),x=wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=wm(t,"div","pptxv-ai-history-body"),m=wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=nm({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=wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=wm(t,"li","pptxv-ai-history-row"),r=wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=wm(t,"span","pptxv-ai-history-text"),k=wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=wm(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(Hm(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=sm(t.toolName,t.input,h?"present":"past"),c=wm(o,"div","pptxv-ai-tool"),p=wm(o,"div","pptxv-ai-tool-head"),m=Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(Hm(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=wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=rm(t.input);if(g){let f=wm(o,"details","pptxv-ai-tool-details"),C=wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${qm(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=fm(a);if(x.length===0&&!h)continue;let c=wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(Hm(o,h?"comment":"sparkles"));let m=wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=wm(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=wm(o,"div","pptxv-ai-proposals-header"),x=wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=wm(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=wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=wm(o,"li");g.textContent=cm(s),l.appendChild(g);}a.appendChild(l);}let c=wm(o,"div","pptxv-ai-proposal-actions"),p=wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(Hm(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=wm(t,"div","pptxv-ai-header"),h=wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(Hm(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=wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=wm(t,"form","pptxv-ai-composer"),d=wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??om)({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:mm(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=>fm(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=tm(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkOBWXMT2T_cjs=require('./chunk-OBWXMT2T.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkOBWXMT2T_cjs.Hm(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-row"),f=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkOBWXMT2T_cjs.jm(p,o.getSlides())){let b=chunkOBWXMT2T_cjs.wm(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=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-actions"),d=chunkOBWXMT2T_cjs.km(p,o.getSlides());if(d){let r=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkOBWXMT2T_cjs.Hm(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkOBWXMT2T_cjs.lm(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=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-focus-pick"),b=chunkOBWXMT2T_cjs.Hm(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkOBWXMT2T_cjs.wm(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=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkOBWXMT2T_cjs.Hm(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history-head"),x=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkOBWXMT2T_cjs.Hm(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-history-body"),m=chunkOBWXMT2T_cjs.wm(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkOBWXMT2T_cjs.nm({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=chunkOBWXMT2T_cjs.wm(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkOBWXMT2T_cjs.wm(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkOBWXMT2T_cjs.wm(t,"li","pptxv-ai-history-row"),r=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-text"),k=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkOBWXMT2T_cjs.Hm(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkOBWXMT2T_cjs.wm(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(chunkOBWXMT2T_cjs.Hm(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=chunkOBWXMT2T_cjs.sm(t.toolName,t.input,h?"present":"past"),c=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool"),p=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-head"),m=chunkOBWXMT2T_cjs.Hm(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkOBWXMT2T_cjs.Hm(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkOBWXMT2T_cjs.Hm(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=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkOBWXMT2T_cjs.rm(t.input);if(g){let f=chunkOBWXMT2T_cjs.wm(o,"details","pptxv-ai-tool-details"),C=chunkOBWXMT2T_cjs.wm(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkOBWXMT2T_cjs.qm(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=chunkOBWXMT2T_cjs.fm(a);if(x.length===0&&!h)continue;let c=chunkOBWXMT2T_cjs.wm(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkOBWXMT2T_cjs.Hm(o,h?"comment":"sparkles"));let m=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkOBWXMT2T_cjs.wm(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=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposals-header"),x=chunkOBWXMT2T_cjs.wm(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkOBWXMT2T_cjs.wm(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=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkOBWXMT2T_cjs.wm(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkOBWXMT2T_cjs.wm(o,"li");g.textContent=chunkOBWXMT2T_cjs.cm(s),l.appendChild(g);}a.appendChild(l);}let c=chunkOBWXMT2T_cjs.wm(o,"div","pptxv-ai-proposal-actions"),p=chunkOBWXMT2T_cjs.wm(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkOBWXMT2T_cjs.Hm(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkOBWXMT2T_cjs.wm(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkOBWXMT2T_cjs.Hm(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=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-header"),h=chunkOBWXMT2T_cjs.wm(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkOBWXMT2T_cjs.Hm(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkOBWXMT2T_cjs.Hm(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=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkOBWXMT2T_cjs.wm(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkOBWXMT2T_cjs.wm(t,"form","pptxv-ai-composer"),d=chunkOBWXMT2T_cjs.wm(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkOBWXMT2T_cjs.wm(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkOBWXMT2T_cjs.Hm(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkOBWXMT2T_cjs.om)({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:chunkOBWXMT2T_cjs.mm(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=>chunkOBWXMT2T_cjs.fm(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=chunkOBWXMT2T_cjs.tm(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;
|