@kaitranntt/ccs 7.77.1-dev.5 → 7.77.1-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/auth/oauth-handler.d.ts +5 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +44 -1
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.d.ts +3 -0
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +13 -1
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/ui/assets/{accounts-PYdWScEG.js → accounts-BWciW_nb.js} +1 -1
- package/dist/ui/assets/{alert-dialog-C5km8Mr2.js → alert-dialog-C-oyVuIB.js} +1 -1
- package/dist/ui/assets/{api-DyqNEbc3.js → api-CE6KShct.js} +1 -1
- package/dist/ui/assets/{auth-section-bEevgiYG.js → auth-section-Batq2rqI.js} +1 -1
- package/dist/ui/assets/{backups-section-D2xYCD_5.js → backups-section-C0dn7Ket.js} +1 -1
- package/dist/ui/assets/{channels-BC2C8bYa.js → channels-CVJfKJyT.js} +1 -1
- package/dist/ui/assets/{checkbox-DgzstwxZ.js → checkbox-BWXzxH0e.js} +1 -1
- package/dist/ui/assets/{claude-extension-BcKfLTXZ.js → claude-extension-DH0ltdyv.js} +1 -1
- package/dist/ui/assets/{cliproxy-fm0VYc-7.js → cliproxy-5ZQ4DdWj.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-BjoutZZO.js → cliproxy-ai-providers-QZCa2DN7.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-lYLoiV9f.js → cliproxy-control-panel-BT1a2KtK.js} +1 -1
- package/dist/ui/assets/{codex-Bdvmcwzt.js → codex-DVC-dMzi.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BvtBhg50.js → confirm-dialog-7py4oJEQ.js} +1 -1
- package/dist/ui/assets/{copilot-D4noBxJX.js → copilot-DOe7yu8W.js} +1 -1
- package/dist/ui/assets/{cursor-CSVuplSL.js → cursor-TaT3xM-m.js} +1 -1
- package/dist/ui/assets/{droid-BU4DgcGo.js → droid-ClF_i2qJ.js} +1 -1
- package/dist/ui/assets/{globalenv-section-DpY3-sT2.js → globalenv-section-CLjnaW56.js} +1 -1
- package/dist/ui/assets/{health-DNtnCuU2.js → health-BUHx35_z.js} +1 -1
- package/dist/ui/assets/{index-PqtYNGNs.js → index-BIF0Wvld.js} +32 -32
- package/dist/ui/assets/{index-eLlSQvI4.js → index-BIgntzT5.js} +1 -1
- package/dist/ui/assets/{index-DCzk2IIO.js → index-Cv_ifcCd.js} +1 -1
- package/dist/ui/assets/{index-CMGQKWf9.js → index-Czt4jG_U.js} +1 -1
- package/dist/ui/assets/{index-CCOT49QL.js → index-D8l3dEVy.js} +1 -1
- package/dist/ui/assets/{index-BtXFodks.js → index-DCdHT0L4.js} +1 -1
- package/dist/ui/assets/{index-DVwLJ_IR.js → index-DZ9DNmxz.js} +1 -1
- package/dist/ui/assets/{logs-zi0sqSKN.js → logs-4FBxeZlN.js} +1 -1
- package/dist/ui/assets/{masked-input-BZNVruOb.js → masked-input-BUPGfXYs.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-is1EjfwJ.js → proxy-status-widget-CEVsYzZc.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-B1-yuQmO.js → raw-json-settings-editor-panel-Bx9NZXKo.js} +1 -1
- package/dist/ui/assets/{searchable-select-RdyLh0wy.js → searchable-select-CRBVpRX9.js} +1 -1
- package/dist/ui/assets/{separator-DPjqb8vr.js → separator-oLpQ8QTJ.js} +1 -1
- package/dist/ui/assets/{shared-RoP2uryw.js → shared-CDOZvFvu.js} +1 -1
- package/dist/ui/assets/{table-M-kDRvQt.js → table-CvB4g1aV.js} +1 -1
- package/dist/ui/assets/{updates-BWU5VmTL.js → updates-FB-3z9nq.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +3 -0
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as Q}from"./react-vendor-Bjx91N7w.js";import{t as j}from"./notifications-B4_o8bcr.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-PqtYNGNs.js";import{a as Te,u as ie,b as Ae}from"./tanstack-bhJxV1h8.js";import{a as Re}from"./raw-json-settings-editor-panel-B1-yuQmO.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-Ce9So20E.js";import{S as R}from"./separator-DPjqb8vr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as Q}from"./react-vendor-Bjx91N7w.js";import{t as j}from"./notifications-B4_o8bcr.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-BIF0Wvld.js";import{a as Te,u as ie,b as Ae}from"./tanstack-bhJxV1h8.js";import{a as Re}from"./raw-json-settings-editor-panel-Bx9NZXKo.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-Ce9So20E.js";import{S as R}from"./separator-oLpQ8QTJ.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
|
|
2
2
|
`)},I=(x,w)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const P={...u.value};w==null?delete P[x]:P[x]=w,L(P)},xe=u.valid?{reasoningEffort:z(u.value.reasoningEffort),autonomyLevel:z(u.value.autonomyLevel),diffMode:z(u.value.diffMode),maxTurns:J(u.value.maxTurns),maxToolCalls:J(u.value.maxToolCalls),autoCompactThreshold:J(u.value.autoCompactThreshold),todoEnabled:_(u.value.todoEnabled),todoAutoRefresh:_(u.value.todoAutoRefresh),autoCompactEnabled:_(u.value.autoCompactEnabled),soundEnabled:_(u.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},ge=u.valid?ns(u.value):[],fe=async()=>{await Promise.all([l(),t()])},pe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await c({rawText:B,expectedMtime:d?.exists?d.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(x){Ce(x)?j.error(s("droidPage.changedExternally")):j.error(x.message||s("droidPage.failedSave"))}},re=r?.byok.customModels??[],te=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((x,w)=>w[1]-x[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Me,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(i||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const x=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=x.notes??[],P=x.links??[],ne=x.providerDocs??[],je=P.length>0?P:fs,ye=ne.length>0?ne:ps,ve=x.providerValues??[],be=x.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(C,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(a=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:a.label}),a.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:a.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:a.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:ys(a.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(a.mtimeMs)}),a.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:a.parseError})}),a.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:a.readError})})]},a.label))})]}),r.warnings.length>0&&e.jsxs(y,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:xe,disabled:o||!u.valid,disabledReason:u.valid?null:`Quick settings disabled: ${u.error}`,onEnumSettingChange:(a,f)=>{I(a,f)},onBooleanSettingChange:(a,f)=>{I(a,f)},onNumberSettingChange:(a,f)=>{I(a,f)}}),e.jsx(ls,{models:ge,disabled:o||!u.valid,disabledReason:u.valid?null:`${s("droidPage.byok")}: ${u.error}`,onEffortChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const E=as(u.value,a,f);if(!E){j.error(s("droidPage.unableUpdateReasoning"));return}L(E)},onAnthropicBudgetChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const E=is(u.value,a,f);if(!E){j.error(s("droidPage.anthropicOnlyBudget"));return}L(E)}}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[te.length===0&&e.jsx(C,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),te.map(([a,f])=>e.jsxs(C,{variant:"outline",className:"font-mono text-xs",children:[a,": ",f]},a))]})]})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(b,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(A,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[re.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),re.map(a=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:a.provider}),e.jsx("p",{className:"text-muted-foreground",children:a.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:a.baseUrl,children:a.host||a.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.baseUrl})]})]},`${a.displayName}-${a.model}-${a.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(A,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((a,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",hs(a)]},`${f}-${a}`)),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:a.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},a.id))})]}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:ye.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",a.provider," | format: ",a.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},`${a.provider}-${a.url}`))})]}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:ve.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:be.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ae,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ae,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:o,parseWarning:d?.parseError,value:B,dirty:ee,saving:m,saveDisabled:!ee||m||o||!F.valid,onChange:x=>{se(x)},onSave:pe,onRefresh:fe})})]})})}export{_s as DroidPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as g}from"./react-vendor-Bjx91N7w.js";import{by as C,bz as w,a as G,bA as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as g}from"./react-vendor-Bjx91N7w.js";import{by as C,bz as w,a as G,bA as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-BIF0Wvld.js";import{R as N,w as D,x as I,at as L,a9 as T}from"./icons-Ce9So20E.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function _(){const{state:s}=C(),n=w(),[o,r]=g.useState(""),[c,m]=g.useState(""),b=g.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=g.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=g.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),m("")},[o,c,s.globalEnvConfig,i]),u=g.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:m,fetchConfig:b,saveConfig:i,addEnvVar:E,removeEnvVar:u}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:m,newEnvKey:b,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:u,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();g.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(I,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:b,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>u(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!b.trim(),className:"h-9",children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),u(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{a as u,c as l,d as x,M as C,N as E,O as k,S as m}from"./index-PqtYNGNs.js";import{r as h}from"./react-vendor-Bjx91N7w.js";import{u as _,a as A,b as O}from"./tanstack-bhJxV1h8.js";import{t as p}from"./notifications-B4_o8bcr.js";import{b7 as g,C as N,$ as v,o as w,R as b,Y as F,w as P,T as R,ai as y,_ as H}from"./icons-Ce9So20E.js";import{m as j,A as I}from"./proxy-C4-M_9kB.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function M(){return _({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function S(){const s=A();return O({mutationFn:async a=>{const t=await fetch(`/api/health/fix/${a}`,{method:"POST"}),r=await t.json();if(!t.ok)throw new Error(r.message);return r},onSuccess:a=>{s.invalidateQueries({queryKey:["health"]}),p.success(a.message)},onError:a=>{p.error(a.message)}})}const q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function z({check:s}){const{t:a}=u(),t=S(),r=q[s.status],[n,i]=h.useState(!1),o=s.details||s.fix,c=d=>{navigator.clipboard.writeText(d),p.success(a("health.copied"))};return o?e.jsx(C,{open:n,onOpenChange:i,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",n?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(E,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(N,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",n&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(v,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>s.fix&&c(s.fix),className:"h-5 w-5 p-0",children:e.jsx(w,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(x,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(g,{className:"w-3 h-3 mr-1"}),a("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(g,{className:"w-3 h-3 mr-1"}),a("health.fix")]})]})}function D(s,a){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return a("health.justNow");if(t<60)return a("health.secondsAgo",{count:t});const r=Math.floor(t/60);if(r<60)return a("health.minutesAgo",{count:r});const n=Math.floor(r/60);return a("health.hoursAgo",{count:n})}function $({summary:s,version:a,lastScan:t,isLoading:r,onRefresh:n}){const{t:i}=u(),[,o]=h.useState(0);h.useEffect(()=>{const f=setInterval(()=>o(T=>T+1),1e3);return()=>clearInterval(f)},[]);const c=()=>{navigator.clipboard.writeText("ccs doctor"),p.success(i("health.copied"))},d=s.errors>0||s.warnings>0;return e.jsxs("div",{className:l("group relative overflow-hidden rounded-2xl border transition-all duration-500",d?"bg-rose-500/5 border-rose-500/20 shadow-[0_0_20px_-12px_rgba(244,63,94,0.3)]":"bg-emerald-500/5 border-emerald-500/20 shadow-[0_0_20px_-12px_rgba(16,185,129,0.3)]"),children:[e.jsx("div",{className:l("absolute inset-0 opacity-[0.05] blur-3xl pointer-events-none transition-colors duration-1000",d?"bg-rose-500":"bg-emerald-500")}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-center gap-4 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:l("w-2.5 h-2.5 rounded-full",d?"bg-rose-500":"bg-emerald-500")}),e.jsx("div",{className:l("absolute inset-0 rounded-full animate-ping opacity-40",d?"bg-rose-500":"bg-emerald-500")})]}),e.jsx("h1",{className:"font-mono text-sm font-bold tracking-tight uppercase",children:i(d?"health.issuesDetected":"health.systemOptimal")})]}),e.jsx("div",{className:"hidden md:block h-4 w-px bg-border/50"}),e.jsxs("div",{className:"flex items-center gap-6 text-xs font-mono",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Checks"}),e.jsx("span",{children:s.total})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Passed"}),e.jsx("span",{className:"text-emerald-500",children:s.passed})]}),s.warnings>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Warnings"}),e.jsx("span",{className:"text-amber-500 font-bold",children:s.warnings})]}),s.errors>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Errors"}),e.jsx("span",{className:"text-rose-500 font-bold underline decoration-rose-500/30",children:s.errors})]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex flex-col items-end text-[10px] font-mono text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(b,{className:l("w-2.5 h-2.5",r&&"animate-spin")}),e.jsx("span",{children:t?D(t,i):"--"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 opacity-60",children:[e.jsx(F,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:a})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:c,className:"h-8 px-3 gap-2 font-mono text-[10px] bg-background/40 hover:bg-background/60 border border-border/40 rounded-full",children:[e.jsx(v,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"ccs doctor"}),e.jsx(w,{className:"w-3 h-3 opacity-40"})]}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n,disabled:r,className:"h-8 w-8 rounded-full bg-background/40 hover:bg-background/60 border border-border/40",children:e.jsx(b,{className:l("w-3.5 h-3.5",r&&"animate-spin")})})]})]})]})]})}function B({check:s}){const{t:a}=u(),t=S(),r=!!(s.details||s.fix||s.fixable),[n,i]=h.useState(!1),o=s.status==="error",c=o?P:R,d=()=>{s.fix&&(navigator.clipboard.writeText(s.fix),p.success(a("health.copied")))},f=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l("flex items-center justify-center w-12 h-12 rounded-2xl shrink-0",o?"bg-rose-500/10 text-rose-500":"bg-amber-500/10 text-amber-500"),children:e.jsx(c,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-bold tracking-tight",children:s.name}),r&&e.jsx("div",{className:"p-1 hover:bg-muted rounded-full transition-colors",children:e.jsx(N,{className:l("w-5 h-5 text-muted-foreground transition-transform",n&&"rotate-90")})})]}),e.jsx("p",{className:"text-sm font-medium leading-relaxed text-muted-foreground/80",children:s.message})]})]});return e.jsx(j.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},className:l("group relative overflow-hidden rounded-[2rem] p-px transition-all duration-300",o?"bg-gradient-to-br from-rose-500/20 via-rose-500/5 to-transparent":"bg-gradient-to-br from-amber-500/20 via-amber-500/5 to-transparent"),children:e.jsxs("div",{className:"relative h-full rounded-[calc(2rem-1px)] bg-background/80 backdrop-blur-md overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 rounded-[calc(2rem-1px)] shadow-[inset_0_1px_1px_rgba(255,255,255,0.1)] pointer-events-none"}),e.jsxs("div",{className:"p-6",children:[r?e.jsx("button",{type:"button",onClick:()=>i(!n),"aria-expanded":n,"aria-label":n?`Collapse ${s.name} details`:`Expand ${s.name} details`,className:"flex w-full select-none items-start gap-4 rounded-2xl text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",children:f}):e.jsx("div",{className:"flex w-full items-start gap-4",children:f}),e.jsx(I,{children:n&&e.jsx(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.32,.72,0,1]},className:"overflow-hidden",children:e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/40 space-y-4",children:[s.details&&e.jsx("div",{className:"rounded-xl bg-muted/30 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground break-all",children:s.details}),(s.fix||s.fixable)&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[s.fix&&e.jsxs("div",{className:"flex-1 flex items-center gap-2 h-10 px-3 rounded-full bg-background/50 border border-border/40",children:[e.jsx(v,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(x,{variant:"ghost",size:"icon",onClick:d,"aria-label":a("health.copy")??"Copy fix command",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(w,{className:"w-3 h-3"})})]}),s.fixable&&e.jsxs(x,{onClick:()=>t.mutate(s.id),disabled:t.isPending,className:l("h-10 px-6 rounded-full font-bold shadow-lg shadow-primary/20 transition-all active:scale-95",o?"bg-rose-500 hover:bg-rose-600":"bg-amber-500 hover:bg-amber-600"),children:[t.isPending?e.jsx(b,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(g,{className:"w-4 h-4 mr-2"}),a("health.applyFix")]})]})]})})})]})]})})}function K({checks:s}){const{t:a}=u();return s.length===0?null:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx("h2",{className:"text-sm font-bold tracking-widest uppercase text-muted-foreground/60",children:a("health.attentionRequired")}),e.jsx("div",{className:"h-px flex-1 bg-border/40"}),e.jsx("span",{className:"font-mono text-xs text-rose-500 font-bold",children:s.length})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:e.jsx(I,{mode:"popLayout",children:s.map(t=>e.jsx(B,{check:t},t.id))})})]})}function Q({groups:s}){const{t:a}=u();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx("h2",{className:"text-sm font-bold tracking-widest uppercase text-muted-foreground/60",children:a("health.environmentAudit")}),e.jsx("div",{className:"h-px flex-1 bg-border/40"}),e.jsx(y,{className:"w-4 h-4 text-emerald-500/60"})]}),e.jsx("div",{className:"space-y-4",children:s.map(t=>e.jsx(W,{group:t},t.id))})]})}function W({group:s}){const[a,t]=h.useState(!1),r=s.checks.filter(i=>i.status==="error"||i.status==="warning").length,n=r>0;return e.jsx(C,{open:a,onOpenChange:t,className:"group/audit",children:e.jsxs("div",{className:l("rounded-2xl border transition-all duration-300",a?"bg-muted/30 border-border/60":"bg-background hover:border-border/60"),children:[e.jsx(E,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-4 px-5 py-4 text-left",children:[e.jsx("div",{className:l("flex items-center justify-center w-8 h-8 rounded-full transition-colors",n?"bg-rose-500/10 text-rose-500":"bg-muted text-muted-foreground"),children:n?e.jsx(H,{className:"w-4 h-4"}):e.jsx(y,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-bold tracking-tight",children:s.name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground uppercase tracking-widest font-mono",children:[s.checks.length," Checks"]})]}),n&&e.jsx("div",{className:"px-2 py-0.5 rounded-full bg-rose-500/10 text-rose-500 text-[10px] font-bold font-mono",children:r}),e.jsx(N,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-300",a&&"rotate-90")})]})}),e.jsx(k,{children:e.jsx("div",{className:"px-5 pb-5 space-y-1",children:s.checks.map(i=>e.jsx(z,{check:i},i.id))})})]})})}function L(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-12",children:[e.jsx(m,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"space-y-16",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(m,{className:"h-4 w-48"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(m,{className:"h-40 rounded-[2rem]"}),e.jsx(m,{className:"h-40 rounded-[2rem]"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{className:"h-4 w-48"}),[1,2,3].map(s=>e.jsx(m,{className:"h-16 rounded-2xl"},s))]})]})]})}function te(){const{t:s}=u(),{data:a,isLoading:t,refetch:r,dataUpdatedAt:n}=M();if(t&&!a)return e.jsx(L,{});const i=a?.checks.filter(c=>c.status==="error"||c.status==="warning")??[],o=i.length>0;return e.jsxs("div",{className:"relative pb-20 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[e.jsx("div",{className:l("absolute top-[5%] -left-[5%] w-[60%] h-[60%] blur-[100px] rounded-full opacity-[0.08] transition-colors duration-1000",o?"bg-rose-500":"bg-emerald-500")}),e.jsx("div",{className:l("absolute -bottom-[5%] -right-[5%] w-[50%] h-[50%] blur-[100px] rounded-full opacity-[0.06] transition-colors duration-1000",o?"bg-amber-500":"bg-blue-500")}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E")`}})]}),e.jsxs("div",{className:"relative p-6 max-w-6xl mx-auto space-y-12",children:[a&&e.jsx($,{summary:a.summary,version:a.version,lastScan:n,isLoading:t,onRefresh:r}),e.jsxs("div",{className:"space-y-16",children:[o?e.jsx(K,{checks:i}):e.jsxs(j.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:"py-20 flex flex-col items-center text-center space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 rounded-[2.5rem] bg-emerald-500/10 flex items-center justify-center",children:e.jsx(y,{className:"w-12 h-12 text-emerald-500"})}),e.jsx("div",{className:"absolute inset-0 w-24 h-24 rounded-[2.5rem] bg-emerald-500/20 animate-ping opacity-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:s("health.allSystemsClear")}),e.jsx("p",{className:"text-muted-foreground max-w-[40ch] mx-auto",children:s("health.optimalStateDesc")})]})]}),a?.groups&&e.jsx(Q,{groups:a.groups})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 text-[10px] uppercase tracking-widest font-mono text-muted-foreground/60 border-t border-border/40 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"opacity-50",children:"Build"}),e.jsx("span",{className:"text-foreground",children:a?.version??"--"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"opacity-50",children:"Platform"}),e.jsx("span",{className:"text-foreground",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 rounded-full bg-muted/30 border border-border/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})]})}export{te as HealthPage};
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{a as u,c as l,d as x,M as C,N as E,O as k,S as m}from"./index-BIF0Wvld.js";import{r as h}from"./react-vendor-Bjx91N7w.js";import{u as _,a as A,b as O}from"./tanstack-bhJxV1h8.js";import{t as p}from"./notifications-B4_o8bcr.js";import{b7 as g,C as N,$ as v,o as w,R as b,Y as F,w as P,T as R,ai as y,_ as H}from"./icons-Ce9So20E.js";import{m as j,A as I}from"./proxy-C4-M_9kB.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function M(){return _({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function S(){const s=A();return O({mutationFn:async a=>{const t=await fetch(`/api/health/fix/${a}`,{method:"POST"}),r=await t.json();if(!t.ok)throw new Error(r.message);return r},onSuccess:a=>{s.invalidateQueries({queryKey:["health"]}),p.success(a.message)},onError:a=>{p.error(a.message)}})}const q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function z({check:s}){const{t:a}=u(),t=S(),r=q[s.status],[n,i]=h.useState(!1),o=s.details||s.fix,c=d=>{navigator.clipboard.writeText(d),p.success(a("health.copied"))};return o?e.jsx(C,{open:n,onOpenChange:i,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",n?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(E,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(N,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",n&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(v,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>s.fix&&c(s.fix),className:"h-5 w-5 p-0",children:e.jsx(w,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(x,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(g,{className:"w-3 h-3 mr-1"}),a("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(g,{className:"w-3 h-3 mr-1"}),a("health.fix")]})]})}function D(s,a){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return a("health.justNow");if(t<60)return a("health.secondsAgo",{count:t});const r=Math.floor(t/60);if(r<60)return a("health.minutesAgo",{count:r});const n=Math.floor(r/60);return a("health.hoursAgo",{count:n})}function $({summary:s,version:a,lastScan:t,isLoading:r,onRefresh:n}){const{t:i}=u(),[,o]=h.useState(0);h.useEffect(()=>{const f=setInterval(()=>o(T=>T+1),1e3);return()=>clearInterval(f)},[]);const c=()=>{navigator.clipboard.writeText("ccs doctor"),p.success(i("health.copied"))},d=s.errors>0||s.warnings>0;return e.jsxs("div",{className:l("group relative overflow-hidden rounded-2xl border transition-all duration-500",d?"bg-rose-500/5 border-rose-500/20 shadow-[0_0_20px_-12px_rgba(244,63,94,0.3)]":"bg-emerald-500/5 border-emerald-500/20 shadow-[0_0_20px_-12px_rgba(16,185,129,0.3)]"),children:[e.jsx("div",{className:l("absolute inset-0 opacity-[0.05] blur-3xl pointer-events-none transition-colors duration-1000",d?"bg-rose-500":"bg-emerald-500")}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-center gap-4 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:l("w-2.5 h-2.5 rounded-full",d?"bg-rose-500":"bg-emerald-500")}),e.jsx("div",{className:l("absolute inset-0 rounded-full animate-ping opacity-40",d?"bg-rose-500":"bg-emerald-500")})]}),e.jsx("h1",{className:"font-mono text-sm font-bold tracking-tight uppercase",children:i(d?"health.issuesDetected":"health.systemOptimal")})]}),e.jsx("div",{className:"hidden md:block h-4 w-px bg-border/50"}),e.jsxs("div",{className:"flex items-center gap-6 text-xs font-mono",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Checks"}),e.jsx("span",{children:s.total})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Passed"}),e.jsx("span",{className:"text-emerald-500",children:s.passed})]}),s.warnings>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Warnings"}),e.jsx("span",{className:"text-amber-500 font-bold",children:s.warnings})]}),s.errors>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-muted-foreground uppercase text-[10px] tracking-widest",children:"Errors"}),e.jsx("span",{className:"text-rose-500 font-bold underline decoration-rose-500/30",children:s.errors})]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex flex-col items-end text-[10px] font-mono text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(b,{className:l("w-2.5 h-2.5",r&&"animate-spin")}),e.jsx("span",{children:t?D(t,i):"--"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 opacity-60",children:[e.jsx(F,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:a})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:c,className:"h-8 px-3 gap-2 font-mono text-[10px] bg-background/40 hover:bg-background/60 border border-border/40 rounded-full",children:[e.jsx(v,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"ccs doctor"}),e.jsx(w,{className:"w-3 h-3 opacity-40"})]}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n,disabled:r,className:"h-8 w-8 rounded-full bg-background/40 hover:bg-background/60 border border-border/40",children:e.jsx(b,{className:l("w-3.5 h-3.5",r&&"animate-spin")})})]})]})]})]})}function B({check:s}){const{t:a}=u(),t=S(),r=!!(s.details||s.fix||s.fixable),[n,i]=h.useState(!1),o=s.status==="error",c=o?P:R,d=()=>{s.fix&&(navigator.clipboard.writeText(s.fix),p.success(a("health.copied")))},f=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l("flex items-center justify-center w-12 h-12 rounded-2xl shrink-0",o?"bg-rose-500/10 text-rose-500":"bg-amber-500/10 text-amber-500"),children:e.jsx(c,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-bold tracking-tight",children:s.name}),r&&e.jsx("div",{className:"p-1 hover:bg-muted rounded-full transition-colors",children:e.jsx(N,{className:l("w-5 h-5 text-muted-foreground transition-transform",n&&"rotate-90")})})]}),e.jsx("p",{className:"text-sm font-medium leading-relaxed text-muted-foreground/80",children:s.message})]})]});return e.jsx(j.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},className:l("group relative overflow-hidden rounded-[2rem] p-px transition-all duration-300",o?"bg-gradient-to-br from-rose-500/20 via-rose-500/5 to-transparent":"bg-gradient-to-br from-amber-500/20 via-amber-500/5 to-transparent"),children:e.jsxs("div",{className:"relative h-full rounded-[calc(2rem-1px)] bg-background/80 backdrop-blur-md overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 rounded-[calc(2rem-1px)] shadow-[inset_0_1px_1px_rgba(255,255,255,0.1)] pointer-events-none"}),e.jsxs("div",{className:"p-6",children:[r?e.jsx("button",{type:"button",onClick:()=>i(!n),"aria-expanded":n,"aria-label":n?`Collapse ${s.name} details`:`Expand ${s.name} details`,className:"flex w-full select-none items-start gap-4 rounded-2xl text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",children:f}):e.jsx("div",{className:"flex w-full items-start gap-4",children:f}),e.jsx(I,{children:n&&e.jsx(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.32,.72,0,1]},className:"overflow-hidden",children:e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/40 space-y-4",children:[s.details&&e.jsx("div",{className:"rounded-xl bg-muted/30 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground break-all",children:s.details}),(s.fix||s.fixable)&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[s.fix&&e.jsxs("div",{className:"flex-1 flex items-center gap-2 h-10 px-3 rounded-full bg-background/50 border border-border/40",children:[e.jsx(v,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(x,{variant:"ghost",size:"icon",onClick:d,"aria-label":a("health.copy")??"Copy fix command",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:e.jsx(w,{className:"w-3 h-3"})})]}),s.fixable&&e.jsxs(x,{onClick:()=>t.mutate(s.id),disabled:t.isPending,className:l("h-10 px-6 rounded-full font-bold shadow-lg shadow-primary/20 transition-all active:scale-95",o?"bg-rose-500 hover:bg-rose-600":"bg-amber-500 hover:bg-amber-600"),children:[t.isPending?e.jsx(b,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(g,{className:"w-4 h-4 mr-2"}),a("health.applyFix")]})]})]})})})]})]})})}function K({checks:s}){const{t:a}=u();return s.length===0?null:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx("h2",{className:"text-sm font-bold tracking-widest uppercase text-muted-foreground/60",children:a("health.attentionRequired")}),e.jsx("div",{className:"h-px flex-1 bg-border/40"}),e.jsx("span",{className:"font-mono text-xs text-rose-500 font-bold",children:s.length})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:e.jsx(I,{mode:"popLayout",children:s.map(t=>e.jsx(B,{check:t},t.id))})})]})}function Q({groups:s}){const{t:a}=u();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx("h2",{className:"text-sm font-bold tracking-widest uppercase text-muted-foreground/60",children:a("health.environmentAudit")}),e.jsx("div",{className:"h-px flex-1 bg-border/40"}),e.jsx(y,{className:"w-4 h-4 text-emerald-500/60"})]}),e.jsx("div",{className:"space-y-4",children:s.map(t=>e.jsx(W,{group:t},t.id))})]})}function W({group:s}){const[a,t]=h.useState(!1),r=s.checks.filter(i=>i.status==="error"||i.status==="warning").length,n=r>0;return e.jsx(C,{open:a,onOpenChange:t,className:"group/audit",children:e.jsxs("div",{className:l("rounded-2xl border transition-all duration-300",a?"bg-muted/30 border-border/60":"bg-background hover:border-border/60"),children:[e.jsx(E,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-4 px-5 py-4 text-left",children:[e.jsx("div",{className:l("flex items-center justify-center w-8 h-8 rounded-full transition-colors",n?"bg-rose-500/10 text-rose-500":"bg-muted text-muted-foreground"),children:n?e.jsx(H,{className:"w-4 h-4"}):e.jsx(y,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-bold tracking-tight",children:s.name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground uppercase tracking-widest font-mono",children:[s.checks.length," Checks"]})]}),n&&e.jsx("div",{className:"px-2 py-0.5 rounded-full bg-rose-500/10 text-rose-500 text-[10px] font-bold font-mono",children:r}),e.jsx(N,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-300",a&&"rotate-90")})]})}),e.jsx(k,{children:e.jsx("div",{className:"px-5 pb-5 space-y-1",children:s.checks.map(i=>e.jsx(z,{check:i},i.id))})})]})})}function L(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-12",children:[e.jsx(m,{className:"h-20 w-full rounded-2xl"}),e.jsxs("div",{className:"space-y-16",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(m,{className:"h-4 w-48"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(m,{className:"h-40 rounded-[2rem]"}),e.jsx(m,{className:"h-40 rounded-[2rem]"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{className:"h-4 w-48"}),[1,2,3].map(s=>e.jsx(m,{className:"h-16 rounded-2xl"},s))]})]})]})}function te(){const{t:s}=u(),{data:a,isLoading:t,refetch:r,dataUpdatedAt:n}=M();if(t&&!a)return e.jsx(L,{});const i=a?.checks.filter(c=>c.status==="error"||c.status==="warning")??[],o=i.length>0;return e.jsxs("div",{className:"relative pb-20 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[e.jsx("div",{className:l("absolute top-[5%] -left-[5%] w-[60%] h-[60%] blur-[100px] rounded-full opacity-[0.08] transition-colors duration-1000",o?"bg-rose-500":"bg-emerald-500")}),e.jsx("div",{className:l("absolute -bottom-[5%] -right-[5%] w-[50%] h-[50%] blur-[100px] rounded-full opacity-[0.06] transition-colors duration-1000",o?"bg-amber-500":"bg-blue-500")}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E")`}})]}),e.jsxs("div",{className:"relative p-6 max-w-6xl mx-auto space-y-12",children:[a&&e.jsx($,{summary:a.summary,version:a.version,lastScan:n,isLoading:t,onRefresh:r}),e.jsxs("div",{className:"space-y-16",children:[o?e.jsx(K,{checks:i}):e.jsxs(j.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:"py-20 flex flex-col items-center text-center space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-24 h-24 rounded-[2.5rem] bg-emerald-500/10 flex items-center justify-center",children:e.jsx(y,{className:"w-12 h-12 text-emerald-500"})}),e.jsx("div",{className:"absolute inset-0 w-24 h-24 rounded-[2.5rem] bg-emerald-500/20 animate-ping opacity-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:s("health.allSystemsClear")}),e.jsx("p",{className:"text-muted-foreground max-w-[40ch] mx-auto",children:s("health.optimalStateDesc")})]})]}),a?.groups&&e.jsx(Q,{groups:a.groups})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 text-[10px] uppercase tracking-widest font-mono text-muted-foreground/60 border-t border-border/40 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"opacity-50",children:"Build"}),e.jsx("span",{className:"text-foreground",children:a?.version??"--"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"opacity-50",children:"Platform"}),e.jsx("span",{className:"text-foreground",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 rounded-full bg-muted/30 border border-border/40",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})]})}export{te as HealthPage};
|