1import{c as n,K as B,j as e,a4 as J,a_ as ie,aq as ce,aT as de,bd as ue,be as me,aX as xe,aW as he,c7 as be,cV as pe,aS as fe,aj as je}from"./vendor-1kUQ7zn2.js";import{aW as ve,bE as ge,aQ as r,bF as we,bG as V,bH as Ne,bI as Ce,aK as De,aJ as ke,bJ as ye,be as H,bK as W,bL as Se,aE as Te,bM as Ee,S as Me,Q as Fe,R as Re,c as E,aM as Ae,bN as Ie,bO as Le,bP as qe,bQ as Oe,bR as $e}from"./index--kdl1ae9.js";import Pe from"./TaskCommentsDialog-BnBwvN69.js";import{D as T,F as Qe,I as _e}from"./vendor-date-en1IyhsK.js";import"./vendor-supabase-Dh2gyaRa.js";import"./vendor-motion-BX-jsy7E.js";import"./textarea-eVnMW_FJ.js";const Ue="border-primary/40 bg-primary/10 text-foreground",C={do:{label:"Do First"},schedule:{label:"Schedule"},delegate:{label:"Delegate"},backlog:{label:"Backlog"}},X=["do","schedule","delegate","backlog"],Be=({open:p,task:t,quadrant:o,apiKey:m,onTaskUpdate:f,onComplete:d,onClose:i})=>{const j=o?C[o.toLowerCase()]:null,G=ve(s=>s.projectNames),[w,M]=n.useState(!1),[N,F]=n.useState(!1);n.useEffect(()=>{p||(M(!1),F(!1))},[p]);const R=n.useRef(null),A=n.useRef(null),I=s=>{if(!s)return;const a=!window.matchMedia("(prefers-reduced-motion: reduce)").matches;requestAnimationFrame(()=>s.scrollIntoView({block:"nearest",behavior:a?"smooth":"auto"}))};n.useEffect(()=>{w&&I(R.current)},[w]),n.useEffect(()=>{N&&I(A.current)},[N]);const l=n.useCallback(s=>{i(),window.setTimeout(()=>{s()},60)},[i]),x=ge(t),K=n.useCallback(()=>{x&&(r(8),l(()=>x.activate()))},[x,l]),Y=n.useCallback(()=>{t&&(r(20),l(()=>d(t.id)))},[t,d,l]),z=n.useCallback(()=>{if(!t)return;r(20);const s=t;l(()=>we(s,()=>{d(s.id)},180))},[t,d,l]),L=n.useCallback((s,a)=>{if(!t)return;r(12);const u=a===void 0?V(t.due):a;l(()=>Ne(t.id,s,u,!!t.due?.isRecurring,{kind:a===void 0?"date":"time"}))},[t,l]),Z=n.useCallback(s=>{if(!t||!m)return;const a=(o||"").toLowerCase();if(s===a){i();return}r(12),l(async()=>{const u=Ce(`Moving to ${C[s].label}â¦`,"mx-move");try{const b=new De(m);b.setUseDirectApiFirst(!0);const S=ke(t.labels,s);await b.updateTaskLabels(t.id,S);const v=`Moved to ${C[s].label}`,g=X.includes(a)?a:null,U={label:"View",onClick:()=>ye(s)};B.success(H(v),g?{id:u,duration:W,className:"has-undo",style:{"--toast-dur":`${W}ms`},cancel:U,action:{label:"Undo",onClick:()=>window.dispatchEvent(new CustomEvent("matrix:move-tasks",{detail:{ids:[t.id],to:g,from:{}}}))}}:{id:u,cancel:U}),await f()}catch{B.error(H("Failed to move task"),{id:u})}})},[t,m,o,f,l,i]),ee=n.useCallback(s=>{t&&(r(12),l(()=>{window.dispatchEvent(new CustomEvent("task:set-deadline",{detail:{taskId:t.id,date:s?T(s,"yyyy-MM-dd"):null}}))}))},[t,l]),se=n.useCallback(()=>{t&&(r(12),l(()=>{window.dispatchEvent(new CustomEvent("task:open-focus",{detail:{taskId:t.id}}))}))},[t,l]),[D,q]=n.useState(null),te=n.useCallback(()=>{if(!t)return;r(8);const s={id:t.id,title:t.content||t.title||""};l(()=>q(s))},[t,l]),O=D&&e.jsx(Pe,{isOpen:!0,onClose:()=>q(null),taskId:D.id,apiKey:m,taskTitle:D.title}),ae=n.useCallback(()=>{if(!t)return;r(12);const s=t,a=(o||"").toLowerCase()||void 0;i(),window.setTimeout(()=>Se({taskId:s.id,via:"sheet",quadrant:a,task:s}),180)},[t,o,i]),ne=n.useCallback(()=>{t&&(r(8),l(()=>{window.open(`https://todoist.com/app/task/${t.id}`,"_blank")}))},[t,l]);if(!t)return O||null;const le=t.content||t.title||"",$=(o||"").toLowerCase(),h=Te(t.due)??void 0,k=t.deadline?.date?Qe(t.deadline.date):void 0,P=!!t.due?.isRecurring,oe=new Date,y=G[t.project_id],Q=V(t.due),re=[h?Ee(t,oe):null,y&&y!=="Inbox"?y:null].filter(Boolean),_=(s,a,u,b,S,v)=>e.jsxs("div",{ref:S,className:"px-2 pb-1 pt-1 scroll-mb-4",children:[e.jsx(Le,{value:s,onPick:a,accentClass:b,variant:"sheet"}),e.jsx("div",{className:"mt-3 flex justify-center",children:e.jsx(qe,{mode:"single",selected:s,onSelect:g=>g&&a(g),initialFocus:!0,className:"rounded-md p-0",classNames:{caption:"flex justify-center relative items-center min-h-[44px]"}})}),v&&e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:v.value,onChange:v.onChange,accentClass:b,inSheet:!0})}),s&&e.jsxs("button",{type:"button",onClick:()=>a(null),className:"mt-1 w-full h-11 flex items-center justify-center gap-1.5 rounded-lg text-[13px] font-medium text-muted-foreground active:bg-muted/60 transition-colors",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),u]})]});return e.jsxs(e.Fragment,{children:[e.jsx(Me,{open:p,onOpenChange:s=>!s&&i(),children:e.jsxs(Fe,{side:"bottom",onOpenAutoFocus:s=>{s.preventDefault(),s.target?.focus()},className:E("mx-sheet p-0 rounded-t-2xl border-t border-border/60","max-h-[85dvh] overflow-y-auto overscroll-contain","data-[state=open]:duration-200 data-[state=closed]:duration-150","[&>button]:hidden"),children:[e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-muted-foreground
1/30","aria-hidden":!0})}),e.jsxs("div",{className:"relative px-5 pt-3 pb-3 pr-14",children:[e.jsx("button",{type:"button",className:"mx-sheet-close",onClick:i,"aria-label":"Close",children:e.jsx(J,{"aria-hidden":!0})}),x&&e.jsxs("button",{type:"button",className:"mx-sheet-parent","data-qa":"sheet-parent",onClick:K,children:[e.jsx(ie,{"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:x.known?e.jsxs(e.Fragment,{children:["Subtask of ",e.jsx("b",{children:x.text})]}):"Subtask"})]}),e.jsx(Re,{className:"text-[17px] font-semibold leading-snug line-clamp-2 break-words",children:le}),e.jsxs("p",{className:"mt-1 flex items-center gap-1.5 text-[13px] text-muted-foreground",children:[j&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:`rgb(var(--q-${$}))`},"aria-hidden":!0}),e.jsx("span",{children:j.label})]}),re.map(s=>e.jsxs("span",{className:"truncate",children:[e.jsx("span",{"aria-hidden":!0,children:"· "}),s]},s))]})]}),e.jsx("div",{className:"mx-3 h-px bg-border/60"}),e.jsxs("div",{className:"px-3 pt-2 pb-1",role:"group","aria-labelledby":"mx-sheet-move",children:[e.jsx("div",{id:"mx-sheet-move",className:"px-3 pb-1 pt-1 text-[12px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Move to"}),X.map(s=>{const a=s===$;return e.jsxs("button",{type:"button","data-quadrant-choice":s,"aria-current":a||void 0,onClick:()=>Z(s),className:"w-full flex items-center gap-3 px-3 h-[52px] rounded-xl text-left text-[15px] active:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{background:`rgb(var(--q-${s}))`}})}),e.jsx("span",{className:E("flex-1",a&&"font-semibold"),children:C[s].label}),a&&e.jsx(ce,{className:"h-4 w-4 text-muted-foreground","aria-label":"current quadrant"})]},s)})]}),e.jsx("div",{className:"mx-3 h-px bg-border/60"}),e.jsxs("div",{className:"px-3 pt-1 pb-2",children:[e.jsx(c,{icon:e.jsx(de,{className:"h-4 w-4"}),label:"Complete",tint:"var(--q-done)",onClick:Y}),e.jsx(c,{icon:e.jsx(ue,{className:"h-4 w-4"}),label:"Complete & follow up",tint:"var(--q-delegate)",onClick:z}),e.jsx(c,{icon:e.jsx(me,{className:"h-4 w-4"}),label:"Focus on this task",tint:"var(--q-focus)",onClick:se}),e.jsx(c,{icon:e.jsx(xe,{className:"h-4 w-4"}),label:P?"Recurring, edit in Todoist":h?`Due · ${Ae(T(h,"MMM d"),h,!!Q)}`:"Set due date",tint:"var(--q-schedule)",onClick:()=>M(s=>!s),disabled:P,expanded:w}),w&&_(h,s=>L(s),"Clear due date",Ue,R,{value:Q,onChange:s=>L(h??_e(),s??null)}),e.jsx(c,{icon:e.jsx(he,{className:"h-4 w-4"}),label:k?`Deadline · ${T(k,"MMM d")}`:"Set deadline",tint:"var(--q-late)",onClick:()=>F(s=>!s),expanded:N}),N&&_(k,ee,"Clear deadline",$e,A),e.jsx(c,{icon:e.jsx(be,{className:"h-4 w-4"}),label:"Comments",onClick:te,chevron:!0}),e.jsx(c,{icon:e.jsx(pe,{className:"h-4 w-4"}),label:"Open in Todoist",onClick:ne})]}),e.jsx("div",{className:"mx-sheet-subtasks px-5 empty:hidden",children:e.jsx(Ie,{parentTaskId:t.id,variant:"sheet",defaultOpen:!0,onCompleteSubtask:s=>{r(15),d(s)}})}),e.jsxs("div",{className:"px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]",children:[e.jsx("div",{className:"mx-1 mb-1 h-px bg-border/60","aria-hidden":!0}),e.jsx(c,{icon:e.jsx(fe,{className:"h-4 w-4"}),label:"Delete task",tint:"var(--q-late)",danger:!0,onClick:ae})]})]})}),O]})};Be.displayName="MobileTaskActionSheet";const c=({icon:p,label:t,tint:o,onClick:m,disabled:f,expanded:d,chevron:i,danger:j})=>e.jsxs("button",{type:"button",onClick:m,disabled:f,"aria-expanded":d,"data-action":j?"delete":void 0,className:E("w-full flex items-center gap-3 px-3 h-[52px] rounded-xl text-left text-[15px] font-medium","active:bg-muted/60 transition-colors",f&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg shrink-0",style:{backgroundColor:o?`rgb(${o} / 0.14)`:"hsl(var(--muted))",color:o?`rgb(${o})`:"hsl(var(--muted-foreground))"},children:p}),e.jsx("span",{className:"flex-1",style:j&&o?{color:`rgb(${o})`}:void 0,children:t}),i&&e.jsx(je,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0})]});
1export{Be as MobileTaskActionSheet};
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.