@georgedong32/ccs 7.67.0 → 7.67.1
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/.claude/settings.local.json +5 -1
- package/dist/commands/command-catalog.d.ts +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +1 -0
- package/dist/commands/cursor-command-display.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +41 -0
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/cursor-usage-display.d.ts +29 -0
- package/dist/commands/cursor-usage-display.d.ts.map +1 -0
- package/dist/commands/cursor-usage-display.js +107 -0
- package/dist/commands/cursor-usage-display.js.map +1 -0
- package/dist/cursor/constants.d.ts +1 -1
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +1 -0
- package/dist/cursor/constants.js.map +1 -1
- package/dist/ui/assets/accounts-DhtktAIG.js +1 -0
- package/dist/ui/assets/{alert-dialog-DudTubF8.js → alert-dialog-DQK2Jxfk.js} +1 -1
- package/dist/ui/assets/api-Den1YY2d.js +4 -0
- package/dist/ui/assets/{auth-section-CHSm0Pb6.js → auth-section-BQitOLMK.js} +1 -1
- package/dist/ui/assets/{backups-section-wajt9dzX.js → backups-section-BLGK5re-.js} +1 -1
- package/dist/ui/assets/{channels-CHran6QE.js → channels-Dop1axTi.js} +1 -1
- package/dist/ui/assets/{checkbox-DvR--eRI.js → checkbox-DDrDuGxi.js} +1 -1
- package/dist/ui/assets/claude-extension-6WjTc0o8.js +1 -0
- package/dist/ui/assets/cliproxy-Ch7RdSMG.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-CjKicdzR.js → cliproxy-ai-providers-DjybBlb5.js} +7 -7
- package/dist/ui/assets/{cliproxy-control-panel-Dw9Q1OoX.js → cliproxy-control-panel-DDif_QAT.js} +1 -1
- package/dist/ui/assets/{codex-D3mdE9ZJ.js → codex-DFAV50Ee.js} +4 -4
- package/dist/ui/assets/{confirm-dialog-C5COcZYh.js → confirm-dialog-CP26_Zko.js} +1 -1
- package/dist/ui/assets/copilot-uZuyhqwv.js +3 -0
- package/dist/ui/assets/cursor-CuaM2FmN.js +1 -0
- package/dist/ui/assets/{droid-BRV6w--c.js → droid-DdjXJ2lF.js} +1 -1
- package/dist/ui/assets/{globalenv-section-D3NP1kLr.js → globalenv-section-D5_-EIlf.js} +1 -1
- package/dist/ui/assets/{health-D9LnJ4lp.js → health-BHhVKLNR.js} +1 -1
- package/dist/ui/assets/{icons-DhBsHU-U.js → icons-CQ3MLSan.js} +1 -1
- package/dist/ui/assets/{index-BCpf7__M.js → index-B8bAYHAs.js} +1 -1
- package/dist/ui/assets/{index-BYrPCHr6.js → index-Ba-43jCS.js} +1 -1
- package/dist/ui/assets/{index-A9ZK234F.js → index-Bm09kGOw.js} +1 -1
- package/dist/ui/assets/{index-DtD1WuHr.js → index-DHY37v8a.js} +1 -1
- package/dist/ui/assets/index-DLCFe4s3.js +1 -0
- package/dist/ui/assets/{index-CKNvmYLR.js → index-TSYtCr3K.js} +20 -20
- package/dist/ui/assets/{masked-input-CcbDAxug.js → masked-input-CTkIqCMg.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-DhIJtL48.js → proxy-status-widget-DPhKjJFl.js} +1 -1
- package/dist/ui/assets/{radix-ui-Zb8sVEtn.js → radix-ui-BlliRfHq.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-BJetiLxV.js → raw-json-settings-editor-panel-DQr_y0E4.js} +1 -1
- package/dist/ui/assets/{searchable-select-DNmazsgI.js → searchable-select-C2sP7JW5.js} +1 -1
- package/dist/ui/assets/{separator-vdIGU0ab.js → separator-2lt47Sla.js} +1 -1
- package/dist/ui/assets/{shared-IFLNQqyt.js → shared-DPKtsiFQ.js} +1 -1
- package/dist/ui/assets/{table-C8wlucHc.js → table-DbsFACgT.js} +1 -1
- package/dist/ui/assets/{tanstack-DWm6aJ-G.js → tanstack-BjiH4QZq.js} +1 -1
- package/dist/ui/assets/updates-C5iL4KNn.js +1 -0
- package/dist/ui/index.html +4 -4
- package/dist/web-server/model-pricing.d.ts.map +1 -1
- package/dist/web-server/model-pricing.js +18 -0
- package/dist/web-server/model-pricing.js.map +1 -1
- package/dist/web-server/usage/aggregator.d.ts.map +1 -1
- package/dist/web-server/usage/aggregator.js +98 -0
- package/dist/web-server/usage/aggregator.js.map +1 -1
- package/dist/web-server/usage/cursor-csv-parser.d.ts +68 -0
- package/dist/web-server/usage/cursor-csv-parser.d.ts.map +1 -0
- package/dist/web-server/usage/cursor-csv-parser.js +238 -0
- package/dist/web-server/usage/cursor-csv-parser.js.map +1 -0
- package/dist/web-server/usage/cursor-data-store.d.ts +55 -0
- package/dist/web-server/usage/cursor-data-store.d.ts.map +1 -0
- package/dist/web-server/usage/cursor-data-store.js +240 -0
- package/dist/web-server/usage/cursor-data-store.js.map +1 -0
- package/dist/web-server/usage/handlers.d.ts +13 -0
- package/dist/web-server/usage/handlers.d.ts.map +1 -1
- package/dist/web-server/usage/handlers.js +105 -1
- package/dist/web-server/usage/handlers.js.map +1 -1
- package/dist/web-server/usage/routes.d.ts.map +1 -1
- package/dist/web-server/usage/routes.js +13 -0
- package/dist/web-server/usage/routes.js.map +1 -1
- package/package.json +3 -1
- package/dist/ui/assets/accounts-Cvu7FuLd.js +0 -1
- package/dist/ui/assets/api-B_SQnrmH.js +0 -4
- package/dist/ui/assets/claude-extension-EUfubgK-.js +0 -1
- package/dist/ui/assets/cliproxy-CMcQRlMQ.js +0 -3
- package/dist/ui/assets/copilot-C_bkjtNE.js +0 -3
- package/dist/ui/assets/cursor-CwFdpjUZ.js +0 -1
- package/dist/ui/assets/index-B8R9vAE9.js +0 -1
- package/dist/ui/assets/updates-BtnxoQcx.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{b1 as w,b2 as Pe,B as S,d as N,a as ie,U as ne,v as H,L as T,ay as X,I as ce,p as ke,q as Fe,r as Te,s as Me,t as Y,w as he,b3 as Le,S as b,b4 as Re,b5 as Ae,b6 as Oe,O as Ee,Q as qe,R as Z,b7 as _e,c as se}from"./index-CKNvmYLR.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as q,b as M}from"./tanstack-DWm6aJ-G.js";import{C as Ie}from"./confirm-dialog-C5COcZYh.js";import{R as ge,L as fe,an as Ke,a6 as Qe,Z as de,Q as Ue,T as je,aq as Je,b as $e,a9 as ze,aw as Be,aI as me,K as Ge,O as He,aJ as We,v as ve,z as we}from"./icons-DhBsHU-U.js";import{S as ae}from"./separator-vdIGU0ab.js";import{S as Ve}from"./searchable-select-DNmazsgI.js";import{t as _}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DudTubF8.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=q({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=q({queryKey:["copilot-config"],queryFn:Ye}),c=q({queryKey:["copilot-models"],queryFn:Ze}),i=q({queryKey:["copilot-raw-settings"],queryFn:et}),d=q({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(Ve,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(X,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(Y,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(Y,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(Y,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(X,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(X,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(H,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Ue,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(he,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,Q=o.opusModel??t?.opus_model??"",U=o.sonnetModel??t?.sonnet_model??"",J=o.haikuModel??t?.haiku_model??"",$=(h,j)=>{a(O=>({...O,[h]:j}))},W=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),_.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:Q||void 0,sonnet_model:U||void 0,haiku_model:J||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const V=pe(j),E=[];V.length>0&&E.push(V.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),V.length>0?_.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?_.success("Copilot configuration saved",{description:E.join(" ")}):_.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):_.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:Q,sonnetModel:U,haikuModel:J,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:$,applyPreset:W,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:Q,handleRawJsonChange:U,handleSave:J,handleConflictResolve:$,refetchRawSettings:W,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>W(),onSave:J}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:R.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(qe,{className:"w-full",children:[e.jsx(Z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Z,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:Q,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Je,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(_e,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:U,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>$(!0),onCancel:()=>$(!1)})]})}function te({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function G({icon:t,label:s,status:l,statusText:c,variant:i="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Ot(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(H,{className:"flex-1",children:l?e.jsx(vt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(te,{title:t("copilotPage.setup"),children:[e.jsx(G,{icon:ze,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(G,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(G,{icon:Ge,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(G,{icon:He,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(We,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(jt,{})})]})}export{Ot as CopilotPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{b1 as N,b2 as Ze,a as Se,B as D,d as f,c as oe,v as E,O as $e,Q as Ye,R as Y,U as ee,L as _,I as se,ay as ye,b7 as es,ad as ss,ae as as,af as ts,ag as rs,ah as ns,av as os,b3 as is}from"./index-CKNvmYLR.js";import{a as cs,u as z,b as M}from"./tanstack-DWm6aJ-G.js";import{D as ke}from"./default-ports-1QQSffYX.js";import{S as ls}from"./separator-vdIGU0ab.js";import{S as ds}from"./searchable-select-DNmazsgI.js";import{R as be,T as us,aG as ms,K as q,a9 as hs,aJ as Ce,aI as gs,L as A,D as xs,an as fs,a6 as ps,Z as ae,aq as js,v as vs,z as ws}from"./icons-DhBsHU-U.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";async function Ps(){const s=await fetch(N("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ns(){const s=await fetch(N("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function ys(){const s=await fetch(N("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function bs(){const s=await fetch(N("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Cs(s){const t=await fetch(N("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Ss(s){const t=await fetch(N("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ze("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function ks(){const s=await fetch(N("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Ds(s){const t=await fetch(N("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const l=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(l.error||"Manual import failed")}return t.json()}async function Ms(){const s=await fetch(N("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function As(){const s=await fetch(N("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function _s(){const s=cs(),t=z({queryKey:["cursor-status"],queryFn:Ps,refetchInterval:5e3}),l=z({queryKey:["cursor-config"],queryFn:Ns}),u=z({queryKey:["cursor-models"],queryFn:ys}),g=z({queryKey:["cursor-raw-settings"],queryFn:bs}),m=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=M({mutationFn:Cs,onSuccess:m}),r=M({mutationFn:Ss,onSuccess:m}),d=M({mutationFn:ks,onSuccess:m}),p=M({mutationFn:Ds,onSuccess:m}),i=M({mutationFn:Ms,onSuccess:m}),c=M({mutationFn:As,onSuccess:m});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:g.data,rawSettingsLoading:g.isLoading,refetchRawSettings:g.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:r.mutate,saveRawSettingsAsync:r.mutateAsync,isSavingRawSettings:r.isPending,autoDetectAuth:d.mutate,autoDetectAuthAsync:d.mutateAsync,isAutoDetectingAuth:d.isPending,autoDetectAuthResult:d.data,importManualAuth:p.mutate,importManualAuthAsync:p.mutateAsync,isImportingManualAuth:p.isPending,manualAuthResult:p.data,startDaemon:i.mutate,startDaemonAsync:i.mutateAsync,isStartingDaemon:i.isPending,stopDaemon:c.mutate,stopDaemonAsync:c.mutateAsync,isStoppingDaemon:c.isPending}),[t.data,t.isLoading,t.error,t.refetch,l.data,l.isLoading,u.data,u.isLoading,g.data,g.isLoading,g.refetch,h.mutate,h.mutateAsync,h.isPending,r.mutate,r.mutateAsync,r.isPending,d.mutate,d.mutateAsync,d.isPending,d.data,p.mutate,p.mutateAsync,p.isPending,p.data,i.mutate,i.mutateAsync,i.isPending,c.mutate,c.mutateAsync,c.isPending])}function te(s){return{port:String(s?.port??ke),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function y(s,t,l){return s.find(g=>t.some(m=>m.test(g.id)))?.id??l}function re(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,t,l){const u=new Set(t.map(re)),g=s.find(h=>u.has(re(h.id)));if(g)return g.id;const m=s.find(h=>u.has(re(h.name)));return m?m.id:l}function Ts(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function G({label:s,description:t,value:l,models:u,disabled:g,allowDefaultFallback:m=!1,onChange:h}){const{t:r}=Se(),d=l||(m?"__default":""),p=j.useMemo(()=>{const i=u.map(c=>({value:c.id,groupKey:"models",searchText:`${c.name||c.id} ${c.id}`,keywords:[c.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:c.name||c.id}),c.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:c.name||c.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]})}));return m?[{value:"__default",groupKey:"models",searchText:r("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:r("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:r("cursorPage.useDefaultModel")})},...i]:i},[m,u,r]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(_,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ds,{value:d||void 0,onChange:i=>{if(m&&i==="__default"){h("");return}h(i)},disabled:g,placeholder:r("cursorPage.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("cursorPage.availableModelCount",{count:u.length})}],options:p})]})}function ne({icon:s,label:t,ok:l,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(vs,{className:"h-4 w-4 text-green-500"}):e.jsx(ws,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:oe("text-xs",l?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Js(){const{t:s}=Se(),{status:t,statusLoading:l,refetchStatus:u,config:g,updateConfigAsync:m,isUpdatingConfig:h,models:r,modelsLoading:d,currentModel:p,rawSettings:i,rawSettingsLoading:c,refetchRawSettings:De,saveRawSettingsAsync:Me,isSavingRawSettings:ie,autoDetectAuthAsync:Ae,isAutoDetectingAuth:ce,importManualAuthAsync:_e,isImportingManualAuth:le,startDaemonAsync:Te,isStartingDaemon:Re,stopDaemonAsync:Fe,isStoppingDaemon:de}=_s(),[k,ue]=j.useState(()=>te()),[v,me]=j.useState(!1),[he,Ie]=j.useState("{}"),[T,K]=j.useState(!1),[Le,I]=j.useState(!1),[U,ge]=j.useState(""),[B,xe]=j.useState(""),C=te(g),fe=v?k.port:C.port,J=v?k.auto_start:C.auto_start,Q=v?k.ghost_mode:C.ghost_mode,w=v?k.model:C.model,H=v?k.opus_model:C.opus_model,V=v?k.sonnet_model:C.sonnet_model,W=v?k.haiku_model:C.haiku_model,X=T?he:JSON.stringify(i?.settings??{},null,2),pe=!!i,R=j.useMemo(()=>Ts(X),[X]),je=R.isValid,ve=v||T,Oe=!T||pe&&je,L=j.useMemo(()=>{const a=new Set,n=[...r].sort((S,$)=>S.name.localeCompare($.name)),x=n.filter(S=>a.has(S.id)?!1:(a.add(S.id),!0));return w&&!n.some(S=>S.id===w)?[{id:w,name:w,provider:"custom"},...x]:x},[r,w]),P=a=>{ue(n=>a(v?n:C)),me(!0)},Ee=!!(t?.enabled&&t?.authenticated&&!t?.token_expired),ze=j.useMemo(()=>t?.enabled?e.jsx(D,{children:s("cursorPage.enabled")}):e.jsx(D,{variant:"secondary",children:s("cursorPage.disabled")}),[t?.enabled,s]),qe=async({suppressSuccessToast:a=!1}={})=>{const n=Number(fe);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await m({port:n,auto_start:J,ghost_mode:Q,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:W||void 0}),me(!1),ue(te({port:n,auto_start:J,ghost_mode:Q,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:W||void 0})),a||o.success(s("cursorPage.savedConfig")),!0}catch(x){return o.error(x.message||s("cursorPage.failedSaveConfig")),!1}},Z=a=>{if(d){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=w||p||r[0]?.id||"gpt-5.3-codex",x=b(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],y(r,[/gpt[-.]?5.*codex/i],n)),S=b(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],y(r,[/gpt[-.]?5.*codex.*max/i],x)),$=b(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(r,[/gpt[-.]?5.*fast/i],x)),Ve=b(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(r,[/gpt[-.]?5.*mini/i],$)),Pe=b(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),We=b(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),O=b(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(r,[/gemini[-.]?3.*pro/i],x)),Xe=b(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(a==="codex53"){P(F=>({...F,model:x,opus_model:S,sonnet_model:x,haiku_model:Ve})),o.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){P(F=>({...F,model:Pe,opus_model:Pe,sonnet_model:Ne,haiku_model:We})),o.success(s("cursorPage.appliedClaudePreset"));return}P(F=>({...F,model:O,opus_model:O,sonnet_model:O,haiku_model:Xe})),o.success(s("cursorPage.appliedGeminiPreset"))},we=async a=>{try{await m({enabled:a}),o.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},Ge=async()=>{try{await Ae(),o.success(s("cursorPage.credentialsImported"))}catch(a){o.error(a.message||s("cursorPage.autoDetectFailed"))}},Ke=async()=>{if(!U.trim()||!B.trim()){o.error(s("cursorPage.manualRequired"));return}try{await _e({accessToken:U.trim(),machineId:B.trim()}),o.success(s("cursorPage.credentialsImported")),I(!1),ge(""),xe("")}catch(a){o.error(a.message||s("cursorPage.manualImportFailed"))}},Ue=async()=>{try{const a=await Te();if(!a.success){o.error(a.error||s("cursorPage.failedStartDaemon"));return}o.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){o.error(a.message||s("cursorPage.failedStartDaemon"))}},Be=async()=>{try{const a=await Fe();if(!a.success){o.error(a.error||s("cursorPage.failedStopDaemon"));return}o.success(s("cursorPage.daemonStopped"))}catch(a){o.error(a.message||s("cursorPage.failedStopDaemon"))}},Je=async({suppressSuccessToast:a=!1}={})=>{if(!pe)return o.error(s("cursorPage.rawLoading")),!1;if(!R.isValid||!R.settings)return o.error(R.error||s("cursorPage.invalidJson")),!1;try{return await Me({settings:R.settings,expectedMtime:i?.mtime}),K(!1),a||o.success(s("cursorPage.rawSaved")),!0}catch(n){return is(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},Qe=async()=>{if(!ve)return;const a=v,n=T;a&&!await qe({suppressSuccessToast:n})||n&&!await Je({suppressSuccessToast:a})||a&&n&&o.success(s("cursorPage.savedAll"))},He=()=>{K(!1),u(),De()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),ze]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>u(),disabled:l,children:e.jsx(be,{className:oe("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{icon:ms,label:s("cursorPage.integration"),ok:!!t?.enabled,detail:t?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(ne,{icon:q,label:s("cursorPage.authentication"),ok:!!(t?.authenticated&&!t?.token_expired),detail:t?.authenticated?t?.token_expired?s("cursorPage.expired"):t.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(ne,{icon:hs,label:s("cursorPage.daemon"),ok:!!t?.daemon_running,detail:t?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),t?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>we(!1),disabled:h,children:[e.jsx(Ce,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>we(!0),disabled:h,children:[e.jsx(gs,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:ce,children:[ce?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>I(!0),children:[e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),t?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ce,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:Ue,disabled:!Ee,children:[Re?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xs,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:t?.port??g?.port??ke})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:He,disabled:l||c,children:e.jsx(be,{className:oe("w-4 h-4",(l||c)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Qe,disabled:h||ie||!ve||!Oe,children:h||ie?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(Y,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(Y,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ps,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("codex53"),disabled:d||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ae,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("claude46"),disabled:d||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ae,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("gemini3"),disabled:d||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ae,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(ls,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:L,disabled:d,onChange:a=>{P(n=>({...n,model:a}))}}),e.jsx(G,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:H,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,opus_model:a}))}}),e.jsx(G,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:V,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,sonnet_model:a}))}}),e.jsx(G,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:W,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,haiku_model:a}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:fe,onChange:a=>{P(n=>({...n,port:a.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(ye,{id:"cursor-auto-start",checked:J,onCheckedChange:a=>{P(n=>({...n,auto_start:a}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(ye,{id:"cursor-ghost-mode",checked:Q,onCheckedChange:a=>{P(n=>({...n,ghost_mode:a}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),d?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===p&&e.jsx(D,{children:s("cursorPage.default")})]},a.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(js,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(es,{rawJsonContent:X,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:a=>{K(!0),Ie(a)}})]})]})]})})]}),e.jsx(ss,{open:Le,onOpenChange:I,children:e.jsxs(as,{children:[e.jsxs(ts,{children:[e.jsx(rs,{children:s("cursorPage.manualImportTitle")}),e.jsx(ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(se,{id:"cursor-manual-token",value:U,onChange:a=>ge(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(se,{id:"cursor-manual-machine-id",value:B,onChange:a=>xe(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(os,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:s("cursorPage.cancel")}),e.jsxs(f,{onClick:Ke,disabled:le,children:[le?e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(q,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{Js as CursorPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as f,c as ye}from"./react-vendor-CNOkPC89.js";import{u as P,a as T,C as k,b as C,S as j,c as d,P as w,B as X,d as E,e as ae,f as je,g as ne,h as Ne,i as re,j as M,k as q,l as Q,I as we,m as be}from"./index-CKNvmYLR.js";import{a0 as ve,ae as W,af as V,ag as le,_ as oe,a6 as ke,G as Ce,ah as z,R as De,V as J,U as Se,Z as Me,t as Le,ai as $e,aj as Te,ak as ie,C as Fe,al as Re}from"./icons-DhBsHU-U.js";import{a as ce,u as $,b as Pe}from"./tanstack-DWm6aJ-G.js";import{K as R,L as Z,f as L,H as Be}from"./utils-CzKF5WmX.js";import{R as de,A as Ae,C as Ue,X as qe,Y as ee,T as ue,a as se,P as Ke,b as Ie,c as Oe}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function _e({data:s,isLoading:t}){const{privacyMode:n}=P(),{t:a}=T();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(r=>e.jsx(k,{children:e.jsx(C,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{className:"h-4 w-[100px]"}),e.jsx(j,{className:"h-8 w-[80px]"})]}),e.jsx(j,{className:"h-8 w-8 rounded-lg"})]})})},r))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),o=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:a("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:r=>U(r),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:a("analyticsSummary.totalTokensSubtitle",{input:U(s?.totalInputTokens??0),output:U(s?.totalOutputTokens??0)})},{title:a("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:W,format:r=>`$${r.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:a("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:a("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:V,format:r=>U(r),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:a("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:o})},{title:a("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:le,format:r=>`$${r.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:a("analyticsSummary.tokensSubtitle",{value:U(s?.tokenBreakdown?.input?.tokens??0)})},{title:a("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:oe,format:r=>`$${r.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:a("analyticsSummary.tokensSubtitle",{value:U(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:i.map((r,c)=>{const u=r.icon;return e.jsx(k,{className:"hover:shadow-md transition-shadow",children:e.jsx(C,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:r.title}),e.jsx("p",{className:d("text-xl font-bold truncate",n&&w),children:r.format(r.value)}),r.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",n&&w),children:r.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",r.bgColor),children:e.jsx(u,{className:d("h-4 w-4",r.color)})})]})})},c)})})}function U(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function He({model:s}){const{privacyMode:t}=P(),{t:n}=T(),a=Ee(s.ioRatio,n);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:n("analyticsModelDetail.percentUsage",{percent:s.percentage.toFixed(1)})}),e.jsx(X,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:n("analyticsModelDetail.ioRatio",{ratio:s.ioRatio.toFixed(0)})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&w),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&w),children:Ge(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.totalTokens")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.tokenBreakdown")}),e.jsxs("div",{className:d("space-y-1",t&&w),children:[e.jsx(H,{label:n("analyticsToken.input"),tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:le}),e.jsx(H,{label:n("analyticsToken.output"),tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:oe}),e.jsx(H,{label:n("analyticsToken.cacheWrite"),tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:V}),e.jsx(H,{label:n("analyticsToken.cacheRead"),tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:V})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:n("analyticsModelDetail.ioRatioTitle")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function H({label:s,tokens:t,cost:n,color:a,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:a}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",n.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:We(t)})]})]})]})}function Ee(s,t){return s>=200?{variant:"destructive",description:t("analyticsModelDetail.ioDescHigh")}:s>=50?{variant:"secondary",description:t("analyticsModelDetail.ioDescMedHigh")}:s>=5?{variant:"outline",description:t("analyticsModelDetail.ioDescBalanced")}:{variant:"default",description:t("analyticsModelDetail.ioDescHighOutput")}}function We(s){return s.toLocaleString()}function Ge(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Qe="/api";function D(s){const t=s.getFullYear(),n=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${t}${n}${a}`}const B={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),F(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),F(`/usage/sessions?${t}`)},monthly:(s,t)=>{const n=new URLSearchParams;return s&&n.append("months",s.toString()),t&&n.append("profile",t),F(`/usage/monthly?${n}`)},refresh:async()=>{if(!(await fetch(`${Qe}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>F("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/insights?${t}`)}};async function F(s){const n=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!n.ok){const l=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||n.statusText)}const a=await n.json();return a.data||a}function Ye(s){return $({queryKey:["usage","summary",s],queryFn:()=>B.summary(s),staleTime:60*1e3})}function Ve(s){return $({queryKey:["usage","trends",s],queryFn:()=>B.trends(s),staleTime:60*1e3})}function ze(s){return $({queryKey:["usage","hourly",s],queryFn:()=>B.hourly(s),staleTime:60*1e3})}function Ze(s){return $({queryKey:["usage","models",s],queryFn:()=>B.models(s),staleTime:60*1e3})}function Xe(){const s=ce();return f.useCallback(async()=>{await B.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return $({queryKey:["usage","status"],queryFn:()=>B.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return $({queryKey:["usage","sessions",s],queryFn:()=>B.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:R(new Date,30),to:new Date}),[n,a]=f.useState(!1),[l,o]=f.useState(null),[i,r]=f.useState(null),[c,u]=f.useState("daily"),x=Xe(),p=f.useCallback(async()=>{a(!0);try{await x()}finally{a(!1)}},[x]),g=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:S,isLoading:v}=Ye(g),{data:h,isLoading:m}=Ve(g),{data:b,isLoading:N}=ze(g),{data:y,isLoading:K}=Ze(g),{data:G,isLoading:I}=es({...g,limit:3}),{data:O}=Je(),xe=f.useCallback(()=>{const A=new Date;t({from:R(A,1),to:A}),u("hourly")},[]),me=f.useCallback(A=>{t(A),u("daily")},[]),fe=f.useMemo(()=>O?.lastFetch?Z(new Date(O.lastFetch),{addSuffix:!0}):null,[O?.lastFetch]),he=f.useCallback((A,ge)=>{const _=ge.currentTarget.getBoundingClientRect();r({x:_.left+_.width/2,y:_.top+_.height/2}),o(A)},[]),pe=f.useCallback(()=>{o(null),r(null)},[]);return{dateRange:s,isRefreshing:n,viewMode:c,selectedModel:l,popoverPosition:i,summary:S,trends:h,hourlyData:b,models:y,sessions:G,status:O,isSummaryLoading:v,isTrendsLoading:m,isHourlyLoading:N,isModelsLoading:K,isSessionsLoading:I,isLoading:v||m||K||I,handleRefresh:p,handleTodayClick:xe,handleDateRangeChange:me,handleModelClick:he,handlePopoverClose:pe,lastUpdatedText:fe}}function ts({value:s,onChange:t,presets:n=[{label:"Last 7 days",range:{from:R(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:R(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:R(new Date,90),to:new Date}}],className:a}){const[l,o]=ye.useState(!1),i=r=>!s||!s.from||!s.to||!r.from||!r.to?!1:L(s.from,"yyyy-MM-dd")===L(r.from,"yyyy-MM-dd")&&L(s.to,"yyyy-MM-dd")===L(r.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex flex-wrap items-center gap-2",a),children:[n.map(r=>e.jsx(E,{variant:i(r.range)?"default":"outline",size:"sm",onClick:()=>t(r.range),children:r.label},r.label)),e.jsxs(ae,{open:l,onOpenChange:o,children:[e.jsx(je,{asChild:!0,children:e.jsxs(E,{id:"date",variant:"outline",className:d("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[L(s.from,"LLL dd, y")," - ",L(s.to,"LLL dd, y")]}):L(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(ne,{className:"w-auto p-0",align:"end",children:e.jsx(Ne,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:n,onRefresh:a,isRefreshing:l,lastUpdatedText:o,viewMode:i}){const{t:r}=T();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:r("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(E,{variant:i==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:n,children:"24H"}),e.jsx(ts,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:R(new Date,7),to:new Date}},{label:"30D",range:{from:R(new Date,30),to:new Date}},{label:r("analytics.month"),range:{from:Be(new Date),to:new Date}},{label:r("analytics.allTime"),range:{from:void 0,to:new Date}}]}),o&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:r("analytics.updated",{value:o})}),e.jsx(E,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:a,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:n="daily",className:a}){const{privacyMode:l}=P(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const u="hour"in c?c.hour:c.date;return{...c,dateFormatted:rs(u,n),costRounded:Number(c.cost.toFixed(4))}}),[s,n]);if(t)return e.jsx(j,{className:d("h-full w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:n==="hourly"?"No usage data for today":"No usage data available"})});const i=({x:r,y:c,payload:u,isRight:x})=>{const p=x?`$${u.value}`:te(Number(u.value));return e.jsx("text",{x:r,y:c,dy:4,textAnchor:x?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",l&&"blur-[4px]"),children:p})};return e.jsx("div",{className:d("w-full h-full",a),children:e.jsx(de,{width:"100%",height:"100%",children:e.jsxs(Ae,{data:o,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ee,{yAxisId:"left",orientation:"left",tick:r=>e.jsx(i,{...r,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ee,{yAxisId:"right",orientation:"right",tick:r=>e.jsx(i,{...r,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ue,{content:({active:r,payload:c,label:u})=>{if(!r||!c||!c.length)return null;const x=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:u}),c.map((p,g)=>e.jsxs("p",{className:d("text-sm",l&&w),style:{color:p.color},children:[p.name,":"," ",p.name==="Tokens"?te(Number(p.value)||0):`$${p.value}`]},g)),"requests"in x&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",l&&w),children:["Requests: ",x.requests]})]})}}),e.jsx(se,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(se,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function rs(s,t){if(t==="hourly"){const[a,l]=s.split(" ");if(a&&l){const o=new Date(`${a}T${l}:00Z`);return L(o,"HH:mm")}return s}const n=new Date(s);return t==="monthly"?L(n,"MMM yyyy"):L(n,"MMM dd")}function te(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:n}){const{privacyMode:a}=P(),{t:l}=T(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>({name:c.model,value:c.tokens,cost:c.cost,percentage:c.percentage,fill:re(c.model)})),[s]);if(t)return e.jsx(j,{className:d("h-full min-h-[100px] w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full min-h-[100px] flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:l("analyticsModel.emptyState")})});const i=({active:c,payload:u})=>{if(!c||!u)return null;const x=u;if(!x.length)return null;const p=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:p.name}),e.jsxs("p",{className:d("text-muted-foreground",a&&w),children:[os(p.value)," (",p.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",a&&w),children:["$",p.cost.toFixed(4)]})]})},r=c=>c.percentage>5?`${c.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full h-full min-h-[100px]",n),children:e.jsx(de,{width:"100%",height:"100%",children:e.jsxs(Ke,{children:[e.jsx(Ie,{data:o,cx:"50%",cy:"50%",labelLine:!1,label:r,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((c,u)=>e.jsx(Oe,{fill:c.fill,strokeWidth:1},`cell-${u}`))}),e.jsx(ue,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is(s){if(!s)return"";const n=s.replace(/^\/|\/$/g,"").split("/").filter(a=>a.length>0);return n[n.length-1]||""}function cs({data:s,isLoading:t,className:n}){const{privacyMode:a}=P(),{t:l}=T(),o=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,r=s.total,c=i.reduce((v,h)=>v+(h.inputTokens+h.outputTokens),0),u=Math.round(c/i.length),p=i.reduce((v,h)=>v+h.cost,0)/i.length,g=i[0],S=g?Z(new Date(g.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:r,avgTokens:u,avgCost:p,lastActive:S,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsx(j,{className:"h-5 w-32"})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}):o?e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),l("analyticsSession.title")]})}),e.jsxs(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:o.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:l("analyticsSession.totalSessions")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(Me,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",a&&w),children:["$",o.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:l("analyticsSession.avgCostPerSession")})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),l("analyticsSession.recentActivity")]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:o.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:is(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Z(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",a&&w),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ds(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),l("analyticsSession.title")]})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:l("analyticsSession.emptyState")})})]})}function ds(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}async function Y(s,t){try{const n=new URLSearchParams,a=r=>{const c=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),x=String(r.getDate()).padStart(2,"0");return`${c}${u}${x}`};n.append("since",a(s)),n.append("until",a(t));const l=await fetch(`/api/usage/summary?${n}`,{headers:{"Content-Type":"application/json"}});if(!l.ok)return 0;const o=await l.json();return(o.data||o).totalCost||0}catch{return 0}}function us(){const s=new Date;return new Date(s.getFullYear(),s.getMonth()+1,0).getDate()}function xs(){return new Date().getDate()}function ms(s,t){return t<=0?"N/A":`${(s/t).toFixed(2)}x`}function fs(s,t){return t<=0?null:s/t}function hs(){const s=ce(),t=$({queryKey:["cost-leverage-config"],queryFn:async()=>{const b=(await Q.config.get()).preferences?.baseline_cost_30d;return typeof b=="number"?b:void 0},staleTime:30*1e3}),n=t.data,a=f.useMemo(()=>new Date,[]),l=f.useMemo(()=>{const h=new Date(a),m=new Date(a);return m.setDate(m.getDate()-6),{start:m,end:h}},[a]),o=f.useMemo(()=>{const h=new Date(a),m=new Date(a);return m.setDate(m.getDate()-29),{start:m,end:h}},[a]),i=f.useMemo(()=>{const h=new Date(a.getFullYear(),a.getMonth(),1),m=new Date(a);return{start:h,end:m}},[a]),r=$({queryKey:["cost-leverage","7d"],queryFn:()=>Y(l.start,l.end),staleTime:60*1e3}),c=$({queryKey:["cost-leverage","30d"],queryFn:()=>Y(o.start,o.end),staleTime:60*1e3}),u=$({queryKey:["cost-leverage","month"],queryFn:()=>Y(i.start,i.end),staleTime:60*1e3}),x=Pe({mutationFn:async h=>{const m=await Q.config.get(),N={...m.preferences||{}};h==null?delete N.baseline_cost_30d:N.baseline_cost_30d=h;const y=typeof m.version=="number"?m.version:12;return Q.config.update({version:y,preferences:N})},onSuccess:()=>{s.invalidateQueries({queryKey:["cost-leverage-config"]})}}),p=f.useMemo(()=>{const h=xs(),m=us();return[{label:"7d",cost:r.data??0,windowDays:7,scaleDays:7},{label:"30d",cost:c.data??0,windowDays:30,scaleDays:30},{label:"Month",cost:u.data??0,windowDays:h,scaleDays:m}].map(N=>{const y=n?n*N.scaleDays/30:0;return{label:N.label,estimatedCost:N.cost,scaledBaseline:y,ratio:fs(N.cost,y),ratioDisplay:ms(N.cost,y),windowDays:N.windowDays}})},[n,r.data,c.data,u.data]),g=f.useCallback(h=>{const m=h.trim();if(m==="")return x.mutate(void 0),{valid:!0};const b=Number(m);return isNaN(b)||b<=0?{valid:!1,error:"invalid"}:(x.mutate(b),{valid:!0})},[x]),S=t.isLoading||r.isLoading&&c.isLoading&&u.isLoading,v=t.error?.message||x.error?.message||null;return{baselineCost:n,windows:p,isLoading:S,isSaving:x.isPending,error:v,saveBaseline:g,cost7d:r.data,cost30d:c.data,costMonth:u.data}}function ps({className:s,isLoading:t}){const{privacyMode:n}=P(),{t:a}=T(),{baselineCost:l,windows:o,isLoading:i,isSaving:r,error:c,saveBaseline:u}=hs(),[x,p]=f.useState(l!==void 0?String(l):""),[g,S]=f.useState(null),[v,h]=f.useState(!1);l!==void 0&&!v&&(p(String(l)),h(!0)),l===void 0&&v&&h(!1);const m=f.useCallback(()=>{u(x).valid?(S(null),x.trim()===""&&(p(""),h(!1))):S(a("analyticsCostLeverage.invalidInput"))},[x,u,a]),b=f.useCallback(y=>{y.key==="Enter"&&(y.preventDefault(),m())},[m]),N=l!==void 0&&l>0;return i||t?e.jsxs(k,{className:d("flex flex-col h-full",s),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsx(j,{className:"h-5 w-36"})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}):e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",s),children:[e.jsx(M,{className:"px-3 py-2 shrink-0",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx($e,{className:"w-4 h-4"}),a("analyticsCostLeverage.title")]})}),e.jsxs(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-2",children:[N?e.jsx("div",{className:"flex-1 flex flex-col gap-2 justify-center min-h-0",children:o.map(y=>e.jsx(gs,{window:y,privacyMode:n,t:a},y.label))}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/50 flex items-center justify-center",children:e.jsx(W,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center leading-relaxed max-w-[180px]",children:a("analyticsCostLeverage.noBaseline")})]}),e.jsxs("div",{className:"shrink-0 pt-2 mt-auto border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx(we,{type:"text",inputMode:"decimal",value:x,onChange:y=>{p(y.target.value),S(null)},onBlur:m,onKeyDown:b,placeholder:a("analyticsCostLeverage.baselinePlaceholder"),disabled:r,className:d("h-7 text-xs",g&&"border-destructive focus-visible:ring-destructive")}),r&&e.jsx("span",{className:"text-[10px] text-muted-foreground animate-pulse",children:a("analyticsCostLeverage.saving")})]}),g&&e.jsx("p",{className:"text-[10px] text-destructive mt-1",children:g}),c&&e.jsxs("p",{className:"text-[10px] text-destructive mt-1",children:[a("analyticsCostLeverage.saveError"),": ",c]})]})]})]})}function gs({window:s,privacyMode:t,t:n}){const a=s.label==="7d"?"analyticsCostLeverage.window7d":s.label==="30d"?"analyticsCostLeverage.window30d":"analyticsCostLeverage.windowMonth",l=s.label==="7d"?z:s.label==="30d"?Te:z,o=s.ratio===null?"text-muted-foreground":s.ratio<2.5?"text-red-600 dark:text-red-400":s.ratio<10?"text-amber-600 dark:text-amber-400":"text-emerald-600 dark:text-emerald-400",i=s.ratio===null?"bg-muted/30":s.ratio<2.5?"bg-red-100/30 dark:bg-red-950/30":s.ratio<10?"bg-amber-100/30 dark:bg-amber-950/30":"bg-emerald-100/30 dark:bg-emerald-950/30";return e.jsxs("div",{className:d("flex items-center gap-2 px-2.5 py-2 rounded-lg border transition-colors",i),children:[e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(l,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:n(a)})]}),e.jsxs("span",{className:d("text-xs text-muted-foreground font-mono",t&&w),children:["$",s.estimatedCost.toFixed(2)]}),e.jsx("div",{className:"flex-1 border-t border-dashed border-muted-foreground/30"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.ratio!==null&&s.ratio>=10&&e.jsx(ie,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsx("span",{className:d("text-lg font-bold tabular-nums min-w-[56px] text-right",o,t&&w),children:s.ratioDisplay})]})]})}function ys(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function js({models:s,isLoading:t,onModelClick:n,privacyMode:a}){const{t:l}=T();return e.jsxs(k,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4"}),l("analyticsCostModel.title")]})}),e.jsx(C,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(j,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((o,i)=>i.cost-o.cost).map(o=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>n(o,i),title:l("analyticsCostModel.clickForDetails"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:re(o.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:o.model})]}),e.jsx(Ns,{model:o}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",a&&w),children:ys(o.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",a&&w),children:["$",o.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},o.model)),e.jsx(ws,{})]})})]})}function Ns({model:s}){const{t}=T(),n={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:n.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`${t("analyticsToken.input")}: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`${t("analyticsToken.output")}: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`${t("analyticsToken.cacheWrite")}: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`${t("analyticsToken.cacheRead")}: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function ws(){const{t:s}=T(),t=[{color:"#335c67",label:s("analyticsToken.input")},{color:"#fff3b0",label:s("analyticsToken.output"),hasBorder:!0},{color:"#e09f3e",label:s("analyticsToken.cacheWrite")},{color:"#9e2a2b",label:s("analyticsToken.cacheRead")}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:t.map(({color:n,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:n}}),a]},a))})}function bs({viewMode:s,trends:t,hourlyData:n,models:a,sessions:l,isTrendsLoading:o,isHourlyLoading:i,isModelsLoading:r,isSessionsLoading:c,isSummaryLoading:u,onModelClick:x}){const{privacyMode:p}=P(),{t:g}=T();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(k,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(M,{className:"px-3 py-2 shrink-0",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4"}),g(s==="hourly"?"analytics.last24Hours":"analytics.usageTrends")]})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?n||[]:t||[],isLoading:s==="hourly"?i:o,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(js,{models:a,isLoading:r,onModelClick:x,privacyMode:p}),e.jsxs(k,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),g("analytics.modelUsage")]})}),e.jsx(C,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:a||[],isLoading:r,className:"h-full w-full"})})]}),e.jsx(cs,{data:l,isLoading:c,className:"lg:col-span-2"}),e.jsx(ps,{className:"lg:col-span-2"})]})]})}function Rs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(k,{className:"flex flex-col min-h-[300px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-32"})}),e.jsx(C,{className:"p-4 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(k,{className:"flex flex-col min-h-[250px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-28"})}),e.jsx(C,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(j,{className:"h-3 w-24"})]}),e.jsx(j,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(k,{className:"flex flex-col min-h-[250px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-28"})}),e.jsx(C,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(j,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-2 h-2 rounded-full"}),e.jsx(j,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ps(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:n,handleTodayClick:a,handleRefresh:l,isRefreshing:o,lastUpdatedText:i,viewMode:r,summary:c,isSummaryLoading:u,trends:x,hourlyData:p,models:g,sessions:S,isTrendsLoading:v,isHourlyLoading:h,isModelsLoading:m,isSessionsLoading:b,handleModelClick:N,selectedModel:y,popoverPosition:K,handlePopoverClose:G}=ss();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:n,onTodayClick:a,onRefresh:l,isRefreshing:o,lastUpdatedText:i,viewMode:r}),e.jsx(_e,{data:c,isLoading:u}),e.jsx(bs,{viewMode:r,trends:x,hourlyData:p,models:g,sessions:S,isTrendsLoading:v,isHourlyLoading:h,isModelsLoading:m,isSessionsLoading:b,isSummaryLoading:u,onModelClick:N}),e.jsxs(ae,{open:!!y,onOpenChange:I=>!I&&G(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:K?.x??0,top:K?.y??0,width:1,height:1}})}),e.jsx(ne,{className:"w-80 p-3",side:"top",align:"center",children:y&&e.jsx(He,{model:y})})]})]})}export{Ps as AnalyticsPage,Rs as AnalyticsSkeleton};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{L as P,r as o}from"./react-vendor-CNOkPC89.js";import{a as p,B as y,c as k,d as x,w as E,be as M,C as g,j,k as N,Y as w,b as v,v as b,bf as U,bg as $,I as z,bh as B}from"./index-CKNvmYLR.js";import{_ as L,V as Q,a$ as J,v as V,E as Y,J as q,a6 as G,C as F,b0 as H,ao as K}from"./icons-DhBsHU-U.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const W={new:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-300",stable:"border-green-200 bg-green-50 text-green-700 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-300",planned:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-300"};function X({status:s,className:a}){const{t}=p(),d={new:t("updates.statusNew"),stable:t("updates.statusStable"),planned:t("updates.statusPlanned")};return e.jsx(y,{variant:"outline",className:k("font-medium",W[s],a),children:d[s]})}const I="ccs:updates:notice-progress:v1";function Z(s){return s==="new"?"new":"seen"}function u(s,a){return a[s.id]??Z(s.status)}function A(s){return s!=="done"&&s!=="dismissed"}function ee(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(I);if(!s)return{};const a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))return{};const t={};for(const[d,l]of Object.entries(a))typeof d=="string"&&(l==="new"||l==="seen"||l==="done"||l==="dismissed")&&(t[d]=l);return t}catch{return{}}}function se(s){typeof window>"u"||window.localStorage.setItem(I,JSON.stringify(s))}function R({state:s,className:a}){const{t}=p(),d={new:{label:t("updates.progressNeedsAction"),className:"border-amber-300/70 bg-amber-100/70 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/15 dark:text-amber-300",showDot:!0},seen:{label:t("updates.progressInReview"),className:"border-blue-300/70 bg-blue-100/70 text-blue-800 dark:border-blue-500/40 dark:bg-blue-500/15 dark:text-blue-300"},done:{label:t("updates.progressDone"),className:"border-emerald-300/70 bg-emerald-100/70 text-emerald-800 dark:border-emerald-500/40 dark:bg-emerald-500/15 dark:text-emerald-300"},dismissed:{label:t("updates.progressDismissed"),className:"border-muted-foreground/20 bg-muted text-muted-foreground dark:border-muted-foreground/30"}}[s];return e.jsxs(y,{variant:"outline",className:k("gap-1.5 border text-[10px] font-medium",d.className,a),children:[d.showDot&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),d.label]})}function ae({action:s}){const{t:a}=p();return e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]}),s.type==="route"&&s.path&&e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:s.path,children:[a("updates.open"),e.jsx(L,{className:"h-3.5 w-3.5"})]})})]}),s.type==="command"&&s.command&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"min-w-0 flex-1 truncate text-[11px]",children:s.command}),e.jsx(E,{value:s.command})]})]})}function re({notice:s,progress:a,relatedEntries:t,onUpdateProgress:d}){const{t:l}=p();return s?e.jsxs("div",{className:"flex-1 min-w-0 bg-background grid grid-rows-[auto_minmax(0,1fr)] overflow-hidden",children:[e.jsxs("div",{className:"border-b bg-background px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-tight",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.summary})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&e.jsx(R,{state:a}),e.jsx(X,{status:s.status})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:l("updates.published",{date:M(s.publishedAt)})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(x,{size:"sm",onClick:()=>d("done"),children:[e.jsx(V,{className:"h-4 w-4"}),l("updates.markDone")]}),e.jsxs(x,{size:"sm",variant:"outline",onClick:()=>d("dismissed"),children:[e.jsx(Y,{className:"h-4 w-4"}),l("updates.dismiss")]}),e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>d("new"),children:[e.jsx(q,{className:"h-4 w-4"}),l("updates.reopen")]})]})]}),e.jsx("div",{className:"min-h-0 p-4",children:e.jsxs("div",{className:"grid h-full gap-4 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,1fr)] overflow-hidden",children:[e.jsxs(g,{className:"h-full overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-primary"}),e.jsx(N,{className:"text-base",children:l("updates.doNext")})]}),e.jsx(w,{children:s.primaryAction})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-3",children:s.actions.map(n=>e.jsx(ae,{action:n},`${s.id}-${n.id}`))})})})]}),e.jsxs("div",{className:"grid h-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-4 overflow-hidden",children:[e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.impactedIntegrations")}),e.jsx(w,{children:l("updates.impactedDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-medium",children:n.name}),e.jsx(y,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:U[n.scope]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.routes[0]&&e.jsx(x,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(P,{to:n.routes[0].path,children:n.routes[0].label})}),n.commands[0]&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"truncate rounded bg-background px-1.5 py-0.5 text-[11px]",children:n.commands[0]}),e.jsx(E,{value:n.commands[0]})]})]})]},n.id))})})})]}),e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.whyMatters")}),e.jsx(w,{children:l("updates.whyMattersDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:s.highlights.map(n=>e.jsxs("li",{children:["- ",n]},`${s.id}-${n}`))})})})]})]})]})})]}):e.jsx("div",{className:"flex h-full items-center justify-center rounded-lg border border-dashed bg-muted/20 p-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l("updates.noUpdates")})})}function te({notice:s,progress:a,selected:t,onSelect:d}){return e.jsxs("button",{type:"button",onClick:d,className:k("w-full rounded-lg border px-3 py-3 text-left transition-colors",t?"border-primary/30 bg-primary/10":"border-transparent bg-background/40 hover:border-border hover:bg-muted/70"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.title}),e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:s.primaryAction})]}),e.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:M(s.publishedAt)}),e.jsx(R,{state:a})]})]})}function de(s,a){return a?[s.title,s.summary,s.primaryAction,...s.highlights,...s.commands,...s.actions.map(d=>`${d.label} ${d.description} ${d.command||""}`),...s.routes.map(d=>d.label)].join(" ").toLowerCase().includes(a):!0}function be(){const{t:s}=p(),a=o.useMemo(()=>[...$].sort((r,i)=>i.publishedAt.localeCompare(r.publishedAt)),[]),[t,d]=o.useState("inbox"),[l,n]=o.useState(""),[c,C]=o.useState(()=>ee()),[S,T]=o.useState(null);o.useEffect(()=>{se(c)},[c]);const h=o.useMemo(()=>{const r=l.trim().toLowerCase();return a.filter(i=>{const f=u(i,c);return de(i,r)?t==="done"?f==="done":t==="inbox"?A(f):!0:!1})},[a,c,l,t]),m=o.useMemo(()=>{const r=t==="all"?a:h;return r.find(i=>i.id===S)??r[0]??null},[a,S,t,h]),D=r=>{T(r.id),C(i=>u(r,i)!=="new"?i:{...i,[r.id]:"seen"})},O=o.useMemo(()=>a.filter(r=>A(u(r,c))).length,[a,c]),_=o.useMemo(()=>a.filter(r=>u(r,c)==="done").length,[a,c]);return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r bg-muted/30 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("updates.inboxTitle")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("updates.inboxSubtitle")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.needsAction")}),e.jsx("p",{className:"text-base font-semibold",children:O})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.doneCount")}),e.jsx("p",{className:"text-base font-semibold",children:_})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(z,{value:l,onChange:r=>n(r.target.value),placeholder:s("updates.searchPlaceholder"),className:"h-9 pl-8"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{id:"inbox",label:s("updates.actionRequired")},{id:"done",label:s("updates.done")},{id:"all",label:s("updates.all")}].map(r=>e.jsx(x,{size:"sm",variant:t===r.id?"default":"outline",onClick:()=>d(r.id),children:r.label},r.id))})]}),e.jsx(b,{className:"flex-1",children:e.jsx("div",{className:"space-y-2 p-2",children:h.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:s("updates.noNotices")}):h.map(r=>e.jsx(te,{notice:r,progress:u(r,c),selected:m?.id===r.id,onSelect:()=>D(r)},r.id))})})]}),e.jsx(re,{notice:m,progress:m?u(m,c):null,relatedEntries:m?B(m):[],onUpdateProgress:r=>{m&&C(i=>({...i,[m.id]:r}))}})]})}export{be as UpdatesPage};
|