1import{u as I,r as m,j as e}from"./react-vendor-xjz46aeH.js";import{J as M,bm as T,bn as O,j as A,L as C,x as D,aP as P,S as _,F as j,B as S,P as U,C as z,aO as B,bo as F}from"./index-DB-GErVi.js";import{C as N}from"./Card-B1YLK7F3.js";import{S as E}from"./SearchableSelect-DyTTeEMu.js";import{E as L}from"./ErrorState-DlvwccLP.js";import{u as $}from"./useOrganizationMutations-BGnMJIKk.js";import{u as k,a as V,s as H,f as Y,C as G,i as J}from"./useCapturePolicy-DOlJyJv-.js";import"./tanstack-vendor-CK-H18W-.js";import"./sentry-vendor-B7Zxq--p.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"53c0c37b9d0458a05694e8ed0430da9c4ec6eaca"};var i=new s.Error().stack;i&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[i]="6f1dd941-8bea-4761-a5be-35156e8420b4",s._sentryDebugIdIdentifier="sentry-dbid-6f1dd941-8bea-4761-a5be-35156e8420b4")}catch{}})();function Z({canUpdate:s,orgId:i}){const{mode:p,explicit:h,policies:b,truncated:a,isLoading:x,isError:c}=k(),l=V(),v=I(),{data:t}=M(),{byAccount:f,allLoaded:d}=T(m.useMemo(()=>(t??[]).map(u=>u?.cloudAccountId),[t])),n=m.useMemo(()=>d&&t?.length?H(t,f):null,[d,t,f]),o=Y(b),g=a?"Your cost source settings could not be read in full, so this setting cannot be shown safely. Reload to try again, or contact support if it persists.":"Could not read the current cost capture setting.";return e.jsx(G,{value:p,notice:!h&&!x&&!a&&!c?J():"",onChange:u=>l.mutate({mode:u,existingId:o?.id,orgId:i}),disabled:!s||x,pending:l.isPending,unavailable:a||c,unavailableReason:g,coverage:n,onFixPermissions:()=>v("../cloud-accounts")})}const q=B.map(s=>({value:s,label:`${s} (${P(s)})`})),K=F.map(s=>({value:s.code,label:`${s.code} â ${s.symbol} ${s.name}`}));function re(){const{data:s,isLoading:i,isError:p,error:h,refetch:b}=O(),a=$(),x=A(U.ORGANISATION_UPDATE),c=s?.settings?.timezone,l=s?.settings?.currency,[v,t]=m.useState(null),[f,d]=m.useState(null),n=v??c??C(),o=f??l??"USD",g=m.useMemo(()=>n!==(c??C())||o!==(l??"USD"),[n,o,c,l]),u=D(o),w=P(n);function R(){const r={...s?.settings??{}};delete r.default_dashboard,a.mutate({name:s.name,settings:{...r,timezone:n,currency:o}},{onSuccess:()=>{z.success("Preferences saved"),t(null),d(null)},onError:y=>z.error(y.message||"Failed to save preferences")})}return i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_,{})}):p?e.jsx(L,{title:"Failed to load preferences",error:h,onRetry:b,resource:"preferences"}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(N,{children:[e.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-4",children:"Display Preferences"}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs(j,{label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4 text-text-muted",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 000-1.5h-3.25V5z",clipRule:"evenodd"})}),"Timezone"]}),children:[e.jsx(E,{options:q,value:n,onChange:r=>t(r.target.value),placeholder:"Search timezone..."}),e.jsxs("p",{className:"text-xs text-text-muted mt-1.5",children:["Dates shown in: ",n," (",w,")"]})]}),e.jsxs(j,{label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4 text-text-muted",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M1 4a1 1 0 011-1h16a1 1 0 011 1v8a1 1 0 01-1 1H2a1 1 0 01-1-1V4zm12 4a3 3 0 11-6 0 3 3 0 016 0zM4 9a1 1 0 100-2 1 1 0 000 2zm13-1a1 1 0 11-2 0 1 1 0 012 0zM1.75 14.5a.75.75 0 000 1.5c4.417 0 8.693.603 12.75 1.73 1.111.309 2.251-.472 2.251-1.63V14.5H1.75z",clipRule:"evenodd"})}),"Currency"]}),children:[e.jsx(E,{options:K,value:o,onChange:r=>d(r.target.value),placeholder:"Search currency..."}),e.jsxs("p",{className:"text-xs text-text-muted mt-1.5",children:["Costs shown in: ",u.symbol," ",u.name]})]})]}),e.jsx("p",{className:"text-xs text-text-muted mt-4",children:"Timezone affects date display only. Schedules use their own timezone."}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(S,{size:"sm",onClick:R,disabled:!g||a.isPending,children:a.isPending?"Saving...":"Save"}),g&&e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{t(null),d(null)},children:"Cancel"})]})]}),e.jsxs(N,{children:[e.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-1",children:"Cost Preferences"}),e.jsx("p",{className:"text-xs text-text-muted mb-4",children:"Choose where your cost numbers come from."}),e.jsx(Z,{canUpdate:x,orgId:s?.id})]})]})}export{re 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.