1import{r as b,a as _,j as e,H as T,b as k}from"./app-D4IBpXEE.js";import{A}from"./AdminLayout-B7cFynqJ.js";import{B as h}from"./Button-CB4LXud6.js";import{T as D,C as v}from"./Tabs-CO9UBWDc.js";import"./Modal-BG2UZmBH.js";import{u as N}from"./useTranslation-mV-gvqqz.js";import"./Sidebar-CzTRGA0N.js";import"./createLucideIcon-CNbh77gd.js";import"./useBranding-B7C0EavV.js";import"./plus-BtmR7ya-.js";import"./x-Bdl9lUlz.js";import"./chevron-down-BD_xrt_b.js";import"./Topbar-YNLa3oLe.js";import"./ApplicationLogo-Bp8Si-NU.js";import"./useLocale-DI-M_4se.js";import"./search-DEcyoQmh.js";import"./loader-circle-D9S0CuXo.js";import"./user-DjuKNgwl.js";import"./file-text-Bmh95Nys.js";import"./users-CkbR-kb7.js";import"./globe-DvUr_wFZ.js";import"./shield-check-D7ft-euV.js";import"./user-cog-Uq6F85Cy.js";import"./clock-CjNziwQQ.js";import"./key-round-BvhkL2Uv.js";const y=0,z=1;function le({locales:t=[],translations:c=[],translationsLocale:s="en",translationsGroup:d="",translationsSearch:u="",translationsMissingOnly:m=!1,groups:i=[],flash:n={}}){const{t:a}=N(),[x,f]=b.useState(y),[g,r]=b.useState(!1),{data:l,setData:p,post:w,processing:C}=_({code:"",name:"",native_name:"",flag:"",enabled:!0,is_rtl:!1,sort_order:0}),S=[{label:a("locales.languages"),key:"languages"},{label:a("locales.translations_tab"),key:"translations"}];return e.jsxs(A,{title:a("locales.languages"),children:[e.jsx(T,{title:`${a("locales.languages")} · ${a("head.admin")}`}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx("h2",{className:"text-xl font-semibold text-neutral-900 dark:text-neutral-100",children:a("locales.languages_and_translations")})}),((n==null?void 0:n.success)||(n==null?void 0:n.error)||(n==null?void 0:n.info))&&e.jsx("div",{className:`rounded-soft-lg px-4 py-2 text-sm ${n.error?"bg-coral-50 dark:bg-coral-900/30 text-coral-800 dark:text-coral-200":n.info?"bg-brand-50 dark:bg-brand-900/30 text-brand-800 dark:text-brand-200":"bg-green-50 dark:bg-green-900/30 text-green-800 dark:text-green-200"}`,children:n.success||n.error||n.info}),e.jsxs(D,{tabs:S,defaultIndex:x,onChange:f,children:[x===y&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{variant:"primary",size:"sm",onClick:()=>r(!0),children:a("locales.add_language")})}),g&&e.jsx(v,{children:e.jsx(v.Body,{children:e.jsx("form",{onSubmit:o=>{o.preventDefault(),l.native_name=l.native_name||l.name,w(route("admin.locales.store"),{onSuccess:()=>{r(!1),p({code:"",name:"",native_name:"",flag:"",enabled:!0,is_rtl:!1,sort_order:0})}})},children:e.jsxs("div",{className:"flex flex-wrap gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-neutral-500 dark:text-neutral-400 mb-0.5",children:a("locales.code")}),e.jsx("input",{placeholder:a("locales.code"),value:l.code,onChange:o=>p("code",o.target.value.toLowerCase()),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-24 focus:outline-none focus:ring-2 focus:ring-brand-500/20",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-neutral-500 dark:text-neutral-400 mb-0.5",children:a("common.name")}),e.jsx("input",{placeholder:a("common.name"),value:l.name,onChange:o=>p("name",o.target.value),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-32 focus:outline-none focus:ring-2 focus:ring-brand-500/20",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-neutral-500 dark:text-neutral-400 mb-0.5",children:a("locales.native_name")}),e.jsx("input",{placeholder:a("locales.native_name"),value:l.native_name,onChange:o=>p("native_name",o.target.value),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-32 focus:outline-none focus:ring-2 focus:ring-brand-500/20"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-neutral-500 dark:text-neutral-400 mb-0.5",children:a("locales.flag")}),e.jsx("input",{placeholder:a("common.optional"),value:l.flag,onChange:o=>p("flag",o.target.value),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-20 focu
1s:outline-none focus:ring-2 focus:ring-brand-500/20"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-neutral-900 dark:text-neutral-100",children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:o=>p("enabled",o.target.checked),className:"rounded border-neutral-300 dark:border-neutral-600 text-brand-500"}),a("common.enabled")]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-neutral-900 dark:text-neutral-100",children:[e.jsx("input",{type:"checkbox",checked:l.is_rtl,onChange:o=>p("is_rtl",o.target.checked),className:"rounded border-neutral-300 dark:border-neutral-600 text-brand-500"}),a("locales.rtl")]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-neutral-500 dark:text-neutral-400 mb-0.5",children:a("locales.sort")}),e.jsx("input",{type:"number",min:0,value:l.sort_order,onChange:o=>p("sort_order",parseInt(o.target.value,10)||0),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-16 focus:outline-none focus:ring-2 focus:ring-brand-500/20"})]}),e.jsx(h,{type:"submit",size:"sm",disabled:C,children:a("common.add")}),e.jsx(h,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),children:a("common.cancel")})]})})})}),e.jsxs(v,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-neutral-200 dark:border-neutral-700 text-left text-neutral-500 dark:text-neutral-400",children:[e.jsx("th",{className:"pb-2 pr-4 font-medium",children:a("locales.languages")}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:a("locales.code")}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:a("admin.col_status")}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:a("locales.rtl")}),e.jsx("th",{className:"pb-2"})]})}),e.jsx("tbody",{children:t.map(o=>e.jsx(B,{locale:o,locales:t},o.code))})]})}),t.length===0&&!g&&e.jsx("div",{className:"py-8 text-center text-neutral-500 dark:text-neutral-400",children:a("locales.no_languages")})]})]}),x===z&&e.jsx(I,{translations:c,translationsLocale:s,translationsGroup:d,translationsSearch:u,translationsMissingOnly:m,groups:i,locales:t})]})]})]})}function B({locale:t,locales:c}){const{t:s}=N(),[d,u]=b.useState(!1),{data:m,setData:i,put:n,processing:a}=_({name:t.name,native_name:t.native_name??t.name,flag:t.flag??"",enabled:t.enabled??!0,is_rtl:t.is_rtl??!1,sort_order:t.sort_order??0}),x=()=>{k.post(route("admin.locales.set-default",t.code),{},{preserveScroll:!0})},f=()=>{confirm(s("locales.remove_language"))&&k.delete(route("admin.locales.destroy",t.code),{preserveScroll:!0})},g=!t.is_default&&c.filter(r=>r.enabled).length>1;return e.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800",children:[e.jsxs("td",{className:"py-3 pr-4",children:[e.jsx("span",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:t.name}),t.native_name&&t.native_name!==t.name&&e.jsxs("span",{className:"text-neutral-500 dark:text-neutral-400 ms-1.5",children:["(",t.native_name,")"]}),t.flag&&e.jsx("span",{className:"ms-1.5","aria-hidden":!0,children:t.flag})]}),e.jsx("td",{className:"py-3 pr-4 font-mono text-neutral-700 dark:text-neutral-300",children:t.code}),e.jsx("td",{className:"py-3 pr-4",children:t.is_default?e.jsx("span",{className:"rounded bg-brand-100 dark:bg-brand-900/40 text-brand-700 dark:text-brand-300 px-1.5 py-0.5 text-xs font-medium",children:s("locales.default_badge")}):t.enabled?s("common.active"):s("common.inactive")}),e.jsx("td",{className:"py-3 pr-4",children:t.is_rtl?s("common.yes"):s("common.no")}),e.jsxs("td",{className:"py-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",className:"text-brand-600 dark:text-brand-400 hover:underline text-sm font-medium",onClick:()=>u(!d),children:s(d?"common.cancel":"locales.edit")}),!t.is_default&&e.jsx("button",{type:"button",className:"text-brand-600 dark:text-brand-400 hover:underline text-sm font-medium",onClick:x,children:s("locales.set_default")}),g&&e.jsx("button",{type:"button",className:"text-coral-600 dar
1k:text-coral-400 hover:underline text-sm font-medium",onClick:f,children:s("common.delete")}),d&&e.jsxs("form",{className:"inline-flex flex-wrap gap-2 items-center",onSubmit:r=>{r.preventDefault(),n(route("admin.locales.update",t.code),{onSuccess:()=>u(!1)})},children:[e.jsx("input",{value:m.name,onChange:r=>i("name",r.target.value),placeholder:s("common.name"),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-2 py-1 text-sm w-28 focus:outline-none focus:ring-2 focus:ring-brand-500/20"}),e.jsx("input",{value:m.native_name,onChange:r=>i("native_name",r.target.value),placeholder:s("locales.native_name"),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-2 py-1 text-sm w-28 focus:outline-none focus:ring-2 focus:ring-brand-500/20"}),e.jsxs("label",{className:"text-neutral-900 dark:text-neutral-100 text-sm",children:[e.jsx("input",{type:"checkbox",checked:m.enabled,onChange:r=>i("enabled",r.target.checked),className:"rounded border-neutral-300 dark:border-neutral-600 text-brand-500"})," ",s("common.enabled")]}),e.jsxs("label",{className:"text-neutral-900 dark:text-neutral-100 text-sm",children:[e.jsx("input",{type:"checkbox",checked:m.is_rtl,onChange:r=>i("is_rtl",r.target.checked),className:"rounded border-neutral-300 dark:border-neutral-600 text-brand-500"})," ",s("locales.rtl")]}),e.jsx(h,{type:"submit",size:"sm",disabled:a,children:s("common.save")})]})]})]})}function I({translations:t,translationsLocale:c,translationsGroup:s,translationsSearch:d,translationsMissingOnly:u,groups:m,locales:i}){const{t:n}=N(),[a,x]=b.useState({locale:c,group:s,search:d,missingOnly:u});b.useEffect(()=>{x({locale:c,group:s,search:d,missingOnly:u})},[c,s,d,u]);const f=b.useCallback(()=>{const r={};a.locale&&(r.translations_locale=a.locale),a.group&&(r.translations_group=a.group),a.search&&(r.translations_search=a.search),a.missingOnly&&(r.translations_missing="1"),k.get(route("admin.locales.index"),r,{preserveState:!0})},[a]),g=()=>{k.post(route("admin.translations.auto-translate"),{locale:a.locale},{preserveScroll:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-end",children:[e.jsx("select",{value:a.locale,onChange:r=>x(l=>({...l,locale:r.target.value})),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500/20",children:i.map(r=>e.jsxs("option",{value:r.code,children:[r.name," (",r.code,")"]},r.code))}),e.jsxs("select",{value:a.group,onChange:r=>x(l=>({...l,group:r.target.value})),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500/20",children:[e.jsx("option",{value:"",children:n("locales.all_groups")}),m.map(r=>e.jsx("option",{value:r,children:r},r))]}),e.jsx("input",{type:"text",placeholder:n("locales.search_key_value"),value:a.search,onChange:r=>x(l=>({...l,search:r.target.value})),className:"rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-brand-500/20"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-neutral-900 dark:text-neutral-100 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.missingOnly,onChange:r=>x(l=>({...l,missingOnly:r.target.checked})),className:"rounded border-neutral-300 dark:border-neutral-600 text-brand-500"}),n("locales.missing_only")]}),e.jsx(h,{size:"sm",variant:"secondary",onClick:f,children:n("locales.apply_filters")}),a.locale!=="en"&&e.jsx(h,{size:"sm",variant:"primary",onClick:g,children:n("locales.auto_translate_missing")})]}),e.jsxs(v,{children:[e.jsx("div",{className:"overflow-x-auto max-h-[60vh] overflow-y-auto",children:e.jsxs("table",{className:"min-w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white dark:bg-neutral-950 border-b border-neutral-200 dark:border-neutral-700",children:e.jsxs("tr",{className:"text-left text-neutral-500 dark:text-neutral-400",children:[e.jsx("th",{className:"pb-2 pr-4 font-medium",children:n("locales.col_key")}),e.jsx("th",{className:"pb-2 pr-4 font-medium w-1/3",children:n("locales.col_english")}),e.jsxs("th",{className:"pb-2 pr-4 font-medium w-1/3",children:[n("locales.translation")," (",c,")"]}),e.jsx("th",{className:"pb-2"})]})}),e.jsx("tbody",{children:t.map(r=>e.jsx(O,{item:r,localeCode:c},r.flat_key))})]})}),t.length===0&&e.jsx("div",{className:"py-8 text-center text-neutral-500 dark:text-neutral-400",children:n("locales.no_translations")})]})]})}function j(t){return t==null?"":typeof t=="string"?t:typeof t=="object"?JSON.stringify(t):String(t)}function O({item:t,localeCode:c}){const{t:s}=N(),[d,u]=b.useState(j(t.value));b.useEffect(()=>{u(j(t.value))},[t.flat_key,t.value]);const[m,i]=b.useState(!1),n=b.useCallback(()=>{d!==(t.value??"")&&(i(!0),k.put(route("admin.translations.update"),{locale:c,flat_key:t.flat_key,value:d},{preserveScroll:!0,onFinish:()=>i(!1)}))},[c,t.flat_key,t.value,d]);
1return e.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800",children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-neutral-700 dark:text-neutral-300 align-top",children:j(t.flat_key)}),e.jsx("td",{className:"py-2 pr-4 text-neutral-600 dark:text-neutral-400 align-top whitespace-pre-wrap",children:j(t.en_value)||"â"}),e.jsx("td",{className:"py-2 pr-4 align-top",children:e.jsx("input",{type:"text",value:d,onChange:a=>u(a.target.value),onBlur:n,className:"w-full rounded-soft border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-900 dark:text-neutral-100 px-2 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500/20",placeholder:s("locales.translation")})}),e.jsx("td",{className:"py-2",children:m&&e.jsx("span",{className:"text-xs text-neutral-400",children:s("locales.saving")})})]})}export{le 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.