1var e=Object.defineProperty,a=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,s=(a,t,r)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,l=(e,a,t)=>new Promise((r,s)=>{var l=e=>{try{i(t.next(e))}catch(a){s(a)}},n=e=>{try{i(t.throw(e))}catch(a){s(a)}},i=e=>e.done?r(e.value):Promise.resolve(e.value).then(l,n);i((t=t.apply(e,a)).next())});import{r as n,j as i,V as d,K as o,u as c,A as x,B as g,b1 as m,_ as b}from"./react-vendor-DPZzhrz4.js";import{C as h,l as u,D as y,k as p,X as f,Y as j}from"./firebase-vendor-fMuS9vAs.js";import{u as N,d as v,j as k}from"./index-BDftTafH.js";import"./pdf-vendor-D0-nrJtw.js";const w=["Lun","Mar","Mer","Gio","Ven","Sab","Dom"],D=e=>{if(!e)return 0;if("number"==typeof e)return e;return{"Molto Bassa":1,Bassa:2,Media:3,Alta:4,"Molto Alta":5}[e]||0},S={5:{bar:"bg-green-500",text:"text-green-600"},4:{bar:"bg-emerald-400",text:"text-emerald-600"},3:{bar:"bg-yellow-400",text:"text-yellow-600"},2:{bar:"bg-orange-400",text:"text-orange-600"},1:{bar:"bg-red-400",text:"text-red-600"},0:{bar:"bg-gray-200 dark:bg-gray-700",text:"text-gray-400"}},I={5:"M.Alta",4:"Alta",3:"Media",2:"Bassa",1:"M.Bassa"},M=()=>{const{currentUser:e}=N(),[a,t]=n.useState(0),[r,s]=n.useState([]),[c,x]=n.useState(!0);n.useEffect(()=>{e&&m()},[e,a]);const g=e=>{const a=new Date,t=a.getDay(),r=new Date(a);return r.setDate(a.getDate()-(t+6)%7+7*e),r.setHours(0,0,0,0),r},m=()=>l(null,null,function*(){x(!0);try{const t=g(a),r=new Date(t);r.setDate(t.getDate()+6),r.setHours(23,59,59,999);const l=h(u(v,"dailyCheckIns"),y("userId","==",e.uid)),n=yield p(l),i=[];for(let e=0;e<7;e++){const a=new Date(t);a.setDate(t.getDate()+e),i.push(a.toISOString().split("T")[0])}const d=new Set(i),o={};n.docs.forEach(e=>{var a,t,r,s;const l=e.data(),n=l.date||"";d.has(n)&&(o[n]={mood:(null==(a=l.answers)?void 0:a.q1)||"",energy:D(null==(t=l.answers)?void 0:t.q2),focus:D(null==(r=l.answers)?void 0:r.q3),priorities:(null==(s=l.answers
1)?void 0:s.q4)||[],hasDiary:!!l.diaryEntry})});const c=(new Date).toISOString().split("T")[0],x=[];for(let e=0;e<7;e++){const a=i[e];x.push({label:w[e],dateStr:a,isToday:a===c,isFuture:a>c,data:o[a]||null})}s(x)}catch(t){console.error("Errore caricamento grafico:",t)}finally{x(!1)}});if(c)return i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-4 border border-gray-200 dark:border-gray-700 animate-pulse mb-4",children:[i.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-40 mb-4"}),i.jsx("div",{className:"h-40 bg-gray-200 dark:bg-gray-700 rounded"})]});const b=r.filter(e=>e.data).length;return i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-4 border border-gray-200 dark:border-gray-700 mb-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("button",{onClick:()=>t(e=>e-1),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:i.jsx(d,{className:"h-4 w-4 text-gray-500"})}),i.jsxs("div",{className:"text-center",children:[i.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white",children:(()=>{const e=g(a),t=new Date(e);t.setDate(e.getDate()+6);const r={day:"numeric",month:"short"};return 0===a?"Questa settimana":-1===a?"Settimana scorsa":`${e.toLocaleDateString("it-IT",r)} - ${t.toLocaleDateString("it-IT",r)}`})()}),i.jsxs("span",{className:"text-[10px] text-gray-500 block",children:[b,"/7 check-in completati"]})]}),i.jsx("button",{onClick:()=>t(e=>Math.min(0,e+1)),disabled:a>=0,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg disabled:opacity-30",children:i.jsx(o,{className:"h-4 w-4 text-gray-500"})})]}),i.jsx("div",{className:"flex justify-between gap-2 items-end mb-3",style:{height:"100px"},children:r.map(e=>{var a,t;const r=(null==(a=e.data)?void 0:a.energy)||0,s=(null==(t=e.data)?void 0:t.focus)||0,l=r>0?Math.max(8,r/5*60):4,n=s>0?Math.max(8,s/5*60):4,d=S[r]||S[0],o=s>0?"bg-blue-400":"bg-gray-200 dark:bg-gray-700";return i.jsxs("div",{className:"flex-1 flex flex-col items-center",children:[e.data&&i.jsx("div",{className:"text-center mb-1",children:i.jsx("span",{className:`text-[10px] font-bold ${d.text}`,children:I[r]||"-"})}),i.jsxs("div",{className:"flex gap-0.5 items-end w-full",style:{height:"60px"},children:[i.jsx("div",{className:"flex-1 flex flex-col justify-end",children:i.jsx("div",{className:`w-full rounded-t ${e.data?d.bar:"bg-gray-100 dark:bg-gray-800"}`,style:{height:`${e.data?l:4}px`}})}),i.jsx("div",{className:"flex-1 flex flex-col justify-end",children:i.jsx("div",{className:`w-full rounded-t ${e.data?o:"bg-gray-100 dark:bg-gray-800"}`,style:{height:`${e.data?n:4}px`,opacity:e.data?.8:.3}})})]}),i.jsx("span",{className:"text-[11px] mt-1 "+(e.isToday?"font-bold text-blue-600 dark:text-blue-400":e.data?"font-medium text-gray-700 dark:text-gray-300":"text-gray-400"),children:e.label})]},e.dateStr)})}),i.jsxs("div",{className:"flex items-center justify-center gap-3 text-[10px] text-gray-500 border-t border-gray-100 dark:border-gray-700 pt-2",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-green-500 inline-block"})," Energia"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-blue-400 inline-block"})," Focus"]}),i.jsx("span",{children:"|"}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-green-500 inline-block"})," Alta"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-yellow-400 inline-block"})," Media"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-sm bg-red-400 inline-block"})," Bassa"]})]}),i.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",className:"mt-3 flex items-center justify-center gap-2 px-3 py-2.5 bg-gradient-to-r from-purple-500 to-indigo-500 hover:from-purple-600 hover:to-indigo-600 text-white text-xs font-medium rounded-lg transition-all",children:"Vuoi analizzare il tuo periodo col coach? Prenota una call"})]})},E=()=>{const e=c(),{userProfile:d,currentUser:o}=N(),k=(null==o?void 0:o.uid)||(null==d?void 0:d.uid),[w,D]=n.useState([]),[S,I]=n.useState(!0);n.useEffect(()=>{E()},[k]);const E=()=>l(null,null,function*(){if(k)try{const e=h(u(v,"dailyCheckIns"),y("userId","==",k),f("date","desc"),j(60)),l=(yield p(e)).docs.map(e=>((e,l)=>{for(var n in l||(l={}))t.call(l,n)&&s(e,n,l[n]);if(a)for(var n of a(l))r.call(l,n)&&s(e,n,l[n]);return e})({id:e.id},e.data()));D(l)}catch(e){console.error("Error loading check-ins:",e),alert("Errore nel caricamento dei diari check-in")}finally{I(!1)}else I(!1)}),O=e=>{const a=new Date(e),t=new Date,r=new Date(t);r.setDate(r.getDate()-1);const s=a.toDateString()===t.toDateString(),l=a.toDateString()===r.toDateString();return s?"Oggi":l?"Ieri":a.toLocaleDateString("it-IT",{weekday:"long",day:"numeric",month:"long",year:a.getFullYear()!==t.getFullYear()?"numeric":void 0})},q=(e,a=80)=>!e||e.length<=a?e:e.substring(0,a)+"...";return S?i.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 flex items-center justify-center",children:i.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-blue-500"})}):i.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 pb-20",children:[i.jsx("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 sticky top-0 z-10",children:i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[i.jsx("button",{onClick:()=>e("/"),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:i.jsx(x,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Diario Check-in"}),i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[w.length," ",1===w.length?"giorno registrato":"giorni registrati"]})]})]})}),i.jsxs("div",{className:"p-4",children:[w.length>0&&i.jsx(M,{}),0===w.length?i.jsxs("div",{className:"text-center py-16",children:[i.jsx("div",{className:"inline-block p-4 bg-gray-100 dark:bg-gray-800 rounded-full mb-4",children:i.jsx(g,{className:"w-12 h-12 text-gray-400"})}),i.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Nessun check-in ancora"}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-6",children:"Inizia a monitorare il tuo stato quotidiano"}),i.jsx("button",{onClick:()=>e("/"),className:"px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition-colors",children:"Torna alla Home"})]}
1):i.jsx("div",{className:"max-w-2xl mx-auto space-y-3",children:w.map(a=>{var t,r;return i.jsxs("div",{onClick:()=>(a=>{e(`/checkin/diary/${a.id}`)})(a),className:"bg-white dark:bg-gray-800 rounded-lg p-4 cursor-pointer hover:shadow-md transition-shadow border border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-start justify-between mb-2",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"font-bold text-gray-900 dark:text-white text-base",children:[O(a.date),a.time&&i.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400 ml-2",children:a.time})]}),i.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.dayOfWeek})]}),i.jsx("div",{className:"flex items-center gap-2",children:a.hasDiary?i.jsxs("div",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[i.jsx(g,{className:"w-4 h-4"}),i.jsx(m,{className:"w-4 h-4"})]}):i.jsx("div",{className:"flex items-center gap-1 text-gray-400",children:i.jsx(b,{className:"w-5 h-5"})})})]}),i.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[(null==(t=a.answers)?void 0:t.q1)&&i.jsx("span",{className:"px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-medium",children:a.answers.q1}),(null==(r=a.answers)?void 0:r.q2)&&i.jsxs("span",{className:"px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 rounded text-xs font-medium",children:["â¡ ",a.answers.q2]})]}),a.hasDiary&&a.diaryEntry?i.jsx("div",{className:"mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:i.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 italic",children:['"',q(a.diaryEntry),'"']})}):i.jsx("div",{className:"mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-500 flex items-center gap-1",children:[i.jsx(b,{className:"w-3 h-3"}),"Aggiungi note del diario"]})})]},a.id)})})]})]})};export{E 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.