1import{_ as q}from"./CZUlEyMu.js";import{_ as W}from"./GgASfCWd.js";import{a as G,_ as J}from"./BULITJXC.js";import{z as K,q as u,v as Q,o as X,b as d,d as t,e as r,w as i,j as o,m as z,n as _,H as Y,A as Z,a as n,f as S,l as tt,k as g,t as l,y as et,F as N,r as P,x as st}from"./azLd_n8v.js";import{_ as at}from"./BHhNMCyR.js";import{a as R}from"./DnNx6me9.js";import"./D13RZPyJ.js";const ot={class:"space-y-12"},it={class:"grid grid-cols-1 lg:grid-cols-2 gap-8"},lt={class:"space-y-4"},nt={class:"space-y-3"},rt={class:"space-y-4"},dt={class:"grid grid-cols-2 gap-4"},ct={class:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg"},ut={class:"text-2xl font-bold text-green-700 dark:text-green-400"},gt={class:"bg-gray-50 dark:bg-gray-800 p-3 rounded-lg"},mt={class:"text-2xl font-bold text-gray-700 dark:text-gray-300"},bt={class:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg"},pt={class:"text-2xl font-bold text-blue-700 dark:text-blue-400"},yt={key:0,class:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg"},_t={class:"text-2xl font-bold text-red-700 dark:text-red-400"},xt={key:0},vt={class:"space-y-2 max-h-64 overflow-y-auto"},ft={class:"flex-1 truncate"},kt={class:"font-medium"},ht={class:"flex items-center gap-2"},At={key:0,class:"text-xs text-gray-500"},Vt={class:"space-y-6"},wt={class:"flex flex-wrap gap-2"},Ut=["onClick"],Tt={key:0,class:"flex justify-center py-8"},$t={class:"max-w-xs"},Bt={class:"font-medium truncate"},Ct={class:"text-xs text-gray-500 truncate"},zt={class:"font-medium"},St={class:"flex items-center gap-2"},Nt={class:"flex flex-wrap gap-1"},Pt={key:0,class:"text-xs text-gray-500"},Rt={class:"text-sm"},Dt={key:2,class:"text-center py-8 text-gray-500"},Et=50,Wt={__name:"discover",setup(Ft){const p=K(),m=u(!1),c=u(null),x=u(50),v=u("public"),f=u(!1);async function E(){if(!m.value){m.value=!0,c.value=null;try{const a=await $fetch("/api/admin/auto-tag-boards",{method:"POST",body:{batchSize:x.value,targetVisibility:v.value,reassignTags:f.value}});c.value=a,p.add({title:"Auto-tagging Complete",description:a.message,color:"green"})}catch(a){console.error("Auto-tagging error:",a),p.add({title:"Auto-tagging Failed",description:a.data?.message||"An error occurred",color:"red"})}finally{m.value=!1}}}const F=[{label:"Public",value:"public"},{label:"Unlisted",value:"unlisted"},{label:"All",value:null}],D=u(1),A=u([]),V=u(!0),y=u("all"),L=u([{id:"all",label:"All",icon:"i-carbon-grid"},...R.map(a=>({id:a.id,label:a.label,icon:a.icon}))]),j=Z(()=>{const a=y.value!=="all"?`&tag=${y.value}`:"";return`/api/chats/gallery?page=${D.value}&limit=${Et}${a}`});async function w(){V.value=!0;try{const a=await $fetch(j.value);A.value=a||[]}catch(a){console.error("Error loading public boards:",a),p.add({title:"Error Loading Boards",description:"Failed to load public boards",color:"red"})}finally{V.value=!1}}Q(y,async()=>{D.value=1,await w()}),X(()=>{w()});function M(a){return a?new Date(a).toLocaleDateString():"N/A"}async function H(a,s){const k=s==="public"?"unlisted":"public";try{await $fetch(`/api/admin/boards/${a}/visibility`,{method:"PATCH",body:{visibility:k}}),await w(),p.add({title:"Visibility Updated",description:`Board is now ${k}`,color:"green"})}catch(U){console.error("Error updating visibility:",U),p.add({title:"Error",description:"Failed to update visibility",color:"red"})}}return(a,s)=>{const k=q,U=W,I=G,h=et,T=tt,$=Y,B=at,O=J;return n(),d("div",ot,[s[17]||(s[17]=t("div",{class:"prose prose-sm dark:prose-invert mb-8"},[t("h1",null,"Discover Management"),t("p",{class:"text-gray-600 dark:text-gray-400"}," Manage discover visibility and categorization of boards displayed on the homepage. ")],-1)),t("div",it,[r($,null,{header:i(()=>[...s[3]||(s[3]=[t("h3",{class:"text-lg font-semibold"}," Auto-tag Boards ",-1)])]),default:i(()=>[t("div",lt,[s[8]||(s[8]=t("p",{class:"text-sm text-gray-600 dark:text-gray-400"}," Automatically tag boards without tags based on their content, sources, and titles. ",-1)),t("div",nt,[t("div",null,[s[4]||(s[4]=t("label",{class:"block text-sm font-medium mb-1"},"Batch Size",-1)),r(k,{modelValue:o(x),"onUpdate:modelValue":s[0]||(s[0]=e=>S(x)?x.value=e:null),modelModifiers:{number:!0},type:"number",min:"1",max:"200",placeholder:"50",class:"w-32"},null,8,["modelValue"]),s[5]||(s[5]=t("p",{class:"text-xs text-gray-500 mt-1"}," Number of boards to process per run ",-1))]),t("div",null,[s[6]||(s[6]=t("label",{class:"block text-sm font-medium mb-1"},"Target Visibility",-1)),r(U,{modelValue:o(v),"onUpdate:modelValue":s[1]||(s[1]=e=>S(v)?v.value=e:null),options:F,"option-attribute":"label","value-attribute":"value",class:"w-48"},null,8,["modelValue"])]),t("div",null,[r(I,{modelValue:o(f),"onUpdate:modelValue":s[2]||(s[2]=e=>S(f)?f.value=e:null),name:"reassignTags",label:"Re-assign existing tags"},null,8,["modelValue"]),s[7]||(s[7]=t("p",{class:"text-xs text-gray-500 mt-1"}," When unchecked, only processes boards without tags ",-1))])]),r(T,{loading:o(m),disabled:o(m),color:"primary",onClick:E},{leading:i(()=>[r(h,{name:"i-carbon-analytics"})]),default:i(()=>[g(" "+l(o(m)?"Processing...":"Run Auto-tagging"),1)]),_:1},8,["loading","disabled"])])]),_:1}),o(c)?(n(),z($,{key:0},{header:i(()=>[...s[9]||(s[9]=[t("h3",{class:"text-lg font-semibold"}," Last Run Results ",-1)])]),default:i(()=>[t("div",rt,[t("div",dt,[t("div",ct,[t("div",ut,l(o(c).summary.updated),1),s[10]||(s[10]=t("div",{class:"text-sm text-green-600 dark:text-green-500"}," Updated ",-1))]),t("div",gt,[t("div",mt,l(o(c).summary.skipped),1),s[11]||(s[11]=t("div",{class:"text-sm text-gray-600 dark:text-gray-400"}," Skipped ",-1))]),t("div",bt,[t("div",pt,l(o(c).summary.totalProcessed),1),s[12]||(s[12]=t("div",{class:"text-sm text-blue-600 dar
1k:text-blue-500"}," Total Processed ",-1))]),o(c).summary.errors>0?(n(),d("div",yt,[t("div",_t,l(o(c).summary.errors),1),s[13]||(s[13]=t("div",{class:"text-sm text-red-600 dark:text-red-500"}," Errors ",-1))])):_("",!0)]),o(c).results.length>0?(n(),d("div",xt,[s[14]||(s[14]=t("h4",{class:"font-medium mb-2"}," Sample Results: ",-1)),t("div",vt,[(n(!0),d(N,null,P(o(c).results.slice(0,10),e=>(n(),d("div",{key:e.id,class:"flex items-center justify-between text-sm p-2 rounded border"},[t("div",ft,[t("span",kt,l(e.title||"Untitled"),1)]),t("div",ht,[r(B,{color:e.status==="updated"?"green":e.status==="error"?"red":"gray",variant:"soft",size:"xs"},{default:i(()=>[g(l(e.status),1)]),_:2},1032,["color"]),e.tags?(n(),d("span",At,l(Array.isArray(e.tags)?e.tags.join(", "):e.tags),1)):_("",!0)])]))),128))])])):_("",!0)])]),_:1})):_("",!0)]),r($,null,{header:i(()=>[...s[15]||(s[15]=[t("h3",{class:"text-lg font-semibold"}," Discover Items ",-1)])]),default:i(()=>[t("div",Vt,[t("div",wt,[(n(!0),d(N,null,P(o(L),e=>(n(),d("button",{key:e.id,class:st(["px-3 py-1 rounded-full text-sm font-medium transition-all duration-200 border",o(y)===e.id?"bg-gray-900 dark:bg-white text-white dark:text-gray-900 border-gray-900 dark:border-white":"bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"]),onClick:b=>y.value=e.id},[r(h,{name:e.icon,class:"mr-1"},null,8,["name"]),g(" "+l(e.label),1)],10,Ut))),128))]),o(V)?(n(),d("div",Tt,[r(h,{name:"i-carbon-loading",class:"animate-spin text-2xl"})])):o(A).length>0?(n(),z(O,{key:1,rows:o(A),columns:[{key:"title",label:"Title"},{key:"username",label:"User"},{key:"visibility",label:"Visibility"},{key:"tags",label:"Tags"},{key:"updatedAt",label:"Updated"},{key:"actions",label:"Actions"}]},{"title-data":i(({row:e})=>[t("div",$t,[t("p",Bt,l(e.title||"Untitled"),1),t("p",Ct,l(e.id),1)])]),"username-data":i(({row:e})=>[t("span",zt,l(e.username||"Anonymous"),1)]),"visibility-data":i(({row:e})=>[t("div",St,[r(B,{color:e.visibility==="public"?"green":e.visibility==="unlisted"?"orange":"gray",variant:"soft",size:"xs"},{default:i(()=>[g(l(e.visibility),1)]),_:2},1032,["color"]),r(T,{variant:"ghost",size:"xs",icon:e.visibility==="public"?"i-carbon-view-off":"i-carbon-view",onClick:b=>H(e.id,e.visibility)},{default:i(()=>[g(l(e.visibility==="public"?"Hide":"Show"),1)]),_:2},1032,["icon","onClick"])])]),"tags-data":i(({row:e})=>[t("div",Nt,[(n(!0),d(N,null,P(e.tags||[],b=>(n(),z(B,{key:b,color:o(R).find(C=>C.id===b)?.color||"gray",variant:"soft",size:"xs"},{default:i(()=>[g(l(o(R).find(C=>C.id===b)?.label||b),1)]),_:2},1032,["color"]))),128)),!e.tags||e.tags.length===0?(n(),d("span",Pt," None ")):_("",!0)])]),"updatedAt-data":i(({row:e})=>[t("span",Rt,l(M(e.updatedAt)),1)]),"actions-data":i(({row:e})=>[r(T,{to:`/${e.username}/${e.id}`,variant:"ghost",size:"xs",target:"_blank"},{default:i(()=>[r(h,{name:"i-carbon-launch"}),s[16]||(s[16]=g(" View ",-1))]),_:1},8,["to"])]),_:1},8,["rows"])):(n(),d("div",Dt," No public boards found for the selected tag. "))])]),_:1})])}}};export{Wt 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.