1import{d as He,u as _e,r as i,b as re,c as N,j as t}from"./vendor-query-BqeRHL1O.js";import{u as We,l as Ue,b as E}from"./index-Dzllbn4p.js";import"./vendor-react-qkC6yhPU.js";import"./vendor-radix-DqMENufp.js";const ge={category:"",key:"",title:"",summary:"",links:[{label:"",url:"",recommended:!1}],sortOrder:0},H={value:"",label:"",levelNumber:"",sortOrder:0};function Je(){const[,R]=He(),{user:ae,isLoading:he}=We(),y=_e(),{toast:u}=Ue(),[D,_]=i.useState(null),[g,m]=i.useState({...ge}),[oe,W]=i.useState(!1),[C,le]=i.useState("all"),[f,U]=i.useState([]),[$,z]=i.useState(null),[fe,P]=i.useState(null),[ne,A]=i.useState(null),[G,Y]=i.useState(null),[j,B]=i.useState(null),[ie,J]=i.useState(!1),[ce,ve]=i.useState(!1),[ke,X]=i.useState(null),[F,v]=i.useState({...H}),[Ee,Z]=i.useState(!1),T=i.useRef(null),M=i.useRef(null),{data:de=[],isLoading:ue}=re({queryKey:["/api/resources"],queryFn:async()=>{const e=await fetch("/api/resources");if(!e.ok)throw new Error("Failed to fetch resources");return e.json()}}),{data:w}=re({queryKey:["/api/admin/resources/progress-stats"],queryFn:async()=>{const e=await fetch("/api/admin/resources/progress-stats",{credentials:"include"});if(!e.ok)throw new Error("Failed to fetch progress stats");return e.json()},enabled:!!ae?.isAdmin}),{data:h=[]}=re({queryKey:["/api/resource-categories"],queryFn:async()=>{const e=await fetch("/api/resource-categories");if(!e.ok)throw new Error("Failed to fetch categories");return e.json()}}),me=N({mutationFn:e=>E("POST","/api/admin/resource-categories",{...e,levelNumber:e.levelNumber===""?null:Number(e.levelNumber)}),onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resource-categories"]}),Z(!1),v({...H}),u({title:"Category created"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})}),pe=N({mutationFn:({id:e,data:s})=>{const{value:a,...r}=s;return E("PATCH",`/api/admin/resource-categories/${e}`,{...r,levelNumber:r.levelNumber===""?null:r.levelNumber===void 0?void 0:Number(r.levelNumber)})},onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resource-categories"]}),X(null),u({title:"Category updated"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})}),xe=N({mutationFn:e=>E("DELETE",`/api/admin/resource-categories/${e}`),onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resource-categories"]}),u({title:"Category deleted"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})});i.useEffect(()=>{U(de)},[de]),i.useEffect(()=>{h.length>0&&!g.category&&m(e=>({...e,category:h[0].value}))},[h]);function K(){return{...ge,category:h[0]?.value??""}}const je=N({mutationFn:e=>E("POST","/api/admin/resources",e),onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resources"]}),W(!1),m(K()),u({title:"Resource created"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})}),Ne=N({mutationFn:({id:e,data:s})=>E("PATCH",`/api/admin/resources/${e}`,s),onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resources"]}),_(null),u({title:"Resource updated"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})}),Q=N({mutationFn:async({id:e,force:s,clearProgress:a})=>{const r=new URLSearchParams;s&&r.set("force","true"),a&&r.set("clearProgress","true");const o=r.toString(),l=`/api/admin/resources/${e}${o?`?${o}`:""}`,c=await fetch(l,{method:"DELETE",credentials:"include"});if(c.status===409)return{warning:!0,count:(await c.json()).count};if(!c.ok){const k=await c.text();throw new Error(k||c.statusText)}return{warning:!1,count:0}},onSuccess:e=>{if(e.warning){B(e.count);return}Y(null),B(null),J(!1),y.invalidateQueries({queryKey:["/api/resources"]}),u({title:"Resource deleted"})},onError:e=>u({title:"Error",description:e.message,variant:"destructive"})}),Ce=N({mutationFn:e=>E("PATCH","/api/admin/resources/reorder",{updates:e}),onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resources"]})},onError:e=>{u({title:"Failed to save order",description:e.message,variant:"destructive"}),y.invalidateQueries({queryKey:["/api/resources"]})}}),Fe=N({mutationFn:async({movedId:e,newCategory:s,movedSortOrder:a,sourceUpdates:r,destUpdates:o})=>{await E("PATCH",`/api/admin/resources/${e}`,{category:s,sortOrder:a}),r.length>0&&await E("PATCH","/api/admin/resources/reorder",{updates:r}),o.length>0&&await E("PATCH","/api/admin/resources/reorder",{updates:o})},onSuccess:()=>{y.invalidateQueries({queryKey:["/api/resources"]})},onError:e=>{u({title:"Failed to move resource",description:e.message,variant:"destructive"}),y.invalidateQueries({queryKey:["/api/resources"]})}});if(he)return t.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"#EEEEEE"},children:t.jsx("p",{className:"text-sm uppercase tracking-widest",style:{color:"#31363F77"},children:"Loadingâ¦"})});if(!ae?.isAdmin)return t.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"#EEEEEE"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-bold uppercase tracking-widest mb-4",style:{color:"#31363F"},children:"Access denied"}),t.jsx("button",{onClick:()=>R("/"),className:"text-xs underline",style:{color:"#31363F77"},children:"Go home"})]})});function we(e){return f.filter(s=>s.category===e).sort((s,a)=>s.sortOrder-a.sortOrder)}function Se(e){T.current=e,z(e)}function Oe(e,s,a){e.preventDefault(),M.current=s,P(s),A(a)}function De(e,s){e.preventDefault(),A(s),P(null),M.current=null}function $e(){z(null),P(null),A(null),T.current=null,M.current=null}function be(e,s,a){e.preventDefault(),e.stopPropagation();const r=T.current;
1if(z(null),P(null),A(null),T.current=null,M.current=null,!r||r===s)return;const o=f.find(c=>c.id===r);if(!o)return;const l=o.category;if(l===a){if(!s)return;const c=f.filter(p=>p.category===l).sort((p,O)=>p.sortOrder-O.sortOrder),k=c.findIndex(p=>p.id===r),I=c.findIndex(p=>p.id===s);if(k===-1||I===-1)return;const L=[...c],[S]=L.splice(k,1);L.splice(I,0,S);const ee=L.map((p,O)=>({id:p.id,sortOrder:O}));U(p=>{const O=p.filter(d=>d.category!==l),n=L.map((d,te)=>({...d,sortOrder:te}));return[...O,...n]}),Ce.mutate(ee)}else{const c=f.filter(n=>n.category===l&&n.id!==r).sort((n,d)=>n.sortOrder-d.sortOrder),k=f.filter(n=>n.category===a).sort((n,d)=>n.sortOrder-d.sortOrder);let I=k.length;if(s){const n=k.findIndex(d=>d.id===s);n!==-1&&(I=n)}const L={...o,category:a},S=[...k];S.splice(I,0,L),U(n=>{const d=n.filter(q=>q.category!==l&&q.category!==a),te=c.map((q,se)=>({...q,sortOrder:se})),Qe=S.map((q,se)=>({...q,sortOrder:se}));return[...d,...te,...Qe]});const ee=S.findIndex(n=>n.id===r),p=c.map((n,d)=>({id:n.id,sortOrder:d})),O=S.filter(n=>n.id!==r).map(n=>({id:n.id,sortOrder:S.findIndex(d=>d.id===n.id)}));Fe.mutate({movedId:r,newCategory:a,movedSortOrder:ee,sourceUpdates:p,destUpdates:O})}}function Le(e,s){e.preventDefault(),be(e,null,s)}function qe(e){_(e.id),m({category:e.category,key:e.key,title:e.title,summary:e.summary,links:e.links.length>0?e.links:[{label:"",url:"",recommended:!1}],sortOrder:e.sortOrder})}function Ie(){_(null),m(K())}function V(e,s,a){m(r=>{const o=[...r.links];return o[e]={...o[e],[s]:a},{...r,links:o}})}function Re(){m(e=>({...e,links:[...e.links,{label:"",url:"",recommended:!1}]}))}function Pe(e){m(s=>({...s,links:s.links.filter((a,r)=>r!==e)}))}function Ae(e){e.preventDefault();const s=g.links.filter(r=>r.label.trim()&&r.url.trim()),a={...g,links:s};if(D)Ne.mutate({id:D,data:a});else{const r=f.filter(l=>l.category===g.category),o=r.length>0?Math.max(...r.map(l=>l.sortOrder))+1:0;je.mutate({...a,sortOrder:o})}}const x="w-full border px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-black",b={borderColor:"#31363F33",backgroundColor:"#EEEEEE",color:"#31363F"};function ye({onCancel:e}){return t.jsxs("form",{onSubmit:Ae,className:"space-y-4 p-5 border",style:{borderColor:"#31363F22",backgroundColor:"#EEEEEE"},children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Category"}),t.jsx("select",{value:g.category,onChange:s=>m(a=>({...a,category:s.target.value})),className:x,style:b,"data-testid":"select-resource-category",children:h.map(s=>t.jsxs("option",{value:s.value,children:[s.label,s.levelNumber!=null?` (Level ${s.levelNumber})`:""]},s.value))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Key (subtask ID)"}),t.jsx("input",{value:g.key,onChange:s=>m(a=>({...a,key:s.target.value})),placeholder:"e.g. email, seo, freelance",className:x,style:b,required:!0,"data-testid":"input-resource-key"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Title"}),t.jsx("input",{value:g.title,onChange:s=>m(a=>({...a,title:s.target.value})),placeholder:"Topic title",className:x,style:b,required:!0,"data-testid":"input-resource-title"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Summary"}),t.jsx("textarea",{value:g.summary,onChange:s=>m(a=>({...a,summary:s.target.value})),placeholder:"Short description shown in the accordion",rows:3,className:x,style:b,required:!0,"data-testid":"input-resource-summary"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"#31363F77"},children:"Links"}),t.jsx("button",{type:"button",onClick:Re,className:"text-xs font-bold uppercase tracking-widest px-3 py-1 hover:opacity-70",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-add-link",children:"+ Add link"})]}),t.jsx("div",{className:"space-y-3",children:g.links.map((s,a)=>t.jsxs("div",{className:"p-3 border space-y-2",style:{borderColor:"#31363F11"},children:[t.jsx("input",{value:s.label,onChange:r=>V(a,"label",r.target.value),placeholder:"Link label",className:x,style:b,"data-testid":`input-link-label-${a}`}),t.jsx("input",{value:s.url,onChange:r=>V(a,"url",r.target.value),placeholder:"https://...",className:x,style:b,"data-testid":`input-link-url-${a}`}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("label",{className:"flex items-center gap-2 text-xs",style:{color:"#31363F77"},children:[t.jsx("input",{type:"checkbox",checked:!!s.recommended,onChange:r=>V(a,"recommended",r.target.checked),"data-testid":`checkbox-link-recommended-${a}`}),"Recommended (shown with star)"]}),g.links.length>1&&t.jsx("button",{type:"button",onClick:()=>Pe(a),className:"text-xs hover:opacity-70",style:{color:"#31363F"},"data-testid":`button-remove-link-${a}`,children:"Remove"})]})]},a))})]}),t.jsxs("div",{className:"flex gap-3 pt-2",children:[t.jsx("button",{type:"submit",className:"px-5 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 transition-opacity",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-save-resource",children:D?"Save changes":"Create resource"}),t.jsx("button",{type:"button",onClick:e,className:"px-5 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 transition-opacity border",style:{borderColor:"#31363F33",color:"#31363F77"},"data-testid":"button-cancel-resource",children:"Cancel"})]})]})}function Te({r:e}){const s=$===e.id,a=fe===e.id&&$!==e.id,r=w?.byResource[e.key]??0;return D===e.id?t.jsxs("div",{children:[t.jsxs("p",{className:"text-xs font-black uppercase tracking-widest mb-3",style:{color:"#31363F77"},children:["Editing: ",e.title]}),t.jsx(ye,{onCancel:Ie})]}):t.jsx("div",{draggable:!0,onDragStart:()=>Se(e.id),onDragOver:o=>Oe(o,e.id,e.category),onDragEnd:$e,onDrop:o=>be(o,e.id,e.category),className:"p-4 border transition-all",style:{borderColor:a?"#31363F":"#31363F22",backgroundColor:"#EEEEEE",opacity:s?.5:1,cursor:"grab",borderTopWidth:a?2:1},"data-testid":`card-resource-${e.id}`,children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[t.jsx("div",{className:"flex-shrink-0 flex flex-col gap-0.5 mt-1 cursor-grab",style:{color:"#31363F44"},title:"Drag to reorder","data-testid":`drag-handle-${e.id}`,children:t.jsx("span",{style:{fontSize:18,lineHeight:1},children:"â ¿"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[t.jsx("span",{className:"text-xs px-2 py-0.5 font-bold uppercase tracking-widest",style:{backgroundColor:"#31363F11",color:"#31363F77"},children:h.find(o=>o.value===e.category)?.label??e.category}),t.jsx("span",{className:"text-xs font-mono",style:{color:"#31363F55"},children:e.key}),w&&t.jsx("span",{className:"text-xs px-2 py-0.5 font-bold uppercase tracking-widest",style:{backgroundColor:r>
10?"#31363F18":"#31363F09",color:r>0?"#31363Fbb":"#31363F55"},"data-testid":`stat-completions-${e.id}`,children:r===0?`0 of ${w.totalUsers} completed`:`${r} of ${w.totalUsers} completed`})]}),t.jsx("h3",{className:"text-sm font-black uppercase tracking-tight",style:{color:"#31363F"},children:e.title}),t.jsx("p",{className:"text-xs mt-1 mb-2",style:{color:"#31363F77"},children:e.summary}),t.jsx("div",{className:"space-y-1",children:e.links.map((o,l)=>t.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"#31363F55"},children:[t.jsx("span",{children:"â"}),t.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"hover:underline",style:{color:"#31363F"},children:o.label}),o.recommended&&t.jsx("span",{className:"font-bold",style:{color:"#31363F99"},children:"â
"})]},l))})]})]}),t.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[t.jsx("button",{onClick:()=>qe(e),className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border hover:opacity-70",style:{borderColor:"#31363F33",color:"#31363F"},"data-testid":`button-edit-resource-${e.id}`,children:"Edit"}),t.jsx("button",{onClick:()=>Y({id:e.id,title:e.title}),disabled:Q.isPending,className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border hover:opacity-70 disabled:opacity-40",style:{borderColor:"rgba(49,54,63,0.15)",color:"#31363F"},"data-testid":`button-delete-resource-${e.id}`,children:"Delete"})]})]})})}const Me=Array.from(new Set([...h.map(e=>e.value),...f.map(e=>e.category)])),Ke=C==="all"?Me:[C];return t.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"#EEEEEE"},children:[t.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-10",children:[t.jsxs("div",{className:"flex items-center justify-between mb-8",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-black uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Admin"}),t.jsx("h1",{className:"text-2xl font-black uppercase tracking-tight",style:{fontFamily:"'Paytone One', sans-serif",color:"#31363F",letterSpacing:"-0.04em"},children:"Resource Links"})]}),t.jsxs("div",{className:"flex gap-4",children:[t.jsx("button",{onClick:()=>R("/admin/users"),className:"text-xs font-bold uppercase tracking-widest hover:opacity-70 transition-opacity",style:{color:"#31363F77"},"data-testid":"link-admin-users",children:"Users"}),t.jsx("button",{onClick:()=>R("/admin/rate-limits"),className:"text-xs font-bold uppercase tracking-widest hover:opacity-70 transition-opacity",style:{color:"#31363F77"},"data-testid":"link-admin-rate-limits",children:"Rate Limits"}),t.jsx("button",{onClick:()=>R("/dashboard"),className:"text-xs font-bold uppercase tracking-widest hover:opacity-70 transition-opacity",style:{color:"#31363F77"},"data-testid":"link-back-dashboard",children:"â Dashboard"})]})]}),t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>le("all"),className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border transition-colors",style:{borderColor:"#31363F",backgroundColor:C==="all"?"#31363F":"transparent",color:C==="all"?"#EEEEEE":"#31363F"},"data-testid":"filter-all",children:"All"}),h.map(e=>t.jsx("button",{onClick:()=>le(e.value),className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border transition-colors",style:{borderColor:"#31363F",backgroundColor:C===e.value?"#31363F":"transparent",color:C===e.value?"#EEEEEE":"#31363F"},"data-testid":`filter-${e.value}`,children:e.label},e.value))]}),!oe&&!D&&t.jsx("button",{onClick:()=>{W(!0),m(K())},className:"px-5 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 transition-opacity",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-new-resource",children:"+ New resource"})]}),oe&&!D&&t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"text-xs font-black uppercase tracking-widest mb-3",style:{color:"#31363F77"},children:"New resource"}),t.jsx(ye,{onCancel:()=>{W(!1),m(K())}})]}),ue?t.jsx("p",{className:"text-sm",style:{color:"#31363F77"},children:"Loading resourcesâ¦"}):t.jsx("div",{className:"space-y-8",children:Ke.map(e=>{const s=h.find(l=>l.value===e),a=s?.label??e,r=we(e),o=w?r.reduce((l,c)=>l+(w.byResource[c.key]??0),0):null;return t.jsxs("div",{children:[C==="all"&&t.jsxs("div",{className:"flex items-baseline gap-3 mb-3",children:[t.jsx("p",{className:"text-xs font-black uppercase tracking-widest",style:{color:"#31363F77"},"data-testid":`category-header-${e}`,children:a}),o!==null&&w&&t.jsxs("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"#31363F55"},"data-testid":`stat-category-${e}`,children:[o," completion",o!==1?"s":""," across ",r.length," topic",r.length!==1?"s":"",s?.levelNumber!=null?` · Level ${s.levelNumber}`:""]})]}),t.jsxs("div",{className:"space-y-2 transition-all",onDragOver:l=>De(l,e),onDrop:l=>Le(l,e),style:{minHeight:48,outline:$&&ne===e&&f.find(l=>l.id===$)?.category!==e?"2px dashed #31363F66":"2px solid transparent",borderRadius:2,padding:$&&ne===e&&f.find(l=>l.id===$)?.category!==e?"4px":"0"},"data-testid":`category-list-${e}`,children:[r.length===0&&t.jsx("p",{className:"text-sm py-8 text-center",style:{color:"#31363F55"},children:"No resources in this category yet."}),r.map(l=>t.jsx(Te,{r:l},l.id))]})]},e)})}),!ue&&t.jsx("p",{className:"text-xs mt-6",style:{color:"#31363F44"},"data-testid":"text-drag-hint",children:"Drag cards to reorder within a category, or drop them into a different category to move them. Changes save automatically."}),t.jsxs("div",{className:"mt-12 border-t pt-8",style:{borderColor:"#31363F22"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-sm font-black uppercase tracking-widest",style:{color:"#31363F"},"data-testid":"heading-manage-categories",children:"Manage Categories"}),t.jsx("button",{onClick:()=>ve(e=>!e),className:"text-xs font-bold uppercase tracking-widest hover:opacity-70",style:{color:"#31363F77"},"data-testid":"button-toggle-categories",children:ce?"Hide":"Show"})]}),ce&&t.jsxs("div",{className:"space-y-3",children:[h.map(e=>t.jsx("div",{className:"border p-4",style:{borderColor:"#31363F22",backgroundColor:"#EEEEEE"},"data-testid":`cat-row-${e.id}`,children:ke===e.id?t.jsxs("form",{onSubmit:s=>{s.preventDefault(),pe.mutate({id:e.id,data:F})},className:"grid grid-cols-4 gap-3 items-end",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Key (fixed)"}),t.jsx("div",{className:"w-full border px-3 py-2 text-sm font-mono",style:{borderColor:"#31363F22",backgroundColor:"#EEEEEE",color:"#31363F77"},"data-testid":"text-cat-value-readonly",children:e.value})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Label"}),t.jsx("input",{value:F.label,onChange:s=>v(a=>({...a,label:s.target.value})),placeholder:"e.g. Business Model",className:x,style:b,required:!0,"data-testid":"input-cat-label"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Level # (optional)"}),t.jsx("input",{type:"number",value:F.levelNumber,onChange:s=>v(a=>({...a,levelNumber:s.target.value})),placeholder:"e.g. 2",min:1,max:99,className:x,style:b,"data-testid":"input-cat-level"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"submit",disabled:pe.isPending,className:"px-3 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 disabled:opacity-40",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-save-cat",children:"Save"}),t.jsx("button",{type:"button",onClick:()=>X(null),className:"px-3 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 border",style:{borderColor:"#31363F33",color:"#31363F77"},"data-testid":"button-cancel-cat",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-sm font-bold",style:{color:"#31363F"},children:e.label}),t.jsx("span",{className:"text-xs ml-2 font-mono",style:{color:"#31363F55"},children:e.value}),e.levelNumber!=null?t.jsxs("span",{className:"text-xs ml-2 px-2 py-0.5 font-bold uppercase tracking-widest",style:{backgroundColor:"#31363F11",color:"#31363F77"},children:["Level ",e.levelNumber]}):t.jsx("span",{className:"text-xs ml-2",style:{color:"#31363F44"},children:"No level tracking"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{X(e.id),v({value:e.value,label:e.label,levelNumber:e.levelNumber??"",sortOrder:e.sortOrder})},className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border hover:opacity-70",style:{borderColor:"#31363F33",color:"#31363F"},"data-testid":`button-edit-cat-${e.id}`,children:"Edit"}),t.jsx("button",{onClick:()=>xe.mutate(e.id),disabled:xe.isPending,className:"text-xs font-bold uppercase tracking-widest px-3 py-1.5 border hover:opacity-70 disabled:opacity-40",style:{borderColor:"rgba(49,54,63,0.15)",color:"#31363F"},"data-testid":`button-delete-cat-${e.id}`,children:"Delete"})]})]})},e.id)),Ee?t.jsxs("form",{onSubmit:e=>{e.preventDefault(),me.mutate(F)},className:"border p-4 grid grid-cols-4 gap-3 items-end",style:{borderColor:"#31363F22",backgroundColor:"#EEEEEE"},"data-testid":"form-add-category",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Key"}),t.jsx("input",{value:F.value,onChange:e=>v(s=>({...s,value:e.target.value})),placeholder:"e.g. growth",className:x,style:b,required:!0,"data-testid":"input-new-cat-value"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Label"}),t.jsx("input",{value:F.label,onChange:e=>v(s=>({...s,label:e.target.value})),placeholder:"e.g. Growth",className:x,style:b,required:!0,"data-testid":"input-new-cat-label"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-bold uppercase tracking-widest mb-1",style:{color:"#31363F77"},children:"Level # (optional)"}),t.jsx("input",{type:"number",value:F.levelNumber,onChange:e=>v(s=>({...s,levelNumber:e.target.value})),placeholder:"e.g. 9",min:1,max:99,className:x,style:b,"data-testid":"input-new-cat-level"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"submit",disabled:me.isPending,className:"px-3 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 disabled:opacity-40",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-create-cat",children:"Add"}),t.jsx("button",{type:"button",onClick:()=>{Z(!1),v({...H})},className:"px-3 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 border",style:{borderColor:"#31363F33",color:"#31363F77"},"data-testid":"button-cancel-add-cat",children:"Cancel"})]})]}):t.jsx("button",{onClick:()=>{Z(!0),v({...H})},className:"text-xs font-bold uppercase tracking-widest px-4 py-2 hover:opacity-80",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-new-category",children:"+ New category"})]})]})]}),G&&t.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{backgroundColor:"rgba(28,42,57,0.45)"},"data-testid":"modal-delete-warning",children:t.jsxs("div",{className:"max-w-md w-full mx-4 p-6 border",style:{backgroundColor:"#EEEEEE",borderColor:"#31363F22"},children:[j!==null?t.jsx("p",{className:"text-xs font-black uppercase tracking-widest mb-3",style:{color:"#31363F"},children:"Warning"}):t.jsx("p",{className:"text-xs font-black uppercase tracking-widest mb-3",style:{color:"#31363F77"}
1,children:"Confirm deletion"}),t.jsxs("p",{className:"text-sm font-bold mb-2",style:{color:"#31363F"},children:["Delete â",G.title,"â?"]}),j!==null&&t.jsxs("p",{className:"text-sm mb-4",style:{color:"#31363F77"},"data-testid":"text-delete-warning-count",children:[j===1?"1 member has this topic marked as complete":`${j} members have this topic marked as complete`," ","â deleting it will not remove their progress, but the topic will disappear from the dashboard."]}),j!==null&&t.jsxs("label",{className:"flex items-center gap-2 text-sm mb-5 cursor-pointer",style:{color:"#31363F"},"data-testid":"label-clear-progress",children:[t.jsx("input",{type:"checkbox",checked:ie,onChange:e=>J(e.target.checked),"data-testid":"checkbox-clear-progress"}),"Also remove this topic from members' completed lists"]}),j===null&&t.jsx("p",{className:"text-sm mb-5",style:{color:"#31363F77"},children:"This action cannot be undone."}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:()=>{const{id:e}=G;j!==null?Q.mutate({id:e,force:!0,clearProgress:ie}):Q.mutate({id:e})},disabled:Q.isPending,className:"px-5 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 transition-opacity disabled:opacity-40",style:{backgroundColor:"#31363F",color:"#EEEEEE"},"data-testid":"button-confirm-delete",children:j!==null?"Delete anyway":"Delete"}),t.jsx("button",{onClick:()=>{Y(null),B(null),J(!1)},className:"px-5 py-2 text-xs font-bold uppercase tracking-widest hover:opacity-80 transition-opacity border",style:{borderColor:"#31363F33",color:"#31363F77"},"data-testid":"button-cancel-delete",children:"Cancel"})]})]})})]})}export{Je 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.