vendor: 5,531 bytes, line 1
1import{c,j as e,d0 as ke,R as H,d1 as tt,d2 as st,d3 as at,d4 as Zt,d5 as Ge,cX as nt,N as Xt,aq as W,Y as Jt,cq as ze,cI as Ve,d6 as es,a$ as ts,ay as rt,a4 as ot,aa as je,ac as lt,az as ss,aH as as,bx as ns,aA as rs,d7 as os,bQ as ls,ab as is,K as q,L as cs}from"./vendor-1kUQ7zn2.js";import{c as A,g as ee,a6 as ge,aP as it,aQ as ds,af as us,ag as ms,ah as fs,ai as xs,u as ps,aR as hs,a4 as gs,s as bs,aS as Te,aT as vs,aU as ys,B as M,D as js,a as Ns,b as ws,d as Cs,e as Ss,aV as Es,aW as As,aX as ks,aY as Ts,M as ct,N as Ie,aZ as Is,a_ as dt,a$ as ut,b0 as mt,b1 as ft,b2 as xt,b3 as fe,b4 as pt,b5 as Ds,b6 as Ls,b7 as Ms,b8 as Rs,aE as ht,h as Ps,i as Os,j as _s,aH as Fs,aI as $s,k as Us,a1 as ae,b9 as Ne,ba as Gs,bb as de,aO as me,C as zs,bc as Vs,w as Ks,bd as Bs,be as X,aK as Hs,aJ as qs,S as Qs,Q as Ws,bf as Ys,bg as Zs}from"./index--kdl1ae9.js";import{m as Y}from"./vendor-motion-BX-jsy7E.js";import{u as Xs,a as Js,b as J,c as ea,A as Ke,d as ta,e as Be,r as sa}from"./AiConsentDialog-CkXfz-s-.js";import{d as gt}from"./vendor-supabase-Dh2gyaRa.js";import{F as aa,a as na,j as bt,D as He}from"./vendor-date-en1IyhsK.js";import{S as ra}from"./scroll-area-Domx4w8f.js";function V(t,s,{checkForDefaultPrevented:a=!0}={}){return function(r){if(t?.(r),a===!1||!r.defaultPrevented)return s?.(r)}}function qe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function vt(...t){return s=>{let a=!1;const n=t.map(r=>{const o=qe(r,s);return!a&&typeof o=="function"&&(a=!0),o});if(a)return()=>{for(let r=0;r<n.length;r++){const o=n[r];typeof o=="function"?o():qe(t[r],null)}}}}function xe(...t){return c.useCallback(vt(...t),t)}var pe=c.forwardRef((t,s)=>{const{children:a,...n}=t,r=c.Children.toArray(a),o=r.find(la);if(o){const l=o.props.children,d=r.map(i=>i===o?c.Children.count(l)>1?c.Children.only(null):c.isValidElement(l)?l.props.children:null:i);return e.jsx(we,{...n,ref:s,children:c.isValidElement(l)?c.cloneElement(l,void 0,d):null})}return e.jsx(we,{...n,ref:s,children:a})});pe.displayName="Slot";var we=c.forwardRef((t,s)=>{const{children:a,...n}=t;if(c.isValidElement(a)){const r=ca(a),o=ia(n,a.props);return a.type!==c.Fragment&&(o.ref=s?vt(s,r):r),c.cloneElement(a,o)}return c.Children.count(a)>1?c.Children.only(null):null});we.displayName="SlotClone";var oa=({children:t})=>e.jsx(e.Fragment,{children:t});function la(t){return c.isValidElement(t)&&t.type===oa}function ia(t,s){const a={...s};for(const n in s){const r=t[n],o=s[n];/^on[A-Z]/.test(n)?r&&o?a[n]=(...d)=>{o(...d),r(...d)}:r&&(a[n]=r):n==="style"?a[n]={...r,...o}:n==="className"&&(a[n]=[r,o].filter(Boolean).join(" "))}return{...t,...a}}function ca(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,a=s&&"isReactWarning"in s&&s.isReactWarning;return a?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,a=s&&"isReactWarning"in s&&s.isReactWarning,a?t.props.ref:t.props.ref||t.ref)}function da(t){const s=t+"CollectionProvider",[a,n]=ke(s),[r,o]=a(s,{collectionRef:{current:null},itemMap:new Map}),l=h=>{const{scope:p,children:g}=h,y=H.useRef(null),v=H.useRef(new Map).current;return e.jsx(r,{scope:p,itemMap:v,collectionRef:y,children:g})};l.displayName=s;const d=t+"CollectionSlot",i=H.forwardRef((h,p)=>{const{scope:g,children:y}=h,v=o(d,g),b=xe(p,v.collectionRef);return e.jsx(pe,{ref:b,children:y})});i.displayName=d;const m=t+"CollectionItemSlot",u="data-radix-collection-item",f=H.forwardRef((h,p)=>{const{scope:g,children:y,...v}=h,b=H.useRef(null),w=xe(p,b),E=o(m,g);return H.useEffect(()=>(E.itemMap.set(b,{ref:b,...v}),()=>{E.itemMap.delete(b)})),e.jsx(pe,{[u]:"",ref:w,children:y})});f.displayName=m;function x(h){const p=o(t+"CollectionConsumer",h);return H.useCallback(()=>{const y=p.collectionRef.current;if(!y)return[];const v=Array.from(y.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((E,R)=>v.indexOf(E.ref.current)-v.indexOf(R.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:l,Slot:i,ItemSlot:f},x,n]}var ua=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],te=ua.reduce((t,s)=>{const a=c.forwardRef((n,r)=>{const{asChild:o,...l}=n,d=o?pe:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...l,ref:r})});return a.displayName=`Primitive.${s}`,{...t,[s]:a}},{}),ve="rovingFocusGroup.onEntryFocus",ma={bubbles:!1,cancelable:!0},be="RovingFocusGroup",[Ce,yt,fa]=da(be),[xa,jt]=ke(be,[fa]),[pa,ha]=xa(be),Nt=c.forwardRef((t,s)=>e.jsx(Ce.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Ce.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(ga,{...t,ref:s})})}));Nt.displayName=be;var ga=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:r=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:i,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...f}=t,x=c.useRef(null),h=xe(s,x),p=st(o),[g=null,y]=at({prop:l,defaultProp:d,onChange:i}),[v,b]=c.useState(!1),w=Zt(m),E=yt(a),R=c.useRef(!1),[K,D]=c.useState(0);return c.useEffect(()=>{const N=x.current;if(N)return N.addEventListener(ve,w),()=>N.removeEventListener(ve,w)},[w]),e.jsx(pa,{scope:a,orientation:n,dir:p,loop:r,currentTabStopId:g,onItemFocus:c.useCallback(N=>y(N),[y]),onItemShiftTab:c.useCallback(()=>b(!0),[]),onFocusableItemAdd:c.useCallback(()=>D(N=>N+1),[]),onFocusableItemRemove:c.useCallback(()=>D(N=>N-1),[]),children:e.jsx(te.div,{tabIndex:v||K===0?-1:0,"data-orientation":n,...f,ref:h,style:{outline:"none",...t.style},onMouseDown:V(t.onMouseDown,()=>{R.current=!0}
vendor: 4,493 bytes, line 1
1),onFocus:V(t.onFocus,N=>{const _=!R.current;if(N.target===N.currentTarget&&_&&!v){const P=new CustomEvent(ve,ma);if(N.currentTarget.dispatchEvent(P),!P.defaultPrevented){const C=E().filter(O=>O.focusable),L=C.find(O=>O.active),F=C.find(O=>O.id===g),se=[L,F,...C].filter(Boolean).map(O=>O.ref.current);St(se,u)}}R.current=!1}),onBlur:V(t.onBlur,()=>b(!1))})})}),wt="RovingFocusGroupItem",Ct=c.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:r=!1,tabStopId:o,...l}=t,d=tt(),i=o||d,m=ha(wt,a),u=m.currentTabStopId===i,f=yt(a),{onFocusableItemAdd:x,onFocusableItemRemove:h}=m;return c.useEffect(()=>{if(n)return x(),()=>h()},[n,x,h]),e.jsx(Ce.ItemSlot,{scope:a,id:i,focusable:n,active:r,children:e.jsx(te.span,{tabIndex:u?0:-1,"data-orientation":m.orientation,...l,ref:s,onMouseDown:V(t.onMouseDown,p=>{n?m.onItemFocus(i):p.preventDefault()}),onFocus:V(t.onFocus,()=>m.onItemFocus(i)),onKeyDown:V(t.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){m.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const g=ya(p,m.orientation,m.dir);if(g!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let v=f().filter(b=>b.focusable).map(b=>b.ref.current);if(g==="last")v.reverse();else if(g==="prev"||g==="next"){g==="prev"&&v.reverse();const b=v.indexOf(p.currentTarget);v=m.loop?ja(v,b+1):v.slice(b+1)}setTimeout(()=>St(v))}})})})});Ct.displayName=wt;var ba={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function va(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ya(t,s,a){const n=va(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return ba[n]}function St(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function ja(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var Na=Nt,wa=Ct;function Ca(t,s){return c.useReducer((a,n)=>s[a][n]??a,t)}var Et=t=>{const{present:s,children:a}=t,n=Sa(s),r=typeof a=="function"?a({present:n.isPresent}):c.Children.only(a),o=xe(n.ref,Ea(r));return typeof a=="function"||n.isPresent?c.cloneElement(r,{ref:o}):null};Et.displayName="Presence";function Sa(t){const[s,a]=c.useState(),n=c.useRef({}),r=c.useRef(t),o=c.useRef("none"),l=t?"mounted":"unmounted",[d,i]=Ca(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{const m=ue(n.current);o.current=d==="mounted"?m:"none"},[d]),Ge(()=>{const m=n.current,u=r.current;if(u!==t){const x=o.current,h=ue(m);t?i("MOUNT"):h==="none"||m?.display==="none"?i("UNMOUNT"):i(u&&x!==h?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,i]),Ge(()=>{if(s){let m;const u=s.ownerDocument.defaultView??window,f=h=>{const g=ue(n.current).includes(h.animationName);if(h.target===s&&g&&(i("ANIMATION_END"),!r.current)){const y=s.style.animationFillMode;s.style.animationFillMode="forwards",m=u.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=y)})}},x=h=>{h.target===s&&(o.current=ue(n.current))};return s.addEventListener("animationstart",x),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{u.clearTimeout(m),s.removeEventListener("animationstart",x),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else i("ANIMATION_END")},[s,i]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:c.useCallback(m=>{m&&(n.current=getComputedStyle(m)),a(m)},[])}}function ue(t){return t?.animationName||"none"}function Ea(t){let s=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,a=s&&"isReactWarning"in s&&s.isReactWarning;return a?t.ref:(s=Object.getOwnPropertyDescriptor(t,"ref")?.get,a=s&&"isReactWarning"in s&&s.isReactWarning,a?t.props.ref:t.props.ref||t.ref)}var De="Tabs",[Aa]=ke(De,[jt]),At=jt(),[ka,Le]=Aa(De),kt=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:r,defaultValue:o,orientation:l="horizontal",dir:d,activationMode:i="automatic",...m}=t,u=st(d),[f,x]=at({prop:n,onChange:r,defaultProp:o});return e.jsx(ka,{scope:a,baseId:tt(),value:f,onValueChange:x,orientation:l,dir:u,activationMode:i,children:e.jsx(te.div,{dir:u,"data-orientation":l,...m,ref:s})})});kt.displayName=De;var Tt="TabsList",It=c.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...r}
1=t,o=Le(Tt,a),l=At(a);return e.jsx(Na,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(te.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:s})})});It.displayName=Tt;var Dt="TabsTrigger",Lt=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:r=!1,...o}=t,l=Le(Dt,a),d=At(a),i=Pt(l.baseId,n),m=Ot(l.baseId,n),u=n===l.value;return e.jsx(wa,{asChild:!0,...d,focusable:!r,active:u,children:e.jsx(te.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":m,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:i,...o,ref:s,onMouseDown:V(t.onMouseDown,f=>{!r&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:V(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:V(t.onFocus,()=>{const f=l.activationMode!=="manual";!u&&!r&&f&&l.onValueChange(n)})})})});Lt.displayName=Dt;var Mt="TabsContent",Rt=c.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:r,children:o,...l}=t,d=Le(Mt,a),i=Pt(d.baseId,n),m=Ot(d.baseId,n),u=n===d.value,f=c.useRef(u);return c.useEffect(()=>{const x=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(x)},[]),e.jsx(Et,{present:r||u,children:({present:x})=>e.jsx(te.div,{"data-state":u?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":i,hidden:!x,id:m,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:x&&o})})});Rt.displayName=Mt;function Pt(t,s){return`${t}-trigger-${s}`}function Ot(t,s){return`${t}-content-${s}`}var Ta=kt,_t=It,Ft=Lt,$t=Rt;const Ia=Ta,Ut=c.forwardRef(({className:t,...s},a)=>e.jsx(_t,{ref:a,className:A("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Ut.displayName=_t.displayName;const Se=c.forwardRef(({className:t,...s},a)=>e.jsx(Ft,{ref:a,className:A("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...s}));Se.displayName=Ft.displayName;const Ee=c.forwardRef(({className:t,...s},a)=>e.jsx($t,{ref:a,className:A("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));Ee.displayName=$t.displayName;function Da(t,s=[]){let a=[];function n(o,l){const d=c.createContext(l),i=a.length;a=[...a,l];function m(f){const{scope:x,children:h,...p}=f,g=x?.[t][i]||d,y=c.useMemo(()=>p,Object.values(p));return e.jsx(g.Provider,{value:y,children:h})}function u(f,x){const h=x?.[t][i]||d,p=c.useContext(h);if(p)return p;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return m.displayName=o+"Provider",[m,u]}const r=()=>{const o=a.map(l=>c.createContext(l));return function(d){const i=d?.[t]||o;return c.useMemo(()=>({[`__scope${t}`]:{...d,[t]:i}}),[d,i])}};return r.scopeName=t,[n,La(r,...s)]}function La(...t){const s=t[0];if(t.length===1)return s;const a=()=>{const n=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(o){const l=n.reduce((d,{useScope:i,scopeName:m})=>{const f=i(o)[`__scope${m}`];return{...d,...f}},{});return c.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return a.scopeName=s.scopeName,a}var Me="Progress",Ma=100,[Ra]=Da(Me),[Pa,Oa]=Ra(Me),Gt=c.forwardRef((t,s)=>{const{__scopeProgress:a,value:n=null,max:r,getValueLabel:o=_a,...l}=t;(r||r===0)&&Qe(r);const d=Qe(r)?r:Ma;n!==null&&We(n,d);const i=We(n,d)?n:null,m=he(i)?o(i,d):void 0;return e.jsx(Pa,{scope:a,value:i,max:d,children:e.jsx(nt.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":he(i)?i:void 0,"aria-valuetext":m,role:"progressbar","data-state":Kt(i,d),"data-value":i??void 0,"data-max":d,...l,ref:s})})});Gt.displayName=Me;var zt="ProgressIndicator",Vt=c.forwardRef((t,s)=>{const{__scopeProgress:a,...n}=t,r=Oa(zt,a);return e.jsx(nt.div,{"data-state":Kt(r.value,r.max),"data-value":r.value??void 0,"data-max":r.max,...n,ref:s})});Vt.displayName=zt;function _a(t,s){return`${Math.round(t/s*100)}%`}function Kt(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function he(t){return typeof t=="number"}function Qe(t){return he(t)&&!isNaN(t)&&t>0}function We(t,s){return he(t)&&!isNaN(t)&&t<=s&&t>=0}var Bt=Gt,Fa=Vt;const Ae=c.forwardRef(({className:t,value:s,indicatorClassName:a,...n},r)=>e.jsx(Bt,{ref:r,className:A("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...n,children:e.jsx(Fa,{className:A("h-full w-full flex-1 bg-primary transition-all",a),style:{transform:`translateX(-${100-(s||0)}%)`}})}));Ae.displayName=Bt.displayName;const $a=({currentTask:t,totalTasks:s,isBulkRecategorization:a=!1})=>{const n=ee(),r=s>0?t/s*100:0;return n?e.jsxs("div",{className:"space-y-3 text-left",children:[e.jsxs("div",{className:"flex min-h-[44px] items-center justify-between gap-3 pr-12",children:[e.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",children:a?"Recategorize":"Sort tasks"}),e.jsx("span",{className:"shrink-0 text-[13px] font-medium text-muted-foreground tabular-nums","aria-live":"polite",children:a?`${t} of ${s} done`:`${t} of ${s}`})]}),e.jsx(Ae,{value:r,className:"w-full h-1.5"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-baseline gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:a?"Recategorize":"Categorize"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground tabular-nums shrink-0","aria-live":"polite",children:a?`${t} of ${s} done`:`${t} of ${s}`})]}),e.jsx(Ae,{value:r,className:"w-full h-2"})]})},Ht=({onLabelTask:t,taskIds:s,disabled:a})=>e.jsx("div",{className:"grid grid-cols-2 gap-2.5 relative z-10",children:ge.map(n=>e.jsx(Ua,{meta:n,count:s.length,disabled:a,onClick:()=>t(n.label,s)},n.label))}),Ua=({meta:t,count:s,disabled:a,onClick:n})=>{const r=t.icon;return e.jsxs(Y.button,{type:"button","data-testid":`quadrant-btn-${t.label}`,onClick:n,disabled:a,initial:"idle",whileHover:a?void 0:"hover",whileTap:a?void 0:"tap",variants:{idle:{scale:1,y:0},hover:{scale:1.02,y:-2},tap:{scale:.97,y:0}},transition:{duration:.18,ease:[.22,1,.36,1]},className:A("group relative flex items-center gap-3 p-3 rounded-2xl text-left","border bg-card overflow-hidden","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","transition-shadow duration-200",a?"opacity-45 cursor-not-allowed":"cursor-pointer hover:shadow-lg"),style:{borderColor:`${t.color}40`,"--tw-ring-color":`${t.color}80`}
1,children:[e.jsx("span",{"aria-hidden":!0,className:"absolute inset-0 opacity-60 group-hover:opacity-100 transition-opacity duration-200",style:{background:`linear-gradient(135deg, ${t.tint}, transparent 70%)`}}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-0 bottom-0 w-1",style:{backgroundColor:t.color}}),e.jsx("span",{className:"relative flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl shadow-sm",style:{backgroundColor:t.color,color:"#fff"},children:e.jsx(r,{className:"h-[18px] w-[18px]"})}),e.jsxs("span",{className:"relative flex flex-col min-w-0",children:[e.jsx("span",{className:"font-bold text-sm leading-tight",style:{color:t.color},children:t.title}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-2",children:t.subtitle}),!a&&s>1&&e.jsxs("span",{className:"mt-1 text-[10px] font-semibold w-fit px-1.5 py-0.5 rounded-full",style:{backgroundColor:`${t.color}1f`,color:t.color},children:["Apply to ",s]})]})]})},qt=({onLabelTask:t,taskIds:s,disabled:a,current:n})=>{const[r,o]=c.useState(null),l=c.useRef(void 0);return c.useEffect(()=>()=>window.clearTimeout(l.current),[]),e.jsx("div",{className:"mx-sort-tiles",role:"group","aria-label":"Move to",children:ge.map((d,i)=>{const m=it[i];return e.jsxs("button",{type:"button","data-testid":`quadrant-btn-${d.label}`,className:A("mx-sort-tile",r===d.label&&"is-flash"),style:{"--q":`var(--q-${m.id})`},disabled:a,"aria-current":n===m.id||void 0,onClick:()=>{ds(10),o(d.label),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(null),120),t(d.label,s)},children:[e.jsxs("span",{className:"mx-sort-tile-name",children:[e.jsx("span",{className:"mx-dot","aria-hidden":!0}),m.label]}),e.jsx("span",{className:"mx-sort-tile-line",children:m.meaning})]},d.label)})})},Qt=()=>{const[t,s]=c.useState(!1),a=c.useCallback((n,r)=>{const{content:o,side:l="bottom",align:d="center",delayDuration:i=300,className:m}=r;return e.jsx(us,{children:e.jsxs(ms,{children:[e.jsx(fs,{asChild:!0,onClick:()=>s(!0),children:n}),e.jsx(xs,{side:l,align:d,className:A("z-50",m),sideOffset:5,children:o})]})})},[t]);return{isOpen:t,setIsOpen:s,renderTooltip:a}},Ga=()=>{const{session:t}=gt.useSessionContext(),{toast:s}=ps(),a=t?.user?.id,{data:n,isLoading:r,error:o}=Xt({queryKey:["subscription-status",a],queryFn:async()=>{try{if(!a)return null;const{data:i,error:m}=await bs.from("profiles").select("id, payment_status, trial_end_date, is_lifetime_purchase, subscription_type, subscription_expiry_date, gumroad_subscription_status, email").eq("id",a).single();if(m)throw m;return i}catch{return s({title:"Error",description:"Failed to fetch subscription status",variant:"destructive"}),null}},enabled:!!a,staleTime:60*1e3}),l=hs(n),d=gs(n?.trial_end_date)??0;return{data:n,isLoading:r,error:o,hasAccess:l,daysLeft:d,paymentStatus:n?.payment_status}},ne={do:{label:"Do First",token:"--q-do",key:"DO"},schedule:{label:"Schedule",token:"--q-schedule",key:"SCHEDULE"},delegate:{label:"Delegate",token:"--q-delegate",key:"DELEGATE"},backlog:{label:"Backlog",token:"--q-backlog",key:"BACKLOG"}},Wt="You've used your free AI suggestions. Upgrade for unlimited.",Ye=(t,s)=>{switch(t){case"limit_reached":return s==="trial"?Wt:"That's today's AI suggestions. More tomorrow.";case"rate_limited":return"A lot of requests at once. Try again in a minute.";case"consent_required":return"AI suggestions are off. Turn them on to continue.";case"no_tasks":return"Nothing left to suggest here.";default:return"Couldn't get suggestions right now. Try again in a moment."}},za=t=>{const s=J(a=>a.byId);return c.useMemo(()=>t.map(a=>s[a.id]).filter(Boolean),[t,s])},Va=({tasks:t,examples:s,onAcceptAll:a,apiKey:n="",compact:r=!1})=>{const{consented:o,outdated:l,isLoading:d}=Xs(),{projects:i}=Te(n),m=c.useMemo(()=>{const z={};for(const j of i)z[j.id]=j.is_inbox_project?"Inbox":j.name;return z},[i]),u=Js(o),{phase:f,errorCode:x,usage:h,truncated:p}=J(),g=ea(),y=za(t),[v,b]=c.useState(!1),[w,E]=c.useState(!1),{data:R}=Ga(),K=vs(ys(R)),D=h??u.data??null,N=D?.plan,_=D?.maxTasks??25,P=!!D&&D.remaining<=0,C=f==="error"&&x==="limit_reached"||P&&f!=="loading"&&y.length===0,L=C&&N==="trial"&&K,F=t.filter(z=>!y.some(j=>j.id===z.id)),Z=()=>g(F.length?F:t,s,_,m),se=()=>{const z=new Map;for(const j of y){const T=ne[j.quadrant].key;z.set(T,[...z.get(T)??[],j.id])}a([...z.entries()].map(([j,T])=>({label:j,taskIds:T})))};if(d)return null;const O=A("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border/60 bg-muted/30 px-3 py-2",r?"mt-2":"mt-1");if(!o)return e.jsxs("div",{className:O,"data-testid":"ai-panel","data-state":l?"reconsent":"no-consent",children:[e.jsx(M,{t
1ype:"button",size:"sm",variant:"outline",disabled:!0,"aria-describedby":"ai-consent-explainer","data-testid":"ai-suggest-btn",className:"h-8",children:"Suggest with AI"}),e.jsx(M,{type:"button",size:"sm",variant:"secondary",className:"ml-auto h-8",onClick:()=>b(!0),"data-testid":"ai-consent-open",children:l?Ke.reconsentButton:"Turn on"}),e.jsx("p",{id:"ai-consent-explainer",className:"basis-full text-xs leading-snug text-muted-foreground",children:l?Ke.reconsentLine:"Needs your OK to share task details with AI."}),e.jsx(ta,{open:v,onOpenChange:b,reconsent:l})]});if(L)return e.jsxs("div",{className:O,"data-testid":"ai-panel","data-state":"upsell",children:[e.jsx("p",{className:"min-w-0 flex-1 text-xs leading-snug text-foreground/85","data-testid":"ai-upsell",children:Wt}),e.jsx(M,{type:"button",size:"sm",className:"h-8",onClick:()=>E(!0),"data-testid":"ai-see-plans",children:"See plans"}),e.jsx(js,{open:w,onOpenChange:E,children:e.jsxs(Ns,{className:"sm:max-w-md z-[70]",overlayClassName:"z-[70]","data-testid":"ai-plans-dialog",children:[e.jsxs(ws,{className:"text-left",children:[e.jsx(Cs,{children:"Unlimited AI suggestions"}),e.jsx(Ss,{children:"Upgrade to keep sorting with AI, along with everything in the app."})]}),e.jsx(Es,{onStarted:()=>E(!1)})]})})]});if(C)return e.jsx("div",{className:O,"data-testid":"ai-panel","data-state":"limit",children:e.jsx("p",{className:"min-w-0 flex-1 text-xs leading-snug text-muted-foreground","data-testid":"ai-limit",children:Ye("limit_reached",N==="trial"?"trial":"paid")})});const G=f==="loading",re=y.length>0,oe=N==="trial"&&D?D.remaining:null;return e.jsx("div",{className:O,"data-testid":"ai-panel","data-state":G?"loading":re?"ready":f==="error"?"error":"idle",children:re&&!G?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex min-w-0 flex-1 items-center text-xs text-muted-foreground","aria-live":"polite",children:e.jsxs("span",{className:"truncate","data-testid":"ai-count",children:[y.length," ",y.length===1?"suggestion":"suggestions",p?` · first ${_}`:""]})}),e.jsxs(M,{type:"button",size:"sm",className:"h-8 gap-1.5",onClick:se,"data-testid":"ai-accept-all",children:[e.jsx(W,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Accept all"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{type:"button",size:"sm",variant:"outline",className:"h-8 gap-1.5",onClick:Z,disabled:G||t.length===0,"aria-busy":G,"data-testid":"ai-suggest-btn",children:[G&&e.jsx(Jt,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),G?"Suggestingâ¦":f==="error"?"Try again":"Suggest with AI"]}),e.jsx("p",{className:"min-w-0 flex-1 text-xs leading-snug text-muted-foreground","aria-live":"polite","data-testid":f==="error"&&!G?"ai-error":"ai-hint",children:G?"Reading your tasksâ¦":f==="error"?Ye(x,N):oe!==null?`${oe} of ${D.limit} free ${D.limit===1?"run":"runs"} left`:"Suggests a quadrant for each task. You decide."})]})})},Ze=({suggestion:t,onAccept:s,withKey:a=!1,className:n})=>{const r=ne[t.quadrant];return c.useEffect(()=>{if(!a)return;const o=l=>{const d=l.target;d&&(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.isContentEditable)||l.repeat||l.metaKey||l.ctrlKey||l.altKey||(l.key==="a"||l.key==="A")&&(l.preventDefault(),s("key"))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a,s]),e.jsxs("div",{className:A("flex min-w-0 items-center gap-2 rounded-xl border px-2.5 py-1.5",n),style:{borderColor:`rgb(var(${r.token}) / 0.35)`,background:`rgb(var(${r.token}) / 0.08)`},"data-testid":"ai-chip","data-quadrant":t.quadrant,children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:`rgb(var(${r.token}))`},"aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 flex-1 text-xs leading-snug",children:[e.jsx("span",{className:"font-semibold",children:r.label}),e.jsx("span",{className:"text-muted-foreground",children:" · "}),e.jsx("span",{className:"text-foreground/80","data-testid":"ai-reason",children:t.reason})]}),e.jsxs(M,{type:"button",size:"sm",variant:"secondary",className:"h-7 shrink-0 gap-1 px-2.5 text-xs",onClick:()=>s("tap"),"data-testid":"ai-accept","aria-label":`Accept ${r.label}`,title:a?"Accept (A)":"Accept",children:[e.jsx(W,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Accept",a&&e.jsx("kbd",{className:"ml-0.5 hidden rounded border border-border/70 px-1 text-[10px] font-medium text-muted-foreground sm:inline",children:"A"})]})]})},Ka=({suggestion:t,onAccept:s})=>{const a=ne[t.quadrant];return e.jsxs("button",{type:"button",onClick:n=>{n.stopPropagation(),s()},className:"mt-1 flex max-w-full items-start gap-1.5 rounded-md px-1.5 py-0.5 text-left text-[11px] leading-4 hover:brightness-95",style:{background:`rgb(var(${a.token}) / 0.1)`},"data-testid":"ai-row-chip","data-quadrant":t.quadrant,"aria-label":`Accept suggestion: ${a.label}, ${t.reason}`,title:"Accept suggestion",children:[e.jsx("span",{className:"mt-[5px] h-1.5 w-1.5 shrink-0 rounded-full",style:{background:`rgb(var(${a.token}
1))`},"aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 whitespace-normal break-words",children:[e.jsx("span",{className:"font-semibold",children:a.label}),e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.reason]})]}),e.jsx(W,{className:"mt-0.5 h-3 w-3 shrink-0 opacity-70","aria-hidden":!0})]})},Xe={1:"DO",2:"SCHEDULE",3:"DELEGATE",4:"BACKLOG"},Je=(t,s=new Date)=>{const a=[],n=Ts(t);if(n){const o=aa(n),l=na(s),d=bt(o,l);d<0?a.push(`Overdue · due ${He(o,"EEE, MMM d")}`):d===0?a.push("Due today"):d===1?a.push("Due tomorrow"):a.push(`Due ${He(o,"EEE, MMM d")}`)}const r=t.priority??1;return r>=2&&a.push(`P${5-r}`),a.length?a.join(" · "):null},Ba=({currentTask:t,onLabelTask:s,onBack:a,onSkip:n,isFirstTask:r,isLastTask:o,showCue:l=!1,aiSuggestions:d=!1})=>{const i=J(y=>d?y.byId[t.id]:void 0),m=H.useCallback((y="tap")=>{i&&s(ne[i.quadrant].key,[t.id],y)},[i,s,t.id]),{renderTooltip:u}=Qt(),f=ee(),x=As(y=>y.projectNames),p=(y=>{const v=["do","schedule","delegate","backlog"];return y.labels.find(b=>v.includes(b.toLowerCase()))?.toLowerCase()})(t);c.useEffect(()=>{const y=v=>{const b=v.target;if(!(!!b&&(b.tagName==="INPUT"||b.tagName==="TEXTAREA"||b.isContentEditable))&&!v.repeat&&!v.metaKey&&!v.ctrlKey&&!v.altKey&&Xe[v.key]){v.preventDefault(),s(Xe[v.key],[t.id]);return}v.key==="ArrowLeft"&&!r?a():v.key==="ArrowRight"&&!o&&n()};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[a,n,r,o,s,t.id]);const g=l?Je(t):null;if(f){const y=t.project_id?x[t.project_id]:void 0,v=[y&&y!=="Inbox"?y:null,Je(t)].filter(Boolean).join(" · "),b=it.find(w=>w.id===p);return e.jsxs("div",{className:"mx-sort",children:[e.jsxs("div",{className:"mx-sort-card",children:[b&&e.jsxs("p",{className:"mx-sort-now",style:{"--q":`var(--q-${b.id})`},children:[e.jsx("span",{className:"mx-dot","aria-hidden":!0}),"Now in ",b.label]}),e.jsx("h3",{className:"mx-sort-title",children:t.content}),v&&e.jsx("p",{className:"mx-sort-facts","data-testid":g?"starter-cue":void 0,children:v}),i&&e.jsx(Ze,{suggestion:i,onAccept:m,className:"mt-3"}),t.description?.trim()&&e.jsx("p",{className:"mx-sort-desc",children:t.description})]}),e.jsx(qt,{onLabelTask:s,taskIds:[t.id],current:p}),e.jsxs("div",{className:"mx-sort-nav",children:[e.jsxs("button",{type:"button",className:"mx-sort-navbtn",onClick:a,disabled:r,children:[e.jsx(ze,{className:"h-5 w-5","aria-hidden":!0}),"Back"]}),e.jsxs("button",{type:"button",className:"mx-sort-navbtn",onClick:n,disabled:o,children:["Skip",e.jsx(Ve,{className:"h-5 w-5","aria-hidden":!0})]})]})]})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:g?"flex items-center gap-2 mb-2":"flex items-center gap-2 mb-4",children:[e.jsx("h3",{className:"text-lg font-medium",children:t.content}),p&&e.jsx(ks,{quadrant:p,size:"sm",showLabel:!0})]}),g&&e.jsx("p",{className:"text-[12px] leading-4 text-muted-foreground mb-3","data-testid":"starter-cue",children:g}),i&&e.jsx(Ze,{suggestion:i,onAccept:m,withKey:!0,className:"mb-3 -mt-1"}),e.jsx(Ht,{onLabelTask:s,taskIds:[t.id]}),e.jsxs("div",{className:"flex justify-between gap-4 mt-4",children:[u(e.jsxs(M,{onClick:a,variant:"outline",className:"flex-1 bg-slate-50 hover:bg-slate-100 dark:bg-muted dark:hover:bg-muted transition-colors",disabled:r,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Back"]}),{content:"Go to previous task",side:"bottom"}),u(e.jsxs(M,{onClick:n,variant:"outline",className:"flex-1 bg-blue-100 text-blue-700 hover:bg-blue-200 hover:text-blue-800 border-blue-300 dark:bg-blue-900/40 dark:text-blue-100 dark:hover:bg-blue-900/60 dark:border-blue-800/70 transition-colors",disabled:o,children:["Skip",e.jsx(Ve,{className:"h-4 w-4 ml-2"})]}),{content:"Skip to next task",side:"bottom"})]}),l&&e.jsx("p",{className:"mt-3 text-center text-[12px] text-muted-foreground max-sm:hidden",children:"Tip: press 1â4 to choose."})]})},Ha=({selectedCount:t,totalCount:s,onSelectAll:a,onClearSelection:n,quadrantCounts:r=[],activeQuadrantFilter:o,onQuadrantFilterChange:l,isBulkRecategorization:d=!1})=>{const i=t===s&&s>0,m=d?r.filter(u=>u.label!=="UNCATEGORIZED"):r;return e.jsxs(Y.div,{initial:{opacity:0,y:-5}
1,animate:{opacity:1,y:0},transition:{duration:.3},className:"rounded-xl border border-slate-200 dark:border-border bg-white dark:bg-card p-2 shadow-sm transition-all",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(M,{variant:i?"secondary":"outline",size:"sm",onClick:a,className:"transition-all duration-200 flex items-center gap-1.5 h-8 text-xs font-semibold rounded-lg",children:[i?e.jsx(es,{className:"h-3.5 w-3.5"}):e.jsx(ts,{className:"h-3.5 w-3.5"}),i?"Deselect all":"Select all"]}),e.jsx(Y.div,{initial:!1,animate:{scale:t>0?[1,1.05,1]:1,transition:{duration:.4}},className:"flex items-center",children:t>0?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-medium bg-primary/10 text-primary rounded-full px-2 py-0.5",children:[t," selected"]}),e.jsx(M,{variant:"ghost",size:"sm",onClick:n,className:"text-muted-foreground hover:text-foreground h-5 px-1.5 text-xs",children:"Clear"})]}):e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s," tasks available"]})},t)]}),m.length>0&&l&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2 pt-2 border-t border-border/60",children:m.map(u=>{const f=o===u.label;return e.jsxs("button",{type:"button",onClick:()=>l(f?null:u.label),className:A("group flex items-center gap-1.5 h-7 px-2.5 rounded-full border","text-[11px] font-semibold transition-all duration-150 active:scale-95"),style:{backgroundColor:f?u.color:`${u.color}14`,color:f?"#fff":u.color,borderColor:f?u.color:`${u.color}40`,opacity:o&&!f?.6:1},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:f?"#fff":u.color}}),qa(u.label),e.jsx("span",{className:"ml-0.5 px-1.5 py-px rounded-full text-[10px] tabular-nums",style:{backgroundColor:f?"rgba(255,255,255,0.25)":`${u.color}22`},children:u.count})]},u.label)})})]})};function qa(t){switch(t.toUpperCase()){case"DO":return"Do First";case"SCHEDULE":return"Schedule";case"DELEGATE":return"Delegate";case"BACKLOG":return"Backlog";case"UNCATEGORIZED":return"Uncategorized";default:return t}}const Qa=({searchQuery:t,setSearchQuery:s,placeholder:a="Search tasksâ¦",autoFocus:n=!1})=>{const r=c.useRef(null);return c.useEffect(()=>{n&&r.current&&r.current.focus()},[n]),e.jsxs(Y.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},transition:{duration:.2},className:"relative",children:[e.jsx(rt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ct,{ref:r,type:"text",placeholder:a,className:"w-full pl-9 h-9 pr-9 bg-background border-slate-200 focus:border-primary/30 focus:ring-primary/20",value:t,onChange:o=>s(o.target.value)}),t&&e.jsx(M,{variant:"ghost",size:"icon",className:"absolute right-1 top-1 h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>s(""),children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]})},Wa=({dueDays:t,setDueDays:s,filteredTasksCount:a,onClearFilter:n,compact:r=!1})=>e.jsxs("div",{className:r?"flex flex-col":"flex items-center gap-2",children:[e.jsxs("div",{className:r?"mb-1.5":"flex items-center gap-1.5",children:[r&&e.jsx(je,{className:"h-3.5 w-3.5 text-primary/70 mb-1"}),e.jsxs("div",{className:r?"":"flex items-center gap-1.5",children:[!r&&e.jsx(je,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx(Ie,{htmlFor:"due-date-filter",className:`text-sm font-medium whitespace-nowrap ${r?"text-xs mb-1.5":""}`,children:"Due in days"})]})]}),e.jsxs("div",{className:r?"w-full flex items-center gap-2":"flex items-center gap-2",children:[e.jsx(ct,{id:"due-date-filter",type:"number",min:"0",placeholder:"Days",value:t,onChange:o=>s(o.target.value),className:`${r?"w-full":"w-16"} h-7 text-sm focus-visible:ring-primary/30 px-2`}),!r&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),t&&e.jsxs(M,{variant:"ghost",size:"icon",className:`h-6 w-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10 p-0 ${r?"absolute top-2 right-2":""}`,onClick:n,children:[e.jsx(ot,{className:"h-3 w-3"}),e.jsx("span",{className:"sr-only",children:"Clear due date filter"})]})]})]}),Ya=({apiKey:t,selectedLabel:s,setSelectedLabel:a,tasks:n,onClearFilter:r,compact:o=!1})=>{const{allLabels:l}=Is(t,n),{trackLabelUsage:d}=dt(),i=u=>{a(u),u!=="all"&&d(u)},m=(u,f)=>{a(f),f!=="all"&&d(f)};return e.jsxs("div",{className:`flex flex-col space-y-1.5 ${o?"w-full":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[o&&e.jsx(lt,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx(Ie,{htmlFor:"label-filter",className:`font-medium ${o?"text-xs":""}`,children:o?"Label":"Filter by Label:"})]}),e.jsxs("div",{className:"flex flex-col space-y-1.5 w-full",children:[e.jsxs(ut,{value:s,onValueChange:i,children:[e.jsx(mt,{id:"label-filter",className:"w-full",children:e.jsx(ft,{placeholder:"Select label"})}),e.jsxs(xt,{children:[e.jsx(fe,{value:"all",children:"All Labels"}),l.map(u=>e.jsx(fe,{value:u,children:u},u))]})]}),s!=="all"&&e.jsx(M,{variant:"ghost",size:"sm",className:"self-start text-xs text-muted-foreground hover:text-destructive",onClick:r,children:"Clear filter"}),e.jsx(pt,{type:"labels",onSelect:m,compact:o})]})]})}
1,Za=({apiKey:t,selectedProject:s,onProjectChange:a,compact:n=!1})=>{const{projects:r,isLoading:o}=Te(t),{trackProjectUsage:l}=dt(),d=(i,m="")=>{if(a(i),i!=="all"){if(!m&&i){const u=r.find(f=>f.id===i);u&&(m=u.name)}l(i,m)}};return e.jsxs("div",{className:`flex flex-col space-y-1.5 max-w-[240px] ${n?"w-full":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(ss,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx(Ie,{htmlFor:"project-filter",className:`font-medium ${n?"text-xs":""}`,children:n?"Project":"Filter by Project:"})]}),e.jsxs("div",{className:"flex flex-col space-y-1.5 w-full",children:[e.jsxs(ut,{value:s,onValueChange:i=>d(i),disabled:o,children:[e.jsx(mt,{className:"w-full",id:"project-filter",children:e.jsx(ft,{placeholder:"Select a project"})}),e.jsxs(xt,{children:[e.jsx(fe,{value:"all",children:"All Projects"}),r.map(i=>e.jsx(fe,{value:i.id,children:i.is_inbox_project?"Inbox":i.name},i.id))]})]}),s!=="all"&&e.jsx(M,{variant:"ghost",size:"sm",className:"self-start text-xs text-muted-foreground hover:text-destructive",onClick:()=>d("all"),children:"Clear filter"}),e.jsx(pt,{type:"projects",onSelect:d,compact:n})]})]})},Xa=({selectedCount:t,totalCount:s,onSelectAll:a,onClearSelection:n,quadrantCounts:r,searchQuery:o,setSearchQuery:l,activeQuadrantFilter:d,onQuadrantFilterChange:i,isBulkRecategorization:m=!1,dueDays:u="",setDueDays:f=()=>{},selectedLabel:x="all",setSelectedLabel:h=()=>{},selectedProject:p="all",setSelectedProject:g=()=>{},apiKey:y=""})=>{const[v,b]=c.useState(!1),w=[u!=="",x!=="all",p!=="all",d!==null].filter(Boolean).length;return e.jsxs(Y.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"mb-4 space-y-3",children:[e.jsx(Ha,{selectedCount:t,totalCount:s,onSelectAll:a,onClearSelection:n,quadrantCounts:r,activeQuadrantFilter:d,onQuadrantFilterChange:i,isBulkRecategorization:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Qa,{searchQuery:o,setSearchQuery:l,autoFocus:!1}),y&&e.jsxs(Ds,{open:v,onOpenChange:b,className:"border border-border rounded-md overflow-hidden",children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(M,{variant:"ghost",size:"sm",className:"w-full flex items-center justify-between p-2 h-auto text-sm hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(as,{className:"w-4 h-4 mr-2"}),e.jsx("span",{children:"Advanced filters"}),w>0&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-primary/10 text-primary text-xs rounded-full",children:w})]}),v?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(rs,{className:"h-4 w-4"})]})}),e.jsx(Ms,{className:"p-3 bg-muted/30 space-y-3 border-t border-border",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsx(Za,{apiKey:y,selectedProject:p,onProjectChange:g,compact:!0}),e.jsx(Ya,{apiKey:y,selectedLabel:x,setSelectedLabel:h,tasks:[],onClearFilter:()=>h("all"),compact:!0}),e.jsx(Wa,{dueDays:u,setDueDays:f,filteredTasksCount:s,onClearFilter:()=>f(""),compact:!0})]})})]})]})]})},Ja=({tasks:t,selectedTasks:s,onTaskSelect:a,renderQuadrantBadge:n,maxHeight:r="calc(100vh - 400px)",activeQuadrantFilter:o,onQuadrantClick:l,onQuickRecategorize:d})=>{const{renderTooltip:i}=Qt(),m=ee(),u=J(x=>x.byId),f=x=>{const h=["DO","SCHEDULE","DELEGATE","BACKLOG"],p=x.labels.find(g=>h.includes(g.toUpperCase()));return p?p.toUpperCase():"UNCATEGORIZED"};return e.jsx(ra,{className:"w-full transition-all duration-300 h-full max-sm:h-auto",style:{height:m?void 0:r},children:e.jsx("div",{className:"space-y-1.5 pb-2 pr-3",children:t.length===0?e.jsx(Y.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"text-center py-6 text-muted-foreground text-sm font-medium bg-muted/40 rounded-xl border border-dashed border-border",children:"No tasks match your current filters"}):t.map(x=>{const h=s.includes(x.id),p=f(x),g=Rs(p),y=g?.color??"#6b7280",v=d&&p==="UNCATEGORIZED"?u[x.id]:void 0;return e.jsxs("div",{className:A("group relative flex items-center gap-3 py-2.5 pl-3.5 pr-2 rounded-xl border cursor-pointer","transition-[background-color,border-color,box-shadow] duration-200",h?"border-primary/50 bg-primary/[0.07] dark:bg-primary/[0.12] shadow-sm":"border-border/60 bg-card hover:border-primary/30 hover:bg-muted/50"),onClick:()=>a(x.id),children:[e.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1.5 bottom-1.5 w-1 rounded-full transition-opacity",style:{backgroundColor:y,opacity:g?h?.9:.55:0}}),m?e.jsx("button",{type:"button","aria-label":h?"Deselect task":"Select task","aria-pressed":h,className:"mx-sort-check",onClick:b=>{b.stopPropagation(),a(x.id)},children:e.jsx("span",{className:A("mx-sort-box",h&&"is-on"),children:h&&e.jsx(W,{className:"h-3.5 w-3.5",strokeWidth:3})})}):e.jsx("button",{type:"button","aria-label":h?"Deselect task":"Select task",className:A("flex-shrink-0 h-5 w-5 rounded-md border flex items-center justify-center","transition-all duration-150 active:scale-90",h?"bg-primary border-primary text-primary-foreground":"border-border/80 bg-background hover:border-primary/60"),onClick:b=>{b.stopPropagation(),a(x.id)},children:h&&e.jsx(W,{className:"h-3.5 w-3.5",strokeWidth:3})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:A("block min-w-0 text-sm font-medium truncate",h?"text-foreground":"text-foreground/90"),children:m?e.jsx("span",{className:"mx-sort-rowtitle",children:x.content}):i(e.jsx("span",{className:"truncate block",children:x.content}),{content:e.jsxs("div",{className:"max-w-[300px] p-2",children:[e.jsx("div",{className:"font-semibold mb-1",children:x.content}),x.description&&e.jsx("div",{className:"text-xs opacity-80",children:x.description}),x.due?.date&&e.jsxs("div",{className:"text-xs mt-1 text-primary",children:["Due:"," ",ht(x.due)?.toLocaleDateString()]})]}),side:"right",align:"start",className:"z-50 text-xs"})}),v&&e.jsx(Ka,{suggestion:v,onAccept:()=>d?.(x.id,ne[v.quadrant].key,"row")})]}),d?e.jsxs(Ps,{children:[e.jsx(Os,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:b=>b.stopPropagation(),className:A("flex-shrink-0 flex items-center gap-1.5 h-7 pl-2 pr-1.5 rounded-lg","text-xs font-semibold border transition-all duration-150","hover:brightness-95 active:scale-95"),style:{backgroundColor:g?g.tint:"transparent",color:g?g.color:"var(--muted-foreground)",borderColor:g?`${g.color}55`:void 0},"aria-label":"Change category",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:g?g.color:"#9ca3af"}}),e.jsx("span",{className:"truncate max-w-[88px]",children:g?g.title:"Set category"}),e.jsx(os,{className:"h-3 w-3 opacity-60"})]})}),e.jsxs(_s,{align:"end",className:"w-52",onClick:b=>b.stopPropagation(),children:[e.jsx(Fs,{className:"text-xs text-muted-foreground",children:"Move to quadrant"}),e.jsx($s,{}),ge.map(b=>{const w=b.icon,E=b.label===p;return e.jsxs(Us,{disabled:E,className:"gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),E||d(x.id,b.label)},children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md",style:{backgroundColor:b.tint,color:b.color},children:e.jsx(w,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:"text-sm font-medium",children:b.title}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:b.subtitle})]}),E&&e.jsx(W,{className:"h-3.5 w-3.5 ml-auto text-primary"})]},b.label)})]})]}):n?.(x)]},x.id)})})})},en=()=>e.jsx("div",{className:"flex justify-center items-center h-full p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("p",{children:"No tasks match your current filter settings."}),e.jsx("p",{className:"text-sm mt-1",children:"Try adjusting your filters or search query."})]})}),tn=t=>{switch(t.toUpperCase()){case"DO":return"bg-red-500/10 text-red-500 border-red-500/20";case"SCHEDULE":return"bg-blue-500/10 text-blue-500 border-blue-500/20";case"DELEGATE":return"bg-orange-500/10 text-orange-500 border-orange-500/20";case"BACKLOG":return"bg-slate-500/10 text-slate-500 border-slate-500/20";default:return"bg-primary/10 text-primary border-primary/20"}},sn=t=>{switch(t.toUpperCase()){case"DO":return"Do First";case"SCHEDULE":return"Schedule";case"DELEGATE":return"Delegate";case"BACKLOG":return"Backlog";default:return t}},an=({activeQuadrantFilter:t,searchQuery:s,selectedLabel:a="all",selectedProject:n="all",dueDays:r="",projectName:o})=>t!==null||s!==""||a!=="all"||n!=="all"||r!==""?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t&&e.jsxs(ae,{variant:"outline",className:A("flex items-center gap-1.5 py-1 px-2",t
1n(t)),children:[e.jsx(ls,{className:"h-3 w-3"}),e.jsx("span",{children:sn(t)})]}),a!=="all"&&e.jsxs(ae,{variant:"outline",className:"flex items-center gap-1.5 py-1 px-2 bg-violet-500/10 text-violet-500 border-violet-500/20",children:[e.jsx(lt,{className:"h-3 w-3"}),e.jsxs("span",{children:["Label: ",a]})]}),n!=="all"&&o&&e.jsxs(ae,{variant:"outline",className:"flex items-center gap-1.5 py-1 px-2 bg-blue-500/10 text-blue-500 border-blue-500/20",children:[e.jsx(is,{className:"h-3 w-3"}),e.jsxs("span",{children:["Project: ",o]})]}),r!==""&&e.jsxs(ae,{variant:"outline",className:"flex items-center gap-1.5 py-1 px-2 bg-green-500/10 text-green-500 border-green-500/20",children:[e.jsx(je,{className:"h-3 w-3"}),e.jsxs("span",{children:["Due in ",r," days"]})]}),s&&e.jsxs(ae,{variant:"outline",className:"flex items-center gap-1.5 py-1 px-2 bg-amber-500/10 text-amber-500 border-amber-500/20 max-w-[200px]",children:[e.jsx(rt,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:`"${s}"`})]})]}):null,nn=({tasks:t,selectedTasks:s,onTaskSelect:a,apiKey:n,maxHeight:r,activeQuadrantFilter:o=null,onQuadrantClick:l,renderQuadrantBadge:d,searchQuery:i="",selectedLabel:m="all",selectedProject:u="all",dueDays:f="",projectName:x,isBulkRecategorization:h=!1,onQuickRecategorize:p,totalTaskCount:g})=>t.length===0?e.jsx(en,{}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(an,{activeQuadrantFilter:o,searchQuery:i,filteredTaskCount:t.length,totalTaskCount:g??t.length,isBulkRecategorization:h,selectedLabel:m,selectedProject:u,dueDays:f,projectName:x}),e.jsx(Ja,{tasks:t,selectedTasks:s,onTaskSelect:a,maxHeight:r,activeQuadrantFilter:o,onQuadrantClick:l,renderQuadrantBadge:d,onQuickRecategorize:p})]}),rn=({onLabelTask:t,taskIds:s,disabled:a,isCtrlSelection:n=!1})=>ee()?e.jsxs("div",{className:"mx-sort-footer",children:[e.jsx("p",{className:"mx-sort-footer-line","aria-live":"polite",children:s.length>0?`${s.length} selected · move to`:"Pick tasks, or tap a rowâs tag to move it"}),s.length>0&&e.jsx(qt,{onLabelTask:t,taskIds:s,disabled:a})]}):s.length===0?e.jsxs("div",{className:"py-3 px-1 sticky bottom-0 bg-background/95 backdrop-blur-sm z-20 border-t max-sm:static max-sm:z-auto max-sm:bg-background",children:[e.jsx("p",{className:"mb-2 text-xs text-muted-foreground","aria-live":"polite",children:"Pick tasks above, or tap a rowâs tag to move it instantly"}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5",role:"group","aria-label":"Move selected tasks to",children:ge.map(o=>e.jsxs("button",{type:"button",disabled:!0,title:`Select tasks to move them to ${o.title}`,className:"flex h-8 min-w-0 items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-xs font-semibold opacity-60 cursor-not-allowed",style:{borderColor:`${o.color}40`,color:o.color},children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 flex-none rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{className:"truncate",children:o.title})]},o.label))})]}):e.jsxs(Y.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"py-4 px-1 sticky bottom-0 bg-background/95 backdrop-blur-sm z-20 border-t max-sm:static max-sm:z-auto max-sm:bg-background",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("h3",{className:"text-base font-semibold text-foreground flex items-center",children:[e.jsx("span",{className:"inline-block w-1 h-5 bg-primary/80 rounded mr-2"}),n?"Move selected tasks":"Categorize selected tasks"]}),s.length>0?e.jsxs("div",{className:A("flex items-center gap-1.5 text-sm font-medium px-2.5 py-1 rounded-full",n?"bg-[#8B5CF6]/10 text-[#8B5CF6]":"bg-primary/10 text-primary"),children:[e.jsx(W,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[s.length," selected"]})]}):e.jsx("span",{className:"text-xs text-muted-foreground text-right",children:"Pick tasks above, or tap a rowâs tag to move it instantly"})]}),e.jsx(Ht,{onLabelTask:t,taskIds:s,disabled:a})]}),on=(t,s,a=new Date)=>{const n=ht(t.due);return n?bt(n,a)<=s:!1},ln=({tasks:t,searchQuery:s,activeQuadrantFilter:a,isBulkRecategorization:n,selectedLabel:r="all",selectedProject:o="all",dueDays:l=""})=>({filteredTasks:c.useMemo(()=>{let i=[...t];if(n&&(i=i.filter(m=>!!Ne(m))),o&&o!=="all"&&(i=i.filter(m=>m.project_id===o)),r&&r!=="all"&&(i=i.filter(m=>m.labels.some(u=>Gs(u,r)))),l&&l!==""){const m=parseInt(l);if(!isNaN(m)){const u=new Date;i=i.filter(f=>on(f,m,u))}}if(a&&(i=i.filter(m=>{const u=Ne(m);return u&&u.toUpperCase()===a.toUpperCase()})),s.trim()!==""){const m=s.toLowerCase();i=i.filter(u=>u.content.toLowerCase().includes(m)||u.description&&u.description.toLowerCase().includes(m))}return i},[t,s,n,a,r,o,l])}),cn=t=>{switch(t.toUpperCase()){case"DO":case"DO_FIRST":return"#dc2626";case"SCHEDULE":return"#2563eb";case"DELEGATE":return"#ea580c";case"BACKLOG":return"#4b5563";default:return"#6b7280"}},et={[de.DO]:1,[de.SCHEDULE]:2,[de.DELEGATE]:3,[de.BACKLOG]:4,UNCATEGORIZED:5},dn=(t,s)=>({quadrantCountsArray:c.useMemo(()=>{const n=t.reduce((r,o)=>{const l=Ne(o);if(l){const d=l.toUpperCase();r[d]=(r[d]||0)+1}else s||(r.UNCATEGORIZED=(r.UNCATEGORIZED||0)+1);return r},{});return Object.entries(n).map(([r,o])=>({label:r,count:o,color:cn(r)})).sort((r,o)=>{const l=et[r.label]||99,d=et[o.label]||99;return l-d})},[t,s])}),un=({tasks:t,selectedTasks:s,onTaskSelect:a,onLabelTask:n,apiKey:r,isBulkRecategorization:o=!1})=>{const[l,d]=c.useState(""),[i,m]=c.useState(null),[u,f]=c.useState("all"),[x,h]=c.useState("all"),[p,g]=c.useState(""),{projects:y}=Te(r),v=ee(),b=y.find(C=>C.id===x)?.name||"",{filteredTasks:w}=ln({tasks:t,searchQuery:l,activeQuadrantFilter:i,isBulkRecategorization:o,selectedLabel:u,selectedProject:x,dueDays:p}),{quadrantCountsArray:E}=dn(t,o);c.useEffect(()=>{s.length>10&&!me()&&q.info("Bulk selection",{description:`${s.length} tasks selected. Consider categorizing in smaller batches for better organization.`})},[s.length]);const R=async(C,L,F)=>{L.length>20&&!window.confirm("You're about to categorize a large number of tasks. Are you sure you want to continue?")||await n(C,L,F)},K=(C,L,F)=>{R(L,[C],F)},D=()=>{a("clear-all")},N=()=>{s.length===w.length?a("clear-all"):w.map(L=>
1L.id).forEach(L=>{s.includes(L)||a(L)})},_=C=>{m(C)},P=c.useCallback(C=>{C.key==="Escape"&&a("clear-all"),(C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="a"&&(C.preventDefault(),N())},[s,w]);return c.useEffect(()=>(window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)),[P]),e.jsx(zs,{className:v?"flex flex-col border-none shadow-none bg-transparent":"flex flex-col h-full min-h-0 overflow-hidden border-none shadow-none max-sm:h-auto max-sm:overflow-visible",children:e.jsxs("div",{className:v?"flex flex-col flex-1":"flex flex-col flex-1 min-h-0 max-sm:overflow-visible",children:[e.jsx("div",{className:v?"pb-1":A("sm:sticky sm:top-0 sm:z-40 sm:backdrop-blur-md border-b border-border/40 transition-colors max-sm:bg-background",s.length>0?"bg-primary/10":"bg-background/70"),children:e.jsx(Xa,{selectedCount:s.length,totalCount:w.length,onSelectAll:N,onClearSelection:D,quadrantCounts:E,searchQuery:l,setSearchQuery:d,activeQuadrantFilter:i,onQuadrantFilterChange:_,isBulkRecategorization:o,dueDays:p,setDueDays:g,selectedLabel:u,setSelectedLabel:f,selectedProject:x,setSelectedProject:h,apiKey:r})}),e.jsx("div",{className:v?"flex-1 mb-2":"flex-1 min-h-0 overflow-y-auto mb-2 max-sm:flex-none max-sm:overflow-visible max-sm:min-h-0",children:e.jsx(nn,{tasks:w,selectedTasks:s,onTaskSelect:a,apiKey:r,onQuickRecategorize:K,totalTaskCount:t.length,activeQuadrantFilter:i,searchQuery:l,selectedLabel:u,selectedProject:x,dueDays:p,projectName:b,isBulkRecategorization:o})}),e.jsx(rn,{onLabelTask:R,taskIds:s,disabled:s.length===0})]})})},mn={do:"Do First",schedule:"Schedule",delegate:"Delegate",backlog:"Backlog"},fn=({total:t,sorted:s})=>e.jsxs("div",{className:"space-y-1.5 pr-6",children:[e.jsxs("h2",{className:"text-xl font-semibold tracking-tight",children:["Sort your first ",t]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Is it urgent? Is it important? Pick the quadrant that fits."}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("span",{className:"flex gap-1.5","aria-hidden":!0,children:Array.from({length:t},(a,n)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full transition-colors duration-200",style:{background:n<s?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.25)"}},n))}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground tabular-nums","aria-live":"polite",children:[s," of ",t," sorted"]})]})]}),ye=({isOpen:t,isBulkRecategorization:s=!1,onOpenChange:a,tasks:n,apiKey:r,onComplete:o,starter:l,onTasksLabeled:d,onTasksLabelFailed:i,examples:m})=>{const u=!l&&!s,{session:f}=gt.useSessionContext(),x=f?.user?.id??null;c.useEffect(()=>{if(!u)return;if(!t){Be.finish();return}const j=()=>Be.flush();return window.addEventListener("pagehide",j),()=>window.removeEventListener("pagehide",j)},[u,t]);const[h,p]=c.useState(0),[g,y]=c.useState([]),[v,b]=c.useState([]),[w,E]=c.useState(new Set),[R,K]=c.useState(s?"bulk":"single"),D=cs(),N=ee(),_=c.useRef(!0),P=c.useRef(void 0),C=c.useRef(!1);c.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]),c.useEffect(()=>{if(!t){C.current=!1;return}const j=n.filter(k=>!w.has(k.id));y(j);const T=!C.current;C.current=!0,p(k=>T?0:Math.min(k,Math.max(0,j.length-1)))},[n,t,w]),c.useEffect(()=>{s&&K("bulk")},[s]),c.useEffect(()=>{t&&n.every(j=>w.has(j.id))&&a(!1)},[t,n,w,a]);const L=c.useCallback(j=>{switch(j){case"DO":return"Do First (Urgent & Important)";case"SCHEDULE":return"Schedule (Important, Not Urgent)";case"DELEGATE":return"Delegate (Urgent, Not Important)";case"BACKLOG":return"Neither Urgent nor Important";default:return j}},[]),F=c.useCallback(async(j,T=null)=>{const k=j.filter($=>$.taskIds.length>0),S=k.flatMap($=>$.taskIds);if(S.length===0)return;const le=k[0].label,Re=new Map;if(k.forEach($=>$.taskIds.forEach(U=>Re.set(U,$.label))),u){const $=new Map(n.map(U=>[U.id,U.content]));k.forEach(U=>sa(x,U.taskIds.map(Q=>({id:Q,title:$.get(Q)??""})),U.label.toLowerCase(),T)),J.getState().drop(S)}try{const $=new Set(w);S.forEach(I=>$.add(I));const U=g.filter(I=>!S.includes(I.id));_.current&&(y(U),b([]),E($)),k.forEach(I=>
1d?.(I.taskIds,I.label)),k.forEach(I=>{const B=Vs(I.label);B!=="unsorted"&&Ks("task_categorized",{quadrant:B,via:T??(I.taskIds.length>1?"bulk":"buttons"),sheet:l?"starter":s?"recategorize":"categorize",n:I.taskIds.length})});const Q="categorization";P.current=Q;const Pe=me(),Oe=k.length>1;!l&&Pe&&S.length>1?(Bs(Q),q.success(X(Oe?`${S.length} tasks sorted`:`${S.length} tasks moved to ${mn[le.toLowerCase()]??le}`),{id:Q,description:void 0,duration:2e3})):!l&&!Pe&&q.success(X(Oe?`${S.length} Tasks Categorized`:`${S.length===1?"Task":"Tasks"} Categorized - ${L(le)}`),{id:Q,description:S.length>1?`${S.length} tasks have been ${s?"recategorized":"categorized"}`:`Task has been ${s?"recategorized":"categorized"}`,duration:2e3});const _e=new Hs(r),Fe=10,$e=[];for(let I=0;I<S.length;I+=Fe)$e.push(S.slice(I,I+Fe));let ie=0;const ce=[];await Promise.all($e.map(async I=>{await Promise.all(I.map(async B=>{try{const Ue=await _e.getTask(B),Yt=qs(Ue.labels,Re.get(B)??le);await _e.updateTaskLabels(B,Yt)||(ie++,ce.push(B))}catch{ie++,ce.push(B)}}))})),ce.length&&i?.(ce),await D.invalidateQueries({queryKey:["tasks"]}),o(),U.length===0?(a(!1),_.current&&p(0),!l&&me()?q.success(X("All tasks sorted"),{id:P.current,description:void 0,duration:2e3}):l||q.success(X(s?"All tasks recategorized":"All tasks categorized"),{id:P.current,description:`You have successfully ${s?"recategorized":"categorized"} all tasks!`,duration:2e3})):h>=U.length&&_.current&&p(U.length-1),ie>0&&q.warning(X("Some tasks could not be categorized"),{id:P.current,description:`${S.length-ie} of ${S.length} ${S.length===1?"task":"tasks"} processed successfully`,duration:2e3})}catch{i?.(S),_.current&&y(n),q.error(X("Failed to update task labels"),{id:P.current,description:"Please try again or check your connection",duration:2e3})}},[n,g,h,r,o,a,D,L,s,w,l,d,i,u,x]),Z=c.useCallback((j,T,k)=>F([{label:j,taskIds:T}],k??null),[F]),se=c.useCallback(j=>F(j,"all"),[F]),O=c.useCallback(()=>{h<g.length-1&&(p(j=>j+1),!l&&!me()&&q("Task skipped",{id:"task-skip",description:"Use Back to return to it",duration:2e3}))},[h,g,l]),G=c.useCallback(()=>{h>0&&p(j=>j-1)},[h]),re=c.useCallback(j=>{if(j==="clear-all"){b([]);return}b(T=>T.includes(j)?T.filter(k=>k!==j):[...T,j])},[]),oe=j=>{a(j),j||(u&&J.getState().reset(),E(new Set),b([]),p(0))},z=j=>{K(j)};return e.jsx(Qs,{open:t,onOpenChange:oe,children:e.jsxs(Ws,{className:N?"mx-sort-sheet flex flex-col w-full max-w-none sm:max-w-none inset-x-0 left-0 border-l-0 gap-0":"sm:max-w-md sm:overflow-hidden max-sm:overflow-y-auto flex flex-col max-sm:w-full max-sm:max-w-none max-sm:inset-x-0 max-sm:left-0 max-sm:border-l-0 max-sm:p-4 max-sm:gap-2",overlayClassName:l?"bg-black/30":void 0,onOpenAutoFocus:l?j=>{j.preventDefault();let T=0;const k=()=>{const S=document.querySelector('[role="dialog"] [data-testid="quadrant-btn-DO"]');S?S.focus():T++<20&&window.setTimeout(k,50)};k()}:void 0,children:[e.jsxs(Ys,{className:N?"mx-sort-head":"space-y-4",children:[l?e.jsx(fn,{total:l.total,sorted:Math.min(l.total,l.alreadySorted+w.size)}):e.jsx($a,{currentTask:s?Math.max(0,n.length-g.length):h+1,totalTasks:s?n.length:g.length,isBulkRecategorization:s}),u&&t&&e.jsx(Va,{tasks:g,examples:m??[],onAcceptAll:se,apiKey:r,compact:N})]}),e.jsxs(Ia,{value:l?"single":R,onValueChange:z,className:N?"mx-sort-tabs":"mt-3 sm:mt-6 flex-1 flex flex-col min-h-0",children:[!l&&e.jsxs(Ut,{className:N?"grid w-full grid-cols-2 mx-sort-tablist":"grid w-full grid-cols-2",children:[e.jsx(Se,{value:"single",children:N?"One by one":"Single task"}),e.jsx(Se,{value:"bulk",children:N?"Select many":"Bulk select"})]}),e.jsx(Ee,{value:"single",className:N?"mx-sort-panel":"mt-2 sm:mt-4 flex-1 min-h-0 overflow-hidden max-sm:overflow-visible max-sm:min-h-0 max-sm:flex-none",children:g[h]&&e.jsx(Ba,{currentTask:g[h],onLabelTask:Z,onBack:G,onSkip:O,isFirstTask:h===0,isLastTask:h===g.length-1,showCue:!!l,aiSuggestions:u})}),e.jsx(Ee,{value:"bulk",className:N?"mx-sort-panel is-bulk":"mt-2 sm:mt-4 flex-1 min-h-0 overflow-hidden max-sm:overflow-visible max-sm:min-h-0 max-sm:flex-none",children:e.jsx(un,{tasks:g,selectedTasks:v,onTaskSelect:re,onLabelTask:Z,apiKey:r,isBulkRecategorization:s})})]})]})})},Nn=({showLabelingSheet:t,setShowLabelingSheet:s,unlabeledTasks:a,apiKey:n,fetchTasks:r,showBulkRecategorySheet:o,setShowBulkRecategorySheet:l,categorizedTasks:d})=>{const{starterSheet:i,recordSorted:m,unrecordSorted:u}=Zs();return e.jsxs(e.Fragment,{children:[e.jsx(ye,{isOpen:t,onOpenChange:s,tasks:a||[],apiKey:n,onComplete:r,onTasksLabeled:(f,x)=>m(f,x,"categorize"),onTasksLabelFailed:u,examples:d}),i&&e.jsx(ye,{isOpen:i.open,onOpenChange:i.onOpenChange,tasks:i.tasks,apiKey:n,onComplete:r,starter:{total:i.total,alreadySorted:i.alreadySorted},onTasksLabeled:(f,x)=>m(f,x,"starter"),onTasksLabelFailed:u}),e.jsx(ye,{isOpen:o,isBulkRecategorization:!0,onOpenChange:l,tasks:d||[],apiKey:n,onComplete:r})]})};export{Nn as MatrixSheets};
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.