1import{C as P,b6 as N,b4 as R,bk as H,r as d,n as t,aB as l,aJ as n,bp as V,bm as _,bf as I,aa as v,be as M,b as w,aw as k,p as f,au as u,ao as o,B as F,bl as K,z as A,_ as O,ah as S}from"./qiiO-fSN.js";import{R as C}from"./BshCiXIQ.js";import{u as z}from"./C1YMW3Pt.js";import"./BJ2ClxiI.js";const j={class:"mb-6 flex flex-wrap items-center justify-between gap-3"},q={class:"text-sm text-brand-gray"},J={class:"mb-8 rounded-xl bg-white p-6 shadow-sm"},Y={class:"min-w-[240px] flex-1"},Z=["value"],G=["disabled"],Q={key:0,class:"text-sm text-brand-red"},W={class:"overflow-x-auto rounded-xl bg-white shadow-sm"},X={class:"w-full text-sm"},tt={class:"px-4 py-3"},et={class:"text-xs text-gray-400"},st={class:"px-4 py-3 text-brand-gray"},at={class:"px-4 py-3"},nt=["disabled","onClick"],lt={class:"px-4 py-3"},it=["disabled","onClick"],dt={class:"px-4 py-3 text-xs text-brand-gray"},ot={class:"px-4 py-3 text-right whitespace-nowrap"},rt=["href"],ut=["disabled","onClick"],pt={key:0},ft=P({__name:"index",async setup(ct){let p,g;N({title:"Resources | Admin",robots:"noindex"});const $=R(),{data:y,refresh:m}=([p,g]=H(()=>z("/api/admin/resources",{default:()=>[]},"$vSY-qFZy67")),p=await p,g(),p),r=u(""),c=u("guides"),b=u(!1),x=u("");async function D(){if(r.value.trim()){b.value=!0,x.value="";try{const a=await $fetch("/api/admin/resources",{method:"POST",body:{title:r.value.trim(),kind:c.value}});$.push(`/admin/resources/${a.id}`)}catch{x.value="Could not create it.",b.value=!1}}}const i=u(null);async function E(a){i.value=a.id;try{await $fetch(`/api/admin/resources/${a.id}`,{method:"PUT",body:{status:a.status==="PUBLISHED"?"DRAFT":"PUBLISHED"}}),await m()}finally{i.value=null}}async function T(a){i.value=a.id;try{await $fetch(`/api/admin/resources/${a.id}`,{method:"PUT",body:{pinned_on_entries:a.pinned_on_entries?0:1}}),await m()}finally{i.value=null}}async function U(a){if(confirm(`Delete "${a.title}"? This cannot be undone.`)){i.value=a.id;try{await $fetch(`/api/admin/resources/${a.id}`,{method:"DELETE"}),await m()}finally{i.value=null}}}function B(a){return C.find(s=>s.slug===a)?.singular??a}return(a,s)=>{const L=O;return o(),d("div",null,[t("div",j,[s[2]||(s[2]=t("h1",{class:"text-xl font-bold text-brand-dark"},"Resources",-1)),t("span",q,l(n(y).length)+" total",1)]),t("div",J,[s[5]||(s[5]=t("h2",{class:"mb-4 font-semibold text-brand-dark"},"New resource",-1)),t("form",{class:"flex flex-wrap items-end gap-3",onSubmit:V(D,["prevent"])},[t("div",Y,[s[3]||(s[3]=t("label",{class:"field-label"},"Title",-1)),_(t("input",{"onUpdate:modelValue":s[0]||(s[0]=e=>v(r)?r.value=e:null),type:"text",class:"field-input",placeholder:"How to read contest rules"},null,512),[[I,n(r)]])]),t("div",null,[s[4]||(s[4]=t("label",{class:"field-label"},"Kind",-1)),_(t("select",{"onUpdate:modelValue":s[1]||(s[1]=e=>v(c)?c.value=e:null),class:"field-input"},[(o(!0),d(w,null,k(n(C),e=>(o(),d("option",{key:e.slug,value:e.slug},l(e.singular),9,Z))),128))],512),[[M,n(c)]])]),t("button",{type:"submit",disabled:n(b)||!n(r).trim(),class:"rounded-lg bg-brand-red px-5 py-2 text-sm font-semibold text-white transition-colors hover:bg-red-700 disabled:opacity-60"},l(n(b)?"Creatingâ¦":"Create draft"),9,G),n(x)?(o(),d("span",Q,l(n(x)),1)):f("",!0)],32)]),t("div",W,[t("table",X,[s[7]||(s[7]=t("thead",{class:"border-b border-gray-200 text-left text-xs uppercase tracking-wide text-brand-gray"},[t("tr",null,[t("th",{class:"px-4 py-3"},"Title"),t("th",{class:"px-4 py-3"},"Kind"),t("th",{class:"px-4 py-3"},"Status"),t("th",{class:"px-4 py-3"},"On contest pages"),t("th",{class:"px-4 py-3"},"Updated"),t("th",{class:"px-4 py-3"})])],-1)),t("tbody",null,[(o(!0),d(w,null,k(n(y),e=>(o(),d("tr",{key:e.id,class:"border-b border-gray-100 last:border-0"},[t("td",tt,[F(L,{to:`/admin/resources/${e.id}`,class:"font-medium text-brand-dark hover:underline"},{default:K(()=>[A(l(e.title),1)]),_:2},1032,["to"]),t("div",et,"/resources/"+l(e.kind)+"/"+l(e.slug),1)]),t("td",st,l(B(e.kind)),1),t("td",at,[t("button",{disabled:n(i)===e.id,class:S(["rounded-full px-2.5 py-1 text-xs font-semibold transition-colors disabled:opacity-50",e.status==="PUBLISHED"?"bg-green-100 text-green-800 hover:bg-green-200":"bg-gray-100 text-gray-600 hover:bg-gray-200"]),onClick:h=>E(e)},l(e.status==="PUBLISHED"?"Published":"Draft"),11,nt)]),t("td",lt,[t("button",{disabled:n(i)===e.id,class:S(["rounded-full px-2.5 py-1 text-xs font-semibold transition-colors disabled:opacity-50",e.pinned_on_entries?"bg-teal-100 text-teal-800 hover:bg-teal-200":"bg-gray-100 text-gray-500 hover:bg-gray-200"]),onClick:h=>T(e)},l(e.pinned_on_entries?"Shown":"Hidden"),11,it)]),t("td",dt,l(new Date(e.updated_at).toLocaleDateString()),1),t("td",ot,[e.status==="PUBLISHED"?(o(),d("a",{key:0,href:`/resources/${e.kind}/${e.slug}`,target:"_blank",class:"mr-3 text-xs text-brand-blue hover:underline"},"View â",8,rt)):f("",!0),t("button",{disabled:n(i)===e.id,class:"text-xs text-brand-red hover:underline disabled:opacity-50",onClick:h=>U(e)}," Delete ",8,ut)])]))),128)),n(y).length?f("",!0):(o(),d("tr",pt,[...s[6]||(s[6]=[t("td",{colspan:"6",class:"px-4 py-10 text-center text-brand-gray"},"Nothing here yet.",-1)])]))])])])])}}});
1export{ft 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.