import{r as h,j as s,H as I,a as v}from"./app-BwDemWQz.js";import{A as O,P as N}from"./AppLayout-3zbhnyYw.js";import{C as f,b,c as w,d as y,a as k}from"./Card-DJ3wHKN-.js";import{B as o}from"./Button-B-KWyoQR.js";import{I as u}from"./Input-BJaxI6jp.js";import{L as _}from"./Label-1lm7x8-L.js";import{u as P,z as T}from"./LanguageContext-zkEAKPTE.js";import{A as $}from"./arrow-left-B11txR0s.js";import{L as g}from"./languages-BJDUufDH.js";import{S as F}from"./save-efCvtXyR.js";import{T as q}from"./trash-2-DJCIoKoz.js";/* empty css            */import"./index-DxJALBsh.js";import"./createLucideIcon-BASx8f0E.js";import"./index-CkDmAPFS.js";import"./zap-BsHQ4DWF.js";import"./rocket-Dt03WmgU.js";import"./users-g1HvrzO9.js";import"./globe-C_ZhZ5i9.js";function os({auth:C,language:c,translations:S={}}){const[d,z]=h.useState(S),[m,l]=h.useState([{key:"",value:""}]),[p,x]=h.useState(!1),a=P(),L=[{label:a("Settings"),href:route("user.setting.index")},{label:a("Languages")},{label:c.name}],A=(e,t)=>{z(r=>({...r,[e]:t}))},j=(e,t,r)=>{l(n=>n.map((i,H)=>H===e?{...i,[t]:r}:i))},E=()=>{l(e=>[...e,{key:"",value:""}])},R=e=>{l(t=>t.filter((r,n)=>n!==e))},B=()=>{x(!0);const e=m.filter(n=>n.key.trim()&&n.value.trim()),t={...d};e.forEach(n=>{t[n.key.trim()]=n.value.trim()});const r=Object.entries(t).map(([n,i])=>({key:n,value:i}));v.post(route("user.language.translation.add"),{translations:r,language_id:c.id},{preserveState:!0,preserveScroll:!0,onSuccess:()=>{T.success(a("Translations saved successfully")),l([{key:"",value:""}]),x(!1)},onError:()=>{T.error(a("Failed to save translations")),x(!1)}})},D=()=>{v.get(route("user.setting.index"))};return s.jsxs(O,{user:C.user,breadcrumbs:L,children:[s.jsx(I,{title:`${a("Translations")} - ${c.name}`}),s.jsx("div",{className:"py-6",children:s.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[s.jsx("div",{className:"mb-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx(o,{variant:"ghost",size:"icon",onClick:D,className:"h-10 w-10",children:s.jsx($,{className:"h-5 w-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{children:s.jsx(g,{className:"h-6 w-6 text-primary"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl sm:text-2xl dark:text-gray-200 font-bold",children:a("Language Translations")}),s.jsx("p",{className:"text-gray-500 dark:text-gray-200",children:"Customize and manage language translations for your application"})]})]})]}),s.jsxs(o,{onClick:B,disabled:p,className:"bg-gradient-to-r from-primary to-secondary hover:opacity-90",children:[s.jsx(F,{className:"w-4 h-4 mr-2"}),a(p?"Saving...":"Save Changes")]})]})}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs(f,{className:"border-0 shadow-sm bg-white/50 dark:bg-zinc-900/50 backdrop-blur-sm",children:[s.jsxs(b,{children:[s.jsxs(w,{className:"flex items-center space-x-2",children:[s.jsx(g,{className:"w-5 h-5"}),s.jsx("span",{children:a("Existing Translations")})]}),s.jsx(y,{children:a("Edit existing translation values")})]}),s.jsx(k,{className:"space-y-4",children:Object.entries(d).length===0?s.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[s.jsx(g,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:a("No translations found")}),s.jsx("p",{className:"text-sm",children:a("Add new translations using the form on the right")})]}):Object.entries(d).map(([e,t])=>s.jsxs("div",{className:"space-y-2",children:[s.jsx(_,{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),s.jsx(u,{value:t,onChange:r=>A(e,r.target.value),placeholder:a("Translation value"),className:"bg-white dark:bg-zinc-800"})]},e))})]}),s.jsxs(f,{className:"border-0 shadow-sm bg-white/50 dark:bg-zinc-900/50 backdrop-blur-sm",children:[s.jsxs(b,{children:[s.jsxs(w,{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(N,{className:"w-5 h-5"}),s.jsx("span",{children:a("Add New Translations")})]}),s.jsxs(o,{variant:"outline",size:"sm",onClick:E,children:[s.jsx(N,{className:"w-4 h-4 mr-1"}),a("Add Row")]})]}),s.jsx(y,{children:a("Add new translation keys and values")})]}),s.jsx(k,{className:"space-y-4",children:m.map((e,t)=>s.jsxs("div",{className:"flex space-x-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(u,{value:e.key,onChange:r=>j(t,"key",r.target.value),placeholder:a("Translation key"),className:"bg-white dark:bg-zinc-800"})}),s.jsx("div",{className:"flex-1",children:s.jsx(u,{value:e.value,onChange:r=>j(t,"value",r.target.value),placeholder:a("Translation value"),className:"bg-white dark:bg-zinc-800"})}),m.length>1&&s.jsx(o,{variant:"ghost",size:"icon",onClick:()=>R(t),className:"text-red-500 hover:text-red-700",children:s.jsx(q,{className:"w-4 h-4"})})]},t))})]})]})]})})]})}export{os as default};
