import{r as d,j as t}from"./react-D_B_5QVd.js";import{q as w,F as v,S,L as k}from"./index-QBya0NjG.js";import{u as C}from"./useLocalStorage-WuAvJp3F.js";import{M as z}from"./MarkdownRenderer-BDaVxTSW.js";import"./jszip-C9ownNzX.js";import"./react-dom-EAO2-NBm.js";import"./scheduler-DYLXRpC5.js";import"./@google-4tyssLU_.js";import"./idb-Dob3nYDb.js";import"./marked-CesSW9Du.js";const g=["bg-yellow-300","bg-green-300","bg-blue-300","bg-pink-300","bg-purple-300"],B=()=>{const[o,n]=C("devcore_notes",[]),[r,u]=d.useState(null),[i,x]=d.useState(!1),[m,c]=d.useState(""),p=d.useCallback(async()=>{if(o.length!==0){x(!0),c("");try{const e=o.map(a=>`- ${a.text}`).join(` `),s=w(e);let l="";for await(const a of s)l+=a,c(l)}catch(e){console.error(e),c("Sorry, an error occurred while summarizing.")}finally{x(!1)}}},[o]),b=()=>{const e={id:Date.now(),text:"New note...",x:50+o.length%10*20,y:50+o.length%10*20,color:g[o.length%g.length]};n([...o,e])},h=(e,s)=>{n(o.map(l=>l.id===e?{...l,text:s}:l))},N=e=>{n(o.filter(s=>s.id!==e))},j=(e,s)=>{if(e.target.tagName==="TEXTAREA"||e.target.tagName==="BUTTON")return;const a=e.currentTarget.getBoundingClientRect();u({id:s,offsetX:e.clientX-a.left,offsetY:e.clientY-a.top})},y=e=>{if(!r)return;const s=e.currentTarget.getBoundingClientRect();n(o.map(l=>l.id===r.id?{...l,x:e.clientX-r.offsetX-s.left,y:e.clientY-r.offsetY-s.top}:l))},f=()=>u(null);return t.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8",children:[t.jsxs("header",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-3xl font-bold text-slate-100 flex items-center",children:[t.jsx(v,{}),t.jsx("span",{className:"ml-3",children:"Dev Notes Sticky Panel"})]}),t.jsx("p",{className:"text-slate-400 mt-1",children:"A place for your thoughts, todos, and random ideas."})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:p,disabled:i||o.length===0,className:"flex items-center gap-2 px-4 py-2 bg-purple-500 text-slate-900 font-bold rounded-md disabled:bg-slate-600",children:[t.jsx(S,{})," ",i?"Summarizing...":"AI Summarize"]}),t.jsx("button",{onClick:b,className:"px-6 py-2 bg-cyan-500 text-slate-900 font-bold rounded-md",children:"Add Note"})]})]}),t.jsx("div",{className:"relative flex-grow bg-slate-900/50 border-2 border-dashed border-slate-700 rounded-lg overflow-hidden",onMouseMove:y,onMouseUp:f,onMouseLeave:f,children:o.map(e=>t.jsxs("div",{className:`absolute w-48 h-48 p-2 flex flex-col shadow-lg cursor-grab active:cursor-grabbing ${e.color}`,style:{top:e.y,left:e.x,transform:(r==null?void 0:r.id)===e.id?"scale(1.05) rotate(3deg)":"scale(1)"},onMouseDown:s=>j(s,e.id),children:[t.jsx("button",{onClick:()=>N(e.id),className:"absolute -top-2 -right-2 w-6 h-6 rounded-full bg-red-500 text-white font-bold text-xs flex items-center justify-center opacity-0 hover:opacity-100",children:"×"}),t.jsx("textarea",{value:e.text,onChange:s=>h(e.id,s.target.value),className:"w-full h-full bg-transparent text-black resize-none focus:outline-none font-medium p-1"})]},e.id))}),(i||m)&&t.jsx("div",{className:"fixed inset-0 bg-slate-900/80 backdrop-blur-sm z-50 flex items-center justify-center",onClick:()=>c(""),children:t.jsxs("div",{className:"w-full max-w-2xl bg-slate-800 border border-slate-700 rounded-lg shadow-2xl p-6",onClick:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-xl font-bold mb-4",children:"AI Summary of Notes"}),i&&!m?t.jsx(k,{}):t.jsx(z,{content:m})]})})]})};export{B as DevNotesStickyPanel}; //# sourceMappingURL=DevNotesStickyPanel-C-lefFL-.js.map