import{u as w,a as C,p as r,aB as y,gR as v,h8 as E,j as s,dy as N,C as B,c2 as p,a3 as F,_ as $,h9 as k,F as c,E as A,r as D,gT as R,ak as T}from"./bundle.CHKSNOJF.js";function P(){const[t]=w(),n=C(),[o,f]=r.useState(!1),[_,b]=r.useState(null),[d,m]=r.useState(null),x=r.useRef(!1),u=r.useRef(null),[S]=y(v),a=S?.companies,j=a?.[0]?.id;r.useEffect(()=>{if(a?.[0]?.settings&&!x.current){const e=a[0].settings;m(e),u.current=e,x.current=!0}},[a?.[0]?.settings]);const h=(e,l)=>{m(i=>{const g=i&&{...i,[e]:l};return g&&(u.current=g),g})};return E({onClick:()=>{if(!o){f(!0),c.processing();const e=A.cloneDeep(a?.[0]);e&&(e.settings=u.current),D("PUT",R("/api/companies/:id",{id:j}),e,{headers:{Authorization:`Bearer ${localStorage.getItem("X-DOCU-NINJA-TOKEN")}`}}).then(()=>{c.success("updated_company"),T(["docuninja_login"])}).catch(l=>{if(l.response?.status===422){b(l.response.data);const i=l.response.data.message||"validation_errors";c.error(i)}else c.error("error_title")}).finally(()=>f(!1))}},disableSaveButton:o},[o]),d?s.jsxs(s.Fragment,{children:[_&&s.jsx(N,{errors:_}),s.jsxs(B,{title:t("widget_defaults"),className:"shadow-sm",style:{borderColor:n.$24},headerStyle:{borderColor:n.$20},children:[s.jsx(p,{leftSide:t("show_label"),leftSideHelp:t("show_label_help"),children:s.jsx(F,{checked:d.widget_show_label??!1,onChange:e=>h("widget_show_label",e),disabled:o})}),s.jsx(p,{leftSide:t("widget_border_style"),leftSideHelp:t("widget_border_style_help"),children:s.jsxs($,{value:d.widget_border_style??"hidden",onValueChange:e=>h("widget_border_style",e),disabled:o,customSelector:!0,dismissable:!1,children:[s.jsx("option",{value:"hidden",children:t("hidden")}),s.jsx("option",{value:"dotted",children:t("dotted")}),s.jsx("option",{value:"solid",children:t("solid")})]})}),s.jsx(p,{leftSide:t("widget_border_color"),leftSideHelp:t("widget_border_color_help"),children:s.jsx(k,{value:d.widget_border_color??"#FF5733",onValueChange:e=>h("widget_border_color",e),disabled:o,includeDefaultPalette:!0,renderLabelBox:e=>s.jsxs("div",{className:"rounded-md flex items-center space-x-2 border p-1 cursor-pointer",style:{borderColor:n.$24},children:[s.jsx("div",{className:"w-7 h-7 rounded-sm",style:{backgroundColor:e}}),s.jsx("span",{className:"text-sm",style:{color:n.$3},children:e.replace("#","")})]})})})]})]}):null}export{P as default};
