PageSourceSearch

https://app.mycontentlab.ai/assets/ClientGoalsPage-CU75MuXJ.js

js mycontentlab.ai collected 2026-10-05 13:45:49 UTC 100,680 bytes, 20 lines download raw bytes

1import{z as Bt,bL as Tn,u as ee,al as Ar,j as s,Y as Xe,c as J,B as Ze,G as Or,a1 as Mn,bn as Fr,r as c,aD as we,bo as Ir,s as oe,D as it,br as gt,J as qt,T as Ln,Q as _n,P as ar,e as An,k as I,aG as On,b5 as Fn,aE as Me,o as ue,O as In,by as Lt,aU as Pr,ac as $t,H as Pn,aY as q,n as zn,ad as zr,ae as Br,af as qr,ag as $r,L as se,I as Ge,ai as ir,a4 as lr,a5 as cr,a6 as dr,a7 as ur,a8 as fr,bx as Bn,az as Vr,bM as Ve,b6 as qn}from"./index-BLGXq3PF.js";import{u as $n}from"./DeleteClientDialog-BMgYYvba.js";import{C as Vn}from"./ClientPageShell-DCAwegIR.js";import{T as Gn,a as mr,b as lt,c as ct}from"./tabs-FXe9U3K4.js";import{B as _t}from"./badge-CBB5HekI.js";import{T as Ne}from"./trophy-D8Ld81q3.js";import{C as Gr}from"./crown-BC7E_Ilm.js";import{p as Yn}from"./reportMonth-DIjWoRjl.js";import{u as Yr,p as Un,M as Kn,l as Ur,A as Wn,C as Xn,a as Hn,c as Kr,b as Qn,d as Jn,e as Zn}from"./useGamificationSettings-CSMMdQ0l.js";import{S as Wr}from"./star-tMp6v-wK.js";import{W as es}from"./wallet-D-tjC4Oc.js";import{M as Xr}from"./MascotEmptyCard-DD-yItyP.js";import{m as Hr,a as Qr}from"./getTimezoneOffsetInMilliseconds-CaYZrnf7.js";import{T as mt}from"./trash-2-DWDj_2jP.js";import{f as Jr}from"./format-BLeMRm9T.js";import{P as ts}from"./pencil-Cb0ZgXxY.js";import{S as rs}from"./switch-Cof4gpXT.js";import{u as ns,a as ss,b as os}from"./useTasks-BtUs63Gr.js";import{u as as}from"./usePageMeta-C3Wog93F.js";import"./oauthErrors-BFQtkMhH.js";import"./ghlIntegration-BeixQ-8P.js";import"./connectionHelpers-CL9-hoO0.js";import"./alert-dialog-DRYU0Bqc.js";import"./BrandRadioPills-CjA4LCIw.js";import"./database-BgOV7O2e.js";import"./chevron-left-ChRudKvh.js";import"./download-DBz-St8v.js";import"./upload-COrjzhvx.js";import"./globe-DOJ1qOfw.js";import"./share-2-DxYAjjth.js";import"./copy-DOR3UrBd.js";import"./AudioWaveform-C6lLmrJm.js";import"./pause-HOrbpNUj.js";import"./play-KmaN80Sv.js";import"./calendar-CAvqXoJI.js";import"./AddonFreeRunChip-Xa0MjZJr.js";import"./mail-RpU6_sqf.js";import"./history-xp8hljSx.js";import"./bot-DOr7r5Bb.js";import"./message-square-CLBrgjCJ.js";import"./phone-d-f1p-Kt.js";import"./user-plus-Es36KZoF.js";import"./calendar-check-D1YYHwWV.js";import"./dollar-sign-DZJt0K6s.js";import"./eye-DwC7RPx3.js";import"./mouse-pointer-click-7FopXlKD.js";import"./card-C9pMpGHK.js";import"./constructFrom-DWjd9ymD.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const St=Bt("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const is=Bt("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const hr=Bt("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);function At(e){return+Tn(e)<Date.now()}function Ye(e,t){const n=us(e);let o;if(n.date){const d=fs(n.date,2);o=ms(d.restDateString,d.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const a=o.getTime();let i=0,l;
vendor: 4,565 bytes, line 16
16if(n.time&&(i=hs(n.time),isNaN(i)))return new Date(NaN);if(n.timezone){if(l=gs(n.timezone),isNaN(l))return new Date(NaN)}else{const d=new Date(a+i),u=new Date(0);return u.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),u.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),u}return new Date(a+i+l)}const dt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ls=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cs=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ds=/^([+-])(\d{2})(?::?(\d{2}))?$/;function us(e){const t={},r=e.split(dt.dateTimeDelimiter);let n;if(r.length>2)return t;if(/:/.test(r[0])?n=r[0]:(t.date=r[0],n=r[1],dt.timeZoneDelimiter.test(t.date)&&(t.date=e.split(dt.timeZoneDelimiter)[0],n=e.substr(t.date.length,e.length))),n){const o=dt.timezone.exec(n);o?(t.time=n.replace(o[1],""),t.timezone=o[1]):t.time=n}return t}function fs(e,t){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),n=e.match(r);if(!n)return{year:NaN,restDateString:""};const o=n[1]?parseInt(n[1]):null,a=n[2]?parseInt(n[2]):null;return{year:a===null?o:a*100,restDateString:e.slice((n[1]||n[2]).length)}}function ms(e,t){if(t===null)return new Date(NaN);const r=e.match(ls);if(!r)return new Date(NaN);const n=!!r[4],o=$e(r[1]),a=$e(r[2])-1,i=$e(r[3]),l=$e(r[4]),d=$e(r[5])-1;if(n)return ys(t,l,d)?ps(t,l,d):new Date(NaN);{const u=new Date(0);return!vs(t,a,i)||!bs(t,o)?new Date(NaN):(u.setUTCFullYear(t,a,Math.max(o,i)),u)}}function $e(e){return e?parseInt(e):1}function hs(e){const t=e.match(cs);if(!t)return NaN;const r=Dt(t[1]),n=Dt(t[2]),o=Dt(t[3]);return ws(r,n,o)?r*Hr+n*Qr+o*1e3:NaN}function Dt(e){return e&&parseFloat(e.replace(",","."))||0}function gs(e){if(e==="Z")return 0;const t=e.match(ds);if(!t)return 0;const r=t[1]==="+"?-1:1,n=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return Ns(n,o)?r*(n*Hr+o*Qr):NaN}function ps(e,t,r){const n=new Date(0);n.setUTCFullYear(e,0,4);const o=n.getUTCDay()||7,a=(t-1)*7+r+1-o;return n.setUTCDate(n.getUTCDate()+a),n}const xs=[31,null,31,30,31,30,31,31,30,31,30,31];function Zr(e){return e%400===0||e%4===0&&e%100!==0}function vs(e,t,r){return t>=0&&t<=11&&r>=1&&r<=(xs[t]||(Zr(e)?29:28))}function bs(e,t){return t>=1&&t<=(Zr(e)?366:365)}function ys(e,t,r){return t>=1&&t<=53&&r>=0&&r<=6}function ws(e,t,r){return e===24?t===0&&r===0:r>=0&&r<60&&t>=0&&t<60&&e>=0&&e<25}function Ns(e,t){return t>=0&&t<=59}const gr={Setup:{badge:"bg-violet-50 text-violet-700 border border-violet-200/60 dark:bg-violet-950/30 dark:text-violet-300 dark:border-violet-800/30",color:"hsl(259 64% 41%)"},Growth:{badge:"bg-sky-50 text-sky-700 border border-sky-200/60 dark:bg-sky-950/30 dark:text-sky-300 dark:border-sky-800/30",color:"hsl(199 89% 48%)"},Performance:{badge:"bg-amber-50 text-amber-700 border border-amber-200/60 dark:bg-amber-950/30 dark:text-amber-300 dark:border-amber-800/30",color:"hsl(38 92% 50%)"},Revenue:{badge:"bg-emerald-50 text-emerald-700 border border-emerald-200/60 dark:bg-emerald-950/30 dark:text-emerald-300 dark:border-emerald-800/30",color:"hsl(152 76% 36%)"},Premium:{badge:"bg-fuchsia-50 text-fuchsia-700 border border-fuchsia-200/60 dark:bg-fuchsia-950/30 dark:text-fuchsia-300 dark:border-fuchsia-800/30",color:"hsl(292 84% 61%)"}},js=({view:e,onClaim:t,claiming:r})=>{const{t:n}=ee("goals"),{getLogo:o}=Ar(),{def:a,target:i,current:l,pct:d,points:u,status:f}=e,m=a.icon,g=a.platform?o(a.platform):null,h=gr[a.category]??gr.Setup,y=f==="completed";if(y)return s.jsx("div",{className:"relative overflow-hidden border-transparent rounded-[2rem] shadow-sm hover:shadow-lg transition-all duration-300 hover:-translate-y-1 h-full flex flex-col min-h-[220px]",style:{background:"linear-gradient(135deg, #10b981 0%, #059669 100%)",color:"#ffffff"},children:s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[s.jsx(Xe,{className:"w-12 h-12 mb-2 opacity-95 stroke-[2]",style:{stroke:"#ffffff"}}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:a.title}),s.jsx("p",{className:"text-xs opacity-90 mt-2 line-clamp-2 max-w-[90%] mx-auto leading-relaxed",children:a.description})]}),s.jsxs("div",{className:"w-full flex items-center justify-between gap-2 mt-auto pt-2.5 px-1 border-t border-white/20",children:[s.jsxs("span",{className:"font-mono text-xs font-bold opacity-90",children:[i.toLocaleStr
16ing()," / ",i.toLocaleString()," reached"]}),s.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-bold tracking-wider uppercase opacity-95",children:[s.jsx(Ne,{className:"h-3.5 w-3.5",style:{stroke:"#ffffff"}}),"+",u," PTS"]})]})]})});const p=f==="claimable";return s.jsxs("div",{className:J("group relative overflow-hidden rounded-[2rem] border bg-card shadow-sm transition-all duration-300 flex flex-col min-h-[220px]",p?"border-primary/40 shadow-primary/5 hover:border-primary/60 hover:shadow-md":"border-border hover:border-primary/30 hover:shadow-md"),children:[s.jsxs("div",{className:"absolute top-4 right-4 flex flex-col gap-1 items-end z-20",children:[s.jsx(_t,{className:J("text-[10px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full shrink-0",h.badge),children:n(`challenges.categories.${a.category}`,{defaultValue:a.category})}),a.type==="addon"&&s.jsxs(_t,{className:"text-[10px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full gap-0.5 bg-amber-50 text-amber-700 border border-amber-200/60 dark:bg-amber-950/30 dark:text-amber-300 dark:border-amber-800/30 shrink-0",children:[s.jsx(Gr,{className:"h-2.5 w-2.5"}),n("challenges.card.addon")]})]}),s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1 z-10",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[g?s.jsx("img",{src:g,alt:"",className:"w-12 h-12 mb-2 object-contain shrink-0"}):s.jsx(m,{className:"w-12 h-12 mb-2 shrink-0",style:{color:h.color}}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:a.title}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-2 max-w-[90%] mx-auto leading-relaxed",children:a.description})]}),s.jsx("div",{className:"w-full mt-auto pt-2.5 border-t border-border/50 space-y-2",children:p?s.jsxs(Ze,{colorVariant:"primary",className:"px-8 mx-auto h-10 !text-[13px] mt-2",activeBubbles:!0,disabled:r,onClick:()=>t(e),children:[s.jsx(Ne,{className:"h-3.5 w-3.5"}),r?n("challenges.card.claiming"):n("challenges.card.claim",{points:u})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-full bg-muted/40 h-1.5 rounded-full overflow-hidden",children:s.jsx("div",{className:J("h-full rounded-full transition-all duration-500 bg-gradient-to-r",a.platform==="facebook"?"from-[#1877F2] to-[#5094ee]":a.platform==="instagram"?"from-[#E1306C] via-[#C13584] to-[#F77737]":a.platform==="tiktok"?"from-[#ee1d52] to-[#69C9D0]":a.platform==="youtube"?"from-[#FF0000] to-[#ff6666]":a.platform==="linkedin"?"from-[#0077B5] to-[#3ca0d6]":a.platform==="pinterest"?"from-[#BD081C] to-[#e63043]":a.platform==="threads"?"from-[#000000] to-[#262626]":a.platform==="google_ads"?"from-[#4285F4] to-[#76a7fa]":a.platform==="meta_ads"?"from-[#0668E1] to-[#3ca5ff]":a.platform==="google_search_console"?"from-[#F68B1E] to-[#fbc02d]":a.platform==="google_analytics"?"from-[#E37400] to-[#f9a825]":a.category==="Setup"?"from-[#5026ac] to-[#9d4aec]":a.category==="Growth"?"from-[#00e3fd] to-[#5026ac]":a.category==="Performance"?"from-[#e7006e] to-[#9d4aec]":a.category==="Revenue"?"from-[#10b981] to-[#00e3fd]":"from-[#b32fbf] to-[#539BDB]"),style:{width:`${d}%`}})}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"font-mono font-semibold text-foreground",children:[l!=null?Math.round(l).toLocaleString():"—",s.jsxs("span",{className:"text-muted-foreground font-medium font-sans text-[10px]",children:[" / ",i.toLocaleString()]})]}),s.jsx("span",{className:"font-mono font-bold text-foreground",children:n("challenges.card.progress",{pct:d,points:u})})]})]})})]}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.05] dark:opacity-[0.08] transition-all duration-500 group-hover:scale-110 group-hover:opacity-[0.10] dark:group-hover:opacity-[0.12] z-0","aria-hidden":"true",children:y?s.jsx(Xe,{className:"w-14 h-14",style:{color:h.color}}):p?s.jsx(Ne,{className:"w-14 h-14",style:{color:h.color}}):s.jsx(m,{className:"w-14 h-14",style:{color:h.color}})})]})},pr=e=>["challenge_completions",e],ks=(e,t)=>{const{orgId:r}=Or(),{plan:n}=Mn(),o=Fr(),{data:a=[],isLoading:i}=Yr(),l=Un(n==null?void 0:n.slug),d=c.useMemo(()=>new Set(t),[t]),u=we({queryKey:pr(e??""),enabled:!!e&&!!r,retry:!1,queryFn:async()=>{const{data:k,error:S}=await oe.from("challenge_progress").select("challenge_key, points, completed_at").eq("client_id",e).eq("org_id",r);
16if(S)throw S;return k??[]}}),f=we({queryKey:["challenge_snapshots",e,[...d].sort().join(",")],enabled:!!e&&d.size>0,staleTime:5*60*1e3,queryFn:async()=>{const{data:k,error:S}=await oe.from("monthly_snapshots").select("platform, metrics_data, report_month, report_year").eq("client_id",e).in("platform",[...d]).or(Yn()).order("report_year",{ascending:!1}).order("report_month",{ascending:!1});if(S)throw S;const x=new Map;for(const T of k??[])x.has(T.platform)||x.set(T.platform,T.metrics_data??{});return x}}),m=we({queryKey:["challenge_addon_tiers",e],enabled:!!e,staleTime:5*60*1e3,queryFn:async()=>{const k=await Promise.all(Wn.map(async S=>{try{const{data:x}=await oe.rpc("client_addon_entitlement",{p_client_id:e,p_slug:S}),T=x&&typeof x=="object"?x.tier:void 0;return[S,T??"none"]}catch{return[S,"none"]}}));return Object.fromEntries(k)}}),g=c.useMemo(()=>m.data??{},[m.data]),h=c.useMemo(()=>[...new Set(a.filter(k=>k.type==="addon"&&k.requiredAddon&&g[k.requiredAddon]==="paid"&&k.table).map(k=>k.table))],[g,a]),p=we({queryKey:["challenge_addon_counts",e,h.slice().sort().join(",")],enabled:!!e&&h.length>0,staleTime:5*60*1e3,queryFn:async()=>{const k=await Promise.all(h.map(async S=>{try{const{count:x,error:T}=await oe.from(S).select("*",{count:"exact",head:!0}).eq("client_id",e);return[S,T?0:x??0]}catch{return[S,0]}}));return Object.fromEntries(k)}}).data,v=c.useMemo(()=>u.data??[],[u.data]),b=c.useMemo(()=>{const k=new Map;for(const S of v)k.set(S.challenge_key,S);return k},[v]),j=c.useMemo(()=>Kn.filter(k=>k.platforms.some(S=>d.has(S))).length,[d]),w=c.useMemo(()=>{const k=f.data,S=[];for(const x of a){if(x.type==="metric"&&(!x.platform||!d.has(x.platform))||x.type==="addon"&&(!x.requiredAddon||g[x.requiredAddon]!=="paid"))continue;const T=x.tiers[l],P=T.target;let A;if(x.type==="connections")A=d.size;else if(x.type==="categories")A=j;else if(x.type==="addon")A=(p==null?void 0:p[x.table])??null;else{const me=k==null?void 0:k.get(x.platform),W=me==null?void 0:me[x.metricKey];A=typeof W=="number"?W:null}const fe=A!=null&&P>0?Math.max(0,Math.min(100,Math.round(A/P*100))):0,G=b.get(x.key);let O;G?O="completed":fe>=100?O="claimable":O="in_progress",S.push({def:x,tier:l,target:P,points:(G==null?void 0:G.points)??T.points,current:A,pct:G?100:fe,status:O,completedAt:(G==null?void 0:G.completed_at)??null})}return S},[a,f.data,d,j,l,b,g,p]),C=Ir({mutationFn:async k=>{if(!e)throw new Error("Missing client");if(k.status!=="claimable")throw new Error("Challenge not ready to claim");const{data:S,error:x}=await oe.rpc("claim_challenge",{p_client_id:e,p_challenge_key:k.def.key});if(x)throw x;const T=S??{};if(!T.success){const P=T.error==="not_achieved"?it.t("goals:challenges.claimErrors.notAchieved"):T.error==="forbidden"?it.t("goals:challenges.claimErrors.forbidden"):T.error==="unknown_challenge"?it.t("goals:challenges.claimErrors.unknown"):it.t("goals:challenges.claimErrors.generic");throw new Error(P)}return T},onSuccess:()=>o.invalidateQueries({queryKey:pr(e??"")})}),D=c.useMemo(()=>v.reduce((k,S)=>k+(S.points??0),0),[v]),E=c.useMemo(()=>Ur(D),[D]),R=w.filter(k=>k.status==="completed").length,N=w.filter(k=>k.status==="claimable").length;return{challenges:w,tier:l,totalPoints:D,level:E,completedCount:R,claimableCount:N,totalCount:w.length,claim:C,isLoading:i||u.isLoading||f.isLoading||m.isLoading}},Cs=({clientId:e,connectedPlatforms:t})=>{const{t:r}=ee("goals"),n=h=>r(`challenges.levels.${h}`,{defaultValue:h}),{challenges:o,totalPoints:a,level:i,completedCount:l,claimableCount:d,totalCount:u,claim:f}=ks(e,t),m=c.useMemo(()=>{const h=new Map;for(const p of o){const v=h.get(p.def.category)??[];v.push(p),h.set(p.def.category,v)}const y=p=>p==="claimable"?0:p==="in_progress"?1:2;for(const p of h.values())p.sort((v,b)=>y(v.status)-y(b.status)||b.pct-v.pct);return h},[o]),g=h=>{f.mutate(h,{onSuccess:()=>I.success(r("challenges.toasts.claimed",{points:h.points}),{icon:"🏆"}),onError:y=>I.error(y instanceof Error?y.message:r("challenges.toasts.claimFailed"))})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 rounded-2xl border border-border bg-card shadow-sm overflow-hidden divide-y sm:divide-y-0 sm:divide-x divide-border",children:[s.jsxs("div",{className:"group relative overflow-hidden p-4 flex flex-col gap-1 min-h-[90px]",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:r("challenges.currentLevel")}),s.jsx("p",{className:"font-mono font-bold text-2xl text-foreground leading-none mt-auto",children:r("challenges.levelShort",{level:i.current.level})}),s.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:n(i.current.title)}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.07] dark:opacity-[0.10] group-hover:scale-110 group-hover:opacity-[0.14] transition-all duration-500","aria-hidden":"true",children:s.jsx(Wr,{className:"w-14 h-14 text-primary dark:text-[hsl(var(--primary-for-dark))]"})})]}),s.jsxs("div",{className:"group relative overflow-hidden p-4 flex flex-col gap-1 min-h-[90px]",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:r("challenges.totalPoints")}),s.jsxs("p",{className:"font-mono font-bold text-2xl text-foreground leading-none mt-auto",children:[a.toLocaleStr
16ing(),s.jsx("span",{className:"text-sm font-medium text-muted-foreground ml-1",children:r("challenges.pts")})]}),d>0?s.jsxs("p",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400 flex items-center gap-1",children:[s.jsx(gt,{className:"h-3 w-3"}),r("challenges.readyToClaim",{count:d})]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:r("challenges.completedOf",{completed:l,total:u})}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.07] dark:opacity-[0.10] group-hover:scale-110 group-hover:opacity-[0.14] transition-all duration-500","aria-hidden":"true",children:s.jsx(qt,{className:"w-14 h-14 text-amber-500"})})]}),s.jsxs("div",{className:"group relative overflow-hidden p-4 flex flex-col gap-2 min-h-[90px]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:r("challenges.progressToNext")}),i.next&&s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[i.progressPct,"%"]})]}),i.next?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-full bg-muted/40 h-1.5 rounded-full overflow-hidden mt-auto",children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500 bg-gradient-to-r from-[#5026ac] to-[#9d4aec]",style:{width:`${i.progressPct}%`}})}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(Ln,{i18nKey:"goals:challenges.pointsToNext",values:{points:i.pointsForNext,title:n(i.next.title)},components:[s.jsx("span",{className:"font-mono font-semibold text-foreground"},"0"),s.jsx("span",{className:"font-medium"},"1")]})})]}):s.jsxs("p",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400 mt-auto flex items-center gap-1",children:[s.jsx(Ne,{className:"h-3.5 w-3.5"})," ",r("challenges.maxLevel")]}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.07] dark:opacity-[0.10] group-hover:scale-110 group-hover:opacity-[0.14] transition-all duration-500","aria-hidden":"true",children:s.jsx(_n,{className:"w-14 h-14 text-primary dark:text-[hsl(var(--primary-for-dark))]"})})]})]}),t.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground border border-dashed border-border rounded-2xl",children:[s.jsx(ar,{className:"h-8 w-8 mb-3 opacity-40"}),s.jsx("p",{className:"text-sm font-medium text-foreground",children:r("challenges.noPlatforms.title")}),s.jsx("p",{className:"text-xs mt-1 mb-4 max-w-xs",children:r("challenges.noPlatforms.description")}),e&&s.jsx(An,{to:`/clients/${e}/connections`,children:s.jsxs(Ze,{colorVariant:"primary",className:"h-9",children:[s.jsx(ar,{className:"h-4 w-4"})," ",r("challenges.noPlatforms.action")]})})]}),Xn.map(h=>{const y=m.get(h);return!y||y.length===0?null:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wide",children:r(`challenges.categories.${h}`,{defaultValue:h})}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded-full",children:y.length})]}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:y.map(p=>s.jsx(js,{view:p,onClaim:g,claiming:f.isPending},p.def.key))})]},h)})]})},Ss=["gamification_rewards_active"],xr=e=>["reward_redemptions",e],vr=e=>["reward_credits",e],Ds=e=>["reward_challenge_progress",e],Rs=e=>{var v;const{orgId:t}=Or(),r=Fr(),n=we({queryKey:Ss,retry:!1,staleTime:60*1e3,queryFn:async()=>{const{data:b,error:j}=await oe.from("gamification_rewards").select("*").eq("is_active",!0).order("display_order",{ascending:!0});return j?(console.warn("gamification_rewards read failed:",j.message),[]):b??[]}}),o=we({queryKey:Ds(e??""),enabled:!!e&&!!t,retry:!1,queryFn:async()=>{const{data:b,error:j}=await oe.from("challenge_progress").select("challenge_key, points").eq("client_id",e);if(j)return{points:0,keys:new Set};const w=b??[];return{points:w.reduce((C,D)=>C+(D.points??0),0),keys:new Set(w.map(C=>C.challenge_key))}}}),a=we({queryKey:xr(e??""),enabled:!!e&&!!t,retry:!1,queryFn:async()=>{const{data:b,error:j}=await oe.from("reward_redemptions").select("reward_id").eq("client_id",e);return j?new Set:new Set((b??[]).map(w=>w.reward_id))}}),i=we({queryKey:vr(e??""),enabled:!!e&&!!t,retry:!1,queryFn:async()=>{const{data:b,error:j}=await oe.from("reward_credits").select("credit_type, balance").eq("client_id",e);if(j)return{};const w={};for(const C of b??[])w[C.credit_type]=C.balance;return w}}),l=((v=o.data)==null?void 0:v.points)??0,d=c.useMemo(()=>{var b;return((b=o.data)==null?void 0:b.keys)??new Set},[o.data]),u=c.useMemo(()=>a.data??new Set,[a.data]),f=c.useMemo(()=>i.data??{},[i.data]),m=c.useMemo(()=>Ur(l),[l]),g=c.useMemo(()=>(n.data??[]).map(b=>{const j=u.has(b.id);let w,C,D;if(b.unlock_type==="challenge")w=!!b.required_challenge_key&&d.has(b.required_challenge_key),C=w?100:0,D="Complete a specific challenge";else{const R=b.required_points??Hn(b.required_level??1);w=l>=R,C=R>0?Math.max(0,Math.min(100,Math.round(l/R*100))):100,D=`Reach ${R.toLocaleStr
16ing()} pts`}return{reward:b,status:j?"redeemed":w?"available":"locked",unlockPct:C,requirementLabel:D}}),[n.data,u,d,l]),h=Ir({mutationFn:async b=>{if(!e)throw new Error("Missing client");const{data:j,error:w}=await oe.rpc("redeem_reward",{p_client_id:e,p_reward_id:b});if(w)throw w;const C=j;if(!(C!=null&&C.success))throw new Error((C==null?void 0:C.error)??"redeem_failed");return C},onSuccess:()=>{r.invalidateQueries({queryKey:xr(e??"")}),r.invalidateQueries({queryKey:vr(e??"")})}}),y=g.filter(b=>b.status==="available").length,p=g.filter(b=>b.status==="redeemed").length;return{rewards:g,credits:f,totalPoints:l,level:m,availableCount:y,redeemedCount:p,redeem:h,isLoading:n.isLoading||o.isLoading||a.isLoading}},Es=({view:e,onRedeem:t,redeeming:r})=>{const{t:n}=ee("goals"),{reward:o,status:a,unlockPct:i}=e,{data:l=[]}=Yr(),d=p=>{var v;return p?((v=l.find(b=>b.key===p))==null?void 0:v.title)??p:n("rewards.card.someChallenge")},f=Kr(o.credit_type).icon,m=Qn(o.credit_type,o.credit_amount),g=a==="redeemed",h=a==="available",y=o.unlock_type==="challenge"?{Icon:Me,text:`${d(o.required_challenge_key)}`}:{Icon:Ne,text:n("rewards.card.levelRequirement",{level:o.required_level??1,points:On(o.required_points??0)})};return g?s.jsx("div",{className:"relative overflow-hidden border-transparent rounded-[2rem] shadow-sm hover:shadow-lg transition-all duration-300 hover:-translate-y-1 h-full flex flex-col min-h-[220px]",style:{background:"linear-gradient(135deg, #10b981 0%, #059669 100%)",color:"#ffffff"},children:s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[s.jsx(Xe,{className:"w-12 h-12 mb-2 opacity-95 stroke-[2]",style:{stroke:"#ffffff"}}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:o.name}),o.description&&s.jsx("p",{className:"text-xs opacity-90 mt-2 line-clamp-2 max-w-[90%] mx-auto leading-relaxed",children:o.description})]}),s.jsxs("div",{className:"w-full flex items-center justify-between gap-2 mt-auto pt-2.5 px-1 border-t border-white/20",children:[s.jsx("span",{className:"font-mono text-xs font-bold opacity-90",children:m}),s.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-bold tracking-wider uppercase opacity-95",children:[s.jsx(Ne,{className:"h-3.5 w-3.5",style:{stroke:"#ffffff"}}),n("rewards.card.claimedBadge")]})]})]})}):s.jsxs("div",{className:J("group relative overflow-hidden rounded-[2rem] border bg-card shadow-sm transition-all duration-300 flex flex-col min-h-[220px]",h?"border-primary/40 shadow-primary/5 hover:border-primary/60 hover:shadow-md":"border-border hover:border-primary/30 hover:shadow-md"),children:[!h&&s.jsx("div",{className:"absolute top-4 right-4 z-20",children:s.jsx(Fn,{className:"h-4 w-4 text-muted-foreground opacity-60"})}),s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1 z-10",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[s.jsx(f,{className:"w-12 h-12 mb-2 shrink-0 text-primary dark:text-[hsl(var(--primary-for-dark))]"}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:o.name}),s.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[10px] font-bold text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-500/20 px-2.5 py-0.5 rounded-full shrink-0 mt-1.5",children:[s.jsx(Gr,{className:"h-2.5 w-2.5"}),m]}),o.description&&s.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-2 max-w-[90%] mx-auto leading-relaxed",children:o.description})]}),s.jsx("div",{className:"w-full mt-auto pt-2.5 border-t border-border/50 space-y-2",children:h?s.jsxs(Ze,{colorVariant:"primary",className:"px-8 mx-auto h-10 !text-[13px]",activeBubbles:!0,disabled:r,onClick:()=>t(o.id),children:[s.jsx(Ne,{className:"h-3.5 w-3.5"}),n(r?"rewards.card.claiming":"rewards.card.claim")]}):s.jsxs(s.Fragment,{children:[!h&&o.unlock_type==="rank"&&s.jsx("div",{className:"w-full bg-muted/40 h-1.5 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500 bg-gradient-to-r from-[#5026ac] to-[#9d4aec]",style:{width:`${i}%`}})}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[s.jsx(y.Icon,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground
16/80"}),s.jsx("span",{className:"truncate text-[10px] font-medium leading-none",children:y.text})]}),!h&&o.unlock_type==="rank"&&s.jsxs("span",{className:"font-mono font-bold text-foreground text-[11px] shrink-0",children:[i,"%"]})]})]})})]}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.05] dark:opacity-[0.08] transition-all duration-500 group-hover:scale-110 group-hover:opacity-[0.10] dark:group-hover:opacity-[0.12] z-0","aria-hidden":"true",children:g?s.jsx(Xe,{className:"w-14 h-14 text-white"}):s.jsx(f,{className:"w-14 h-14 text-primary dark:text-[hsl(var(--primary-for-dark))]"})})]})},Ts=[{key:"available"},{key:"locked"},{key:"redeemed"}],Ms=({clientId:e})=>{const{t}=ee("goals"),r=m=>t(`challenges.levels.${m}`,{defaultValue:m}),{rewards:n,credits:o,totalPoints:a,level:i,redeem:l}=Rs(e),d=c.useMemo(()=>{const m={available:[],locked:[],redeemed:[]};for(const g of n)m[g.status].push(g);return m},[n]),u=Object.entries(o).filter(([,m])=>m>0),f=m=>{const g=n.find(h=>h.reward.id===m);l.mutate(m,{onSuccess:()=>I.success(`Reward claimed${g?` — ${g.reward.name}`:""}!`,{icon:"🎁"}),onError:h=>{const y=h instanceof Error?h.message:"redeem_failed",p=t(y==="already_redeemed"||y==="rank_not_reached"||y==="challenge_not_completed"?`rewards.errors.${y}`:"rewards.errors.generic");I.error(p)}})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 rounded-2xl border border-border bg-card shadow-sm overflow-hidden divide-y md:divide-y-0 md:divide-x divide-border",children:[s.jsxs("div",{className:"group relative overflow-hidden p-5 flex flex-col gap-1 min-h-[95px]",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t("rewards.levelAndPoints")}),s.jsxs("p",{className:"font-mono font-bold text-2xl text-foreground leading-none mt-auto",children:[a.toLocaleString(),s.jsx("span",{className:"text-sm font-medium text-muted-foreground ml-1",children:t("rewards.ptsEarned")})]}),s.jsxs("p",{className:"text-xs text-muted-foreground font-medium",children:[r(i.current.title)," · ",s.jsxs("span",{className:"font-semibold text-primary dark:text-[hsl(var(--primary-for-dark))]",children:["LVL ",i.current.level]})]}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.07] dark:opacity-[0.10] group-hover:scale-110 group-hover:opacity-[0.14] transition-all duration-500","aria-hidden":"true",children:s.jsx(qt,{className:"w-14 h-14 text-amber-500"})})]}),s.jsxs("div",{className:"group relative overflow-hidden p-5 flex flex-col gap-2 min-h-[95px]",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t("rewards.bankedCredits")}),s.jsx("div",{className:"mt-auto",children:u.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.map(([m,g])=>{const y=Kr(m).icon;return s.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full border border-border bg-muted/40 text-xs font-semibold text-foreground",children:[s.jsx(y,{className:"h-3.5 w-3.5 text-primary dark:text-[hsl(var(--primary-for-dark))] shrink-0"}),s.jsx("span",{className:"font-mono font-bold mr-0.5",children:g})," × ",Jn(m)]},m)})}):s.jsxs("p",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground py-1",children:[s.jsx(es,{className:"h-3.5 w-3.5 shrink-0"}),t("rewards.noCredits")]})}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.07] dark:opacity-[0.10] group-hover:scale-110 group-hover:opacity-[0.14] transition-all duration-500","aria-hidden":"true",children:s.jsx(gt,{className:"w-14 h-14 text-primary dark:text-[hsl(var(--primary-for-dark))]"})})]})]}),n.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground border border-dashed border-border rounded-2xl",children:[s.jsx(gt,{className:"h-10 w-10 mb-3 opacity-40"}),s.jsx("p",{className:"text-sm font-medium text-foreground",children:t("rewards.empty.title")}),s.jsx("p",{className:"text-xs mt-1",children:t("rewards.empty.description")})]}),Ts.map(m=>{const g=d[m.key];return!g||g.length===0?null:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wide",children:t(`rewards.sections.${m.key}`)}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded-full",children:g.length})]}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:g.map(h=>s.jsx(Es,{view:h,onRedeem:f,redeeming:l.isPending},h.reward.id))})]},m.key)})]})},en="/assets/mascot_tasks-BuBonfTM.webp",Ls={active:"bg-blue-50 text-blue-700 border border-blue-200/60 dark:bg-blue-950/30 dark:text-blue-300 dark:border-blue-800/30",achieved:"bg-emerald-50 text-emerald-700 border border-emerald-200/60 dark:bg-emerald-950/30 dark:text-emerald-300 dark:border-emerald-800/30",missed:"bg-red-50 text-red-700 border border-red-200/60 dark:bg-red-950/30 dark:text-red-300 dark:border-red-800/30",archived:"bg-gray-50 text-gray-700 border border-gray-200/60 dark:bg-gray-950/30 dark:text-gray-300 dark:border-gray-800/30"},br=({goal:e,progress:t,onArchive:r,onDelete:n,onEdit:o})=>{const{t:a}=ee("goals"),{getLabel:i,getLogo:l}=Ar(),d=(t==null?void 0:t.percentage)??0,u=t==null?void 0:t.currentValue;let f=e.status;f==="active"&&(d>=100?f="achieved":e.deadline&&At(Ye(e.deadline))&&(f="missed"));const m=f==="missed"&&e.deadline&&At(Ye(e.deadline)),g=l(e.platform);return f==="achieved"?s.jsx("div",{className:"relative overflow-hidden border-transparent roun
16ded-[2rem] shadow-sm hover:shadow-lg transition-all duration-300 hover:-translate-y-1 h-full flex flex-col min-h-[210px]",style:{background:"linear-gradient(135deg, #10b981 0%, #059669 100%)",color:"#ffffff"},children:s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[s.jsx(Xe,{className:"w-12 h-12 mb-2 opacity-95 stroke-[2]",style:{stroke:"#ffffff"}}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:e.title}),s.jsx("p",{className:"text-[11px] font-medium opacity-80 uppercase tracking-widest mt-1",children:i(e.platform)??e.platform})]}),s.jsxs("div",{className:"w-full flex items-center justify-between gap-2 mt-auto pt-2.5 px-1 border-t border-white/20",children:[s.jsxs("span",{className:"font-mono text-xs font-bold opacity-90",children:[e.target_value.toLocaleString()," reached"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/70 hover:text-white hover:bg-white/20 transition-colors rounded-full shrink-0",onClick:()=>r(e.id),children:s.jsx(St,{className:"h-4 w-4",style:{stroke:"#ffffff"}})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/70 hover:text-white hover:bg-white/20 transition-colors rounded-full shrink-0",onClick:()=>n(e.id),children:s.jsx(mt,{className:"h-4 w-4",style:{stroke:"#ffffff"}})})]})]})]})}):f==="missed"?s.jsx("div",{className:"relative overflow-hidden border-transparent rounded-[2rem] shadow-sm hover:shadow-lg transition-all duration-300 hover:-translate-y-1 h-full flex flex-col min-h-[210px]",style:{background:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)",color:"#ffffff"},children:s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[s.jsx(In,{className:"w-12 h-12 mb-2 opacity-95 stroke-[2]",style:{stroke:"#ffffff"}}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:e.title}),s.jsx("p",{className:"text-[11px] font-medium opacity-80 uppercase tracking-widest mt-1",children:i(e.platform)??e.platform})]}),s.jsxs("div",{className:"w-full flex items-center justify-between gap-2 mt-auto pt-2.5 px-1 border-t border-white/20",children:[s.jsx("span",{className:"font-mono text-xs font-bold opacity-90",children:a("goalCard.reached",{current:u!=null?Math.round(u).toLocaleString():"0",target:e.target_value.toLocaleString()})}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/70 hover:text-white hover:bg-white/20 transition-colors rounded-full shrink-0",onClick:()=>r(e.id),children:s.jsx(St,{className:"h-4 w-4",style:{stroke:"#ffffff"}})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/70 hover:text-white hover:bg-white/20 transition-colors rounded-full shrink-0",onClick:()=>n(e.id),children:s.jsx(mt,{className:"h-4 w-4",style:{stroke:"#ffffff"}})})]})]})]})}):s.jsxs("div",{className:"group relative overflow-hidden rounded-[2rem] border bg-card shadow-sm transition-all duration-300 flex flex-col min-h-[210px] border-border hover:border-primary/30 hover:shadow-md",children:[s.jsx("div",{className:"absolute top-4 right-4 z-20",children:s.jsx(_t,{className:J("text-[10px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full shrink-0 border shadow-none",Ls[f]??""),children:a(`goalCard.status.${f}`,{defaultValue:f})})}),s.jsxs("div",{className:"p-4 flex flex-col justify-between h-full flex-1 z-10",children:[s.jsxs("div",{className:"flex flex-col items-center justify-center text-center my-auto pt-2",children:[g?s.jsx("img",{src:g,alt:"",className:"w-12 h-12 mb-2 object-contain shrink-0"}):s.jsx(Me,{className:"w-12 h-12 mb-2 shrink-0 text-primary dark:text-[hsl(var(--primary-for-dark))]/40"}),s.jsx("h3",{className:"font-bold text-base leading-tight line-clamp-2 max-w-[90%]",children:e.title}),s.jsxs("p",{className:"text-xs text-muted-foreground mt-1 max-w-[90%] mx-auto leading-relaxed",children:[i(e.platform)??e.platform," · ",Lt[e.metric_key]??e.metric_key]}),e.notes&&s.jsxs("p",{className:"text-[11px] text-muted-foreground
16/80 italic mt-1 max-w-[90%] mx-auto line-clamp-1",children:['"',e.notes,'"']})]}),s.jsxs("div",{className:"w-full mt-auto pt-2.5 border-t border-border/50 space-y-2",children:[s.jsx("div",{className:"w-full bg-muted/40 h-1.5 rounded-full overflow-hidden",children:s.jsx("div",{className:J("h-full rounded-full transition-all duration-500 bg-gradient-to-r",e.platform==="facebook"?"from-[#1877F2] to-[#5094ee]":e.platform==="instagram"?"from-[#E1306C] via-[#C13584] to-[#F77737]":e.platform==="tiktok"?"from-[#ee1d52] to-[#69C9D0]":e.platform==="youtube"?"from-[#FF0000] to-[#ff6666]":e.platform==="linkedin"?"from-[#0077B5] to-[#3ca0d6]":e.platform==="pinterest"?"from-[#BD081C] to-[#e63043]":e.platform==="threads"?"from-[#000000] to-[#262626]":e.platform==="google_ads"?"from-[#4285F4] to-[#76a7fa]":e.platform==="meta_ads"?"from-[#0668E1] to-[#3ca5ff]":e.platform==="google_search_console"?"from-[#F68B1E] to-[#fbc02d]":e.platform==="google_analytics"?"from-[#E37400] to-[#f9a825]":"from-[#b32fbf] to-[#539BDB]"),style:{width:`${d}%`}})}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex flex-col text-left",children:[s.jsxs("span",{className:"font-mono font-semibold text-foreground",children:[u!=null?u.toLocaleString():"—",s.jsxs("span",{className:"text-muted-foreground font-medium font-sans text-[10px]",children:[" / ",e.target_value.toLocaleString()]})]}),e.deadline&&s.jsx("span",{className:J("text-[10px] mt-0.5 block font-medium",m?"text-rose-500 font-bold":"text-muted-foreground"),children:m?a("goalCard.overdue"):a("goalCard.due",{date:Jr(Ye(e.deadline),"dd.MM.yyyy")})})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsxs("span",{className:"font-mono font-bold text-foreground text-xs mr-2",children:[d,"%"]}),o&&s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground hover:bg-slate-100 dark:hover:bg-zinc-800 transition-colors rounded-full shrink-0",onClick:()=>o(e),"aria-label":a("goalCard.edit"),children:s.jsx(ts,{className:"h-4 w-4"})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground hover:bg-slate-100 dark:hover:bg-zinc-800 transition-colors rounded-full shrink-0",onClick:()=>r(e.id),children:s.jsx(St,{className:"h-4 w-4"})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors rounded-full shrink-0",onClick:()=>n(e.id),children:s.jsx(mt,{className:"h-4 w-4"})})]})]})]})]}),s.jsx("div",{className:"absolute pointer-events-none select-none right-3 bottom-3 opacity-[0.05] dark:opacity-[0.08] transition-all duration-500 group-hover:scale-110 group-hover:opacity-[0.10] dark:group-hover:opacity-[0.12] z-0","aria-hidden":"true",children:s.jsx(Me,{className:"w-14 h-14 text-primary dark:text-[hsl(var(--primary-for-dark))]"})})]})},_s=({goals:e,isLoading:t,progressMap:r,onArchive:n,onDelete:o,onEdit:a,onCreateGoal:i})=>{const{t:l}=ee("goals");if(t&&e.length===0)return s.jsx(Pr,{});if(e.length===0)return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Xr,{imageSrc:en,overline:l("goalsList.empty.overline"),title:l("goalsList.empty.title"),description:l("goalsList.empty.description"),speechBubble:l("goalsList.empty.speechBubble"),primaryAction:i?{label:l("goalsList.empty.action"),icon:$t,onClick:i}:void 0}),s.jsx(As,{onCreateClick:i})]});const d=e.filter(f=>f.status==="active"),u=e.filter(f=>f.status!=="active");return s.jsxs("div",{className:"space-y-6",children:[d.length>0&&s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:d.map(f=>s.jsx(br,{goal:f,progress:r.get(f.id),onArchive:n,onDelete:o,onEdit:a},f.id))}),u.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-3 uppercase tracking-wide",children:l("goalsList.completedHeading")}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:u.map(f=>s.jsx(br,{goal:f,progress:r.get(f.id),onArchive:n,onDelete:o},f.id))})]})]})},As=({onCreateClick:e})=>{const{t}=ee("goals"),r=[{key:"define",icon:Me,title:t("goalsList.workflow.defineTitle"),value:t("goalsList.workflow.defineValue"),onClick:e},{key:"link",icon:Pn,title:t("goalsList.workflow.linkTitle"),value:t("goalsList.workflow.linkValue"),onClick:e},{key:"track",icon:qt,title:t("goalsList.workflow.trackTitle"),value:t("goalsList.workflow.trackValue"),onClick:e}];return s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-6 max-w-6xl w-full mx-auto mt-8",children:r.map((n,o)=>{const a=n.icon;return s.jsxs(q.Fragment,{children:[s.jsxs("div",{onClick:n.onClick,className:"flex flex-col items-center justify-center text-center p-6 rounded-3xl border transition-all duration-300 min-h-[195px] font-body w-full sm:w-[260px] shrink-0 border-transparent bg-transparent opacity-60 text-muted-foreground hover:opacity-100 hover:border-zinc-300 dark:hover:border-white/10 hover:bg-zinc-100/10 dark:hover:bg-white/[0.01] shadow-sm hover:shadow-md cursor-pointer select-none",children:[s.jsx(a,{className:"h-14 w-14 mb-3 shrink-0 text-muted-foreground transition-colors"}),s.jsx("div",{className:"px-4 py-1.5 rounded-full text-[10px] font-bold tracking-widest uppercase mb-3 bg-zinc-100 dark:bg-white/[0.02] text-muted-foreground border border-zinc-200/60 dark:border-white/5",children:n.title}),s.jsx("span",{className:"text-xs text-muted-foreground max-w-[200px]",children:n.value})]}),o<r.length-1&&s.jsx("div",{className:"hidden lg:flex items-center justify-center text-muted-foreground
16/30 dark:text-zinc-800 shrink-0 select-none pointer-events-none",children:s.jsx(zn,{className:"h-6 w-6"})})]},n.key)})})},yr=({open:e,onOpenChange:t,connectedPlatforms:r,onCreate:n,goal:o,onSave:a})=>{const{t:i}=ee("goals"),l=!!o,[d,u]=c.useState(""),[f,m]=c.useState(""),[g,h]=c.useState(""),[y,p]=c.useState(""),[v,b]=c.useState(""),[j,w]=c.useState(""),[C,D]=c.useState(!1);c.useEffect(()=>{e&&(o?(u(o.title),m(o.platform),h(o.metric_key),p(String(o.target_value)),b(o.deadline?o.deadline.slice(0,10):""),w(o.notes??"")):(u(""),m(""),h(""),p(""),b(""),w("")))},[e,o]);const E=f?Bn[f]??[]:[],R=async()=>{if(!d.trim()||!f||!g){I.error(i("goalForm.errors.missingFields"));return}const N=Number(y);if(!Number.isFinite(N)||N<=0){I.error(i("goalForm.errors.invalidTarget"));return}D(!0);try{l&&o&&a?(await a({id:o.id,title:d.trim(),targetValue:N,deadline:v||null,notes:j.trim()||null}),I.success(i("goalForm.toasts.updated"))):n&&(await n({title:d.trim(),platform:f,metricKey:g,targetValue:N,deadline:v||void 0,notes:j.trim()||void 0}),I.success(i("goalForm.toasts.created"))),t(!1)}catch(k){I.error(k instanceof Error?k.message:i(l?"goalForm.errors.updateFailed":"goalForm.errors.createFailed"))}finally{D(!1)}};return s.jsx(zr,{open:e,onOpenChange:t,children:s.jsxs(Br,{className:"sm:max-w-md rounded-3xl sm:rounded-3xl border border-border shadow-md",children:[s.jsx(qr,{children:s.jsx($r,{className:"font-sans font-bold text-lg text-foreground",children:i(l?"goalForm.titleEdit":"goalForm.titleNew")})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.fieldTitle")}),s.jsx(Ge,{className:"rounded-xl mt-1",placeholder:i("goalForm.titlePlaceholder"),value:d,onChange:N=>u(N.target.value)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.platform")}),l?s.jsx("div",{className:"rounded-xl mt-1 h-10 px-3 flex items-center text-sm bg-muted/40 border border-border text-muted-foreground",children:ir[f]??f}):s.jsxs(lr,{value:f,onValueChange:N=>{m(N),h("")},children:[s.jsx(cr,{className:"rounded-xl mt-1",children:s.jsx(dr,{placeholder:i("goalForm.select")})}),s.jsx(ur,{children:r.map(N=>s.jsx(fr,{value:N,children:ir[N]},N))})]})]}),s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.metric")}),l?s.jsx("div",{className:"rounded-xl mt-1 h-10 px-3 flex items-center text-sm bg-muted/40 border border-border text-muted-foreground",children:Lt[g]??g}):s.jsxs(lr,{value:g,onValueChange:h,disabled:!f,children:[s.jsx(cr,{className:"rounded-xl mt-1",children:s.jsx(dr,{placeholder:i("goalForm.select")})}),s.jsx(ur,{children:E.map(N=>s.jsx(fr,{value:N,children:Lt[N]??N},N))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.targetValue")}),s.jsx(Ge,{className:"rounded-xl mt-1",type:"number",min:0,placeholder:i("goalForm.targetPlaceholder"),value:y,onChange:N=>p(N.target.value)})]}),s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.deadline")}),s.jsx(Ge,{className:"rounded-xl mt-1",type:"date",value:v,onChange:N=>b(N.target.value)})]})]}),s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:i("goalForm.notes")}),s.jsx(Vr,{className:"rounded-xl mt-1",rows:2,value:j,onChange:N=>w(N.target.value)})]}),s.jsx(Ze,{colorVariant:"brand",className:"w-full h-10 mt-2",onClick:R,disabled:C,children:i(C?"goalForm.saving":l?"goalForm.save":"goalForm.create")})]})]})})};function Os(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return c.useMemo(()=>n=>{t.forEach(o=>o(n))},t)}const yt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Le(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Vt(e){return"nodeType"in e}function V(e){var t,r;return e?Le(e)?e:Vt(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Gt(e){const{Document:t}=V(e);return e instanceof t}function et(e){return Le(e)?!1:e instanceof V(e).HTMLElement}function tn(e){return e instanceof V(e).SVGElement}function _e(e){return e?Le(e)?e.document:Vt(e)?Gt(e)?e:et(e)||tn(e)?e.ownerDocument:document:document:document}const ae=yt?c.useLayoutEffect:c.useEffect;function Yt(e){const t=c.useRef(e);return ae(()=>{t.current=e}),c.useCallback(function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return t.current==null?void 0:t.current(...n)},[])}function Fs(){const e=c.useRef(null),t=c.useCallback((n,o)=>{e.current=setInterval(n,o)},[]),r=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function He(e,t){t===void 0&&(t=[e]);const r=c.useRef(e);return ae(()=>{r.current!==e&&(r.current=e)},t),r}function tt(e,t){const r=c.useRef();return c.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...t])}function pt(e){const t=Yt(e),r=c.useRef(null),n=c.useCallback(o=>{o!==r.current&&(t==null||t(o,r.current)),r.current=o},[]);return[r,n]}function Ot(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let Rt={};function rt(e,t){return c.useMemo(()=>
16{if(t)return t;const r=Rt[e]==null?0:Rt[e]+1;return Rt[e]=r,e+"-"+r},[e,t])}function rn(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return n.reduce((a,i)=>{const l=Object.entries(i);for(const[d,u]of l){const f=a[d];f!=null&&(a[d]=f+e*u)}return a},{...t})}}const Te=rn(1),xt=rn(-1);function Is(e){return"clientX"in e&&"clientY"in e}function Ut(e){if(!e)return!1;const{KeyboardEvent:t}=V(e.target);return t&&e instanceof t}function Ps(e){if(!e)return!1;const{TouchEvent:t}=V(e.target);return t&&e instanceof t}function Ft(e){if(Ps(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Is(e)?{x:e.clientX,y:e.clientY}:null}const Qe=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Qe.Translate.toString(e),Qe.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:n}=e;return t+" "+r+"ms "+n}}}),wr="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zs(e){return e.matches(wr)?e:e.querySelector(wr)}const Bs={display:"none"};function qs(e){let{id:t,value:r}=e;return q.createElement("div",{id:t,style:Bs},r)}function $s(e){let{id:t,announcement:r,ariaLiveType:n="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return q.createElement("div",{id:t,style:o,role:"status","aria-live":n,"aria-atomic":!0},r)}function Vs(){const[e,t]=c.useState("");return{announce:c.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const nn=c.createContext(null);function Gs(e){const t=c.useContext(nn);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ys(){const[e]=c.useState(()=>new Set),t=c.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[c.useCallback(n=>{let{type:o,event:a}=n;e.forEach(i=>{var l;return(l=i[o])==null?void 0:l.call(i,a)})},[e]),t]}const Us={draggable:`
17    To pick up a draggable item, press the space bar.
18    While dragging, use the arrow keys to move the item.
19    Press space again to drop the item in its new position, or press escape to cancel.
20  `},Ks={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Ws(e){let{announcements:t=Ks,container:r,hiddenTextDescribedById:n,screenReaderInstructions:o=Us}=e;const{announce:a,announcement:i}=Vs(),l=rt("DndLiveRegion"),[d,u]=c.useState(!1);if(c.useEffect(()=>{u(!0)},[]),Gs(c.useMemo(()=>({onDragStart(m){let{active:g}=m;a(t.onDragStart({active:g}))},onDragMove(m){let{active:g,over:h}=m;t.onDragMove&&a(t.onDragMove({active:g,over:h}))},onDragOver(m){let{active:g,over:h}=m;a(t.onDragOver({active:g,over:h}))},onDragEnd(m){let{active:g,over:h}=m;a(t.onDragEnd({active:g,over:h}))},onDragCancel(m){let{active:g,over:h}=m;a(t.onDragCancel({active:g,over:h}))}}),[a,t])),!d)return null;const f=q.createElement(q.Fragment,null,q.createElement(qs,{id:n,value:o.draggable}),q.createElement($s,{id:l,announcement:i}));return r?Ve.createPortal(f,r):f}var _;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(_||(_={}));function vt(){}function Xs(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Hs(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return c.useMemo(()=>[...t].filter(n=>n!=null),[...t])}const Z=Object.freeze({x:0,y:0});function Qs(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Js(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return r-n}function Zs(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function eo(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Nr(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const to=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=Nr(t,t.left,t.top),a=[];for(const i of n){const{id:l}=i,d=r.get(l);if(d){const u=Qs(Nr(d),o);a.push({id:l,data:{droppableContainer:i,value:u}})}}return a.sort(Js)};function ro(e,t){const r=Math.max(t.top,e.top),n=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),i=o-n,l=a-r;if(n<o&&r<a){const d=t.width*t.height,u=e.width*e.height,f=i*l,m=f/(d+u-f);return Number(m.toFixed(4))}return 0}const no=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const o=[];for(const a of n){const{id:i}=a,l=r.get(i);if(l){const d=ro(l,t);d>0&&o.push({id:i,data:{droppableContainer:a,value:d}})}}return o.sort(Zs)};function so(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function sn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Z}function oo(e){return function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return o.reduce((i,l)=>
20({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...r})}}const ao=oo(1);function io(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function lo(e,t,r){const n=io(t);if(!n)return e;const{scaleX:o,scaleY:a,x:i,y:l}=n,d=e.left-i-(1-o)*parseFloat(r),u=e.top-l-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),f=o?e.width/o:e.width,m=a?e.height/a:e.height;return{width:f,height:m,top:u,right:d+f,bottom:u+m,left:d}}const co={ignoreTransform:!1};function Ae(e,t){t===void 0&&(t=co);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=V(e).getComputedStyle(e);u&&(r=lo(r,u,f))}const{top:n,left:o,width:a,height:i,bottom:l,right:d}=r;return{top:n,left:o,width:a,height:i,bottom:l,right:d}}function jr(e){return Ae(e,{ignoreTransform:!0})}function uo(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function fo(e,t){return t===void 0&&(t=V(e).getComputedStyle(e)),t.position==="fixed"}function mo(e,t){t===void 0&&(t=V(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const a=t[o];return typeof a=="string"?r.test(a):!1})}function Kt(e,t){const r=[];function n(o){if(t!=null&&r.length>=t||!o)return r;if(Gt(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!et(o)||tn(o)||r.includes(o))return r;const a=V(e).getComputedStyle(o);return o!==e&&mo(o,a)&&r.push(o),fo(o,a)?r:n(o.parentNode)}return e?n(e):r}function on(e){const[t]=Kt(e,1);return t??null}function Et(e){return!yt||!e?null:Le(e)?e:Vt(e)?Gt(e)||e===_e(e).scrollingElement?window:et(e)?e:null:null}function an(e){return Le(e)?e.scrollX:e.scrollLeft}function ln(e){return Le(e)?e.scrollY:e.scrollTop}function It(e){return{x:an(e),y:ln(e)}}var F;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(F||(F={}));function cn(e){return!yt||!e?!1:e===document.scrollingElement}function dn(e){const t={x:0,y:0},r=cn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,i=e.scrollTop>=n.y,l=e.scrollLeft>=n.x;return{isTop:o,isLeft:a,isBottom:i,isRight:l,maxScroll:n,minScroll:t}}const ho={x:.2,y:.2};function go(e,t,r,n,o){let{top:a,left:i,right:l,bottom:d}=r;n===void 0&&(n=10),o===void 0&&(o=ho);const{isTop:u,isBottom:f,isLeft:m,isRight:g}=dn(e),h={x:0,y:0},y={x:0,y:0},p={height:t.height*o.y,width:t.width*o.x};return!u&&a<=t.top+p.height?(h.y=F.Backward,y.y=n*Math.abs((t.top+p.height-a)/p.height)):!f&&d>=t.bottom-p.height&&(h.y=F.Forward,y.y=n*Math.abs((t.bottom-p.height-d)/p.height)),!g&&l>=t.right-p.width?(h.x=F.Forward,y.x=n*Math.abs((t.right-p.width-l)/p.width)):!m&&i<=t.left+p.width&&(h.x=F.Backward,y.x=n*Math.abs((t.left+p.width-i)/p.width)),{direction:h,speed:y}}function po(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:i}=window;return{top:0,left:0,right:a,bottom:i,width:a,height:i}}const{top:t,left:r,right:n,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:o,width:e.clientWidth,height:e.clientHeight}}function un(e){return e.reduce((t,r)=>Te(t,It(r)),Z)}function xo(e){return e.reduce((t,r)=>t+an(r),0)}function vo(e){return e.reduce((t,r)=>t+ln(r),0)}function bo(e,t){if(t===void 0&&(t=Ae),!e)return;const{top:r,left:n,bottom:o,right:a}=t(e);on(e)&&(o<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const yo=[["x",["left","right"],xo],["y",["top","bottom"],vo]];class Wt{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Kt(r),o=un(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,i,l]of yo)for(const d of i)Object.defineProperty(this,d,{get:()=>{const u=l(n),f=o[a]-u;return this.rect[d]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}
20class Ue{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var o;(o=this.target)==null||o.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function wo(e){const{EventTarget:t}=V(e);return e instanceof t?e:_e(e)}function Tt(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var Q;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Q||(Q={}));function kr(e){e.preventDefault()}function No(e){e.stopPropagation()}var M;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(M||(M={}));const fn={start:[M.Space,M.Enter],cancel:[M.Esc],end:[M.Space,M.Enter,M.Tab]},jo=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case M.Right:return{...r,x:r.x+25};case M.Left:return{...r,x:r.x-25};case M.Down:return{...r,y:r.y+25};case M.Up:return{...r,y:r.y-25}}};class mn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new Ue(_e(r)),this.windowListeners=new Ue(V(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Q.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&bo(n),r(Z)}handleKeyDown(t){if(Ut(t)){const{active:r,context:n,options:o}=this.props,{keyboardCodes:a=fn,coordinateGetter:i=jo,scrollBehavior:l="smooth"}=o,{code:d}=t;if(a.end.includes(d)){this.handleEnd(t);return}if(a.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:u}=n.current,f=u?{x:u.left,y:u.top}:Z;this.referenceCoordinates||(this.referenceCoordinates=f);const m=i(t,{active:r,context:n.current,currentCoordinates:f});if(m){const g=xt(m,f),h={x:0,y:0},{scrollableAncestors:y}=n.current;for(const p of y){const v=t.code,{isTop:b,isRight:j,isLeft:w,isBottom:C,maxScroll:D,minScroll:E}=dn(p),R=po(p),N={x:Math.min(v===M.Right?R.right-R.width/2:R.right,Math.max(v===M.Right?R.left:R.left+R.width/2,m.x)),y:Math.min(v===M.Down?R.bottom-R.height/2:R.bottom,Math.max(v===M.Down?R.top:R.top+R.height/2,m.y))},k=v===M.Right&&!j||v===M.Left&&!w,S=v===M.Down&&!C||v===M.Up&&!b;if(k&&N.x!==m.x){const x=p.scrollLeft+g.x,T=v===M.Right&&x<=D.x||v===M.Left&&x>=E.x;if(T&&!g.y){p.scrollTo({left:x,behavior:l});return}T?h.x=p.scrollLeft-x:h.x=v===M.Right?p.scrollLeft-D.x:p.scrollLeft-E.x,h.x&&p.scrollBy({left:-h.x,behavior:l});break}else if(S&&N.y!==m.y){const x=p.scrollTop+g.y,T=v===M.Down&&x<=D.y||v===M.Up&&x>=E.y;if(T&&!g.x){p.scrollTo({top:x,behavior:l});return}T?h.y=p.scrollTop-x:h.y=v===M.Down?p.scrollTop-D.y:p.scrollTop-E.y,h.y&&p.scrollBy({top:-h.y,behavior:l});break}}this.handleMove(t,Te(xt(m,this.referenceCoordinates),h))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}mn.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=fn,onActivation:o}=t,{active:a}=r;const{code:i}=e.nativeEvent;if(n.start.includes(i)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Cr(e){return!!(e&&"distance"in e)}function Sr(e){return!!(e&&"delay"in e)}class Xt{constructor(t,r,n){var o;n===void 0&&(n=wo(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:a}=t,{target:i}=a;this.props=t,this.events=r,this.document=_e(i),this.documentListeners=new Ue(this.document),this.listeners=new Ue(n),this.windowListeners=new Ue(V(i)),this.initialCoordinates=(o=Ft(a))!=null?o:Z,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.DragStart,kr),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),this.windowListeners.add(Q.ContextMenu,kr),this.documentListeners.add(Q.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Sr(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Cr(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:n,onPending:o}=this.props;o(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Q.Click,No,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Q.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:o,props:a}=this,{onMove:i,options:{activationConstraint:l}}=a;if(!o)return;const d=(r=Ft(t))!=null?r:Z,u=xt(o,d);if(!n&&l){if(Cr(l)){if(l.tolerance!=null&&Tt(u,l.tolerance))return this.handleCancel();if(Tt(u,l.distance))return this.handleStart()}if(Sr(l)&&Tt(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),i(d)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===M.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ko={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ht extends Xt{constructor(t){const{event:r}=t,n=_e(r.target);super(t,ko,n)}}Ht.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const Co={move:{name:"mousemove"},end:{name:"mouseup"}};var Pt;
20(function(e){e[e.RightClick=2]="RightClick"})(Pt||(Pt={}));class So extends Xt{constructor(t){super(t,Co,_e(t.event.target))}}So.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===Pt.RightClick?!1:(n==null||n({event:r}),!0)}}];const Mt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Do extends Xt{constructor(t){super(t,Mt)}static setup(){return window.addEventListener(Mt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Mt.move.name,t)};function t(){}}}Do.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:o}=r;return o.length>1?!1:(n==null||n({event:r}),!0)}}];var Ke;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ke||(Ke={}));var bt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bt||(bt={}));function Ro(e){let{acceleration:t,activator:r=Ke.Pointer,canScroll:n,draggingRect:o,enabled:a,interval:i=5,order:l=bt.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:f,delta:m,threshold:g}=e;const h=To({delta:m,disabled:!a}),[y,p]=Fs(),v=c.useRef({x:0,y:0}),b=c.useRef({x:0,y:0}),j=c.useMemo(()=>{switch(r){case Ke.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Ke.DraggableRect:return o}},[r,o,d]),w=c.useRef(null),C=c.useCallback(()=>{const E=w.current;if(!E)return;const R=v.current.x*b.current.x,N=v.current.y*b.current.y;E.scrollBy(R,N)},[]),D=c.useMemo(()=>l===bt.TreeOrder?[...u].reverse():u,[l,u]);c.useEffect(()=>{if(!a||!u.length||!j){p();return}for(const E of D){if((n==null?void 0:n(E))===!1)continue;const R=u.indexOf(E),N=f[R];if(!N)continue;const{direction:k,speed:S}=go(E,N,j,t,g);for(const x of["x","y"])h[x][k[x]]||(S[x]=0,k[x]=0);if(S.x>0||S.y>0){p(),w.current=E,y(C,i),v.current=S,b.current=k;return}}v.current={x:0,y:0},b.current={x:0,y:0},p()},[t,C,n,p,a,i,JSON.stringify(j),JSON.stringify(h),y,u,D,f,JSON.stringify(g)])}const Eo={x:{[F.Backward]:!1,[F.Forward]:!1},y:{[F.Backward]:!1,[F.Forward]:!1}};function To(e){let{delta:t,disabled:r}=e;const n=Ot(t);return tt(o=>{if(r||!n||!o)return Eo;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[F.Backward]:o.x[F.Backward]||a.x===-1,[F.Forward]:o.x[F.Forward]||a.x===1},y:{[F.Backward]:o.y[F.Backward]||a.y===-1,[F.Forward]:o.y[F.Forward]||a.y===1}}},[r,t,n])}function Mo(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return tt(o=>{var a;return t==null?null:(a=n??o)!=null?a:null},[n,t])}function Lo(e,t){return c.useMemo(()=>e.reduce((r,n)=>{const{sensor:o}=n,a=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,n)}));return[...r,...a]},[]),[e,t])}var Je;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Je||(Je={}));var zt;(function(e){e.Optimized="optimized"})(zt||(zt={}));const Dr=new Map;function _o(e,t){let{dragging:r,dependencies:n,config:o}=t;const[a,i]=c.useState(null),{frequency:l,measure:d,strategy:u}=o,f=c.useRef(e),m=v(),g=He(m),h=c.useCallback(function(b){b===void 0&&(b=[]),!g.current&&i(j=>j===null?b:j.concat(b.filter(w=>!j.includes(w))))},[g]),y=c.useRef(null),p=tt(b=>{if(m&&!r)return Dr;if(!b||b===Dr||f.current!==e||a!=null){const j=new Map;for(let w of e){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){j.set(w.id,w.rect.current);continue}const C=w.node.current,D=C?new Wt(d(C),C):null;w.rect.current=D,D&&j.set(w.id,D)}return j}return b},[e,a,r,m,d]);return c.useEffect(()=>{f.current=e},[e]),c.useEffect(()=>{m||h()},[r,m]),c.useEffect(()=>{a&&a.length>0&&i(null)},[JSON.stringify(a)]),c.useEffect(()=>{m||typeof l!="number"||y.current!==null||(y.current=setTimeout(()=>{h(),y.current=null},l))},[l,m,h,...n]),{droppableRects:p,measureDroppableContainers:h,measuringScheduled:a!=null};function v(){switch(u){case Je.Always:return!1;case Je.BeforeDragging:return r;default:return!r}}}function hn(e,t){return tt(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function Ao(e,t){return hn(e,t)}function Oo(e){let{callback:t,disabled:r}=e;const n=Yt(t),o=c.useMemo(()=>
20{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return c.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function wt(e){let{callback:t,disabled:r}=e;const n=Yt(t),o=c.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return c.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Fo(e){return new Wt(Ae(e),e)}function Rr(e,t,r){t===void 0&&(t=Fo);const[n,o]=c.useState(null);function a(){o(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??r)!=null?u:null}const f=t(e);return JSON.stringify(d)===JSON.stringify(f)?d:f})}const i=Oo({callback(d){if(e)for(const u of d){const{type:f,target:m}=u;if(f==="childList"&&m instanceof HTMLElement&&m.contains(e)){a();break}}}}),l=wt({callback:a});return ae(()=>{a(),e?(l==null||l.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),i==null||i.disconnect())},[e]),n}function Io(e){const t=hn(e);return sn(e,t)}const Er=[];function Po(e){const t=c.useRef(e),r=tt(n=>e?n&&n!==Er&&e&&t.current&&e.parentNode===t.current.parentNode?n:Kt(e):Er,[e]);return c.useEffect(()=>{t.current=e},[e]),r}function zo(e){const[t,r]=c.useState(null),n=c.useRef(e),o=c.useCallback(a=>{const i=Et(a.target);i&&r(l=>l?(l.set(i,It(i)),new Map(l)):null)},[]);return c.useEffect(()=>{const a=n.current;if(e!==a){i(a);const l=e.map(d=>{const u=Et(d);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,It(u)]):null}).filter(d=>d!=null);r(l.length?new Map(l):null),n.current=e}return()=>{i(e),i(a)};function i(l){l.forEach(d=>{const u=Et(d);u==null||u.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,i)=>Te(a,i),Z):un(e):Z,[e,t])}function Tr(e,t){t===void 0&&(t=[]);const r=c.useRef(null);return c.useEffect(()=>{r.current=null},t),c.useEffect(()=>{const n=e!==Z;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?xt(e,r.current):Z}function Bo(e){c.useEffect(()=>{if(!yt)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r==null||r()}},e.map(t=>{let{sensor:r}=t;return r}))}function qo(e,t){return c.useMemo(()=>e.reduce((r,n)=>{let{eventName:o,handler:a}=n;return r[o]=i=>{a(i,t)},r},{}),[e,t])}function gn(e){return c.useMemo(()=>e?uo(e):null,[e])}const Mr=[];function $o(e,t){t===void 0&&(t=Ae);const[r]=e,n=gn(r?V(r):null),[o,a]=c.useState(Mr);function i(){a(()=>e.length?e.map(d=>cn(d)?n:new Wt(t(d),d)):Mr)}const l=wt({callback:i});return ae(()=>{l==null||l.disconnect(),i(),e.forEach(d=>l==null?void 0:l.observe(d))},[e]),o}function Vo(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return et(t)?t:e}function Go(e){let{measure:t}=e;const[r,n]=c.useState(null),o=c.useCallback(u=>{for(const{target:f}of u)if(et(f)){n(m=>{const g=t(f);return m?{...m,width:g.width,height:g.height}:g});break}},[t]),a=wt({callback:o}),i=c.useCallback(u=>{const f=Vo(u);a==null||a.disconnect(),f&&(a==null||a.observe(f)),n(f?t(f):null)},[t,a]),[l,d]=pt(i);return c.useMemo(()=>({nodeRef:l,rect:r,setRef:d}),[r,l,d])}const Yo=[{sensor:Ht,options:{}},{sensor:mn,options:{}}],Uo={current:{}},ht={draggable:{measure:jr},droppable:{measure:jr,strategy:Je.WhileDragging,frequency:zt.Optimized},dragOverlay:{measure:Ae}};class We extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const Ko={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new We,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:vt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ht,measureDroppableContainers:vt,windowRect:null,measuringScheduled:!1},Wo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:vt,draggableNodes:new Map,over:null,measureDroppableContainers:vt},Nt=c.createContext(Wo),pn=c.createContext(Ko);function Xo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new We}}}function Ho(e,t){switch(t.type){case _.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case _.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case _.DragEnd:case _.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case _.RegisterDroppable:{const{element:r}=t,{id:n}
20=r,o=new We(e.droppable.containers);return o.set(n,r),{...e,droppable:{...e.droppable,containers:o}}}case _.SetDroppableDisabled:{const{id:r,key:n,disabled:o}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const i=new We(e.droppable.containers);return i.set(r,{...a,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case _.UnregisterDroppable:{const{id:r,key:n}=t,o=e.droppable.containers.get(r);if(!o||n!==o.key)return e;const a=new We(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Qo(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:o}=c.useContext(Nt),a=Ot(n),i=Ot(r==null?void 0:r.id);return c.useEffect(()=>{if(!t&&!n&&a&&i!=null){if(!Ut(a)||document.activeElement===a.target)return;const l=o.get(i);if(!l)return;const{activatorNode:d,node:u}=l;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[d.current,u.current]){if(!f)continue;const m=zs(f);if(m){m.focus();break}}})}},[n,t,o,i,a]),null}function Jo(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((o,a)=>a({transform:o,...n}),r):r}function Zo(e){return c.useMemo(()=>({draggable:{...ht.draggable,...e==null?void 0:e.draggable},droppable:{...ht.droppable,...e==null?void 0:e.droppable},dragOverlay:{...ht.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function ea(e){let{activeNode:t,measure:r,initialRect:n,config:o=!0}=e;const a=c.useRef(!1),{x:i,y:l}=typeof o=="boolean"?{x:o,y:o}:o;ae(()=>{if(!i&&!l||!t){a.current=!1;return}if(a.current||!n)return;const u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;const f=r(u),m=sn(f,n);if(i||(m.x=0),l||(m.y=0),a.current=!0,Math.abs(m.x)>0||Math.abs(m.y)>0){const g=on(u);g&&g.scrollBy({top:m.y,left:m.x})}},[t,i,l,n,r])}const xn=c.createContext({...Z,scaleX:1,scaleY:1});var ye;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ye||(ye={}));const ta=c.memo(function(t){var r,n,o,a;let{id:i,accessibility:l,autoScroll:d=!0,children:u,sensors:f=Yo,collisionDetection:m=no,measuring:g,modifiers:h,...y}=t;const p=c.useReducer(Ho,void 0,Xo),[v,b]=p,[j,w]=Ys(),[C,D]=c.useState(ye.Uninitialized),E=C===ye.Initialized,{draggable:{active:R,nodes:N,translate:k},droppable:{containers:S}}=v,x=R!=null?N.get(R):null,T=c.useRef({initial:null,translated:null}),P=c.useMemo(()=>{var B;return R!=null?{id:R,data:(B=x==null?void 0:x.data)!=null?B:Uo,rect:T}:null},[R,x]),A=c.useRef(null),[fe,G]=c.useState(null),[O,me]=c.useState(null),W=He(y,Object.values(y)),Oe=rt("DndDescribedBy",i),nt=c.useMemo(()=>S.getEnabled(),[S]),$=Zo(g),{droppableRects:ie,measureDroppableContainers:je,measuringScheduled:Fe}=_o(nt,{dragging:E,dependencies:[k.x,k.y],config:$.droppable}),X=Mo(N,R),st=c.useMemo(()=>O?Ft(O):null,[O]),he=En(),le=Ao(X,$.draggable.measure);ea({activeNode:R!=null?N.get(R):null,config:he.layoutShiftCompensation,initialRect:le,measure:$.draggable.measure});const L=Rr(X,$.draggable.measure,le),Ie=Rr(X?X.parentElement:null),te=c.useRef({activatorEvent:null,active:null,activeNode:X,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ke=S.getNodeFor((r=te.current.over)==null?void 0:r.id),ce=Go({measure:$.dragOverlay.measure}),Ce=(n=ce.nodeRef.current)!=null?n:X,Se=E?(o=ce.rect)!=null?o:L:null,Jt=!!(ce.nodeRef.current&&ce.rect),Zt=Io(Jt?null:L),jt=gn(Ce?V(Ce):null),ge=Po(E?ke??X:null),ot=$o(ge),at=Jo(h,{transform:{x:k.x-Zt.x,y:k.y-Zt.y,scaleX:1,scaleY:1},activatorEvent:O,active:P,activeNodeRect:L,containerNodeRect:Ie,draggingNodeRect:Se,over:te.current.over,overlayNodeRect:ce.rect,scrollableAncestors:ge,scrollableAncestorRects:ot,windowRect:jt}),er=st?Te(st,k):null,tr=zo(ge),Nn=Tr(tr),jn=Tr(tr,[L]),De=Te(at,Nn),Re=Se?ao(Se,at):null,Pe=P&&Re?m({active:P,collisionRect:Re,droppableRects:ie,droppableContainers:nt,pointerCoordinates:er}):null,rr=eo(Pe,"id"),[pe,nr]=c.useState(null),kn=Jt?at:Te(at,jn),Cn=so(kn,(a=pe==null?void 0:pe.rect)!=null?a:null,
20L),kt=c.useRef(null),sr=c.useCallback((B,Y)=>{let{sensor:U,options:xe}=Y;if(A.current==null)return;const H=N.get(A.current);if(!H)return;const K=B.nativeEvent,re=new U({active:A.current,activeNode:H,event:K,options:xe,context:te,onAbort(z){if(!N.get(z))return;const{onDragAbort:ne}=W.current,de={id:z};ne==null||ne(de),j({type:"onDragAbort",event:de})},onPending(z,ve,ne,de){if(!N.get(z))return;const{onDragPending:Be}=W.current,be={id:z,constraint:ve,initialCoordinates:ne,offset:de};Be==null||Be(be),j({type:"onDragPending",event:be})},onStart(z){const ve=A.current;if(ve==null)return;const ne=N.get(ve);if(!ne)return;const{onDragStart:de}=W.current,ze={activatorEvent:K,active:{id:ve,data:ne.data,rect:T}};Ve.unstable_batchedUpdates(()=>{de==null||de(ze),D(ye.Initializing),b({type:_.DragStart,initialCoordinates:z,active:ve}),j({type:"onDragStart",event:ze}),G(kt.current),me(K)})},onMove(z){b({type:_.DragMove,coordinates:z})},onEnd:Ee(_.DragEnd),onCancel:Ee(_.DragCancel)});kt.current=re;function Ee(z){return async function(){const{active:ne,collisions:de,over:ze,scrollAdjustedTranslate:Be}=te.current;let be=null;if(ne&&Be){const{cancelDrop:qe}=W.current;be={activatorEvent:K,active:ne,collisions:de,delta:Be,over:ze},z===_.DragEnd&&typeof qe=="function"&&await Promise.resolve(qe(be))&&(z=_.DragCancel)}A.current=null,Ve.unstable_batchedUpdates(()=>{b({type:z}),D(ye.Uninitialized),nr(null),G(null),me(null),kt.current=null;const qe=z===_.DragEnd?"onDragEnd":"onDragCancel";if(be){const Ct=W.current[qe];Ct==null||Ct(be),j({type:qe,event:be})}})}}},[N]),Sn=c.useCallback((B,Y)=>(U,xe)=>{const H=U.nativeEvent,K=N.get(xe);if(A.current!==null||!K||H.dndKit||H.defaultPrevented)return;const re={active:K};B(U,Y.options,re)===!0&&(H.dndKit={capturedBy:Y.sensor},A.current=xe,sr(U,Y))},[N,sr]),or=Lo(f,Sn);Bo(f),ae(()=>{L&&C===ye.Initializing&&D(ye.Initialized)},[L,C]),c.useEffect(()=>{const{onDragMove:B}=W.current,{active:Y,activatorEvent:U,collisions:xe,over:H}=te.current;if(!Y||!U)return;const K={active:Y,activatorEvent:U,collisions:xe,delta:{x:De.x,y:De.y},over:H};Ve.unstable_batchedUpdates(()=>{B==null||B(K),j({type:"onDragMove",event:K})})},[De.x,De.y]),c.useEffect(()=>{const{active:B,activatorEvent:Y,collisions:U,droppableContainers:xe,scrollAdjustedTranslate:H}=te.current;if(!B||A.current==null||!Y||!H)return;const{onDragOver:K}=W.current,re=xe.get(rr),Ee=re&&re.rect.current?{id:re.id,rect:re.rect.current,data:re.data,disabled:re.disabled}:null,z={active:B,activatorEvent:Y,collisions:U,delta:{x:H.x,y:H.y},over:Ee};Ve.unstable_batchedUpdates(()=>{nr(Ee),K==null||K(z),j({type:"onDragOver",event:z})})},[rr]),ae(()=>{te.current={activatorEvent:O,active:P,activeNode:X,collisionRect:Re,collisions:Pe,droppableRects:ie,draggableNodes:N,draggingNode:Ce,draggingNodeRect:Se,droppableContainers:S,over:pe,scrollableAncestors:ge,scrollAdjustedTranslate:De},T.current={initial:Se,translated:Re}},[P,X,Pe,Re,N,Ce,Se,ie,S,pe,ge,De]),Ro({...he,delta:k,draggingRect:Re,pointerCoordinates:er,scrollableAncestors:ge,scrollableAncestorRects:ot});const Dn=c.useMemo(()=>({active:P,activeNode:X,activeNodeRect:L,activatorEvent:O,collisions:Pe,containerNodeRect:Ie,dragOverlay:ce,draggableNodes:N,droppableContainers:S,droppableRects:ie,over:pe,measureDroppableContainers:je,scrollableAncestors:ge,scrollableAncestorRects:ot,measuringConfiguration:$,measuringScheduled:Fe,windowRect:jt}),[P,X,L,O,Pe,Ie,ce,N,S,ie,pe,je,ge,ot,$,Fe,jt]),Rn=c.useMemo(()=>({activatorEvent:O,activators:or,active:P,activeNodeRect:L,ariaDescribedById:{draggable:Oe},dispatch:b,draggableNodes:N,over:pe,measureDroppableContainers:je}),[O,or,P,L,b,Oe,N,pe,je]);return q.createElement(nn.Provider,{value:w},q.createElement(Nt.Provider,{value:Rn},q.createElement(pn.Provider,{value:Dn},q.createElement(xn.Provider,{value:Cn},u)),q.createElement(Qo,{disabled:(l==null?void 0:l.restoreFocus)===!1})),q.createElement(Ws,{...l,hiddenTextDescribedById:Oe}));function En(){const B=(fe==null?void 0:fe.autoScrollEnabled)===!1,Y=typeof d=="object"?d.enabled===!1:d===!1,U=E&&!B&&!Y;return typeof d=="object"?{...d,enabled:U}:{enabled:U}}}),ra=c.createContext(null),Lr="button",na="Draggable";function sa(e){let{id:t,data:r,disabled:n=!1,attributes:o}=e;const a=rt(na),{activators:i,activatorEvent:l,active:d,activeNodeRect:u,ariaDescribedById:f,draggableNodes:m,over:g}=c.useContext(Nt),{role:h=Lr,roleDescription:y="draggable",tabIndex:p=0}=o??{},v=(d==null?void 0:d.id)===t,b=c.useContext(v?xn:ra),[j,w]=pt(),[C,D]=pt(),E=qo(i,t),R=He(r);ae(()=>(m.set(t,{id:t,key:a,node:j,activatorNode:C,data:R}),()=>{const k=m.get(t);k&&k.key===a&&m.delete(t)}),[m,t]);const N=c.useMemo(()=>({role:h,tabIndex:p,"aria-disabled":n,"aria-pressed":v&&h===Lr?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[n,h,p,v,y,f.draggable]);return{active:d,activatorEvent:l,activeNodeRect:u,attributes:N,isDragging:v,listeners:n?void 0:E,node:j,over:g,setNodeRef:w,setActivatorNodeRef:D,transform:b}}function oa(){return c.useContext(pn)}const aa="Droppable",ia={timeout:25};function la(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:o}=e;const a=rt(aa),{active:i,dispatch:l,over:d,measureDroppableContainers:u}=c.useContext(Nt),f=c.useRef({disabled:r}),m=c.useRef(!1),g=c.useRef(null),h=c.useRef(null),{disabled:y,updateMeasurementsFor:p,timeout:v}={...ia,...o},b=He(p??n),j=c.useCallback(()=>
20{if(!m.current){m.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),h.current=null},v)},[v]),w=wt({callback:j,disabled:y||!i}),C=c.useCallback((N,k)=>{w&&(k&&(w.unobserve(k),m.current=!1),N&&w.observe(N))},[w]),[D,E]=pt(C),R=He(t);return c.useEffect(()=>{!w||!D.current||(w.disconnect(),m.current=!1,w.observe(D.current))},[D,w]),c.useEffect(()=>(l({type:_.RegisterDroppable,element:{id:n,key:a,disabled:r,node:D,rect:g,data:R}}),()=>l({type:_.UnregisterDroppable,key:a,id:n})),[n]),c.useEffect(()=>{r!==f.current.disabled&&(l({type:_.SetDroppableDisabled,id:n,key:a,disabled:r}),f.current.disabled=r)},[n,a,r,l]),{active:i,rect:g,isOver:(d==null?void 0:d.id)===n,node:D,over:d,setNodeRef:E}}function Qt(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function ca(e,t){return e.reduce((r,n,o)=>{const a=t.get(n);return a&&(r[o]=a),r},Array(e.length))}function ut(e){return e!==null&&e>=0}function da(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function ua(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const vn=e=>{let{rects:t,activeIndex:r,overIndex:n,index:o}=e;const a=Qt(t,n,r),i=t[o],l=a[o];return!l||!i?null:{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}},ft={scaleX:1,scaleY:1},fa=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:o,rects:a,overIndex:i}=e;const l=(t=a[r])!=null?t:n;if(!l)return null;if(o===r){const u=a[i];return u?{x:0,y:r<i?u.top+u.height-(l.top+l.height):u.top-l.top,...ft}:null}const d=ma(a,o,r);return o>r&&o<=i?{x:0,y:-l.height-d,...ft}:o<r&&o>=i?{x:0,y:l.height+d,...ft}:{x:0,y:0,...ft}};function ma(e,t,r){const n=e[t],o=e[t-1],a=e[t+1];return n?r<t?o?n.top-(o.top+o.height):a?a.top-(n.top+n.height):0:a?a.top-(n.top+n.height):o?n.top-(o.top+o.height):0:0}const bn="Sortable",yn=q.createContext({activeIndex:-1,containerId:bn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:vn,disabled:{draggable:!1,droppable:!1}});function ha(e){let{children:t,id:r,items:n,strategy:o=vn,disabled:a=!1}=e;const{active:i,dragOverlay:l,droppableRects:d,over:u,measureDroppableContainers:f}=oa(),m=rt(bn,r),g=l.rect!==null,h=c.useMemo(()=>n.map(E=>typeof E=="object"&&"id"in E?E.id:E),[n]),y=i!=null,p=i?h.indexOf(i.id):-1,v=u?h.indexOf(u.id):-1,b=c.useRef(h),j=!da(h,b.current),w=v!==-1&&p===-1||j,C=ua(a);ae(()=>{j&&y&&f(h)},[j,h,y,f]),c.useEffect(()=>{b.current=h},[h]);const D=c.useMemo(()=>({activeIndex:p,containerId:m,disabled:C,disableTransforms:w,items:h,overIndex:v,useDragOverlay:g,sortedRects:ca(h,d),strategy:o}),[p,m,C.draggable,C.droppable,w,h,v,d,g,o]);return q.createElement(yn.Provider,{value:D},t)}const ga=e=>{let{id:t,items:r,activeIndex:n,overIndex:o}=e;return Qt(r,n,o).indexOf(t)},pa=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:o,items:a,newIndex:i,previousItems:l,previousContainerId:d,transition:u}=e;return!u||!n||l!==a&&o===i?!1:r?!0:i!==o&&t===d},xa={duration:200,easing:"ease"},wn="transform",va=Qe.Transition.toString({property:wn,duration:0,easing:"linear"}),ba={roleDescription:"sortable"};function ya(e){let{disabled:t,index:r,node:n,rect:o}=e;const[a,i]=c.useState(null),l=c.useRef(r);return ae(()=>{if(!t&&r!==l.current&&n.current){const d=o.current;if(d){const u=Ae(n.current,{ignoreTransform:!0}),f={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(f.x||f.y)&&i(f)}}r!==l.current&&(l.current=r)},[t,r,n,o]),c.useEffect(()=>{a&&i(null)},[a]),a}function wa(e){let{animateLayoutChanges:t=pa,attributes:r,disabled:n,data:o,getNewIndex:a=ga,id:i,strategy:l,resizeObserverConfig:d,transition:u=xa}=e;const{items:f,containerId:m,activeIndex:g,disabled:h,disableTransforms:y,sortedRects:p,overIndex:v,useDragOverlay:b,strategy:j}=c.useContext(yn),w=Na(n,h),C=f.indexOf(i),D=c.useMemo(()=>({sortable:{containerId:m,index:C,items:f},...o}),[m,o,C,f]),E=c.useMemo(()=>f.slice(f.indexOf(i)),[f,i]),{rect:R,node:N,isOver:k,setNodeRef:S}=la({id:i,data:D,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...d}}
20),{active:x,activatorEvent:T,activeNodeRect:P,attributes:A,setNodeRef:fe,listeners:G,isDragging:O,over:me,setActivatorNodeRef:W,transform:Oe}=sa({id:i,data:D,attributes:{...ba,...r},disabled:w.draggable}),nt=Os(S,fe),$=!!x,ie=$&&!y&&ut(g)&&ut(v),je=!b&&O,Fe=je&&ie?Oe:null,st=ie?Fe??(l??j)({rects:p,activeNodeRect:P,activeIndex:g,overIndex:v,index:C}):null,he=ut(g)&&ut(v)?a({id:i,items:f,activeIndex:g,overIndex:v}):C,le=x==null?void 0:x.id,L=c.useRef({activeId:le,items:f,newIndex:he,containerId:m}),Ie=f!==L.current.items,te=t({active:x,containerId:m,isDragging:O,isSorting:$,id:i,index:C,items:f,newIndex:L.current.newIndex,previousItems:L.current.items,previousContainerId:L.current.containerId,transition:u,wasDragging:L.current.activeId!=null}),ke=ya({disabled:!te,index:C,node:N,rect:R});return c.useEffect(()=>{$&&L.current.newIndex!==he&&(L.current.newIndex=he),m!==L.current.containerId&&(L.current.containerId=m),f!==L.current.items&&(L.current.items=f)},[$,he,m,f]),c.useEffect(()=>{if(le===L.current.activeId)return;if(le!=null&&L.current.activeId==null){L.current.activeId=le;return}const Ce=setTimeout(()=>{L.current.activeId=le},50);return()=>clearTimeout(Ce)},[le]),{active:x,activeIndex:g,attributes:A,data:D,rect:R,index:C,newIndex:he,items:f,isOver:k,isSorting:$,isDragging:O,listeners:G,node:N,overIndex:v,over:me,setNodeRef:nt,setActivatorNodeRef:W,setDroppableNodeRef:S,setDraggableNodeRef:fe,transform:ke??st,transition:ce()};function ce(){if(ke||Ie&&L.current.newIndex===C)return va;if(!(je&&!Ut(T)||!u)&&($||te))return Qe.Transition.toString({...u,property:wn})}}function Na(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}M.Down,M.Right,M.Up,M.Left;const _r=({task:e,onToggleComplete:t,onToggleImportant:r,onDelete:n})=>{const{attributes:o,listeners:a,setNodeRef:i,transform:l,transition:d,isDragging:u}=wa({id:e.id}),f={transform:Qe.Transform.toString(l),transition:d},m=e.due_date&&!e.is_completed&&At(Ye(e.due_date));return s.jsxs("div",{ref:i,style:f,className:J("flex items-center gap-3 px-4 py-4 rounded-2xl border bg-card shadow-sm transition-all duration-300 group",u&&"opacity-50 shadow-lg",e.is_completed?"opacity-60 border-border bg-card shadow-sm":"border-border hover:border-primary/30 hover:shadow-md"),children:[!e.is_completed&&s.jsx("button",{...o,...a,className:"cursor-grab text-muted-foreground hover:text-foreground shrink-0",children:s.jsx(is,{className:"h-4 w-4"})}),s.jsx(qn,{checked:e.is_completed,onCheckedChange:g=>t(e.id,!!g),className:"flex-shrink-0"}),s.jsx("span",{className:J("flex-1 text-sm font-medium tracking-tight truncate",e.is_completed&&"line-through text-muted-foreground"),children:e.title}),e.due_date&&s.jsx("span",{className:J("text-xs font-mono font-semibold flex-shrink-0 px-2 py-0.5 rounded-full border bg-muted/30 border-border/30",m?"text-rose-500 border-rose-500/20 bg-rose-500/5":"text-muted-foreground"),children:Jr(Ye(e.due_date),"MMM d")}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0 hover:bg-muted rounded-full",onClick:()=>r(e.id,!e.is_important),children:s.jsx(Wr,{className:J("h-4 w-4",e.is_important?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive hover:bg-destructive/10 rounded-full",onClick:()=>n(e.id),children:s.jsx(mt,{className:"h-4 w-4"})})]})},ja=({tasks:e,isLoading:t,onToggleComplete:r,onToggleImportant:n,onDelete:o,onReorder:a,onCreateTask:i})=>{const{t:l}=ee("goals"),d=Hs(Xs(Ht,{activationConstraint:{distance:5}})),u=e.filter(g=>!g.is_completed),f=e.filter(g=>g.is_completed),m=g=>{const{active:h,over:y}=g;if(!y||h.id===y.id)return;const p=u.findIndex(j=>j.id===h.id),v=u.findIndex(j=>j.id===y.id);if(p===-1||v===-1)return;const b=Qt(u,p,v);a(b.map(j=>j.id))};return t&&e.length===0?s.jsx(Pr,{}):e.length===0?s.jsx(Xr,{imageSrc:en,overline:l("tasksList.empty.overline"),title:l("tasksList.empty.title"),description:l("tasksList.empty.description"),speechBubble:l("tasksList.empty.speechBubble"),primaryAction:i?{label:l("tasksList.empty.action"),icon:$t,onClick:i}:void 0}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(ta,{sensors:d,collisionDetection:to,onDragEnd:m,children:s.jsx(ha,{items:u.map(g=>g.id),strategy:fa,children:s.jsx("div",{className:"space-y-1.5",children:u.map(g=>s.jsx(_r,{task:g,onToggleComplete:r,onToggleImportant:n,onDelete:o},g.id))})})}),f.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2 uppercase tracking-wide",children:l("tasksList.completedHeading",{count:f.length})}),s.jsx("div",{className:"space-y-1.5",children:f.map(g=>s.jsx(_r,{task:g,onToggleComplete:r,onToggleImportant:n,onDelete:o},g.id))})]})]})},ka=({open:e,onOpenChange:t,onCreate:r})=>{const{t:n}=ee("goals"),[o,a]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState(""),[f,m]=c.useState(!1),[g,h]=c.useState(!1),y=()=>{a(""),l(""),u(""),m(!1)},p=async()=>
20{if(!o.trim()){I.error(n("taskForm.errors.titleRequired"));return}h(!0);try{await r({title:o.trim(),description:i.trim()||void 0,dueDate:d||void 0,isImportant:f}),I.success(n("taskForm.toasts.created")),y(),t(!1)}catch(v){I.error(v instanceof Error?v.message:n("taskForm.errors.createFailed"))}finally{h(!1)}};return s.jsx(zr,{open:e,onOpenChange:t,children:s.jsxs(Br,{className:"sm:max-w-md rounded-3xl sm:rounded-3xl border border-border shadow-md",children:[s.jsx(qr,{children:s.jsx($r,{className:"font-sans font-bold text-lg text-foreground",children:n("taskForm.title")})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:n("taskForm.fieldTitle")}),s.jsx(Ge,{className:"rounded-xl mt-1",placeholder:n("taskForm.titlePlaceholder"),value:o,onChange:v=>a(v.target.value)})]}),s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:n("taskForm.description")}),s.jsx(Vr,{className:"rounded-xl mt-1",rows:2,value:i,onChange:v=>l(v.target.value)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx(se,{className:"font-sans font-medium text-xs text-muted-foreground",children:n("taskForm.dueDate")}),s.jsx(Ge,{className:"rounded-xl mt-1",type:"date",value:d,onChange:v=>u(v.target.value)})]}),s.jsxs("div",{className:"flex items-end gap-2 pb-1.5",children:[s.jsx(rs,{id:"important",checked:f,onCheckedChange:m}),s.jsx(se,{htmlFor:"important",className:"cursor-pointer font-sans font-medium text-xs text-muted-foreground select-none mb-1",children:n("taskForm.important")})]})]}),s.jsx(Ze,{colorVariant:"brand",className:"w-full h-10 mt-2",onClick:p,disabled:g,children:n(g?"taskForm.saving":"taskForm.create")})]})]})})};function Ca(){var S;const{t:e}=ee(["clients","common"]),t=$n(),r=(S=t.client)==null?void 0:S.id;as({title:t.client?`${t.client.company_name} — ${e("pages.goals")}`:e("pages.goals")});const{goals:n,isLoading:o,create:a,update:i,remove:l}=ns(r),{data:d}=ss(n,r),{tasks:u,isLoading:f,create:m,update:g,reorder:h,remove:y}=os(r),{data:p=!1}=Zn(),[v,b]=c.useState(!1),[j,w]=c.useState(null),[C,D]=c.useState(!1),E=c.useMemo(()=>(t.connections??[]).filter(x=>x.is_connected).map(x=>x.platform),[t.connections]),R=c.useMemo(()=>{const x=new Map;for(const T of d??[])x.set(T.goalId,T);return x},[d]),N=async x=>{await a.mutateAsync(x)},k=async x=>{await m.mutateAsync(x)};return s.jsx(s.Fragment,{children:s.jsxs(Vn,{workspace:t,pageTitle:t.client?`${t.client.company_name} — ${e("pages.goals")}`:void 0,pageDescription:e(p?"pages.goalsDescriptionGamified":"pages.goalsDescription"),actionButton:{text:e("pages.addLabel"),icon:$t,menuItems:[{label:e("pages.newGoal"),icon:Me,onSelect:()=>b(!0)},{label:e("pages.newTask"),icon:hr,onSelect:()=>D(!0)}]},children:[s.jsxs(Gn,{defaultValue:p?"challenges":"goals",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[s.jsxs(mr,{"data-tour":"goals.tabs",children:[p&&s.jsxs(lt,{value:"challenges",className:"gap-1.5",children:[s.jsx(Ne,{className:"h-3.5 w-3.5"}),e("pages.tabs.challenges")]}),s.jsxs(lt,{value:"goals",className:"gap-1.5",children:[s.jsx(Me,{className:"h-3.5 w-3.5"}),e("pages.tabs.goals",{count:n.length})]}),s.jsxs(lt,{value:"tasks",className:"gap-1.5",children:[s.jsx(hr,{className:"h-3.5 w-3.5"}),e("pages.tabs.tasks",{count:u.length})]})]}),p&&s.jsx(mr,{className:"ml-auto bg-primary/10 dark:bg-primary/20 border border-primary/25 rounded-full p-0.5",children:s.jsxs(lt,{value:"rewards",className:"gap-1.5 text-primary dark:text-primary-foreground/90 hover:bg-primary/5 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:scale-[1.02] data-[state=active]:font-bold rounded-full px-5 py-2 text-xs sm:text-sm font-semibold transition-all shadow-none",children:[s.jsx(gt,{className:"h-3.5 w-3.5 shrink-0"}),e("pages.tabs.rewards")]})})]}),p&&s.jsx(ct,{value:"challenges",className:"mt-4",children:s.jsx(Cs,{clientId:r,connectedPlatforms:E})}),p&&s.jsx(ct,{value:"rewards",className:"mt-4",children:s.jsx(Ms,{clientId:r})}),s.jsx(ct,{value:"goals",className:"mt-4","data-tour":"goals.list",children:s.jsx(_s,{goals:n,isLoading:o,progressMap:R,onArchive:x=>{i.mutateAsync({id:x,status:"archived"}).catch(()=>I.error(e("pages.toasts.archiveFailed")))},onDelete:x=>{l.mutateAsync(x).catch(()=>I.error(e("pages.toasts.deleteFailed")))},onEdit:w,onCreateGoal:()=>b(!0)})}),s.jsx(ct,{value:"tasks",className:"mt-4",children:s.jsx(ja,{tasks:u,isLoading:f,onToggleComplete:(x,T)=>{g.mutateAsync({id:x,is_completed:T}).catch(()=>I.error(e("pages.toasts.updateFailed")))},onToggleImportant:(x,T)=>{g.mutateAsync({id:x,is_important:T}).catch(()=>I.error(e("pages.toasts.updateFailed")))},onDelete:x=>{y.mutateAsync(x).catch(()=>I.error(e("pages.toasts.deleteFailed")))},onReorder:x=>{h.mutateAsync(x).catch(()=>I.error(e("pages.toasts.reorderFailed")))},onCreateTask:()=>D(!0)})})]},p?"g-on":"g-off"),s.jsx(yr,{open:v,onOpenChange:b,connectedPlatforms:t.connectedPlatforms??[],onCreate:N}),s.jsx(yr,{open:j!==null,onOpenChange:x=>{x||w(null)},connectedPlatforms:t.connectedPlatforms??[],goal:j??void 0,onSave:async x=>{await i.mutateAsync({id:x.id,title:x.title,targetValue:x.targetValue,deadline:x.deadline,notes:x.notes}),w(null)}}),s.jsx(ka,{open:C,onOpenChange:D,onCreate:k})]})})}function yi(){return s.jsx(Ca,{})}export{yi 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.