PageSourceSearch

https://datahub-pro-production.up.railway.app/assets/AISettings-D0X3JFTk.js

js datahub-pro-production.up.railway.app collected 2026-10-03 12:13:35 UTC 8,034 bytes, 1 lines download raw bytes

1import{r as i,as as C,j as e,x as W}from"./index-BACUqBz4.js";const P={"claude-haiku-4-5":"Claude Haiku 4.5"},z=[{value:"client",label:"Client"},{value:"board",label:"Board"},{value:"team",label:"Team"}],U=[{value:"executive",label:"Executive"},{value:"analyst",label:"Analyst"},{value:"storyteller",label:"Storyteller"},{value:"plain",label:"Plain"}],O=z,Y=[{value:"zscore",label:"Z-Score"},{value:"iqr",label:"IQR (Tukey)"}],F=["default_narrative_audience","default_narrative_tone","default_report_audience","default_forecast_periods","anomaly_method","decimal_places","currency"];function G(){const[c,v]=i.useState(!0),[u,f]=i.useState(""),[l,p]=i.useState(!1),[h,j]=i.useState("claude-haiku-4-5"),[N,T]=i.useState(""),[A,B]=i.useState(null),[n,S]=i.useState(null),[m,w]=i.useState(!1),[k,y]=i.useState(!1),[I,_]=i.useState("");i.useEffect(()=>{let t=!1;return v(!0),f(""),p(!1),C.getSettings().then(a=>{if(t)return;const r=a.data||{};j(r.model||"claude-haiku-4-5"),T(r.plan||""),B(r.ai_quota||null),S(r.settings||{})}).catch(a=>{var r,o,x;t||(((r=a==null?void 0:a.response)==null?void 0:r.status)===403?p(!0):f(((x=(o=a==null?void 0:a.response)==null?void 0:o.data)==null?void 0:x.detail)||a.message||"Failed to load AI settings"))}).finally(()=>{t||v(!1)}),()=>{t=!0}},[]);function g(t,a){S(r=>({...r,[t]:a})),y(!1),_("")}async function D(){var a,r,o,x;if(!n)return;w(!0),y(!1),_("");const t={};for(const s of F)n[s]!==void 0&&(t[s]=n[s]);try{const E=(a=(await C.saveSettings(t)).data)==null?void 0:a.settings;E&&S(E),y(!0),setTimeout(()=>y(!1),2500)}catch(s){((r=s==null?void 0:s.response)==null?void 0:r.status)===403?p(!0):_(((x=(o=s==null?void 0:s.response)==null?void 0:o.data)==null?void 0:x.detail)||s.message||"Failed to save settings")}finally{w(!1)}}const R=({title:t,children:a})=>e.jsxs("div",{style:{background:"var(--bg-raised)",borderRadius:12,padding:20,boxShadow:"var(--elev-1)",marginBottom:20},children:[e.jsx("div",{style:{fontWeight:700,color:"var(--fg-primary)",marginBottom:16,fontSize:"1rem",borderBottom:"1px solid var(--border-subtle)",paddingBottom:10},children:t}),a]}),d=({label:t,desc:a,children:r})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 0",borderBottom:"1px solid var(--border-subtle)",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,color:"var(--fg-secondary)",fontSize:"0.875rem"},children:t}),a&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--fg-tertiary)",marginTop:2},children:a})]}),e.jsx("div",{children:r})]}),M={padding:"8px 12px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.875rem",background:"var(--bg-raised)",color:"var(--fg-primary)"},b=({value:t,onChange:a,options:r})=>e.jsx("select",{value:t??"",onChange:o=>a(o.target.value),style:M,children:r.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))}),L=P[h]||h;return e.jsxs(W,{width:800,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:24,gap:16},children:[e.jsxs("div",{children:[e.jsx("h1",{className:"v3-page__title",style:{margin:"0 0 4px"},children:"AI Settings"}),e.jsx("p",{style:{margin:0,color:"var(--fg-tertiary)"},children:"Your AI plan, usage, and analysis defaults"})]}),!c&&!l&&n&&e.jsx("button",{onClick:D,disabled:m,style:{padding:"9px 24px",background:k?"#10b981":"#e91e8c",color:"#fff",border:"none",borderRadius:8,fontWeight:700,cursor:m?"wait":"pointer",transition:"background 0.3s",opacity:m?.8:1,whiteSpace:"nowrap"},children:m?"Saving…":k?"✓ Saved":"Save Changes"})]}),c&&e.jsx("div",{style:{background:"var(--bg-raised)",borderRadius:12,padding:40,textAlign:"center",color:"var(--fg-tertiary)",boxShadow:"var(--elev-1)"},children:"Loading your AI settings…"}),!c&&l&&e.jsx("div",{style:{background:"#fffbeb",border:"1px solid #fcd34d",color:"#92400e",padding:"16px 18px",borderRadius:12,fontSize:"0.9rem",lineHeight:1.5},children:"AI is not enabled on this workspace. Ask your organisation owner to enable the AI add-on to configure these settings."}),!c&&!l&&u&&e.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#991b1b",padding:"12px 16px",borderRadius:8,marginBottom:16,fontSize:"0.85rem"},children:u}),!c&&!l&&n&&e.jsxs(e.Fragment,{children:[I&&e.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#991b1b",padding:"12px 16px",borderRadius:8,marginBottom:16,fontSize:"0.85rem"},children:I}),e.jsxs(R,{title:"Model & plan",children:[e.jsx(d,{label:"Model",desc:"The model powering every AI feature on your workspace",children:e.jsx("span",{style:{fontWeight:700,color:"var(--fg-primary)",fontSize:"0.9rem"},children:L})}),e.jsx(d,{label:"Plan",desc:"Your current subscription tier",children:e.jsx("span",{style:{padding:"3px 12px",background:"var(--bg-tint-brand)",color:"var(--fg-brand)",borderRadius:999,fontSize:"0.78rem",fontWeight:700,textTransform:"capitalize"},children:N||"—"})}),A&&e.jsx(H,{quota:A})]}),e.jsxs(R,{title:"Defaults",children:[e.jsx(d,{label:"Narrative audience",desc:"Default reader for AI narratives",children:e.jsx(b,{value:n.default_narrative_audience,onChange:t=>g("default_narrative_audience",t),options:z})}),e.jsx(d,{label:"Narrative tone",desc:"Default writing style for AI narratives",children:e.jsx(b,{value:n.default_narrative_tone,onChange:t=>g("default_narrative_tone",t),options:U})}),e.jsx(d,{label:"Report audience",desc:"Default reader for auto-generated reports",children:e.jsx(b,{value:n.default_report_audience,onChange:t=>g("default_report_audience",t),options:O})}),e.jsx(d,{label:"Forecast periods",desc:"Default number of periods to project (1–48)",children:e.jsx("input",{type:"number",min:1,max:48,value:n.default_forecast_periods??12,onChange:t=>{let a=parseInt(t.target.value,10);Number.isNaN(a)&&(a=12),a=Math.max(1,Math.min(48,a)),g("default_forecast_periods",a)},style:{width:80,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.875rem",background:"var(--bg-raised)",color:"var(--fg-primary)"}})}),e.jsx(d,{label:"Anomaly method",desc:"Default outlier-detection method",children:e.jsx(b,{value:n.anomaly_method,onChange:t=>g("anomaly_method",t),options:Y})}),e.jsx(d,{label:"Decimal places",desc:"How many decimals to show in AI output (0–6)",children:e.jsx(b,{value:String(n.decimal_places??2),onChange:t=>g("decimal_places",parseInt(t,10)),options:[0,1,2,3,4,5,6].map(t=>({value:String(t),label:String(t)}))})}
1),e.jsx(d,{label:"Currency",desc:"Currency code used when formatting money (e.g. GBP, USD, EUR)",children:e.jsx("input",{type:"text",value:n.currency??"",onChange:t=>g("currency",t.target.value.toUpperCase().slice(0,6)),placeholder:"GBP",style:{width:90,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.875rem",textTransform:"uppercase",background:"var(--bg-raised)",color:"var(--fg-primary)"}})})]})]})]})}function H({quota:c}){const{used:v,limit:u,period:f}=c,l=u==null,p=f==="day"?"today":f==="month"?"this month":f||"",h=l||!u?0:Math.min(100,Math.round(v/u*100)),j=!l&&h>=80;return e.jsxs("div",{style:{padding:"14px 0 4px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:8},children:[e.jsxs("div",{style:{fontWeight:600,color:"var(--fg-secondary)",fontSize:"0.875rem"},children:["AI usage ",p&&e.jsxs("span",{style:{color:"var(--fg-tertiary)",fontWeight:500},children:["· ",p]})]}),e.jsxs("div",{style:{fontSize:"0.85rem",fontWeight:700,color:"var(--fg-primary)"},children:[v," / ",l?"Unlimited":u]})]}),!l&&e.jsx("div",{style:{height:8,borderRadius:4,background:"var(--bg-sunken)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${h}%`,background:j?"linear-gradient(90deg,#f59e0b,#ef4444)":"linear-gradient(90deg,#e91e8c,#06b6d4)",transition:"width 0.4s ease"}})}),l&&e.jsx("div",{style:{fontSize:"0.78rem",color:"var(--fg-tertiary)"},children:"You have unlimited AI calls on this plan."})]})}export{G 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.