import{u as b,aU as S,hm as j,h as w,d1 as t,d2 as i,ac as E,ci as O,ag as R,hn as I,X as m,ho as V,hp as H,cf as L,j as n,p as f,h8 as $,ae as z,cm as G,cn as M,O as x,e as y,hq as U,r as W,gc as X,ak as J}from"./bundle.CHKSNOJF.js";import{u as K}from"./atoms-BzmrHkTd.js";import{I as Q}from"./InvoiceViewer-DkbHIsNq.js";function Y(){const[e]=b(),d=S(),{isCompanySettingsActive:s}=j();return[{name:e("general_settings"),href:"/settings/invoice_design"},{name:e("custom_designs"),href:"/settings/invoice_design/custom_designs",matcher:[()=>"/settings/invoice_design/custom_designs/create",a=>w("/settings/invoice_design/custom_designs/:id/edit",a)],enabled:s},{name:e("client"),href:"/settings/invoice_design/client_details",enabled:s},{name:e("company"),href:"/settings/invoice_design/company_details",enabled:s&&(t()||i())},{name:e("company_address"),href:"/settings/invoice_design/company_address",enabled:s&&(t()||i())},{name:e("invoice"),href:"/settings/invoice_design/invoice_details",enabled:s&&(t()||i())},{name:e("quote"),href:"/settings/invoice_design/quote_details",enabled:s&&(t()||i())},{name:e("credit"),href:"/settings/invoice_design/credit_details",enabled:s&&(t()||i())},{name:e("vendor"),href:"/settings/invoice_design/vendor_details",enabled:s&&(t()||i())},{name:e("purchase_order"),href:"/settings/invoice_design/purchase_order_details",enabled:s&&(t()||i())},{name:d?.settings.sync_invoice_quote_columns?e("product_columns"):e("invoice_product_columns"),href:"/settings/invoice_design/product_columns",enabled:s&&(t()||i())},{name:e("quote_product_columns"),href:"/settings/invoice_design/quote_product_columns",enabled:s&&(t()||i())&&!d?.settings.sync_invoice_quote_columns},{name:e("task_columns"),href:"/settings/invoice_design/task_columns",enabled:s&&(t()||i())},{name:e("total_fields"),href:"/settings/invoice_design/total_fields",enabled:s&&(t()||i())}]}function ne(){const[e]=b(),{documentTitle:d}=E("invoice_design"),{id:s}=O(),_=Y(),a=R(),o=S(),T=I(),{isClientSettingsActive:q,isGroupSettingsActive:v}=j(),l=!a.pathname.includes("custom_designs"),p=m(V),P=m(H),A=L(),g=a.pathname.includes("custom_designs")?a.pathname.endsWith("/custom_designs"):!0,h=()=>n.jsxs("div",{className:"flex space-x-0.5 items-center text-xs py-1 px-2 bg-[#2176FF26] rounded",children:[n.jsx("div",{children:n.jsx(U,{size:"1rem",color:"#2176FF"})}),n.jsx("span",{className:"font-medium",style:{color:"#2176FF"},children:e("pro")})]}),C=[{name:e("settings"),href:"/settings"},{name:e("invoice_design"),href:"/settings/invoice_design",afterName:n.jsx(h,{})}],F=[{name:e("settings"),href:"/settings"},{name:e("invoice_design"),href:"/settings/invoice_design"},{name:e("custom_designs"),href:"/settings/invoice_design/custom_designs"},{name:e("design"),href:s?w("/settings/invoice_design/custom_designs/:id/edit",{id:s}):"/settings/invoice_design/custom_designs/create",afterName:n.jsx(h,{})}],[N,B]=f.useState({client_id:"-1",entity_type:"invoice",group_id:"-1",settings:null,settings_type:"company"}),r=m(K),k=()=>{A();const c=[];r.map(({design_id:u,entity:D})=>{c.push(W("POST",y("/api/v1/designs/set/default"),{design_id:u,entity:D,settings_level:v?"group_settings":T.level,...q&&{client_id:o?.settings?.id},...v&&{group_settings_id:P?.id}}))}),X.all(c).then(()=>{r.forEach(({entity:u})=>{J([`${u}s`])})})};return f.useEffect(()=>{o?.settings&&B(c=>c&&{...c,settings:o.settings})},[o?.settings]),$({onClick:k,displayButton:l,disableSaveButton:p},[o,r,a,p]),n.jsxs(z,{title:d,breadcrumbs:g?C:F,children:[n.jsx(G,{tabs:_,visible:g,withoutDefaultTabSpace:!0,fullRightPadding:!0,paddingTabsHeight:"2.9rem"}),n.jsxs("div",{className:x("flex flex-col lg:flex-row gap-4",{"my-4":g}),children:[n.jsx("div",{className:x("w-full overflow-y-auto",{"lg:w-1/2":l}),children:n.jsx(M,{})}),l&&n.jsx("div",{className:"w-full lg:w-1/2 max-h-[80vh] overflow-y-scroll",children:n.jsx(Q,{link:y("/api/v1/live_design"),resource:N,method:"POST",withToast:!0})})]})]})}export{ne as default};
