1import{j as e}from"./vendor-motion-C9uFufCg.js";import{r as i}from"./vendor-charts-BlP1Pdbv.js";import{S as le}from"./Sidebar-D6lBmmuC.js";import{T as ne,M as oe,a as ie,i as ce}from"./Topbar-6s02ukrz.js";import{L as de,T as me,a as ue,F as xe,b as pe}from"./FeedbackSuccessModal-CQa8fJ7j.js";import{b as fe,s as he,c as ge}from"./analyticsService-CrTy5lfj.js";import{g as x}from"./colors-CDAwji7w.js";import{p as ye,u as be,a as je,C as we}from"./index-l8sTCxZG.js";import{M as ve}from"./message-square-C6n4hz78.js";import{C as Ne}from"./check-nZeBL_GS.js";import{P as Ce,M as _e}from"./paperclip--LVe8flp.js";import{C as Fe}from"./calendar-CLQT2--9.js";import"./auth-in9l8hlf.js";import"./vendor-firebase-DnNwiSSY.js";import"./vendor-select-DbJAgDSj.js";import"./workspaceMembers-mKunQ_Ga.js";import"./MiloProModal-BhWYr3_j.js";import"./LockedChecklist-D0JHVZON.js";import"./InfoTooltip-Ci48YrBM.js";import"./workspacePermissions-CpagWCcX.js";import"./plus-DsElQDY9.js";import"./loader-circle-DYBjTSyn.js";import"./chevron-down-DGFsUP3D.js";import"./crown-CDeLb5OG.js";import"./postOnboarding-DY5nO3HR.js";import"./pencil-T7pJ4Lfk.js";import"./house-B4FumM_3.js";import"./log-out-RfP0l2og.js";import"./user-CDk7Y6rw.js";import"./user-round-CZW--Hno.js";import"./template-bUP7O4e2.js";import"./industries-BGfpIx6V.js";import"./milo-logo-VIUzRCaq.js";import"./usePricing-D-yi-eXS.js";import"./billing-BvxUDs_S.js";import"./HoverTooltip-Bkr7NYNK.js";const w=c=>c?c.charAt(0).toUpperCase()+c.slice(1):"";function ds(){var I,k,E,$,z,A,L,P;const{id:c}=ye(),[B]=be(),d=B.get("collaborator"),v=je(),[f,h]=i.useState(!1),[r,H]=i.useState(null),[R,g]=i.useState(!0),[N,W]=i.useState(null),[G,C]=i.useState(!1),[_,F]=i.useState(!1),[Y,S]=i.useState(!1),[Q,T]=i.useState(!1),[p,V]=i.useState("All"),D=s=>{if(!s)return null;try{const t=s.lastIndexOf("/");if(t===-1)return s;const l=s.substring(0,t+1),o=s.substring(t+1),n=decodeURIComponent(o);if(n.includes(" ")){const a=encodeURIComponent(n);return l+a}return s}catch(t){return console.warn("Error encoding image URL:",s,t),s}},y=(()=>{if(!d||!(r!=null&&r.team_members))return d;const s=r==null?void 0:r.team_members.find(t=>{var l;return((l=t.email)==null?void 0:l.toLowerCase())===d.toLowerCase()});return(s==null?void 0:s.name)||d})(),q=((k=(I=r==null?void 0:r.tasks)==null?void 0:I.filter(s=>s.is_completed))==null?void 0:k.length)||0,M=((E=r==null?void 0:r.tasks)==null?void 0:E.length)||0,J=s=>{if(!s)return["All"];const t=new Set;let l=!1;s.forEach(a=>{(a.due_date&&O(a.due_date)&&!a.is_completed||!a.due_date&&a.is_due&&!a.is_completed)&&(l=!0);const u=a.frequencies||(a.frequency?[a.frequency]:[]);if(u.length>0&&!(u.length===1&&u[0]==="once")){const m=U(u);m&&t.add(m)}});const o=["All","Daily","Weekly","Monthly","Quarterly","Yearly","Overdue"],n=[];return o.forEach(a=>{(a==="All"||a==="Overdue"&&l||t.has(a))&&n.push(a)}),n},U=s=>{const t=s.filter(n=>n!=="once");if(t.length===0)return null;const l=t.filter(n=>["daily","weekly","monthly","quarterly","yearly"].includes(n));if(l.length>0)return l[0].charAt(0).toUpperCase()+l[0].slice(1);if(t.includes("weekday"))return"Daily";const o=t.filter(n=>["monday","tuesday","wednesday","thursday","friday","saturday","sunday"].includes(n));return o.length===1?"Weekly":o.length>=2?"Daily":null},O=s=>{if(!s)return!1;const t=new Date(s),l=new Date;return l.setHours(0,0,0,0),t.setHours(0,0,0,0),t<l},K=s=>{if(!s)return"";const[t]=s.split("T"),[l,o,n]=t.split("-"),a=new Date;a.setFullYear(parseInt(l),parseInt(o)-1,parseInt(n)),a.setHours(12,0,0,0);const u=new Date,m=new Date(u);m.setHours(12,0,0,0);const b=new Date(m);b.setDate(b.getDate()+1);const j=new Date(m);return j.setDate(j.getDate()-1),a.getTime()===m.getTime()?"Today":a.getTime()===b.getTime()?"Tomorrow":a.getTime()===j.getTime()?"Yesterday":a.toLocaleDateString("en-us",{month:"short",day:"numeric"})},X=J(r==null?void 0:r.tasks),Z=s=>{const t=s.frequencies||(s.frequency?[s.frequency]:[]);if(t.length===0||t.length===1&&t[0]==="once")return null;const{fill:l,stroke:o}=x(s.bg_color);if(t.includes("weekday"))return e.jsx("div",{className:"flex items-center space-x-1 flex-row",children:["Mon","Tue","Wed","Thu","Fri"].map(a=>e.jsx("div",{style:{backgroundColor:l?`${l}15`:"#fff",color:o||"#000"},className:"px-1 py-0.5 rounded-md text-[10px] font-medium",children:a.charAt(0).toUpperCase()+a.slice(1)},a))});const n=t.filter(a=>["daily","weekly","monthly","quarterly","yearly"].includes(a));return n.length>0?e.jsx("div",{className:"flex items-center space-x-1 flex-row",children:n.map(a=>e.jsx("div",{style:{backgroundColor:l?`${l}20`:"#fff",color:o||"#000"},className:"px-1 py-0.5 rounded-md text-[10px] font-medium",children:w(a)},w(a)))}):e.jsx("div",{className:"flex items-center space-x-1 flex-row",children:t.map(a=>e.jsx("div",{style:{backgroundColor:l?`${l}20`:"#fff",color:o||"#000"},className:"px-1 py-0.5 rounded-md text-[10px] font-medium",children:a.substring(0,1).toUpperCase()+a.substring(1,3)},w(a)))})};i.useEffect(()=>{c&&(async()=>{try{g(!0);const t=await fe(c);H(t),g(!1)}catch(t){console.error("Error fetching checklist insights:",t),W("Failed to load checklist details"),g(!1)}})()},[c]);const ee=async()=>{try{F(!0),await he(c,"",d),C(!0)}catch(s){console.error("Error sending thumbs up:",s),alert("Failed to send thumbs up. Please try again.")}finally{F(!1)}},se=()=>{S(!0)},te=async s=>{try{await ge(c,s,d),T(!0)}catch(t){throw console.error("Error sending feedback:",t),t}},re=(($=r==null?void 0:r.tasks)==null?void 0:$.filter(s=>{if(p==="All")return!0;
1if(p==="Overdue")return s.due_date&&O(s.due_date);const t=s.frequencies||(s.frequency?[s.frequency]:[]);return U(t)===p}))||[],ae=s=>s.image?{backgroundImage:`url(${D(s.image)})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}:s.gradient?{background:`linear-gradient(to top, ${s.gradient})`}:{background:`linear-gradient(to top, ${s.color||"#6fc6c3"}, ${s.color?`${s.color}50`:"white"})`};return e.jsxs("div",{className:"flex flex-col h-screen bg-gray-200 font-poppins",children:[e.jsx("div",{className:"md:block hidden",children:e.jsx(ne,{onMenuClick:()=>h(!f),currentPage:"Checklist Insight"})}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(le,{isOpen:f,onClose:()=>h(!1),className:"md:block hidden"}),e.jsx("main",{className:"flex-1 bg-gray-50 md:p-8 overflow-auto",children:R?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(de,{className:"animate-spin h-10 w-10 text-gray-500"}),e.jsx("span",{className:"ml-2 text-gray-500",children:"Loading checklist insights..."})]}):N?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx("div",{className:"text-red-500 text-xl mb-4",children:N}),e.jsx("button",{onClick:()=>v(-1),className:"px-4 py-2 bg-gray-200 rounded-lg hover:bg-gray-300",children:"Go Back"})]}):r?e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"rounded-b-[30px] md:rounded-[30px] p-8 w-full relative",style:ae(r),children:e.jsxs("div",{className:"w-full flex justify-center items-center",children:[e.jsxs("div",{className:"flex absolute top-8 left-8 right-8 items-center justify-between",children:[e.jsxs("button",{className:"flex items-center gap-1 text-white bg-black hover:cursor-pointer hover:text-neutral-700 hover:bg-white transition-colors rounded-full pl-2 pr-3 py-1",onClick:()=>v(-1),children:[e.jsx(we,{size:20}),e.jsx("span",{className:"text-sm",children:"Back"})]}),e.jsx("div",{className:"flex items-center gap-3 md:hidden",children:e.jsx("button",{onClick:()=>h(!f),children:e.jsx(oe,{size:20})})})]}),e.jsxs("div",{className:"relative mb-4 mt-10 rounded-[20px] bg-white md:w-[700px] w-full p-8 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"overflow-hidden",style:{maxWidth:"calc(100% - 48px)"},children:[e.jsx("h2",{className:"text-xl font-semibold",children:r.title}),e.jsx("p",{className:"text-gray-600",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-gray-500",children:[(r==null?void 0:r.created_by)&&e.jsxs("span",{children:["Created by: ",r.created_by.username||r.created_by.name||r.created_by.email||""]}),((z=r==null?void 0:r.last_edited_by)==null?void 0:z.username)&&((A=r==null?void 0:r.last_edited_by)==null?void 0:A.username)!==((L=r==null?void 0:r.created_by)==null?void 0:L.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:"â¢"}),e.jsxs("span",{children:["Edited by: ",r.last_edited_by.username]})]})]})]})}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex -space-x-2",children:(P=r.collaborators)==null?void 0:P.map((s,t)=>{const l=s.profile_picture||s.avatar,o=ie(s,`Collaborator ${t+1}`),n=ce(s);return e.jsxs("div",{className:"group relative",children:[l?e.jsx("img",{src:D(l),alt:o,className:"h-8 w-8 rounded-full border-2 border-white object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded-full bg-gray-200 border-2 border-white flex items-center justify-center text-xs text-gray-600",children:n}),e.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 -top-9 z-20 hidden group-hover:block bg-black text-white text-xs rounded px-2 py-1 whitespace-nowrap shadow-lg pointer-events-none min-w-max",children:o})]},t)})}),e.jsxs("div",{className:"ml-4 text-sm font-medium bg-black px-2 py-1 rounded-[32px] text-white",children:[q,"/",M]})]}),e.jsx("div",{className:"mt-3",children:e.jsx("div",{className:"w-full h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#59A6B6] rounded-full",style:{width:`${q*100/(M||1)}%`}})})})]})]})}),e.jsxs("div",{className:"mt-[-28px] relative z-0 px-4 w-full flex justify-center gap-4",children:[d&&e.jsx("button",{className:"w-44 py-2.5 flex items-center justify-center gap-2 rounded-2xl bg-black text-white disabled:opacity-70 hover:cursor-pointer text-sm",onClick:ee,disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:18}),"Send a thumbs up"]})}),e.jsxs("button",{className:"w-44 py-2.5 flex items-center justify-center gap-2 rounded-2xl bg-black text-white hover:cursor-pointer text-sm",onClick:se,children:[e.jsx(ve,{size:18}),"Give feedback"]})]}),e.jsx("div",{className:"mt-8 px-4 max-w-2xl mx-auto",children:e.jsx("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide",children:e.jsx("div",{className:"flex gap-2 min-w-max",children:X.map(s=>e.jsx("button",{onClick:()=>V(s),className:`rounded-full px-4 py-2 text-sm whitespace-nowrap hover:cursor-pointer flex-shrink-0 ${p===s?"bg-black text-white":"bg-white text-gray-600"}`,children:s},s))})})}),e.jsx("div",{className:"mt-6 space-y-0 px-4 max-w-2xl mx-auto
1scrollbar-hide",children:re.map(s=>{var o;const{fill:t,stroke:l}=x(s.bg_color);return e.jsx("div",{className:"w-full bg-white shadow-[2px_2px_2px_2px_rgba(0,0,0,0.10)] mb-1.5 p-1 rounded-xl font-poppins",children:e.jsx("div",{className:"w-full rounded-lg p-2",style:{backgroundColor:t?`${t}15`:"#F2F3F5"},children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("button",{className:"w-5 h-5 rounded-full border-2 flex justify-center items-center cursor-default flex-shrink-0",style:{borderColor:l||"#gray-300",backgroundColor:s.is_completed?t:"transparent"},disabled:!0,children:s.is_completed&&e.jsx(Ne,{size:12,color:"white"})}),e.jsxs("div",{className:"flex flex-col max-w-[190px] md:max-w-full",children:[e.jsxs("div",{className:"text-left leading-tight",style:{color:"#gray-600"},children:[e.jsx("span",{className:"inline",children:s.title}),e.jsxs("span",{className:"inline-flex items-center gap-1 ml-1 align-baseline",children:[((o=s.files)==null?void 0:o.length)>0&&e.jsx(Ce,{size:14,className:"text-current opacity-70"}),s.comment&&e.jsx(_e,{size:14,className:"text-current opacity-70"})]})]}),e.jsxs("div",{className:"flex flex-col space-y-1 md:space-x-1 md:flex-row",children:[e.jsx("div",{className:"text-xs min-w-max",style:{color:"#gray-600"},children:s.assigned_to?`Assigned to: ${s.assigned_to}`:"Unassigned"}),e.jsxs("div",{className:"flex flex-row",children:[(s.frequencies&&s.frequencies.length>0&&!(s.frequencies.length===1&&s.frequencies[0]==="once")||!!s.due_date)&&e.jsx(e.Fragment,{children:e.jsx(Fe,{className:"min-h-4 min-w-4 md:h-4 md:w-4 mr-2 mb-1 md:mb-0 md:mr-1 md:ml-2"})}),Z(s),s.due_date&&(()=>{const n=K(s.due_date);return e.jsx("div",{style:{backgroundColor:x(s.bg_color).fill?`${x(s.bg_color).fill}15`:"#fff",color:x(s.bg_color).stroke||"#000"},className:"px-1 py-0.5 rounded-md text-[10px] font-medium",children:n})})()]})]})]})]}),e.jsxs("div",{className:"flex flex-col items-end flex-shrink-0",children:[e.jsx("span",{className:"text-sm font-medium",style:{color:l||"#6B7280"},children:s.is_completed?"Completed":"Not Completed"}),s.completed_by&&e.jsx("span",{className:"text-xs",style:{color:"#gray-600"},children:`Completed by: ${s.completed_by}`})]})]})})},s.id)})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-gray-500",children:"Checklist not found"})})})]}),e.jsx(ue,{isOpen:G,onClose:()=>C(!1),collaboratorEmail:y}),e.jsx(xe,{isOpen:Y,onClose:()=>S(!1),onSendFeedback:te,collaboratorEmail:y}),e.jsx(pe,{isOpen:Q,onClose:()=>T(!1),collaboratorEmail:y})]})}export{ds as default}; 2//# sourceMappingURL=ChecklistInsight-B_P_Hv0H.js.map
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.