PageSourceSearch

https://ceomindos.com/assets/Door-pxNLsRT8.js

js ceomindos.com collected 2026-10-10 02:34:50 UTC 104,297 bytes, 7 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ideasBankService-CBqncqnk.js","assets/index-KGKWUjdc.js","assets/vendor-ui-BBcGEyn3.js","assets/vendor-react-ZTecBUnV.js","assets/vendor-charts-DDMqbH1O.js","assets/vendor-query-Bg4vXuM0.js","assets/vendor-supabase-kHwMmFCK.js","assets/vendor-date-CX9rHtAx.js","assets/vendor-motion-CmYyPEuW.js","assets/index-ThO54raJ.css"])))=>i.map(i=>d[i]);
2import{j as e}from"./vendor-ui-BBcGEyn3.js";import{r as d,R as $t,f as Gt,h as Jt}from"./vendor-react-ZTecBUnV.js";import{u as fe,ac as at,p as ne,B as _,aa as Se,ae as Ue,y as ce,$ as Ts,s as Y,D as dt,k as mt,l as ut,m as xt,w as Pe,a3 as ht,a1 as ge,ap as _e,o as zs,C as Ee,T as Xt,b3 as Qt,aR as As,aS as _s,aT as Es,aU as $s,h as L,a6 as rt,a7 as nt,a8 as it,a9 as we,aq as Be,aO as Pt,Y as Oe,b4 as Ps,b5 as Os,b6 as Rs,at as Yt,n as Ls,S as Fs,i as Zt,Q as $e,_ as es,A as pt,a as gt,b as ft,c as jt,d as yt,e as bt,f as vt,g as Nt,a4 as wt,K as ts,z as ss,ad as Ms,a0 as St,b7 as as,b8 as rs,b9 as ns,aN as Hs,ai as pe,ba as Ws,aI as Ze,R as Bs,bb as kt,bc as qs,aj as Vs,bd as Ct,au as is,be as Ae,bf as ls,bg as It,bh as Me,v as Us,q as Ks,x as Gs,ab as lt,bi as Js,al as os,bj as Xs,bk as Qs,ao as Ys,Z as Zs,bl as ea,N as ta,E as sa,F as aa,G as ra,O as Ot,W as na,J as et,V as ia,aC as la,am as oa,bm as ca}from"./index-KGKWUjdc.js";import{H as da,M as ma,Q as ua,A as xa}from"./AnnualVisionTab-BQX79tyS.js";import{ideasBankService as se}from"./ideasBankService-CBqncqnk.js";import{L as cs}from"./lightbulb-KRKnGUwC.js";import{M as ha}from"./index-Xf0M4a33.js";import{L as ds}from"./list-checks-QOPWoaIy.js";import{A as pa}from"./archive-B3nn8zkA.js";import{E as He,a as ga,g as fa}from"./EisenhowerSelector-D07PDfZ5.js";import{S as ja}from"./skip-forward-zeRLD7wJ.js";import{Q as ya}from"./QuadrantBadge-PTn_H9h7.js";import{F as ba}from"./filter-CvOfushP.js";import{A as va,a as ms}from"./arrow-up-down-o2rGNJoz.js";import{S as Rt}from"./search-CrQ093D4.js";import{S as qe}from"./square-check-big-B5AlCPd6.js";import{u as Na}from"./useVoiceToText-CfD_6Xa9.js";import{M as wa}from"./mic-off-CIL6GszY.js";import{M as Sa}from"./mic-C_Aiy6Gs.js";import{D as us,a as xs,b as hs,c as ps,d as gs}from"./drawer-n9SPU-5g.js";import{H as Ve}from"./history-cDpVIgmO.js";import{R as fs}from"./rotate-ccw-w_NnYZ-D.js";import{f as ot,p as ka,o as Lt,a as Ft,g as Mt,n as Ca}from"./vendor-date-CX9rHtAx.js";import{D as Ia}from"./DoorPlanningModal-4KP29_JN.js";import{A as Da,a as Ta,b as za,c as Aa}from"./accordion-DyyaeTdz.js";import{K as ke}from"./key-round-D4CnLiPH.js";import{I as js}from"./info-QqQ9nMyT.js";import{T as ct}from"./trending-up-Eg_ZXvGm.js";import{T as _a}from"./trending-down-3WY7UJxm.js";import{C as Ea}from"./cloud-Wyz4pRMx.js";import{C as $a}from"./cloud-off-JFXNHsdb.js";import{C as Dt}from"./circle-alert-DEcQRXP2.js";import{T as Pa}from"./TaskHelpButton-BpqVwDMY.js";import{C as Oa}from"./circle-check-big-D4GwvaCB.js";import{WeeklyPlanningNotification as Ra}from"./WeeklyPlanningNotification-CQNMJdIk.js";import{C as La}from"./calendar-CtMzMSDP.js";import{C as Fa}from"./ConfettiCelebration-C8k5EX19.js";import{E as Ma}from"./ellipsis-BfHp0oNO.js";import{U as Ha,R as Wa}from"./undo-2-CFTG3ldz.js";import{T as tt}from"./TierLockOverlay-CsgF21qh.js";import"./vendor-charts-DDMqbH1O.js";import"./vendor-query-Bg4vXuM0.js";import"./vendor-supabase-kHwMmFCK.js";import"./vendor-motion-CmYyPEuW.js";import"./goalRemindersService-BlrA_Eym.js";import"./bell-off-Hk9JJ_8H.js";import"./calendar-days-CF0wAttr.js";import"./unlink-5GoQE6XV.js";import"./pencil-Dmw0rNHu.js";import"./git-branch-o2AuDfj_.js";import"./pen-lU8EvFEo.js";import"./bot-CyMKWldg.js";import"./languages-oiIUmoY-.js";import"./volume-2-BQktbBeU.js";import"./volume-x-DuCnEkYg.js";import"./EarlyBirdCountdown-DtwcL0ka.js";import"./sword-BiKG7GNY.js";import"./useVoiceInput-DJs2LXOj.js";import"./VoiceInputButton-C4EcUd3i.js";import"./radio-CkxmgwQe.js";import"./key-D4G7f38J.js";import"./list-plus-Cfr8S7qk.js";import"./confetti.module-ONDKWxYZ.js";const Ba=({selectedDomino:t,dominoKeyPoints:i,setSelectedDomino:s,setDominoKeyPoints:l})=>
2{const[a,x]=d.useState([]),[n,c]=d.useState(-1),r=d.useRef(!1);d.useEffect(()=>{if(r.current){r.current=!1;return}const k={selectedDomino:t?{...t}:null,dominoKeyPoints:i.map(b=>({...b,metadata:b.metadata?{...b.metadata}:void 0}))},z=a[n];if(z&&JSON.stringify(z.selectedDomino)===JSON.stringify(k.selectedDomino)&&JSON.stringify(z.dominoKeyPoints)===JSON.stringify(k.dominoKeyPoints))return;const h=a.slice(0,n+1);h.push(k),h.length>20?(h.shift(),x(h),c(h.length-1)):(x(h),c(h.length-1))},[t,i]);const u=d.useCallback(()=>{if(n>0){r.current=!0;const k=a[n-1];return s(k.selectedDomino),l(k.dominoKeyPoints),c(n-1),!0}return!1},[n,a,s,l]),I=d.useCallback(()=>{if(n<a.length-1){r.current=!0;const k=a[n+1];return s(k.selectedDomino),l(k.dominoKeyPoints),c(n+1),!0}return!1},[n,a,s,l]),p=n>0,m=n<a.length-1;return{undo:u,redo:I,canUndo:p,canRedo:m}};function qa(t,i,s){const{toast:l}=fe(),a=d.useCallback(r=>{switch(r){case 4:return"urgent-important";case 3:return"important";case 2:return"urgent";default:return"none"}},[]),x=d.useCallback(async r=>{try{console.log("🔄 Moving idea to HIT:",{idea:r,weekKey:t,day:i}),await at.addIdeaToWeek(t,{id:r.id,text:r.text,category:"hit",priority:a(r.priority),day:i}),await se.archiveIdea(r.id),s==null||s(),l({title:"✅ Idee mutată în Sarcini",description:`"${r.text.substring(0,30)}..." adăugată pentru ${i}`}),console.log("✅ Idea moved to HIT successfully")}catch(u){console.error("❌ Error moving idea to HIT:",u),l({title:"⚠️ Eroare",description:"Nu s-a putut muta ideea în sarcini",variant:"destructive"})}},[t,i,a,s,l]),n=d.useCallback(async r=>{try{console.log("🔄 Moving idea to DO:",{idea:r,weekKey:t,day:i}),await at.addIdeaToWeek(t,{id:r.id,text:r.text,category:"do",priority:a(r.priority),day:i}),await se.archiveIdea(r.id),s==null||s(),l({title:"✅ Idee mutată în To Do",description:`"${r.text.substring(0,30)}..." adăugată pentru ${i}`}),console.log("✅ Idea moved to DO successfully")}catch(u){console.error("❌ Error moving idea to DO:",u),l({title:"⚠️ Eroare",description:"Nu s-a putut muta ideea în to do",variant:"destructive"})}},[t,i,a,s,l]),c=d.useCallback(async(r,u)=>{const I=r.dataTransfer.getData("application/json");if(!I)return!1;try{const p=JSON.parse(I);if(p.type!=="idea-bank-item")return!1;console.log("🎯 Idea dropped on TaskList:",{data:p,targetList:u});const m={id:p.id,text:p.text,priority:p.priority||0,category:p.category||"work",status:"new",analysis_result:null,linked_objective_id:null,analyzed_at:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return u==="hit"?await x(m):await n(m),!0}catch(p){return console.error("Error parsing idea drop data:",p),!1}},[x,n]);return{handleMoveIdeaToHit:x,handleMoveIdeaToDo:n,handleIdeaDrop:c,mapPriority:a}}const Va=({onAddItem:t,onAddTemplate:i})=>{const{language:s}=ne(),l=[{icon:Ue,text:s==="en"?"Schedule important meeting":"Programează 
2întâlnire importantă",color:"text-blue-500",bgColor:"bg-blue-500/10 hover:bg-blue-500/20"},{icon:ce,text:s==="en"?"Complete project milestone":"Finalizează etapă proiect",color:"text-green-500",bgColor:"bg-green-500/10 hover:bg-green-500/20"},{icon:Ts,text:s==="en"?"Follow up with client":"Follow-up cu clientul",color:"text-orange-500",bgColor:"bg-orange-500/10 hover:bg-orange-500/20"}];return e.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-2 animate-fade-in",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(cs,{className:"w-7 h-7 text-primary"})}),e.jsx("h3",{className:"text-base font-semibold text-foreground mb-1 text-center",children:s==="en"?"Start your week":"Începe săptămâna"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 text-center px-2",children:s==="en"?"Add ideas and set your focus":"Adaugă idei și setează focusul"}),e.jsxs(_,{onClick:t,className:"mb-4 bg-primary hover:bg-primary/90 text-primary-foreground",size:"sm",children:[e.jsx(Se,{className:"w-4 h-4 mr-1"}),s==="en"?"Add idea":"Adaugă idee"]}),e.jsxs("div",{className:"w-full space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mb-2",children:s==="en"?"Quick add:":"Adaugă rapid:"}),l.map((a,x)=>e.jsxs("button",{onClick:()=>i(a.text),className:`w-full flex items-center gap-2 p-2.5 rounded-lg ${a.bgColor} transition-all text-left`,children:[e.jsx(a.icon,{className:`w-4 h-4 shrink-0 ${a.color}`}),e.jsx("span",{className:"text-xs text-foreground truncate",children:a.text})]},x))]})]})},Ua=({isOpen:t,onClose:i,idea:s,onMoveToHit:l,onMoveToDo:a,onArchive:x,onAnalysisComplete:n})=>{var q;ne();const{toast:c}=fe(),[r,u]=d.useState([]),[I,p]=d.useState(""),[m,k]=d.useState(!1),[z,h]=d.useState(null),b=d.useRef(null),j=d.useRef(null);d.useEffect(()=>{t&&s&&(u([]),h(null),p(""),g())},[t,s==null?void 0:s.id]),d.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[r]);const g=async()=>{if(!s)return;k(!0);const T={role:"user",content:`Analizează această idee: "${s.text}"`};u([T]);try{await v([T])}catch(A){console.error("Error starting analysis:",A),c({title:"Eroare",description:"Nu s-a putut porni analiza",variant:"destructive"})}finally{k(!1)}},v=async T=>{var J,V,N;const{data:{session:A}}=await Y.auth.getSession();if(!(A!=null&&A.access_token))throw new Error("Not authenticated");const f=await fetch("https://exsbnfmaadjyfblperas.supabase.co/functions/v1/analyze-idea",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${A.access_token}`},body:JSON.stringify({ideaText:s==null?void 0:s.text,messages:T})});if(!f.ok||!f.body)throw new Error("Failed to start analysis stream");const O=f.body.getReader(),E=new TextDecoder;let $="",F="";for(u(P=>[...P,{role:"assistant",content:""}]);;){const{done:P,value:W}=await O.read();if(P)break;$+=E.decode(W,{stream:!0});let ee;for(;(ee=$.indexOf(`
3`))!==-1;){let Z=$.slice(0,ee);
3if($=$.slice(ee+1),Z.endsWith("\r")&&(Z=Z.slice(0,-1)),Z.startsWith(":")||Z.trim()===""||!Z.startsWith("data: "))continue;const U=Z.slice(6).trim();if(U==="[DONE]")break;try{const je=(N=(V=(J=JSON.parse(U).choices)==null?void 0:J[0])==null?void 0:V.delta)==null?void 0:N.content;je&&(F+=je,u(me=>{const X=[...me];return X.length>0&&X[X.length-1].role==="assistant"&&(X[X.length-1]={role:"assistant",content:F}),X}))}catch{$=Z+`
4`+$;break}}}S(F)},S=T=>{try{const A=T.match(/\{[\s\S]*"analysis_complete"[\s\S]*\}/);if(A){const f=JSON.parse(A[0]);f.analysis_complete&&f.result&&(h(f.result),s&&(se.saveAnalysisResult(s.id,f.result),n==null||n(s,f.result)))}}catch{}},y=async()=>{if(!I.trim()||m)return;const T={role:"user",content:I.trim()},A=[...r,T];u(A),p(""),k(!0);try{await v(A)}catch(f){console.error("Error sending message:",f),c({title:"Eroare",description:"Nu s-a putut trimite mesajul",variant:"destructive"})}finally{k(!1)}},R=()=>{if(!z)return null;const T={pursue:{icon:Ee,label:"PURSUE",className:"bg-green-500/20 text-green-400 border-green-500/50"},defer:{icon:Xt,label:"DEFER",className:"bg-yellow-500/20 text-yellow-400 border-yellow-500/50"},discard:{icon:Qt,label:"DISCARD",className:"bg-red-500/20 text-red-400 border-red-500/50"}},{icon:A,label:f,className:O}=T[z.recommendation];return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border ${O}`,children:[e.jsx(A,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:f}),e.jsxs("span",{className:"text-sm opacity-80",children:["(",z.relevance_score,"% relevanță)"]})]})};return e.jsx(dt,{open:t,onOpenChange:T=>!T&&i(),children:e.jsxs(mt,{className:"max-w-2xl h-[80vh] flex flex-col p-0",children:[e.jsxs(ut,{className:"p-4 pb-2 border-b",children:[e.jsxs(xt,{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-5 h-5 text-primary"}),e.jsx("span",{children:"Analiză Idee"})]}),s&&e.jsxs("p",{className:"text-sm text-muted-foreground truncate mt-1",children:['"',s.text,'"']})]}),e.jsx(ht,{className:"flex-1 p-4",ref:b,children:e.jsxs("div",{className:"space-y-4",children:[r.map((T,A)=>e.jsx("div",{className:`flex ${T.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] rounded-lg px-4 py-2 ${T.role==="user"?"bg-primary text-primary-foreground":"bg-muted"}`,children:T.role==="assistant"?e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.jsx(ha,{children:T.content||"..."})}):e.jsx("p",{className:"text-sm",children:T.content})})},A)),m&&((q=r[r.length-1])==null?void 0:q.role)!=="assistant"&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:e.jsx(ge,{className:"w-4 h-4 animate-spin"})})})]})}),z&&e.jsxs("div",{className:"p-4 border-t bg-muted/50 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[R(),z.is_busy_work&&e.jsx("span",{className:"text-xs text-orange-400 bg-orange-500/20 px-2 py-1 rounded",children:"⚠️ Risc de busy work"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(_,{size:"sm",variant:"default",onClick:()=>s&&(l==null?void 0:l(s)),className:"gap-1",children:[e.jsx(ce,{className:"w-4 h-4"}),"Mută în HIT"]}),e.jsxs(_,{size:"sm",variant:"secondary",onClick:()=>s&&(a==null?void 0:a(s)),className:"gap-1",children:[e.jsx(ds,{className:"w-4 h-4"}),"Mută în DO"]}),e.jsxs(_,{size:"sm",variant:"ghost",onClick:()=>s&&(x==null?void 0:x(s)),className:"gap-1",children:[e.jsx(pa,{className:"w-4 h-4"}),"Arhivează"]})]})]}),e.jsx("div",{className:"p-4 border-t",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_e,{ref:j,value:I,onChange:T=>p(T.target.value),onKeyDown:T=>T.key==="Enter"&&!T.shiftKey&&y(),placeholder:"Adaugă detalii sau răspunde la întrebări...",disabled:m,className:"flex-1"}),e.jsx(_,{onClick:y,disabled:m||!I.trim(),size:"icon",children:m?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4"})})]})})]})})},We=({config:t,onClick:i,position:s})=>{const l={tl:"rounded-tl-xl",tr:"rounded-tr-xl",bl:"rounded-bl-xl",br:"rounded-br-xl"};return e.jsxs("button",{onClick:i,className:L("flex flex-col items-center justify-center p-4 transition-all duration-200","border hover:scale-[1.02] active:scale-[0.98]",t.bgColor,t.borderColor,t.hoverBgColor,l[s]),children:[e.jsx("span",{className:"text-2xl mb-1",children:t.icon}),e.jsx("span",{className:L("font-semibold text-sm",t.color),children:t.labelRo.toUpperCase()}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:t.actionRo})]})},Ht=({ideaText:t,onSelectQuadrant:i,onSkip:s,onAnalyze:l})=>{const a=He.q1_reactor,x=He.q2_creator,n=He.q3_delegator,c=He.q4_eliminator;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-3 bg-muted/50 rounded-lg border",children:e.jsxs("p",{className:"text-sm text-foreground font-medium line-clamp-2",children:['📝 "',t,'"']})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-center gap-4 text-[10px] text-muted-foreground font-medium tracking-wider",children:[e.jsx("span",{children:"← URGENT"}),e.jsx("span",{children:"NU URGENT →"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(We,{config:a,onClick:()=>i(a.priority),position:"tl"}),e.jsx(We,{config:x,onClick:()=>i(x.priority),position:"tr"}),e.jsx(We,{config:n,onClick:()=>i(n.priority),position:"bl"}),e.jsx(We,{config:c,onClick:()=>i(c.priority),position:"br"})]}),e.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground px-1",children:[e.jsx("span",{className:"font-medium",children:"↑ IMPORTANT"}),e.jsx("span",{className:"font-medium",children:"↓ NEIMPORTANT"})]})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsxs(_,{variant:"ghost",className:"w-full justify-start gap-2 h-11 text-muted-foreground hover:text-foreground",onClick:s,children:[e.jsx(ja,{className:"w-4 h-4"}),e.jsx("span",{children:"Sări peste (clasifici mai târziu)"})]}),e.jsxs(_,{variant:"outline",className:"w-full justify-start gap-2 h-11 border-primary/30 hover:bg-primary/10 hover:border-primary",onClick:l,children:[e.jsx(Pe,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:"Analizează cu AI"})]})]})]})},Ka=({isOpen:t,onClose:i,ideaText:s,onSelectQuadrant:l,onSkip:a,onAnalyze:x,isMobile:n=!1})=>{const c="Clasifică ideea ta";return n?e.jsx(As,{open:t,onOpenChange:r=>!r&&i(),children:e.jsxs(_s,{side:"bottom",className:"rounded-t-2xl max-h-[85vh]",children:[e.jsx(Es,{className:"pb-4",children:e.jsx($s,{className:"text-center",children:c})}),e.jsx(Ht,{ideaText:s,onSelectQuadrant:l,onSkip:a,onAnalyze:x})]})}):e.jsx(dt,{open:t,onOpenChange:r=>!r&&i(),children:e.jsxs(mt,{className:"sm:max-w-md",children:[e.jsx(ut,{children:e.jsx(xt,{className:"text-center",children:c})}),e.jsx(Ht,{ideaText:s,onSelectQuadrant:l,onSkip:a,onAnalyze:x})]})})},Wt=({onMoveToHit:t,onMoveToDo:i,isMobile:s=!1})=>{var Ce,Ge,Ie;
4const[l,a]=d.useState([]),[x,n]=d.useState(""),[c,r]=d.useState(""),[u,I]=d.useState(!1),[p,m]=d.useState(!1),[k,z]=d.useState(null),[h,b]=d.useState(""),[j,g]=d.useState(null),[v,S]=d.useState(!1),[y,R]=d.useState(null),[q,T]=d.useState(!1),[A,f]=d.useState("all"),[O,E]=d.useState(new Set),[$,F]=d.useState(!1),[J,V]=d.useState("newest"),N=d.useRef(null),{t:P}=ne(),{toast:W}=fe();d.useEffect(()=>{ee()},[]);const ee=async()=>{try{const o=await se.fetchAllIdeas();a(o)}catch(o){console.error("Error loading ideas:",o)}},U=[...l.filter(o=>o.text.toLowerCase().includes(x.toLowerCase())?A==="all"?!0:A==="unclassified"?o.priority===0:A==="reactor"?o.priority===4:A==="creator"?o.priority===3:A==="delegator"?o.priority===2:!0:!1)].sort((o,D)=>{switch(J){case"priority":return(D.priority||0)-(o.priority||0);case"alphabetical":return o.text.localeCompare(D.text);case"newest":default:return new Date(D.created_at).getTime()-new Date(o.created_at).getTime()}}),de=d.useCallback(o=>{if(!o.destination)return;const D=o.source.index,w=o.destination.index;D!==w&&a(Q=>{const re=[...Q],[xe]=re.splice(D,1);return re.splice(w,0,xe),re})},[]),je=d.useCallback(o=>{E(D=>{const w=new Set(D);return w.has(o)?w.delete(o):w.add(o),w})},[]),me=d.useCallback(()=>{E(new Set(U.map(o=>o.id)))},[U]),X=d.useCallback(()=>{E(new Set),F(!1)},[]),le=d.useCallback(async()=>{if(O.size===0)return;const o=O.size;if(confirm(`Sigur vrei să ștergi ${o} ${o===1?"idee":"idei"}?`))try{await Promise.all([...O].map(D=>se.deleteIdea(D))),a(D=>D.filter(w=>!O.has(w.id))),W({title:`🗑️ ${o} ${o===1?"idee ștearsă":"idei șterse"}`,description:"Ideile au fost eliminate"}),X()}catch(D){console.error("Error bulk deleting ideas:",D),W({title:"⚠️ Eroare",description:"Nu s-au putut șterge toate ideile",variant:"destructive"})}},[O,W,X]),oe=[{value:"all",label:"Toate",emoji:"📋"},{value:"reactor",label:"Reactor (Urgent+Important)",emoji:"⚡"},{value:"creator",label:"Creator (Important)",emoji:"✨"},{value:"delegator",label:"Delegator (Urgent)",emoji:"👥"},{value:"unclassified",label:"Neclasificate",emoji:"❓"}],ye=[{value:"newest",label:"Cele mai noi"},{value:"priority",label:"După prioritate"},{value:"alphabetical",label:"Alfabetic"}],C=async()=>{if(c.trim()&&!p){m(!0);try{const o=await se.addIdea(c.trim(),"work",0);a(D=>[o,...D]),r(""),R(o),T(!0)}catch(o){console.error("Error adding idea:",o),W({title:"⚠️ Eroare",description:"Nu s-a putut salva ideea",variant:"destructive"})}finally{m(!1)}}},H=async o=>{if(y){try{o===1?(await ue(y.id),W({title:"🗑️ Idee eliminată",description:"Nu era importantă și nici urgentă"})):(await se.updateIdea(y.id,{priority:o}),a(D=>D.map(w=>w.id===y.id?{...w,priority:o}:w)),W({title:"✅ Idee clasificată!",description:`Cadran: ${fa(o)}`}))}catch(D){console.error("Error updating idea priority:",D)}T(!1),R(null),setTimeout(()=>{var D;return(D=N.current)==null?void 0:D.focus()},0)}},te=()=>{T(!1),R(null),W({title:"💡 Idee salvată",description:"Poți clasifica mai târziu"}),setTimeout(()=>{var o;return(o=N.current)==null?void 0:o.focus()},0)},B=()=>{T(!1),y&&(g(y),S(!0),R(null))},ae=async(o,D)=>{if(D.trim()){try{await se.updateIdea(o,{text:D.trim()}),a(w=>w.map(Q=>Q.id===o?{...Q,text:D.trim()}:Q))}catch(w){console.error("Error updating idea:",w)}z(null)}},ue=async o=>{try{await se.deleteIdea(o),a(D=>D.filter(w=>w.id!==o)),W({title:"Idee ștearsă",description:"Ideea a fost eliminată"})}catch(D){console.error("Error deleting idea:",D)}},be=async o=>{try{await se.archiveIdea(o.id),a(D=>D.filter(w=>w.id!==o.id)),S(!1),W({title:"Idee arhivată",description:"Ideea a fost mutată în arhivă"})}catch(D){console.error("Error archiving idea:",D)}},Tt=o=>{g(o),S(!0)},Re=(o,D)=>{a(w=>w.map(Q=>Q.id===o.id?{...Q,analysis_result:D,status:D.recommendation==="pursue"?"approved":D.recommendation==="defer"?"analyzed":"rejected"}:Q))},Ke=o=>{t==null||t(o),S(!1),a(D=>D.filter(w=>w.id!==o.id)),se.archiveIdea(o.id)},ve=o=>{i==null||i(o),S(!1),a(D=>D.filter(w=>w.id!==o.id)),se.archiveIdea(o.id)},Ne=o=>{if(!o.analysis_result)return null;const D={pursue:{icon:Ee,className:"text-green-500"},defer:{icon:Xt,className:"text-yellow-500"},discard:{icon:Qt,className:"text-red-500"}},w=o.analysis_result.recommendation,{icon:Q,className:re}=D[w];return e.jsxs("div",{className:L("flex items-center gap-1",re),title:`${w.toUpperCase()} - ${o.analysis_result.relevance_score}%`,children:[e.jsx(Q,{className:"w-3 h-3"}),e.jsxs("span",{className:"text-xs",children:[o.analysis_result.relevance_score,"%"]})]})};return e.jsxs("div",{className:s?"max-h-[70vh] overflow-y-auto overflow-x-hidden w-full max-w-full":"",children:[e.jsx("div",{className:`${s?"mb-3":"mb-4"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Se,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground ${s?"w-3 h-3":"h-4 w-4"}`}),e.jsx(_e,{ref:N,value:c,onChange:o=>r(o.target.value),onKeyDown:async o=>{o.key==="Enter"&&!p&&(o.preventDefault(),await C())},placeholder:p?"Se salvează...":`${P("addItem")}...${s?"":" (Enter ↵)"}`,disabled:p,className:`bg-muted/50 border-0 focus-visible:ring-1 focus-visible:ring-primary transition-all ${s?"pl-8 pr-2 text-sm h-9":"pl-10 h-10"} ${p?"opacity-50":""}`})]}),s&&c.trim()&&e.jsx(_,{size:"sm",onClick:C,disabled:p,className:"h-10 px-4 shrink-0 bg-primary text-primary-foreground font-medium",children:p?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:"Adaugă"})]})})]})}),e.jsxs("div",{className:`flex items-center gap-2 flex-wrap ${s?"mb-3":"mb-4"}`,children:[e.jsxs(rt,{children:[e.jsx(nt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",children:[e.jsx(ba,{className:"w-3 h-3"}),e.jsx("span",{className:s?"hidden":"",children:((Ce=oe.find(o=>o.value===A))==null?void 0:Ce.label)||"Filtrează"}),e.jsx("span",{className:s?"":"hidden",children:(Ge=oe.find(o=>o.value===A))==null?void 0:Ge.emoji})]})}),e.jsx(it,{align:"start",className:"w-48",children:oe.map(o=>e.jsxs(we,{onClick:()=>
4f(o.value),className:L("cursor-pointer",A===o.value&&"bg-accent"),children:[e.jsx("span",{className:"mr-2",children:o.emoji}),o.label]},o.value))})]}),e.jsxs(rt,{children:[e.jsx(nt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",children:[e.jsx(va,{className:"w-3 h-3"}),e.jsx("span",{className:s?"hidden":"",children:((Ie=ye.find(o=>o.value===J))==null?void 0:Ie.label)||"Sortează"})]})}),e.jsx(it,{align:"start",children:ye.map(o=>e.jsx(we,{onClick:()=>V(o.value),className:L("cursor-pointer",J===o.value&&"bg-accent"),children:o.label},o.value))})]}),e.jsx("div",{className:"flex-1 min-w-0",children:u?e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground ${s?"w-3 h-3":"h-4 w-4"}`}),e.jsx(_e,{placeholder:P("searchItems"),value:x,onChange:o=>n(o.target.value),onBlur:()=>!x&&I(!1),autoFocus:!0,className:`bg-muted/50 border-0 focus-visible:ring-1 focus-visible:ring-primary text-foreground placeholder:text-muted-foreground ${s?"pl-8 text-sm h-8":"pl-10 h-8"}`}),x&&e.jsx("button",{onClick:()=>{n(""),I(!1)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Be,{className:"w-3 h-3"})})]}):e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>I(!0),className:"h-8 gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Rt,{className:"w-3 h-3"}),e.jsx("span",{children:P("searchItems")})]})}),e.jsxs(_,{variant:$?"secondary":"ghost",size:"sm",onClick:()=>{$?X():F(!0)},className:"h-8 gap-1.5 text-xs",title:"Selectare multiplă",children:[e.jsx(qe,{className:"w-3 h-3"}),!s&&e.jsx("span",{children:"Selectează"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[U.length," ",U.length===1?"idee":"idei"]})]}),$&&e.jsxs("div",{className:`flex items-center gap-2 p-2 mb-3 rounded-lg bg-muted/50 border border-border ${s?"flex-wrap":""}`,children:[e.jsx(Pt,{checked:O.size===U.length&&U.length>0,onCheckedChange:o=>{o?me():E(new Set)}}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[O.size," selectate"]}),e.jsx("div",{className:"flex-1"}),e.jsx(_,{variant:"ghost",size:"sm",onClick:me,className:"h-7 text-xs",disabled:O.size===U.length,children:"Selectează toate"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:le,disabled:O.size===0,className:"h-7 gap-1 text-xs",children:[e.jsx(Oe,{className:"w-3 h-3"}),"Șterge (",O.size,")"]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:X,className:"h-7 text-xs",children:"Anulează"})]}),e.jsx(Ps,{onDragEnd:de,children:e.jsx(Os,{droppableId:"ideas-list",children:(o,D)=>e.jsxs("div",{ref:o.innerRef,...o.droppableProps,className:L("space-y-1",s?"max-h-[calc(70vh-180px)] overflow-y-auto":"",D.isDraggingOver&&"bg-accent/20 rounded-lg"),children:[U.length>0?U.map((w,Q)=>{const re=k===w.id;return e.jsx(Rs,{draggableId:w.id,index:Q,children:(xe,Le)=>e.jsxs("div",{ref:xe.innerRef,...xe.draggableProps,draggable:!0,onDragStart:K=>{K.dataTransfer.setData("application/json",JSON.stringify({type:"idea-bank-item",id:w.id,text:w.text,priority:w.priority,category:w.
4category})),K.dataTransfer.effectAllowed="copyMove"},className:L("group relative flex items-center gap-2 rounded-lg hover:bg-muted/50 transition-all cursor-grab","p-2",Le.isDragging&&"bg-muted shadow-lg ring-2 ring-primary/50"),children:[$&&e.jsx(Pt,{checked:O.has(w.id),onCheckedChange:()=>je(w.id),onClick:K=>K.stopPropagation(),className:"shrink-0"}),!$&&e.jsx("div",{...xe.dragHandleProps,className:L("cursor-grab text-muted-foreground/50 hover:text-muted-foreground touch-none",s?"opacity-50":"opacity-0 group-hover:opacity-100"),children:e.jsx(Yt,{className:"w-4 h-4"})}),e.jsx(ga,{priority:w.priority,onSelect:async K=>{if(K===1){confirm("Această idee nu este importantă și nici urgentă. Vrei să o ștergi?")&&await ue(w.id);return}try{await se.updateIdea(w.id,{priority:K}),a(De=>De.map(he=>he.id===w.id?{...he,priority:K}:he))}catch(De){console.error("Error updating priority:",De)}},trigger:e.jsx(ya,{priority:w.priority,size:"sm",onClick:()=>{}})}),Ne(w),re?e.jsx(_e,{value:h,onChange:K=>b(K.target.value),onKeyDown:K=>{K.key==="Enter"?(K.preventDefault(),ae(w.id,h)):K.key==="Escape"&&z(null)},onBlur:()=>ae(w.id,h),autoFocus:!0,className:`flex-grow bg-transparent border-none focus:ring-1 focus:ring-primary text-foreground ${s?"p-1 text-sm h-7":"p-1 h-7"}`}):e.jsx("span",{className:"flex-grow text-foreground cursor-text hover:text-primary transition-colors text-sm",onClick:()=>{b(w.text),z(w.id)},children:w.text}),e.jsxs("div",{className:L("flex items-center gap-1 transition-opacity",s?"opacity-70":"opacity-0 group-hover:opacity-100"),children:[e.jsx("button",{className:"p-1 text-muted-foreground hover:text-primary transition-colors",title:"Analizează ideea cu AI",onClick:K=>{K.stopPropagation(),Tt(w)},children:e.jsx(Pe,{className:`${s?"w-3 h-3":"w-4 h-4"}`})}),e.jsx("button",{className:"p-1 text-muted-foreground hover:text-primary transition-colors",title:P("setWeeklyFocus"),onClick:K=>{K.stopPropagation(),Ke(w)},children:e.jsx(ce,{className:`${s?"w-3 h-3":"w-4 h-4"}`})}),e.jsx("button",{className:"p-1 text-muted-foreground hover:text-destructive transition-colors",onClick:K=>{K.stopPropagation(),ue(w.id)},children:e.jsx(Be,{className:`${s?"w-3 h-3":"w-4 h-4"}`})})]})]})},w.id)}):e.jsx(Va,{onAddItem:()=>{var w;return(w=N.current)==null?void 0:w.focus()},onAddTemplate:async w=>{const Q=await se.addIdea(w,"work",0);a(re=>[Q,...re]),R(Q),T(!0)}}),o.placeholder]})})}),e.jsx(Ka,{isOpen:q,onClose:()=>{T(!1),R(null)},ideaText:(y==null?void 0:y.text)||"",onSelectQuadrant:H,onSkip:te,onAnalyze:B,isMobile:s}),e.jsx(Ua,{isOpen:v,onClose:()=>S(!1),idea:j,onMoveToHit:Ke,onMoveToDo:ve,onArchive:be,onAnalysisComplete:Re})]})},Ga=({value:t,onChange:i,language:s="ro",autoSubmit:l=!1,onAutoSubmit:a,className:x,...n})=>{const[c,r]=d.useState(t),{isListening:u,transcript:I,toggleListening:p,resetTranscript:m,isSupported:k}=Na({language:s,autoSubmit:l,onAutoSubmit:a,onTranscript:b=>{const j=c?c+" "+b:b;r(j),i({target:{value:j},currentTarget:{value:j}})}});d.useEffect(()=>{r(t)},[t]);const z=b=>{r(b.target.value),i(b)},h=()=>{u||m(),p()};return e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsx(Ls,{...n,value:c,onChange:z,className:L("flex-1",x)}),k&&e.jsx(_,{type:"button",variant:u?"default":"outline",size:"icon",onClick:h,className:L("h-10 w-10 shrink-0",u&&"animate-pulse bg-red-500 hover:bg-red-600"),title:u?"Stop Recording":"Start Voice Input",children:u?e.jsx(wa,{className:"h-4 w-4"}):e.jsx(Sa,{className:"h-4 w-4"})})]})};async function ze(){var s;const{data:t,error:i}=await Y.auth.getUser();return i?(console.error("Error getting user:",i),null):((s=t.user)==null?void 0:s.id)??null}const st={async getHistoryForWeek(t){const i=await ze();if(!i)return[];try{const{data:s,error:l}=await Y.from("weekly_planning_history").select("*").eq("user_id",i).eq("week_key",t).order("version_number",{ascending:!1});return l||!s?(console.error("Error fetching history:",l),[]):s.map(a=>({id:a.id,weekKey:a.week_key,dominoTitle:a.domino_title||"",weekGoal:a.week_goal||"",keyPoints:a.key_points||[],reviewData:a.review_data,versionNumber:a.version_number,createdAt:a.created_at,
4snapshotReason:a.snapshot_reason||"auto_save"}))}catch(s){return console.error("Error in getHistoryForWeek:",s),[]}},async getAllHistory(){const t=await ze();if(!t)return[];try{const{data:i,error:s}=await Y.from("weekly_planning_history").select("*").eq("user_id",t).order("created_at",{ascending:!1}).limit(50);return s||!i?(console.error("Error fetching all history:",s),[]):i.map(l=>({id:l.id,weekKey:l.week_key,dominoTitle:l.domino_title||"",weekGoal:l.week_goal||"",keyPoints:l.key_points||[],reviewData:l.review_data,versionNumber:l.version_number,createdAt:l.created_at,snapshotReason:l.snapshot_reason||"auto_save"}))}catch(i){return console.error("Error in getAllHistory:",i),[]}},async createSnapshot(t,i,s,l,a="manual_backup"){var n;const x=await ze();if(!x)return!1;try{const{data:c}=await Y.from("weekly_planning_history").select("version_number").eq("user_id",x).eq("week_key",t).order("version_number",{ascending:!1}).limit(1),r=(((n=c==null?void 0:c[0])==null?void 0:n.version_number)||0)+1,{error:u}=await Y.from("weekly_planning_history").insert({user_id:x,week_key:t,domino_title:i,week_goal:s,key_points:l,version_number:r,snapshot_reason:a});return u?(console.error("Error creating snapshot:",u),!1):(console.log("✅ Snapshot created successfully, version:",r),!0)}catch(c){return console.error("Error in createSnapshot:",c),!1}},async deleteVersion(t){const i=await ze();if(!i)return!1;try{const{error:s}=await Y.from("weekly_planning_history").delete().eq("id",t).eq("user_id",i);return s?(console.error("Error deleting history version:",s),!1):!0}catch(s){return console.error("Error in deleteVersion:",s),!1}},async cleanupOldHistory(t=10){const i=await ze();if(i)try{const{data:s}=await Y.from("weekly_planning_history").select("week_key").eq("user_id",i);if(!s)return;const l=[...new Set(s.map(a=>a.week_key))];for(const a of l){const{data:x}=await Y.from("weekly_planning_history").select("id, version_number").eq("user_id",i).eq("week_key",a).order("version_number",{ascending:!1});if(!x||x.length<=t)continue;const n=x.slice(t);for(const c of n)await Y.from("weekly_planning_history").delete().eq("id",c.id)}console.log("✅ History cleanup completed")}catch(s){console.error("Error in cleanupOldHistory:",s)}}},Ja=({isOpen:t,onClose:i,weekKey:s,currentDomino:l,currentKeyPoints:a,onRestore:x})=>{const{toast:n}=fe(),[c,r]=d.useState([]),[u,I]=d.useState(!1),[p,m]=d.useState(null),[k,z]=d.useState(!1),[h,b]=d.useState(null),[j,g]=d.useState(!1);d.useEffect(()=>{t&&s&&v()},[t,s]);const v=async()=>{I(!0);const f=await st.getHistoryForWeek(s);r(f),I(!1)},S=async()=>{if(!l){n({title:"⚠️ Nu ai Domino selectat",description:"Selectează un Domino înainte de a crea un backup.",variant:"destructive"});return}g(!0);const f=a.map((E,$)=>{var F,J,V,N,P,W,ee;return{id:$+1,title:E.text,objective:((F=E.metadata)==null?void 0:F.objective)||"",why:((J=E.metadata)==null?void 0:J.why)||"",positiveImpact:((V=E.metadata)==null?void 0:V.positiveImpact)||"",negativeImpact:((N=E.metadata)==null?void 0:N.negativeImpact)||"",steps:((P=E.metadata)==null?void 0:P.steps)||[],responsible:((W=E.metadata)==null?void 0:W.responsible)||"",deadline:((ee=E.metadata)==null?void 0:ee.deadline)||""}}),O=await st.createSnapshot(s,l.text,"",f,"manual_backup");g(!1),O?(n({title:"✅ Backup creat!",description:"Versiunea curentă a fost salvată în istoric."}),v()):n({title:"❌ Eroare",description:"Nu s-a putut crea backup-ul.",variant:"destructive"})},y=f=>{const O={id:`domino-restored-${Date.now()}`,text:f.dominoTitle,selected:!0,priority:"urgent-important"},E=f.keyPoints.map($=>({id:`key${$.id}`,text:$.title,completed:!1,metadata:{objective:$.objective,why:$.why,positiveImpact:$.positiveImpact,negativeImpact:$.negativeImpact,steps:$.steps,responsible:$.responsible,deadline:$.deadline}}));x(O,E),i(),n({title:"🔄 Versiune restaurată!",description:`Domino "${f.dominoTitle}" a fost restaurat din versiunea ${f.versionNumber}.`})},R=f=>{b(f),z(!0)},q=async()=>{if(!h)return;await st.deleteVersion(h.id)?(n({title:"✅ Versiune ștearsă",description:`Versiunea ${h.versionNumber} a fost ștearsă.`}),v()):n({title:"❌ Eroare",description:"Nu s-a putut șterge versiunea.",variant:"destructive"}),z(!1),b(null)},T=f=>{try{return ot(ka(f),"d MMM yyyy, HH:mm",{locale:wt})}catch{return f}},A=f=>{switch(f){case"auto_save":return"Auto-save";case"manual_backup":return"Backup manual";default:return f}};return e.jsxs(e.Fragment,{children:[e.jsx(us,{open:t,onOpenChange:i,children:e.jsxs(xs,{className:"max-h-[85vh]",children:[e.jsxs(hs,{children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"w-5 h-5"}),"Istoric Versiuni Domino Door"]}),e.jsx(gs,{children:"Restaurează versiuni anterioare ale Domino-ului și cheilor tale"})]}),e.jsx("div",{className:"px-6 pb-4",children:e.jsx(_,{onClick:S,disabled:j||!l,className:"w-full gap-2",variant:"outline",children:j?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),"Se salvează..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"w-4 h-4"}),"Salvează versiunea curentă ca backup"]})})}),e.jsx(ht,{className:"px-6 pb-6 flex-1",children:u?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-6 h-6 animate-spin text-primary"})}):c.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ve,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Nu există versiuni anterioare pentru această săptămână"}),e.jsx("p",{className:"text-sm mt-2",children:"Istoricul se salvează automat când modifici Domino-ul"})]}):e.jsx("div",{className:"space-y-4",children:c.map(f=>{const O=p===f.id;return e.jsxs("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Zt,{className:"w-3 h-3"}),e.jsx("span",{children:T(f.createdAt)}),e.jsxs($e,{variant:"secondary",className:"text-xs",children:["v",f.versionNumber]}),e.jsx($e,{variant:"outline",className:"text-xs",children:A(f.snapshotReason)})]}),e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-primary"}),f.dominoTitle||"(Fără titlu)"]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>m(O?null:f.id),title:"Vezi detalii",children:e.jsx(es,{className:"w-4 h-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>y(f),title:"Restaurează",className:"gap-1",children:[e.jsx(fs,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Restaurează"})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>R(f),title:"Șterge",className:"text-destructive hover:text-destructive",children:e.jsx(Oe,{className:"w-4 h-4"})})]})]}),O&&f.keyPoints.length>0&&e.jsxs("div",{className:"border-t pt-3 mt-3 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Cele 4 Chei:"}),f.keyPoints.map((E,$)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm pl-4",children:[e.jsx(Ee,{className:"w-4 h-4 mt-0.5 text-green-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:E.title}),E.objective&&e.jsxs("p",{className:"text-muted-foreground text-xs mt-0.5",children:["Obiectiv: ",E.objective]})]})]},$))]})]},f.id)})})})]})}),e.jsx(pt,{open:k,onOpenChange:z,children:e.jsxs(gt,{children:[e.jsxs(ft,{children:[e.jsx(jt,{children:"Șterge versiunea?"}),e.jsxs(yt,{children:["Vrei să ștergi versiunea ",h==null?void 0:h.versionNumber,"?",e.jsx("br",{}),e.jsx("strong",{children:h==null?void 0:h.dominoTitle}),e.jsx("br",{}),e.jsx("br",{}),"Această acțiune nu poate fi anulată."]})]}),e.jsxs(bt,{children:[e.jsx(vt,{children:"Anulează"}),e.jsx(Nt,{onClick:q,className:"bg-destructive hover:bg-destructive/90",children:"Șterge"})]})]})})]})},Xa=()=>{const{language:t}=ne();return e.jsxs("div",{className:"mb-4 sm:mb-6 bg-gradient-to-br from-[#1E293B] to-[#2A3A53] rounded-xl shadow-lg p-3 sm:p-6 border border-blue-500/20 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx(ke,{className:"w-6 h-6 mr-3 text-blue-400"}),e.jsx("h2",{className:"text-xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-purple-600",children:t==="en"?"To Do - The Pillar of Focus and Production":"Taskuri - Stâlpul Concentrării și Producției"})]}),e.jsxs("div",{className:"text-gray-300 mb-6 leading-relaxed",children:[e.jsx("p",{className:"mb-4",children:t==="en"?'To Do represents the game of daily production. While Stack handles perspective and Core Four provides power, To Do focuses on daily productivity, answering the question: "What do I do today?"':'Taskuri reprezintă jocul producției zilnice. În timp ce Stack se ocupă de perspectivă și Core Four oferă putere, Taskuri se concentrează pe productivitatea zilnică, răspunzând la întrebarea: "Ce fac azi?"'}),e.jsx("p",{children:t==="en"?`The system works on the premise that "doing more" doesn't necessarily mean "achieving more". The goal is not to just do more things, but to do what matters to get clear results.`:'Sistemul funcționează pe premisa că "a face mai mult" nu înseamnă neapărat "a obține mai mult". Scopul nu este doar să faci mai multe lucruri, ci să faci ceea ce contează pentru a obține rezultate clare.'})]}),e.jsx(Da,{type:"single",collapsible:!0,className:"border-t border-blue-500/20 pt-2",children:e.jsxs(Ta,{value:"components",className:"border-b-0",children:[e.jsx(za,{className:"text-blue-400 hover:text-blue-300 py-2",children:t==="en"?"The Four Components of To Do":"Cele Patru Componente ale Aplicației Taskuri"}),e.jsx(Aa,{className:"text-gray-300",children:e.jsxs("div",{className:"space-y-4 mt
4-2",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-orange-400 to-red-500 flex items-center justify-center mr-3",children:e.jsx(ts,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-orange-400",children:t==="en"?"Potential":"Potențial"}),e.jsx("p",{className:"text-sm mt-1",children:t==="en"?"The Hot List with all your ideas and action options.":"Lista de idei cu toate ideile și opțiunile tale de acțiune."})]})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-blue-400 to-purple-600 flex items-center justify-center mr-3",children:e.jsx(ke,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-blue-400",children:t==="en"?"Planning":"Planificare"}),e.jsx("p",{className:"text-sm mt-1",children:t==="en"?"Selecting one priority item as your Domino Door - the action that will have the greatest impact.":"Selectarea unui element prioritar ca Ușa Domino - acțiunea care va avea cel mai mare impact."})]})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-purple-400 to-pink-600 flex items-center justify-center mr-3",children:e.jsx(ss,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-purple-400",children:t==="en"?"Production":"Producție"}),e.jsx("p",{className:"text-sm mt-1",children:t==="en"?"Your Hit List and Do List - the essential actions for your daily focus.":"Lista de Lovituri și Lista de Sarcini - acțiunile esențiale pentru focusul tău zilnic."})]})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-green-400 to-emerald-600 flex items-center justify-center mr-3",children:e.jsx(Ms,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-green-400",children:"Profit"}),e.jsx("p",{className:"text-sm mt-1",children:t==="en"?"The results obtained from production - tracking your completed tasks and achievements.":"Rezultatele obținute din producție - urmărirea sarcinilor și realizărilor completate."})]})]})]})})]})}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsxs("div",{className:"inline-flex items-center text-sm text-blue-400 hover:text-blue-300 transition-colors cursor-pointer group",children:[e.jsx("span",{children:t==="en"?"Start creating your To Do lists":"Începe să-ți creezi listele de Taskuri"}),e.jsx(St,{className:"w-4 h-4 ml-1 transform group-hover:translate-x-1 transition-transform"})]})})]})},Qa=({keyPoint:t,children:i})=>{var l,a,x,n,c,r,u;return t.metadata&&(t.metadata.objective||t.metadata.why||t.metadata.positiveImpact||t.metadata.negativeImpact||t.metadata.steps||t.metadata.responsible||t.metadata.deadline)?e.jsxs(as,{children:[e.jsx(rs,{asChild:!0,children:e.jsxs("div",{className:"relative group cursor-pointer",children:[i,e.jsx(_,{variant:"ghost",size:"icon",className:"absolute -top-1 -right-1 w-5 h-5 opacity-0 group-hover:opacity-100 transition-opacity bg-blue-500/20 hover:bg-blue-500/30 rounded-full",children:e.jsx(js,{className:"w-3 h-3 text-blue-400"})})]})}),e.jsxs(ns,{className:"w-96 p-4 space-y-3",side:"right",children:[e.jsx("div",{className:"font-semibold text-base border-b pb-2 mb-2",children:"📌 Detalii Cheie"}),((l=t.metadata)==null?void 0:l.objective)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4"}),e.jsx("span",{children:"Obiectiv"})]}),e.jsx("p",{className:"text-sm pl-6",children:t.metadata.objective})]}),((a=t.metadata)==null?void 0:a.why)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(cs,{className:"w-4 h-4"}),e.jsx("span",{children:"De ce?"})]}),e.jsx("p",{className:"text-sm pl-6",children:t.metadata.why})]}),((x=t.metadata)==null?void 0:x.positiveImpact)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-green-600",children:[e.jsx(ct,{className:"w-4 h-4"}),e.jsx("span",{children:"Impact Pozitiv"})]}),e.jsx("p",{className:"text-sm pl-6 text-green-700 dark:text-green-400",children:t.metadata.positiveImpact})]}),((n=t.metadata)==null?void 0:n.negativeImpact)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-red-600",children:[e.jsx(_a,{className:"w-4 h-4"}),e.jsx("span",{children:"Impact Negativ (dacă nu se face)"})]}),e.jsx("p",{className:"text-sm pl-6 text-red-700 dark:text-red-400",children:t.metadata.negativeImpact})]}),((c=t.metadata)==null?void 0:c.steps)&&t.metadata.steps.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(ds,{className:"w-4 h-4"}),e.jsx("span",{children:"Pași"})]}),e.jsx("ul",{className:"text-sm pl-6 space-y-1 list-disc",children:t.metadata.steps.map((I,p)=>
4{if(typeof I=="string")return e.jsx("li",{children:I},p);const m=I;return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{children:m.text}),m.day&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[m.day==="M"?"Luni":m.day==="T"?"Marți":m.day==="W"?"Miercuri":m.day==="Th"?"Joi":m.day==="F"?"Vineri":m.day,m.listType&&` • ${m.listType==="hit"?"HIT":"DO"}`]})]},p)})})]}),((r=t.metadata)==null?void 0:r.responsible)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Hs,{className:"w-4 h-4"}),e.jsx("span",{children:"Responsabil"})]}),e.jsx("p",{className:"text-sm pl-6 font-medium",children:t.metadata.responsible})]}),((u=t.metadata)==null?void 0:u.deadline)&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Ue,{className:"w-4 h-4"}),e.jsx("span",{children:"Deadline"})]}),e.jsx("p",{className:"text-sm pl-6 font-medium text-orange-600 dark:text-orange-400",children:t.metadata.deadline})]})]})]}):e.jsx(e.Fragment,{children:i})},Ya=t=>{const[i,s]=d.useState({monthly:null,quarterly:null,annual:null}),[l,a]=d.useState(!1);return d.useEffect(()=>{if(!t){s({monthly:null,quarterly:null,annual:null});return}(async()=>{var n;a(!0);try{const{data:c}=await Y.auth.getSession();if(!((n=c==null?void 0:c.session)!=null&&n.user)){a(!1);return}const r=c.session.user.id,[u,I]=t.split("-W"),p=parseInt(u,10),m=parseInt(I,10),k=Math.ceil(m/4.33),z=`${p}-${String(Math.min(k,12)).padStart(2,"0")}`,{data:h}=await Y.from("missions").select("*").eq("user_id",r).eq("mission_type","monthly").eq("period",z).limit(1),b=(h==null?void 0:h[0])||null;let j=null,g=null;if(b!=null&&b.parent_mission_id){const{data:v}=await Y.from("missions").select("*").eq("id",b.parent_mission_id).single();if(j=v||null,j!=null&&j.parent_mission_id){const{data:S}=await Y.from("missions").select("*").eq("id",j.parent_mission_id).single();g=S||null}}s({monthly:b,quarterly:j,annual:g})}catch(c){console.error("Error fetching weekly hierarchy:",c)}finally{a(!1)}})()},[t]),{hierarchy:i,loading:l}},Za=({status:t,lastSaveTime:i,className:s})=>{const a=(()=>{switch(t){case"saving":return{icon:e.jsx(ge,{className:"w-3 h-3 animate-spin"}),text:"Salvare...",color:"text-yellow-500"};case"saved":return{icon:e.jsx(pe,{className:"w-3 h-3"}),text:i?`Salvat ${i.toLocaleTimeString("ro-RO",{hour:"2-digit",minute:"2-digit"})}`:"Salvat",color:"text-green-500"};case"error":return{icon:e.jsx(Dt,{className:"w-3 h-3"}),text:"Eroare salvare",color:"text-red-500"};case"offline":return{icon:e.jsx($a,{className:"w-3 h-3"}),text:"Salvat local",color:"text-amber-500"};case"idle":default:return{icon:e.jsx(Ea,{className:"w-3 h-3"}),text:"Sincronizat",color:"text-muted-foreground"}}})();return e.jsxs("div",{className:L("flex items-center gap-1.5 text-xs transition-colors",a.color,s),children:[a.icon,e.jsx("span",{children:a.text})]})},Bt=({selectedDomino:t,dominoKeyPoints:i,updateKeyPointText:s,handleDragOverDomino:l,handleDropOnDomino:a,handleKeyPointDragStart:x,isMobile:n=!1,isCompleted:c=!1,moveKeyPointToHotList:r,addNewKeyPoint:u,handleDropOnKeyPoint:I,setSelectedDomino:p,setDominoKeyPoints:m,weekKey:k,saveStatus:z="idle",lastSaveTime:h})=>{const{t:b,language:j}=ne(),{toast:g}=fe(),[v,S]=d.useState(!1),[y,R]=d.useState(!1),[q,T]=d.useState(!1),[A,f]=d.useState(!1),[O,E]=d.useState(!1),[$,F]=d.useState(!1),[J,V]=d.useState(!1),[N,P]=d.useState(!1),W=$t.useMemo(()=>Ws(),[]),ee=`doorPlanningDraft_${W}`,Z=`doorPlanningDismissed_${W}`;d.useEffect(()=>{if(v||localStorage.getItem(Z)==="1")return;const C=localStorage.getItem(ee);if(C)try{const H=JSON.parse(C);Array.isArray(H==null?void 0:H.messages)&&H.messages.length>0&&S(!0)}catch{}},[v,ee,Z]);const{hierarchy:U}=Ya(k||null),de=$t.useMemo(()=>{var H,te,B;const C=[];return(H=U.annual)!=null&&H.title&&C.push({type:"annual",title:U.annual.title}),(te=U.quarterly)!=null&&te.title&&C.push({type:"quarterly",title:U.quarterly.title}),(B=U.monthly)!=null&&B.title&&C.push({type:"monthly",title:U.monthly.title}),C},[U]),je=C=>{!p||!m||(p({id:`domino-${Date.now()}`,text:C.dominoTitle,selected:!0,priority:"urgent-important"}),m(C.keyPoints.map(H=>({id:`key${H.id}`,text:H.title,completed:!1,metadata:{objective:H.objective,why:H.why,positiveImpact:H.positiveImpact,negativeImpact:H.negativeImpact,steps:H.steps,responsible:H.responsible,deadline:H.deadline}}))),S(!1),g({title:"✅ Planificare completată!",description:"Domino Door și cele 4 chei au fost setate pentru săptămâna aceasta."}))},X=[...i.slice(0,4)];for(;X.length<4;)X.push({id:`placeholder-${X.length}`,text:""});const le=i.filter(C=>C.completed&&C.text.trim()).length,oe=i.filter(C=>C.text.trim()).length,ye=async C=>{var te;C.preventDefault(),f(!1),F(!0);const H=C.dataTransfer.getData("application/json");if(H&&p&&m)try{const B=JSON.parse(H);if(B.type==="idea-bank-item"){await new Promise(ae=>setTimeout(ae,200)),p({id:`idea-${B.id}`,text:B.text,selected:!0,priority:"urgent-important"}),m([{id:"key1",text:"",completed:!1},{id:"key2",text:"",completed:!1},{id:"key3",text:"",completed:!1},{id:"key4",text:"",completed:!1}]),E(!0);try{const{ideasBankService:ae}=await qs(async()=>{const{ideasBankService:ue}=await import("./ideasBankService-CBqncqnk.js");return{ideasBankService:ue}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await ae.updateIdea(B.id,{status:"archived"})}catch(ae){console.warn("[DominoDoor] Could not archive idea:",ae)}F(!1),V(!0),setTimeout(()=>
4V(!1),1e3),g({title:"🎯 Domino setat din Idei!",description:`"${B.text}" este acum focusul tău săptămânal. Generează key points cu AI!`}),console.debug("[DominoDoor] Idea bank item dropped as Domino",{id:B.id,text:B.text});return}if(B.type==="monthly-mission"){if(await new Promise(ae=>setTimeout(ae,200)),p({id:`monthly-${B.id}`,text:B.text,selected:!0,priority:"urgent-important"}),B.keyActions&&B.keyActions.length>0){const ae=B.keyActions.slice(0,4).map((ue,be)=>({id:`key${be+1}`,text:ue,completed:!1}));m(ae)}else m([{id:"key1",text:"",completed:!1},{id:"key2",text:"",completed:!1},{id:"key3",text:"",completed:!1},{id:"key4",text:"",completed:!1}]),E(!0);F(!1),V(!0),setTimeout(()=>V(!1),1e3),g({title:"🎯 Domino setat!",description:((te=B.keyActions)==null?void 0:te.length)>0?`"${B.text}" este acum focusul tău săptămânal.`:`"${B.text}" setat. Generează key points cu AI!`}),console.debug("[DominoDoor] Monthly mission dropped directly",{id:B.id,text:B.text});return}}catch{console.debug("[DominoDoor] Drop data parse failed, falling back to handler")}F(!1),a(C),V(!0),setTimeout(()=>V(!1),1e3)};return e.jsxs("div",{className:L("relative bg-card rounded-xl border transition-all duration-200",A?"border-primary ring-2 ring-primary/30 ring-offset-2 ring-offset-background":"border-border",n?"p-4":"h-full p-5"),onDragOver:C=>{C.preventDefault(),l(C),f(!0)},onDragLeave:C=>{C.currentTarget.contains(C.relatedTarget)||f(!1)},onDrop:ye,children:[$&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2 text-primary animate-fade-in",children:[e.jsx(ge,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{className:"text-sm font-medium",children:"Se procesează..."})]})}),J&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-green-500/10 rounded-xl pointer-events-none",children:e.jsx("div",{className:"flex items-center gap-2 text-green-600 animate-success-pop",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-green-500 flex items-center justify-center",children:e.jsx(pe,{className:"w-5 h-5 text-white"})})})}),A&&!$&&!J&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-xl bg-primary/10 border-2 border-dashed border-primary animate-drop-zone-pulse pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center animate-bounce",children:e.jsx(ms,{className:"w-5 h-5 text-primary"})}),e.jsx("span",{className:"text-sm font-medium text-primary",children:b("setWeeklyFocus")||"Set as weekly focus"})]})}),t?e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("h2",{className:"text-base font-medium text-foreground flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-primary"}),"Focus"]}),oe>0&&e.jsxs($e,{variant:le===oe?"default":"secondary",className:`${le===oe?"bg-green-500/20 text-green-600 border-green-500/30":"bg-muted text-muted-foreground"} text-xs`,children:[le,"/",oe]})]}),e.jsx(Za,{status:z,lastSaveTime:h,className:"mr-2"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{onClick:()=>T(!0),variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground p-1.5",title:"Istoric versiuni",children:e.jsx(Ve,{className:"w-4 h-4"})}),e.jsxs(_,{onClick:()=>{localStorage.removeItem(Z),S(!0)},variant:"ghost",size:"sm",className:"gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[e.jsx(Ze,{className:"w-4 h-4"}),!n&&e.jsx("span",{className:"text-xs",children:"AI Planning"})]}),e.jsx(_,{onClick:()=>R(!0),variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground p-1.5",children:e.jsx(js,{className:"w-4 h-4"})})]})]}),de.length>0&&e.jsx("div",{className:"animate-fade-in",children:e.jsx(da,{chain:de})}),e.jsxs("div",{className:`relative group ${c?"bg-green-500/10 border-l-4 border-green-500":"bg-primary/5 border-l-4 border-primary"} p-4 rounded-lg`,children:[e.jsx("p",{className:"text-foreground font-medium pr-8",children:t.text}),c&&e.jsxs("div",{className:"flex items-center text-green-600 mt-2 text-sm gap-1",children:[e.jsx(pe,{className:"w-4 h-4"}),e.jsx("span",{children:b("completed")})]}),p&&!c&&e.jsx("button",{onClick:()=>P(!0),className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 p-1.5 rounded-full hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-all",title:j==="en"?"Remove weekly focus":"Șterge focusul săptămânal",children:e.jsx(Be,{className:"w-4 h-4"})}),!c&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border/40 flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["🪞 Iei această decizie din ",e.jsx("span",{className:"font-medium",children:"smerenie"})," sau din ",e.jsx("span",{className:"font-medium",children:"aroganță"}),"?"]}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{sessionStorage.setItem("beliefs-arrogance-prefill",JSON.stringify({decision:t.text})),window.open("/credinte/anti-aroganta","_blank")},children:"Verifică în 60s →"})]})]}),(O||i.every(C=>!C.text.trim()))&&e.jsx("div",{className:"bg-gradient-to-r from-primary/10 to-purple-500/10 border border-primary/20 rounded-lg p-4 animate-fade-in",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-foreground",children:"Generează cele 4 chei cu AI pentru obiectivul tău"})]}),e.jsxs(_,{onClick:()=>{E(!1),localStorage.removeItem(Z),S(!0)},size:"sm",className:"gap-2 bg-primary hover:bg-primary/90",children:[e.jsx(Ze,{className:"w-4 h-4"}),"Generează Key Points"]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:b("keyPoints")}),e.jsx("div",{className:"space-y-2",children:X.map((C,H)=>e.jsx(Qa,{keyPoint:C,children:e.jsxs("div",{className:`group flex items-center gap-3 rounded-lg p-3 transition-all cursor-pointer border ${C.completed?"bg-green-500/10 border-green-500/30":C.isContinued?"bg-amber-500/10 border-amber-500/30":"bg-muted/30 border-transparent hover:border-border"}`,draggable:C.text&&C.text.trim().length>0,onDragStart:te=>x(te,C),onDragOver:te=>te.preventDefault(),onDrop:()=>I&&I(C.id),children:[e.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${C.completed?"bg-green-500 text-white":"bg-muted text-muted-foreground"}`,children:C.completed?e.jsx(pe,{className:"w-3 h-3"}):e.jsx("span",{className:"text-xs font-medium",children:H+1})}),e.jsxs("div",{className:"flex-grow flex flex-col gap-1 min-w-0",children:[C.isContinued&&e.jsxs($e,{variant:"secondary",className:"self-start text-xs bg-amber-500/20 text-amber-600 border-amber-500/30 mb-1",children:[e.jsx(Bs,{className:"w-3 h-3 mr-1"}),"Continuat"]}),e.jsx(Ga,{className:`flex-grow bg-transparent border-none focus:ring-0 focus:ring-offset-0 p-0 min-h-0 resize-none ${C.completed?"text-muted-foreground line-through":"text-foreground"} text-sm`,placeholder:`${b("keyPoint")} ${H+1}`,value:C.text,onChange:te=>s(C.id,te.target.value),rows:1,language:"ro"})]}),C.text&&C.text.trim().length>0&&r&&e.jsx("button",{onClick:()=>r(C),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary transition-all p-1",title:b("moveBackToIdeaList"),children:e.jsx(Se,{className:"w-4 h-4 rotate-45"})})]})},C.id))})]})]}):e.jsxs("div",{className:`flex flex-col items-center justify-center ${n?"py-8":"py-12"} px-4`,children:[e.jsx("div",{className:`${n?"w-12 h-12":"w-14 h-14"} rounded-xl bg-primary/10 flex items-center justify-center mb-3`,children:e.jsx(ke,{className:`${n?"w-6 h-6":"w-7 h-7"} text-primary`})}),e.jsx("p",{className:`text-foreground font-medium ${n?"text-base":"text-lg"} mb-1`,children:b("noGoalSelected")}),e.jsx("p",{className:"text-muted-foreground text-sm text-center max-w-xs mb-4",children:b("dragGoalToSet")}),p&&m&&e.jsxs(_,{onClick:()=>{localStorage.removeItem(Z),S(!0)},size:n?"sm":"default",className:"gap-2",children:[e.jsx(Ze,{className:"w-4 h-4"}),"AI Planning"]})]}),v&&p&&m&&e.jsx(Ia,{isOpen:v,onClose:()=>{localStorage.setItem(Z,"1"),S(!1)},onPlanningComplete:je}),e.jsx(dt,{open:y,onOpenChange:R,children:e.jsxs(mt,{className:"max-w-2xl",children:[e.jsx(ut,{children:e.jsx(xt,{children:"Ce este Domino Door?"})}),e.jsx(Xa,{})]})}),e.jsx(pt,{open:N,onOpenChange:P,children:e.jsxs(gt,{children:[e.jsxs(ft,{children:[e.jsx(jt,{children:j==="en"?"Remove weekly focus?":"Ștergi focusul săptămânal?"}),e.jsx(yt,{children:j==="en"?"Are you sure? You will lose the weekly focus and the 4 key points set for this week.":"Ești sigur? Vei pierde focusul săptămânal și cele 4 chei setate pentru această săptămână."})]}),e.jsxs(bt,{children:[e.jsx(vt,{children:j==="en"?"Cancel":"Anulează"}),e.jsx(Nt,{onClick:async()=>
4{if(p&&m&&k){p(null),m([{id:"1",text:"",completed:!1},{id:"2",text:"",completed:!1},{id:"3",text:"",completed:!1},{id:"4",text:"",completed:!1}]);try{await kt.savePlan({weekKey:k,dominoTitle:"",weekGoal:"",keyPoints:[{id:1,title:"",objective:"",why:"",positiveImpact:"",negativeImpact:"",steps:[],responsible:"Eu",deadline:""},{id:2,title:"",objective:"",why:"",positiveImpact:"",negativeImpact:"",steps:[],responsible:"Eu",deadline:""},{id:3,title:"",objective:"",why:"",positiveImpact:"",negativeImpact:"",steps:[],responsible:"Eu",deadline:""},{id:4,title:"",objective:"",why:"",positiveImpact:"",negativeImpact:"",steps:[],responsible:"Eu",deadline:""}]}),console.log("✅ Weekly focus cleared from database")}catch(C){console.error("❌ Failed to clear weekly focus from database:",C)}g({title:j==="en"?"Focus removed":"Focus șters",description:j==="en"?"Weekly focus has been cleared":"Focusul săptămânal a fost șters"})}P(!1)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:j==="en"?"Yes, remove":"Da, șterge"})]})]})}),e.jsx(Ja,{isOpen:q,onClose:()=>T(!1),weekKey:k||"",currentDomino:t,currentKeyPoints:i,onRestore:(C,H)=>{p&&m&&(p(C),m(H))}})]})},er=({activeDay:t,selectDayOfWeek:i,isMobile:s=!1})=>{const{language:l,t:a}=ne(),x=["M","T","W","Th","F","Sa","Su"];a("mondayShort"),a("tuesdayShort"),a("wednesdayShort"),a("thursdayShort"),a("fridayShort"),a("saturdayShort"),a("sundayShort");const c=(()=>{const r=new Date().getDay();return{0:"Su",1:"M",2:"T",3:"W",4:"Th",5:"F",6:"Sa"}[r]||"M"})();return e.jsx("div",{className:`flex justify-center ${s?"mb-3":"mb-4"}`,children:e.jsx("div",{className:"flex space-x-1 bg-muted rounded-md p-1",children:x.map(r=>e.jsx("button",{className:`${s?"px-2 py-1 text-xs":"px-3 py-1 text-sm"} rounded transition-colors ${t===r?"bg-card text-foreground shadow-sm":r===c?"text-primary hover:bg-accent":"text-muted-foreground hover:bg-accent"}`,onClick:()=>i(r),children:r},r))})})},qt=({id:t,text:i,completed:s,priority:l,isKeyPoint:a,onToggleCompletion:x,onMoveBack:n,isMobile:c=!1})=>{const{t:r}=ne(),u=(p,m=!1)=>{if(m)return"bg-green-500/10";switch(p){case"important":return"bg-green-500/10";case"urgent":return"bg-orange-500/10";case"urgent-important":return"bg-red-500/10";default:return"bg-muted"}},I=p=>{const m=c?"w-3 h-3":"w-4 h-4";switch(p){case"important":return e.jsx(is,{className:`${m} text-green-500 mr-2`});case"urgent":return e.jsx(Ct,{className:`${m} text-orange-500 mr-2`});case"urgent-important":return e.jsx(Dt,{className:`${m} text-red-500 mr-2`});default:return null}};return e.jsxs("div",{className:`flex items-center rounded-md ${u(l,s)} p-2`,children:[e.jsx(_,{variant:"ghost",size:"sm",className:`${c?"w-5 h-5 p-0":"w-6 h-6 p-0"} rounded-full mr-3 flex items-center justify-center ${s?"bg-green-500 text-white":"bg-transparent border border-border text-muted-foreground"}`,onClick:()=>x(t),children:s&&e.jsx(pe,{className:`${c?"w-2.5 h-2.5":"w-3 h-3"}`})}),e.jsxs("span",{className:`flex-grow ${s?"text-muted-foreground line-through":"text-foreground"} ${c?"text-sm":""} flex items-center`,children:[!s&&I(l),i]}),a&&e.jsxs("span",{className:`bg-primary/20 text-primary px-2 py-0.5 rounded mr-2 flex items-center ${c?"text-xs px-1.5 py-0.5":"text-xs"}`,children:[e.jsx(ke,{className:`${c?"w-2 h-2":"w-3 h-3"} mr-1`}),r("keyPointLabel")]}),!s&&e.jsx(Pa,{taskId:t,taskTitle:i,size:"sm",className:"mr-1"}),n&&e.jsx(_,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-primary transition-colors p-1",onClick:()=>n(t),title:r("moveBackToIdeaList"),children:e.jsx(Vs,{className:`${c?"w-3 h-3":"w-4 h-4"}`})})]})},Vt=({id:t,text:i,completed:s,priority:l,isKeyPoint:a,onToggleCompletion:x,onDelete:n,onMoveBack:c,isMobile:r=!1})=>{const[u,I]=d.useState(0),[p,m]=d.useState(!1),[k,z]=d.useState(!0),h=d.useRef(0),b=d.useRef(0),j=60,g=100,v=f=>{r&&(h.current=f.touches[0].clientX,b.current=Date.now(),m(!0),z(!1))},S=f=>{if(!p||!r)return;const E=f.touches[0].clientX-h.current,$=.5;let F=E;if(Math.abs(E)>j){const J=Math.abs(E)-j;F=Math.sign(E)*(j+J*$)}F=Math.max(-g,Math.min(g,F)),I(F),Math.abs(F)>
4=j&&Math.abs(E-F)<5&&Ae.light()},y=()=>{if(!r)return;m(!1);const f=Date.now()-b.current,E=Math.abs(u)/f>.5&&Math.abs(u)>30;u>j||E&&u>0?(Ae.success(),x(t)):(u<-j||E&&u<0)&&n&&(Ae.warning(),n(t)),I(0)},R=(f,O=!1)=>{if(O)return"border-l-4 border-l-green-500 bg-green-500/5";switch(f){case"important":return"border-l-4 border-l-green-500";case"urgent":return"border-l-4 border-l-orange-500";case"urgent-important":return"border-l-4 border-l-red-500";default:return"border-l-4 border-l-transparent"}},q=f=>{switch(f){case"important":return e.jsx(is,{className:"w-3 h-3 text-green-500"});case"urgent":return e.jsx(Ct,{className:"w-3 h-3 text-orange-500"});case"urgent-important":return e.jsx(Dt,{className:"w-3 h-3 text-red-500"});default:return null}},T=Math.min(1,Math.max(0,u/j)),A=Math.min(1,Math.max(0,-u/j));return e.jsxs("div",{className:"relative overflow-hidden rounded-lg mb-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:L("absolute inset-y-0 left-0 flex items-center pl-4 transition-all duration-150",T>=1?"bg-green-500":"bg-green-500/80"),style:{width:`${Math.max(u,0)}px`,opacity:T},children:e.jsx(pe,{className:L("w-5 h-5 text-white transition-transform",T>=1&&"scale-125")})}),e.jsx("div",{className:L("absolute inset-y-0 right-0 flex items-center justify-end pr-4 transition-all duration-150",A>=1?"bg-red-500":"bg-red-500/80"),style:{width:`${Math.max(-u,0)}px`,opacity:A},children:e.jsx(Oe,{className:L("w-5 h-5 text-white transition-transform",A>=1&&"scale-125")})})]}),e.jsxs("div",{className:L("flex items-center gap-3 p-3 bg-card rounded-lg relative z-10 touch-pan-y",R(l,s),p?"":"transition-transform duration-200 ease-out"),style:{transform:r?`translateX(${u}px)`:void 0},onTouchStart:v,onTouchMove:S,onTouchEnd:y,children:[e.jsx("button",{className:L("w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-all duration-200",s?"bg-green-500 text-white":"border-2 border-border"),onClick:()=>{Ae.light(),x(t)},children:s&&e.jsx(pe,{className:"w-3.5 h-3.5"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[!s&&q(l),e.jsx("span",{className:L("text-sm leading-tight",s&&"text-muted-foreground line-through"),children:i})]})}),a&&e.jsx("span",{className:"shrink-0 bg-primary/15 text-primary px-1.5 py-0.5 rounded text-[10px] font-medium flex items-center gap-0.5",children:e.jsx(ke,{className:"w-2.5 h-2.5"})}),r&&k&&!s&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground/40",children:[e.jsx(ls,{className:"w-3 h-3"}),e.jsx(It,{className:"w-3 h-3"})]})]})]})},Ut=({activeList:t,isMobile:i=!1,onTasksAdded:s,weekKey:l,activeDay:a})=>{const{t:x,language:n}=ne(),[c,r]=d.useState(["","","",""]),[u,I]=d.useState(!1),[p,m]=d.useState(!1),k=(j,g)=>{const v=[...c];v[j]=g,r(v)},z=async()=>{const j=c.filter(g=>g.trim());if(j.length!==0){if(!l||l.trim()===""){console.error("❌ Cannot add tasks: weekKey is empty!",{weekKey:l,activeDay:a}),Me({title:n==="en"?"Loading...":"Se încarcă...",description:n==="en"?"Week data is loading. Please wait a moment and try again.":"Datele săptămânii se încarcă. Te rog așteaptă un moment.",variant:"destructive"});return}console.log("✅ Adding priorities to:",{weekKey:l,activeDay:a}),I(!0);try{const{data:{user:g}}=await Y.auth.getUser();if(!g){Me({title:n==="en"?"Please log in":"Te rog să te autentifici",variant:"destructive"});return}const v=j.map((y,R)=>({id:Us(),user_id:g.id,title:y.trim(),task_type:t,list_type:t,week_key:l,day_of_week:a,completed:!1,position:R,priority:R===0?3:R===1?2:R===2?1:0})),{error:S}=await Y.from("user_tasks").insert(v);if(S)throw S;Me({title:n==="en"?"Priorities added!":"Priorități adăugate!",description:n==="en"?`${j.length} tasks added for today`:`${j.length} sarcini adăugate pentru azi`}),r(["","","",""]),m(!1),await(s==null?void 0:s())}catch(g){console.error("Error adding priorities:",g),Me({title:n==="en"?"Error":"Eroare",description:n==="en"?"Could not add tasks":"Nu s-au putut adăuga sarcinile",variant:"destructive"})}finally{I(!1)}}},h=(j,g)=>{if(j.key==="Enter")if(g<3){const v=document.getElementById(`priority-input-${g+1}`);v==null||v.focus()}else z()},b=c.some(j=>j.trim());return p?e.jsxs("div",{className:`${i?"py-4":"py-3"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-500"}),e.jsx("h4",{className:"font-medium text-sm",children:n==="en"?"Top 4 Priorities for Today":"Top 4 Priorități pentru Azi"})]}),e.jsx("div",{className:"space-y-2",children:c.map((j,g)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`
5              w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold
6              ${g===0?"bg-red-500/20 text-red-400":g===1?"bg-orange-500/20 text-orange-400":g===2?"bg-yellow-500/20 text-yellow-400":"bg-muted text-muted-foreground"}
7            `,children:g+1}),e.jsx(_e,{id:`priority-input-${g}`,value:j,onChange:v=>k(g,v.target.value),onKeyDown:v=>h(v,g),placeholder:n==="en"?`Priority ${g+1}
7...`:`Prioritatea ${g+1}...`,className:"flex-1 h-9 text-sm",disabled:u})]},g))}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>{m(!1),r(["","","",""])},disabled:u,children:n==="en"?"Cancel":"Anulează"}),e.jsxs(_,{size:"sm",onClick:z,disabled:!b||u||!l,className:"gap-2",children:[u?e.jsx(ge,{className:"h-4 w-4 animate-spin"}):e.jsx(Se,{className:"h-4 w-4"}),n==="en"?"Add":"Adaugă"]})]})]}):e.jsx("div",{className:`text-center ${i?"py-6":"py-4"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(ce,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:`text-muted-foreground ${i?"text-sm":""}`,children:x(t==="hit"?"noTasksForDay":"noDoItemsForDay")}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),n==="en"?"Add Top 4 Priorities":"Adaugă Top 4 Priorități"]})]})})},Kt=({activeList:t,setActiveList:i,activeDay:s,selectDayOfWeek:l,hitList:a,doList:x,toggleHitListItemCompletion:n,toggleDoListItemCompletion:c,hitAchievedCount:r,hitDoneCount:u,doAchievedCount:I,doDoneCount:p,isMobile:m=!1,moveTaskBackToHotList:k,onDeleteTask:z,onTasksAdded:h,isDragOver:b,onDragOver:j,onDrop:g,weekKey:v=""})=>{const[S,y]=d.useState(!1),[R,q]=d.useState(!1),T=b!==void 0?b:S,A=N=>{N.preventDefault(),y(!0),j==null||j(N)},f=N=>{N.currentTarget.contains(N.relatedTarget)||y(!1)},O=N=>{N.preventDefault(),y(!1),g==null||g(N),q(!0),setTimeout(()=>q(!1),1e3)},E=N=>{if(typeof N!="string")return N;const P={monday:"M",tuesday:"T",wednesday:"W",thursday:"Th",friday:"F",saturday:"Sa",sunday:"Su",m:"M",t:"T",w:"W",th:"Th",f:"F",sa:"Sa",su:"Su"},W=N.toLowerCase();return P[W]||N},$=a.filter(N=>E(N.day)===s),F=x.filter(N=>E(N.day)===s),J=`${u}/${r}`,V=`${p}/${I}`;return e.jsxs("div",{className:L("relative transition-all duration-200",m?"max-h-[70vh] overflow-y-auto overflow-x-hidden w-full max-w-full":"",T&&"ring-2 ring-primary/30 ring-offset-2 ring-offset-background rounded-xl"),onDragOver:A,onDragLeave:f,onDrop:O,children:[T&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-xl bg-primary/10 border-2 border-dashed border-primary animate-drop-zone-pulse pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center animate-bounce",children:e.jsx(ms,{className:"w-5 h-5 text-primary"})}),e.jsx("span",{className:"text-sm font-medium text-primary",children:"Add to tasks"})]})}),R&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-green-500/10 rounded-xl pointer-events-none",children:e.jsx("div",{className:"flex items-center gap-2 text-green-600 animate-success-pop",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-green-500 flex items-center justify-center",children:e.jsx(pe,{className:"w-5 h-5 text-white"})})})}),e.jsxs("div",{className:"flex mb-3 bg-muted/50 p-1 rounded-lg",children:[e.jsxs("button",{className:`flex-1 px-3 py-1.5 text-sm font-medium rounded-md transition-all ${t==="hit"?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>i("hit"),children:["HIT (",J,")"]}),e.jsxs("button",{className:`flex-1 px-3 py-1.5 text-sm font-medium rounded-md transition-all ${t==="do"?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>i("do"),children:["DO (",V,")"]})]}),e.jsx(er,{activeDay:s,selectDayOfWeek:l,isMobile:m}),e.jsx("div",{className:`space-y-1 ${m?"max-h-[calc(70vh-120px)] overflow-y-auto":""}`,children:t==="hit"?$.length>0?$.map(N=>m?e.jsx(Vt,{id:N.id,text:N.text,completed:N.completed,priority:N.priority,isKeyPoint:N.isKeyPoint,onToggleCompletion:n,onDelete:z?P=>z(P,"hit"):void 0,onMoveBack:k?P=>k(P,"hit"):void 0,isMobile:m},N.id):e.jsx(qt,{id:N.id,text:N.text,completed:N.completed,priority:N.priority,isKeyPoint:N.isKeyPoint,onToggleCompletion:n,onMoveBack:k?P=>k(P,"hit"):void 0,isMobile:m},N.id)):e.jsx(Ut,{activeList:"hit",isMobile:m,onTasksAdded:h,weekKey:v||"",activeDay:s}):F.length>0?F.map(N=>m?e.jsx(Vt,{id:N.id,text:N.text,completed:N.completed,priority:N.priority,onToggleCompletion:c,onDelete:z?P=>z(P,"do"):void 0,onMoveBack:k?P=>k(P,"do"):void 0,isMobile:m},N.id):e.jsx(qt,{id:N.id,text:N.text,completed:N.completed,priority:N.priority,onToggleCompletion:c,onMoveBack:k?P=>k(P,"do"):void 0,isMobile:m},N.id)):e.jsx(Ut,{activeList:"do",isMobile:m,onTasksAdded:h,weekKey:v||"",activeDay:s})})]})},tr=({step:t,totalSteps:i,title:s,description:l,isVisible:a,onNext:x,onSkip:n,onClose:c,position:r="bottom"})=>{const{language:u}=ne();if(!a)return null;const I=t===i;return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 flex items-center justify-center animate-fade-in",children:e.jsx(Ks,{className:"max-w-sm mx-4 border-primary/20 bg-gradient-to-br from-card to-card/90 shadow-xl",children:e.jsxs(Gs,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:t})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t," / ",i]})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:c,children:e.jsx(Be,{className:"w-4 h-4"})})]}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:l}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:n,children:u==="en"?"Skip":"Sări peste"}),e.jsx(_,{onClick:x,size:"sm",className:"flex items-center gap-2",children:I?e.jsxs(e.Fragment,{children:[e.jsx(Oa,{className:"w-4 h-4"}),u==="en"?"Got it!":"Am înțeles!"]}):e.jsxs(e.Fragment,{children:[u==="en"?"Next":"Următorul",e.jsx(St,{className:"w-4 h-4"})]})})]}),e.jsx("div",{className:"flex gap-1 mt-4",children:Array.from({length:i},(p,m)=>e.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${m<t?"bg-primary":"bg-muted"}`},m))})]})})})},sr=({isOpen:t,onClose:i,plans:s,onSelectPlan:l,onRefresh:a})=>{const{toast:x}
7=fe(),[n,c]=d.useState(!1),[r,u]=d.useState(null),[I,p]=d.useState(null),m=h=>{u(h),c(!0)},k=async()=>{if(!(r!=null&&r.id))return;await kt.deletePlan(r.id)?(x({title:"✅ Plan șters",description:`Planul pentru săptămâna ${r.weekKey} a fost șters cu succes.`}),a()):x({title:"❌ Eroare",description:"Nu s-a putut șterge planul. Încearcă din nou.",variant:"destructive"}),c(!1),u(null)},z=h=>{p(I===h?null:h)};return e.jsxs(e.Fragment,{children:[e.jsx(us,{open:t,onOpenChange:i,children:e.jsxs(xs,{className:"max-h-[85vh]",children:[e.jsxs(hs,{children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(Zt,{className:"w-5 h-5"}),"Istoric Planificare Săptămânală"]}),e.jsx(gs,{children:"Vezi, restaurează sau șterge planurile tale anterioare"})]}),e.jsx(ht,{className:"px-6 pb-6",children:e.jsx("div",{className:"space-y-4",children:s.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Nu ai planuri săptămânale salvate încă"})]}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-8 top-0 bottom-0 w-0.5 bg-border"}),s.map((h,b)=>{const j=I===h.id;return e.jsxs("div",{className:"relative pl-16 pb-8",children:[e.jsx("div",{className:"absolute left-6 top-2 w-4 h-4 rounded-full bg-primary border-4 border-background"}),e.jsxs("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"text-sm text-muted-foreground mb-1",children:["Săptămâna ",h.weekKey]}),e.jsxs("h3",{className:"font-semibold text-lg flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-primary"}),h.dominoTitle]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>z(h.id),title:"Vezi detalii",children:e.jsx(es,{className:"w-4 h-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>{l(h),i()},title:"Restaurează plan",children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),"Restaurează"]}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>m(h),title:"Șterge plan",children:e.jsx(Oe,{className:"w-4 h-4"})})]})]}),h.weekGoal&&e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:h.weekGoal}),j&&e.jsxs("div",{className:"space-y-3 border-t pt-3 mt-3",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ct,{className:"w-4 h-4"}),"Cele 4 Chei:"]}),h.keyPoints.map((g,v)=>e.jsxs("div",{className:"pl-6 space-y-2 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm font-medium",children:[e.jsx(Ee,{className:"w-4 h-4 mt-0.5 text-green-500 flex-shrink-0"}),e.jsx("span",{children:g.title})]}),g.objective&&e.jsxs("p",{className:"text-sm text-muted-foreground pl-6",children:[e.jsx("strong",{children:"Obiectiv:"})," ",g.objective]}),g.positiveImpact&&e.jsxs("p",{className:"text-sm text-green-600 pl-6",children:[e.jsx("strong",{children:"Impact pozitiv:"})," ",g.positiveImpact]}),g.responsible&&e.jsxs("p",{className:"text-sm text-muted-foreground pl-6",children:[e.jsx("strong",{children:"Responsabil:"})," ",g.responsible]}),g.deadline&&e.jsxs("p",{className:"text-sm text-muted-foreground pl-6",children:[e.jsx("strong",{children:"Deadline:"})," ",g.deadline]})]},v))]}),!j&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ct,{className:"w-4 h-4"}),"Cele 4 Chei:"]}),h.keyPoints.map((g,v)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm pl-6",children:[e.jsx(Ee,{className:"w-4 h-4 mt-0.5 text-green-500 flex-shrink-0"}),e.jsx("span",{children:g.title})]},v))]})]})]},h.id)})]})})})]})}),e.jsx(pt,{open:n,onOpenChange:c,children:e.jsxs(gt,{children:[e.jsxs(ft,{children:[e.jsx(jt,{children:"Ești sigur?"}),e.jsxs(yt,{children:["Vrei să ștergi planul pentru ",e.jsxs("strong",{children:["săptămâna ",r==null?void 0:r.weekKey]}),"?",e.jsx("br",{}),"Domino: ",e.jsx("strong",{children:r==null?void 0:r.dominoTitle}),e.jsx("br",{}),e.jsx("br",{}),"Această acțiune nu poate fi anulată."]})]}),e.jsxs(bt,{children:[e.jsx(vt,{children:"Anulează"}),e.jsx(Nt,{onClick:k,className:"bg-destructive hover:bg-destructive/90",children:"Șterge Plan"})]})]})})]})},ar=({currentDate:t,onPreviousWeek:i,onNextWeek:s,onSelectDate:l})=>{const a=Lt(t),x=Ft(t),n=Lt(new Date)===a&&Ft(new Date)===x;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:i,className:"h-7 w-7",children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsxs(as,{children:[e.jsx(rs,{asChild:!0,children:e.jsxs(_,{variant:"ghost",size:"sm",className:"flex items-center gap-1.5 h-7 px-2",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-xs font-medium",children:["S",a]}),n&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"})]})}),e.jsx(ns,{className:"w-auto p-0",align:"center",children:e.jsx(La,{mode:"single",selected:t,onSelect:c=>{c&&l(c)},locale:wt,className:"rounded-md border"})})]}),e.jsx(_,{variant:"ghost",size:"icon",onClick:s,className:"h-7 w-7",disabled:n,children:e.jsx(It,{className:"h-4 w-4"})})]})},rr=({activeSection:t,onSectionChange:i,stats:s,streak:l=0})=>{const a=[{id:"todo",icon:lt,label:"Idei",count:s.ideas,activeColor:"bg-blue-600"},{id:"focus",icon:ce,label:"Focus",count:s.focus,activeColor:"bg-purple-600"},{id:"tasks",icon:qe,label:"Sarcini",count:s.tasks,activeColor:"bg-green-600"}],x=n=>
7{Ae.light(),i(n)};return e.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-card border-t border-border z-50 safe-area-bottom",children:e.jsxs("div",{className:"flex items-stretch justify-around h-16",children:[a.map(n=>{const c=n.icon,r=t===n.id;return e.jsxs("button",{onClick:()=>x(n.id),className:L("flex-1 flex flex-col items-center justify-center gap-0.5 relative transition-all duration-200",r?"text-primary":"text-muted-foreground active:bg-accent/50"),children:[r&&e.jsx("div",{className:"absolute top-0 left-1/4 right-1/4 h-0.5 bg-primary rounded-b-full"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{className:L("w-5 h-5 transition-transform duration-200",r&&"scale-110")}),n.count>0&&e.jsx("span",{className:L("absolute -top-1.5 -right-2.5 min-w-[16px] h-4 px-1 rounded-full text-[10px] font-bold flex items-center justify-center",r?"bg-primary text-primary-foreground":"bg-muted-foreground/20 text-muted-foreground"),children:n.count>99?"99+":n.count})]}),e.jsx("span",{className:L("text-[10px] font-medium",r&&"font-semibold"),children:n.label})]},n.id)}),l>0&&e.jsxs("div",{className:"absolute right-2 -top-8 flex items-center gap-1 bg-orange-500/20 text-orange-500 px-2 py-1 rounded-full text-xs font-bold",children:[e.jsx(ts,{className:"w-3 h-3"}),l]})]})})},nr=({children:t,onSwipeLeft:i,onSwipeRight:s,className:l=""})=>{const[a,x]=d.useState(null),[n,c]=d.useState(null),[r,u]=d.useState(!1),[I,p]=d.useState(0),m=d.useRef(null),k=50,z=j=>{c(null),x(j.targetTouches[0].clientX),u(!0)},h=j=>{if(a===null)return;const g=j.targetTouches[0].clientX;c(g);const v=g-a,S=Math.max(-150,Math.min(150,v));p(S)},b=()=>{if(!a||!n){u(!1),p(0);return}const j=a-n,g=j>k,v=j<-k;g&&i&&i(),v&&s&&s(),u(!1),p(0),x(null),c(null)};return e.jsx("div",{ref:m,onTouchStart:z,onTouchMove:h,onTouchEnd:b,className:`${l} transition-transform duration-200 w-full max-w-full overflow-hidden box-border ${r?"touch-none":""}`,style:{transform:r?`translateX(${I}px)`:"translateX(0)"},children:t})},ir=()=>{const[t,i]=d.useState(!1),[s,l]=d.useState(1),[a,x]=d.useState(!1),[n,c]=d.useState(!1),[r,u]=d.useState(!1),[I,p]=d.useState([]),[m,k]=d.useState("focus"),z=Js(),{toast:h}=fe(),{language:b}=ne(),j=Gt();d.useEffect(()=>{const M=localStorage.getItem("door-hot-list")||localStorage.getItem("door-hit-list")||localStorage.getItem("door-do-list"),G=localStorage.getItem("door-onboarding-completed");!M&&!G&&i(!0),x(!!G)},[]);const g=()=>{c(!0)},v=async()=>{const M=await kt.getAllPlans();p(M)},S=()=>{v(),u(!0)},y=async()=>{try{const M=await at.removeDuplicateTasks();M.removed>0?(h({title:"🧹 Dubluri eliminate",description:`Am eliminat ${M.removed} task-uri duplicate. Au rămas ${M.kept} task-uri unice.`}),setTimeout(()=>he(),500)):h({title:"✅ Niciun duplicat",description:"Nu am găsit task-uri duplicate în baza de date."})}catch(M){console.error("Error cleaning duplicates:",M),h({title:"❌ Eroare",description:"Nu am putut curăța duplicatele. Încearcă din nou.",variant:"destructive"})}},{currentDate:R,currentWeekKey:q,filteredHotList:T,hitList:A,doList:f,searchTerm:O,activeDay:E,activeList:$,selectedDomino:F,dominoKeyPoints:J,hitAchievedCount:V,hitDoneCount:N,doAchievedCount:P,doDoneCount:W,isDominoCompleted:ee,editingNewItem:Z,saveStatus:U,lastCloudSaveTime:de,setSearchTerm:je,setActiveList:me,setSelectedDomino:X,setDominoKeyPoints:le,handlePreviousWeek:oe,handleNextWeek:ye,toggleHotListItemSelection:C,addNewTarget:H,addNewTargetWithText:te,deleteHotListItem:B,updateHotListItemText:ae,updateHotListItemPriority:ue,selectDayOfWeek:be,handleDominoSelection:Tt,updateKeyPointText:Re,handleDragStartToDomino:Ke,handleDragOverDomino:ve,handleDropOnDomino:Ne,handleKeyPointDragStart:Ce,handleDragStart:Ge,handleDragOver:Ie,handleDrop:o,handleDropOnKeyPoint:D,handleDragEnd:w,toggleHitListItemCompletion:Q,toggleDoListItemCompletion:re,moveKeyPointToHotList:xe,moveTaskBackToHotList:Le,addNewKeyPoint:K,navigateToDate:De,refreshLists:he}=os(),{handleMoveIdeaToHit:zt,handleMoveIdeaToDo:At}=qa(q,E,he),{streakData:ys,updateDailyProgress:bs}=Xs();d.useEffect(()=>{const M=V+P,G=N+W;M>0&&bs(M,G,T.length,V,P)},[N,W,V,P]);const{undo:Je,redo:Xe,canUndo:vs,canRedo:Ns}=Ba({selectedDomino:F,dominoKeyPoints:J,setSelectedDomino:X,setDominoKeyPoints:le});d.useEffect(()=>{const M=G=>{(G.ctrlKey||G.metaKey)&&G.key==="z"&&!G.shiftKey&&(G.preventDefault(),Je()&&h({title:"↩️ Undo",description:b==="en"?"Restored previous focu
7s":"Focus anterior restaurat"})),((G.ctrlKey||G.metaKey)&&G.shiftKey&&G.key==="z"||(G.ctrlKey||G.metaKey)&&G.key==="y")&&(G.preventDefault(),Xe()&&h({title:"↪️ Redo",description:b==="en"?"Restored next focus":"Focus următor restaurat"}))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[Je,Xe,h,b]);const ws=()=>{oe();const M=Mt(new Date(R.getTime()-7*24*60*60*1e3));h({title:`${b==="en"?"Loading Week":"Încărcarea Săptămânii"} ${M}`,description:b==="en"?"Your saved tasks and dominos for this week have been loaded":"Sarcinile și domeniile salvate pentru această săptămână au fost încărcate"})},Ss=()=>{ye();const M=Mt(new Date(R.getTime()+7*24*60*60*1e3));h({title:`${b==="en"?"Loading Week":"Încărcarea Săptămânii"} ${M}`,description:b==="en"?"Your saved tasks and dominos for this week have been loaded":"Sarcinile și domeniile salvate pentru această săptămână au fost încărcate"})},ks=M=>{M.dominoTitle&&X({id:`domino-${M.weekKey}`,text:M.dominoTitle,priority:"none",selected:!1});const G=[];for(let Te=0;Te<4;Te++){const ie=M.keyPoints[Te];ie?G.push({id:ie.id?`key${ie.id}`:`key${Te+1}`,text:ie.title||"",completed:!1,metadata:{objective:ie.objective||"",why:ie.why||"",positiveImpact:ie.positiveImpact||"",negativeImpact:ie.negativeImpact||"",steps:ie.steps||[],responsible:ie.responsible||"Eu",deadline:ie.deadline||""}}):G.push({id:`key${Te+1}`,text:"",completed:!1,metadata:{objective:"",why:"",positiveImpact:"",negativeImpact:"",steps:[],responsible:"Eu",deadline:""}})}le(G),h({title:"📋 Plan restaurat din cloud",description:`Planul pentru săptămâna ${M.weekKey} a fost încărcat cu succes.`})},Fe=[{title:b==="en"?"Welcome to Command Center!":"Bine ai venit în Command Center!",description:b==="en"?"This is your productivity hub. All three sections are now visible for easy drag & drop!":"Acesta este hub-ul tău de productivitate. Toate cele 3 secțiuni sunt acum vizibile pentru drag & drop ușor!"},{title:b==="en"?"Set Your Weekly Focus":"Stabilește Focusul Săptămânal",description:b==="en"?"Drag an idea to the Focus section or click to select your weekly domino goal.":"Trage o idee în secțiunea Focus sau click pentru a selecta obiectivul domino săptămânal."},{title:b==="en"?"Execute Daily Tasks":"Execută Sarcinile Zilnice",description:b==="en"?"Drag ideas or key points to the Tasks section to create your daily action lists.":"Trage idei sau puncte cheie în secțiunea Sarcini pentru a crea listele de acțiuni zilnice."}],Cs=()=>{s<Fe.length?l(s+1):(i(!1),localStorage.setItem("door-onboarding-completed","true"),x(!0))},_t=()=>{i(!1),localStorage.setItem("door-onboarding-completed","true"),x(!0)},Qe={ideas:T.filter(M=>M.selected).length,focus:F?J.filter(M=>M.completed).length:0,tasks:V+P},Is=()=>{m==="todo"?k("focus"):m==="focus"&&k("tasks")},Ds=()=>{m==="tasks"?k("focus"):m==="focus"&&k("todo")},Ye=V+P,Et=N+W;return e.jsx("div",{className:"overflow-x-hidden w-full max-w-full",children:e.jsxs("div",{className:`${z?"px-2 pt-2 pb-20 w-full max-w-full overflow-hidden":"px-6 py-4"}`,children:[e.jsx(Fa,{totalTasks:Ye,completedTasks:Et}),!z&&e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6 pb-4 border-b border-border",children:[e.jsx(ar,{currentDate:R,onPreviousWeek:ws,onNextWeek:Ss,onSelectDate:De}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{onClick:()=>j("/focus"),variant:"default",size:"sm",className:"gap-2",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Start Deep Work",e.jsx(St,{className:"h-4 w-4"})]}),Ye>0&&e.jsxs("span",{className:"text-sm text-muted-foreground bg-muted px-3 py-1.5 rounded-lg",children:[Et,"/",Ye," ✓"]}),e.jsxs(rt,{children:[e.jsx(nt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0",children:e.jsx(Ma,{className:"h-4 w-4"})})}),e.jsxs(it,{align:"end",className:"w-48",children:[e.jsxs(we,{onClick:()=>Je(),disabled:!vs,className:"cursor-pointer",children:[e.jsx(Ha,{className:"w-4 h-4 mr-2"}),"Undo"]}),e.jsxs(we,{onClick:()=>Xe(),disabled:!Ns,className:"cursor-pointer",children:[e.jsx(Wa,{className:"w-4 h-4 mr-2"}),"Redo"]}),e.jsx(Qs,{}),e.jsxs(we,{onClick:S,className:"cursor-pointer",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),"Istoric planuri"]}),e.jsxs(we,{onClick:y,className:"cursor-pointer",children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Curăță duplicate"]})]})]})]})]}),new Date().getDay()===0&&e.jsxs("div",{className:"bg-primary/10 border border-primary/20 p-3 rounded-lg mb-4 flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:"📅"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-primary",children:"Duminică - Mod Planificare"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Planifici pentru săptămâna viitoare (Luni - Sâmbătă). Review + Setează Domino + Distribuie task-uri."})]})]}),!z&&e.jsx(Ra,{onStartPlanning:g}),z?e.jsxs(e.Fragment,{children:[e.jsxs(nr,{onSwipeLeft:Is,onSwipeRight:Ds,className:"min-h-[60vh] w-full max-w-full overflow-hidden",children:[m==="todo"&&e.jsxs("div",{className:"animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-foreground flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4 text-blue-500"}),"Idei"]}),e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-full",children:T.length})]}),e.jsx(Wt,{isMobile:z,onMoveToHit:zt,onMoveToDo:At})]}),m==="focus"&&e.jsx("div",{className:"animate-fade-in",onDragOver:ve,onDrop:Ne,children:e.jsx(Bt,{selectedDomino:F,dominoKeyPoints:J,updateKeyPointText:Re,handleDragOverDomino:ve,handleDropOnDomino:Ne,handleKeyPointDragStart:Ce,isMobile:z,isCompleted:ee,moveKeyPointToHotList:xe,addNewKeyPoint:K,handleDropOnKeyPoint:D,setSelectedDomino:X,setDominoKeyPoints:le,weekKey:q,saveStatus:U,lastSaveTime:de})}),m==="tasks"&&e.jsxs("div",{className:"animate-fade-in",onDragOver:Ie,onDrop:o,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-foreground flex items-center gap-2",children:[e.jsx(qe,{className:"w-4 h-4 text-green-500"}
7),"Sarcini"]}),e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-full",children:Qe.tasks})]}),e.jsx(Kt,{hitList:A,doList:f,activeDay:E,activeList:$,setActiveList:me,selectDayOfWeek:be,toggleHitListItemCompletion:Q,toggleDoListItemCompletion:re,hitAchievedCount:V,hitDoneCount:N,doAchievedCount:P,doDoneCount:W,moveTaskBackToHotList:Le,isMobile:z,onTasksAdded:he,weekKey:q})]})]}),e.jsx(rr,{activeSection:m,onSectionChange:k,stats:Qe,streak:ys.currentStreak})]}):e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)_minmax(0,1fr)] gap-6 animate-fade-in",children:[e.jsxs("div",{className:"min-w-0 [&_*]:break-words bg-card border border-border rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-base font-medium text-foreground flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4 text-primary"}),"Idei"]}),e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded-full",children:T.length})]}),e.jsx(Wt,{isMobile:!1,onMoveToHit:zt,onMoveToDo:At})]}),e.jsx("div",{onDragOver:ve,onDrop:Ne,children:e.jsx(Bt,{selectedDomino:F,dominoKeyPoints:J,updateKeyPointText:Re,handleDragOverDomino:ve,handleDropOnDomino:Ne,handleKeyPointDragStart:Ce,isMobile:!1,isCompleted:ee,moveKeyPointToHotList:xe,addNewKeyPoint:K,handleDropOnKeyPoint:D,setSelectedDomino:X,setDominoKeyPoints:le,weekKey:q,saveStatus:U,lastSaveTime:de})}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5",onDragOver:Ie,onDrop:o,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-base font-medium text-foreground flex items-center gap-2",children:[e.jsx(qe,{className:"w-4 h-4 text-green-500"}),"Sarcini"]}),e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded-full",children:Qe.tasks})]}),e.jsx(Kt,{hitList:A,doList:f,activeDay:E,activeList:$,setActiveList:me,selectDayOfWeek:be,toggleHitListItemCompletion:Q,toggleDoListItemCompletion:re,hitAchievedCount:V,hitDoneCount:N,doAchievedCount:P,doDoneCount:W,moveTaskBackToHotList:Le,isMobile:!1,onTasksAdded:he,weekKey:q})]})]}),t&&e.jsx(tr,{title:Fe[s-1].title,description:Fe[s-1].description,step:s,totalSteps:Fe.length,onNext:Cs,onSkip:_t,onClose:_t,position:z?"bottom":"top",isVisible:t}),e.jsx(sr,{isOpen:r,onClose:()=>u(!1),plans:I,onSelectPlan:ks,onRefresh:v})]})})},lr={body:{icon:Ys,label:{en:"Body",ro:"Corp"},color:"text-emerald-500",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/50"},being:{icon:Pe,label:{en:"Spirituality",ro:"Spiritualitate"},color:"text-purple-500",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/50"},balance:{icon:Zs,label:{en:"Relationships",ro:"Relații"},color:"text-rose-500",bgColor:"bg-rose-500/10",borderColor:"border-rose-500/50"},business:{icon:ea,label:{en:"Business",ro:"Business"},color:"text-blue-500",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/50"}},or=()=>{const{language:t}=ne();fe(),Gt();const[i,s]=Jt(),[l,a]=d.useState([]),[x,n]=d.useState(!0),[c,r]=d.useState(null),[u,I]=d.useState(null),p=new Date,m=ot(p,"yyyy-MM"),k=ot(p,"MMMM yyyy",{locale:t==="en"?Ca:wt});let z=null;try{z=os()}catch{}d.useEffect(()=>{(async()=>{var S;try{n(!0);const{data:y}=await Y.auth.getSession();if(!((S=y==null?void 0:y.session)!=null&&S.user)){n(!1);return}const{data:R,error:q}=await Y.from("missions").select("*").eq("user_id",y.session.user.id).eq("mission_type","monthly").eq("period",m);if(q)throw q;const T=(R||[]).map(A=>{var f,O;return{id:A.id,category:A.category,title:A.title||"",measurableResult:A.measurable_result||"",progress:((f=A.goal_data)==null?void 0:f.progress)||0,keyActions:((O=A.goal_data)==null?void 0:O.keyActions)||[]}});a(T)}catch(y){console.error("Error fetching monthly missions:",y)}finally{n(!1)}})()},[m]);const h=v=>l.find(S=>S.category===v),b=(v,S)=>{r(S.id);const y={type:"monthly-mission",id:S.id,text:S.title,measurableResult:S.measurableResult,keyActions:S.keyActions,category:S.category};v.dataTransfer.setData("application/json",JSON.stringify(y)),v.dataTransfer.setData("text/plain",S.title),v.dataTransfer.effectAllowed="copyMove",console.debug("[DnD] Lunar dragStart",{id:S.id,effectAllowed:"copyMove"})},j=v=>{v.dataTransfer.dropEffect!=="none"&&c&&(I(c),setTimeout(()=>I(null),1500)),r(null)},g=()=>{s(v=>{const S=new URLSearchParams(v);return S.set("tab","monthly"),S},{replace:!0}),window.scrollTo({top:0,behavior:"smooth"})};return x?e.jsxs("div",{className:"px-6 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-3",children:[e.jsx("span",{children:t==="en"?"Monthly Objectives":"Obiective Lunare"}),e.jsx("span",{children:"•"}),e.jsx("span",{className:"capitalize",children:k})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[1,2,3,4].map(v
7=>e.jsx("div",{className:"h-32 bg-muted animate-pulse rounded-xl"},v))})]}):e.jsxs("div",{className:"px-6 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-3",children:[e.jsx("span",{children:t==="en"?"Monthly Objectives":"Obiective Lunare"}),e.jsx("span",{children:"•"}),e.jsx("span",{className:"capitalize",children:k})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:Object.entries(lr).map(([v,S])=>{const y=h(v),R=S.icon;return e.jsxs("div",{className:L("relative rounded-xl border-2 p-3 transition-all duration-200",S.borderColor,S.bgColor,y&&"cursor-grab active:cursor-grabbing hover:shadow-lg hover:scale-[1.02]",c===(y==null?void 0:y.id)&&"opacity-50 ring-2 ring-primary scale-95",u===(y==null?void 0:y.id)&&"ring-2 ring-green-500 bg-green-500/10"),draggable:!!y,onDragStart:q=>y&&b(q,y),onDragEnd:j,children:[c===(y==null?void 0:y.id)&&e.jsx("div",{className:"absolute -top-2 -right-2 z-10 bg-primary text-primary-foreground text-xs px-2 py-0.5 rounded-full animate-fade-in shadow-lg",children:t==="en"?"Dragging...":"Se mută..."}),u===(y==null?void 0:y.id)&&e.jsxs("div",{className:"absolute -top-2 -right-2 z-10 bg-green-500 text-white text-xs px-2 py-0.5 rounded-full animate-success-pop shadow-lg flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t==="en"?"Added!":"Adăugat!"]}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:L("w-4 h-4",S.color)}),e.jsx("span",{className:L("text-sm font-semibold",S.color),children:S.label[t==="en"?"en":"ro"]})]}),e.jsxs($e,{variant:"secondary",className:L("text-xs px-1.5 py-0",S.color,"bg-transparent"),children:[(y==null?void 0:y.progress)||0,"%"]})]}),y?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"text-sm text-foreground font-medium line-clamp-1",children:["1. ",y.title]}),y.measurableResult&&e.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:y.measurableResult}),y.keyActions&&y.keyActions.length>1&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",y.keyActions.length-1," ",t==="en"?"more":"mai multe"]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground/50 pt-1",children:[e.jsx(Yt,{className:"w-3 h-3"}),e.jsx("span",{children:t==="en"?"Drag to Focus":"Trage în Focus"})]})]}):e.jsx("div",{className:"text-xs text-muted-foreground/50 italic",children:t==="en"?"No mission set":"Nicio misiune setată"})]},v)})}),e.jsx("div",{className:"flex justify-center mt-4",children:e.jsxs(_,{variant:"link",onClick:g,className:"text-sm text-primary hover:text-primary/80 gap-1",children:[t==="en"?"View all monthly objectives":"Vezi toate obiectivele lunare",e.jsx(It,{className:"w-4 h-4"})]})})]})},cr=()=>{const{language:t}=ne(),[i,s]=Jt(),[l,a]=d.useState(!1),x=i.get("tab")||"monthly",n=r=>{s(u=>{const I=new URLSearchParams(u);return r==="monthly"?I.delete("tab"):I.set("tab",r),I},{replace:!0}),l||a(!0)},c=[{value:"monthly",label:t==="en"?"Monthly":"Lunar",icon:Ct,description:t==="en"?"Monthly focus mission":"Misiune lunară de focus"},{value:"quarterly",label:t==="en"?"90 Days":"90 Zile",icon:ce,description:t==="en"?"Quarterly goals & progress":"Obiective și progres trimestrial"},{value:"annual",label:t==="en"?"Annual":"Anual",icon:la,description:t==="en"?"Annual vision & big goals":"Viziune anuală & obiective mari"}];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ta,{open:l,onOpenChange:a,children:e.jsxs(sa,{value:x,onValueChange:n,className:"w-full",children:[e.jsx("div",{className:"sticky top-0 z-20 bg-background/95 backdrop-blur-sm border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsx(aa,{className:"w-full grid grid-cols-3 gap-0 bg-transparent border border-border p-0 rounded-none h-auto",children:c.map(r=>e.jsxs(ra,{value:r.value,className:"flex items-center gap-2 py-3 px-3 text-mono text-xs uppercase tracking-wider rounded-none border-r border-border last:border-r-0 text-muted-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground transition-colors duration-200",children:[e.jsx(r.icon,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:r.label})]},r.value))})})}),!l&&e.jsx(Ot,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer hover:bg-muted/30 transition-colors",children:e.jsx(or,{})})}),e.jsx(na,{children:e.jsxs("div",{className:"container mx-auto",children:[e.jsx(et,{value:"monthly",className:"mt-0 outline-none",children:e.jsx(tt,{requiredTier:"basic",featureName:t==="en"?"Monthly Mission (30 days)":"Misiunea Lunară (30 zile)",teaser:t==="en"?"Plan your monthly focu
7s mission with milestones + weekly breakdown. Available on Basic.":"Planifică misiunea lunară de focus cu milestone-uri + defalcare săptămânală. Disponibil în Basic.",children:e.jsx(ma,{})})}),e.jsx(et,{value:"quarterly",className:"mt-0 outline-none",children:e.jsx(tt,{requiredTier:"basic",featureName:t==="en"?"90-Day Goals":"Obiective 90 Zile",teaser:t==="en"?"Strategic 90-day objectives with quarterly review and progress tracking. Available on Basic.":"Obiective strategice pe 90 zile cu review trimestrial și progres. Disponibil în Basic.",children:e.jsx(ua,{})})}),e.jsx(et,{value:"annual",className:"mt-0 outline-none",children:e.jsx(tt,{requiredTier:"basic",featureName:t==="en"?"Annual Vision":"Viziune Anuală",teaser:t==="en"?"Full 12-month vision, big goals, and life design. Available on Basic.":"Viziune completă pe 12 luni, obiective mari și design de viață. Disponibil în Basic.",children:e.jsx(xa,{})})})]})}),l&&e.jsx(Ot,{asChild:!0,children:e.jsx("div",{className:"flex justify-center py-2 cursor-pointer hover:bg-muted/30 transition-colors border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(ia,{className:L("w-4 h-4 transition-transform",l&&"rotate-180")}),e.jsx("span",{children:t==="en"?"Collapse":"Restrânge"})]})})})]})}),e.jsx("div",{className:"border-t border-border bg-card",children:e.jsx("div",{className:"container mx-auto",children:e.jsx(ir,{})})})]})},dr=()=>e.jsx(cr,{}),Nn=()=>e.jsx(oa,{children:e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(dr,{}),e.jsx(ca,{})]})});export{Nn as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.