import{A as D}from"./ActionButton-6dFA985o.js";import{C as L}from"./ConfirmationDialog-Dsr1A4w6.js";import{H as E}from"./HeroSection-D-Cp_ogz.js";import{R as H}from"./ReusableDataTable-1-hRJNZ3.js";import{S as O}from"./SearchBox-eFhvvd_1.js";import{u as R}from"./languageTemplateStore-DMVSJQ2j.js";import{z as $,T as z,g as c,c as B,W as N,a as V,o as q,d as r,e as s,u as d}from"./main-CJbVOHh0.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";/* empty css                                                                     */import"./languageTemplateApi-DtS3Soe6.js";const M={class:"language-templates-page"},P={class:"content-wrapper"},U={class:"page-content"},W={class:"toolbar"},I={class:"search-section"},j={class:"action-section"},G={class:"table-container"},J=1e3,K=500,Q={__name:"LanguageTemplates",setup(X){const p=R(),{templates:h,total:v,loading:m}=$(p),{fetchTemplates:b,deleteTemplate:_}=p,u=z(),T=[{field:"language_name",header:"Language Name",sortable:!0,style:{width:"25%"},template:"user"},{field:"language_code",header:"Code",sortable:!0,style:{width:"20%"},alignHeader:"center",align:"center",template:"custom",customHTML:e=>`<span class="px-2 py-1 bg-slate-100 rounded text-xs font-mono font-bold uppercase text-slate-600 border border-slate-200">${e.language_code}</span>`},{field:"status",header:"Status",sortable:!0,style:{width:"25%"},alignHeader:"center",align:"center",template:"badge"},{field:"published_at",header:"Published At",sortable:!0,style:{width:"20%"},template:"custom",customHTML:e=>e.published_at?`<div class="flex flex-col">
        <span class="text-sm font-semibold">${new Date(e.published_at).toLocaleDateString()}</span>
      </div>`:'<span class="text-slate-400 italic font-light">Not published</span>'}],y=[{icon:"pi pi-pencil",label:"Edit",tooltip:"Edit template",severity:"info",action:"edit"},{icon:"pi pi-list-check",label:"Required Checklist",tooltip:"Open required translation checklist",severity:"secondary",action:"required"},{icon:"pi pi-trash",tooltip:"Delete Template",severity:"danger",action:"delete"}],t=c({page:1,rows:J,sortField:"created_at",sortOrder:-1,search:""}),l=c(!1),o=c(null),w=B(()=>h.value||[]);async function i(){await b({page:t.value.page,rows:t.value.rows,search:t.value.search})}function S(e){t.value.page=e.page+1,t.value.rows=e.rows,i()}function x(e){t.value.sortField=e.sortField,t.value.sortOrder=Number(e.sortOrder||0),i()}let g=null;function C(){clearTimeout(g),g=setTimeout(()=>{t.value.page=1,i()},K)}function k({action:e,rowData:a}){e.action==="manage"||e.action==="edit"?u.push(`/pages/language-templates/${a.id}/edit`):e.action==="required"?u.push(`/pages/language-templates/${a.id}/edit#required-checklist`):e.action==="delete"&&(o.value=a,l.value=!0)}async function A(){if(!o.value)return;(await _(o.value.id)).status&&(l.value=!1,o.value=null,i())}return N(i),(e,a)=>{var f;return q(),V("div",M,[r(E,{title:"Website Language Templates",subtitle:"Manage which website languages are published and translation readiness",icon:"pi pi-language"}),s("div",P,[s("div",U,[s("div",W,[s("div",I,[r(O,{modelValue:t.value.search,"onUpdate:modelValue":a[0]||(a[0]=n=>t.value.search=n),placeholder:"Search languages...",loading:d(m),size:"medium",onSearch:C,class:"w-full"},null,8,["modelValue","loading"])]),s("div",j,[r(D,{label:"Add Template",icon:"pi pi-plus",severity:"primary",size:"small",onClick:a[1]||(a[1]=n=>d(u).push("/pages/language-templates/add"))})])]),s("div",G,[r(H,{data:w.value,columns:T,actions:y,loading:d(m),"total-records":d(v),rows:t.value.rows,"sort-field":t.value.sortField,"sort-order":t.value.sortOrder,lazy:!1,paginator:!1,"frozen-actions":!1,"show-icons-limit":1,"actions-column-style":{width:"25%"},"data-key":"id",onPage:S,onSort:x,onActionClick:k},null,8,["data","loading","total-records","rows","sort-field","sort-order"])])])]),r(L,{visible:l.value,"onUpdate:visible":a[2]||(a[2]=n=>l.value=n),title:"Delete Template",message:`Are you sure you want to delete the ${(f=o.value)==null?void 0:f.language_name} template? This action cannot be undone.`,onConfirm:A,onCancel:a[3]||(a[3]=n=>l.value=!1)},null,8,["visible","message"])])}}},re=F(Q,[["__scopeId","data-v-0dbfd6f0"]]);export{re as default};
