pptx-vanilla-viewer 2.7.0 → 2.9.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 +21 -0
- package/dist/ai-panel-OJWWPQW3.cjs +1 -0
- package/dist/{ai-panel-AUKGON6W.js → ai-panel-P3F5MPDN.js} +1 -1
- package/dist/chunk-H54T5LVL.js +2579 -0
- package/dist/chunk-O224FLRL.cjs +2579 -0
- package/dist/index.cjs +123 -70
- package/dist/index.d.ts +675 -84
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -70
- package/dist/smartart-3d-4XR267AX.cjs +1 -0
- package/dist/smartart-3d-5ELDYNIY.js +1 -0
- package/dist/styles.css +53 -0
- package/package.json +2 -2
- package/dist/ai-panel-AUEUQB4P.cjs +0 -1
- package/dist/chunk-GH6VDNPP.js +0 -2466
- package/dist/chunk-HTQCNJMD.cjs +0 -2466
- package/dist/smartart-3d-KGBJA3DV.js +0 -1
- package/dist/smartart-3d-OMEUBRBB.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('./chunk-B5PFHICE.cjs');var three=require('three'),OrbitControls_js=require('three/examples/jsm/controls/OrbitControls.js');var T=4,R=.86;function ne(t,n,e){let i=n.split(/\s+/u).filter(Boolean);if(i.length===0)return [];let s=[],o=i[0];for(let a=1;a<i.length;a++){let l=`${o} ${i[a]}`;t.measureText(l).width<=e?o=l:(s.push(o),o=i[a]);}return s.push(o),s}function oe(t,n){let e=n?.bold===void 0?"600":n.bold?"700":"400",i=n?.italic?"italic ":"",s=typeof n?.fontScale=="number"&&Number.isFinite(n.fontScale)&&n.fontScale>0?n.fontScale:1;return {weight:e,italic:i,color:n?.color??t,scale:s}}function ie(t,n,e,i,s,o){if(typeof document>"u"||!t.trim()||i<=0||s<=0)return null;let{weight:a,italic:l,color:r,scale:p}=oe(n,o),h=i*R,w=s*R,f=document.createElement("canvas");f.width=Math.max(8,Math.round(h*T)),f.height=Math.max(8,Math.round(w*T));let d=f.getContext("2d");if(!d)return null;let M="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",S=f.width*.94,g=x=>`${l}${a} ${x}px ${M}`,c=Math.max(6,e)*p*T,b=[];for(let x=0;x<12;x++){d.font=g(c),b=ne(d,t,S);let m=c*1.2;if(b.length*m<=f.height*.96||c<=6*T)break;c*=.88;}d.clearRect(0,0,f.width,f.height),d.fillStyle=r,d.textAlign="center",d.textBaseline="middle",d.font=g(c);let y=c*1.2,v=b.length*y,k=f.height/2-v/2+y/2;for(let x=0;x<b.length;x++){let m=k+x*y;if(d.fillText(b[x],f.width/2,m),o?.underline){let F=d.measureText(b[x]).width;d.strokeStyle=r,d.lineWidth=Math.max(1,c*.06),d.beginPath(),d.moveTo(f.width/2-F/2,m+c*.32),d.lineTo(f.width/2+F/2,m+c*.32),d.stroke();}}let u=new three.CanvasTexture(f);return u.colorSpace=three.SRGBColorSpace,u.minFilter=three.LinearFilter,u.magFilter=three.LinearFilter,u.flipY=false,u.premultiplyAlpha=false,u.wrapT=three.RepeatWrapping,u.repeat.set(1,-1),u.offset.set(0,1),u.needsUpdate=true,{texture:u,worldWidth:h,worldHeight:w}}function ae(t){let n=new three.Shape;t.outline.forEach((i,s)=>{s===0?n.moveTo(i.x,i.y):n.lineTo(i.x,i.y);}),n.closePath();let e=t.bevel>0;return new three.ExtrudeGeometry(n,{depth:t.depth,bevelEnabled:e,bevelThickness:t.bevel,bevelSize:t.bevel,bevelSegments:2,curveSegments:t.rounded?24:1,steps:1})}function se(t,n,e){let i=ae(e),s=new three.MeshStandardMaterial({color:new three.Color(e.fill),metalness:.12,roughness:.52,transparent:e.opacity<1,opacity:e.opacity}),o=new three.Mesh(i,s);if(o.position.set(e.position.x,e.position.y,e.position.z),o.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.add(o),n.push(i,s),e.strokeWidth>0){let a=new three.EdgesGeometry(i,30),l=new three.LineBasicMaterial({color:new three.Color(e.stroke)}),r=new three.LineSegments(a,l);r.position.copy(o.position),r.rotation.copy(o.rotation),t.add(r),n.push(a,l);}return i}function E(t,n){if(!t.text)return null;let e=ie(t.text,t.textColor,t.fontSize,t.halfWidth*2,t.halfHeight*2,n);if(!e)return null;let i=new three.PlaneGeometry(e.worldWidth,e.worldHeight),s=new three.MeshBasicMaterial({map:e.texture,transparent:true,depthWrite:false}),o=new three.Mesh(i,s),a=new three.Euler(t.rotation.x,t.rotation.y,t.rotation.z),l=new three.Vector3(0,0,t.depth+t.bevel+.4).applyEuler(a);return o.position.set(t.position.x+l.x,t.position.y+l.y,t.position.z+l.z),o.rotation.copy(a),{plane:o,disposables:[i,s,e.texture]}}function re(t,n,e){for(let i of e.connectors){if(i.points.length<2)continue;let s=new three.BufferGeometry().setFromPoints(i.points.map(a=>new three.Vector3(a.x,a.y,a.z))),o=new three.LineBasicMaterial({color:new three.Color(i.color),transparent:true,opacity:.7});t.add(new three.Line(s,o)),n.push(s,o);}}function C(t,n){n.plane&&t.remove(n.plane);for(let e of n.disposables)e.dispose();n.plane=null,n.disposables=[];}function le(t,n){let e=new three.Group,i=[],s=t.meshes.map(o=>{se(e,i,o);let a=E(o,n);return a&&e.add(a.plane),{node:o,plane:a?.plane??null,disposables:a?.disposables??[]}});return re(e,i,t),{group:e,setTextStyle(o){for(let a of s){C(e,a);let l=E(a.node,o);l&&(e.add(l.plane),a.plane=l.plane,a.disposables=l.disposables);}},dispose(){for(let o of i)o.dispose();for(let o of s)C(e,o);}}}var B=42;function ce(t){let n=1/0,e=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0,l=(r,p,h,w)=>{n=Math.min(n,r-w),e=Math.min(e,p-w),i=Math.min(i,h-w),s=Math.max(s,r+w),o=Math.max(o,p+w),a=Math.max(a,h+w);};for(let r of t.meshes){let p=Math.max(r.halfWidth,r.halfHeight)+r.depth+r.bevel;l(r.position.x,r.position.y,r.position.z,p);}for(let r of t.connectors)for(let p of r.points)l(p.x,p.y,p.z,1);return Number.isFinite(n)?{cx:(n+s)/2,cy:(e+o)/2,cz:(i+a)/2,radius:.5*Math.hypot(s-n,o-e,a-i)||1}:{cx:0,cy:0,cz:0,radius:Math.max(t.bounds.width,t.bounds.height)/2||1}}function de(t,n){let e=B*Math.PI/180,i=2*Math.atan(Math.tan(e/2)*n),s=Math.min(e,i);return t/Math.sin(s/2)*1.1}function pe(t,n,e,i,s={}){let o=new three.WebGLRenderer({canvas:t,antialias:true,alpha:!s.background});o.setPixelRatio(Math.min(typeof window>"u"?1:window.devicePixelRatio||1,s.maxPixelRatio??2)),o.setSize(e,i,false);let a=new three.Scene;s.background&&(a.background=new three.Color(s.background));let{cx:l,cy:r,cz:p,radius:h}=ce(n),w=e/Math.max(1,i),f=de(h,w),d=new three.PerspectiveCamera(B,w,.1,f*8+h*4);d.position.set(l+h*.25,r+h*.3,p+f),d.lookAt(l,r,p),a.add(new three.AmbientLight(16777215,.62));let M=new three.DirectionalLight(16777215,.95);M.position.set(l+h,r+h*1.4,p+f),a.add(M);let S=new three.DirectionalLight(16777215,.3);S.position.set(l-h,r-h*.6,p+f*.6),a.add(S);let g=le(n,s.textStyle);a.add(g.group);let c=null,b=u=>{u&&!c?(c=new OrbitControls_js.OrbitControls(d,t),c.enablePan=false,c.target.set(l,r,p),c.minDistance=f*.4,c.maxDistance=f*3,c.update()):!u&&c&&(c.dispose(),c=null),c&&(c.autoRotate=!!s.autoRotate,c.autoRotateSpeed=1.2);};b(!!s.interactive);let y=0,v=false,k=()=>{v||(y=requestAnimationFrame(k),c?.update(),o.render(a,d));};return y=requestAnimationFrame(k),{resize(u,x){d.aspect=u/Math.max(1,x),d.updateProjectionMatrix(),o.setSize(u,x,false);},setInteractive(u){b(u);},setTextStyle(u){g.setTextStyle(u);},dispose(){v=true,cancelAnimationFrame(y),c?.dispose(),g.dispose(),o.dispose();}}}exports.mountSmartArt3D=pe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-62D2TNHX.js';import {WebGLRenderer,Scene,Color,PerspectiveCamera,AmbientLight,DirectionalLight,Group,MeshStandardMaterial,Mesh,EdgesGeometry,LineBasicMaterial,LineSegments,PlaneGeometry,MeshBasicMaterial,Euler,Vector3,BufferGeometry,Line,Shape,ExtrudeGeometry,CanvasTexture,SRGBColorSpace,LinearFilter,RepeatWrapping}from'three';import {OrbitControls}from'three/examples/jsm/controls/OrbitControls.js';var T=4,R=.86;function ne(t,n,e){let i=n.split(/\s+/u).filter(Boolean);if(i.length===0)return [];let s=[],o=i[0];for(let a=1;a<i.length;a++){let l=`${o} ${i[a]}`;t.measureText(l).width<=e?o=l:(s.push(o),o=i[a]);}return s.push(o),s}function oe(t,n){let e=n?.bold===void 0?"600":n.bold?"700":"400",i=n?.italic?"italic ":"",s=typeof n?.fontScale=="number"&&Number.isFinite(n.fontScale)&&n.fontScale>0?n.fontScale:1;return {weight:e,italic:i,color:n?.color??t,scale:s}}function ie(t,n,e,i,s,o){if(typeof document>"u"||!t.trim()||i<=0||s<=0)return null;let{weight:a,italic:l,color:r,scale:p}=oe(n,o),h=i*R,w=s*R,f=document.createElement("canvas");f.width=Math.max(8,Math.round(h*T)),f.height=Math.max(8,Math.round(w*T));let d=f.getContext("2d");if(!d)return null;let M="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",S=f.width*.94,g=x=>`${l}${a} ${x}px ${M}`,c=Math.max(6,e)*p*T,b=[];for(let x=0;x<12;x++){d.font=g(c),b=ne(d,t,S);let m=c*1.2;if(b.length*m<=f.height*.96||c<=6*T)break;c*=.88;}d.clearRect(0,0,f.width,f.height),d.fillStyle=r,d.textAlign="center",d.textBaseline="middle",d.font=g(c);let y=c*1.2,v=b.length*y,k=f.height/2-v/2+y/2;for(let x=0;x<b.length;x++){let m=k+x*y;if(d.fillText(b[x],f.width/2,m),o?.underline){let F=d.measureText(b[x]).width;d.strokeStyle=r,d.lineWidth=Math.max(1,c*.06),d.beginPath(),d.moveTo(f.width/2-F/2,m+c*.32),d.lineTo(f.width/2+F/2,m+c*.32),d.stroke();}}let u=new CanvasTexture(f);return u.colorSpace=SRGBColorSpace,u.minFilter=LinearFilter,u.magFilter=LinearFilter,u.flipY=false,u.premultiplyAlpha=false,u.wrapT=RepeatWrapping,u.repeat.set(1,-1),u.offset.set(0,1),u.needsUpdate=true,{texture:u,worldWidth:h,worldHeight:w}}function ae(t){let n=new Shape;t.outline.forEach((i,s)=>{s===0?n.moveTo(i.x,i.y):n.lineTo(i.x,i.y);}),n.closePath();let e=t.bevel>0;return new ExtrudeGeometry(n,{depth:t.depth,bevelEnabled:e,bevelThickness:t.bevel,bevelSize:t.bevel,bevelSegments:2,curveSegments:t.rounded?24:1,steps:1})}function se(t,n,e){let i=ae(e),s=new MeshStandardMaterial({color:new Color(e.fill),metalness:.12,roughness:.52,transparent:e.opacity<1,opacity:e.opacity}),o=new Mesh(i,s);if(o.position.set(e.position.x,e.position.y,e.position.z),o.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.add(o),n.push(i,s),e.strokeWidth>0){let a=new EdgesGeometry(i,30),l=new LineBasicMaterial({color:new Color(e.stroke)}),r=new LineSegments(a,l);r.position.copy(o.position),r.rotation.copy(o.rotation),t.add(r),n.push(a,l);}return i}function E(t,n){if(!t.text)return null;let e=ie(t.text,t.textColor,t.fontSize,t.halfWidth*2,t.halfHeight*2,n);if(!e)return null;let i=new PlaneGeometry(e.worldWidth,e.worldHeight),s=new MeshBasicMaterial({map:e.texture,transparent:true,depthWrite:false}),o=new Mesh(i,s),a=new Euler(t.rotation.x,t.rotation.y,t.rotation.z),l=new Vector3(0,0,t.depth+t.bevel+.4).applyEuler(a);return o.position.set(t.position.x+l.x,t.position.y+l.y,t.position.z+l.z),o.rotation.copy(a),{plane:o,disposables:[i,s,e.texture]}}function re(t,n,e){for(let i of e.connectors){if(i.points.length<2)continue;let s=new BufferGeometry().setFromPoints(i.points.map(a=>new Vector3(a.x,a.y,a.z))),o=new LineBasicMaterial({color:new Color(i.color),transparent:true,opacity:.7});t.add(new Line(s,o)),n.push(s,o);}}function C(t,n){n.plane&&t.remove(n.plane);for(let e of n.disposables)e.dispose();n.plane=null,n.disposables=[];}function le(t,n){let e=new Group,i=[],s=t.meshes.map(o=>{se(e,i,o);let a=E(o,n);return a&&e.add(a.plane),{node:o,plane:a?.plane??null,disposables:a?.disposables??[]}});return re(e,i,t),{group:e,setTextStyle(o){for(let a of s){C(e,a);let l=E(a.node,o);l&&(e.add(l.plane),a.plane=l.plane,a.disposables=l.disposables);}},dispose(){for(let o of i)o.dispose();for(let o of s)C(e,o);}}}var B=42;function ce(t){let n=1/0,e=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0,l=(r,p,h,w)=>{n=Math.min(n,r-w),e=Math.min(e,p-w),i=Math.min(i,h-w),s=Math.max(s,r+w),o=Math.max(o,p+w),a=Math.max(a,h+w);};for(let r of t.meshes){let p=Math.max(r.halfWidth,r.halfHeight)+r.depth+r.bevel;l(r.position.x,r.position.y,r.position.z,p);}for(let r of t.connectors)for(let p of r.points)l(p.x,p.y,p.z,1);return Number.isFinite(n)?{cx:(n+s)/2,cy:(e+o)/2,cz:(i+a)/2,radius:.5*Math.hypot(s-n,o-e,a-i)||1}:{cx:0,cy:0,cz:0,radius:Math.max(t.bounds.width,t.bounds.height)/2||1}}function de(t,n){let e=B*Math.PI/180,i=2*Math.atan(Math.tan(e/2)*n),s=Math.min(e,i);return t/Math.sin(s/2)*1.1}function pe(t,n,e,i,s={}){let o=new WebGLRenderer({canvas:t,antialias:true,alpha:!s.background});o.setPixelRatio(Math.min(typeof window>"u"?1:window.devicePixelRatio||1,s.maxPixelRatio??2)),o.setSize(e,i,false);let a=new Scene;s.background&&(a.background=new Color(s.background));let{cx:l,cy:r,cz:p,radius:h}=ce(n),w=e/Math.max(1,i),f=de(h,w),d=new PerspectiveCamera(B,w,.1,f*8+h*4);d.position.set(l+h*.25,r+h*.3,p+f),d.lookAt(l,r,p),a.add(new AmbientLight(16777215,.62));let M=new DirectionalLight(16777215,.95);M.position.set(l+h,r+h*1.4,p+f),a.add(M);let S=new DirectionalLight(16777215,.3);S.position.set(l-h,r-h*.6,p+f*.6),a.add(S);let g=le(n,s.textStyle);a.add(g.group);let c=null,b=u=>{u&&!c?(c=new OrbitControls(d,t),c.enablePan=false,c.target.set(l,r,p),c.minDistance=f*.4,c.maxDistance=f*3,c.update()):!u&&c&&(c.dispose(),c=null),c&&(c.autoRotate=!!s.autoRotate,c.autoRotateSpeed=1.2);};b(!!s.interactive);let y=0,v=false,k=()=>{v||(y=requestAnimationFrame(k),c?.update(),o.render(a,d));};return y=requestAnimationFrame(k),{resize(u,x){d.aspect=u/Math.max(1,x),d.updateProjectionMatrix(),o.setSize(u,x,false);},setInteractive(u){b(u);},setTextStyle(u){g.setTextStyle(u);},dispose(){v=true,cancelAnimationFrame(y),c?.dispose(),g.dispose(),o.dispose();}}}export{pe as mountSmartArt3D};
|
package/dist/styles.css
CHANGED
|
@@ -4609,6 +4609,59 @@ svg[data-pptx-motion-path-overlay] [data-pptx-motion-path-handle] { pointer-even
|
|
|
4609
4609
|
}
|
|
4610
4610
|
.pptxv-readonly-banner-dismiss:hover { background: rgba(120, 53, 15, 0.12); }
|
|
4611
4611
|
.pptxv-readonly-banner-dismiss svg { width: 14px; height: 14px; }
|
|
4612
|
+
.pptxv-readonly-banner-password-form {
|
|
4613
|
+
display: flex;
|
|
4614
|
+
flex: none;
|
|
4615
|
+
align-items: center;
|
|
4616
|
+
gap: 8px;
|
|
4617
|
+
}
|
|
4618
|
+
.pptxv-readonly-banner-password-input {
|
|
4619
|
+
padding: 3px 8px;
|
|
4620
|
+
border: 1px solid #b45309;
|
|
4621
|
+
border-radius: 4px;
|
|
4622
|
+
background: #fff;
|
|
4623
|
+
color: #78350f;
|
|
4624
|
+
font: inherit;
|
|
4625
|
+
}
|
|
4626
|
+
.pptxv-readonly-banner-unlock {
|
|
4627
|
+
flex: none;
|
|
4628
|
+
padding: 3px 10px;
|
|
4629
|
+
border: 1px solid #b45309;
|
|
4630
|
+
border-radius: 4px;
|
|
4631
|
+
background: #fff;
|
|
4632
|
+
color: #78350f;
|
|
4633
|
+
font: inherit;
|
|
4634
|
+
font-weight: 600;
|
|
4635
|
+
cursor: pointer;
|
|
4636
|
+
}
|
|
4637
|
+
.pptxv-readonly-banner-unlock:hover { background: #fde68a; }
|
|
4638
|
+
.pptxv-readonly-banner-password-cancel {
|
|
4639
|
+
flex: none;
|
|
4640
|
+
padding: 3px 8px;
|
|
4641
|
+
border: none;
|
|
4642
|
+
background: transparent;
|
|
4643
|
+
color: inherit;
|
|
4644
|
+
font: inherit;
|
|
4645
|
+
cursor: pointer;
|
|
4646
|
+
border-radius: 4px;
|
|
4647
|
+
}
|
|
4648
|
+
.pptxv-readonly-banner-password-cancel:hover { background: rgba(120, 53, 15, 0.12); }
|
|
4649
|
+
.pptxv-readonly-banner-password-error {
|
|
4650
|
+
flex: none;
|
|
4651
|
+
color: #991b1b;
|
|
4652
|
+
font-size: 12px;
|
|
4653
|
+
}
|
|
4654
|
+
.pptxv-sr-only {
|
|
4655
|
+
position: absolute;
|
|
4656
|
+
width: 1px;
|
|
4657
|
+
height: 1px;
|
|
4658
|
+
padding: 0;
|
|
4659
|
+
margin: -1px;
|
|
4660
|
+
overflow: hidden;
|
|
4661
|
+
clip: rect(0, 0, 0, 0);
|
|
4662
|
+
white-space: nowrap;
|
|
4663
|
+
border: 0;
|
|
4664
|
+
}
|
|
4612
4665
|
|
|
4613
4666
|
.pptxv-compat-toasts {
|
|
4614
4667
|
/* Position, size, stacking order and pointer-events come from
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pptx-vanilla-viewer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Zero-framework PowerPoint viewer and editor: render, edit, present, and export PPTX slides with plain DOM, no React/Vue/Angular required.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"jspdf": "^4.2.1",
|
|
62
62
|
"jszip": "^3.10.1",
|
|
63
63
|
"lucide": "^1.34.0",
|
|
64
|
-
"pptx-viewer-mcp": "^2.
|
|
64
|
+
"pptx-viewer-mcp": "^2.4.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/dompurify": "^3.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkHTQCNJMD_cjs=require('./chunk-HTQCNJMD.cjs');require('./chunk-B5PFHICE.cjs');function K(o){let{doc:t,t:n,controller:i}=o,a=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-focus"),h=(p,m,l)=>{let s=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-focus-btn");return s.type="button",s.title=m,s.setAttribute("aria-label",m),s.appendChild(chunkHTQCNJMD_cjs.mn(t,p)),s.addEventListener("click",l),s},x=()=>{a.replaceChildren();let p=i.getEffectiveTargets(),m=i.hasPicks(),l=i.isPinned(),s=i.isPicking(),g=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-focus-row"),f=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-focus-label");f.textContent=n("pptx.ai.focusScope"),g.appendChild(f);for(let r of chunkHTQCNJMD_cjs.Qm(p,o.getSlides())){let b=chunkHTQCNJMD_cjs.bn(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=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-focus-pinned");r.textContent=n("pptx.ai.pinnedFocus"),g.appendChild(r);}let C=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-focus-actions"),d=chunkHTQCNJMD_cjs.Rm(p,o.getSlides());if(d){let r=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-focus-merge");r.type="button",r.append(chunkHTQCNJMD_cjs.mn(t,"git-merge"),t.createTextNode(n("pptx.ai.mergeSelectedTables"))),r.addEventListener("click",()=>o.onSendDirective(chunkHTQCNJMD_cjs.Sm(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=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-focus-pick"),b=chunkHTQCNJMD_cjs.mn(t,"crosshair");b.classList.add("pptxv-ai-focus-pick-icon");let k=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-focus-pick-hint");k.textContent=n("pptx.ai.pickElementHint");let T=chunkHTQCNJMD_cjs.bn(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=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-chats");i.type="button",i.append(chunkHTQCNJMD_cjs.mn(t,"history"),t.createTextNode(n("pptx.ai.chats")));let a=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-history");a.hidden=true;let h=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-history-head"),x=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-history-title");x.textContent=n("pptx.ai.historyTitle");let c=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-history-new");c.type="button",c.append(chunkHTQCNJMD_cjs.mn(t,"plus"),t.createTextNode(n("pptx.ai.newChat"))),h.append(x,c);let p=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-history-body"),m=chunkHTQCNJMD_cjs.bn(t,"p","pptxv-ai-history-hint");m.textContent=n("pptx.ai.historyHint"),a.append(h,p,m);let l=chunkHTQCNJMD_cjs.Um({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=chunkHTQCNJMD_cjs.bn(t,"p","pptxv-ai-history-empty");d.textContent=n("pptx.ai.historyEmpty"),p.appendChild(d);return}let C=chunkHTQCNJMD_cjs.bn(t,"ul","pptxv-ai-history-list");for(let d of f){let y=chunkHTQCNJMD_cjs.bn(t,"li","pptxv-ai-history-row"),r=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-history-resume");r.type="button",r.classList.toggle("is-active",d.id===l.activeChatId());let b=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-history-text"),k=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-history-name");k.textContent=d.title||n("pptx.ai.untitledChat");let T=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-history-meta");T.textContent=n("pptx.ai.messageCount",{count:d.messageCount}),b.append(k,T),r.append(chunkHTQCNJMD_cjs.mn(t,"comment"),b),r.addEventListener("click",()=>{l.resumeChat(d.id),a.hidden=true;});let P=chunkHTQCNJMD_cjs.bn(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(chunkHTQCNJMD_cjs.mn(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=chunkHTQCNJMD_cjs.Zm(t.toolName,t.input,h?"present":"past"),c=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-tool"),p=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-tool-head"),m=chunkHTQCNJMD_cjs.mn(o,_[x.icon]??"wrench");m.classList.add("pptxv-ai-tool-icon");let l=chunkHTQCNJMD_cjs.bn(o,"span","pptxv-ai-tool-name");l.textContent=x.label;let s=chunkHTQCNJMD_cjs.bn(o,"span","pptxv-ai-tool-state");if(i?(s.classList.add("is-error"),s.append(chunkHTQCNJMD_cjs.mn(o,"alert"),o.createTextNode(n("pptx.ai.toolFailed")))):a?(s.classList.add("is-done"),s.append(chunkHTQCNJMD_cjs.mn(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=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-tool-error");f.textContent=t.errorText,c.appendChild(f);}let g=chunkHTQCNJMD_cjs.Ym(t.input);if(g){let f=chunkHTQCNJMD_cjs.bn(o,"details","pptxv-ai-tool-details"),C=chunkHTQCNJMD_cjs.bn(o,"summary");C.textContent=n("pptx.ai.toolDetails");let d=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-tool-raw");d.textContent=`${chunkHTQCNJMD_cjs.Xm(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=chunkHTQCNJMD_cjs.Mm(a);if(x.length===0&&!h)continue;let c=chunkHTQCNJMD_cjs.bn(o,"div",`pptxv-ai-msg pptxv-ai-msg-${a.role}`),p=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-msg-avatar");p.setAttribute("aria-label",i(h?"pptx.ai.you":"pptx.ai.assistant")),p.appendChild(chunkHTQCNJMD_cjs.mn(o,h?"comment":"sparkles"));let m=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-msg-body");for(let l of x)if(l.kind==="text"){let s=chunkHTQCNJMD_cjs.bn(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=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-proposals-header"),x=chunkHTQCNJMD_cjs.bn(o,"span","pptxv-ai-proposals-title");if(x.textContent=i("pptx.ai.pendingChanges",{count:n.length}),h.appendChild(x),n.length>1){let c=chunkHTQCNJMD_cjs.bn(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=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-proposal");a.dataset.proposalId=t.id;let h=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-proposal-eyebrow");h.textContent=n("pptx.ai.proposedChange"),a.appendChild(h);let x=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-proposal-label");if(x.textContent=t.label,a.appendChild(x),t.summary.length>0){let l=chunkHTQCNJMD_cjs.bn(o,"ul","pptxv-ai-proposal-summary");for(let s of t.summary){let g=chunkHTQCNJMD_cjs.bn(o,"li");g.textContent=chunkHTQCNJMD_cjs.Jm(s),l.appendChild(g);}a.appendChild(l);}let c=chunkHTQCNJMD_cjs.bn(o,"div","pptxv-ai-proposal-actions"),p=chunkHTQCNJMD_cjs.bn(o,"button","pptxv-ai-proposal-btn is-accept");p.type="button",p.append(chunkHTQCNJMD_cjs.mn(o,"check"),o.createTextNode(n("pptx.ai.accept"))),p.addEventListener("click",()=>i.accept(t.id));let m=chunkHTQCNJMD_cjs.bn(o,"button","pptxv-ai-proposal-btn is-reject");return m.type="button",m.append(chunkHTQCNJMD_cjs.mn(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=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-header"),h=chunkHTQCNJMD_cjs.bn(t,"span","pptxv-ai-title");h.textContent=i("pptx.ai.title");let x=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-close");x.type="button",x.title=i("pptx.ai.close"),x.setAttribute("aria-label",i("pptx.ai.close")),x.appendChild(chunkHTQCNJMD_cjs.mn(t,"close")),x.addEventListener("click",()=>o.onClose?.()),a.append(chunkHTQCNJMD_cjs.mn(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=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-messages");l.setAttribute("role","log"),l.setAttribute("aria-live","polite");let s=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-empty");s.textContent=i("pptx.ai.emptyHint"),l.appendChild(s);let g=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-proposals");g.hidden=true;let f=chunkHTQCNJMD_cjs.bn(t,"div","pptxv-ai-error");f.setAttribute("role","alert"),f.hidden=true;let C=chunkHTQCNJMD_cjs.bn(t,"form","pptxv-ai-composer"),d=chunkHTQCNJMD_cjs.bn(t,"textarea","pptxv-ai-input");d.rows=2,d.placeholder=i("pptx.ai.placeholder"),d.setAttribute("aria-label",i("pptx.ai.placeholder"));let y=chunkHTQCNJMD_cjs.bn(t,"button","pptxv-ai-send");y.type="submit",y.setAttribute("aria-label",i("pptx.ai.send")),y.appendChild(chunkHTQCNJMD_cjs.mn(t,"send")),C.append(d,y),n.append(a,...m?[m.el]:[],l,g,f,C);try{c=await(o.createChat??chunkHTQCNJMD_cjs.Vm)({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:chunkHTQCNJMD_cjs.Tm(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=>chunkHTQCNJMD_cjs.Mm(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=chunkHTQCNJMD_cjs._m(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;
|