import{r as n,j as e,Q as b,a as p,t as l}from"./app-BBZbvTSO.js";import{A as L}from"./app-layout-DgXit_SB.js";import S from"./layout-CRccZ4Da.js";import{H as x}from"./heading-small-CjA8Z0WM.js";import{B as m}from"./button-CZmOQP7j.js";import{S as v}from"./separator-BzKY_P4f.js";import{S as A}from"./Select-BSWSW26d.js";import{l as j}from"./locales-b3RnhGsA.js";import{T as z}from"./trash-2-BBs2y9vd.js";/* empty css            */import"./utils-YhN_nlHn.js";import"./index-C0VDnRYN.js";import"./index-CbDI-tXU.js";import"./Combination-9YgcTppv.js";import"./index-13DH8-b5.js";import"./index-C1VwruLz.js";import"./tooltip-CRkL5R4V.js";import"./index-hDbW6ayQ.js";import"./floating-ui.dom-DtF1XweH.js";import"./index-AiAmtg3H.js";import"./dropdown-menu-DkvU_mzU.js";import"./index-IvSACaye.js";import"./index-BosTFUDi.js";import"./index-Dbn6AP0q.js";import"./settings-1sj5BLwD.js";import"./app-logo-icon-BZsH9yGo.js";import"./index-BnKWxTXF.js";import"./image-BEhzBCM8.js";import"./globe-DRyUQWUz.js";import"./users-DU0sA3Q7.js";import"./layout-grid-CF44vN4j.js";import"./chevron-right-fDICdnKB.js";import"./heading-D7WRqD78.js";function ie({project:h}){const[a,i]=n.useState(h),[o,u]=n.useState(null),f=[{title:a.name,href:route("projects.show",a.id)},{title:"Settings",href:route("projects.settings.project",a.id)},{title:"Localization",href:route("projects.settings.localization",a.id)}],c=Array.isArray(a.locales)?a.locales:a.locales?[a.locales]:[],y=n.useMemo(()=>Object.entries(j).filter(([t])=>!c.includes(t)).map(([t,s])=>({value:t,label:`${t} - ${s}`})),[a]),w=async()=>{var t,s;if(o)try{const r=await p.post(route("projects.settings.locales.add",a.id),{locale:o.value});i(r.data),u(null),l.success("Locale added")}catch(r){l.error(((s=(t=r.response)==null?void 0:t.data)==null?void 0:s.message)||"Failed to add locale")}},g=async t=>{try{const s=await p.put(route("projects.settings.locales.default",a.id),{locale:t});i(s.data),l.success("Default locale updated")}catch{l.error("Failed to update default locale")}},N=async t=>{var s,r;try{const d=await p.delete(route("projects.settings.locales.delete",[a.id,t]));i(d.data),l.success("Locale deleted")}catch(d){l.error(((r=(s=d.response)==null?void 0:s.data)==null?void 0:r.message)||"Failed to delete locale")}};return e.jsxs(L,{breadcrumbs:f,children:[e.jsx(b,{title:"Localization settings"}),e.jsx(S,{project:a,children:e.jsxs("div",{className:"space-y-10 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx(x,{title:"Available Locales"}),e.jsx("div",{className:"mt-4 overflow-x-auto border rounded-md",children:e.jsx("table",{className:"min-w-full text-sm",children:e.jsxs("tbody",{children:[c.map(t=>e.jsxs("tr",{className:"border-b last:border-b-0",children:[e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:t}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:j[t]||"-"}),e.jsx("td",{className:"px-4 py-2 text-center whitespace-nowrap",children:t===a.default_locale?e.jsx("span",{className:"font-medium",children:"Default"}):e.jsx(m,{variant:"link",className:"px-2",onClick:()=>g(t),children:"Set as default"})}),e.jsx("td",{className:"px-4 py-2 text-center whitespace-nowrap",children:t!==a.default_locale&&e.jsx(m,{variant:"ghost",size:"icon",className:"text-red-600",onClick:()=>N(t),children:e.jsx(z,{className:"w-4 h-4"})})})]},t)),c.length===0&&e.jsx("tr",{children:e.jsx("td",{className:"px-4 py-2 text-muted-foreground",colSpan:4,children:"No locales yet."})})]})})})]}),e.jsx(v,{}),e.jsxs("div",{children:[e.jsx(x,{title:"Add a Locale"}),e.jsxs("div",{className:"mt-4 flex gap-2 w-full",children:[e.jsx(A,{value:o,onChange:u,options:y,placeholder:"Select locale",classNamePrefix:"react-select",className:"w-full"}),e.jsx(m,{onClick:w,disabled:!o,children:"Add"})]})]})]})})]})}export{ie as default};
