slidecanvas 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -6
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var He=Object.defineProperty,je=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var be=Object.getOwnPropertySymbols;var We=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var ye=(y,l,r)=>l in y?He(y,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):y[l]=r,w=(y,l)=>{for(var r in l||(l={}))We.call(l,r)&&ye(y,r,l[r]);if(be)for(var r of be(l))Ge.call(l,r)&&ye(y,r,l[r]);return y},I=(y,l)=>je(y,Xe(l));import{useState as M,useCallback as de,useMemo as Bt,useEffect as ue}from"react";import Ne,{useState as K}from"react";import{Type as Ke,Image as Ve,Square as qe,Download as ce,Plus as pe,Trash2 as Je,Bold as Ze,Italic as Qe,AlignLeft as et,AlignCenter as tt,AlignRight as st,List as ve,Layout as it,Columns as at,FileText as nt,History as ot,Share2 as lt,Play as rt,Sparkles as ae,RefreshCw as fe}from"lucide-react";import{clsx as Ye}from"clsx";import{twMerge as _e}from"tailwind-merge";function F(...y){return _e(Ye(y))}import{Fragment as we,jsx as s,jsxs as c}from"react/jsx-runtime";var dt=["Inter","Lato","Open Sans","Poppins","Roboto","Roboto Slab","Georgia","Playfair Display","Merriweather","Nunito Sans","Montserrat","Oswald","Raleway","Ubuntu","Lora","PT Sans","PT Serif","Play","Arvo","Kanit","Times New Roman","Arial"],ct=[12,14,16,18,20,24,28,32,36,48,64,72,96],pt=[{name:"Basic Shapes",shapes:["rect","circle","triangle","rightTriangle","rhombus","parallelogram","trapezoid","pentagon","hexagon","heptagon","octagon","heart","smiley","sun","moon"]},{name:"Arrows",shapes:["arrowRight","arrowLeft","arrowUp","arrowDown","arrowLeftRight","arrowUpDown"]},{name:"Stars & Symbols",shapes:["star4","star5","star6","star8","cloud","lightning"]},{name:"Equation Shapes",shapes:["plus","minus","multiply","divide","equal"]}],ft=({onAddShape:y})=>{let[l,r]=K(!1);return Ne.useEffect(()=>(window._toggleShapesMenu=()=>r(!l),()=>{window._toggleShapesMenu=void 0}),[l]),l?s("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-2xl shadow-2xl p-4 w-[320px] max-h-[480px] overflow-y-auto z-[100] animate-in fade-in zoom-in-95 duration-200",children:s("div",{className:"flex flex-col gap-6",children:pt.map(m=>c("div",{className:"flex flex-col gap-2",children:[s("span",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 px-1",children:m.name}),s("div",{className:"grid grid-cols-5 gap-1",children:m.shapes.map(g=>s("button",{onClick:()=>{y(g),r(!1)},className:"aspect-square hover:bg-slate-50 rounded-lg flex items-center justify-center border border-transparent hover:border-slate-100 transition-all group",title:g,children:s("div",{className:"w-6 h-6 bg-slate-100 rounded-sm group-hover:bg-blue-100 group-hover:scale-110 transition-all flex items-center justify-center overflow-hidden",children:s("div",{className:"text-[8px] font-bold text-slate-400 group-hover:text-blue-600 uppercase text-center scale-[0.8] leading-tight",children:g.slice(0,3)})})},g))})]},m.name))})}):null},Se=({onAddText:y,onAddImage:l,onAddShape:r,onAddSlide:m,onExport:g,onFormatText:p,onDeleteElement:N,onApplyLayout:v,onPlay:f,selectedElement:i,appName:b,onAiAction:a,onAiResponseAction:x,aiResponse:t,isAiLoading:e,onNewPresentation:n,onLoadPresentation:u})=>{let S=Ne.useRef(null),[P,R]=K("Home"),[E,O]=K(!1),[H,j]=K(!1),[X,C]=K(!1),[J,B]=K(!1),[W,G]=K("file"),[L,Y]=K(""),z=(i==null?void 0:i.type)==="text",te=(i==null?void 0:i.type)==="shape",he="#B7472A";return c("div",{className:"flex flex-col border-b border-slate-200 bg-white z-50 select-none",children:[c("div",{className:"flex items-center bg-[#F3F2F1] border-b border-slate-200 h-10",children:[s("div",{className:"flex items-center h-full px-4 border-r border-slate-200 mr-2 bg-[#B7472A] text-white",children:s("span",{className:"font-black text-xs tracking-tighter capitalize",children:b})}),c("div",{className:"flex h-full relative",children:[s("button",{onClick:()=>C(!X),className:F("px-4 h-10 transition-all flex items-center text-xs font-semibold relative",X?"text-white bg-[#B7472A]":"text-slate-600 hover:bg-slate-200/50"),children:"File"}),X&&c(we,{children:[s("div",{className:"fixed inset-0 z-[140]",onClick:()=>C(!1)}),c("div",{className:"absolute top-10 left-0 w-48 bg-white border border-slate-200 shadow-xl rounded-b-xl z-[150] py-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[c("button",{onClick:()=>{n(),C(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[s(pe,{size:14,className:"text-slate-400"}),s("span",{children:"Create New"})]}),c("button",{onClick:()=>{B(!0),C(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[s(ce,{size:14,className:"text-slate-400"}),s("span",{children:"Upload"})]}),s("div",{className:"h-[1px] bg-slate-100 my-1 mx-2"}),c("button",{onClick:()=>{g(),C(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[s(lt,{size:14,className:"text-slate-400"}),s("span",{children:"Export PPTX"})]})]})]})]}),s("div",{className:"flex-1"}),c("div",{className:"flex items-center gap-4 px-4 text-slate-400",children:[s("div",{className:"h-4 w-[1px] bg-slate-200"}),s(rt,{size:16,className:"cursor-pointer hover:text-[#B7472A] transition-colors",onClick:f})]})]}),c("div",{className:"bg-white h-[96px] flex items-center px-6 gap-8 justify-start",children:[c("div",{className:"flex flex-col items-center border-r border-slate-100 pr-8 py-1 min-w-[140px]",children:[c("div",{className:"flex items-center gap-2 mb-1",children:[c("button",{onClick:m,className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",children:[s("div",{className:"bg-orange-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:s(pe,{size:22,className:"text-[#B7472A]"})}),s("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"New Slide"})]}),c("div",{className:"relative",children:[c("button",{onClick:()=>O(!E),className:F("p-2 hover:bg-slate-50 rounded-xl transition-all flex flex-col items-center",E&&"bg-slate-100"),children:[s(it,{size:20,className:"text-slate-500"}),s("span",{className:"text-[10px] font-medium text-slate-500 mt-1",children:"Layout"})]}),E&&c("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-xl shadow-2xl p-2 w-56 flex flex-col gap-1 z-[100] animate-in fade-in zoom-in-95 duration-200",children:[c("button",{onClick:()=>{v("title"),O(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[s(nt,{size:16,className:"text-blue-500"})," Title Slide"]}),c("button",{onClick:()=>{v("content"),O(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[s(ve,{size:16,className:"text-emerald-500"})," Title & Content"]}),c("button",{onClick:()=>{v("split"),O(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[s(at,{size:16,className:"text-purple-500"})," Two Columns"]})]})]})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Slides"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[c("div",{className:"flex flex-col gap-2 min-w-[220px]",children:[c("div",{className:"flex items-center gap-1.5",children:[s("select",{disabled:!z,value:(i==null?void 0:i.fontFamily)||"Arial",onChange:A=>p({fontFamily:A.target.value}),className:"h-8 px-3 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-36 disabled:opacity-50 transition-colors appearance-none cursor-pointer",children:dt.map(A=>s("option",{value:A,children:A},A))}),s("select",{disabled:!z,value:(i==null?void 0:i.fontSize)||24,onChange:A=>p({fontSize:parseInt(A.target.value)}),className:"h-8 px-2 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-16 disabled:opacity-50 transition-colors appearance-none cursor-pointer text-center",children:ct.map(A=>s("option",{value:A,children:A},A))})]}),c("div",{className:"flex items-center gap-1",children:[s("button",{disabled:!z,onClick:()=>p({isBold:!i.isBold}),className:F("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isBold?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:s(Ze,{size:16,strokeWidth:3})}),s("button",{disabled:!z,onClick:()=>p({isItalic:!i.isItalic}),className:F("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isItalic?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:s(Qe,{size:16})}),s("div",{className:"h-4 w-[1px] bg-slate-200 mx-2"}),c("div",{className:"relative group p-1 hover:bg-slate-50 rounded-lg transition-colors cursor-pointer",children:[s("input",{type:"color",disabled:!i,value:z?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6",onChange:A=>p(z?{color:A.target.value}:{fill:A.target.value}),className:"w-8 h-6 p-0 border-0 bg-transparent cursor-pointer disabled:opacity-30",title:"Format Color"}),s("div",{className:"absolute bottom-1.5 left-2 right-2 h-1 rounded-full",style:{backgroundColor:z?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6"}})]})]})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto pt-1",children:"Font"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[c("div",{className:"flex flex-col gap-2",children:[c("div",{className:"flex items-center gap-1 px-1.5 py-1 bg-slate-50 rounded-xl border border-slate-100",children:[s("button",{disabled:!z,onClick:()=>p({textAlign:"left"}),className:F("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="left"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:s(et,{size:16})}),s("button",{disabled:!z,onClick:()=>p({textAlign:"center"}),className:F("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="center"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:s(tt,{size:16})}),s("button",{disabled:!z,onClick:()=>p({textAlign:"right"}),className:F("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="right"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:s(st,{size:16})})]}),s("button",{disabled:!z,onClick:()=>p({isBulleted:!i.isBulleted}),className:F("p-2 rounded-lg self-start transition-all disabled:opacity-30",i!=null&&i.isBulleted?"bg-slate-100 text-[#B7472A]":"text-slate-500 hover:bg-slate-50"),children:s(ve,{size:18})})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Paragraph"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[c("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[c("div",{className:"relative group/shapes",children:[c("button",{className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",onClick:()=>{var A;return(A=window._toggleShapesMenu)==null?void 0:A.call(window)},children:[s("div",{className:"bg-blue-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:s(qe,{size:22,className:"text-blue-600"})}),s("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"Shapes"})]}),s(ft,{onAddShape:A=>{r(A)}})]}),s("div",{className:"h-10 w-[1px] bg-slate-100 mx-2"}),s("button",{onClick:y,className:"p-2.5 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Text Box",children:s(Ke,{size:18})}),c("button",{onClick:()=>{var A;return(A=S.current)==null?void 0:A.click()},className:"p-2.5 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Image",children:[s(Ve,{size:18}),s("input",{type:"file",ref:S,className:"hidden",accept:"image/*",onChange:A=>{var V;return((V=A.target.files)==null?void 0:V[0])&&l(A.target.files[0])}})]})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Drawing"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[c("div",{className:"flex flex-col gap-2 relative",children:[c("div",{className:"flex items-center gap-1.5",children:[c("button",{disabled:!z||e,onClick:()=>a(i.id,"shorten"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[s(ae,{size:16,className:"text-purple-500"}),s("span",{className:"text-[10px] font-bold",children:"Shorten"})]}),c("button",{disabled:!z||e,onClick:()=>a(i.id,"reframe"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[s(ae,{size:16,className:"text-blue-500"}),s("span",{className:"text-[10px] font-bold",children:"Reframe"})]}),c("button",{disabled:!z||e,onClick:()=>a(i.id,"lengthen"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[s(ae,{size:16,className:"text-emerald-500"}),s("span",{className:"text-[10px] font-bold",children:"Lengthen"})]})]}),e&&s("div",{className:"absolute inset-0 bg-white/80 flex items-center justify-center rounded-lg z-10 backdrop-blur-[1px]",children:s(fe,{size:18,className:"text-blue-600 animate-spin"})}),t&&c("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] bg-white border border-slate-200 rounded-2xl shadow-2xl p-6 z-[200] animate-in fade-in zoom-in-95 duration-200",children:[c("div",{className:"flex items-center gap-2 mb-4",children:[s(ae,{size:20,className:"text-purple-600"}),s("h3",{className:"text-sm font-black text-slate-800 uppercase tracking-widest",children:"AI Generated Response"})]}),c("div",{className:"bg-slate-50 p-4 rounded-xl mb-6 max-h-[200px] overflow-y-auto border border-slate-100 italic text-slate-700 text-sm leading-relaxed",children:['"',t,'"']}),c("div",{className:"flex flex-col gap-2",children:[c("div",{className:"grid grid-cols-2 gap-2",children:[s("button",{onClick:()=>x("replace"),className:"px-4 py-2.5 bg-[#B7472A] text-white text-[11px] font-bold rounded-lg hover:bg-[#a33f25] transition-colors shadow-sm",children:"REPLACE CURRENT"}),s("button",{onClick:()=>x("addBelow"),className:"px-4 py-2.5 bg-slate-800 text-white text-[11px] font-bold rounded-lg hover:bg-slate-900 transition-colors shadow-sm",children:"ADD BELOW"})]}),c("div",{className:"flex gap-2",children:[c("button",{onClick:()=>x("regenerate"),className:"flex-1 px-4 py-2.5 border border-slate-200 text-slate-600 text-[11px] font-bold rounded-lg hover:bg-slate-50 transition-colors flex items-center justify-center gap-2",children:[s(fe,{size:14})," REGENERATE"]}),s("button",{className:"px-4 py-2.5 text-slate-400 text-[11px] font-bold hover:text-slate-600 transition-colors",onClick:()=>{x("replace")},children:"CLOSE"})]})]})]})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"AI Text"})]}),c("div",{className:"flex flex-col items-center px-8 py-1",children:[c("div",{className:"flex gap-3",children:[s("button",{onClick:g,className:"flex flex-col items-center justify-center p-2.5 hover:bg-emerald-50 rounded-xl group transition-all",title:"Download Presentation",children:s("div",{className:"bg-emerald-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:s(ce,{size:22,className:"text-emerald-700"})})}),i&&s("button",{onClick:N,className:"flex flex-col items-center justify-center p-2.5 hover:bg-red-50 rounded-xl group transition-all",title:"Delete Element",children:s("div",{className:"bg-red-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:s(Je,{size:22,className:"text-red-600"})})})]}),s("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Actions"})]}),s("div",{className:"flex-1"}),c("div",{className:"pr-12 flex flex-col items-end gap-1 group",children:[c("div",{className:"flex items-center gap-1.5 text-[10px] font-black text-slate-300 group-hover:text-[#B7472A] transition-colors",children:[s(ot,{size:12}),s("span",{children:"SAVED AUTOMATICALLY"})]}),s("div",{className:"h-1 w-24 bg-slate-100 rounded-full overflow-hidden",children:s("div",{className:"h-full w-full bg-emerald-500/20"})})]})]}),J&&c(we,{children:[s("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-[2000]",onClick:()=>B(!1)}),c("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] bg-white rounded-3xl shadow-2xl z-[2001] border border-slate-200 p-8 animate-in fade-in zoom-in-95 duration-200",children:[c("div",{className:"flex justify-between items-center mb-6",children:[c("h3",{className:"text-lg font-black text-slate-800 tracking-tight flex items-center gap-3",children:[s("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-xl",children:s(ce,{size:20})}),"Upload Presentation"]}),s("button",{onClick:()=>B(!1),className:"text-slate-400 hover:text-slate-600 transition-colors",children:s(fe,{size:20,className:"rotate-45"})})]}),c("div",{className:"flex gap-2 p-1 bg-slate-50 rounded-2xl mb-8",children:[s("button",{onClick:()=>G("file"),className:F("flex-1 py-3 text-xs font-black rounded-xl transition-all",W==="file"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"FILE UPLOAD"}),s("button",{onClick:()=>G("link"),className:F("flex-1 py-3 text-xs font-black rounded-xl transition-all",W==="link"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"LINK UPLOAD"})]}),W==="file"?c("label",{className:"flex flex-col items-center justify-center gap-4 py-12 border-2 border-dashed border-slate-200 rounded-3xl hover:border-blue-400 hover:bg-blue-50/50 transition-all cursor-pointer group",children:[s("div",{className:"p-4 bg-white rounded-2xl shadow-sm border border-slate-100 group-hover:scale-110 transition-transform",children:s(pe,{size:24,className:"text-blue-500"})}),c("div",{className:"text-center",children:[s("p",{className:"text-sm font-bold text-slate-700",children:"Choose a PPTX file"}),s("p",{className:"text-xs text-slate-400 mt-1",children:"Maximum file size: 50MB"})]}),s("input",{type:"file",accept:".pptx",className:"hidden",onChange:A=>{var se;let V=(se=A.target.files)==null?void 0:se[0];V&&(u(V),B(!1))}})]}):c("div",{className:"space-y-4",children:[s("div",{className:"relative",children:s("input",{type:"text",placeholder:"Paste S3 or public URL",value:L,onChange:A=>Y(A.target.value),className:"w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 focus:outline-none focus:ring-4 focus:ring-blue-500/10 focus:border-blue-500 text-sm placeholder:text-slate-400 text-black"})}),s("button",{onClick:()=>{L.trim()&&(u(L.trim()),B(!1))},disabled:!L.trim(),className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 text-white font-black py-4 rounded-2xl transition-all shadow-lg shadow-blue-500/20",children:"LOAD PRESENTATION"}),s("p",{className:"text-[10px] text-slate-400 text-center uppercase tracking-widest font-black",children:"Supports S3, Dropbox, and public URLS"})]})]})]})]})};import{Trash2 as mt,Copy as ut,GripVertical as ht}from"lucide-react";import{DndContext as xt,closestCenter as gt,KeyboardSensor as bt,PointerSensor as yt,useSensor as Ae,useSensors as vt}from"@dnd-kit/core";import{SortableContext as wt,sortableKeyboardCoordinates as Nt,verticalListSortingStrategy as St,useSortable as At}from"@dnd-kit/sortable";import{CSS as kt}from"@dnd-kit/utilities";import{jsx as T,jsxs as q}from"react/jsx-runtime";var It=({slide:y,index:l,isActive:r,onSelect:m,onDelete:g,onDuplicate:p,showDelete:N})=>{let{attributes:v,listeners:f,setNodeRef:i,transform:b,transition:a,isDragging:x}=At({id:y.id}),t={transform:kt.Transform.toString(b),transition:a,zIndex:x?2:1,opacity:x?.5:1};return q("div",{ref:i,style:t,onClick:m,className:F("cursor-pointer border-[1.5px] rounded-2xl p-2 transition-all duration-300 group relative select-none",r?"border-[#B7472A] bg-white":"border-transparent hover:border-slate-200 bg-white/50 hover:bg-white"),children:[q("div",{className:"text-[10px] font-bold text-slate-400 mb-1 flex items-center justify-between",children:[q("div",{className:"flex items-center gap-1",children:[T("div",I(w(w({},v),f),{className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-slate-100 rounded text-slate-300 hover:text-slate-500",children:T(ht,{size:10})})),q("span",{children:["SLIDE ",l+1]})]}),q("div",{className:"flex items-center gap-1",children:[r&&T("span",{className:"h-1.5 w-1.5 rounded-full bg-[#B7472A]"}),q("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[T("button",{onClick:e=>{e.stopPropagation(),p()},className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-500 rounded transition-all",title:"Duplicate Slide",children:T(ut,{size:12})}),N&&T("button",{onClick:e=>{e.stopPropagation(),g()},className:"p-1 hover:bg-red-50 text-red-400 hover:text-red-500 rounded transition-all",title:"Delete Slide",children:T(mt,{size:12})})]})]})]}),T("div",{className:"aspect-video bg-white rounded-xl flex items-center justify-center border border-slate-200 overflow-hidden relative group-hover:shadow-sm transition-shadow",children:T("div",{className:"absolute inset-0 origin-top-left pointer-events-none select-none",style:{width:"1200px",height:"675px",transform:"scale(0.165)",backgroundColor:"#ffffff"},children:y.elements.sort((e,n)=>(e.zIndex||0)-(n.zIndex||0)).map(e=>{var u;let n={position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,opacity:(u=e.opacity)!=null?u:1};return e.type==="text"?T("div",{style:I(w({},n),{fontSize:e.fontSize,fontFamily:e.fontFamily,color:e.color,textAlign:e.textAlign||"left",fontWeight:e.isBold?"bold":"normal",fontStyle:e.isItalic?"italic":"normal",lineHeight:1.2,overflow:"hidden",wordBreak:"break-word",whiteSpace:"pre-wrap"}),children:e.content},e.id):e.type==="shape"?T("div",{style:I(w({},n),{backgroundColor:e.fill,borderRadius:e.shapeType==="ellipse"?"50%":"0"})},e.id):e.type==="image"?T("img",{src:e.src,alt:"",style:I(w({},n),{objectFit:"contain"})},e.id):null})})})]})},ke=({slides:y,currentSlideIndex:l,onSelectSlide:r,onDeleteSlide:m,onDuplicateSlide:g,onReorderSlides:p})=>{let N=vt(Ae(yt,{activationConstraint:{distance:5}}),Ae(bt,{coordinateGetter:Nt}));return T("div",{className:"w-64 bg-white border-r border-slate-100 overflow-y-auto p-4 flex flex-col gap-4",children:T(xt,{sensors:N,collisionDetection:gt,onDragEnd:f=>{let{active:i,over:b}=f;if(i.id!==(b==null?void 0:b.id)){let a=y.findIndex(t=>t.id===i.id),x=y.findIndex(t=>t.id===(b==null?void 0:b.id));p(a,x)}},children:T(wt,{items:y.map(f=>f.id),strategy:St,children:y.map((f,i)=>T(It,{slide:f,index:i,isActive:i===l,onSelect:()=>r(i),onDelete:()=>m(i),onDuplicate:()=>g(i),showDelete:y.length>1},f.id))})})})};import{useEffect as me,useRef as Q}from"react";import*as $ from"fabric";import{jsx as Ie}from"react/jsx-runtime";var ne=({slide:y,onElementUpdate:l,onSelect:r})=>{let m=Q(null),g=Q(null),p=Q(!1),N=Q(l),v=Q(r);return me(()=>{N.current=l,v.current=r},[l,r]),me(()=>{if(m.current&&!g.current){g.current=new $.Canvas(m.current,{width:1200,height:675,backgroundColor:"#ffffff"});let f=g.current,i=t=>{t.left<0&&t.set("left",0),t.top<0&&t.set("top",0);let e=t.getBoundingRect();e.left+e.width>(f.width||1200)&&t.set("left",(f.width||1200)-e.width),e.top+e.height>(f.height||675)&&t.set("top",(f.height||675)-e.height)};f.on("object:moving",t=>i(t.target)),f.on("object:scaling",t=>i(t.target));let b=t=>{var u;if(p.current)return;let e=t.target,n=(u=e.get("data"))==null?void 0:u.id;e&&n&&N.current(n,w({x:e.left,y:e.top,width:e.getScaledWidth(),height:e.getScaledHeight()},e.isType("textbox")?{content:e.text,textAlign:e.textAlign,fontSize:e.fontSize,fontFamily:e.fontFamily,color:e.fill}:{fill:e.fill}))};f.on("object:modified",b),f.on("text:changed",b);let a=t=>{var n,u;let e=((n=t.selected)==null?void 0:n[0])||t.target;if(e){let S=(u=e.get("data"))==null?void 0:u.id;v.current(S)}};f.on("selection:created",a),f.on("selection:updated",a),f.on("selection:cleared",()=>v.current(null));let x=t=>{let e=f.getActiveObject();if(!e||e.isType("textbox")&&e.isEditing)return;let n=t.shiftKey?10:1,u=!1;switch(t.key){case"ArrowLeft":e.set("left",e.left-n),u=!0;break;case"ArrowRight":e.set("left",e.left+n),u=!0;break;case"ArrowUp":e.set("top",e.top-n),u=!0;break;case"ArrowDown":e.set("top",e.top+n),u=!0;break}u&&(i(e),f.requestRenderAll(),b({target:e}))};window.addEventListener("keydown",x),f._keyboardListener=x}return()=>{if(g.current){let f=g.current._keyboardListener;f&&window.removeEventListener("keydown",f),g.current.dispose(),g.current=null}}},[]),me(()=>{if(!g.current)return;let f=g.current;(async()=>{p.current=!0;let b=f.getObjects(),a=new Set(y.elements.map(t=>t.id));b.forEach(t=>{var n;let e=(n=t.get("data"))==null?void 0:n.id;e&&!a.has(e)&&f.remove(t)});let x=[...y.elements].sort((t,e)=>(t.zIndex||0)-(e.zIndex||0));for(let t of x){let e=b.find(n=>{var u;return((u=n.get("data"))==null?void 0:u.id)===t.id});if(e){if(e===f.getActiveObject()&&e.isType("textbox")&&e.isEditing)continue;let n={left:t.x,top:t.y,opacity:t.opacity!==void 0?t.opacity:1,zIndex:t.zIndex};t.type==="text"&&e.isType("textbox")?(n.text=t.content||" ",n.fontSize=t.fontSize||22,n.fill=t.color||"#000000",n.textAlign=t.textAlign||"left",n.fontWeight=t.isBold?"bold":"normal",n.fontStyle=t.isItalic?"italic":"normal",n.fontFamily=t.fontFamily||"Arial",n.width=Math.max(t.width||50,10)):t.type==="shape"?(n.fill=t.fill||"#cccccc",n.scaleX=(t.width||50)/(e.width||1),n.scaleY=(t.height||50)/(e.height||1)):t.type==="image"&&(n.scaleX=(t.width||100)/(e.width||1),n.scaleY=(t.height||100)/(e.height||1)),e.set(n)}else{let n=null,u={left:t.x,top:t.y,data:{id:t.id},originX:"left",originY:"top",opacity:t.opacity!==void 0?t.opacity:1};if(t.type==="text")n=new $.Textbox(t.content||" ",I(w({},u),{width:Math.max(t.width||200,10),fontSize:t.fontSize||22,fill:t.color||"#000000",fontFamily:t.fontFamily||"Inter, Arial, sans-serif",textAlign:t.textAlign||"left",fontWeight:t.isBold?"bold":"normal",fontStyle:t.isItalic?"italic":"normal",splitByGrapheme:!1}));else if(t.type==="shape"){let S=t.fill||"#3b82f6";t.shapeType==="ellipse"?n=new $.Circle(I(w({},u),{radius:(t.width||100)/2,scaleY:(t.height||100)/(t.width||100),fill:S})):n=new $.Rect(I(w({},u),{width:t.width||100,height:t.height||100,fill:S}))}else if(t.type==="image")try{let S=await $.FabricImage.fromURL(t.src);S.set(I(w({},u),{scaleX:(t.width||100)/(S.width||1),scaleY:(t.height||100)/(S.height||1)})),n=S}catch(S){console.error(S)}n&&f.add(n)}}f.renderAll(),p.current=!1})()},[y]),Ie("div",{className:"border border-slate-200 rounded-xl overflow-hidden bg-white",children:Ie("canvas",{ref:m})})};import Ct from"pptxgenjs";var oe=class{async export(l){var i,b;let r=new Ct,m=((i=l.layout)==null?void 0:i.width)||12192e3,g=((b=l.layout)==null?void 0:b.height)||6858e3,p=1200,N=675,v=a=>a/p*(m/914400),f=a=>a/N*(g/914400);l.slides.forEach(a=>{let x=r.addSlide();[...a.elements].sort((e,n)=>e.zIndex-n.zIndex).forEach(e=>{var S,P;let n=e.opacity!==void 0?(1-e.opacity)*100:0,u={x:v(e.x),y:f(e.y),w:v(e.width),h:f(e.height)};if(e.type==="text")x.addText(e.content,I(w({},u),{fontSize:(e.fontSize||18)/2,color:((S=e.color)==null?void 0:S.replace("#",""))||"000000",fontFace:e.fontFamily||"Arial"}));else if(e.type==="image")x.addImage(I(w({},u),{path:e.src,transparency:n}));else if(e.type==="shape"){let R=e.shapeType==="ellipse"?r.ShapeType.ellipse:r.ShapeType.rect;x.addShape(R,I(w({},u),{fill:{color:((P=e.fill)==null?void 0:P.replace("#",""))||"CCCCCC",transparency:n>0?Math.min(n+10,100):0}}))}})}),await r.writeFile({fileName:"presentation.pptx"})}};import Pt from"jszip";var le=class{constructor(){this.slideWidth=12192e3;this.slideHeight=6858e3;this.CANVAS_WIDTH=1200;this.CANVAS_HEIGHT=675}async parse(l){var b,a;let r=l;if(typeof l=="string"){let x=await fetch(l);if(!x.ok){let t=x.status,e=x.statusText,n="";try{let u=await x.json();n=u.details||u.error||""}catch(u){}throw new Error(`Failed to fetch PPTX from ${l}: ${t} ${e} ${n?`(${n})`:""}`)}r=await x.arrayBuffer()}let m=await Pt.loadAsync(r),g=await((b=m.file("ppt/presentation.xml"))==null?void 0:b.async("string"));if(!g)throw new Error("Invalid PPTX");let N=new DOMParser().parseFromString(g,"text/xml"),v=this.findFirstByLocalName(N,"sldSz");v&&(this.slideWidth=parseInt(this.getAttr(v,"cx")||"12192000"),this.slideHeight=parseInt(this.getAttr(v,"cy")||"6858000"));let f=Array.from(N.getElementsByTagNameNS("*","sldId")),i=[];for(let x=0;x<f.length;x++){let t=x+1,e=`ppt/slides/slide${t}.xml`,n=await((a=m.file(e))==null?void 0:a.async("string"));if(n){let u=await this.parseSlide(n,t,m);i.push(u)}}return{slides:i,layout:{width:this.slideWidth,height:this.slideHeight}}}getAttr(l,r){return l.getAttribute(r)||l.getAttribute(`a:${r}`)||l.getAttribute(`p:${r}`)||l.getAttribute(`r:${r}`)}findFirstByLocalName(l,r){let m=l.getElementsByTagNameNS("*",r);return m.length>0?m[0]:null}findAllByLocalName(l,r){return Array.from(l.getElementsByTagNameNS("*",r))}scaleX(l){return l/this.slideWidth*this.CANVAS_WIDTH}scaleY(l){return l/this.slideHeight*this.CANVAS_HEIGHT}parseColor(l){let r=this.findFirstByLocalName(l,"srgbClr");if(r){let g=`#${this.getAttr(r,"val")}`,p=this.findFirstByLocalName(r,"alpha"),N=p?parseInt(this.getAttr(p,"val")||"100000")/1e5:1;return{color:g,opacity:N}}let m=this.findFirstByLocalName(l,"schemeClr");if(m){let g=this.findFirstByLocalName(m,"alpha");return{color:"#000000",opacity:g?parseInt(this.getAttr(g,"val")||"100000")/1e5:1}}return{color:"#000000",opacity:1}}async resolveImage(l,r,m){var i,b;let g=await((i=m.file(`ppt/slides/_rels/slide${r}.xml.rels`))==null?void 0:i.async("string"));if(!g)return null;let N=new DOMParser().parseFromString(g,"text/xml"),v=Array.from(N.getElementsByTagName("Relationship")).find(a=>a.getAttribute("Id")===l),f=v==null?void 0:v.getAttribute("Target");if(f){let a=(f.startsWith("../")?`ppt/${f.substring(3)}`:`ppt/slides/${f}`).replace("ppt/slides/../","ppt/");return await((b=m.file(a))==null?void 0:b.async("blob"))||null}return null}async parseSlide(l,r,m){let p=new DOMParser().parseFromString(l,"text/xml"),N=[],v=0,f=this.findFirstByLocalName(p,"bg");if(f){let a=this.findFirstByLocalName(f,"blip"),x=(a==null?void 0:a.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(a==null?void 0:a.getAttribute("r:embed"));if(x){let t=await this.resolveImage(x,r,m);t&&N.push({id:`bg-${r}`,type:"image",src:URL.createObjectURL(t),x:0,y:0,width:this.CANVAS_WIDTH,height:this.CANVAS_HEIGHT,zIndex:v++,opacity:1})}}let i=this.findFirstByLocalName(p,"spTree");if(!i)return{id:`slide-${r}`,elements:N};let b=Array.from(i.children);for(let a of b){let x=a.localName;if(x==="sp"){let t=this.findFirstByLocalName(a,"txBody"),e=this.findFirstByLocalName(a,"xfrm"),n=e?this.findFirstByLocalName(e,"off"):null,u=e?this.findFirstByLocalName(e,"ext"):null;if(t&&n&&u){let P=this.findAllByLocalName(t,"p"),R="",E=18,O="#000000",H=1,j=!1;for(let X of P){let C=this.findFirstByLocalName(X,"pPr"),J=C?this.findFirstByLocalName(C,"buNone"):null;C&&!J&&(this.findFirstByLocalName(C,"buChar")||this.findFirstByLocalName(C,"buAutoNum"))&&(j=!0,R+="\u2022 ");let B=this.findAllByLocalName(X,"r");for(let W of B){let G=this.findFirstByLocalName(W,"t");G&&(R+=G.textContent);let L=this.findFirstByLocalName(W,"rPr");if(L){let Y=this.getAttr(L,"sz");Y&&(E=parseInt(Y)/100*2);let z=this.parseColor(L);O=z.color,H=z.opacity}}R+=`
|
|
3
|
-
`}if(
|
|
2
|
+
var it=Object.defineProperty,ot=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var Be=(g,i,p)=>i in g?it(g,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):g[i]=p,w=(g,i)=>{for(var p in i||(i={}))nt.call(i,p)&&Be(g,p,i[p]);if(Pe)for(var p of Pe(i))lt.call(i,p)&&Be(g,p,i[p]);return g},A=(g,i)=>ot(g,rt(i));import{useState as $,useCallback as xe,useMemo as Ve,useEffect as Ae}from"react";import Me,{useState as _}from"react";import{Type as pt,Image as ut,Square as ft,Download as Ne,Plus as Se,Trash2 as mt,Bold as ht,Italic as xt,AlignLeft as gt,AlignCenter as bt,AlignRight as vt,List as Te,Layout as De,Columns as yt,FileText as wt,History as Nt,Share2 as Fe,Play as St,Sparkles as ne,RefreshCw as ke}from"lucide-react";import{clsx as ct}from"clsx";import{twMerge as dt}from"tailwind-merge";function B(...g){return dt(ct(g))}import{Fragment as le,jsx as e,jsxs as c}from"react/jsx-runtime";var kt=["Inter","Lato","Open Sans","Poppins","Roboto","Roboto Slab","Georgia","Playfair Display","Merriweather","Nunito Sans","Montserrat","Oswald","Raleway","Ubuntu","Lora","PT Sans","PT Serif","Play","Arvo","Kanit","Times New Roman","Arial"],Ct=[12,14,16,18,20,24,28,32,36,48,64,72,96],At=[{name:"Basic Shapes",shapes:["rect","circle","triangle","rightTriangle","rhombus","parallelogram","trapezoid","pentagon","hexagon","heptagon","octagon","heart","smiley","sun","moon"]},{name:"Arrows",shapes:["arrowRight","arrowLeft","arrowUp","arrowDown","arrowLeftRight","arrowUpDown"]},{name:"Stars & Symbols",shapes:["star4","star5","star6","star8","cloud","lightning"]},{name:"Equation Shapes",shapes:["plus","minus","multiply","divide","equal"]}],Lt=({type:g,className:i})=>{switch(g){case"rect":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:"currentColor"})});case"circle":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("circle",{cx:"12",cy:"12",r:"9",fill:"currentColor"})});case"triangle":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 4L20 18H4L12 4Z",fill:"currentColor"})});case"rightTriangle":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M4 4V20H20L4 4Z",fill:"currentColor"})});case"rhombus":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 4L20 12L12 20L4 12L12 4Z",fill:"currentColor"})});case"parallelogram":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M7 4H21L17 20H3L7 4Z",fill:"currentColor"})});case"trapezoid":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M6 4H18L21 20H3L6 4Z",fill:"currentColor"})});case"pentagon":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 3L21 9V19H3V9L12 3Z",fill:"currentColor"})});case"hexagon":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5L12 3Z",fill:"currentColor"})});case"heptagon":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 3L18.5 6L21 13L16 20H8L3 13L5.5 6L12 3Z",fill:"currentColor"})});case"octagon":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M8.5 3H15.5L21 8.5V15.5L15.5 21H8.5L3 15.5V8.5L8.5 3Z",fill:"currentColor"})});case"heart":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",fill:"currentColor"})});case"smiley":return c("svg",{viewBox:"0 0 24 24",className:i,children:[e("circle",{cx:"12",cy:"12",r:"9",fill:"currentColor",fillOpacity:"0.2",stroke:"currentColor",strokeWidth:"2"}),e("circle",{cx:"9",cy:"9",r:"1.5",fill:"currentColor"}),e("circle",{cx:"15",cy:"9",r:"1.5",fill:"currentColor"}),e("path",{d:"M8 15C8 15 9.5 17 12 17C14.5 17 16 15 16 15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"sun":return c("svg",{viewBox:"0 0 24 24",className:i,children:[e("circle",{cx:"12",cy:"12",r:"5",fill:"currentColor"}),e("path",{d:"M12 2V4M12 20V22M4 12H2M22 12H20M19.07 4.93L17.66 6.34M6.34 17.66L4.93 19.07M4.93 4.93L6.34 6.34M17.66 17.66L19.07 19.07",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"moon":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 3a9 9 0 1 0 9 9 7 7 0 0 1-9-9",fill:"currentColor"})});case"arrowRight":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M4 11h11.5l-3.5-3.5 1.5-1.5 6 6-6 6-1.5-1.5 3.5-3.5H4z",fill:"currentColor"})});case"arrowLeft":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M20 11H8.5l3.5-3.5L10.5 6l-6 6 6 6 1.5-1.5-3.5-3.5H20z",fill:"currentColor"})});case"arrowUp":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M13 20V8.5l3.5 3.5 1.5-1.5-6-6-6 6 1.5 1.5 3.5-3.5V20z",fill:"currentColor"})});case"arrowDown":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M11 4v11.5l-3.5-3.5-1.5 1.5 6 6 6-6-1.5-1.5-3.5 3.5V4z",fill:"currentColor"})});case"arrowLeftRight":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M4 12l4-4v3h8V8l4 4-4 4v-3H8v3l-4-4z",fill:"currentColor"})});case"arrowUpDown":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 4l-4 4h3v8H8l4 4 4-4h-3V8h3l-4-4z",fill:"currentColor"})});case"star4":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 2l2 8 8 2-8 2-2 8-2-8-8-2 8-2 2-8z",fill:"currentColor"})});case"star5":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 2l2.5 7.5H22l-6 4.5 2.5 7.5-6.5-4.5-6.5 4.5 2.5-7.5-6-4.5h7.5L12 2z",fill:"currentColor"})});case"star6":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 2l3 5 6-1-4 4.5 2 6.5-7-3-7 3 2-6.5-4-4.5 6 1 3-5z",fill:"currentColor"})});case"star8":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M12 2l2 4 4-2-2 4 4 2-4 2 2 4-4-2-2 4-2-4-4 2 2-4-4-2 4-2-2-4 4 2 2-4z",fill:"currentColor"})});case"cloud":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M17.5 19c-3 0-5.5-2.5-5.5-5.5 0-.2 0-.4.1-.6-2-.8-3.6-2.5-4.1-4.7C6.5 7.4 5 6 3 6c-1.7 0-3 1.3-3 3s1.3 3 3 3c.4 0 .8-.1 1.2-.2C4.1 13 5 14.5 6.5 15.5c.3 1.8 1.4 3.4 3 4.3.4.2.8.3 1.2.4 1.2.4 2.5.6 3.8.6 4.4 0 8-3.6 8-8s-3.6-8-8-8c-.4 0-.8 0-1.2.1-1.2.2-2.3.7-3.2 1.5C11 4.2 12.4 3.5 14 3.5c4.1 0 7.5 3.4 7.5 7.5s-1.8 7.5-4 8z",fill:"currentColor",transform:"scale(0.8) translate(3,3)"})});case"lightning":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M13 2L3 14h9v8l10-12h-9l3-8z",fill:"currentColor"})});case"plus":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})});case"minus":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M19 13H5v-2h14v2z",fill:"currentColor"})});case"multiply":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z",fill:"currentColor"})});case"divide":return c("svg",{viewBox:"0 0 24 24",className:i,children:[e("circle",{cx:"12",cy:"7",r:"2",fill:"currentColor"}),e("circle",{cx:"12",cy:"17",r:"2",fill:"currentColor"}),e("rect",{x:"5",y:"11",width:"14",height:"2",fill:"currentColor"})]});case"equal":return e("svg",{viewBox:"0 0 24 24",className:i,children:e("path",{d:"M19 10H5V8h14v2zm0 6H5v-2h14v2z",fill:"currentColor"})});default:return e("div",{className:"w-6 h-6 bg-slate-200 rounded-sm"})}},zt=({onAddShape:g,uiScale:i})=>{let[p,f]=_(!1);return Me.useEffect(()=>(window._toggleShapesMenu=()=>f(!p),()=>{window._toggleShapesMenu=void 0}),[p]),p?e("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-2xl shadow-2xl p-4 overflow-y-auto z-[100] animate-in fade-in zoom-in-95 duration-200",style:{width:`${320*i}px`,maxHeight:`${480*i}px`},children:e("div",{className:"flex flex-col gap-6",children:At.map(N=>c("div",{className:"flex flex-col gap-2",children:[e("span",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 px-1",style:{fontSize:`${10*i}px`},children:N.name}),e("div",{className:"grid grid-cols-5 gap-1",children:N.shapes.map(m=>e("button",{onClick:()=>{g(m),f(!1)},className:"aspect-square hover:bg-slate-50 rounded-lg flex items-center justify-center border border-transparent hover:border-slate-100 transition-all group p-1",title:m,children:e("div",{className:"w-full h-full bg-slate-100 rounded-sm group-hover:bg-blue-100 group-hover:scale-110 transition-all flex items-center justify-center overflow-hidden p-1.5",children:e(Lt,{type:m,className:"w-full h-full text-slate-400 group-hover:text-blue-600 transition-colors"})})},m))})]},N.name))})}):null},Re=({onAddText:g,onAddImage:i,onAddShape:p,onAddSlide:f,onExport:N,onFormatText:m,onDeleteElement:S,onApplyLayout:k,onPlay:L,selectedElement:a,appName:v,onAiAction:o,onAiResponseAction:x,aiResponse:y,isAiLoading:t,onNewPresentation:s,onLoadPresentation:r,appBgColor:l="#B7472A",uiScale:h,source:z})=>{let D=Me.useRef(null),[se,K]=_("Home"),[H,M]=_(!1),[W,ae]=_(!1),[X,O]=_(!1),[Q,R]=_(!1),[U,Z]=_("file"),[ee,ie]=_(""),P=(a==null?void 0:a.type)==="text",ge=(a==null?void 0:a.type)==="shape",oe="#B7472A";return c("div",{className:"flex flex-col border-b border-slate-200 bg-white z-50 select-none pb-1",style:{fontSize:`${12*h}px`},children:[c("div",{className:"flex items-center bg-[#F3F2F1] border-b border-slate-200",style:{height:`${40*h}px`},children:[e("div",{className:"flex items-center h-full px-4 border-r border-slate-200 mr-2 text-white",style:{backgroundColor:l},children:e("span",{className:"font-black text-xs tracking-tighter capitalize",children:v})}),c("div",{className:"flex h-full relative",children:[e("button",{onClick:()=>O(!X),className:B("px-4 h-10 transition-all flex items-center text-xs font-semibold relative",X?"text-white":"text-slate-600 hover:bg-slate-200/50"),style:{backgroundColor:X?l:"transparent"},children:"File"}),X&&c(le,{children:[e("div",{className:"fixed inset-0 z-[140]",onClick:()=>O(!1)}),c("div",{className:"absolute top-10 left-0 w-48 bg-white border border-slate-200 shadow-xl rounded-b-xl z-[200] py-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[c("button",{onClick:()=>{s(),O(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[e(Se,{size:14,className:"text-slate-400"}),e("span",{children:"Create New"})]}),c("button",{onClick:()=>{R(!0),O(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[e(Ne,{size:14,className:"text-slate-400"}),e("span",{children:"Upload"})]}),e("div",{className:"h-[1px] bg-slate-100 my-1 mx-2"}),c("button",{onClick:()=>{N(),O(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[e(Fe,{size:14,className:"text-slate-400"}),e("span",{children:"Export PPTX"})]})]})]})]}),e("div",{className:"flex-1"}),c("div",{className:"flex items-center gap-2 px-4 h-full",children:[z&&c("div",{className:"flex items-center gap-1.5 px-2.5 py-1 bg-white/50 rounded-full border border-slate-200/50 shadow-sm animate-in fade-in slide-in-from-right-2 duration-300",children:[z==="scratch"&&c(le,{children:[e(ne,{size:10,className:"text-amber-500"}),e("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Scratch"})]}),z==="uploaded"&&c(le,{children:[e(De,{size:10,className:"text-blue-500"}),e("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Uploaded"})]}),z==="url"&&c(le,{children:[e(Fe,{size:10,className:"text-emerald-500"}),e("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Linked"})]})]}),e("div",{className:"h-4 w-[1px] bg-slate-200 mx-1"}),e(St,{size:16,className:"text-slate-400 cursor-pointer hover:text-[#B7472A] transition-colors",onClick:L})]})]}),c("div",{className:"bg-white flex items-center px-4 gap-4 justify-start",style:{height:`${96*h}px`},children:[c("div",{className:B("flex flex-col items-center border-r border-slate-100 py-1",h<.84?"px-1.5 min-w-0":"px-3 min-w-[110px]"),children:[c("div",{className:"flex items-center gap-1 mb-1",children:[c("button",{onClick:f,className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",children:[e("div",{className:"bg-orange-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:e(Se,{size:22,style:{color:l}})}),e("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"New Slide"})]}),c("div",{className:"relative",children:[c("button",{onClick:()=>M(!H),className:B("p-1.5 hover:bg-slate-50 rounded-xl transition-all flex flex-col items-center",H&&"bg-slate-100"),children:[e(De,{size:20,className:"text-slate-500"}),e("span",{className:"text-[10px] font-medium text-slate-500 mt-1",children:"Layout"})]}),H&&c("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-xl shadow-2xl p-2 w-56 flex flex-col gap-1 z-[100] animate-in fade-in zoom-in-95 duration-200",children:[c("button",{onClick:()=>{k("title"),M(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[e(wt,{size:16,className:"text-blue-500"})," Title Slide"]}),c("button",{onClick:()=>{k("content"),M(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[e(Te,{size:16,className:"text-emerald-500"})," Title & Content"]}),c("button",{onClick:()=>{k("split"),M(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[e(yt,{size:16,className:"text-purple-500"})," Two Columns"]})]})]})]}),h>=.85&&e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Slides"})]}),c("div",{className:B("flex flex-col items-center border-r border-slate-100 py-1 pt-1",h<.85?"px-1.5":"px-3"),children:[c("div",{className:B("flex flex-col gap-2",h<.85?"min-w-0":"min-w-[220px]"),children:[c("div",{className:"flex items-center gap-1.5",children:[e("select",{disabled:!P,value:(a==null?void 0:a.fontFamily)||"Arial",onChange:b=>m({fontFamily:b.target.value}),className:B("h-7 px-2 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none disabled:opacity-50 transition-colors appearance-none cursor-pointer",h<.85?"w-24":"w-32"),children:kt.map(b=>e("option",{value:b,children:b},b))}),e("select",{disabled:!P,value:(a==null?void 0:a.fontSize)||24,onChange:b=>m({fontSize:parseInt(b.target.value)}),className:"h-7 px-1.5 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-14 disabled:opacity-50 transition-colors appearance-none cursor-pointer text-center",children:Ct.map(b=>e("option",{value:b,children:b},b))})]}),c("div",{className:"flex items-center gap-1",children:[e("button",{disabled:!P,onClick:()=>m({isBold:!a.isBold}),className:B("p-2 rounded-lg transition-all disabled:opacity-30",a!=null&&a.isBold?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:e(ht,{size:16,strokeWidth:3})}),e("button",{disabled:!P,onClick:()=>m({isItalic:!a.isItalic}),className:B("p-2 rounded-lg transition-all disabled:opacity-30",a!=null&&a.isItalic?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:e(xt,{size:16})}),e("div",{className:"h-4 w-[1px] bg-slate-200 mx-2"}),c("div",{className:"relative group p-1 hover:bg-slate-50 rounded-lg transition-colors cursor-pointer",children:[e("input",{type:"color",disabled:!a,value:P?a.color||"#000000":(a==null?void 0:a.fill)||"#3b82f6",onChange:b=>m(P?{color:b.target.value}:{fill:b.target.value}),className:"w-8 h-6 p-0 border-0 bg-transparent cursor-pointer disabled:opacity-30",title:"Format Color"}),e("div",{className:"absolute bottom-1.5 left-2 right-2 h-1 rounded-full",style:{backgroundColor:P?a.color||"#000000":(a==null?void 0:a.fill)||"#3b82f6"}})]})]})]}),h>=.85&&e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto pt-1",children:"Font"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-4 py-1",children:[c("div",{className:"flex flex-col gap-1",children:[c("div",{className:"flex items-center gap-1 px-1.5 py-1 bg-slate-50 rounded-xl border border-slate-100",children:[e("button",{disabled:!P,onClick:()=>m({textAlign:"left"}),className:B("p-1.5 rounded-lg transition-all disabled:opacity-30",(a==null?void 0:a.textAlign)==="left"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(a==null?void 0:a.textAlign)==="left"?l:void 0},children:e(gt,{size:16})}),e("button",{disabled:!P,onClick:()=>m({textAlign:"center"}),className:B("p-1.5 rounded-lg transition-all disabled:opacity-30",(a==null?void 0:a.textAlign)==="center"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(a==null?void 0:a.textAlign)==="center"?l:void 0},children:e(bt,{size:16})}),e("button",{disabled:!P,onClick:()=>m({textAlign:"right"}),className:B("p-1.5 rounded-lg transition-all disabled:opacity-30",(a==null?void 0:a.textAlign)==="right"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(a==null?void 0:a.textAlign)==="right"?l:void 0},children:e(vt,{size:16})})]}),e("button",{disabled:!P,onClick:()=>m({isBulleted:!a.isBulleted}),className:B("p-2 rounded-lg self-start transition-all disabled:opacity-30",a!=null&&a.isBulleted?"bg-slate-100":"text-slate-500 hover:bg-slate-50"),style:{color:a!=null&&a.isBulleted?l:void 0},children:e(Te,{size:18})})]}),e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Paragraph"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-3 py-1 shrink-0",children:[c("div",{className:"flex items-center gap-1.5 mb-0.5",children:[c("div",{className:"relative group/shapes",children:[c("button",{className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",onClick:()=>{var b;return(b=window._toggleShapesMenu)==null?void 0:b.call(window)},children:[e("div",{className:"bg-blue-50 p-1.5 rounded-lg group-hover:scale-105 transition-transform",children:e(ft,{size:20,className:"text-blue-600"})}),e("span",{className:"text-[9px] font-bold text-slate-700 mt-1",children:"Shapes"})]}),e(zt,{onAddShape:b=>{p(b)},uiScale:h})]}),e("div",{className:"h-10 w-[1px] bg-slate-100 mx-2"}),e("button",{onClick:g,className:"p-2 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Text Box",children:e(pt,{size:18})}),c("button",{onClick:()=>{var b;return(b=D.current)==null?void 0:b.click()},className:"p-2 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Image",children:[e(ut,{size:18}),e("input",{type:"file",ref:D,className:"hidden",accept:"image/*",onChange:b=>{var q;return((q=b.target.files)==null?void 0:q[0])&&i(b.target.files[0])}})]})]}),e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Drawing"})]}),c("div",{className:"flex flex-col items-center border-r border-slate-100 px-4 py-1",children:[c("div",{className:"flex flex-col gap-2 relative",children:[c("div",{className:"flex items-center gap-1.5",children:[c("button",{disabled:!P||t,onClick:()=>o(a.id,"shorten"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[e(ne,{size:14,className:"text-purple-500"}),e("span",{className:"text-[9px] font-bold",children:"Shorten"})]}),c("button",{disabled:!P||t,onClick:()=>o(a.id,"reframe"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[e(ne,{size:14,className:"text-blue-500"}),e("span",{className:"text-[9px] font-bold",children:"Reframe"})]}),c("button",{disabled:!P||t,onClick:()=>o(a.id,"lengthen"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[e(ne,{size:14,className:"text-emerald-500"}),e("span",{className:B("text-[9px] font-bold",h<.85&&"hidden"),children:"Lengthen"})]})]}),t&&e("div",{className:"absolute inset-0 bg-white/80 flex items-center justify-center rounded-lg z-10 backdrop-blur-[1px]",children:e(ke,{size:18,className:"text-blue-600 animate-spin"})}),y&&c("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] bg-white border border-slate-200 rounded-2xl shadow-2xl p-6 z-[200] animate-in fade-in zoom-in-95 duration-200",children:[c("div",{className:"flex items-center gap-2 mb-4",children:[e(ne,{size:20,className:"text-purple-600"}),e("h3",{className:"text-sm font-black text-slate-800 uppercase tracking-widest",children:"AI Generated Response"})]}),c("div",{className:"bg-slate-50 p-4 rounded-xl mb-6 max-h-[200px] overflow-y-auto border border-slate-100 italic text-slate-700 text-sm leading-relaxed",children:['"',y,'"']}),c("div",{className:"flex flex-col gap-2",children:[c("div",{className:"grid grid-cols-2 gap-2",children:[e("button",{onClick:()=>x("replace"),className:"px-4 py-2.5 text-white text-[11px] font-bold rounded-lg transition-colors shadow-sm",style:{backgroundColor:l},children:"REPLACE CURRENT"}),e("button",{onClick:()=>x("addBelow"),className:"px-4 py-2.5 bg-slate-800 text-white text-[11px] font-bold rounded-lg hover:bg-slate-900 transition-colors shadow-sm",children:"ADD BELOW"})]}),c("div",{className:"flex gap-2",children:[c("button",{onClick:()=>x("regenerate"),className:"flex-1 px-4 py-2.5 border border-slate-200 text-slate-600 text-[11px] font-bold rounded-lg hover:bg-slate-50 transition-colors flex items-center justify-center gap-2",children:[e(ke,{size:14})," REGENERATE"]}),e("button",{className:"px-4 py-2.5 text-slate-400 text-[11px] font-bold hover:text-slate-600 transition-colors",onClick:()=>{x("replace")},children:"CLOSE"})]})]})]})]}),e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"AI Text"})]}),c("div",{className:"flex flex-col items-center px-3 py-1",children:[c("div",{className:"flex gap-3",children:[e("button",{onClick:N,className:"flex flex-col items-center justify-center p-2.5 hover:bg-emerald-50 rounded-xl group transition-all",title:"Download Presentation",children:e("div",{className:"bg-emerald-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:e(Ne,{size:22,className:"text-emerald-700"})})}),a&&e("button",{onClick:S,className:"flex flex-col items-center justify-center p-2.5 hover:bg-red-50 rounded-xl group transition-all",title:"Delete Element",children:e("div",{className:"bg-red-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:e(mt,{size:22,className:"text-red-600"})})})]}),e("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Actions"})]}),e("div",{className:"flex-1"}),c("div",{className:"pr-12 flex flex-col items-end gap-1 group",children:[c("div",{className:"flex items-center gap-1.5 text-[10px] font-black text-slate-300 transition-colors",style:{color:l},children:[e(Nt,{size:12}),e("span",{children:"SAVED AUTOMATICALLY"})]}),e("div",{className:"h-1 w-24 bg-slate-100 rounded-full overflow-hidden",children:e("div",{className:"h-full w-full bg-emerald-500/20"})})]})]}),Q&&c(le,{children:[e("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-[2000]",onClick:()=>R(!1)}),c("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] bg-white rounded-3xl shadow-2xl z-[2001] border border-slate-200 p-8 animate-in fade-in zoom-in-95 duration-200",children:[c("div",{className:"flex justify-between items-center mb-6",children:[c("h3",{className:"text-lg font-black text-slate-800 tracking-tight flex items-center gap-3",children:[e("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-xl",children:e(Ne,{size:20})}),"Upload Presentation"]}),e("button",{onClick:()=>R(!1),className:"text-slate-400 hover:text-slate-600 transition-colors",children:e(ke,{size:20,className:"rotate-45"})})]}),c("div",{className:"flex gap-2 p-1 bg-slate-50 rounded-2xl mb-8",children:[e("button",{onClick:()=>Z("file"),className:B("flex-1 py-3 text-xs font-black rounded-xl transition-all",U==="file"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"FILE UPLOAD"}),e("button",{onClick:()=>Z("link"),className:B("flex-1 py-3 text-xs font-black rounded-xl transition-all",U==="link"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"LINK UPLOAD"})]}),U==="file"?c("label",{className:"flex flex-col items-center justify-center gap-4 py-12 border-2 border-dashed border-slate-200 rounded-3xl hover:border-blue-400 hover:bg-blue-50/50 transition-all cursor-pointer group",children:[e("div",{className:"p-4 bg-white rounded-2xl shadow-sm border border-slate-100 group-hover:scale-110 transition-transform",children:e(Se,{size:24,className:"text-blue-500"})}),c("div",{className:"text-center",children:[e("p",{className:"text-sm font-bold text-slate-700",children:"Choose a PPTX file"}),e("p",{className:"text-xs text-slate-400 mt-1",children:"Maximum file size: 50MB"})]}),e("input",{type:"file",accept:".pptx",className:"hidden",onChange:b=>{var G;let q=(G=b.target.files)==null?void 0:G[0];q&&(r(q),R(!1))}})]}):c("div",{className:"space-y-4",children:[e("div",{className:"relative",children:e("input",{type:"text",placeholder:"Paste S3 or public URL",value:ee,onChange:b=>ie(b.target.value),className:"w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 focus:outline-none focus:ring-4 focus:ring-blue-500/10 focus:border-blue-500 text-sm placeholder:text-slate-400 text-black"})}),e("button",{onClick:()=>{ee.trim()&&(r(ee.trim()),R(!1))},disabled:!ee.trim(),className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 text-white font-black py-4 rounded-2xl transition-all shadow-lg shadow-blue-500/20",children:"LOAD PRESENTATION"}),e("p",{className:"text-[10px] text-slate-400 text-center uppercase tracking-widest font-black",children:"Supports S3, Dropbox, and public URLS"})]})]})]})]})};import{Trash2 as It,Copy as Pt,GripVertical as Bt}from"lucide-react";import{DndContext as Tt,closestCenter as Dt,KeyboardSensor as Ft,PointerSensor as Mt,useSensor as $e,useSensors as Rt}from"@dnd-kit/core";import{SortableContext as $t,sortableKeyboardCoordinates as Ht,verticalListSortingStrategy as Ut,useSortable as Ot}from"@dnd-kit/sortable";import{CSS as Et}from"@dnd-kit/utilities";import{jsx as T,jsxs as te}from"react/jsx-runtime";var jt=({slide:g,index:i,isActive:p,onSelect:f,onDelete:N,onDuplicate:m,showDelete:S,uiScale:k})=>{let{attributes:L,listeners:a,setNodeRef:v,transform:o,transition:x,isDragging:y}=Ot({id:g.id}),t={transform:Et.Transform.toString(o),transition:x,zIndex:y?2:1,opacity:y?.5:1};return te("div",{ref:v,style:t,onClick:f,className:B("cursor-pointer border-[1.5px] rounded-2xl p-2 transition-all duration-300 group relative select-none",p?"border-[#B7472A] bg-white":"border-transparent hover:border-slate-200 bg-white/50 hover:bg-white"),children:[te("div",{className:"text-[10px] font-bold text-slate-400 mb-1 flex items-center justify-between",children:[te("div",{className:"flex items-center gap-1",children:[T("div",A(w(w({},L),a),{className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-slate-100 rounded text-slate-300 hover:text-slate-500",children:T(Bt,{size:10})})),te("span",{children:["SLIDE ",i+1]})]}),te("div",{className:"flex items-center gap-1",children:[p&&T("span",{className:"h-1.5 w-1.5 rounded-full bg-[#B7472A]"}),te("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[T("button",{onClick:s=>{s.stopPropagation(),m()},className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-500 rounded transition-all",title:"Duplicate Slide",children:T(Pt,{size:12})}),S&&T("button",{onClick:s=>{s.stopPropagation(),N()},className:"p-1 hover:bg-red-50 text-red-400 hover:text-red-500 rounded transition-all",title:"Delete Slide",children:T(It,{size:12})})]})]})]}),T("div",{className:"aspect-video bg-white rounded-xl flex items-center justify-center border border-slate-200 overflow-hidden relative group-hover:shadow-sm transition-shadow",children:T("div",{className:"origin-center pointer-events-none select-none shrink-0",style:{width:"1200px",height:"675px",transform:`scale(${180*k/1200})`,backgroundColor:"#ffffff"},children:g.elements.sort((s,r)=>(s.zIndex||0)-(r.zIndex||0)).map(s=>{var l;let r={position:"absolute",left:s.x,top:s.y,width:s.width,height:s.height,opacity:(l=s.opacity)!=null?l:1};return s.type==="text"?T("div",{style:A(w({},r),{fontSize:s.fontSize,fontFamily:s.fontFamily,color:s.color,textAlign:s.textAlign||"left",fontWeight:s.isBold?"bold":"normal",fontStyle:s.isItalic?"italic":"normal",lineHeight:1.2,overflow:"hidden",wordBreak:"break-word",whiteSpace:"pre-wrap"}),children:s.content},s.id):s.type==="shape"?T("div",{style:A(w({},r),{backgroundColor:s.fill,borderRadius:s.shapeType==="ellipse"?"50%":"0"})},s.id):s.type==="image"?T("img",{src:s.src,alt:"",style:A(w({},r),{objectFit:"contain"})},s.id):null})})})]})},He=({slides:g,currentSlideIndex:i,onSelectSlide:p,onDeleteSlide:f,onDuplicateSlide:N,onReorderSlides:m,uiScale:S})=>{let k=Rt($e(Mt,{activationConstraint:{distance:5}}),$e(Ft,{coordinateGetter:Ht})),L=a=>{let{active:v,over:o}=a;if(v.id!==(o==null?void 0:o.id)){let x=g.findIndex(t=>t.id===v.id),y=g.findIndex(t=>t.id===(o==null?void 0:o.id));m(x,y)}};return T("div",{className:"bg-white border-r border-slate-100 overflow-y-auto p-4 flex flex-col gap-4",style:{width:`${256*S}px`},children:T(Tt,{sensors:k,collisionDetection:Dt,onDragEnd:L,children:T($t,{items:g.map(a=>a.id),strategy:Ut,children:g.map((a,v)=>T(jt,{slide:a,index:v,isActive:v===i,onSelect:()=>p(v),onDelete:()=>f(v),onDuplicate:()=>N(v),showDelete:g.length>1,uiScale:S},a.id))})})})};import{useEffect as Ce,useRef as ce}from"react";import*as E from"fabric";import{jsx as Ue}from"react/jsx-runtime";var ue=({slide:g,onElementUpdate:i,onSelect:p,uiScale:f})=>{let N=ce(null),m=ce(null),S=ce(!1),k=ce(i),L=ce(p);return Ce(()=>{k.current=i,L.current=p},[i,p]),Ce(()=>{if(N.current&&!m.current){m.current=new E.Canvas(N.current,{width:1200,height:675,backgroundColor:"#ffffff"});let a=m.current,v=t=>{t.left<0&&t.set("left",0),t.top<0&&t.set("top",0);let s=t.getBoundingRect();s.left+s.width>(a.width||1200)&&t.set("left",(a.width||1200)-s.width),s.top+s.height>(a.height||675)&&t.set("top",(a.height||675)-s.height)};a.on("object:moving",t=>v(t.target)),a.on("object:scaling",t=>v(t.target));let o=t=>{var l;if(S.current)return;let s=t.target,r=(l=s.get("data"))==null?void 0:l.id;s&&r&&k.current(r,w({x:s.left,y:s.top,width:s.getScaledWidth(),height:s.getScaledHeight()},s.isType("textbox")?{content:s.text,textAlign:s.textAlign,fontSize:s.fontSize,fontFamily:s.fontFamily,color:s.fill}:{fill:s.fill}))};a.on("object:modified",o),a.on("text:changed",o);let x=t=>{var r,l;let s=((r=t.selected)==null?void 0:r[0])||t.target;if(s){let h=(l=s.get("data"))==null?void 0:l.id;L.current(h)}};a.on("selection:created",x),a.on("selection:updated",x),a.on("selection:cleared",()=>L.current(null));let y=t=>{let s=a.getActiveObject();if(!s||s.isType("textbox")&&s.isEditing)return;let r=t.shiftKey?10:1,l=!1;switch(t.key){case"ArrowLeft":s.set("left",s.left-r),l=!0;break;case"ArrowRight":s.set("left",s.left+r),l=!0;break;case"ArrowUp":s.set("top",s.top-r),l=!0;break;case"ArrowDown":s.set("top",s.top+r),l=!0;break}l&&(v(s),a.requestRenderAll(),o({target:s}))};window.addEventListener("keydown",y),a._keyboardListener=y}return()=>{if(m.current){let a=m.current._keyboardListener;a&&window.removeEventListener("keydown",a),m.current.dispose(),m.current=null}}},[]),Ce(()=>{if(!m.current)return;let a=m.current;(async()=>{S.current=!0;let o=a.getObjects(),x=new Set(g.elements.map(t=>t.id));o.forEach(t=>{var r;let s=(r=t.get("data"))==null?void 0:r.id;s&&!x.has(s)&&a.remove(t)});let y=[...g.elements].sort((t,s)=>(t.zIndex||0)-(s.zIndex||0));for(let t of y){let s=o.find(r=>{var l;return((l=r.get("data"))==null?void 0:l.id)===t.id});if(s){if(s===a.getActiveObject()&&s.isType("textbox")&&s.isEditing)continue;let r={left:t.x,top:t.y,opacity:t.opacity!==void 0?t.opacity:1,zIndex:t.zIndex};t.type==="text"&&s.isType("textbox")?(r.text=t.content||" ",r.fontSize=t.fontSize||22,r.fill=t.color||"#000000",r.textAlign=t.textAlign||"left",r.fontWeight=t.isBold?"bold":"normal",r.fontStyle=t.isItalic?"italic":"normal",r.fontFamily=t.fontFamily||"Arial",r.width=Math.max(t.width||50,10)):t.type==="shape"?(r.fill=t.fill||"#cccccc",r.scaleX=(t.width||50)/(s.width||1),r.scaleY=(t.height||50)/(s.height||1)):t.type==="image"&&(r.scaleX=(t.width||100)/(s.width||1),r.scaleY=(t.height||100)/(s.height||1)),s.set(r)}else{let r=null,l={left:t.x,top:t.y,data:{id:t.id},originX:"left",originY:"top",opacity:t.opacity!==void 0?t.opacity:1};if(t.type==="text")r=new E.Textbox(t.content||" ",A(w({},l),{width:Math.max(t.width||200,10),fontSize:t.fontSize||22,fill:t.color||"#000000",fontFamily:t.fontFamily||"Inter, Arial, sans-serif",textAlign:t.textAlign||"left",fontWeight:t.isBold?"bold":"normal",fontStyle:t.isItalic?"italic":"normal",splitByGrapheme:!1}));else if(t.type==="shape"){let h=t.fill||"#3b82f6";t.shapeType==="ellipse"?r=new E.Circle(A(w({},l),{radius:(t.width||100)/2,scaleY:(t.height||100)/(t.width||100),fill:h})):r=new E.Rect(A(w({},l),{width:t.width||100,height:t.height||100,fill:h}))}else if(t.type==="image")try{let h=await E.FabricImage.fromURL(t.src);h.set(A(w({},l),{scaleX:(t.width||100)/(h.width||1),scaleY:(t.height||100)/(h.height||1)})),r=h}catch(h){console.error(h)}r&&a.add(r)}}a.renderAll(),S.current=!1})()},[g]),Ue("div",{className:"border border-slate-200 overflow-hidden bg-white shadow-lg transition-transform duration-300",style:{transform:`scale(${f*.8})`,transformOrigin:"center center"},children:Ue("canvas",{ref:N})})};import Vt from"pptxgenjs";var fe=class{async export(i){var a,v;let p=new Vt,f=((a=i.layout)==null?void 0:a.width)||12192e3,N=((v=i.layout)==null?void 0:v.height)||6858e3,m=1200,S=675,k=o=>o/m*(f/914400),L=o=>o/S*(N/914400);i.slides.forEach(o=>{let x=p.addSlide();[...o.elements].sort((t,s)=>t.zIndex-s.zIndex).forEach(t=>{var l,h;let s=t.opacity!==void 0?(1-t.opacity)*100:0,r={x:k(t.x),y:L(t.y),w:k(t.width),h:L(t.height)};if(t.type==="text")x.addText(t.content,A(w({},r),{fontSize:(t.fontSize||18)/2,color:((l=t.color)==null?void 0:l.replace("#",""))||"000000",fontFace:t.fontFamily||"Arial"}));else if(t.type==="image")x.addImage(A(w({},r),{path:t.src,transparency:s}));else if(t.type==="shape"){let z=t.shapeType==="ellipse"?p.ShapeType.ellipse:p.ShapeType.rect;x.addShape(z,A(w({},r),{fill:{color:((h=t.fill)==null?void 0:h.replace("#",""))||"CCCCCC",transparency:s>0?Math.min(s+10,100):0}}))}})}),await p.writeFile({fileName:"presentation.pptx"})}};import Wt from"jszip";var me=class{constructor(){this.slideWidth=12192e3;this.slideHeight=6858e3;this.CANVAS_WIDTH=1200;this.CANVAS_HEIGHT=675}async parse(i){var v,o;let p=i;if(typeof i=="string"){let x=await fetch(i);if(!x.ok){let y=x.status,t=x.statusText,s="";try{let r=await x.json();s=r.details||r.error||""}catch(r){}throw new Error(`Failed to fetch PPTX from ${i}: ${y} ${t} ${s?`(${s})`:""}`)}p=await x.arrayBuffer()}let f=await Wt.loadAsync(p),N=await((v=f.file("ppt/presentation.xml"))==null?void 0:v.async("string"));if(!N)throw new Error("Invalid PPTX");let S=new DOMParser().parseFromString(N,"text/xml"),k=this.findFirstByLocalName(S,"sldSz");k&&(this.slideWidth=parseInt(this.getAttr(k,"cx")||"12192000"),this.slideHeight=parseInt(this.getAttr(k,"cy")||"6858000"));let L=Array.from(S.getElementsByTagNameNS("*","sldId")),a=[];for(let x=0;x<L.length;x++){let y=x+1,t=`ppt/slides/slide${y}.xml`,s=await((o=f.file(t))==null?void 0:o.async("string"));if(s){let r=await this.parseSlide(s,y,f);a.push(r)}}return{slides:a,layout:{width:this.slideWidth,height:this.slideHeight}}}getAttr(i,p){return i.getAttribute(p)||i.getAttribute(`a:${p}`)||i.getAttribute(`p:${p}`)||i.getAttribute(`r:${p}`)}findFirstByLocalName(i,p){let f=i.getElementsByTagNameNS("*",p);return f.length>0?f[0]:null}findAllByLocalName(i,p){return Array.from(i.getElementsByTagNameNS("*",p))}scaleX(i){return i/this.slideWidth*this.CANVAS_WIDTH}scaleY(i){return i/this.slideHeight*this.CANVAS_HEIGHT}parseColor(i){let p=this.findFirstByLocalName(i,"srgbClr");if(p){let N=`#${this.getAttr(p,"val")}`,m=this.findFirstByLocalName(p,"alpha"),S=m?parseInt(this.getAttr(m,"val")||"100000")/1e5:1;return{color:N,opacity:S}}let f=this.findFirstByLocalName(i,"schemeClr");if(f){let N=this.findFirstByLocalName(f,"alpha");return{color:"#000000",opacity:N?parseInt(this.getAttr(N,"val")||"100000")/1e5:1}}return{color:"#000000",opacity:1}}async resolveImage(i,p,f){var a,v;let N=await((a=f.file(`ppt/slides/_rels/slide${p}.xml.rels`))==null?void 0:a.async("string"));if(!N)return null;let S=new DOMParser().parseFromString(N,"text/xml"),k=Array.from(S.getElementsByTagName("Relationship")).find(o=>o.getAttribute("Id")===i),L=k==null?void 0:k.getAttribute("Target");if(L){let o=(L.startsWith("../")?`ppt/${L.substring(3)}`:`ppt/slides/${L}`).replace("ppt/slides/../","ppt/");return await((v=f.file(o))==null?void 0:v.async("blob"))||null}return null}async parseSlide(i,p,f){let m=new DOMParser().parseFromString(i,"text/xml"),S=[],k=0,L=this.findFirstByLocalName(m,"bg");if(L){let o=this.findFirstByLocalName(L,"blip"),x=(o==null?void 0:o.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(o==null?void 0:o.getAttribute("r:embed"));if(x){let y=await this.resolveImage(x,p,f);y&&S.push({id:`bg-${p}`,type:"image",src:URL.createObjectURL(y),x:0,y:0,width:this.CANVAS_WIDTH,height:this.CANVAS_HEIGHT,zIndex:k++,opacity:1})}}let a=this.findFirstByLocalName(m,"spTree");if(!a)return{id:`slide-${p}`,elements:S};let v=Array.from(a.children);for(let o of v){let x=o.localName;if(x==="sp"){let y=this.findFirstByLocalName(o,"txBody"),t=this.findFirstByLocalName(o,"xfrm"),s=t?this.findFirstByLocalName(t,"off"):null,r=t?this.findFirstByLocalName(t,"ext"):null;if(y&&s&&r){let h=this.findAllByLocalName(y,"p"),z="",D=18,se="#000000",K=1,H=!1;for(let M of h){let W=this.findFirstByLocalName(M,"pPr"),ae=W?this.findFirstByLocalName(W,"buNone"):null;W&&!ae&&(this.findFirstByLocalName(W,"buChar")||this.findFirstByLocalName(W,"buAutoNum"))&&(H=!0,z+="\u2022 ");let X=this.findAllByLocalName(M,"r");for(let O of X){let Q=this.findFirstByLocalName(O,"t");Q&&(z+=Q.textContent);let R=this.findFirstByLocalName(O,"rPr");if(R){let U=this.getAttr(R,"sz");U&&(D=parseInt(U)/100*2);let Z=this.parseColor(R);se=Z.color,K=Z.opacity}}z+=`
|
|
3
|
+
`}if(z.trim()){S.push({id:`el-${p}-${Date.now()}-${k}`,type:"text",content:z.trim(),x:this.scaleX(parseInt(this.getAttr(s,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(s,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(r,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(r,"cy")||"0")),fontSize:D,color:se,fontFamily:"Arial",zIndex:k++,isBulleted:H,opacity:K});continue}}let l=this.findFirstByLocalName(o,"prstGeom");if(l&&s&&r){let h=this.getAttr(l,"prst"),z=this.findFirstByLocalName(o,"spPr"),D=z?this.parseColor(z):{color:"#cccccc",opacity:1};S.push({id:`el-${p}-${Date.now()}-${k}`,type:"shape",shapeType:h==="ellipse"||h==="circle"?"ellipse":"rect",fill:D.color,opacity:D.opacity,x:this.scaleX(parseInt(this.getAttr(s,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(s,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(r,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(r,"cy")||"0")),zIndex:k++})}}if(x==="pic"){let y=this.findFirstByLocalName(o,"blip"),t=(y==null?void 0:y.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(y==null?void 0:y.getAttribute("r:embed")),s=this.findFirstByLocalName(o,"xfrm"),r=s?this.findFirstByLocalName(s,"off"):null,l=s?this.findFirstByLocalName(s,"ext"):null;if(t&&r&&l){let h=await this.resolveImage(t,p,f);h&&S.push({id:`el-${p}-${Date.now()}-${k}`,type:"image",src:URL.createObjectURL(h),x:this.scaleX(parseInt(this.getAttr(r,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(r,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(l,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(l,"cy")||"0")),zIndex:k++,opacity:1})}}}return{id:`slide-${p}`,elements:S}}};import{useEffect as Oe,useState as Ee}from"react";import{ChevronLeft as Xt,ChevronRight as Gt,X as Yt}from"lucide-react";import{jsx as j,jsxs as he}from"react/jsx-runtime";var je=({presentation:g,initialSlideIndex:i,onClose:p})=>{let[f,N]=Ee(i),m=g.slides[f],S=()=>{f>0&&N(f-1)},k=()=>{f<g.slides.length-1&&N(f+1)};Oe(()=>{let v=o=>{o.key==="ArrowRight"||o.key===" "||o.key==="PageDown"?k():o.key==="ArrowLeft"||o.key==="Backspace"||o.key==="PageUp"?S():o.key==="Escape"&&p()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f]);let[L,a]=Ee(1);return Oe(()=>{let v=()=>{let x=window.innerWidth-40,y=window.innerHeight-40,t=1200,s=675,r=x/t,l=y/s,h=Math.min(r,l);a(h)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]),he("div",{className:"fixed inset-0 z-[99999] bg-[#0A0A0A] flex flex-col items-center justify-center overflow-hidden",children:[he("div",{className:"absolute top-0 left-0 right-0 p-6 flex justify-between items-center opacity-0 hover:opacity-100 transition-opacity bg-gradient-to-b from-black/60 to-transparent z-[100] pointer-events-none",children:[he("div",{className:"text-white/80 font-bold ml-4 pointer-events-auto",children:["Slide ",f+1," of ",g.slides.length]}),j("button",{onClick:p,className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-full transition-all pointer-events-auto",children:j(Yt,{size:24})})]}),j("div",{className:"w-full h-full flex items-center justify-center",children:j("div",{className:"relative shadow-2xl shadow-black/80 bg-white",style:{width:"1200px",height:"675px",transform:`scale(${L})`,transformOrigin:"center center"},children:j(ue,{slide:m,onElementUpdate:()=>{},onSelect:()=>{},uiScale:.75})})}),he("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 flex items-center gap-6 opacity-0 hover:opacity-100 transition-opacity bg-black/40 backdrop-blur-md px-6 py-3 rounded-full border border-white/10 pointer-events-auto",children:[j("button",{disabled:f===0,onClick:S,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:j(Xt,{size:32})}),j("div",{className:"h-6 w-[1px] bg-white/10"}),j("button",{disabled:f===g.slides.length-1,onClick:k,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:j(Gt,{size:32})})]})]})};import{GoogleGenerativeAI as _t}from"@google/generative-ai";import{jsx as I,jsxs as V}from"react/jsx-runtime";var js=({initialPresentation:g,url:i,appName:p="SlideCanvas",onChange:f,geminiApiKey:N,width:m,height:S,appBgColor:k="#B7472A",showHomeOnEmpty:L=!1,initialSource:a,onSourceChange:v})=>{let[o,x]=$(g||{slides:[{id:"slide-1",elements:[]}],layout:{width:12192e3,height:6858e3}}),[y,t]=$([]),[s,r]=$([]),[l,h]=$(0),[z,D]=$(null),[se,K]=$(!1),[H,M]=$(null),[W,ae]=$(!1),[X,O]=$(a||(i?"url":null)),[Q,R]=$(L&&!g&&!i&&!a),[U,Z]=$("");Ae(()=>{i&&de(i)},[i]);let[ee,ie]=$(!1),[P,ge]=$(null),oe=Ve(()=>{let n=typeof m=="number"?m:parseInt(String(m));return isNaN(n)?1:Math.min(Math.max(n/1600,.7),1)},[m]),b=o.slides[l],q=Ve(()=>b.elements.find(n=>n.id===z)||null,[b,z]),G=xe(n=>{t(d=>[...d.slice(-19),o]),r([]),x(n),f==null||f(n)},[f,o]),Le=()=>{if(y.length===0)return;let n=y[y.length-1];r(d=>[...d,o]),t(d=>d.slice(0,-1)),x(n)},be=()=>{if(s.length===0)return;let n=s[s.length-1];t(d=>[...d,o]),r(d=>d.slice(0,-1)),x(n)},J=xe(n=>{x(d=>{let u=[...d.slides];u[l]=w(w({},u[l]),n);let C=A(w({},d),{slides:u});return t(F=>[...F.slice(-19),d]),r([]),f==null||f(C),C})},[l,f]),ve=xe((n,d)=>{x(u=>{let C=u.slides[l],F=C.elements.map(re=>re.id===n?w(w({},re),d):re),Y=[...u.slides];Y[l]=A(w({},C),{elements:F});let pe=A(w({},u),{slides:Y});return f==null||f(pe),pe})},[l,f]),We=n=>{if(!z)return;if(b.elements.find(u=>u.id===z)){ve(z,n);let u=o.slides[l],C=u.elements.map(Y=>Y.id===z?w(w({},Y),n):Y),F=[...o.slides];F[l]=A(w({},u),{elements:C}),G(A(w({},o),{slides:F}))}},ye=xe(()=>{if(!z)return;let d=o.slides[l].elements.filter(u=>u.id!==z);J({elements:d}),D(null)},[z,l,o,J]),Xe=()=>{let n={id:`text-${Date.now()}`,type:"text",content:"New Text",x:100,y:100,width:400,height:100,fontSize:48,fontFamily:"Arial",color:"#000000",zIndex:b.elements.length};J({elements:[...b.elements,n]})},Ge=n=>{let d=URL.createObjectURL(n),u=`img-${Date.now()}`,C={id:u,type:"image",src:d,x:100,y:100,width:400,height:250,zIndex:b.elements.length};J({elements:[...b.elements,C]}),D(u)},Ye=n=>{let d={id:`shape-${Date.now()}`,type:"shape",shapeType:n,fill:"#3b82f6",x:200,y:200,width:200,height:200,zIndex:b.elements.length};J({elements:[...b.elements,d]})},_e=()=>{let n={id:`slide-${Date.now()}`,elements:[]};G(A(w({},o),{slides:[...o.slides,n]})),h(o.slides.length)},Ke=n=>{if(o.slides.length<=1)return;let d=o.slides.filter((u,C)=>C!==n);G(A(w({},o),{slides:d})),n<=l&&h(Math.max(0,l-1))},Ze=n=>{let d=o.slides[n],u=A(w({},d),{id:`slide-${Date.now()}`,elements:d.elements.map(F=>A(w({},F),{id:`${F.type}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}))}),C=[...o.slides];C.splice(n+1,0,u),G(A(w({},o),{slides:C})),h(n+1)},qe=(n,d)=>{if(n===d)return;let u=[...o.slides],[C]=u.splice(n,1);u.splice(d,0,C),G(A(w({},o),{slides:u})),l===n?h(d):l>n&&l<=d?h(l-1):l<n&&l>=d&&h(l+1)},Je=n=>{let d=[],u=Date.now();n==="title"?d=[{id:`text-title-${u}`,type:"text",content:"Presentation Title",x:100,y:200,width:1e3,height:150,fontSize:80,fontFamily:"Inter",color:"#000000",textAlign:"center",isBold:!0,zIndex:0},{id:`text-sub-${u}`,type:"text",content:"Subtitle goes here",x:200,y:380,width:800,height:80,fontSize:36,fontFamily:"Inter",color:"#64748b",textAlign:"center",zIndex:1}]:n==="content"?d=[{id:`text-title-${u}`,type:"text",content:"Slide Title",x:60,y:40,width:800,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,zIndex:0},{id:`text-body-${u}`,type:"text",content:`\u2022 Add your points here
|
|
4
4
|
\u2022 Press Enter for new line
|
|
5
|
-
\u2022 Use the toolbar to format`,x:60,y:150,width:1080,height:480,fontSize:28,fontFamily:"Inter",color:"#334155",zIndex:1,isBulleted:!0}]:
|
|
5
|
+
\u2022 Use the toolbar to format`,x:60,y:150,width:1080,height:480,fontSize:28,fontFamily:"Inter",color:"#334155",zIndex:1,isBulleted:!0}]:n==="split"&&(d=[{id:`text-title-${u}`,type:"text",content:"Comparison Layout",x:60,y:40,width:1080,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,textAlign:"center",zIndex:0},{id:`text-left-${u}`,type:"text",content:"Left column content goes here.",x:60,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:1},{id:`text-right-${u}`,type:"text",content:"Right column content goes here.",x:620,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:2}]),J({elements:d})},ze=async(n,d)=>{let C=o.slides[l].elements.find(F=>F.id===n);if(!(!C||C.type!=="text")){ie(!0),M(null),ge({id:n,action:d});try{if(!N){M("Gemini API key is missing. Please provide it via the 'geminiApiKey' prop."),ie(!1);return}let Y=new _t(N).getGenerativeModel({model:"gemini-flash-latest",systemInstruction:`You are a professional presentation assistant. Your task is to transform slide text according to specific user requests (shorten, reframe, or lengthen).
|
|
6
6
|
|
|
7
7
|
CRITICAL RULES:
|
|
8
8
|
1. Return ONLY the transformed text.
|
|
@@ -10,9 +10,9 @@ CRITICAL RULES:
|
|
|
10
10
|
3. Do NOT use markdown formatting (like bolding or headers) unless specifically needed for bullet points.
|
|
11
11
|
4. If the input text is a title/headline, the output should be a professional title/headline.
|
|
12
12
|
5. If the input text is a bulleted list, the output MUST be a bulleted list using the same bullet style (e.g., '\u2022').
|
|
13
|
-
6. Maintain the professional tone of the original presentation.`}),
|
|
14
|
-
Text Role: ${
|
|
15
|
-
Original Text: "${
|
|
13
|
+
6. Maintain the professional tone of the original presentation.`}),pe=C.fontSize>32?"Title/Headline":"Body Text/List",re=`Action: ${d.toUpperCase()}
|
|
14
|
+
Text Role: ${pe}
|
|
15
|
+
Original Text: "${C.content}"
|
|
16
16
|
|
|
17
|
-
Transformed Text:`,
|
|
17
|
+
Transformed Text:`,at=await(await Y.generateContent(re)).response;M(at.text().trim())}catch(F){console.error("Gemini AI Error:",F),M("Error generating response. Please check your API key or connection.")}finally{ie(!1)}}},Qe=n=>{if(!H||!P)return;if(n==="regenerate"){ze(P.id,P.action);return}let d=o.slides[l],u=d.elements.find(C=>C.id===P.id);if(!(!u||u.type!=="text")){if(n==="replace")ve(P.id,{content:H});else if(n==="addBelow"){let C=A(w({},u),{id:`text-ai-${Date.now()}`,content:H,y:u.y+u.height+20,zIndex:d.elements.length});J({elements:[...d.elements,C]})}M(null),ge(null)}},et=async()=>{await new fe().export(o)},tt=()=>{K(!0);let n=document.documentElement;n.requestFullscreen&&n.requestFullscreen()},st=()=>{K(!1),document.fullscreenElement&&document.exitFullscreen()};Ae(()=>{let n=()=>{document.fullscreenElement||K(!1)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),Ae(()=>{let n=d=>{if(d.key==="Delete"||d.key==="Backspace"){let u=document.activeElement;if((u==null?void 0:u.tagName)==="INPUT"||(u==null?void 0:u.tagName)==="TEXTAREA"||u!=null&&u.isContentEditable)return;ye()}(d.ctrlKey||d.metaKey)&&(d.key==="z"&&(d.preventDefault(),d.shiftKey?be():Le()),d.key==="y"&&(d.preventDefault(),be()))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[ye,Le,be]);let we=(n,d)=>{O(n),v==null||v(n,d)},Ie=()=>{x({slides:[{id:`slide-${Date.now()}`,elements:[]}],layout:{width:12192e3,height:6858e3}}),h(0),D(null),we("scratch")},de=async n=>{ae(!0);try{let d=new me,u=n;typeof n=="string"?(u=`/api/proxy?url=${encodeURIComponent(n.trim())}`,we("url",n.trim())):we("uploaded");let C=await d.parse(u);x(C),t([]),r([]),h(0),D(null)}catch(d){console.error("Failed to load PPTX",d),alert("Failed to load presentation. Please ensure it is a valid .pptx.")}finally{ae(!1)}};return!m||!S?I("div",{className:"flex items-center justify-center bg-red-50 text-red-600 p-8 rounded-xl border-2 border-red-200 font-bold",children:"Error: width and height props are compulsory for PptEditor."}):V("div",{className:"flex flex-col bg-white overflow-hidden relative",style:{width:typeof m=="number"?`${m}px`:m,height:typeof S=="number"?`${S}px`:S,fontSize:`${16*oe}px`},children:[Q&&I("div",{className:"absolute inset-0 z-[2000] bg-white flex items-center justify-center p-12",children:V("div",{className:"max-w-xl w-full text-center space-y-8 animate-in fade-in zoom-in-95 duration-500",children:[V("div",{className:"space-y-2",children:[I("h2",{className:"text-4xl font-black tracking-tight text-slate-800",children:p}),I("p",{className:"text-slate-500 font-medium",children:"Create stunning presentations in seconds."})]}),V("div",{className:"grid grid-cols-2 gap-4",children:[V("button",{onClick:()=>{Ie(),R(!1)},className:"flex flex-col items-center justify-center gap-3 p-8 border-2 border-slate-100 rounded-3xl hover:border-slate-300 hover:bg-slate-50 transition-all group",children:[I("div",{className:"p-3 bg-slate-100 rounded-xl group-hover:bg-blue-50 transition-colors",children:I("svg",{className:"w-6 h-6 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:I("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),I("span",{className:"text-xs font-black uppercase tracking-widest text-slate-600",children:"Start New Deck"})]}),V("label",{className:"flex flex-col items-center justify-center gap-3 p-8 border-2 border-slate-100 rounded-3xl hover:border-slate-300 hover:bg-slate-50 transition-all group cursor-pointer",children:[I("div",{className:"p-3 bg-slate-100 rounded-xl group-hover:bg-emerald-50 transition-colors",children:I("svg",{className:"w-6 h-6 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:I("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),I("span",{className:"text-xs font-black uppercase tracking-widest text-slate-600",children:"Upload PPTX"}),I("input",{type:"file",accept:".pptx",className:"hidden",onChange:n=>{var u;let d=(u=n.target.files)==null?void 0:u[0];d&&(de(d),R(!1))}})]})]}),V("div",{className:"space-y-4 pt-4 border-t border-slate-100",children:[V("div",{className:"flex gap-2",children:[V("div",{className:"flex-1 relative",children:[I("svg",{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:I("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9h18"})}),I("input",{type:"text",placeholder:"Paste presentation URL...",value:U,onChange:n=>Z(n.target.value),className:"text-black w-full bg-slate-50 border border-slate-200 rounded-2xl pl-11 pr-5 py-4 focus:outline-none focus:border-slate-400 focus:ring-4 focus:ring-slate-400/5 text-sm transition-all"})]}),I("button",{onClick:()=>{U.trim()&&(de(U.trim()),R(!1))},disabled:!U.trim()||W,style:{cursor:"pointer"},className:"bg-slate-900 hover:bg-black disabled:bg-slate-200 disabled:text-slate-400 text-white font-bold px-8 rounded-2xl transition-all shadow-sm text-sm",children:"Load"})]}),I("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest",children:"Supports S3, public links, and versioned assets"})]})]})}),se&&I(je,{presentation:o,initialSlideIndex:l,onClose:st}),I(Re,{onAddText:Xe,onAddImage:Ge,onAddShape:Ye,onAddSlide:_e,onExport:et,onFormatText:We,onDeleteElement:ye,onApplyLayout:Je,onPlay:tt,onAiAction:ze,onAiResponseAction:Qe,onNewPresentation:Ie,onLoadPresentation:de,aiResponse:H,isAiLoading:ee,selectedElement:q,appName:p,appBgColor:k,uiScale:oe,source:X}),V("div",{className:"flex flex-1 overflow-hidden",children:[I(He,{slides:o.slides,currentSlideIndex:l,onSelectSlide:h,onDeleteSlide:Ke,onDuplicateSlide:Ze,onReorderSlides:qe,uiScale:oe}),I("div",{className:"flex-1 flex items-center justify-center p-12 overflow-auto bg-white",children:I(ue,{slide:b,onElementUpdate:ve,onSelect:D,uiScale:oe})})]})]})};export{js as PptEditor,fe as PptxExporter,me as PptxParser};
|
|
18
18
|
//# sourceMappingURL=index.mjs.map
|