PageSourceSearch

https://bizvanguard.ai/assets/OrganizationSettings-DeVNxmED.js

js bizvanguard.ai collected 2026-10-05 13:47:36 UTC 162,739 bytes, 2 lines download raw bytes

1import{u as Z,r as u,t as fe,j as e,v as he}from"./vendor-react-zwv87yMD.js";import{a as _,b as D,u as Te}from"./vendor-query-DYq8g7OI.js";import{s as U,P as Ba,b as Ua}from"./employeeAuthStore-lYSKMuhw.js";import{p as Ue}from"./positions-DqspSnNm.js";import{o as Nt}from"./app-entry-CaCir6v3.js";import{a as le}from"./api-client-wl3SCNAO.js";import{b as $t}from"./billing-CEA-EPiP.js";import{e as qa}from"./employees-BPFguWOi.js";import{u as se}from"./authStore-Bv6p2Ne2.js";import{f as Ka}from"./phoneUtils-CLDOdnrv.js";import{j as _s}from"./timezoneFormatters-Lg56xFv0.js";import{m as Ut}from"./modules-BwvPEPDG.js";import{A as _a,i as za,M as $a,F as Ot}from"./navigation-CBv1MCGY.js";import{X as Yt,v as Ya,c as yt,n as vt,ao as Wa,ap as Wt,J as Ga,E as qe,C as Be,aN as Qa,R as Qe,az as jt,aO as Va,aI as Xa,x as zs,s as It,y as Ft,ax as Za}from"./vendor-icons-bLSWzydc.js";import{B}from"./button-DlBDuKbo.js";import{a as Ht}from"./apiError-3JmRUUhQ.js";import{a as Pe}from"./appointment-settings-D08T_URC.js";import{I as Y}from"./input-C9cRIRX4.js";import{L}from"./label-CSUA9GMO.js";import{S as be}from"./switch-DcU2Tpfn.js";import{T as pt}from"./textarea-CfTUtQow.js";import{S as qt,a as Kt,b as _t,c as zt,d as ye}from"./select-D2pLZtG9.js";import{s as gt}from"./appointment-service-types-hhBy6662.js";import{D as Ja,a as en,b as tn,c as sn,d as an}from"./dialog-CCoQRIQ_.js";import{T as nn,a as rn,b as $s,c as we,d as ln,e as Ce}from"./table-BLRYsg93.js";import{m as Ys}from"./vendor-date-DQe75t6Q.js";import{s as Ge}from"./stripe-connect-4YWWQn6S.js";import{u as on}from"./useOrgTimezone-C1UagyKl.js";import{b as dn}from"./Logo-CcvH_fVs.js";import{L as cn,b as mn}from"./vendor-router-DimZLiZb.js";import{u as un}from"./usePermissions-CBDKNj1w.js";import"./vendor-charts-CtrTLS4K.js";import"./vendor-i18n-BdYkS11p.js";import"./vendor-ui-CfDMlrKu.js";import"./vendor-pdf-DQuePnfN.js";import"./vendor-state-ByI9XJey.js";import"./vendor-editor-C_dhmuey.js";import"./i18n-CwjSIy0a.js";import"./legal-documents-DjQ2iB_Z.js";import"./RichTextContent-CRaB6axZ.js";import"./dropdown-menu-DJoX9NOt.js";import"./utils-BXSzAfFa.js";const Ws={getSettings:async()=>(await le.get("/reminders/settings")).data,updateSettings:async t=>{await le.patch("/reminders/settings",t)},getLogs:async t=>(await le.get("/reminders/logs",{params:t})).data},ht={[Ot.MARKETING]:"Platinum",[Ot.LOYALTY]:"Platinum",[Ot.CORPORATE_CATERING]:"Platinum"},Gs={FREE:0,SILVER:1,GOLD:2,PLATINUM:3};function xn(){var T;const{t}=Z("settings"),a=se(C=>C.currentOrganizationId),d=se(C=>C.enabledModules),r=se(C=>C.setEnabledModules),[p,y]=u.useState(new Set(d)),[S,N]=u.useState(!1),{data:f}=_({queryKey:["subscription",a],queryFn:$t.getSubscription,enabled:!!a,staleTime:300*1e3}),l=((T=f==null?void 0:f.plan)==null?void 0:T.tier)||"FREE",k=C=>{const j=ht[C];return j?(Gs[l]||0)>=(Gs[j.toUpperCase()]||0):!0},{data:x}=_({queryKey:["module-setup-status",a],queryFn:Ut.getSetupStatus,enabled:!!a,staleTime:300*1e3}),c=D({mutationFn:C=>Ut.updateEnabledModules(C),onSuccess:C=>{r(C),N(!1),fe.success(t("featuresTab.toast.saved"))},onError:()=>{fe.error(t("featuresTab.toast.saveFailed"))}}),m=C=>{if(!k(C)){const j=ht[C];fe.error(t("featuresTab.toast.tierRequired",{tier:j}));return}y(j=>{const q=new Set(j);return q.has(C)?q.delete(C):q.add(C),N(!0),q})},g=()=>{c.mutate(Array.from(p))},h=()=>{y(new Set(d)),N(!1)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("featuresTab.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("featuresTab.subtitle")})]}),(x==null?void 0:x.industryPresetId)&&e.jsxs("div",{className:"text-sm text-muted-foreground bg-muted/50 px-4 py-2 rounded-md",children:[t("featuresTab.industry")," ",e.jsx("span",{className:"font-medium text-foreground capitalize",children:x.industryPresetId.replace(/_/g," ")})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3",children:_a.map(C=>{const j=$a[C];if(!j)return null;const q=d.includes(C);if(za(C,q))return null;const $=p.has(C);return e.jsxs("div",{className:`flex items-center justify-between p-4 border rounded-lg transition-colors ${$?"border-primary/30 bg-primary/5":"border-border"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0 mr-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:j.name}),ht[C]&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:t("featuresTab.requiresTier",{tier:ht[C]})})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.description})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":$,onClick:()=>m(C),disabled:!k(C),className:`relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${k(C)?$?"bg-primary curs
1or-pointer":"bg-input cursor-pointer":"bg-input opacity-50 cursor-not-allowed"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${$?"translate-x-5":"translate-x-0"}`})})]},C)})}),S&&e.jsxs("div",{className:"sticky bottom-4 flex items-center justify-end gap-3 p-4 bg-card border rounded-lg shadow-lg",children:[e.jsx("span",{className:"text-sm text-muted-foreground mr-auto",children:t("featuresTab.unsavedChanges")}),e.jsxs("button",{onClick:h,className:"inline-flex items-center gap-1.5 px-4 py-2 border rounded-md hover:bg-accent text-sm",children:[e.jsx(Yt,{className:"h-4 w-4"}),t("featuresTab.discard")]}),e.jsxs("button",{onClick:g,disabled:c.isPending,className:"inline-flex items-center gap-1.5 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 text-sm disabled:opacity-50",children:[c.isPending?e.jsx(Ya,{className:"h-4 w-4 animate-spin"}):e.jsx(yt,{className:"h-4 w-4"}),t("featuresTab.saveChanges")]})]})]})}function Qs(t){return`${t.toFixed(4).replace(/\.?0+$/,"")}%`}function pn({rates:t,currentPercent:a}){const{t:d}=Z("settings"),r=Te(),[p,y]=u.useState(!1),[S,N]=u.useState(""),[f,l]=u.useState(""),[k,x]=u.useState(""),[c,m]=u.useState(null),[g,h]=u.useState(""),[T,C]=u.useState(""),j=()=>{r.invalidateQueries({queryKey:["settings"]}),r.invalidateQueries({queryKey:["company-info"]}),r.invalidateQueries({queryKey:["sales-tax-period"]})},q=D({mutationFn:()=>U.addSalesTaxRate({ratePercent:Number(S),effectiveOn:f,note:k.trim()||null}),onSuccess:()=>{fe.success(d("profile.salesTaxRateAdded")),y(!1),N(""),l(""),x(""),j()},onError:M=>fe.error(Ht(M,d("profile.salesTaxRateFailed")))}),$=D({mutationFn:()=>U.updateSalesTaxRate(c,{ratePercent:Number(g),effectiveOn:T}),onSuccess:()=>{fe.success(d("profile.salesTaxRateAdded")),m(null),j()},onError:M=>fe.error(Ht(M,d("profile.salesTaxRateFailed")))}),oe=D({mutationFn:M=>U.deleteSalesTaxRate(M),onSuccess:()=>{fe.success(d("profile.salesTaxRateRemoved")),j()},onError:M=>fe.error(Ht(M,d("profile.salesTaxRateFailed")))}),W=[...t].sort((M,G)=>M.effectiveOn.localeCompare(G.effectiveOn));return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:d("profile.salesTaxLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:d("profile.salesTaxScheduleHint")}),a!=null&&e.jsx("p",{className:"text-sm",children:d("profile.salesTaxCurrent",{rate:Qs(a)})})]}),e.jsx("div",{className:"overflow-x-auto rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:d("profile.salesTaxEffectiveOn")}),e.jsx("th",{className:"px-3 py-2 font-medium",children:d("profile.salesTaxRateCol")}),e.jsx("th",{className:"px-3 py-2 font-medium",children:d("profile.salesTaxNote")}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"divide-y",children:W.length===0?e.jsx("tr",{children:e.jsx("td",{className:"px-3 py-2 text-muted-foreground",colSpan:4,children:d("profile.salesTaxNoRows")})}):W.map(M=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:c===M.id?e.jsx("input",{type:"date",value:T,onChange:G=>C(G.target.value),className:"px-2 py-1 border rounded-md text-sm"}):M.effectiveOn}),e.jsx("td",{className:"px-3 py-2 tabular-nums",children:c===M.id?e.jsx("input",{type:"number",step:"0.0001",min:"0",max:"100",value:g,onChange:G=>h(G.target.value),className:"w-24 px-2 py-1 border rounded-md text-sm"}):Qs(M.ratePercent)}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:M.note||"—"}),e.jsx("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:c===M.id?e.jsxs("span",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"text-xs underline",onClick:()=>$.mutate(),disabled:$.isPending,children:d("profile.salesTaxSaveChange")}),e.jsx("button",{type:"button",className:"text-xs underline text-muted-foreground",onClick:()=>m(null),children:d("buttons.cancel")})]}):e.jsxs("span",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"text-xs underline",onClick:()=>{m(M.id),h(String(M.ratePercent)),C(M.effectiveOn)},children:d("profile.salesTaxEdit")}),W.length>1&&e.jsx("button",{type:"button",className:"text-xs underline text-muted-foreground hover:text-destructive",onClick:()=>oe.mutate(M.id),disabled:oe.isPending,children:d("profile.salesTaxRemove")})]})})]},M.id))})]})}),p?e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:d("profile.salesTaxAddTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d("profile.salesTaxAddHint")}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-2",children:[e.jsxs("label",{className:"text-xs",children:[d("profile.salesTaxRateCol"),e.jsx("input",{type:"number",step:"0.0001",min:"0",max:"100",value:S,onChange:M=>N(M.target.value),placeholder:"9.75",className:"mt-1 w-full px-2 py-1.5 border rounded-md text-sm"})]}),e.jsxs("label",{className:"text-xs",children:[d("profile.salesTaxEffectiveOn"),e.jsx("input",{type:"date",value:f,onChange:M=>l(M.target.value),className:"mt-1 w-full px-2 py-1.5 border rounded-md text-sm"})]}),e.jsxs("label",{className:"text-xs",children:[d("profile.salesTaxNote"),e.jsx("input",{type:"text",value:k,onChange:M=>x(M.target.value),placeholder:d("profile.salesTaxNotePlaceholder"),className:"mt-1 w-full px-2 py-1.5 border rounded-md text-sm"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{size:"sm",onClick:()=>q.mutate(),disabled:q.isPending||!S||!f,children:d("profile.salesTaxSaveChange")}),e.jsx(B,{size:"sm",variant:"outline",onClick:()=>y(!1),children:d("buttons.cancel")})]})]}):e.jsx(B,{size:"sm",variant:"outline",onClick:()=>y(!0),children:d("profile.salesTaxAddChange")})]})}function gn(){const{t}=Z("appointments"),{currentOrganizationId:a}=se(),d=Te(),[r,p]=u.useState(!1),[y,S]=u.useState(null),[N,f]=u.useState(""),[l,k]=u.useState("60"),[x,c]=u.useState(""),[m,g]=u.useState("0"),[h,T]=u.useState("#3b82f6"),[C,j]=u.useState(""),{data:q=[],isLoading:$}=_({queryKey:["appointment-service-types",a],queryFn:()=>gt.getAll(),enabled:!!a}),oe=D({mutationFn:w=>gt.create(w),onSuccess:()=>{d.invalidateQueries({queryKey:["appointment-service-types"]}),ae()}}),W=D({mutationFn:({id:w,data:J})=>gt.update(w,J),onSuccess:()=>{d.invalidateQueries({queryKey:["appointment-service-types"]}),ae()}}),M=D({mutationFn:w=>gt.delete(w),onSuccess:()=>{d.invalidateQueries({queryKey:["appointment-service-types"]})}}),G=()=>{S(null),f(""),k("60"),g("0"),c(""),T("#3b82f6"),j(""),p(!0)},Ee=w=>{S(w),f(w.name),k(String(w.durationMinutes)),g(String(w.bufferMinutesAfter)),c(w.price!==null?String(w.price):""),T(w.color),j(w.description||""),p(!0)},ae=()=>{p(!1),S(null)},De=w=>{w.preventDefault();const J={name:N,durationMinutes:parseInt(l,10),bufferMinutesAfter:parseInt(m,10)||0,price:x?parseFloat(x):void 0,color:h,description:C||void 0};y?W.mutate({id:y.id,data:J}):oe.mutate(J)};return $?e.jsx("div",{className:"py-8 text-center text-gray-500",children:t("serviceTypes.loading")}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("serviceTypes.title")}),e.jsx("p",{className:"text-sm text-gray-500",children:t("serviceTypes.subtitle")})]}),e.jsxs(B,{onClick:G,size:"sm",children:[e.jsx(vt,{className:"mr-1 h-4 w-4"}),t("serviceTypes.addButton")]})]}),q.length===0?e.jsx("div",{className:"rounded-lg border border-dashed p-8 text-center text-gray-500",children:t("serviceTypes.empty")}):e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs($s,{children:[e.jsx(we,{children:t("serviceTypes.table.color")}),e.jsx(we,{children:t("serviceTypes.table.name")}),e.jsx(we,{children:t("serviceTypes.table.duration")}),e.jsx(we,{children:t("serviceTypes.table.buffer")}),e.jsx(we,{children:t("serviceTypes.table.price")}),e.jsx(we,{children:t("serviceTypes.table.status")}),e.jsx(we,{className:"w-24",children:t("serviceTypes.table.actions")})]})}),e.jsx(ln,{children:q.map(w=>e.jsxs($s,{children:[e.jsx(Ce,{children:e.jsx("span",{className:"inline-block h-5 w-5 rounded-full",style:{backgroundColor:w.color}})}),e.jsx(Ce,{className:"font-medium",children:w.name}),e.jsx(Ce,{children:t("serviceTypes.minutes",{count:w.durationMinutes})}),e.jsx(Ce,{children:w.bufferMinutesAfter>0?t("serviceTypes.minutes",{count:w.bufferMinutesAfter}):"-"}),e.jsx(Ce,{children:w.price!==null?`$${Number(w.price).toFixed(2)}`:"-"}),e.jsx(Ce,{children:e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${w.isActive?"bg-green-100 text-green-800":"bg-gray-100 text-gray-600"}`,children:w.isActive?t("serviceTypes.status.active"):t("serviceTypes.status.inactive")})}),e.jsx(Ce,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>Ee(w),children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{window.confirm(t("serviceTypes.confirmDelete"))&&M.mutate(w.id)},children:e.jsx(Wt,{className:"h-4 w-4 text-red-500"})})]})})]},w.id))})]}),e.jsx(Ja,{open:r,onOpenChange:p,children:e.jsxs(en,{children:[e.jsx(tn,{children:e.jsx(sn,{children:t(y?"serviceTypes.form.editTitle":"serviceTypes.form.newTitle")})}),e.jsxs("form",{onSubmit:De,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.name")}),e.jsx(Y,{value:N,onChange:w=>f(w.target.value),placeholder:t("serviceTypes.form.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.duration")}
1),e.jsx(Y,{type:"number",value:l,onChange:w=>k(w.target.value),min:5,required:!0})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.buffer")}),e.jsx(Y,{type:"number",value:m,onChange:w=>g(w.target.value),min:0,max:120}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("serviceTypes.form.bufferHelp")})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.price")}),e.jsx(Y,{type:"number",value:x,onChange:w=>c(w.target.value),step:"0.01",min:0,placeholder:t("serviceTypes.form.pricePlaceholder")})]})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.color")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:h,onChange:w=>T(w.target.value),className:"h-10 w-10 cursor-pointer rounded border"}),e.jsx(Y,{value:h,onChange:w=>T(w.target.value),className:"flex-1",placeholder:"#3b82f6"})]})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("serviceTypes.form.description")}),e.jsx(Y,{value:C,onChange:w=>j(w.target.value),placeholder:t("serviceTypes.form.descriptionPlaceholder")})]}),e.jsxs(an,{children:[e.jsx(B,{type:"button",variant:"outline",onClick:ae,children:t("serviceTypes.form.cancel")}),e.jsx(B,{type:"submit",disabled:oe.isPending||W.isPending,children:t(y?"serviceTypes.form.update":"serviceTypes.form.create")})]})]})]})})]})}function hn(t){if(t.length===0)return[];const a=[...t].sort((p,y)=>new Date(p.date).getTime()-new Date(y.date).getTime()),d=[];let r={startDate:a[0].date.split("T")[0],endDate:a[0].date.split("T")[0],reason:a[0].reason,ids:[a[0].id]};for(let p=1;p<a.length;p++){const y=new Date(r.endDate+"T00:00:00.000Z"),S=a[p].date.split("T")[0];(new Date(S+"T00:00:00.000Z").getTime()-y.getTime())/(1e3*60*60*24)===1&&a[p].reason===r.reason?(r.endDate=S,r.ids.push(a[p].id)):(d.push(r),r={startDate:S,endDate:S,reason:a[p].reason,ids:[a[p].id]})}return d.push(r),d}function bt(t){return new Date(t+"T00:00:00.000Z").toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function bn(t){return new Date(t+"T00:00:00.000Z").toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:"UTC"})}function fn(t){if(t.startDate===t.endDate)return bt(t.startDate);const a=t.startDate.substring(0,4),d=t.endDate.substring(0,4);return a===d?`${bn(t.startDate)} – ${bt(t.endDate)}`:`${bt(t.startDate)} – ${bt(t.endDate)}`}function yn(){const{t}=Z("appointments"),{currentOrganizationId:a}=se(),d=Te(),[r,p]=u.useState(""),[y,S]=u.useState(""),[N,f]=u.useState(""),{data:l=[],isLoading:k}=_({queryKey:["blackout-dates",a],queryFn:()=>Pe.getBlackoutDates(),enabled:!!a}),x=u.useMemo(()=>hn(l),[l]),c=D({mutationFn:j=>Pe.createBlackoutDate(j),onSuccess:()=>{d.invalidateQueries({queryKey:["blackout-dates"]}),p(""),S(""),f("")}}),m=D({mutationFn:j=>Pe.deleteBlackoutDate(j),onSuccess:()=>{d.invalidateQueries({queryKey:["blackout-dates"]})}}),g=D({mutationFn:j=>Pe.deleteBlackoutDateRange(j.startDate,j.endDate),onSuccess:()=>{d.invalidateQueries({queryKey:["blackout-dates"]})}}),h=()=>{r&&c.mutate({date:r,endDate:y||void 0,reason:N||void 0})},T=j=>{j.ids.length===1?m.mutate(j.ids[0]):g.mutate({startDate:j.startDate,endDate:j.endDate})},C=m.isPending||g.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ga,{className:"h-5 w-5 text-gray-500"}),e.jsx("h3",{className:"text-sm font-medium text-gray-900",children:t("blackout.title")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:t("blackout.description")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:t("blackout.start")}),e.jsx(Y,{type:"date",value:r,onChange:j=>p(j.target.value),className:"w-40"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:t("blackout.end")}),e.jsx(Y,{type:"date",value:y,onChange:j=>S(j.target.value),min:r,className:"w-40"})]}),e.jsx(Y,{placeholder:t("blackout.reasonPlaceholder"),value:N,onChange:j=>
1f(j.target.value),className:"flex-1 min-w-[120px]"}),e.jsxs(B,{size:"sm",onClick:h,disabled:!r||c.isPending,children:[e.jsx(vt,{className:"h-4 w-4 mr-1"}),y&&y>r?t("blackout.addRange"):t("blackout.add")]})]}),k?e.jsx("p",{className:"text-sm text-gray-400",children:t("blackout.loading")}):x.length===0?e.jsx("p",{className:"text-sm text-gray-400",children:t("blackout.empty")}):e.jsx("div",{className:"border rounded-md divide-y",children:x.map(j=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:fn(j)}),j.ids.length>1&&e.jsxs("span",{className:"text-xs text-gray-400 ml-1.5",children:["(",t("blackout.daysCount",{count:j.ids.length}),")"]}),j.reason&&e.jsxs("span",{className:"text-sm text-gray-500 ml-2",children:["— ",j.reason]})]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>T(j),disabled:C,children:e.jsx(Wt,{className:"h-4 w-4 text-red-500"})})]},j.ids.join(",")))})]})}const ft={getConnectUrl:async()=>(await le.get("/google-calendar/connect")).data,disconnect:async()=>(await le.post("/google-calendar/disconnect")).data,sync:async()=>(await le.post("/google-calendar/sync")).data,getStatus:async()=>(await le.get("/google-calendar/status")).data};function jn(){const{t}=Z("appointments"),{currentOrganizationId:a,permissions:d}=se(),r=Te(),[p,y]=u.useState(!1),S=d.includes("MANAGE_CALENDAR_SYNC"),{data:N,isLoading:f}=_({queryKey:["google-calendar-status",a],queryFn:()=>ft.getStatus(),enabled:!!a,staleTime:3e4}),l=D({mutationFn:()=>ft.getConnectUrl(),onSuccess:c=>{window.location.href=c.url}}),k=D({mutationFn:()=>ft.disconnect(),onSuccess:()=>{r.invalidateQueries({queryKey:["google-calendar-status"]}),y(!1)}}),x=D({mutationFn:()=>ft.sync(),onSuccess:()=>{r.invalidateQueries({queryKey:["google-calendar-status"]})}});return f?e.jsx("div",{className:"text-sm text-gray-500",children:t("googleCalendar.checking")}):N!=null&&N.connected?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:t("googleCalendar.connected")})]}),S&&(p?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:t("googleCalendar.confirmDisconnect")}),e.jsx(B,{variant:"destructive",size:"sm",onClick:()=>k.mutate(),disabled:k.isPending,children:k.isPending?t("googleCalendar.disconnecting"):t("googleCalendar.confirmDisconnectYes")}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>y(!1),children:t("googleCalendar.cancel")})]}):e.jsxs(B,{variant:"ghost",size:"sm",onClick:()=>y(!0),children:[e.jsx(Qa,{className:"mr-1 h-3 w-3"}),t("googleCalendar.disconnect")]}))]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500",children:[e.jsx("div",{children:N.lastSyncAt?e.jsx(e.Fragment,{children:t("googleCalendar.lastSynced",{time:Ys(new Date(N.lastSyncAt),{addSuffix:!0})})}):t("googleCalendar.notSyncedYet")}),S&&e.jsxs(B,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx(Qe,{className:`mr-1 h-3 w-3 ${x.isPending?"animate-spin":""}`}),x.isPending?t("googleCalendar.syncing"):t("googleCalendar.syncNow")]})]}),N.connectedAt&&e.jsx("p",{className:"text-xs text-gray-400",children:t("googleCalendar.connectedAt",{time:Ys(new Date(N.connectedAt),{addSuffix:!0})})})]}):e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-center",children:[e.jsx("p",{className:"mb-3 text-sm text-gray-600",children:t("googleCalendar.connectPrompt")}),S?e.jsxs(B,{onClick:()=>l.mutate(),disabled:l.isPending,size:"sm",children:[e.jsx(qe,{className:"mr-1 h-4 w-4"}),l.isPending?t("googleCalendar.redirecting"):t("googleCalendar.connect")]}):e.jsx("p",{className:"text-xs text-gray-400",children:t("googleCalendar.contactAdmin")})]})}const Nn=[{key:"0",id:"sunday"},{key:"1",id:"monday"},{key:"2",id:"tuesday"},{key:"3",id:"wednesday"},{key:"4",id:"thursday"},{key:"5",id:"friday"},{key:"6",id:"saturday"}],vn={0:null,1:{open:"09:00",close:"17:00"},2:{open:"09:00",close:"17:00"},3:{open:"09:00",close:"17:00"},4:{open:"09:00",close:"17:00"},5:{open:"09:00",close:"17:00"},6:null};function kn({value:t,onChange:a}){const{t:d}=Z("appointments"),r=t||vn,p=l=>{const k=r[l],x={...r,[l]:k?null:{open:"09:00",close:"17:00"}};a(x)},y=(l,k,x)=>{const c=r[l];if(!c)return;const m={...r,[l]:{...c,[k]:x}};a(m)},S=l=>{const k=r[l];if(!k)return;const x={...r,[l]:{...k,breaks:[...k.breaks||[],{start:"12:00",end:"13:00"}]}};a(x)},N=(l,k)=>{const x=r[l];if(!(x!=null&&x.breaks))return;const c={...r,[l]:{...x,breaks:x.breaks.filter((m,g)=>g!==k)}};a(c)},f=(l,k,x,c)=>{const m=r[l];if(!(m!=null&&m.breaks))return;const g=m.breaks.map((T,C)=>C===k?{...T,[x]:c}:T),h={...r,[l]:{...m,breaks:g}};a(h)};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{className:"text-sm font-medium",children:d("businessHours.title")}),e.jsx("p",{className:"text-xs text-gray-500",children:d("businessHours.description")}),e.jsx("div",{className:"space-y-2",children:Nn.map(l=>{const k=r[l.key],x=!!k;return e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24",children:e.jsx("span",{className:"text-sm font-medium",children:d(`businessHours.days.${l.id}`)})}),e.jsx(be,{checked:x,onCheckedChange:()=>p(l.key)}),x?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"time",value:k.open,onChange:c=>y(l.key,"open",c.target.value),className:"rounded border px-2 py-1 text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:d("businessHours.to")}),e.jsx("input",{type:"time",value:k.close,onChange:c=>y(l.key,"close",c.target.value),className:"rounded border px-2 py-1 text-sm"}),e.jsxs(B,{type:"button",variant:"ghost",size:"sm",className:"ml-1 h-7 gap-1 px-2 text-xs",onClick:()=>S(l.key),children:[e.jsx(vt,{className:"h-3 w-3"}),d("businessHours.break")]})]}):e.jsx("span",{className:"text-sm text-gray-400",children:d("businessHours.closed")})]}),x&&k.breaks&&k.breaks.length>0&&e.jsx("div",{className:"ml-[calc(6rem+2.75rem)] mt-2 space-y-1.5",children:k.breaks.map((c,m)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:d("businessHours.breakLabel")}
1),e.jsx("input",{type:"time",value:c.start,onChange:g=>f(l.key,m,"start",g.target.value),className:"rounded border px-2 py-1 text-sm"}),e.jsx("span",{className:"text-xs text-gray-500",children:d("businessHours.to")}),e.jsx("input",{type:"time",value:c.end,onChange:g=>f(l.key,m,"end",g.target.value),className:"rounded border px-2 py-1 text-sm"}),e.jsx("button",{type:"button",onClick:()=>N(l.key,m),"aria-label":d("businessHours.removeBreak"),className:"rounded p-0.5 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:e.jsx(Yt,{className:"h-3.5 w-3.5"})})]},m))})]},l.key)})})]})}const Xs=[{minutes:15,label:"15 min"},{minutes:30,label:"30 min"},{minutes:60,label:"1 hour"},{minutes:120,label:"2 hours"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:2880,label:"48 hours"}],Sn=new Set(Xs.map(t=>t.minutes));function wn(t){if(t<60)return`${t} min`;if(t%1440===0)return`${t/1440} day${t/1440>1?"s":""}`;if(t%60===0)return`${t/60} hour${t/60>1?"s":""}`;const a=Math.floor(t/60),d=t%60;return`${a}h ${d}m`}function Cn({value:t,onChange:a}){const{t:d}=Z("settings"),[r,p]=u.useState(!1),[y,S]=u.useState(""),[N,f]=u.useState("hours"),l=new Set(t),k=t.filter(g=>!Sn.has(g)).sort((g,h)=>g-h),x=g=>{const h=l.has(g)?t.filter(T=>T!==g):[...t,g].sort((T,C)=>T-C);h.length>0&&a(h)},c=g=>{const h=t.filter(T=>T!==g);h.length>0&&a(h)},m=()=>{const g=parseFloat(y);if(isNaN(g)||g<=0)return;const h=Math.round(N==="days"?g*1440:N==="hours"?g*60:g);h>0&&!l.has(h)&&a([...t,h].sort((T,C)=>T-C)),S(""),p(!1)};return e.jsxs("div",{children:[e.jsx(L,{children:d("appointmentSettings.reminders.timingsLabel")}),e.jsx("p",{className:"mb-2 text-xs text-gray-500",children:d("appointmentSettings.reminders.timingsHelp")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Xs.map(g=>e.jsx("button",{type:"button",onClick:()=>x(g.minutes),className:`rounded-full border px-3 py-1 text-sm font-medium transition-colors ${l.has(g.minutes)?"border-blue-600 bg-blue-600 text-white":"border-gray-300 bg-white text-gray-700 hover:border-gray-400"}`,children:g.label},g.minutes)),k.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-blue-600 bg-blue-600 px-3 py-1 text-sm font-medium text-white",children:[wn(g),e.jsx("button",{type:"button",onClick:()=>c(g),className:"ml-0.5 rounded-full p-0.5 hover:bg-blue-700",children:e.jsx(Yt,{className:"h-3 w-3"})})]},g)),!r&&e.jsxs("button",{type:"button",onClick:()=>p(!0),className:"inline-flex items-center gap-1 rounded-full border border-dashed border-gray-300 px-3 py-1 text-sm text-gray-500 hover:border-gray-400 hover:text-gray-700",children:[e.jsx(vt,{className:"h-3 w-3"}),d("appointmentSettings.reminders.custom")]})]}),r&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Y,{type:"number",value:y,onChange:g=>S(g.target.value),placeholder:d("appointmentSettings.reminders.customPlaceholder"),className:"w-24",min:1,onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&p(!1)},autoFocus:!0}),e.jsxs(qt,{value:N,onValueChange:g=>f(g),children:[e.jsx(Kt,{className:"w-28",children:e.jsx(_t,{})}),e.jsxs(zt,{children:[e.jsx(ye,{value:"minutes",children:d("appointmentSettings.reminders.unitMinutes")}),e.jsx(ye,{value:"hours",children:d("appointmentSettings.reminders.unitHours")}),e.jsx(ye,{value:"days",children:d("appointmentSettings.reminders.unitDays")})]})]}),e.jsx(B,{size:"sm",onClick:m,children:d("appointmentSettings.reminders.add")}),e.jsx(B,{size:"sm",variant:"ghost",onClick:()=>p(!1),children:d("appointmentSettings.reminders.cancel")})]})]})}function He({value:t,onCommit:a,min:d,max:r,className:p}){const[y,S]=u.useState(String(t));return u.useEffect(()=>{S(String(t))},[t]),e.jsx(Y,{type:"number",value:y,onChange:N=>S(N.target.value),onBlur:()=>{const N=parseInt(y,10);if(isNaN(N)){S(String(t));return}const f=Math.max(d??-1/0,Math.min(r??1/0,N));f!==t&&a(f),S(String(f))},min:d,max:r,className:p})}function Pn(){const{t}=Z("settings"),{currentOrganizationId:a}=se(),d=Te(),[r,p]=u.useState(!1),[y,S]=u.useState(!1),[N,f]=u.useState(!1),{data:l,isLoading:k}=_({queryKey:["appointment-settings",a],queryFn:()=>Pe.get(),enabled:!!a}),{data:x}=_({queryKey:["booking-url",a],queryFn:()=>Pe.getBookingUrl(),enabled:!!a}),c=D({mutationFn:h=>Pe.update(h),onSuccess:()=>{d.invalidateQueries({queryKey:["appointment-settings"]})}}),m=h=>{c.mutate(h)},g=()=>{x!=null&&x.bookingUrl&&(navigator.clipboard.writeText(x.bookingUrl),p(!0),setTimeout(()=>p(!1),2e3))};return k||!l?e.jsx("div",{className:"py-8 text-center text-gray-500",children:t("appointmentSettings.loading")}):e.jsxs("div",{className:"space-y-8",children:[e.jsx(gn,{}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.bookingPortal.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.bookingPortal.subtitle")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.enable")}),e.jsx(be,{checked:l.bookingEnabled,onCheckedChange:h=>m({bookingEnabled:h})})]}),l.bookingEnabled&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.bookingLink")}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(Y,{value:x.bookingUrl,readOnly:!0,className:"text-sm"}),e.jsx(B,{variant:"outline",size:"sm",onClick:g,className:"shrink-0",children:r?e.jsx(yt,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4"})}),e.jsx("a",{href:x.bookingUrl,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(B,{variant:"outline",size:"sm",children:e.jsx(qe,{className:"h-4 w-4"})})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.allowEmployeeSelection")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("appointmentSettings.bookingPortal.allowEmployeeSelectionHelp")})]}),e.jsx(be,{checked:l.allowEmployeeSelection,onCheckedChange:h=>m({allowEmployeeSelection:h})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.requirePhone")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("appointmentSettings.bookingPortal.requirePhoneHelp")})]}),e.jsx(be,{checked:l.requirePhone,onCheckedChange:h=>m({requirePhone:h})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.maxAdvance")}),e.jsx(He,{value:l.bookingAdvanceDays,onCommit:h=>m({bookingAdvanceDays:h}),min:0,max:365,className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:l.bookingAdvanceDays===0?t("appointmentSettings.bookingPortal.maxAdvanceHelpNoLimit"):t("appointmentSettings.bookingPortal.maxAdvanceHelp")})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.leadTime")}
1),e.jsx(He,{value:l.bookingLeadTimeHours,onCommit:h=>m({bookingLeadTimeHours:h}),min:0,max:168,className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.bookingPortal.leadTimeHelp")})]})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.welcomeMessage")}),e.jsx(pt,{defaultValue:l.bookingMessage||"",onBlur:h=>m({bookingMessage:h.target.value||void 0}),placeholder:t("appointmentSettings.bookingPortal.welcomeMessagePlaceholder"),rows:2,className:"mt-1"})]}),e.jsx(kn,{value:l.businessHours,onChange:h=>m({businessHours:h})}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.bookingPortal.defaultMeetingLink")}),e.jsx(Y,{type:"url",defaultValue:l.defaultMeetingLink||"",onBlur:h=>{const T=h.target.value.trim();T!==(l.defaultMeetingLink||"")&&m({defaultMeetingLink:T||null})},placeholder:t("appointmentSettings.bookingPortal.defaultMeetingLinkPlaceholder"),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.bookingPortal.defaultMeetingLinkHelp")})]}),e.jsxs("div",{className:"rounded-lg border bg-gray-50 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Va,{className:"h-4 w-4 text-gray-600"}),e.jsx(L,{className:"text-sm font-semibold",children:t("appointmentSettings.embed.title")})]}),e.jsx("p",{className:"mb-3 text-xs text-gray-500",children:t("appointmentSettings.embed.subtitle")}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-600",children:t("appointmentSettings.embed.iframeLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{readOnly:!0,value:`<iframe src="${window.location.origin}/book/${x.bookingToken}/embed" width="300" height="200" frameborder="0"></iframe>`,className:"font-mono text-xs"}),e.jsx(B,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{navigator.clipboard.writeText(`<iframe src="${window.location.origin}/book/${x.bookingToken}/embed" width="300" height="200" frameborder="0"></iframe>`),S(!0),setTimeout(()=>S(!1),2e3)},children:y?e.jsx(yt,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4"})})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-gray-50 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4 text-gray-600"}),e.jsx(L,{className:"text-sm font-semibold",children:t("appointmentSettings.social.title")})]}),e.jsx("p",{className:"mb-3 text-xs text-gray-500",children:t("appointmentSettings.social.subtitle")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-600",children:t("appointmentSettings.social.linkLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{readOnly:!0,value:`${window.location.origin}/api/booking/og/${x.bookingToken}`,className:"text-sm"}),e.jsx(B,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/api/booking/og/${x.bookingToken}`),f(!0),setTimeout(()=>f(!1),2e3)},children:N?e.jsx(yt,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-400",children:t("appointmentSettings.social.help")})]})]})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.selfService.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.selfService.subtitle")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.selfService.allowCancel")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("appointmentSettings.selfService.allowCancelHelp")})]}),e.jsx(be,{checked:l.allowCustomerCancel,onCheckedChange:h=>m({allowCustomerCancel:h})})]}),l.allowCustomerCancel&&e.jsxs("div",{className:"ml-4 border-l-2 border-gray-200 pl-4",children:[e.jsx(L,{children:t("appointmentSettings.selfService.cancelCutoff")}),e.jsx(He,{value:l.cancelCutoffHours,onCommit:h=>m({cancelCutoffHours:h}),min:0,max:720,className:"mt-1 w-32"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.selfService.cancelCutoffHelp")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.selfService.allowReschedule")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("appointmentSettings.selfService.allowRescheduleHelp")})]}),e.jsx(be,{checked:l.allowCustomerReschedule,onCheckedChange:h=>m({allowCustomerReschedule:h})})]}),l.allowCustomerReschedule&&e.jsxs("div",{className:"ml-4 space-y-3 border-l-2 border-gray-200 pl-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.selfService.rescheduleCutoff")}),e.jsx(He,{value:l.rescheduleCutoffHours,onCommit:h=>m({rescheduleCutoffHours:h}),min:0,max:720,className:"mt-1 w-32"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.selfService.rescheduleCutoffHelp")})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.selfService.maxReschedules")}),e.jsx(He,{value:l.maxReschedules,onCommit:h=>m({maxReschedules:h}),min:0,max:100,className:"mt-1 w-32"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.selfService.maxReschedulesHelp")})]})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.selfService.cancellationPolicy")}),e.jsx(pt,{defaultValue:l.cancellationPolicyText||"",onBlur:h=>m({cancellationPolicyText:h.target.value||void 0}),placeholder:t("appointmentSettings.selfService.cancellationPolicyPlaceholder"),rows:3,className:"mt-1",maxLength:1e3}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("appointmentSettings.selfService.cancellationPolicyHelp")})]})]})]}),e.jsx("div",{className:"border-t pt-6",children:e.jsx(yn,{})}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.reminders.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.reminders.subtitle")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.reminders.enable")}),e.jsx(be,{checked:l.remindersEnabled,onCheckedChange:h=>m({remindersEnabled:h})})]}),l.remindersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.reminders.channel")}),e.jsxs(qt,{value:l.reminderChannels,onValueChange:h=>m({reminderChannels:h}),children:[e.jsx(Kt,{children:e.jsx(_t,{})}),e.jsxs(zt,{children:[e.jsx(ye,{value:"email",children:t("appointmentSettings.channels.email")}),e.jsx(ye,{value:"sms",children:t("appointmentSettings.channels.sms")}),e.jsx(ye,{value:"both",children:t("appointmentSettings.channels.both")})]})]})]}),e.jsx(Cn,{value:l.reminderTimings,onChange:h=>m({reminderTimings:h})})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.followUp.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.followUp.subtitle")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.followUp.enable")}),e.jsx(be,{checked:l.followUpEnabled,onCheckedChange:h=>m({followUpEnabled:h})})]}),l.followUpEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.followUp.channel")}),e.jsxs(qt,{value:l.followUpChannel,onValueChange:h=>m({followUpChannel:h}),children:[e.jsx(Kt,{children:e.jsx(_t,{})}),e.jsxs(zt,{children:[e.jsx(ye,{value:"email",children:t("appointmentSettings.channels.email")}),e.jsx(ye,{value:"sms",children:t("appointmentSettings.channels.sms")}),e.jsx(ye,{value:"both",children:t("appointmentSettings.channels.both")})]})]})]}),e.jsxs("div",{children:[e.jsx(L,{children:t("appointmentSettings.followUp.delay")}),e.jsx(He,{value:l.followUpDelayHours,onCommit:h=>m({followUpDelayHours:h}),min:1})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.followUp.customMessage")}),l.followUpMessage&&e.jsx("button",{type:"button",onClick:()=>m({followUpMessage:null}),className:"text-xs text-blue-600 hover:text-blue-800",children:t("appointmentSettings.useDefault")})]}),e.jsx(pt,{defaultValue:l.followUpMessage||"",onBlur:h=>{const T=h.target.value.trim();T!==(l.followUpMessage||"")&&m({followUpMessage:T||null})},placeholder:t("appointmentSettings.followUp.messagePlaceholder"),rows:3},l.followUpMessage??"__default__"),!l.followUpMessage&&e.jsxs("div",{className:"mt-2 rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-500",children:[e.jsx("p",{className:"mb-1 font-medium text-gray-600",children:t("appointmentSettings.defaultMessageSent")}),e.jsxs("p",{children:["“",t("appointmentSettings.followUp.defaultMessage"),"”"]}
1)]})]})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.noShow.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.noShow.subtitle")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.noShow.enable")}),e.jsx(be,{checked:l.noShowNotificationEnabled,onCheckedChange:h=>m({noShowNotificationEnabled:h})})]}),l.noShowNotificationEnabled&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:t("appointmentSettings.noShow.customMessage")}),l.noShowMessage&&e.jsx("button",{type:"button",onClick:()=>m({noShowMessage:null}),className:"text-xs text-blue-600 hover:text-blue-800",children:t("appointmentSettings.useDefault")})]}),e.jsx(pt,{defaultValue:l.noShowMessage||"",onBlur:h=>{const T=h.target.value.trim();T!==(l.noShowMessage||"")&&m({noShowMessage:T||null})},placeholder:t("appointmentSettings.noShow.messagePlaceholder"),rows:3},l.noShowMessage??"__default__"),!l.noShowMessage&&e.jsxs("div",{className:"mt-2 rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-500",children:[e.jsx("p",{className:"mb-1 font-medium text-gray-600",children:t("appointmentSettings.defaultMessageSent")}),e.jsxs("p",{children:["“",t("appointmentSettings.noShow.defaultMessage"),"”"]})]})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("appointmentSettings.calendar.title")}),e.jsx("p",{className:"mb-4 text-sm text-gray-500",children:t("appointmentSettings.calendar.subtitle")}),e.jsx(jn,{})]}),c.isPending&&e.jsx("p",{className:"text-sm text-blue-600",children:t("appointmentSettings.saving")})]})}const Bt={getStatus:async()=>
1(await le.get("/payment-api-key")).data,generate:async()=>(await le.post("/payment-api-key")).data,revoke:async()=>(await le.delete("/payment-api-key")).data};function Tn({embedded:t=!1}={}){var ze;const{t:a}=Z("settings"),d=on(),r=Te(),p=se(n=>n.currentOrganizationId),[y,S]=u.useState(!1),[N,f]=u.useState(null),[l,k]=u.useState(!1),[x,c]=u.useState(null),m=u.useRef(null),{data:g}=_({queryKey:["settings",p],queryFn:U.getSettings,enabled:!!p,staleTime:300*1e3}),h=(g==null?void 0:g.onlinePaymentsEnabled)??!1,T=(g==null?void 0:g.offerAch)??!0,C=(g==null?void 0:g.cardSurchargeEnabled)??!1,j=(g==null?void 0:g.cardSurchargePercent)??0,q=(g==null?void 0:g.requestTipsDefault)??!0,$=(g==null?void 0:g.tipBasis)??"POST_DISCOUNT",oe=(g==null?void 0:g.allowPartialPayment)??!1,W=(()=>{const n="https://api.bizvanguard.ai/api";return/^https?:\/\//.test(n)?n.replace(/\/+$/,""):`${window.location.origin}/api`})(),M=`${W}/payments/public/pay`,G=`/docs/payment-api.html?api=${encodeURIComponent(W)}`,[Ee,ae]=u.useState("");u.useEffect(()=>{ae(String(j))},[j]);const De=D({mutationFn:n=>U.updateSettings({onlinePaymentsEnabled:n}),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),w=D({mutationFn:n=>U.updateSettings({offerAch:n}),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),J=D({mutationFn:n=>U.updateSettings(n),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),Ae=D({mutationFn:n=>U.updateSettings({requestTipsDefault:n}),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),Ve=D({mutationFn:n=>U.updateSettings({tipBasis:n}),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),ve=D({mutationFn:n=>U.updateSettings({allowPartialPayment:n}),onSuccess:n=>{f(null),r.setQueryData(["settings",p],n)},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.toggleFailed"))}}),{data:O,isLoading:Ke}=_({queryKey:["payment-api-key",p],queryFn:Bt.getStatus,enabled:!!p,staleTime:300*1e3}),[A,de]=u.useState(null),[kt,ce]=u.useState(!1),[Xe,ke]=u.useState(!1),F=u.useRef(null);u.useEffect(()=>()=>{F.current&&clearTimeout(F.current),de(null)},[]);const je=D({mutationFn:Bt.generate,onSuccess:n=>{f(null),de(n.apiKey),ce(!1),ke(!1),r.invalidateQueries({queryKey:["payment-api-key",p]})},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.generateFailed"))}}),_e=D({mutationFn:Bt.revoke,onSuccess:()=>{f(null),de(null),r.invalidateQueries({queryKey:["payment-api-key",p]})},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.revokeFailed"))}}),Me=async()=>{if(A)try{await navigator.clipboard.writeText(A),ke(!1),ce(!0),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>ce(!1),2e3)}catch{ke(!0)}},Ze=()=>{O!=null&&O.exists&&!window.confirm(a("paymentSettings.confirm.rotate"))||je.mutate()},{data:v,isLoading:Je,isFetching:Ne,refetch:et}=_({queryKey:["stripe-connect-status",p],queryFn:Ge.getStatus,enabled:!!p,staleTime:30*1e3,refetchInterval:n=>{var P;const E=(P=n.state.data)==null?void 0:P.status;return y||E==="in_review"||E==="restricted"?8e3:!1}
1,refetchIntervalInBackground:!0});u.useEffect(()=>{const n=v==null?void 0:v.status;y&&n&&n!=="pending"&&S(!1)},[v==null?void 0:v.status,y]);const{data:me}=_({queryKey:["subscription",p],queryFn:$t.getSubscription,enabled:!!p,staleTime:300*1e3}),ue=((ze=me==null?void 0:me.plan)==null?void 0:ze.tier)==="FREE"&&!(v!=null&&v.accountId),re=D({mutationFn:async()=>(v!=null&&v.paymentTermsAccepted||await Ge.acceptPaymentTerms(),Ge.startOnboarding()),onSuccess:n=>{f(null),c(n.onboardingUrl),m.current&&!m.current.closed&&(m.current.location.href=n.onboardingUrl),m.current=null,S(!0)},onError:n=>{var P,ee;m.current&&!m.current.closed&&m.current.close(),m.current=null;const E=((ee=(P=n==null?void 0:n.response)==null?void 0:P.data)==null?void 0:ee.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.setupFailed");f(E)}}),Q=D({mutationFn:Ge.getDashboardLink,onSuccess:n=>{window.open(n.url,"_blank")},onError:n=>{var P,ee;const E=((ee=(P=n==null?void 0:n.response)==null?void 0:P.data)==null?void 0:ee.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.dashboardFailed");f(E)}}),Se=D({mutationFn:Ge.acceptPaymentTerms,onSuccess:()=>{f(null),et()},onError:n=>{var E,P;f(((P=(E=n==null?void 0:n.response)==null?void 0:E.data)==null?void 0:P.message)||(n==null?void 0:n.message)||a("paymentSettings.toast.acceptTermsFailed"))}}),tt=()=>et(),Le=()=>{f(null),m.current=window.open("about:blank","_blank"),m.current&&m.current.document.write('
1<!doctype html><meta charset="utf-8"><title>Connecting to Stripe…</title><body style="font-family:system-ui,-apple-system,sans-serif;color:#374151;display:flex;align-items:center;justify-content:center;height:100vh;margin:0"><div style="text-align:center"><div style="font-size:18px;font-weight:600">Connecting you to Stripe…</div><div style="color:#6b7280;margin-top:8px">This will just take a moment.</div></div></body>'),re.mutate()};if(Je)return e.jsx("div",{className:t?"":"p-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-48 mb-4"}),e.jsx("div",{className:"h-32 bg-gray-200 rounded"})]})});if(!(v!=null&&v.isOnboarded)){const n=(v==null?void 0:v.status)==="in_review",E=(v==null?void 0:v.status)==="restricted",P=(v==null?void 0:v.status)==="rejected";return e.jsxs("div",{className:t?"max-w-2xl":"p-6 max-w-2xl",children:[!t&&e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:a("paymentSettings.title")}),e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(zs,{className:"h-8 w-8 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:a("paymentSettings.setup.heading")}),e.jsx("p",{className:"text-gray-600 mt-1",children:a("paymentSettings.setup.intro")}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(Be,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{children:a("paymentSettings.setup.benefit1")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(Be,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{children:a("paymentSettings.setup.benefit2")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(Be,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{children:a("paymentSettings.setup.benefit3")})]})]}),ue&&e.jsxs("div",{className:"mt-4 rounded-lg border border-amber-200 bg-amber-50 p-4",children:[e.jsx("p",{className:"font-medium text-amber-900",children:a("paymentSettings.setup.upgradeTitle")}),e.jsx("p",{className:"mt-1 text-sm text-amber-800",children:a("paymentSettings.setup.upgradeBody")}),e.jsx(cn,{to:"/dashboard/billing",className:"mt-3 inline-flex items-center gap-2 rounded-lg bg-amber-600 px-4 py-2 font-medium text-white transition-colors hover:bg-amber-700",children:a("paymentSettings.setup.upgradeCta")})]}),e.jsx("div",{className:"mt-4 p-3 bg-gray-50 border border-gray-200 rounded-lg",children:e.jsxs("p",{className:"text-sm text-gray-700",children:[e.jsx("span",{className:"font-medium",children:a("paymentSettings.fees.label")})," ",a("paymentSettings.fees.detail")]})}),e.jsxs("div",{className:"mt-3 p-4 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("paymentSettings.responsibilities.heading")}),e.jsx("p",{className:"mt-1 text-sm text-amber-800",children:a("paymentSettings.responsibilities.intro")}),e.jsxs("ul",{className:"mt-2 space-y-1.5 text-sm text-amber-800",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"•"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:a("paymentSettings.responsibilities.feesLabel")})," ",a("paymentSettings.responsibilities.feesDetail")]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"•"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:a("paymentSettings.responsibilities.disputesLabel")})," ",a("paymentSettings.responsibilities.disputesDetail",{brandName:dn.name})]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"•"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:a("paymentSettings.responsibilities.taxLabel")})," ",a("paymentSettings.responsibilities.taxDetail")]})]})]})]}),!y&&!n&&!E&&!P&&e.jsxs("div",{className:"mt-5 border-t border-gray-100 pt-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:a("paymentSettings.howSetupWorks.heading")}),e.jsxs("ol",{className:"mt-2 space-y-1.5 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"1."}),e.jsx("span",{children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.howSetupWorks.step1",children:["Click ",e.jsx("span",{className:"font-medium",children:"Set Up Payments"})," — a secure Stripe window opens in a new tab."]})})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"2."}),e.jsx("span",{children:a("paymentSettings.howSetupWorks.step2")})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"3."}),e.jsx("span",{children:a("paymentSettings.howSetupWorks.step3")})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"4."}),e.jsx("span",{children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.howSetupWorks.step4",children:["Come back to this tab — it updates on its own when Stripe is done. You can also click ",e.jsx("span",{className:"font-medium",children:"Check now"}),"."]})})]})]}),e.jsx("h3",{className:"mt-4 text-sm font-semibold text-gray-900",children:a("paymentSettings.whatYouNeed.heading")}),e.jsx("ul",{className:"mt-2 grid gap-1.5 text-sm text-gray-600 sm:grid-cols-2",children:["businessName","ein","bankAccount","photoId"].map(ee=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 flex-shrink-0 text-green-500"}),e.jsx("span",{children:a(`paymentSettings.whatYouNeed.${ee}`)})]},ee))}),e.jsx("p",{className:"mt-3 text-xs text-gray-500",children:a("paymentSettings.whatYouNeed.note")}),e.jsxs("a",{href:"/docs/stripe-setup-guide.html",target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-flex w-fit items-center gap-1.5 text-sm font-medium text-blue-600 hover:text-blue-700",children:[e.jsx(qe,{className:"h-4 w-4"}),a("paymentSettings.setupGuideLink")]})]}),y||n?e.jsxs("div",{className:"mt-6 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center gap-2 text-yellow-800",children:[e.jsx(It,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:a(n&&!y?"paymentSettings.review.heading":"paymentSettings.onboarding.heading")})]}),e.jsx("p",{className:"text-sm text-yellow-700 mt-1",children:a(n&&!y?"paymentSettings.review.description":"paymentSettings.onboarding.description")}),e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{onClick:tt,disabled:Ne,className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-600 text-white rounded-lg hover:bg-yellow-700 transition-colors disabled:opacity-60",children:[e.jsx(Qe,{className:`h-4 w-4 ${Ne?"animate-spin":""}`}),a(Ne?"paymentSettings.onboarding.checking":"paymentSettings.onboarding.checkNow")]}),e.jsx("span",{className:"text-xs text-yellow-700",children:a("paymentSettings.onboarding.autoChecks")})]}),y&&x&&e.jsx("p",{className:"mt-2 text-xs text-yellow-700",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.onboarding.popupFallback",children:["Didn't see the Stripe window? ",e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"font-medium underline",children:"Open it here"}),"."]})})]}):P?e.jsxs("div",{className:"mt-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-800",children:[e.jsx(Ft,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:a("paymentSettings.rejected.heading")})]}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:a("paymentSettings.rejected.description")})]}):E?e.jsxs("div",{className:"mt-6 p-4 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-800",children:[e.jsx(It,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:a("paymentSettings.restricted.heading")})]}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:a("paymentSettings.restricted.description")}),e.jsxs("button",{onClick:Le,disabled:re.isPending,className:"mt-3 inline-flex items-center gap-2 px-4 py-2 bg-amber-600 text-white rounded-lg hover:bg-amber-700 transition-colors disabled:opacity-50",children:[re.isPending?e.jsx(Qe,{className:"h-4 w-4 animate-spin"}):e.jsx(qe,{className:"h-4 w-4"}),a("paymentSettings.restricted.continueButton")]})]}):e.jsxs(e.Fragment,{children:[!(v!=null&&v.paymentTermsAccepted)&&e.jsxs("label",{className:"mt-6 flex items-start gap-2 text-sm text-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:ee=>k(ee.target.checked),className:"mt-0.5 rounded border-gray-300"}),e.jsx("span",{children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.termsCheckbox.label",children:["I have read and agree to the ",e.jsx("a",{href:"/legal/payment-terms",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-blue-600 hover:underline",children:"Payment Processing Terms"}),", I accept responsibility for fees, refunds, chargebacks, and any negative balance on my account, and I certify my business does not engage in any ",e.jsx("a",{href:"https://stripe.com/restricted-businesses",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-blue-600 hover:underline",children:"prohibited or restricted business"}),"."]})})]}),e.jsx("button",{onClick:Le,disabled:ue||re.isPending||!(v!=null&&v.paymentTermsAccepted)&&!l,className:"mt-4 inline-flex items-center gap-2 px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:re.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"h-5 w-5 animate-spin"}),a("paymentSettings.setup.settingUp")]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"h-5 w-5"}),(v==null?void 0:v.status)==="pending"?a("paymentSettings.setup.continueButton"):a("paymentSettings.setup.setUpButton")]})})]}),N&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ft,{className:"h-5 w-5 text-red-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800",children:a("paymentSettings.error.setupFailedTitle")}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:N}),e.jsx("p",{className:"text-xs text-red-600 mt-2",children:a("paymentSettings.error.contactSupport")})]})]})}),!y&&(v==null?void 0:v.status)==="pending"&&e.jsx("p",{className:"mt-4 text-sm text-orange-600",children:a("paymentSettings.setup.incomplete")}
1)]})]})})]})}return e.jsxs("div",{className:t?"max-w-2xl":"p-6 max-w-2xl",children:[!t&&e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:a("paymentSettings.title")}),N&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ft,{className:"h-5 w-5 text-red-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700",children:N})]})}),v&&!v.paymentTermsAccepted&&e.jsx("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-200 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(It,{className:"h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("paymentSettings.updatedTerms.heading")}),e.jsx("p",{className:"text-sm text-amber-800 mt-1",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.updatedTerms.description",children:["We’ve updated our terms. Please review and accept to keep accepting payments. ",e.jsx("a",{href:"/legal/payment-terms",target:"_blank",rel:"noopener noreferrer",className:"font-medium underline",children:"Review the Payment Processing Terms"}),"."]})}),e.jsx("button",{onClick:()=>Se.mutate(),disabled:Se.isPending,className:"mt-3 inline-flex items-center gap-2 px-4 py-2 bg-amber-600 text-white text-sm font-medium rounded-lg hover:bg-amber-700 transition-colors disabled:opacity-50",children:Se.isPending?a("paymentSettings.updatedTerms.saving"):a("paymentSettings.updatedTerms.agreeButton")})]})]})}),e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(Be,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:a("paymentSettings.enabled.heading")}),e.jsx("p",{className:"text-gray-600 mt-1",children:a("paymentSettings.enabled.description")}),e.jsx("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:a("paymentSettings.enabled.payouts")}),e.jsxs("div",{className:"font-medium text-gray-900 flex items-center gap-1",children:[e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${v.payoutsEnabled?"bg-green-500":"bg-yellow-500"}`}),v.payoutsEnabled?a("paymentSettings.status.active"):a("paymentSettings.status.pendingVerification")]})]}),v.onboardedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:a("paymentSettings.enabled.connectedSince")}),e.jsx("div",{className:"font-medium text-gray-900",children:new Date(v.onboardedAt).toLocaleDateString(void 0,{timeZone:d})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:a("paymentSettings.enabled.bankTransfer")}),e.jsxs("div",{className:"font-medium text-gray-900 flex items-center gap-1",children:[e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${v.achEnabled?"bg-green-500":"bg-gray-300"}`}),v.achEnabled?a("paymentSettings.status.active"):a("paymentSettings.status.pendingVerification")]})]})]})}),e.jsx("div",{className:"mt-6 flex gap-3",children:e.jsxs("button",{onClick:()=>Q.mutate(),disabled:Q.isPending,className:"inline-flex items-center gap-2 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors",children:[e.jsx(qe,{className:"h-4 w-4"}),a("paymentSettings.enabled.viewDashboard")]})}),!v.payoutsEnabled&&e.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:e.jsx("p",{className:"text-sm text-yellow-800",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.enabled.verificationPending",children:[e.jsx("strong",{children:"Verification pending:"})," Stripe may need additional information before payouts can be enabled. Check your Stripe dashboard for details."]})})})]})]})}),e.jsxs("div",{className:"mt-6 bg-white rounded-lg border border-gray-200 p-6",children:[e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:h,disabled:De.isPending,onChange:n=>
1De.mutate(n.target.checked),className:"h-4 w-4 rounded border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.toggle.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.toggle.description")})]})]}),h&&e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer mt-4 pt-4 border-t border-gray-100 ml-7",children:[e.jsx("input",{type:"checkbox",checked:T,disabled:w.isPending,onChange:n=>w.mutate(n.target.checked),className:"h-4 w-4 rounded border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.offerAch.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.offerAch.description")}),e.jsx("p",{className:"text-xs text-gray-500 mt-2 bg-blue-50 border border-blue-100 rounded-md px-3 py-2",children:a("paymentSettings.offerAch.settlementNote")})]})]}),h&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100 ml-7",children:[e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C,disabled:J.isPending,onChange:n=>J.mutate({cardSurchargeEnabled:n.target.checked,cardSurchargePercent:n.target.checked&&!j?3:j||void 0}),className:"h-4 w-4 rounded border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.cardSurcharge.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.cardSurcharge.description")})]})]}),C&&e.jsxs("div",{className:"mt-3 ml-7",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a("paymentSettings.cardSurcharge.percentLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:0,max:3,step:.1,value:Ee,disabled:J.isPending,onChange:n=>ae(n.target.value),onBlur:()=>{const n=Math.min(Math.max(Number(Ee)||0,0),3);ae(String(n)),n!==j&&J.mutate({cardSurchargePercent:n})},className:"w-24 rounded-md border border-gray-300 px-3 py-2 text-sm disabled:opacity-50"}),e.jsx("span",{className:"text-sm text-gray-500",children:"%"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("paymentSettings.cardSurcharge.percentHelp")}),e.jsx("p",{className:"text-xs text-amber-800 mt-2 bg-amber-50 border border-amber-100 rounded-md px-3 py-2",children:a("paymentSettings.cardSurcharge.complianceNote")})]})]}),h&&e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer mt-4 pt-4 border-t border-gray-100 ml-7",children:[e.jsx("input",{type:"checkbox",checked:q,disabled:Ae.isPending,onChange:n=>Ae.mutate(n.target.checked),className:"h-4 w-4 rounded border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.requestTips.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.requestTips.description")}),e.jsx("p",{className:"text-xs text-gray-500 mt-2 bg-blue-50 border border-blue-100 rounded-md px-3 py-2",children:a("paymentSettings.requestTips.note")})]})]}),h&&q&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100 ml-14",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.tipBasis.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.tipBasis.description")}),e.jsx("div",{className:"mt-3 space-y-2",children:["PRE_DISCOUNT","POST_DISCOUNT"].map(n=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"tipBasis",value:n,checked:$===n,disabled:Ve.isPending,onChange:()=>Ve.mutate(n),className:"h-4 w-4 border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsx("span",{className:"text-sm text-gray-900",children:a(n==="PRE_DISCOUNT"?"paymentSettings.tipBasis.preDiscount":"paymentSettings.tipBasis.postDiscount")})]},n))}),e.jsx("p",{className:"text-xs text-gray-500 mt-2 bg-blue-50 border border-blue-100 rounded-md px-3 py-2",children:a("paymentSettings.tipBasis.note")})]}),h&&e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer mt-4 pt-4 border-t border-gray-100 ml-7",children:[e.jsx("input",{type:"checkbox",checked:oe,disabled:ve.isPending,onChange:n=>
1ve.mutate(n.target.checked),className:"h-4 w-4 rounded border-gray-300 mt-0.5 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a("paymentSettings.allowPartialPayment.label")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:a("paymentSettings.allowPartialPayment.description")}),e.jsx("p",{className:"text-xs text-gray-500 mt-2 bg-blue-50 border border-blue-100 rounded-md px-3 py-2",children:a("paymentSettings.allowPartialPayment.note")})]})]})]}),e.jsx("div",{className:"mt-6 bg-white rounded-lg border border-gray-200 p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:e.jsx(Za,{className:"h-5 w-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:a("paymentSettings.apiKey.heading")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.apiKey.description",children:["Use this key on your own website to let customers pay for catering orders online. Your site sends it as an ",e.jsx("code",{className:"text-xs",children:"x-api-key"})," header — keep it on your server, never in browser code."]})}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsxs("a",{href:G,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm font-medium text-blue-600 hover:text-blue-700 w-fit",children:[e.jsx(qe,{className:"h-4 w-4"}),a("paymentSettings.apiKey.guideLink")]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[a("paymentSettings.apiKey.endpointLabel")," ",e.jsx("code",{className:"text-xs break-all",children:M})]})]}),A?e.jsxs("div",{className:"mt-4 p-3 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("paymentSettings.apiKey.copyNow")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-white border border-amber-200 rounded text-xs break-all",children:A}),e.jsxs("button",{onClick:Me,"aria-label":a("paymentSettings.apiKey.copyAriaLabel"),className:"inline-flex items-center gap-1 px-3 py-2 bg-amber-600 text-white text-sm rounded-lg hover:bg-amber-700 transition-colors",children:[e.jsx(jt,{className:"h-4 w-4"}),e.jsx("span",{"aria-live":"polite",children:a(kt?"paymentSettings.apiKey.copied":"paymentSettings.apiKey.copy")})]})]}),Xe&&e.jsx("p",{className:"mt-2 text-xs text-amber-800",role:"alert",children:a("paymentSettings.apiKey.copyFailed")})]}):e.jsx("div",{className:"mt-3 text-sm text-gray-600",children:Ke?e.jsx("span",{className:"text-gray-400",children:a("paymentSettings.apiKey.loading")}):O!=null&&O.exists?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[e.jsxs("span",{children:[a("paymentSettings.apiKey.keyLabel")," ",e.jsxs("code",{className:"text-xs",children:[O.prefix,"…"]})]}),O.createdAt&&e.jsx("span",{className:"text-gray-500",children:a("paymentSettings.apiKey.created",{date:new Date(O.createdAt).toLocaleDateString(void 0,{timeZone:d})})}),e.jsx("span",{className:"text-gray-500",children:O.lastUsedAt?a("paymentSettings.apiKey.lastUsed",{date:new Date(O.lastUsedAt).toLocaleDateString(void 0,{timeZone:d})}):a("paymentSettings.apiKey.notUsed")})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:a("paymentSettings.apiKey.showOnceHint")})]}):e.jsx("span",{className:"text-gray-500",children:a("paymentSettings.apiKey.none")})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsxs("button",{onClick:Ze,disabled:je.isPending||Ke,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:[e.jsx(Qe,{className:`h-4 w-4 ${je.isPending?"animate-spin":""}`}),O!=null&&O.exists?a("paymentSettings.apiKey.rotateButton"):a("paymentSettings.apiKey.generateButton")]}),(O==null?void 0:O.exists)&&e.jsxs("button",{onClick:()=>{window.confirm(a("paymentSettings.confirm.revoke"))&&_e.mutate()},disabled:_e.isPending,className:"inline-flex items-center gap-2 px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition-colors disabled:opacity-50",children:[e.jsx(Wt,{className:"h-4 w-4"}),a("paymentSettings.apiKey.revokeButton")]})]}),(O==null?void 0:O.exists)&&e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:a("paymentSettings.apiKey.rotateNote")})]})]})}),e.jsxs("div",{className:"mt-6 bg-white rounded-lg border border-gray-200 p-6",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:a("paymentSettings.howItWorks.heading")}),e.jsxs("ol",{className:"space-y-2 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"1."}),a("paymentSettings.howItWorks.step1")]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"2."}),a("paymentSettings.howItWorks.step2")]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"3."}),a("paymentSettings.howItWorks.step3")]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"4."}),a("paymentSettings.howItWorks.step4")]})]})]}),e.jsxs("div",{className:"mt-6 bg-white rounded-lg border border-gray-200 p-6",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:a("paymentSettings.processingFees.heading")}),e.jsx("p",{className:"text-sm text-gray-600",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.processingFees.detail",children:[e.jsx("span",{className:"font-semibold text-gray-900",children:"2.9% + $0.30"})," per successful transaction. Fees are automatically deducted from each payment before funds are deposited to your account."]})}),e.jsx("div",{className:"mt-3 p-3 bg-blue-50 rounded-lg",children:e.jsx("p",{className:"text-sm text-blue-800",children:e.jsxs(he,{t:a,i18nKey:"paymentSettings.processingFees.example",children:[e.jsx("span",{className:"font-medium",children:"Example:"})," For a $100 payment, the fee is $3.20 ($100 × 2.9% + $0.30). You receive $96.80."]})})})]})]})}const En={AL:"America/Chicago",AK:"America/Anchorage",AZ:"America/Phoenix",AR:"America/Chicago",CA:"America/Los_Angeles",CO:"America/Denver",CT:"America/Ne
1w_York",DE:"America/New_York",DC:"America/New_York",FL:"America/New_York",GA:"America/New_York",HI:"Pacific/Honolulu",ID:"America/Denver",IL:"America/Chicago",IN:"America/New_York",IA:"America/Chicago",KS:"America/Chicago",KY:"America/New_York",LA:"America/Chicago",ME:"America/New_York",MD:"America/New_York",MA:"America/New_York",MI:"America/New_York",MN:"America/Chicago",MS:"America/Chicago",MO:"America/Chicago",MT:"America/Denver",NE:"America/Chicago",NV:"America/Los_Angeles",NH:"America/New_York",NJ:"America/New_York",NM:"America/Denver",NY:"America/New_York",NC:"America/New_York",ND:"America/Chicago",OH:"America/New_York",OK:"America/Chicago",OR:"America/Los_Angeles",PA:"America/New_York",RI:"America/New_York",SC:"America/New_York",SD:"America/Chicago",TN:"America/Chicago",TX:"America/Chicago",UT:"America/Denver",VT:"America/New_York",VA:"America/New_York",WA:"America/Los_Angeles",WV:"America/New_York",WI:"America/Chicago",WY:"America/Denver"};function Zs(t){return En[t]??""}const Vs=t=>({profile:t("tabs.profile"),payroll:t("tabs.payroll"),timeclock:t("tabs.timeclock"),invoicing:t("tabs.invoicing"),payments:t("tabs.payments"),positions:t("tabs.positions"),notifications:t("tabs.notifications"),appointments:t("tabs.appointments"),features:t("tabs.features")}),Dn={CA:{disallowed:["MONTHLY"],note:"CA Labor Code §204 requires at least semi-monthly pay for non-exempt employees."},AZ:{disallowed:["MONTHLY"],note:"AZ Rev. Stat. §23-351 requires paydays no more than 16 days apart."}},An=!1;function ki(){var os,ds,cs,ms,us,xs,ps,gs,hs,bs,fs,ys,js,Ns,vs,ks,Ss,ws,Cs,Ps,Ts,Es,Ds,As,Ms,Ls,Rs,Os,Is,Fs,Hs,Bs,Us,qs;const{t}=Z("settings"),[a,d]=mn(),r=a.get("tab")||"profile",{hasPermission:p}=un(),y=p("MANAGE_BILLING"),S=s=>{d({tab:s})},{enabledModules:N}=se(),f=N.includes("customer_appointments"),[l,k]=u.useState([]),[x,c]=u.useState(""),[m,g]=u.useState(""),[h,T]=u.useState(0),[C,j]=u.useState(!1),[q,$]=u.useState(""),[oe,W]=u.useState(!1),[M,G]=u.useState(null),[Ee,ae]=u.useState(!1),[De,w]=u.useState(!1),[J,Ae]=u.useState(null),[Ve,ve]=u.useState(!1),[O,Ke]=u.useState(null),[A,de]=u.useState({enabled:!1,notifications:{onboarding:!0,documentSigning:!0,wageReceipts:!0,breakReminders:!0,clockReminders:!0},reminderSettings:{takeBreak:{enabled:!1,thresholdMinutes:240},clockOut:{enabled:!1,thresholdMinutes:450},endBreak:{enabled:!1,thresholdMinutes:35}}}),[kt,ce]=u.useState(!1),[Xe,ke]=u.useState(""),[F,je]=u.useState({email:"",phone:"",website:"",address:"",city:"",state:"",zipCode:"",country:"US",taxId:"",statePayrollTaxNumber:"",salesTaxRate:"",employerLegalName:"",socialLinks:{}}),[_e,Me]=u.useState(!1),[Ze,v]=u.useState(""),[Je,Ne]=u.useState(!1),[et,me]=u.useState(!1),[ue,re]=u.useState(null),[Q,Se]=u.useState({invoicePrefix:"INV",invoiceIncludeYear:!0,invoiceNextNumber:1,invoiceSeparator:"-",billPrefix:"BILL",billNextNumber:1}),[tt,Le]=u.useState(!1),[ze,n]=u.useState(""),[E,P]=u.useState({defaultInvitationRole:"ACCOUNTANT",defaultInvitationApprovalMode:"IMMEDIATE"}),[ee,St]=u.useState(!1),[Gt,wt]=u.useState(""),[H,xe]=u.useState({requirePhotoOnClock:"OFF",companyCode:"",clockInGracePeriodMinutes:0,clockOutGracePeriodMinutes:0,autoClockOutEnabled:!1,autoClockOutGracePeriodMinutes:30,autoClockOutMaxShiftHours:12}),[Js,pe]=u.useState(!1),[Qt,st]=u.useState(""),[ne,Ct]=u.useState(Ba),[ea,Pt]=u.useState(!1),[Vt,Xt]=u.useState(""),[Zt,Tt]=u.useState(14),[Jt,Et]=u.useState(!1),[ta,at]=u.useState(!1),[es,ts]=u.useState(""),[Re,Dt]=u.useState({autoSendTimesheetReviews:!1,timesheetReviewDelayHours:6,timesheetReviewExpirationDays:2}),[sa,At]=u.useState(!1),[ss,Mt]=u.useState(""),K=Te(),I=se(s=>s.currentOrganizationId),{data:i,isLoading:aa}=_({queryKey:["settings",I],queryFn:U.getSettings,staleTime:300*1e3,gcTime:1200*1e3,enabled:!!I}),{data:as=[]}=_({queryKey:["positions",I],queryFn:Ue.getAll,staleTime:300*1e3,gcTime:1200*1e3,enabled:!!I}),{data:$e}=_({queryKey:["position-suggestions",I],queryFn:Ue.getSuggestions,staleTime:300*1e3,enabled:!!I&&r==="positions"}),{data:ns=[]}=_({queryKey:["organizations"],queryFn:Nt.getAll,staleTime:300*1e3,gcTime:1200*1e3}),{data:V}=_({queryKey:["reminderSettings",I],queryFn:Ws.getSettings,staleTime:300*1e3,gcTime:1200*1e3,enabled:!!I}),{data:Lt}=_({queryKey:["billingUsage",I],queryFn:$t.getUsage,staleTime:120*1e3,gcTime:600*1e3,enabled:!!I}),te=(os=Lt==null?void 0:Lt.metrics)==null?void 0:os.find(s=>s.metricType==="SMS_SENT"),is=D({mutationFn:Ue.delete,onSuccess:()=>{K.invalidateQueries({queryKey:["positions",I]})}}),nt=D({mutationFn:Ue.bulkCreate,onSuccess:()=>{K.invalidateQueries({queryKey:["positions",I]}),K.invalidateQueries({queryKey:["position-suggestions",I]})}});u.useEffect(()=>
1{i&&(k(i.defaultBreaks||[]),c(i.payrollPeriodType||"BI_WEEKLY"),g(i.payrollScheduleStartDate?i.payrollScheduleStartDate.split("T")[0]:""),T(i.workweekStartDay??0),i.employeePortalConfig&&Ct(i.employeePortalConfig),Tt(i.refundWindowDays??14),Et(i.depositsRefundable??!1),je({email:i.email||"",phone:i.phone||"",website:i.website||"",address:i.address||"",city:i.city||"",state:i.state||"",zipCode:i.zipCode||"",country:i.country||"US",taxId:i.taxId||"",statePayrollTaxNumber:i.statePayrollTaxNumber||"",salesTaxRate:i.salesTaxRate??"",employerLegalName:i.employerLegalName||"",socialLinks:i.socialLinks||{}}),Se({invoicePrefix:i.invoicePrefix||"INV",invoiceIncludeYear:i.invoiceIncludeYear??!0,invoiceNextNumber:i.invoiceNextNumber||1,invoiceSeparator:i.invoiceSeparator||"-",billPrefix:i.billPrefix||"BILL",billNextNumber:i.billNextNumber||1}),P({defaultInvitationRole:i.defaultInvitationRole||"ACCOUNTANT",defaultInvitationApprovalMode:i.defaultInvitationApprovalMode||"IMMEDIATE"}),xe({requirePhotoOnClock:i.requirePhotoOnClock||"OFF",companyCode:i.emailInboxSlug||"",clockInGracePeriodMinutes:i.clockInGracePeriodMinutes||0,clockOutGracePeriodMinutes:i.clockOutGracePeriodMinutes||0,autoClockOutEnabled:i.autoClockOutEnabled??!1,autoClockOutGracePeriodMinutes:i.autoClockOutGracePeriodMinutes??30,autoClockOutMaxShiftHours:i.autoClockOutMaxShiftHours??12}),Dt({autoSendTimesheetReviews:i.autoSendTimesheetReviews??!1,timesheetReviewDelayHours:i.timesheetReviewDelayHours??6,timesheetReviewExpirationDays:i.timesheetReviewExpirationDays??2}),me(!1))},[i]),u.useEffect(()=>{let s=null;return i!=null&&i.logoUrl&&I?(async()=>{try{const b=sessionStorage.getItem("accessToken"),R=await fetch(`https://api.bizvanguard.ai/api/organizations/${I}/logo`,{headers:{Authorization:`Bearer ${b}`}});if(R.ok){const z=await R.blob();s=URL.createObjectURL(z),re(s),me(!1)}else me(!0)}catch(b){console.error("Failed to fetch logo:",b),me(!0)}})():re(null),()=>{s&&URL.revokeObjectURL(s)}},[i==null?void 0:i.logoUrl,I]),u.useEffect(()=>{var s,o,b;V&&de({enabled:V.enabled||!1,notifications:V.notifications||{onboarding:!0,documentSigning:!0,wageReceipts:!0,breakReminders:!0,clockReminders:!0},reminderSettings:{takeBreak:((s=V.reminderSettings)==null?void 0:s.takeBreak)||{enabled:!1,thresholdMinutes:240},clockOut:((o=V.reminderSettings)==null?void 0:o.clockOut)||{enabled:!1,thresholdMinutes:450},endBreak:((b=V.reminderSettings)==null?void 0:b.endBreak)||{enabled:!1,thresholdMinutes:35}}})},[V]);const it=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),j(!1),$(""),window.dispatchEvent(new Event("organization-updated"))},onError:s=>{var o,b;$(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update settings")}}),rt=D({mutationFn:s=>Ws.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["reminderSettings"]}),ce(!1),ke("")},onError:s=>{var o,b;ke(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update SMS settings")}}),na=()=>{k([...l,{start:"14:30",end:"16:30"}]),j(!0)},ia=s=>{k(l.filter((o,b)=>b!==s)),j(!0)},rs=(s,o,b)=>{const R=[...l];R[s][o]=b,k(R),j(!0)},ra=()=>{for(const s of l)if(s.start>=s.end){$("Break end time must be after start time");return}it.mutate({defaultBreaks:l,payrollPeriodType:x,payrollScheduleStartDate:m||void 0,workweekStartDay:h})},la=()=>{k((i==null?void 0:i.defaultBreaks)||[]),c((i==null?void 0:i.payrollPeriodType)||"BI_WEEKLY"),g(i!=null&&i.payrollScheduleStartDate?i.payrollScheduleStartDate.split("T")[0]:""),T((i==null?void 0:i.workweekStartDay)??0),j(!1),$("")},oa=()=>{G(null),W(!0)},da=s=>{G(s),W(!0)},ca=async s=>{window.confirm(`Delete position "${s.name}"? This action cannot be undone.`)&&await is.mutateAsync(s.id)},ma=(s,o)=>{de({...A,[s]:o}),ce(!0)},Ye=(s,o)=>{const b=A.notifications||{onboarding:!0,documentSigning:!0,wageReceipts:!0,breakReminders:!0,clockReminders:!0};de({...A,notifications:{...b,[s]:o}}),ce(!0)},Oe=(s,o,b)=>{var R;de({...A,reminderSettings:{...A.reminderSettings,[s]:{...(R=A.reminderSettings)==null?void 0:R[s],[o]:b}}}),ce(!0)},ua=()=>{rt.mutate(A)},xa=()=>{var s,o,b;V&&de({enabled:V.enabled||!1,notifications:V.notifications||{onboarding:!0,documentSigning:!0,wageReceipts:!0,breakReminders:!0,clockReminders:!0},reminderSettings:{takeBreak:((s=V.reminderSettings)==null?void 0:s.takeBreak)||{enabled:!1,thresholdMinutes:240},clockOut:((o=V.reminderSettings)==null?void 0:o.clockOut)||{enabled:!1,thresholdMinutes:450},endBreak:((b=V.reminderSettings)==null?void 0:b.endBreak)||{enabled:!1,thresholdMinutes:35}}}),ce(!1),ke("")},lt=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),Me(!1),v(""),window.dispatchEvent(new Event("organization-updated"))},onError:s=>{var o,b;v(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update business profile")}}),ie=(s,o)=>{je({...F,[s]:o}),Me(!0)},pa=(s,o)=>{je({...F,socialLinks:{...F.socialLinks,[s]:o}}),Me(!0)},ga=s=>
1{const o=(i==null?void 0:i.name)||"",b=[F.city,F.state].filter(Boolean).join(", "),R=`${o} ${b}`.trim();return s==="google"?`https://www.google.com/maps/search/${encodeURIComponent(R)}`:s==="yelp"?`https://www.yelp.com/search?find_desc=${encodeURIComponent(o)}&find_loc=${encodeURIComponent(b)}`:`https://www.google.com/search?q=${encodeURIComponent(`${R} ${s==="x"?"twitter":s}`)}`},ha=()=>{const{salesTaxRate:s,...o}=F;lt.mutate(o)},ba=()=>{i&&je({email:i.email||"",phone:i.phone||"",website:i.website||"",address:i.address||"",city:i.city||"",state:i.state||"",zipCode:i.zipCode||"",country:i.country||"US",taxId:i.taxId||"",statePayrollTaxNumber:i.statePayrollTaxNumber||"",salesTaxRate:i.salesTaxRate??"",employerLegalName:i.employerLegalName||"",socialLinks:i.socialLinks||{}}),Me(!1),v("")},ot=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),Le(!1),n("")},onError:s=>{var o,b;n(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update invoice settings")}}),Ie=(s,o)=>{Se({...Q,[s]:o}),Le(!0)},fa=()=>{ot.mutate(Q)},ya=()=>{i&&Se({invoicePrefix:i.invoicePrefix||"INV",invoiceIncludeYear:i.invoiceIncludeYear??!0,invoiceNextNumber:i.invoiceNextNumber||1,invoiceSeparator:i.invoiceSeparator||"-",billPrefix:i.billPrefix||"BILL",billNextNumber:i.billNextNumber||1}),Le(!1),n("")},dt=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),St(!1),wt("")},onError:s=>{var o,b;wt(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update invitation defaults")}}),ls=(s,o)=>{P({...E,[s]:o}),St(!0)},ja=()=>{dt.mutate(E)},Na=()=>{i&&P({defaultInvitationRole:i.defaultInvitationRole||"ACCOUNTANT",defaultInvitationApprovalMode:i.defaultInvitationApprovalMode||"IMMEDIATE"}),St(!1),wt("")},ct=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),pe(!1),st("")},onError:s=>{var o,b;st(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update time clock settings")}}),We=D({mutationFn:()=>qa.bulkResetPins(),onSuccess:s=>{Ke(s),ve(!1)},onError:s=>{var o,b;st(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to reset PINs"),ve(!1)}}),va=(s,o)=>{xe({...H,[s]:o}),pe(!0)},ka=()=>{ct.mutate(H)},ge=(i==null?void 0:i.employeePortalEntitlements)??Ua,mt=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),Pt(!1),Xt("")},onError:s=>{var o,b;Xt(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update employee portal")}}),Fe=(s,o)=>{Ct(b=>({...b,[s]:o})),Pt(!0)},Sa=()=>{const s=i==null?void 0:i.employeePortalConfig,o={};Object.keys(ne).forEach(b=>{(!s||ne[b]!==s[b])&&(o[b]=ne[b])}),mt.mutate({employeePortalConfig:o})},wa=()=>{i!=null&&i.employeePortalConfig&&Ct(i.employeePortalConfig),Pt(!1)},ut=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),at(!1),ts("")},onError:s=>{var o,b;ts(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update refund policy")}}),Ca=()=>{ut.mutate({refundWindowDays:Zt,depositsRefundable:Jt})},Pa=()=>{Tt((i==null?void 0:i.refundWindowDays)??14),Et((i==null?void 0:i.depositsRefundable)??!1),at(!1)},Ta=()=>{i&&xe({requirePhotoOnClock:i.requirePhotoOnClock||"OFF",companyCode:i.emailInboxSlug||"",clockInGracePeriodMinutes:i.clockInGracePeriodMinutes||0,clockOutGracePeriodMinutes:i.clockOutGracePeriodMinutes||0,autoClockOutEnabled:i.autoClockOutEnabled??!1,autoClockOutGracePeriodMinutes:i.autoClockOutGracePeriodMinutes??30,autoClockOutMaxShiftHours:i.autoClockOutMaxShiftHours??12}),pe(!1),st("")},xt=D({mutationFn:s=>U.updateSettings(s),onSuccess:()=>{K.invalidateQueries({queryKey:["settings"]}),At(!1),Mt("")},onError:s=>{var o,b;Mt(((b=(o=s.response)==null?void 0:o.data)==null?void 0:b.message)||"Failed to update timesheet review settings")}}),Rt=(s,o)=>{Dt({...Re,[s]:o}),At(!0)},Ea=()=>{xt.mutate(Re)},Da=()=>{i&&Dt({autoSendTimesheetReviews:i.autoSendTimesheetReviews??!1,timesheetReviewDelayHours:i.timesheetReviewDelayHours??6,timesheetReviewExpirationDays:i.timesheetReviewExpirationDays??2}),At(!1),Mt("")},Aa=()=>{const{invoicePrefix:s,invoiceIncludeYear:o,invoiceNextNumber:b,invoiceSeparator:R}=Q,z=new Date().getFullYear(),X=b.toString().padStart(4,"0");return o?`${s}${R}${z}${R}${X}`:`${s}${R}${X}`},Ma=()=>{const{billPrefix:s,invoiceIncludeYear:o,billNextNumber:b,invoiceSeparator:R}=Q,z=new Date().getFullYear(),X=b.toString().padStart(4,"0");return o?`${s}${R}${z}${R}${X}`:`${s}${R}${X}`},La=!(i!=null&&i.email)||!(i!=null&&i.phone)||!(i!=null&&i.address),Ra=async s=>{var b,R,z;const o=(b=s.target.files)==null?void 0:b[0];if(!(!o||!I)){if(o.size>2*1024*1024){v("File too large. Maximum size is 2MB.");return}Ne(!0),v("");try{await U.uploadLogo(I,o);const X=sessionStorage.getItem("accessToken"),Ia=Date.now(),Ks=await fetch(`https://api.bizvanguard.ai/api/organizations/${I}/logo?v=${Ia}`,{headers:{Authorization:`Bearer ${X}`},cache:"no-store"});if(Ks.ok){ue&&URL.revokeObjectURL(ue);const Fa=await Ks.blob(),Ha=URL.createObjectURL(Fa);re(Ha),me(!1)}K.invalidateQueries({queryKey:["settings"]}),window.dispatchEvent(new Event("organization-updated"))}catch(X){v(((z=(R=X.response)==null?void 0:R.data)==null?void 0:z.message)||"Failed to upload logo")}finally{Ne(!1),s.target.value=""}}},Oa=async()=>{var s,o;if(I&&window.confirm("Are you sure you want to remove the logo?")){Ne(!0),v("");try{await U.deleteLogo(I),K.invalidateQueries({queryKey:["settings"]}),ue&&URL.revokeObjectURL(ue),re(null),window.dispatchEvent(new Event("organization-updated"))}catch(b){v(((o=(s=b.response)==null?void 0:s.data)==null?void 0:o.message)||"Failed to delete logo")}finally{Ne(!1)}}};return aa?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:t("loading")})}):e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold",children:t("heading")}),e.jsx("p",{className:"text-muted-foreground mt-1",children:t("subheading")})]}),e.jsx("div",{className:"border-b",children:e.jsx("nav",{className:"flex -mb-px overflow-x-auto",children:Object.keys(Vs(t)).filter(s=>s!=="appointments"||f).filter(s=>s!=="payments"||y).map(s=>e.jsx("button",{onClick:()=>S(s),className:`px-3 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${r===s?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground
1/30"}`,children:Vs(t)[s]},s))})}),r==="profile"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("orgs.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("orgs.subheading")})]}),e.jsx("button",{type:"button",onClick:()=>ae(!0),className:"px-3 py-1 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:t("orgs.createButton")})]}),ns.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:t("orgs.noOrgs")}):e.jsx("div",{className:"space-y-2",children:ns.map(s=>e.jsxs("div",{className:`flex justify-between items-center p-4 border rounded-md hover:bg-accent/50 ${s.id===I?"border-primary bg-primary/5":""}`,children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium",children:s.name}),s.id===I&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-primary text-primary-foreground rounded",children:t("orgs.currentBadge")})]}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("orgs.orgMeta",{role:s.role,industry:s.industry||t("orgs.notSet"),stateCode:s.stateCode,timezone:s.timezone||t("orgs.notSet")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(s.role==="OWNER"||s.role==="ADMIN")&&e.jsx("button",{onClick:()=>{Ae(s),w(!0)},className:"px-3 py-2 text-sm border rounded hover:bg-accent",title:t("orgs.editTitle"),children:t("buttons.edit")}),s.id!==I&&e.jsx("button",{onClick:async()=>{try{const o=await Nt.switch(s.id);sessionStorage.setItem("accessToken",o.accessToken),sessionStorage.setItem("refreshToken",o.refreshToken),window.location.href=`/dashboard/settings?tab=${r}`}catch(o){console.error("Failed to switch organization:",o),alert(t("errors.switchOrgFailed"))}},className:"px-4 py-2 text-sm border rounded hover:bg-accent",children:t("orgs.switchButton")})]})]},s.id))})]}),La&&e.jsx("div",{className:"p-4 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-400 text-xl",children:"⚠"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:t("profile.incompleteBannerTitle")}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300 mt-1",children:t("profile.incompleteBannerBody")})]})]})}),e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("profile.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("profile.subheading")})]}),Ze&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:Ze}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.logoLabel")}),e.jsxs("div",{className:"flex items-center gap-4",children:[i!=null&&i.logoUrl&&I?e.jsxs("div",{className:"relative",children:[et?e.jsxs("div",{className:"w-24 h-24 border rounded-md bg-muted/20 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx("span",{className:"text-2xl",children:"!"}),e.jsx("span",{className:"text-xs",children:t("profile.logoLoadError")})]}):ue?e.jsx("img",{src:ue,alt:t("profile.logoAlt"),className:"w-24 h-24 object-contain border rounded-md bg-white"}):e.jsx("div",{className:"w-24 h-24 border rounded-md bg-muted/20 flex items-center justify-center text-muted-foreground animate-pulse",children:e.jsx("span",{className:"text-xs",children:t("profile.logoLoading")})}),e.jsx("button",{type:"button",onClick:Oa,disabled:Je,className:"absolute -top-2 -right-2 w-6 h-6 bg-destructive text-destructive-foreground rounded-full flex items-center justify-center text-sm hover:bg-destructive/90 disabled:opacity-50",title:t("profile.removeLogoTitle"),children:"×"})]}):e.jsx("div",{className:"w-24 h-24 border-2 border-dashed rounded-md flex items-center justify-center text-muted-foreground bg-muted/20",children:e.jsx("span",{className:"text-3xl",children:"+"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"logo-upload",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:Ra,className:"hidden"}),e.jsx("label",{htmlFor:"logo-upload",className:"inline-block px-4 py-2 border rounded-md cursor-pointer hover:bg-accent text-sm",children:Je?t("profile.uploading"):i!=null&&i.logoUrl?t("profile.changeLogo"):t("profile.uploadLogo")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:t("profile.logoHint")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.emailLabel")}),e.jsx("input",{type:"email",autoComplete:"off",value:F.email,onChange:s=>ie("email",s.target.value),placeholder:t("profile.emailPlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.phoneLabel")}),e.jsx("input",{type:"tel",autoComplete:"off",value:F.phone,onChange:s=>ie("phone",Ka(s.target.value)),placeholder:t("profile.phonePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.websiteLabel")}),e.jsx("input",{type:"url",autoComplete:"off",value:F.website,onChange:s=>ie("website",s.target.value),placeholder:t("profile.websitePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{className:"pt-2 border-t",children:[e.jsx("p",{className:"text-sm font-medium",children:t("profile.socialTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("profile.socialHint")}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[["google",t("profile.socialGoogle"),"https://g.page/r/..."],["yelp","Yelp","https://www.yelp.com/biz/..."],["instagram","Instagram","https://www.instagram.com/..."],["facebook","Facebook","https://www.facebook.com/..."],["x","X (Twitter)","https://x.com/..."],["tiktok","TikTok","https://www.tiktok.com/@..."]].map(([s,o,b])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium",children:o}),e.jsx("a",{href:ga(s),target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline",children:t("profile.socialFindIt")})]}),e.jsx("input",{type:"url",autoComplete:"off",value:F.socialLinks[s]||"",onChange:R=>pa(s,R.target.value),placeholder:b,className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]},s))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.addressLabel")}),e.jsx("input",{type:"text",autoComplete:"off",value:F.address,onChange:s=>ie("address",s.target.value),placeholder:t("profile.addressPlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2 md:col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.cityLabel")}),e.jsx("input",{type:"text",autoComplete:"off",value:F.city,onChange:s=>ie("city",s.target.value),placeholder:t("profile.cityPlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.stateLabel")}),e.jsx("input",{type:"text",autoComplete:"off",value:F.state,onChange:s=>ie("state",s.target.value),placeholder:t("profile.statePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.zipLabel")}),e.jsx("input",{type:"text",autoComplete:"off",value:F.zipCode,onChange:s=>ie("zipCode",s.target.value),placeholder:t("profile.zipPlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.countryLabel")}),e.jsxs("select",{autoComplete:"off",value:F.country,onChange:s=>ie("country",s.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"US",children:t("country.us")}),e.jsx("option",{value:"CA",children:t("country.ca")})]})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx("h4",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:t("profile.employerInfoHeading")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.employerLegalNameLabel")}),e.jsx("input",{type:"text",value:F.employerLegalName,onChange:s=>ie("employerLegalName",s.target.value),placeholder:(i==null?void 0:i.name)||t("profile.employerLegalNamePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("profile.employerLegalNameHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.taxIdLabel")}),e.jsx("input",{type:"text",value:F.taxId,onChange:s=>
1ie("taxId",s.target.value),placeholder:"XX-XXXXXXX",className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("profile.taxIdHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("profile.statePayrollTaxLabel")}),e.jsx("input",{type:"text",value:F.statePayrollTaxNumber,onChange:s=>ie("statePayrollTaxNumber",s.target.value),placeholder:"XXX-XXXX-X",className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("profile.statePayrollTaxHint")})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(pn,{rates:(i==null?void 0:i.salesTaxRates)||[],currentPercent:(i==null?void 0:i.salesTaxRate)??null})})]})]})]}),e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:ha,disabled:lt.isPending||!_e,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:lt.isPending?t("buttons.saving"):t("buttons.saveProfile")}),_e&&e.jsx("button",{onClick:ba,disabled:lt.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]})]}),r==="payroll"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("payroll.configHeading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("payroll.configSubheading")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("payroll.periodTypeLabel")}),(()=>{const s=(i==null?void 0:i.stateCode)||"",o=s?Dn[s]:null,b=(o==null?void 0:o.disallowed)??[];return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:x,onChange:R=>{const z=R.target.value;c(z),j(!0),z==="SEMI_MONTHLY"||z==="MONTHLY"?T(0):m&&(z==="WEEKLY"||z==="BI_WEEKLY")&&T(_s(m+"T12:00:00Z","UTC"))},className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"WEEKLY",children:t("payrollSchedule.weekly")}),e.jsx("option",{value:"BI_WEEKLY",children:t("payrollSchedule.biWeekly")}),e.jsx("option",{value:"SEMI_MONTHLY",children:t("payrollSchedule.semiMonthly")}),e.jsxs("option",{value:"MONTHLY",disabled:b.includes("MONTHLY"),children:[t("payrollSchedule.monthly"),b.includes("MONTHLY")?` (${t("payrollSchedule.notAvailableIn",{state:s})})`:""]})]}),o&&e.jsx("p",{className:"text-sm text-amber-600 mt-1",children:o.note})]})})()]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[t("payroll.startDateLabel"),e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["(",t("payroll.startDateHintInline"),")"]})]}),e.jsx("input",{type:"date",value:m,onChange:s=>{const o=s.target.value;g(o),j(!0),o&&(x==="WEEKLY"||x==="BI_WEEKLY")&&T(_s(o+"T12:00:00Z","UTC"))},className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[x==="WEEKLY"&&t("payroll.startDateHintWeekly"),x==="BI_WEEKLY"&&t("payroll.startDateHintBiWeekly"),x==="SEMI_MONTHLY"&&t("payroll.startDateHintSemiMonthly"),x==="MONTHLY"&&t("payroll.startDateHintMonthly")]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[t("payroll.workweekStartLabel"),e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["(",t("payroll.workweekStartHintInline"),")"]})]}),e.jsxs("select",{value:h,onChange:s=>{T(Number(s.target.value)),j(!0)},disabled:x==="WEEKLY"||x==="BI_WEEKLY",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary ${x==="WEEKLY"||x==="BI_WEEKLY"?"bg-muted cursor-not-allowed opacity-70":""}`,children:[e.jsx("option",{value:0,children:t("days.sunday")}),e.jsx("option",{value:1,children:t("days.monday")}),e.jsx("option",{value:2,children:t("days.tuesday")}),e.jsx("option",{value:3,children:t("days.wednesday")}),e.jsx("option",{value:4,children:t("days.thursday")}),e.jsx("option",{value:5,children:t("days.friday")}),e.jsx("option",{value:6,children:t("days.saturday")})]}),x==="WEEKLY"||x==="BI_WEEKLY"?e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("payroll.workweekAutoHint")}):e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("payroll.workweekFlsaHint",{periodType:t(x==="SEMI_MONTHLY"?"payrollSchedule.semiMonthlyShort":"payrollSchedule.monthlyShort")})})]})]})]}),e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("payroll.breaksHeading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("payroll.breaksSubheading")})]}),e.jsx("button",{type:"button",onClick:na,className:"px-3 py-1 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:t("payroll.addBreakButton")})]}),q&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:q}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:t("payroll.noBreaks")}):e.jsx("div",{className:"space-y-3",children:l.map((s,o)=>e.jsxs("div",{className:"flex gap-3 items-center p-4 border rounded-md bg-accent/20",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground block mb-1",children:t("payroll.breakStartTime")}
1),e.jsx("input",{type:"time",value:s.start,onChange:b=>rs(o,"start",b.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground block mb-1",children:t("payroll.breakEndTime")}),e.jsx("input",{type:"time",value:s.end,onChange:b=>rs(o,"end",b.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsx("button",{type:"button",onClick:()=>ia(o),className:"px-3 py-2 text-destructive hover:bg-destructive/10 rounded-md mt-5",title:t("payroll.removeBreakTitle"),children:t("buttons.remove")})]},o))}),C&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:ra,disabled:it.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:it.isPending?t("buttons.saving"):t("buttons.saveChanges")}),e.jsx("button",{onClick:la,disabled:it.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]}),!C&&l.length>0&&e.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-950 border border-green-200 dark:border-green-800 rounded-md",children:e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:t("payroll.breaksConfigured")})}),e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("timesheetReview.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("timesheetReview.subheading")})]}),ss&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:ss}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-md bg-accent/20",children:[e.jsxs("div",{children:[e.jsx("label",{className:"font-medium",children:t("timesheetReview.autoSendLabel")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("timesheetReview.autoSendHint")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Re.autoSendTimesheetReviews,onChange:s=>Rt("autoSendTimesheetReviews",s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary/20 dark:peer-focus:ring-primary/30 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary"})]})]}),Re.autoSendTimesheetReviews&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 border rounded-md bg-muted/30",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timesheetReview.delayLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"0",max:"48",value:Re.timesheetReviewDelayHours,onChange:s=>Rt("timesheetReviewDelayHours",parseInt(s.target.value)||0),className:"w-20 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("units.hours")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timesheetReview.delayHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timesheetReview.deadlineLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"1",max:"14",value:Re.timesheetReviewExpirationDays,onChange:s=>Rt("timesheetReviewExpirationDays",parseInt(s.target.value)||2),className:"w-20 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("units.days")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timesheetReview.deadlineHint")})]})]})]}),sa&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:Ea,disabled:xt.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:xt.isPending?t("buttons.saving"):t("buttons.saveSettings")}),e.jsx("button",{onClick:Da,disabled:xt.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]})]}),r==="notifications"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("notifications.inviteDefaultsHeading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("notifications.inviteDefaultsSubheading")})]}),Gt&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:Gt}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("notifications.defaultRoleLabel")}),e.jsxs("select",{value:E.defaultInvitationRole,onChange:s=>ls("defaultInvitationRole",s.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"ADMIN",children:t("roles.adminOption")}),e.jsx("option",{value:"MANAGER",children:t("roles.managerOption")}),e.jsx("option",{value:"ACCOUNTANT",children:t("roles.accountantOption")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("notifications.defaultRoleHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("notifications.approvalModeLabel")}),e.jsxs("select",{value:E.defaultInvitationApprovalMode,onChange:s=>ls("defaultInvitationApprovalMode",s.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"IMMEDIATE",children:t("notifications.approvalModeImmediate")}),e.jsx("option",{value:"REQUIRES_APPROVAL",children:t("notifications.approvalModeRequires")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("notifications.approvalModeHint")})]})]})}),ee&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:ja,disabled:dt.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:dt.isPending?t("buttons.saving"):t("buttons.saveDefaults")}),e.jsx("button",{onClick:Na,disabled:dt.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]})}),r==="timeclock"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("timeclock.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("timeclock.subheading")})]}),Qt&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:Qt}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.companyCodeL
1abel")}),e.jsx("div",{className:"flex items-center gap-2 max-w-md",children:e.jsx("input",{type:"text",value:H.companyCode,onChange:s=>{const o=s.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"");xe({...H,companyCode:o}),pe(!0)},placeholder:t("timeclock.companyCodePlaceholder"),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.companyCodeHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.photoVerificationLabel")}),e.jsxs("select",{value:H.requirePhotoOnClock,onChange:s=>va("requirePhotoOnClock",s.target.value),className:"w-full max-w-md px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"OFF",children:t("timeclock.photoOff")}),e.jsx("option",{value:"REMOTE_ONLY",children:t("timeclock.photoRemoteOnly")}),e.jsx("option",{value:"ALL",children:t("timeclock.photoAll")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.photoVerificationHint")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.clockInGraceLabel")}),e.jsx("input",{type:"number",min:"0",max:"60",value:H.clockInGracePeriodMinutes,onChange:s=>{xe({...H,clockInGracePeriodMinutes:Math.max(0,parseInt(s.target.value)||0)}),pe(!0)},className:"w-full max-w-[200px] px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.clockInGraceHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.clockOutGraceLabel")}),e.jsx("input",{type:"number",min:"0",max:"60",value:H.clockOutGracePeriodMinutes,onChange:s=>{xe({...H,clockOutGracePeriodMinutes:Math.max(0,parseInt(s.target.value)||0)}),pe(!0)},className:"w-full max-w-[200px] px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.clockOutGraceHint")})]})]}),e.jsx("div",{className:"p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:t("timeclock.noteLabel")})," ",t("timeclock.flexibleNote")]})}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("input",{type:"checkbox",id:"autoClockOutEnabled",checked:H.autoClockOutEnabled,onChange:s=>{xe({...H,autoClockOutEnabled:s.target.checked}),pe(!0)},className:"h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"autoClockOutEnabled",className:"text-sm font-medium",children:t("timeclock.autoClockOutLabel")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:t("timeclock.autoClockOutHint")}),H.autoClockOutEnabled&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 ml-7",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.autoClockOutGraceLabel")}),e.jsx("input",{type:"number",min:"0",max:"480",value:H.autoClockOutGracePeriodMinutes,onChange:s=>{xe({...H,autoClockOutGracePeriodMinutes:Math.max(0,parseInt(s.target.value)||0)}),pe(!0)},className:"w-full max-w-[200px] px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.autoClockOutGraceHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("timeclock.maxShiftLabel")}),e.jsx("input",{type:"number",min:"1",max:"24",value:H.autoClockOutMaxShiftHours,onChange:s=>{xe({...H,autoClockOutMaxShiftHours:Math.max(1,Math.min(24,parseInt(s.target.value)||12))}),pe(!0)},className:"w-full max-w-[200px] px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("timeclock.maxShiftHint")})]})]})]}),e.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsxs("h4",{className:"font-semibold text-green-800 dark:text-green-200 mb-2 flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),t("timeclock.securityFeaturesHeading")]}),e.jsxs("ul",{className:"text-sm text-green-700 dark:text-green-300 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:t("timeclock.securityPinOnly")})," ",t("timeclock.securityPinOnlyDesc")]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:t("timeclock.securityRateLimit")})," ",t("timeclock.securityRateLimitDesc")]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:t("timeclock.securityEncryptedPins")})," ",t("timeclock.securityEncryptedPinsDesc")]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:t("timeclock.securityGps")})," ",t("timeclock.securityGpsDesc")]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:t("timeclock.securityPhoto")})," ",t("timeclock.securityPhotoDesc")]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h4",{className:"font-semibold mb-2",children:t("timeclock.pinMgmtHeading")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("timeclock.pinMgmtHint")}),e.jsx("button",{onClick:()=>ve(!0),disabled:We.isPending,className:"px-4 py-2 bg-orange-600 text-white rounded-md hover:bg-orange-700 disabled:opacity-50 font-medium",children:We.isPending?t("timeclock.resettingPins"):t("timeclock.resetAllPinsButton")})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h4",{className:"font-semibold mb-4",children:t("timeclock.setupHeading")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h5",{className:"text-sm font-medium mb-2",children:t("timeclock.kioskHeading")}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-sm space-y-2",children:[e.jsx("p",{className:"text-muted-foreground",children:t("timeclock.kioskDesc")}),H.companyCode?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:t("timeclock.urlLabel")}),e.jsxs("code",{className:"px-2 py-1 bg-background border rounded text-xs",children:[window.location.origin,"/kiosk/",H.companyCode]}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/kiosk/${H.companyCode}`),className:"px-2 py-1 text-xs border rounded hover:bg-accent",children:t("buttons.copy")})]}):e.jsx("p",{className:"text-muted-foreground italic",children:t("timeclock.kioskNoCode")}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[e.jsx("strong",{children:t("timeclock.kioskSetupLabel")})," ",t("timeclock.kioskSetupDesc")]})]})]}),e.jsxs("div",{children:[e.jsx("h5",{className:"text-sm font-medium mb-2",children:t("timeclock.remoteClockHeading")}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-sm space-y-2",children:[e.jsx("p",{className:"text-muted-foreground",children:t("timeclock.remoteClockDesc")}),H.companyCode?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:t("timeclock.urlLabel")}),e.jsxs("code",{className:"px-2 py-1 bg-background border rounded text-xs",children:[window.location.origin,"/clock/",H.companyCode]}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/clock/${H.companyCode}`),className:"px-2 py-1 text-xs border rounded hover:bg-accent",children:t("buttons.copy")})]}):e.jsx("p",{className:"text-muted-foreground italic",children:t("timeclock.remoteNoCode")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:t("timeclock.remoteClockShareHint")})]})]})]})]}),Js&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:ka,disabled:ct.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:ct.isPending?t("buttons.saving"):t("buttons.saveSettings")}),e.jsx("button",{onClick:Ta,disabled:ct.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]}),e.jsxs("div",{className:"border rounded-lg p-6 bg-card mt-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("employeePortal.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("employeePortal.subheading")})]}),Vt&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:Vt}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.enabled,onChange:s=>Fe("enabled",s.target.checked),className:"h-5 w-5 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:t("employeePortal.enable")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("employeePortal.enableHint")})]})]}
1),e.jsxs("div",{className:ne.enabled?"space-y-3":"space-y-3 opacity-50 pointer-events-none",children:[e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ge.clockControls?ne.timeClock:!0,disabled:!ge.clockControls,onChange:s=>Fe("timeClock",s.target.checked),className:"h-5 w-5 rounded border-gray-300 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[t("employeePortal.clockInFromPhone"),!ge.clockControls&&e.jsx("span",{className:"ml-2 text-xs font-semibold text-amber-600 border border-amber-400 rounded px-1.5 py-0.5",children:t("employeePortal.goldPlanBadge")})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t("employeePortal.clockInFromPhoneHint"),!ge.clockControls&&t("employeePortal.clockInGateHint")]}),!ge.clockControls&&!ne.timeClock&&e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400 mt-1 font-medium",children:t("employeePortal.clockInPausedWarning")})]})]}),e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.schedule,onChange:s=>Fe("schedule",s.target.checked),className:"h-5 w-5 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:t("employeePortal.schedule")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("employeePortal.scheduleHint")})]})]}),e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.documents,onChange:s=>Fe("documents",s.target.checked),className:"h-5 w-5 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:t("employeePortal.documents")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("employeePortal.documentsHint")})]})]}),N.includes("tip_tracking")&&e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.tips,onChange:s=>Fe("tips",s.target.checked),className:"h-5 w-5 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:t("employeePortal.tips")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("employeePortal.tipsHint")})]})]}),e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ge.payDocuments?ne.payDocuments:!1,disabled:!ge.payDocuments,onChange:s=>Fe("payDocuments",s.target.checked),className:"h-5 w-5 rounded border-gray-300 disabled:opacity-50"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[t("employeePortal.payDocuments"),!ge.payDocuments&&e.jsx("span",{className:"ml-2 text-xs font-semibold text-amber-600 border border-amber-400 rounded px-1.5 py-0.5",children:t("employeePortal.platinumPlanBadge")})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t("employeePortal.payDocumentsHint"),!ge.payDocuments&&t("employeePortal.payDocumentsGateHint")]})]})]})]})]}),ea&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:Sa,disabled:mt.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:mt.isPending?t("buttons.saving"):t("buttons.saveSettings")}),e.jsx("button",{onClick:wa,disabled:mt.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]})]}),r==="invoicing"&&e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("invoicing.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("invoicing.subheading")})]}),ze&&e.jsx("div",{className:"text-destructive text-sm mb-4 p-3 bg-destructive/10 rounded-md",children:ze}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("invoicing.separatorLabel")}),e.jsxs("select",{value:Q.invoiceSeparator,onChange:s=>Ie("invoiceSeparator",s.target.value),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"-",children:t("invoicing.separatorDash")}),e.jsx("option",{value:"/",children:t("invoicing.separatorSlash")}),e.jsx("option",{value:"",children:t("invoicing.separatorNone")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[e.jsx("input",{type:"checkbox",id:"invoiceIncludeYear",checked:Q.invoiceIncludeYear,onChange:s=>Ie("invoiceIncludeYear",s.target.checked),className:"h-4 w-4 roun
1ded border-gray-300"}),e.jsx("label",{htmlFor:"invoiceIncludeYear",className:"text-sm font-medium",children:t("invoicing.includeYearLabel")})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:t("invoicing.invoicesHeading")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("invoicing.prefixLabel")}),e.jsx("input",{type:"text",value:Q.invoicePrefix,onChange:s=>Ie("invoicePrefix",s.target.value.toUpperCase()),placeholder:"INV",maxLength:10,className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("invoicing.nextNumberLabel")}),e.jsx("input",{type:"number",value:Q.invoiceNextNumber,onChange:s=>Ie("invoiceNextNumber",parseInt(s.target.value)||1),min:1,className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[t("invoicing.preview")," ",e.jsx("span",{className:"font-mono font-medium text-foreground",children:Aa()})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:t("invoicing.billsHeading")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("invoicing.prefixLabel")}),e.jsx("input",{type:"text",value:Q.billPrefix,onChange:s=>Ie("billPrefix",s.target.value.toUpperCase()),placeholder:"BILL",maxLength:10,className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("invoicing.nextNumberLabel")}),e.jsx("input",{type:"number",value:Q.billNextNumber,onChange:s=>Ie("billNextNumber",parseInt(s.target.value)||1),min:1,className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[t("invoicing.preview")," ",e.jsx("span",{className:"font-mono font-medium text-foreground",children:Ma()})]})]})]}),e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:fa,disabled:ot.isPending||!tt,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:ot.isPending?t("buttons.saving"):t("buttons.saveInvoiceSettings")}),tt&&e.jsx("button",{onClick:ya,disabled:ot.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]}),r==="payments"&&y&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Tn,{embedded:!0}),e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("refundPolicy.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("refundPolicy.subheading")})]}),es&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:es}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"max-w-xs",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:t("refundPolicy.windowLabel")}),e.jsx("input",{type:"number",min:"1",max:"90",value:Zt,onChange:s=>{Tt(Math.max(1,Math.min(90,parseInt(s.target.value)||14))),at(!0)},className:"w-full min-h-[44px] px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("refundPolicy.windowHint")})]}),e.jsxs("label",{className:"flex items-center gap-3 p-4 border rounded-md cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Jt,onChange:s=>{Et(s.target.checked),at(!0)},className:"h-5 w-5 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:t("refundPolicy.allowDeposits")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("refundPolicy.allowDepositsHint")})]})]}),e.jsx("div",{className:"p-4 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:t("refundPolicy.feesNoteLabel")})," ",t("refundPolicy.feesNote")]})})]}),ta&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:Ca,disabled:ut.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:ut.isPending?t("buttons.saving"):t("buttons.saveSettings")}),e.jsx("button",{onClick:Pa,disabled:ut.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]})]}),r==="positions"&&e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("positions.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("positions.subheading")})]}),e.jsx("button",{type:"button",onClick:oa,className:"px-3 py-1 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:t("positions.addButton")})]}),(((ds=$e==null?void 0:$e.suggestions)==null?void 0:ds.length)??0)>0&&e.jsxs("div",{className:"mb-4 p-4 border border-dashed rounded-md bg-muted/30",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("h4",{className:"text-sm font-medium",children:t("positions.suggestionsHeading")}),e.jsx("button",{type:"button",onClick:()=>nt.mutate($e.suggestions),disabled:nt.isPending,className:"text-sm text-primary hover:underline disabled:opacity-50",children:t("positions.addAll")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:$e.suggestions.map(s=>e.jsxs("button",{type:"button",onClick:()=>nt.mutate([s]),disabled:nt.isPending,className:"px-3 py-1 text-sm border rounded-full hover:bg-accent disabled:opacity-50",children:["+ ",s]},s))})]}),as.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:t("positions.noPositions")}):e.jsx("div",{className:"space-y-2",children:as.map(s=>e.jsxs("div",{className:"flex justify-between items-center p-4 border rounded-md hover:bg-accent/50",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),s.description&&e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:s.description})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>da(s),className:"px-3 py-1 text-sm border rounded hover:bg-accent",children:t("buttons.edit")}),e.jsx("button",{onClick:()=>ca(s),disabled:is.isPending,className:"px-3 py-1 text-sm border border-destructive text-destructive rounded hover:bg-destructive/10 disabled:opacity-50",children:t("buttons.delete")})]})]},s.id))})]}),r==="notifications"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-6 bg-card",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:t("sms.heading")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("sms.subheading")})]}),Xe&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:Xe}),te&&e.jsxs("div",{className:"mb-6 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:t("sms.usageHeading")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:te.limit===-1?t("sms.unlimited"):`${te.currentUsage} / ${te.limit}`})]}),te.limit!==-1&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 mb-2",children:e.jsx("div",{className:`h-2 rounded-full transition-all ${te.percentage>=90?"bg-destructive":te.percentage>
1=70?"bg-yellow-500":"bg-primary"}`,style:{width:`${Math.min(100,te.percentage)}%`}})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t("sms.usagePercent",{pct:te.percentage}),te.percentage>=90&&` - ${t("sms.upgradeHint")}`]})]}),te.limit===-1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.messagesSent",{count:te.currentUsage})})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("input",{type:"checkbox",id:"smsEnabled",checked:A.enabled||!1,onChange:s=>ma("enabled",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"smsEnabled",className:"font-medium",children:t("sms.enableLabel")})]}),A.enabled&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:t("sms.typesHeading")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("sms.typesSubheading")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md",children:[e.jsx("input",{type:"checkbox",id:"smsOnboarding",checked:((cs=A.notifications)==null?void 0:cs.onboarding)??!0,onChange:s=>Ye("onboarding",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"smsOnboarding",className:"font-medium text-sm cursor-pointer",children:t("sms.signingLinksLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.signingLinksDesc")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md",children:[e.jsx("input",{type:"checkbox",id:"smsDocumentSigning",checked:((ms=A.notifications)==null?void 0:ms.documentSigning)??!0,onChange:s=>Ye("documentSigning",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"smsDocumentSigning",className:"font-medium text-sm cursor-pointer",children:t("sms.documentSigningLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.documentSigningDesc")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md",children:[e.jsx("input",{type:"checkbox",id:"smsWageReceipts",checked:((us=A.notifications)==null?void 0:us.wageReceipts)??!0,onChange:s=>Ye("wageReceipts",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"smsWageReceipts",className:"font-medium text-sm cursor-pointer",children:t("sms.wageReceiptsLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.wageReceiptsDesc")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md",children:[e.jsx("input",{type:"checkbox",id:"smsBreakReminders",checked:((xs=A.notifications)==null?void 0:xs.breakReminders)??!0,onChange:s=>Ye("breakReminders",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"smsBreakReminders",className:"font-medium text-sm cursor-pointer",children:t("sms.breakRemindersLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.breakRemindersDesc")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md",children:[e.jsx("input",{type:"checkbox",id:"smsClockReminders",checked:((ps=A.notifications)==null?void 0:ps.clockReminders)??!0,onChange:s=>Ye("clockReminders",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"smsClockReminders",className:"font-medium text-sm cursor-pointer",children:t("sms.clockRemindersLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("sms.clockRemindersDesc")})]})]})]})]}),(((gs=A.notifications)==null?void 0:gs.breakReminders)||((hs=A.notifications)==null?void 0:hs.clockReminders))&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:t("sms.reminderTimingHeading")}),e.jsxs("div",{className:"space-y-4",children:[((bs=A.notifications)==null?void 0:bs.breakReminders)&&e.jsxs("div",{className:"p-4 border rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"checkbox",id:"takeBreakEnabled",checked:((ys=(fs=A.reminderSettings)==null?void 0:fs.takeBreak)==null?void 0:ys.enabled)||!1,onChange:s=>Oe("takeBreak","enabled",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"takeBreakEnabled",className:"font-medium",children:t("sms.takeBreakLabel")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("sms.takeBreakDesc")}),((Ns=(js=A.reminderSettings)==null?void 0:js.takeBreak)==null?void 0:Ns.enabled)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:t("sms.sendAfter")}),e.jsx("input",{type:"number",min:"60",step:"30",value:((ks=(vs=A.reminderSettings)==null?void 0:vs.takeBreak)==null?void 0:ks.thresholdMinutes)||240,onChange:s=>Oe("takeBreak","thresholdMinutes",parseInt(s.target.value)),className:"w-20 px-2 py-1 border rounded-md text-center"}),e.jsx("span",{className:"text-sm",children:t("sms.minutesHours",{hours:((((ws=(Ss=A.reminderSettings)==null?void 0:Ss.takeBreak)==null?void 0:ws.thresholdMinutes)||240)/60).toFixed(1)})})]})]}),((Cs=A.notifications)==null?void 0:Cs.breakReminders)&&e.jsxs("div",{className:"p-4 border rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"checkbox",id:"endBreakEnabled",checked:((Ts=(Ps=A.reminderSettings)==null?void 0:Ps.endBreak)==null?void 0:Ts.enabled)||!1,onChange:s=>Oe("endBreak","enabled",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"endBreakEnabled",className:"font-medium",children:t("sms.endBreakLabel")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("sms.endBreakDesc")}),((Ds=(Es=A.reminderSettings)==null?void 0:Es.endBreak)==null?void 0:Ds.enabled)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:t("sms.sendAfter")}),e.jsx("input",{type:"number",min:"5",step:"5",value:((Ms=(As=A.reminderSettings)==null?void 0:As.endBreak)==null?void 0:Ms.thresholdMinutes)||35,onChange:s=>Oe("endBreak","thresholdMinutes",parseInt(s.target.value)),className:"w-20 px-2 py-1 border rounded-md text-center"}),e.jsx("span",{className:"text-sm",children:t("sms.minutesOnBreak")})]})]}),((Ls=A.notifications)==null?void 0:Ls.clockReminders)&&e.jsxs("div",{className:"p-4 border rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"checkbox",id:"clockOutEnabled",checked:((Os=(Rs=A.reminderSettings)==null?void 0:Rs.clockOut)==null?void 0:Os.enabled)||!1,onChange:s=>Oe("clockOut","enabled",s.target.checked),className:"w-4 h-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"clockOutEnabled",className:"font-medium",children:t("sms.clockOutLabel")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("sms.clockOutDesc")}),((Fs=(Is=A.reminderSettings)==null?void 0:Is.clockOut)==null?void 0:Fs.enabled)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:t("sms.sendAfter")}),e.jsx("input",{type:"number",min:"60",step:"30",value:((Bs=(Hs=A.reminderSettings)==null?void 0:Hs.clockOut)==null?void 0:Bs.thresholdMinutes)||450,onChange:s=>Oe("clockOut","thresholdMinutes",parseInt(s.target.value)),className:"w-20 px-2 py-1 border rounded-md text-center"}),e.jsx("span",{className:"text-sm",children:t("sms.minutesHours",{hours:((((qs=(Us=A.reminderSettings)==null?void 0:Us.clockOut)==null?void 0:qs.thresholdMinutes)||450)/60).toFixed(1)})})]})]})]})]})]})}),kt&&e.jsxs("div",{className:"flex gap-3 mt-6 pt-4 border-t",children:[e.jsx("button",{onClick:ua,disabled:rt.isPending,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 font-medium",children:rt.isPending?t("buttons.saving"):t("buttons.saveSmsSettings")}),e.jsx("button",{onClick:xa,disabled:rt.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")})]})]}),An]}
1),r==="appointments"&&e.jsx("div",{className:"border rounded-lg p-6 bg-card",children:e.jsx(Pn,{})}),r==="features"&&e.jsx("div",{className:"border rounded-lg p-6 bg-card",children:e.jsx(xn,{})}),Ve&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-background rounded-lg shadow-xl max-w-md w-full p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:t("dialogs.pinReset.confirmTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("dialogs.pinReset.confirmBody")}),e.jsx("p",{className:"text-sm text-orange-600 dark:text-orange-400 mb-4",children:t("dialogs.pinReset.confirmWarning")}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>ve(!1),className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.cancel")}),e.jsx("button",{onClick:()=>We.mutate(),disabled:We.isPending,className:"px-4 py-2 bg-orange-600 text-white rounded-md hover:bg-orange-700 disabled:opacity-50",children:We.isPending?t("timeclock.resettingPins"):t("dialogs.pinReset.confirmButton")})]})]})}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-background rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("dialogs.pinReset.successTitle")}),e.jsx("p",{className:"text-muted-foreground",children:t("dialogs.pinReset.successBody",{count:O.totalReset})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("dialogs.pinReset.sharePrompt")}),e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:t("dialogs.pinReset.colEmployee")}),e.jsx("th",{className:"text-left py-2 font-medium",children:t("dialogs.pinReset.colPin")})]})}),e.jsx("tbody",{children:O.employees.map(s=>e.jsxs("tr",{className:"border-b",children:[e.jsxs("td",{className:"py-2",children:[s.lastName,", ",s.firstName]}),e.jsx("td",{className:"py-2 font-mono font-bold",children:s.newPin})]},s.id))})]})]}),e.jsxs("div",{className:"p-6 border-t flex justify-between",children:[e.jsx("button",{onClick:()=>{const s=["Last Name,First Name,PIN",...O.employees.map(X=>`${X.lastName},${X.firstName},${X.newPin}`)].join(`
2`),o=new Blob([s],{type:"text/csv"}),b=URL.createObjectURL(o),R=document.createElement("a");R.href=b;const z=new Date().toISOString().split("T")[0];R.download=`employee-pins-${z}.csv`,R.click(),URL.revokeObjectURL(b)},className:"px-4 py-2 border rounded-md hover:bg-accent",children:t("buttons.downloadCsv")}),e.jsx("button",{onClick:()=>Ke(null),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:t("buttons.done")})]})]})}),oe&&e.jsx(Mn,{position:M,onClose:()=>{W(!1),G(null)},onSuccess:()=>{K.invalidateQueries({queryKey:["positions"]}),W(!1),G(null),window.dispatchEvent(new Event("organization-updated"))}}),Ee&&e.jsx(Ln,{onClose:()=>ae(!1),onSuccess:async()=>{K.invalidateQueries({queryKey:["organizations"]}),await se.getState().fetchOrganizations(),ae(!1)}}),De&&J&&e.jsx(Rn,{organization:J,onClose:()=>{w(!1),Ae(null)},onSuccess:async()=>{K.invalidateQueries({queryKey:["organizations"]}),K.invalidateQueries({queryKey:["settings"]}),await se.getState().fetchOrganizations(),w(!1),Ae(null)}})]})}function Mn({position:t,onClose:a,onSuccess:d}){const{t:r}=Z("settings"),[p,y]=u.useState({name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||"",workType:(t==null?void 0:t.workType)||""}),[S,N]=u.useState(""),f=D({mutationFn:x=>Ue.create(x),onSuccess:d,onError:x=>{var c,m;N(((m=(c=x.response)==null?void 0:c.data)==null?void 0:m.message)||"Failed to create position")}}),l=D({mutationFn:({id:x,data:c})=>Ue.update(x,c),onSuccess:d,onError:x=>{var c,m;N(((m=(c=x.response)==null?void 0:c.data)==null?void 0:m.message)||"Failed to update position")}}),k=x=>{if(x.preventDefault(),N(""),!p.name.trim()){N("Position name is required");return}t?l.mutate({id:t.id,data:{name:p.name,description:p.description||void 0,workType:p.workType||null}}):f.mutate({name:p.name,description:p.description||void 0,workType:p.workType||void 0})};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-card border rounded-lg max-w-md w-full",children:[e.jsx("div",{className:"p-6 border-b",children:e.jsx("h3",{className:"text-xl font-semibold",children:r(t?"positions.dialog.editTitle":"positions.dialog.addTitle")})}),e.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[S&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:S}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[r("positions.dialog.nameLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:p.name,onChange:x=>y({...p,name:x.target.value}),placeholder:r("positions.dialog.namePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:r("positions.dialog.descLabel")}),e.jsx("textarea",{value:p.description,onChange:x=>y({...p,description:x.target.value}),rows:3,placeholder:r("positions.dialog.descPlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:r("positions.dialog.scheduleTypeLabel")}
2),e.jsxs("select",{value:p.workType,onChange:x=>y({...p,workType:x.target.value}),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:r("positions.dialog.scheduleNoDefault")}),e.jsx("option",{value:"FIXED",children:r("positions.dialog.scheduleFixed")}),e.jsx("option",{value:"FLEXIBLE",children:r("positions.dialog.scheduleFlexible")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("positions.dialog.scheduleTypeHint")})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{type:"submit",disabled:f.isPending||l.isPending,className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:f.isPending||l.isPending?r(t?"positions.dialog.updating":"positions.dialog.adding"):r(t?"positions.dialog.updateButton":"positions.dialog.addButton")}),e.jsx("button",{type:"button",onClick:a,disabled:f.isPending||l.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent disabled:opacity-50",children:r("buttons.cancel")})]})]})]})})}function Ln({onClose:t,onSuccess:a}){const{t:d}=Z("settings"),[r,p]=u.useState({name:"",stateCode:"",industryPresetId:"restaurant",timezone:""}),[y,S]=u.useState(""),{data:N=[]}=_({queryKey:["industry-categories"],queryFn:Ut.getIndustryCategories,staleTime:600*1e3}),f=D({mutationFn:c=>Nt.create(c),onSuccess:a,onError:c=>{var m,g;S(((g=(m=c.response)==null?void 0:m.data)==null?void 0:g.message)||"Failed to create organization")}}),l=c=>{if(c.preventDefault(),S(""),!r.name.trim()){S("Organization name is required");return}if(!r.stateCode){S("State code is required");return}if(!r.industryPresetId){S("Industry is required");return}f.mutate({name:r.name,stateCode:r.stateCode,industryPresetId:r.industryPresetId,timezone:r.timezone||void 0})},k=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"],x=["America/New_York","America/Chicago","America/Denver","America/Phoenix","America/Los_Angeles","America/Anchorage","Pacific/Honolulu"];return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-card border rounded-lg max-w-md w-full",children:[e.jsxs("div",{className:"p-6 border-b",children:[e.jsx("h3",{className:"text-xl font-semibold",children:d("dialogs.createOrg.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:d("dialogs.createOrg.subtitle")})]}),e.jsxs("form",{onSubmit:l,className:"p-6 space-y-4",children:[y&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:y}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[d("dialogs.createOrg.nameLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:r.name,onChange:c=>p({...r,name:c.target.value}),placeholder:d("dialogs.createOrg.namePlaceholder"),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[d("dialogs.createOrg.stateLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("select",{required:!0,value:r.stateCode,onChange:c=>{const m=c.target.value;p({...r,stateCode:m,timezone:Zs(m)||r.timezone})},className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:d("dialogs.createOrg.selectState")}),k.map(c=>e.jsx("option",{value:c,children:c},c))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[d("dialogs.createOrg.industryLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}
2),e.jsxs("select",{required:!0,value:r.industryPresetId,onChange:c=>p({...r,industryPresetId:c.target.value}),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:d("dialogs.createOrg.selectIndustry")}),N.map(c=>e.jsx("optgroup",{label:c.name,children:c.industries.map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))},c.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d("dialogs.createOrg.industryHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:d("dialogs.createOrg.timezoneLabel")}),e.jsxs("select",{value:r.timezone,onChange:c=>p({...r,timezone:c.target.value}),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:d("dialogs.createOrg.selectTimezone")}),x.map(c=>e.jsx("option",{value:c,children:c.replace("America/","").replace("Pacific/","").replace("_"," ")},c))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d("dialogs.createOrg.timezoneHint")})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{type:"submit",disabled:f.isPending,className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:f.isPending?d("dialogs.createOrg.creating"):d("dialogs.createOrg.createButton")}),e.jsx("button",{type:"button",onClick:t,disabled:f.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent disabled:opacity-50",children:d("buttons.cancel")})]})]})]})})}function Rn({organization:t,onClose:a,onSuccess:d}){const{t:r}=Z("settings"),[p,y]=u.useState({name:t.name,stateCode:t.stateCode,timezone:t.timezone||""}),[S,N]=u.useState(""),f=D({mutationFn:c=>Nt.update(t.id,c),onSuccess:d,onError:c=>{var m,g;N(((g=(m=c.response)==null?void 0:m.data)==null?void 0:g.message)||"Failed to update organization")}}),l=c=>{if(c.preventDefault(),N(""),!p.name.trim()){N("Organization name is required");return}if(!p.stateCode){N("State code is required");return}f.mutate({name:p.name,stateCode:p.stateCode,timezone:p.timezone||void 0})},k=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"],x=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Phoenix","America/Anchorage","Pacific/Honolulu"];return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-background border rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:r("dialogs.editOrg.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 mb-4",children:r("dialogs.editOrg.subtitle")}),S&&e.jsx("div",{className:"text-destructive text-sm mb-4 p-3 bg-destructive/10 rounded-md",children:S}),e.jsxs("form",{onSubmit:l,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[r("dialogs.editOrg.nameLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("input",{type:"text",value:p.name,onChange:c=>y({...p,name:c.target.value}),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",placeholder:r("dialogs.editOrg.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:[r("dialogs.editOrg.stateLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("select",{value:p.stateCode,onChange:c=>{const m=c.target.value;y({...p,stateCode:m,timezone:Zs(m)||p.timezone})},className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",required:!0,children:[e.jsx("option",{value:"",children:r("dialogs.editOrg.selectState")}),k.map(c=>e.jsx("option",{value:c,children:c},c))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("dialogs.editOrg.stateHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:r("dialogs.editOrg.timezoneLabel")}),e.jsxs("select",{value:p.timezone,onChange:c=>y({...p,timezone:c.target.value}),className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:r("dialogs.editOrg.selectTimezone")}),x.map(c=>e.jsx("option",{value:c,children:c.replace("America/","").replace("Pacific/","").replace("_"," ")},c))]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{type:"submit",disabled:f.isPending,className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:f.isPending?r("buttons.saving"):r("buttons.saveChanges")}
2),e.jsx("button",{type:"button",onClick:a,disabled:f.isPending,className:"px-4 py-2 border rounded-md hover:bg-accent disabled:opacity-50",children:r("buttons.cancel")})]})]})]})})}export{ki 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.