@harnspec/ui 0.0.1 → 0.0.2
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/bin/harnspec-ui.js +46 -29
- package/dist/assets/{ChatSettingsPage-JPXu3eH0.js → ChatSettingsPage-CHSjd3vp.js} +1 -1
- package/dist/assets/{ContextPage-BLFL7v_u.js → ContextPage-BaNHyJAS.js} +1 -1
- package/dist/assets/{DashboardPage-D-pA0AIe.js → DashboardPage-DCb6-5kD.js} +1 -1
- package/dist/assets/{DependenciesPage-DjavTkHz.js → DependenciesPage-DmcZ0HId.js} +1 -1
- package/dist/assets/{FilesPage-BxxpK9Bt.js → FilesPage-DZzXXnSe.js} +1 -1
- package/dist/assets/{SessionDetailPage-iEL9xj4a.js → SessionDetailPage-DpLwCjal.js} +1 -1
- package/dist/assets/{SessionsPage-CO68ICYO.js → SessionsPage-BKKyO4A_.js} +1 -1
- package/dist/assets/{SpecDetailPage-9MMpkW8X.js → SpecDetailPage-B0cx1uxg.js} +2 -2
- package/dist/assets/{SpecsPage-1nVMIoG9.js → SpecsPage-CF_GhEVh.js} +1 -1
- package/dist/assets/{StatsPage-BvmDcqy8.js → StatsPage-CHongCio.js} +1 -1
- package/dist/assets/{_baseUniq-BRyOJSQv.js → _baseUniq-BWXYSgg3.js} +1 -1
- package/dist/assets/{arc-ljNi3wsf.js → arc-DVUWV1Ux.js} +1 -1
- package/dist/assets/{architectureDiagram-VXUJARFQ-CAly0kzY.js → architectureDiagram-VXUJARFQ-DtTMloLc.js} +1 -1
- package/dist/assets/{blockDiagram-VD42YOAC-BOl04R0o.js → blockDiagram-VD42YOAC-5FgtpUfA.js} +1 -1
- package/dist/assets/{c4Diagram-YG6GDRKO-S5hXNTsJ.js → c4Diagram-YG6GDRKO-DL2TZvVA.js} +1 -1
- package/dist/assets/channel-DRaxx9t9.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-iNaFpgQz.js → chunk-4BX2VUAB-DuxW4ARi.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-DqKEYEHN.js → chunk-55IACEB6-jI95g37A.js} +1 -1
- package/dist/assets/{chunk-B4BG7PRW-z9_0Jmwe.js → chunk-B4BG7PRW-DjnYS36d.js} +1 -1
- package/dist/assets/{chunk-DI55MBZ5-BX1YqnSd.js → chunk-DI55MBZ5-BKKp8oyH.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-CUWgtpIs.js → chunk-FMBD7UC4-Kf-ovOBd.js} +1 -1
- package/dist/assets/{chunk-QN33PNHL-kfBxkNBp.js → chunk-QN33PNHL-Ct8TKBeY.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-N9ia6yy2.js → chunk-QZHKN3VN-BmSaNL6k.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-sKnpnnNJ.js → chunk-TZMSLE5B-DQvOFmy4.js} +1 -1
- package/dist/assets/classDiagram-2ON5EDUG-MuAiNNYp.js +1 -0
- package/dist/assets/classDiagram-v2-WZHVMYZB-MuAiNNYp.js +1 -0
- package/dist/assets/clone-C-DQbIm8.js +1 -0
- package/dist/assets/{code-block-37QAKDTI-DeQWV7FO.js → code-block-37QAKDTI-C5riIxE5.js} +1 -1
- package/dist/assets/{cose-bilkent-S5V4N54A-gY03429f.js → cose-bilkent-S5V4N54A-DhwtA41M.js} +1 -1
- package/dist/assets/{dagre-6UL2VRFP-DSANw7dB.js → dagre-6UL2VRFP-B4ns4hkv.js} +1 -1
- package/dist/assets/{diagram-PSM6KHXK-ButP3OXt.js → diagram-PSM6KHXK-C6vBYdLz.js} +1 -1
- package/dist/assets/{diagram-QEK2KX5R-B_kcqC9w.js → diagram-QEK2KX5R-D5hNzEvu.js} +1 -1
- package/dist/assets/{diagram-S2PKOQOG-CEZf1YN1.js → diagram-S2PKOQOG-B7hU4Vir.js} +1 -1
- package/dist/assets/{erDiagram-Q2GNP2WA-2_Q02Cxk.js → erDiagram-Q2GNP2WA-GT38PoiU.js} +1 -1
- package/dist/assets/{flowDiagram-NV44I4VS-zHYqmkyx.js → flowDiagram-NV44I4VS-CG1t4tHV.js} +1 -1
- package/dist/assets/{funnel-x-BS_Cfod-.js → funnel-x-DVbrqcHk.js} +1 -1
- package/dist/assets/{ganttDiagram-JELNMOA3-6Yspdlny.js → ganttDiagram-JELNMOA3-BXKmb-ii.js} +1 -1
- package/dist/assets/{gitGraphDiagram-NY62KEGX-B9FE0mj2.js → gitGraphDiagram-NY62KEGX-AzgnB9fT.js} +1 -1
- package/dist/assets/{graph-Dj86lVww.js → graph-dOzOTENu.js} +1 -1
- package/dist/assets/{index-Bo42UlS3.js → index-BlyOVhDj.js} +6 -6
- package/dist/assets/{info-CjwfpSMh.js → info-Cl-KzKzC.js} +1 -1
- package/dist/assets/{infoDiagram-WHAUD3N6-BGRk5inn.js → infoDiagram-WHAUD3N6-D0wkBIMn.js} +1 -1
- package/dist/assets/{journeyDiagram-XKPGCS4Q-DkLUAT8H.js → journeyDiagram-XKPGCS4Q-Cmxvw-CF.js} +1 -1
- package/dist/assets/{kanban-definition-3W4ZIXB7-Cz5Z2HI7.js → kanban-definition-3W4ZIXB7-YdVwldix.js} +1 -1
- package/dist/assets/{layout-CBJU43bb.js → layout--LdX6GN6.js} +1 -1
- package/dist/assets/{linear-DEceC7GR.js → linear-CcZ9lo23.js} +1 -1
- package/dist/assets/{min-C3REIl55.js → min-C_YM2Fvy.js} +1 -1
- package/dist/assets/{mindmap-definition-VGOIOE7T-DK-dKLTa.js → mindmap-definition-VGOIOE7T-Bo3LAno7.js} +1 -1
- package/dist/assets/{page-transition-BKC5kVS6.js → page-transition-DY_O2TfZ.js} +1 -1
- package/dist/assets/{pieDiagram-ADFJNKIX--hXf44AA.js → pieDiagram-ADFJNKIX-TY170q2q.js} +1 -1
- package/dist/assets/{quadrantDiagram-AYHSOK5B-BP4dBgbK.js → quadrantDiagram-AYHSOK5B-CaGT9oCS.js} +1 -1
- package/dist/assets/{refresh-ccw-CfzFVZ57.js → refresh-ccw-DZO2C09G.js} +1 -1
- package/dist/assets/{requirementDiagram-UZGBJVZJ-BjJP3Slm.js → requirementDiagram-UZGBJVZJ-cjPEHOn1.js} +1 -1
- package/dist/assets/{sankeyDiagram-TZEHDZUN-DSt3qjc-.js → sankeyDiagram-TZEHDZUN-C1jZ6BzB.js} +1 -1
- package/dist/assets/{sequenceDiagram-WL72ISMW-CLo7P2AR.js → sequenceDiagram-WL72ISMW-CfbBeFLR.js} +1 -1
- package/dist/assets/{session-mode-badge-BQaNgsJN.js → session-mode-badge-BAcHdIhX.js} +1 -1
- package/dist/assets/{stat-card-CZ-HGUBa.js → stat-card-BEjjOCD2.js} +1 -1
- package/dist/assets/{stateDiagram-FKZM4ZOC-D5NKNKls.js → stateDiagram-FKZM4ZOC-BHdZJa9R.js} +1 -1
- package/dist/assets/stateDiagram-v2-4FDKWEC3-CnXnQZrS.js +1 -0
- package/dist/assets/{table-of-contents-BiPY4Kr6.js → table-of-contents-Cnkk8UZa.js} +1 -1
- package/dist/assets/{time-B8z8CeFv.js → time-yYkNCeI6.js} +1 -1
- package/dist/assets/{timeline-definition-IT6M3QCI-BJI5Adg7.js → timeline-definition-IT6M3QCI-DbB6dLD9.js} +1 -1
- package/dist/assets/{treemap-KMMF4GRG-DzpCHjjP.js → treemap-KMMF4GRG-Cm_v04dc.js} +1 -1
- package/dist/assets/{trending-up-COWs9Nc7.js → trending-up-C8H38O_j.js} +1 -1
- package/dist/assets/{validation-badge-IPkKaNb8.js → validation-badge-Bg0rq4Tp.js} +1 -1
- package/dist/assets/{xychartDiagram-PRI3JC2R-CFAKvOPr.js → xychartDiagram-PRI3JC2R-DCoq2bZ7.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/dist/assets/channel-DTtYVPxU.js +0 -1
- package/dist/assets/classDiagram-2ON5EDUG-DEiSx8NZ.js +0 -1
- package/dist/assets/classDiagram-v2-WZHVMYZB-DEiSx8NZ.js +0 -1
- package/dist/assets/clone-B-FuuJTp.js +0 -1
- package/dist/assets/stateDiagram-v2-4FDKWEC3-oN7y0aok.js +0 -1
package/bin/harnspec-ui.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { spawn, spawnSync } from 'child_process';
|
|
10
|
-
import { existsSync } from 'fs';
|
|
10
|
+
import { existsSync, readFileSync } from 'fs';
|
|
11
11
|
import { join, dirname } from 'path';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
13
|
import { createRequire } from 'module';
|
|
@@ -32,6 +32,12 @@ if (!existsSync(DIST_DIR)) {
|
|
|
32
32
|
* Try to resolve @harnspec/http-server from multiple locations
|
|
33
33
|
*/
|
|
34
34
|
function resolveHttpServer() {
|
|
35
|
+
// If we're in the monorepo, try that first
|
|
36
|
+
const monorepoPath = join(__dirname, '..', '..', 'http-server', 'bin', 'harnspec-http.js');
|
|
37
|
+
if (existsSync(monorepoPath)) {
|
|
38
|
+
return monorepoPath;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
// Try local resolution first
|
|
36
42
|
try {
|
|
37
43
|
return require.resolve('@harnspec/http-server/bin/harnspec-http.js');
|
|
@@ -39,15 +45,21 @@ function resolveHttpServer() {
|
|
|
39
45
|
// Continue to try other locations
|
|
40
46
|
}
|
|
41
47
|
|
|
48
|
+
// Try resolving from the same node_modules folder where @harnspec/ui is installed
|
|
49
|
+
const parentNodeModules = join(__dirname, '..', '..', 'http-server', 'bin', 'harnspec-http.js');
|
|
50
|
+
if (existsSync(parentNodeModules)) {
|
|
51
|
+
return parentNodeModules;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
// Try resolving from global npm modules
|
|
43
55
|
try {
|
|
44
|
-
const
|
|
56
|
+
const npmRootResult = spawnSync('npm', ['root', '-g'], {
|
|
45
57
|
encoding: 'utf8',
|
|
46
58
|
shell: true
|
|
47
59
|
});
|
|
48
|
-
if (
|
|
60
|
+
if (npmRootResult.status === 0 && npmRootResult.stdout) {
|
|
49
61
|
const globalPath = join(
|
|
50
|
-
|
|
62
|
+
npmRootResult.stdout.trim(),
|
|
51
63
|
'@harnspec',
|
|
52
64
|
'http-server',
|
|
53
65
|
'bin',
|
|
@@ -68,36 +80,41 @@ function resolveHttpServer() {
|
|
|
68
80
|
* Auto-install @harnspec/http-server globally using npm
|
|
69
81
|
*/
|
|
70
82
|
function installHttpServer() {
|
|
71
|
-
console.log('📦 @harnspec/http-server not found,
|
|
83
|
+
console.log('📦 @harnspec/http-server not found, attempting to install globally...');
|
|
72
84
|
console.log('');
|
|
73
85
|
|
|
74
86
|
// Get the version of @harnspec/ui to match
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
try {
|
|
88
|
+
const uiPkg = JSON.parse(
|
|
89
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf8')
|
|
90
|
+
);
|
|
91
|
+
const version = uiPkg.version;
|
|
92
|
+
const packageSpec = version.includes('dev')
|
|
93
|
+
? '@harnspec/http-server@dev'
|
|
94
|
+
: `@harnspec/http-server@^${version}`;
|
|
95
|
+
|
|
96
|
+
// Install globally so it persists across npx runs
|
|
97
|
+
const result = spawnSync('npm', ['install', '-g', packageSpec], {
|
|
98
|
+
stdio: 'inherit',
|
|
99
|
+
shell: true
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (result.status !== 0) {
|
|
103
|
+
console.error('');
|
|
104
|
+
console.error('Failed to auto-install @harnspec/http-server');
|
|
105
|
+
console.error('');
|
|
106
|
+
console.error('Please install manually:');
|
|
107
|
+
console.error(' npm install -g @harnspec/http-server');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log('');
|
|
112
|
+
console.log('✅ @harnspec/http-server installed globally');
|
|
113
|
+
console.log('');
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error('Failed to read package.json for auto-install:', err.message);
|
|
95
116
|
process.exit(1);
|
|
96
117
|
}
|
|
97
|
-
|
|
98
|
-
console.log('');
|
|
99
|
-
console.log('✅ @harnspec/http-server installed globally');
|
|
100
|
-
console.log('');
|
|
101
118
|
}
|
|
102
119
|
|
|
103
120
|
// Try to resolve http-server, install if needed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as re,u as U,aP as oe,aQ as he,aR as xe,r as m,j as e,aS as B,C as F,l as z,aT as J,a as r,aU as me,i as V,k as $,aV as q,aW as ee,aX as _,aY as Q,aZ as W,a_ as X,a$ as Y,b0 as v,D as S,b as T,c as P,d as M,b1 as L,b2 as R,B as A,b3 as ue,b4 as Z}from"./index-Bo42UlS3.js";const je=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],G=re("pen",je);function u({htmlFor:s,children:j,className:n=""}){return e.jsx("label",{htmlFor:s,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${n}`,children:j})}function Ne(){var H,O;const{t:s}=U("common"),j=oe(),{data:n,isLoading:g,error:a,refetch:i}=he(),{updateProvider:h,deleteProvider:d,updateModel:o,deleteModel:x,updateDefaults:N}=xe(),f=(a==null?void 0:a.message)??null,[l,c]=m.useState(!1),[se,C]=m.useState(null),[te,b]=m.useState(!1),[y,k]=m.useState(null),[K,D]=m.useState(null),[I,w]=m.useState(null),ae=t=>{D(t)},ie=async()=>{!n||!K||(await d({config:n,providerId:K}),D(null))},ne=async t=>{n&&(await h({config:n,provider:t}),c(!1),C(null))},le=async(t,p)=>{n&&(await o({config:n,providerId:t,model:p}),b(!1),k(null))},de=(t,p)=>{w({providerId:t,modelId:p})},ce=async()=>{!n||!I||(await x({config:n,providerId:I.providerId,modelId:I.modelId}),w(null))},E=async(t,p)=>{n&&await N({config:n,field:t,value:p})};return g?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:s("actions.loading")})}):f||!n?e.jsx(B,{children:e.jsx(F,{children:e.jsxs(z,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(J,{className:"h-5 w-5"}),e.jsx("p",{children:f||s("chat.settings.errors.loadConfiguration")})]}),e.jsx(r,{onClick:()=>i(),className:"mt-4",children:s("actions.retry")})]})})}):e.jsxs("div",{className:"h-full overflow-auto",children:[e.jsxs(B,{contentClassName:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>j(-1),children:e.jsx(me,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("chat.settings.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("chat.settings.description")})]})]}),e.jsxs(F,{children:[e.jsx(V,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx($,{children:s("chat.settings.providers")}),e.jsx(q,{children:s("chat.settings.providersDescription")})]}),e.jsxs(r,{onClick:()=>{C(null),c(!0)},size:"sm",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),s("chat.settings.addProvider")]})]})}),e.jsx(z,{className:"space-y-4",children:n.providers.map(t=>e.jsx(ge,{provider:t,isDefault:n.settings.defaultProviderId===t.id,onEdit:()=>{C(t),c(!0)},onDelete:()=>ae(t.id),onAddModel:()=>{k({providerId:t.id,model:null}),b(!0)},onEditModel:p=>{k({providerId:t.id,model:p}),b(!0)},onDeleteModel:p=>de(t.id,p)},t.id))})]}),e.jsxs(F,{children:[e.jsxs(V,{children:[e.jsx($,{children:s("chat.settings.defaults")}),e.jsx(q,{children:s("chat.settings.defaultsDescription")})]}),e.jsx(z,{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"default-provider",children:s("chat.settings.defaultProvider")}),e.jsxs(_,{value:n.settings.defaultProviderId,onValueChange:t=>E("defaultProviderId",t),children:[e.jsx(Q,{id:"default-provider",children:e.jsx(W,{})}),e.jsx(X,{children:n.providers.map(t=>e.jsx(Y,{value:t.id,disabled:!t.hasApiKey,children:t.name},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"default-model",children:s("chat.settings.defaultModel")}),e.jsxs(_,{value:n.settings.defaultModelId,onValueChange:t=>E("defaultModelId",t),children:[e.jsx(Q,{id:"default-model",children:e.jsx(W,{})}),e.jsx(X,{children:(H=n.providers.find(t=>t.id===n.settings.defaultProviderId))==null?void 0:H.models.map(t=>e.jsx(Y,{value:t.id,children:t.name},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"max-steps",children:s("chat.settings.maxSteps")}),e.jsx(v,{id:"max-steps",type:"number",min:1,max:50,value:n.settings.maxSteps,onChange:t=>E("maxSteps",Number(t.target.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("chat.settings.maxStepsHelp")})]})]})})]})]}),l&&e.jsx(pe,{provider:se,existingIds:n.providers.map(t=>t.id),onSave:ne,onCancel:()=>{c(!1),C(null)}}),te&&y&&e.jsx(ve,{model:y.model,providerId:y.providerId,existingIds:((O=n.providers.find(t=>t.id===y.providerId))==null?void 0:O.models.map(t=>t.id))??[],onSave:t=>le(y.providerId,t),onCancel:()=>{b(!1),k(null)}}),e.jsx(S,{open:!!K,onOpenChange:t=>!t&&D(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:s("chat.settings.deleteProviderTitle")}),e.jsx(L,{children:s("chat.settings.confirmDeleteProvider")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>D(null),children:s("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:ie,children:s("actions.delete")})]})]})}),e.jsx(S,{open:!!I,onOpenChange:t=>!t&&w(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:s("chat.settings.deleteModelTitle")}),e.jsx(L,{children:s("chat.settings.confirmDeleteModel")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>w(null),children:s("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:ce,children:s("actions.delete")})]})]})})]})}function ge({provider:s,isDefault:j,onEdit:n,onDelete:g,onAddModel:a,onEditModel:i,onDeleteModel:h}){const{t:d}=U("common");return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:s.name}),j&&e.jsx(A,{variant:"secondary",className:"text-xs",children:d("chat.settings.default")}),s.hasApiKey?e.jsxs(A,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),d("chat.settings.keyConfigured")]}):e.jsxs(A,{variant:"destructive",className:"text-xs gap-1",children:[e.jsx(J,{className:"h-3 w-3"}),d("chat.settings.noKey")]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[s.id," ",s.baseURL&&`• ${s.baseURL}`]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:n,children:e.jsx(G,{className:"h-4 w-4"})}),e.jsx(r,{variant:"ghost",size:"icon",onClick:g,children:e.jsx(Z,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:d("chat.settings.models")}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(ee,{className:"h-3 w-3 mr-1"}),d("chat.settings.addModel")]})]}),e.jsx("div",{className:"space-y-1",children:s.models.map(o=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1 px-2 rounded hover:bg-muted",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs",children:o.id}),e.jsx("span",{className:"mx-2 text-muted-foreground",children:"•"}),e.jsx("span",{children:o.name}),o.maxTokens&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",o.maxTokens.toLocaleString()," tokens)"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>i(o),children:e.jsx(G,{className:"h-3 w-3"})}),e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>h(o.id),children:e.jsx(Z,{className:"h-3 w-3"})})]})]},o.id))})]})]})}function pe({provider:s,existingIds:j,onSave:n,onCancel:g}){const{t:a}=U("common"),[i,h]=m.useState({id:(s==null?void 0:s.id)??"",name:(s==null?void 0:s.name)??"",baseURL:(s==null?void 0:s.baseURL)??"",apiKey:"",hasApiKey:(s==null?void 0:s.hasApiKey)??!1}),[d,o]=m.useState({}),x=!!s,N=()=>{const l={};return i.id.trim()?!x&&j.includes(i.id)?l.id=a("chat.settings.errors.idExists"):/^[a-z0-9-]+$/.test(i.id)||(l.id=a("chat.settings.errors.idInvalid")):l.id=a("chat.settings.errors.idRequired"),i.name.trim()||(l.name=a("chat.settings.errors.nameRequired")),i.baseURL&&!i.baseURL.match(/^https?:\/\//)&&(l.baseURL=a("chat.settings.errors.urlInvalid")),o(l),Object.keys(l).length===0},f=()=>{if(!N())return;const l=i.apiKey.trim();n({id:i.id,name:i.name,baseURL:i.baseURL||void 0,models:(s==null?void 0:s.models)??[],hasApiKey:l?!0:i.hasApiKey,apiKey:l||void 0})};return e.jsx(S,{open:!0,onOpenChange:g,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(x?"chat.settings.editProvider":"chat.settings.addProvider")}),e.jsx(L,{children:a("chat.settings.providerDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"provider-id",children:[a("chat.settings.providerId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"provider-id",value:i.id,onChange:l=>h({...i,id:l.target.value}),placeholder:a("chat.settings.placeholders.providerId"),disabled:x}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.providerIdHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"provider-name",children:[a("chat.settings.providerName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"provider-name",value:i.name,onChange:l=>h({...i,name:l.target.value}),placeholder:a("chat.settings.placeholders.providerName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"provider-baseurl",children:a("chat.settings.baseURL")}),e.jsx(v,{id:"provider-baseurl",value:i.baseURL,onChange:l=>h({...i,baseURL:l.target.value}),placeholder:a("chat.settings.placeholders.baseUrl")}),d.baseURL&&e.jsx("p",{className:"text-xs text-destructive",children:d.baseURL}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.baseURLHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"provider-apikey",children:a("chat.settings.apiKey")}),e.jsx(v,{id:"provider-apikey",type:"password",value:i.apiKey,onChange:l=>h({...i,apiKey:l.target.value}),placeholder:a(x?"chat.settings.placeholders.apiKeyMasked":"chat.settings.placeholders.apiKeyEnv")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.apiKeyHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:g,children:a("actions.cancel")}),e.jsx(r,{onClick:f,children:a("actions.save")})]})]})})}function ve({model:s,existingIds:j,onSave:n,onCancel:g}){var l;const{t:a}=U("common"),[i,h]=m.useState({id:(s==null?void 0:s.id)??"",name:(s==null?void 0:s.name)??"",maxTokens:((l=s==null?void 0:s.maxTokens)==null?void 0:l.toString())??""}),[d,o]=m.useState({}),x=!!s,N=()=>{const c={};return i.id.trim()?!x&&j.includes(i.id)&&(c.id=a("chat.settings.errors.modelIdExists")):c.id=a("chat.settings.errors.modelIdRequired"),i.name.trim()||(c.name=a("chat.settings.errors.modelNameRequired")),i.maxTokens&&Number.isNaN(Number(i.maxTokens))&&(c.maxTokens=a("chat.settings.errors.maxTokensInvalid")),o(c),Object.keys(c).length===0},f=()=>{N()&&n({id:i.id,name:i.name,maxTokens:i.maxTokens?Number(i.maxTokens):void 0})};return e.jsx(S,{open:!0,onOpenChange:g,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(x?"chat.settings.editModel":"chat.settings.addModel")}),e.jsx(L,{children:a("chat.settings.modelDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"model-id",children:[a("chat.settings.modelId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"model-id",value:i.id,onChange:c=>h({...i,id:c.target.value}),placeholder:a("chat.settings.placeholders.modelId"),disabled:x}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"model-name",children:[a("chat.settings.modelName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"model-name",value:i.name,onChange:c=>h({...i,name:c.target.value}),placeholder:a("chat.settings.placeholders.modelName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"model-maxtokens",children:a("chat.settings.maxTokens")}),e.jsx(v,{id:"model-maxtokens",type:"number",value:i.maxTokens,onChange:c=>h({...i,maxTokens:c.target.value}),placeholder:a("chat.settings.placeholders.maxTokens")}),d.maxTokens&&e.jsx("p",{className:"text-xs text-destructive",children:d.maxTokens}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.maxTokensHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:g,children:a("actions.cancel")}),e.jsx(r,{onClick:f,children:a("actions.save")})]})]})})}export{Ne as ChatSettingsPage};
|
|
1
|
+
import{h as re,u as U,aP as oe,aQ as he,aR as xe,r as m,j as e,aS as B,C as F,l as z,aT as J,a as r,aU as me,i as V,k as $,aV as q,aW as ee,aX as _,aY as Q,aZ as W,a_ as X,a$ as Y,b0 as v,D as S,b as T,c as P,d as M,b1 as L,b2 as R,B as A,b3 as ue,b4 as Z}from"./index-BlyOVhDj.js";const je=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],G=re("pen",je);function u({htmlFor:s,children:j,className:n=""}){return e.jsx("label",{htmlFor:s,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${n}`,children:j})}function Ne(){var H,O;const{t:s}=U("common"),j=oe(),{data:n,isLoading:g,error:a,refetch:i}=he(),{updateProvider:h,deleteProvider:d,updateModel:o,deleteModel:x,updateDefaults:N}=xe(),f=(a==null?void 0:a.message)??null,[l,c]=m.useState(!1),[se,C]=m.useState(null),[te,b]=m.useState(!1),[y,k]=m.useState(null),[K,D]=m.useState(null),[I,w]=m.useState(null),ae=t=>{D(t)},ie=async()=>{!n||!K||(await d({config:n,providerId:K}),D(null))},ne=async t=>{n&&(await h({config:n,provider:t}),c(!1),C(null))},le=async(t,p)=>{n&&(await o({config:n,providerId:t,model:p}),b(!1),k(null))},de=(t,p)=>{w({providerId:t,modelId:p})},ce=async()=>{!n||!I||(await x({config:n,providerId:I.providerId,modelId:I.modelId}),w(null))},E=async(t,p)=>{n&&await N({config:n,field:t,value:p})};return g?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:s("actions.loading")})}):f||!n?e.jsx(B,{children:e.jsx(F,{children:e.jsxs(z,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(J,{className:"h-5 w-5"}),e.jsx("p",{children:f||s("chat.settings.errors.loadConfiguration")})]}),e.jsx(r,{onClick:()=>i(),className:"mt-4",children:s("actions.retry")})]})})}):e.jsxs("div",{className:"h-full overflow-auto",children:[e.jsxs(B,{contentClassName:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>j(-1),children:e.jsx(me,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("chat.settings.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("chat.settings.description")})]})]}),e.jsxs(F,{children:[e.jsx(V,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx($,{children:s("chat.settings.providers")}),e.jsx(q,{children:s("chat.settings.providersDescription")})]}),e.jsxs(r,{onClick:()=>{C(null),c(!0)},size:"sm",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),s("chat.settings.addProvider")]})]})}),e.jsx(z,{className:"space-y-4",children:n.providers.map(t=>e.jsx(ge,{provider:t,isDefault:n.settings.defaultProviderId===t.id,onEdit:()=>{C(t),c(!0)},onDelete:()=>ae(t.id),onAddModel:()=>{k({providerId:t.id,model:null}),b(!0)},onEditModel:p=>{k({providerId:t.id,model:p}),b(!0)},onDeleteModel:p=>de(t.id,p)},t.id))})]}),e.jsxs(F,{children:[e.jsxs(V,{children:[e.jsx($,{children:s("chat.settings.defaults")}),e.jsx(q,{children:s("chat.settings.defaultsDescription")})]}),e.jsx(z,{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"default-provider",children:s("chat.settings.defaultProvider")}),e.jsxs(_,{value:n.settings.defaultProviderId,onValueChange:t=>E("defaultProviderId",t),children:[e.jsx(Q,{id:"default-provider",children:e.jsx(W,{})}),e.jsx(X,{children:n.providers.map(t=>e.jsx(Y,{value:t.id,disabled:!t.hasApiKey,children:t.name},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"default-model",children:s("chat.settings.defaultModel")}),e.jsxs(_,{value:n.settings.defaultModelId,onValueChange:t=>E("defaultModelId",t),children:[e.jsx(Q,{id:"default-model",children:e.jsx(W,{})}),e.jsx(X,{children:(H=n.providers.find(t=>t.id===n.settings.defaultProviderId))==null?void 0:H.models.map(t=>e.jsx(Y,{value:t.id,children:t.name},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"max-steps",children:s("chat.settings.maxSteps")}),e.jsx(v,{id:"max-steps",type:"number",min:1,max:50,value:n.settings.maxSteps,onChange:t=>E("maxSteps",Number(t.target.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("chat.settings.maxStepsHelp")})]})]})})]})]}),l&&e.jsx(pe,{provider:se,existingIds:n.providers.map(t=>t.id),onSave:ne,onCancel:()=>{c(!1),C(null)}}),te&&y&&e.jsx(ve,{model:y.model,providerId:y.providerId,existingIds:((O=n.providers.find(t=>t.id===y.providerId))==null?void 0:O.models.map(t=>t.id))??[],onSave:t=>le(y.providerId,t),onCancel:()=>{b(!1),k(null)}}),e.jsx(S,{open:!!K,onOpenChange:t=>!t&&D(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:s("chat.settings.deleteProviderTitle")}),e.jsx(L,{children:s("chat.settings.confirmDeleteProvider")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>D(null),children:s("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:ie,children:s("actions.delete")})]})]})}),e.jsx(S,{open:!!I,onOpenChange:t=>!t&&w(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:s("chat.settings.deleteModelTitle")}),e.jsx(L,{children:s("chat.settings.confirmDeleteModel")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>w(null),children:s("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:ce,children:s("actions.delete")})]})]})})]})}function ge({provider:s,isDefault:j,onEdit:n,onDelete:g,onAddModel:a,onEditModel:i,onDeleteModel:h}){const{t:d}=U("common");return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:s.name}),j&&e.jsx(A,{variant:"secondary",className:"text-xs",children:d("chat.settings.default")}),s.hasApiKey?e.jsxs(A,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),d("chat.settings.keyConfigured")]}):e.jsxs(A,{variant:"destructive",className:"text-xs gap-1",children:[e.jsx(J,{className:"h-3 w-3"}),d("chat.settings.noKey")]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[s.id," ",s.baseURL&&`• ${s.baseURL}`]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:n,children:e.jsx(G,{className:"h-4 w-4"})}),e.jsx(r,{variant:"ghost",size:"icon",onClick:g,children:e.jsx(Z,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:d("chat.settings.models")}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(ee,{className:"h-3 w-3 mr-1"}),d("chat.settings.addModel")]})]}),e.jsx("div",{className:"space-y-1",children:s.models.map(o=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1 px-2 rounded hover:bg-muted",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs",children:o.id}),e.jsx("span",{className:"mx-2 text-muted-foreground",children:"•"}),e.jsx("span",{children:o.name}),o.maxTokens&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",o.maxTokens.toLocaleString()," tokens)"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>i(o),children:e.jsx(G,{className:"h-3 w-3"})}),e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>h(o.id),children:e.jsx(Z,{className:"h-3 w-3"})})]})]},o.id))})]})]})}function pe({provider:s,existingIds:j,onSave:n,onCancel:g}){const{t:a}=U("common"),[i,h]=m.useState({id:(s==null?void 0:s.id)??"",name:(s==null?void 0:s.name)??"",baseURL:(s==null?void 0:s.baseURL)??"",apiKey:"",hasApiKey:(s==null?void 0:s.hasApiKey)??!1}),[d,o]=m.useState({}),x=!!s,N=()=>{const l={};return i.id.trim()?!x&&j.includes(i.id)?l.id=a("chat.settings.errors.idExists"):/^[a-z0-9-]+$/.test(i.id)||(l.id=a("chat.settings.errors.idInvalid")):l.id=a("chat.settings.errors.idRequired"),i.name.trim()||(l.name=a("chat.settings.errors.nameRequired")),i.baseURL&&!i.baseURL.match(/^https?:\/\//)&&(l.baseURL=a("chat.settings.errors.urlInvalid")),o(l),Object.keys(l).length===0},f=()=>{if(!N())return;const l=i.apiKey.trim();n({id:i.id,name:i.name,baseURL:i.baseURL||void 0,models:(s==null?void 0:s.models)??[],hasApiKey:l?!0:i.hasApiKey,apiKey:l||void 0})};return e.jsx(S,{open:!0,onOpenChange:g,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(x?"chat.settings.editProvider":"chat.settings.addProvider")}),e.jsx(L,{children:a("chat.settings.providerDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"provider-id",children:[a("chat.settings.providerId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"provider-id",value:i.id,onChange:l=>h({...i,id:l.target.value}),placeholder:a("chat.settings.placeholders.providerId"),disabled:x}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.providerIdHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"provider-name",children:[a("chat.settings.providerName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"provider-name",value:i.name,onChange:l=>h({...i,name:l.target.value}),placeholder:a("chat.settings.placeholders.providerName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"provider-baseurl",children:a("chat.settings.baseURL")}),e.jsx(v,{id:"provider-baseurl",value:i.baseURL,onChange:l=>h({...i,baseURL:l.target.value}),placeholder:a("chat.settings.placeholders.baseUrl")}),d.baseURL&&e.jsx("p",{className:"text-xs text-destructive",children:d.baseURL}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.baseURLHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"provider-apikey",children:a("chat.settings.apiKey")}),e.jsx(v,{id:"provider-apikey",type:"password",value:i.apiKey,onChange:l=>h({...i,apiKey:l.target.value}),placeholder:a(x?"chat.settings.placeholders.apiKeyMasked":"chat.settings.placeholders.apiKeyEnv")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.apiKeyHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:g,children:a("actions.cancel")}),e.jsx(r,{onClick:f,children:a("actions.save")})]})]})})}function ve({model:s,existingIds:j,onSave:n,onCancel:g}){var l;const{t:a}=U("common"),[i,h]=m.useState({id:(s==null?void 0:s.id)??"",name:(s==null?void 0:s.name)??"",maxTokens:((l=s==null?void 0:s.maxTokens)==null?void 0:l.toString())??""}),[d,o]=m.useState({}),x=!!s,N=()=>{const c={};return i.id.trim()?!x&&j.includes(i.id)&&(c.id=a("chat.settings.errors.modelIdExists")):c.id=a("chat.settings.errors.modelIdRequired"),i.name.trim()||(c.name=a("chat.settings.errors.modelNameRequired")),i.maxTokens&&Number.isNaN(Number(i.maxTokens))&&(c.maxTokens=a("chat.settings.errors.maxTokensInvalid")),o(c),Object.keys(c).length===0},f=()=>{N()&&n({id:i.id,name:i.name,maxTokens:i.maxTokens?Number(i.maxTokens):void 0})};return e.jsx(S,{open:!0,onOpenChange:g,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(x?"chat.settings.editModel":"chat.settings.addModel")}),e.jsx(L,{children:a("chat.settings.modelDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"model-id",children:[a("chat.settings.modelId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"model-id",value:i.id,onChange:c=>h({...i,id:c.target.value}),placeholder:a("chat.settings.placeholders.modelId"),disabled:x}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(u,{htmlFor:"model-name",children:[a("chat.settings.modelName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(v,{id:"model-name",value:i.name,onChange:c=>h({...i,name:c.target.value}),placeholder:a("chat.settings.placeholders.modelName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"model-maxtokens",children:a("chat.settings.maxTokens")}),e.jsx(v,{id:"model-maxtokens",type:"number",value:i.maxTokens,onChange:c=>h({...i,maxTokens:c.target.value}),placeholder:a("chat.settings.placeholders.maxTokens")}),d.maxTokens&&e.jsx("p",{className:"text-xs text-destructive",children:d.maxTokens}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.maxTokensHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:g,children:a("actions.cancel")}),e.jsx(r,{onClick:f,children:a("actions.save")})]})]})})}export{Ne as ChatSettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as $,r as m,u as C,j as e,aS as v,a as k,aU as H,bU as L,bA as V,bV as I,B as f,bW as J,bX as W,bY as U,bZ as q,b_ as R,b$ as X,c0 as G,c1 as Y,c2 as Z,bm as K,bf as Q,bn as ee,b0 as te,br as se,C as y,l as b,c3 as D,f as O,c4 as z,c5 as ne,i as ae,k as oe,aV as ce,aT as T,bh as re,c6 as le,c7 as ie}from"./index-
|
|
1
|
+
import{h as $,r as m,u as C,j as e,aS as v,a as k,aU as H,bU as L,bA as V,bV as I,B as f,bW as J,bX as W,bY as U,bZ as q,b_ as R,b$ as X,c0 as G,c1 as Y,c2 as Z,bm as K,bf as Q,bn as ee,b0 as te,br as se,C as y,l as b,c3 as D,f as O,c4 as z,c5 as ne,i as ae,k as oe,aV as ce,aT as T,bh as re,c6 as le,c7 as ie}from"./index-BlyOVhDj.js";import{T as de,a as xe}from"./table-of-contents-Cnkk8UZa.js";import{I as me}from"./info-Cl-KzKzC.js";const ge=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],he=$("external-link",ge);const pe=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],ue=$("type",pe);function fe(t){return e.jsx("input",{type:"checkbox",...t,className:"appearance-none h-4 w-4 shrink-0 rounded-sm border border-input bg-background disabled:cursor-default checked:bg-primary checked:border-primary relative mr-2 top-[3px] align-middle after:content-[''] after:hidden checked:after:block after:absolute after:left-[5px] after:top-[1px] after:w-[4px] after:h-[8px] after:border-r-[2px] after:border-b-[2px] after:border-primary-foreground after:rotate-45"})}function je(t,o){return`vscode://file${o.startsWith("/")?o:`${t}/${o}`}`}function Ne({file:t,projectRoot:o,onBack:i}){const[s,x]=m.useState(!1),r=t.name.toLowerCase().endsWith(".md"),c=t.name.toLowerCase().endsWith(".json"),{t:n,i18n:l}=C("common"),h=m.useMemo(()=>t.content,[t.content]),g=async()=>{try{await navigator.clipboard.writeText(t.content),x(!0),setTimeout(()=>x(!1),1500)}catch(a){console.error("Failed to copy context content",a)}},u=()=>{o&&window.open(je(o,t.path),"_blank")};return e.jsxs(v,{contentClassName:"space-y-6",children:[e.jsxs("header",{className:"flex flex-col gap-3 sticky top-14 bg-background py-2 z-10",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsxs(k,{variant:"ghost",size:"sm",onClick:i,className:"h-8 px-2",children:[e.jsx(H,{className:"h-4 w-4 mr-1"}),n("contextPage.detail.back")]}),e.jsx(L,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold leading-tight break-words",children:t.name}),e.jsx("span",{className:"text-xs text-muted-foreground break-all",children:t.path})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o&&e.jsxs(k,{variant:"ghost",size:"sm",onClick:u,className:"h-8 px-3 text-xs",children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1"}),n("contextPage.detail.openInEditor")]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:g,className:"h-8 px-3 text-xs",children:[s?e.jsx(V,{className:"h-3.5 w-3.5 mr-1 text-green-600"}):e.jsx(I,{className:"h-3.5 w-3.5 mr-1"}),n(s?"contextPage.detail.copySuccess":"contextPage.detail.copy")]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),t.fileType||n("contextPage.detail.defaultFileType")]}),e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(J,{className:"h-3 w-3"}),n("contextPage.badges.tokens",{formattedCount:t.tokenCount.toLocaleString()})]}),e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),n("contextPage.detail.lines",{count:t.lineCount})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(W,{className:"h-3.5 w-3.5"}),n("contextPage.detail.modified",{date:U(t.modified??t.modifiedAt,l.language)})]}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:n("contextPage.detail.size",{size:(t.size/1024).toFixed(1)})})]})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsx("div",{className:"overflow-hidden p-4 sm:p-6",children:c?e.jsx("pre",{className:"p-3 text-sm overflow-x-auto bg-muted/40 rounded-md border whitespace-pre-wrap",children:(()=>{try{return JSON.stringify(JSON.parse(t.content),null,2)}catch(a){return console.error("Failed to parse JSON context file",a),t.content}})()}):r?e.jsx("article",{className:"prose prose-slate dark:prose-invert max-w-none prose-sm sm:prose-base",children:e.jsx(q,{remarkPlugins:[G,Y],rehypePlugins:[R,X],components:{input:a=>a.type==="checkbox"?e.jsx(fe,{...a}):e.jsx("input",{...a}),pre:({children:a,...d})=>{var P,S,p,N;const j=(Array.isArray(a)?a:[a])[0];if(j&&typeof j=="object"&&"props"in j&&typeof((P=j.props)==null?void 0:P.className)=="string"&&((p=(S=j.props)==null?void 0:S.className)!=null&&p.includes("language-mermaid"))){const M=(N=j.props)==null?void 0:N.children,_=typeof M=="string"?M:"";return e.jsx(Z,{chart:_})}return e.jsx("pre",{...d,children:a})}},children:t.content})}):e.jsx("pre",{className:"p-3 text-sm overflow-x-auto bg-muted/40 rounded-md border whitespace-pre-wrap",children:t.content})}),r&&e.jsx("aside",{className:"hidden xl:block sticky top-28 h-[calc(100dvh-8rem)] overflow-y-auto",children:e.jsx(de,{content:h})})]}),r&&e.jsx("div",{className:"xl:hidden",children:e.jsx(xe,{content:h})})]})}function A(t){return t<5e3?"text-green-600 dark:text-green-400":t<1e4?"text-blue-600 dark:text-blue-400":t<2e4?"text-yellow-600 dark:text-yellow-400":"text-red-600 dark:text-red-400"}function w(t,o){if(!o||o.length<2)return 0;const i=new RegExp(o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),s=t.match(i);return s?s.length:0}function B({icon:t,title:o,description:i,suggestion:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(t,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1 max-w-xs",children:i}),s&&e.jsx("p",{className:"text-xs text-primary mt-2",children:s})]})}function ye({file:t,searchQuery:o,onClick:i}){const{t:s}=C("common"),x=o?w(t.content,o):0;if(!(!o||x>0||t.name.toLowerCase().includes(o.toLowerCase())))return null;const c=x===1?s("contextPage.badges.matchesSingular",{count:x}):s("contextPage.badges.matchesPlural",{count:x}),n=s("contextPage.badges.tokens",{formattedCount:t.tokenCount.toLocaleString()});return e.jsx("button",{onClick:i,className:"w-full text-left p-4 rounded-lg border border-border bg-card hover:bg-accent transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(L,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:t.path})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o&&x>0&&e.jsx(f,{variant:"secondary",className:"text-xs bg-yellow-100 dark:bg-yellow-900",children:c}),e.jsxs(f,{variant:"outline",className:"text-xs",children:[e.jsx(D,{className:"h-3 w-3 mr-1"}),n]})]})]})})}function F({title:t,description:o,icon:i,files:s,emptyMessage:x,emptySuggestion:r,searchQuery:c,onFileSelect:n}){const{t:l}=C("common"),h=s.reduce((p,N)=>p+N.tokenCount,0),g=m.useMemo(()=>!c||c.length<2?s:s.filter(p=>{const N=w(p.content,c),M=p.name.toLowerCase().includes(c.toLowerCase());return N>0||M}),[s,c]),u=m.useMemo(()=>!c||c.length<2?0:g.reduce((p,N)=>p+w(N.content,c),0),[g,c]),a=g.length,d=m.useMemo(()=>u===1?l("contextPage.badges.matchesSingular",{count:u}):l("contextPage.badges.matchesPlural",{count:u}),[l,u]),E=m.useMemo(()=>a===s.length?a===1?l("contextPage.badges.filesSingular",{count:a}):l("contextPage.badges.filesPlural",{count:a}):l("contextPage.badges.filesFiltered",{count:a,total:s.length}),[s.length,a,l]),j=m.useMemo(()=>l("contextPage.badges.tokens",{formattedCount:h.toLocaleString()}),[l,h]),P=c?l("contextPage.search.noMatchesTitle"):x,S=l(c?"contextPage.search.noMatchesDescription":"contextPage.search.noFilesDescription");return e.jsxs(y,{children:[e.jsx(ae,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(i,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(oe,{className:"text-lg",children:t}),e.jsx(ce,{children:o})]})]}),s.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[c&&u>0&&e.jsx(f,{variant:"secondary",className:"text-xs bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200",children:d}),e.jsx(f,{variant:"secondary",className:"text-xs",children:E}),e.jsxs(f,{variant:"outline",className:O("text-xs",A(h)),children:[e.jsx(D,{className:"h-3 w-3 mr-1"}),j]})]})]})}),e.jsx(b,{children:g.length===0?e.jsx(B,{icon:T,title:P,description:S,suggestion:c?void 0:r}):e.jsx("div",{className:"space-y-3",children:g.map(p=>e.jsx(ye,{file:p,searchQuery:c,onClick:()=>n==null?void 0:n(p)},p.path))})})]})}function be({context:t}){const[o,i]=m.useState(!1),[s,x]=m.useState(""),[r,c]=m.useState(null),{t:n}=C("common"),l=async()=>{const a=[];for(const d of t.agentInstructions)a.push(`# ${d.path}
|
|
2
2
|
|
|
3
3
|
${d.content}
|
|
4
4
|
`);t.config.file&&a.push(`# ${t.config.file.path}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as $,j as e,c8 as j,B,c9 as F,ca as E,u as T,bB as I,aS as w,bU as R,bX as A,cb as S,cc as U,C as m,i as u,k as p,l as x,a as f,L as M,bh as q,bj as V,cd as z,r as D,ce as Q,aT as _}from"./index-
|
|
1
|
+
import{h as $,j as e,c8 as j,B,c9 as F,ca as E,u as T,bB as I,aS as w,bU as R,bX as A,cb as S,cc as U,C as m,i as u,k as p,l as x,a as f,L as M,bh as q,bj as V,cd as z,r as D,ce as Q,aT as _}from"./index-BlyOVhDj.js";import{S as N}from"./stat-card-BEjjOCD2.js";import{T as L}from"./trending-up-C8H38O_j.js";const H=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],W=$("calendar",H);function C({spec:s,basePath:i="/projects"}){const n=s.title||s.specName,c=`${i}/specs/${s.specName}`;return e.jsx(j,{to:c,className:"block p-3 rounded-lg hover:bg-accent transition-colors",title:s.specName,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.specNumber&&e.jsxs("span",{className:"text-sm font-mono text-muted-foreground shrink-0",children:["#",s.specNumber]}),e.jsx("h4",{className:"text-sm font-medium truncate",children:n})]}),n!==s.specName&&e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s.specName}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.slice(0,3).map(r=>e.jsx(B,{variant:"secondary",className:"text-xs",children:r},r))})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[s.status&&e.jsx(F,{status:s.status,className:"text-[11px]"}),s.priority&&e.jsx(E,{priority:s.priority,className:"text-[11px]"})]})]})})}function X({spec:s,action:i,time:n,basePath:c="/projects"}){const r=s.title||s.specName,a=`${c}/specs/${s.specName}`,{i18n:d}=T("common"),o=I(n,d.language);return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary mt-2 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[e.jsxs(j,{to:a,className:"font-medium hover:underline",title:s.specName,children:[s.specNumber&&`#${s.specNumber} `,r]})," ",e.jsx("span",{className:"text-muted-foreground",children:i})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:o})]})]})}function G({specs:s,stats:i,projectColor:n,projectName:c,basePath:r="/projects"}){const{t:a}=T("common"),d=s.filter(t=>t.status==="in-progress").sort((t,l)=>(l.specNumber||0)-(t.specNumber||0)).slice(0,5),o=s.filter(t=>t.status==="planned").sort((t,l)=>(l.specNumber||0)-(t.specNumber||0)).slice(0,5),b=s.slice().sort((t,l)=>{if(!t.createdAt)return 1;if(!l.createdAt)return-1;const v=new Date(t.createdAt).getTime();return new Date(l.createdAt).getTime()-v}).slice(0,5),g=s.filter(t=>t.updatedAt).sort((t,l)=>{if(!t.updatedAt)return 1;if(!l.updatedAt)return-1;const v=new Date(t.updatedAt).getTime();return new Date(l.updatedAt).getTime()-v}).slice(0,10),h=(i.specsByStatus??[]).reduce((t,l)=>(t[l.status]=l.count,t),{}),y=h.complete||0,k=i.completionRate??0;return e.jsxs(w,{contentClassName:"space-y-6 sm:space-y-8",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[n&&e.jsx("div",{className:"h-8 w-2 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold tracking-tight",children:a("dashboard.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:c?a("dashboard.subtitleWithProject",{projectName:c}):a("dashboard.subtitle")})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:[e.jsx(N,{title:a("dashboard.cards.total"),value:i.totalSpecs,icon:R,iconColor:"text-blue-600",gradientFrom:"from-blue-500/10"}),e.jsx(N,{title:a("dashboard.cards.planned"),value:h.planned||0,icon:A,iconColor:"text-purple-600",gradientFrom:"from-purple-500/10"}),e.jsx(N,{title:a("dashboard.cards.inProgress"),value:h["in-progress"]||0,icon:S,iconColor:"text-orange-600",gradientFrom:"from-orange-500/10"}),e.jsx(N,{title:a("dashboard.cards.completed"),value:y,icon:U,iconColor:"text-green-600",gradientFrom:"from-green-500/10",subtext:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),a("dashboard.cards.completionRate",{rate:k.toFixed(1)})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs(m,{children:[e.jsx(u,{children:e.jsxs(p,{className:"text-lg flex items-center gap-2",children:[e.jsx(W,{className:"h-5 w-5 text-blue-600"}),a("dashboard.recentlyAdded")]})}),e.jsx(x,{className:"space-y-1",children:b.slice(0,5).map(t=>e.jsx(C,{spec:t,basePath:r},t.id))})]}),e.jsxs(m,{children:[e.jsx(u,{children:e.jsxs(p,{className:"text-lg flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-purple-600"}),a("dashboard.plannedSection",{count:o.length})]})}),e.jsx(x,{className:"space-y-1",children:o.length>0?o.map(t=>e.jsx(C,{spec:t,basePath:r},t.id)):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:a("dashboard.noPlanned")})})]}),e.jsxs(m,{children:[e.jsx(u,{children:e.jsxs(p,{className:"text-lg flex items-center gap-2",children:[e.jsx(S,{className:"h-5 w-5 text-orange-600"}),a("dashboard.inProgressSection",{count:d.length})]})}),e.jsx(x,{className:"space-y-1",children:d.length>0?d.map(t=>e.jsx(C,{spec:t,basePath:r},t.id)):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:a("dashboard.noInProgress")})})]})]}),e.jsxs(m,{children:[e.jsx(u,{children:e.jsx(p,{className:"text-lg",children:a("dashboard.recentActivity")})}),e.jsx(x,{children:e.jsx("div",{className:"border-l-2 border-muted pl-4 space-y-1",children:g.map(t=>e.jsx(X,{spec:t,action:a("dashboard.actionUpdated"),time:t.updatedAt??null,basePath:r},t.id))})})]}),e.jsxs(m,{children:[e.jsx(u,{children:e.jsx(p,{className:"text-lg",children:a("dashboard.quickActions")})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(f,{asChild:!0,children:e.jsxs(j,{to:`${r}/specs`,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),a("dashboard.viewAllSpecs")]})}),e.jsx(f,{variant:"outline",asChild:!0,children:e.jsxs(j,{to:`${r}/stats`,children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("dashboard.viewStats")]})})]})})]})]})}function Y(){const{currentProject:s,loading:i}=q(),n=(s==null?void 0:s.id)??null,c=V(n),r=z(n),{t:a}=T("common"),d=s&&"color"in s?s.color:void 0,o=s!=null&&s.id?`/projects/${s.id}`:"/projects",b=D.useMemo(()=>Array.isArray(c.data)?c.data:[],[c.data]),g=r.data??null,h=D.useCallback(async()=>{await Promise.all([c.refetch(),r.refetch()])},[c,r]),y=i||c.isLoading||r.isLoading,t=c.error||r.error?a("dashboard.state.errorDescription"):null;return y?e.jsx(Q,{}):s?t?e.jsx(w,{children:e.jsx(m,{children:e.jsxs(x,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(_,{className:"h-6 w-6 text-destructive"})}),e.jsx("div",{className:"text-lg font-semibold",children:a("dashboard.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t||a("dashboard.state.errorDescription")}),e.jsx(f,{variant:"secondary",size:"sm",onClick:h,className:"mt-2",children:a("actions.retry")})]})})}):g?e.jsx(G,{specs:b,stats:g,projectColor:d,projectName:s==null?void 0:s.name,basePath:o}):null:e.jsx(w,{children:e.jsx(m,{children:e.jsxs(x,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"text-lg font-semibold",children:a("dashboard.state.noProjectTitle",{defaultValue:"No project selected"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("dashboard.state.noProjectDescription",{defaultValue:"Select or create a project to view the dashboard."})}),e.jsx(j,{to:"/projects",className:"inline-flex",children:e.jsx(f,{variant:"secondary",size:"sm",children:a("projectsPage.title",{defaultValue:"Projects"})})})]})})})}export{Y as DashboardPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as f,d5 as _e,d6 as me,x as Je,d7 as et,d8 as y,d9 as Le,da as ge,db as tt,dc as st,dd as nt,de as ve,df as rt,dg as ot,dh as at,u as Ne,j as e,cI as Oe,cc as Re,cb as Te,bX as he,cM as Ae,cN as pe,cO as Be,aT as Fe,f as C,di as ye,b5 as it,b6 as ct,a as dt,b7 as lt,b8 as ut,b9 as mt,ba as gt,bb as ht,bc as pt,bd as xt,be as De,br as ft,bf as bt,dj as $e,dk as we,dl as yt,bg as wt,aP as vt,bl as Nt,bh as jt,c7 as kt,dm as ze,dn as St,aS as Ee,bm as Et}from"./index-
|
|
1
|
+
import{r as f,d5 as _e,d6 as me,x as Je,d7 as et,d8 as y,d9 as Le,da as ge,db as tt,dc as st,dd as nt,de as ve,df as rt,dg as ot,dh as at,u as Ne,j as e,cI as Oe,cc as Re,cb as Te,bX as he,cM as Ae,cN as pe,cO as Be,aT as Fe,f as C,di as ye,b5 as it,b6 as ct,a as dt,b7 as lt,b8 as ut,b9 as mt,ba as gt,bb as ht,bc as pt,bd as xt,be as De,br as ft,bf as bt,dj as $e,dk as we,dl as yt,bg as wt,aP as vt,bl as Nt,bh as jt,c7 as kt,dm as ze,dn as St,aS as Ee,bm as Et}from"./index-BlyOVhDj.js";const We=({id:t,x:s,y:c,width:u,height:r,style:o,color:d,strokeColor:x,strokeWidth:l,className:i,borderRadius:g,shapeRendering:p,onClick:N,selected:n})=>{const{background:v,backgroundColor:k}=o||{},P=d||v||k;return y.createElement("rect",{className:ge(["react-flow__minimap-node",{selected:n},i]),x:s,y:c,rx:g,ry:g,width:u,height:r,fill:P,stroke:x,strokeWidth:l,shapeRendering:p,onClick:N?M=>N(M,t):void 0})};We.displayName="MiniMapNode";var Ct=f.memo(We);const Mt=t=>t.nodeOrigin,Pt=t=>t.getNodes().filter(s=>!s.hidden&&s.width&&s.height),Ce=t=>t instanceof Function?t:()=>t;function Dt({nodeStrokeColor:t="transparent",nodeColor:s="#e2e2e2",nodeClassName:c="",nodeBorderRadius:u=5,nodeStrokeWidth:r=2,nodeComponent:o=Ct,onClick:d}){const x=me(Pt,ve),l=me(Mt),i=Ce(s),g=Ce(t),p=Ce(c),N=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.createElement(y.Fragment,null,x.map(n=>{const{x:v,y:k}=nt(n,l).positionAbsolute;return y.createElement(o,{key:n.id,x:v,y:k,width:n.width,height:n.height,style:n.style,selected:n.selected,className:p(n),color:i(n),borderRadius:u,strokeColor:g(n),strokeWidth:r,shapeRendering:N,onClick:d,id:n.id})}))}var $t=f.memo(Dt);const zt=200,It=150,Ht=t=>{const s=t.getNodes(),c={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:c,boundingRect:s.length>0?rt(ot(s,t.nodeOrigin),c):c,rfId:t.rfId}},_t="react-flow__minimap-desc";function Ve({style:t,className:s,nodeStrokeColor:c="transparent",nodeColor:u="#e2e2e2",nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:d=2,nodeComponent:x,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:i="none",maskStrokeWidth:g=1,position:p="bottom-right",onClick:N,onNodeClick:n,pannable:v=!1,zoomable:k=!1,ariaLabel:P="React Flow mini map",inversePan:M=!1,zoomStep:E=10,offsetScale:S=5}){const A=_e(),$=f.useRef(null),{boundingRect:R,viewBB:I,rfId:Q}=me(Ht,ve),b=(t==null?void 0:t.width)??zt,O=(t==null?void 0:t.height)??It,X=R.width/b,xe=R.height/O,W=Math.max(X,xe),ce=W*b,oe=W*O,H=S*W,T=R.x-(ce-R.width)/2-H,Y=R.y-(oe-R.height)/2-H,z=ce+H*2,ae=oe+H*2,fe=`${_t}-${Q}`,Z=f.useRef(0);Z.current=W,f.useEffect(()=>{if($.current){const K=Je($.current),J=q=>{const{transform:a,d3Selection:h,d3Zoom:w}=A.getState();if(q.sourceEvent.type!=="wheel"||!h||!w)return;const D=-q.sourceEvent.deltaY*(q.sourceEvent.deltaMode===1?.05:q.sourceEvent.deltaMode?1:.002)*E,_=a[2]*Math.pow(2,D);w.scaleTo(h,_)},de=q=>{const{transform:a,d3Selection:h,d3Zoom:w,translateExtent:D,width:_,height:B}=A.getState();if(q.sourceEvent.type!=="mousemove"||!h||!w)return;const F=Z.current*Math.max(1,a[2])*(M?-1:1),V={x:a[0]-q.sourceEvent.movementX*F,y:a[1]-q.sourceEvent.movementY*F},ee=[[0,0],[_,B]],ie=tt.translate(V.x,V.y).scale(a[2]),re=w.constrain()(ie,ee,D);w.transform(h,re)},ke=et().on("zoom",v?de:null).on("zoom.wheel",k?J:null);return K.call(ke),()=>{K.on("zoom",null)}}},[v,k,M,E]);const ne=N?K=>{const J=st(K);N(K,{x:J[0],y:J[1]})}:void 0,je=n?(K,J)=>{const de=A.getState().nodeInternals.get(J);n(K,de)}:void 0;return y.createElement(Le,{position:p,style:t,className:ge(["react-flow__minimap",s]),"data-testid":"rf__minimap"},y.createElement("svg",{width:b,height:O,viewBox:`${T} ${Y} ${z} ${ae}`,role:"img","aria-labelledby":fe,ref:$,onClick:ne},P&&y.createElement("title",{id:fe},P),y.createElement($t,{onClick:je,nodeColor:u,nodeStrokeColor:c,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:d,nodeComponent:x}),y.createElement("path",{className:"react-flow__minimap-mask",d:`M${T-H},${Y-H}h${z+H*2}v${ae+H*2}h${-z-H*2}z
|
|
2
2
|
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:l,fillRule:"evenodd",stroke:i,strokeWidth:g,pointerEvents:"none"})))}Ve.displayName="MiniMap";var Lt=f.memo(Ve);function Ot(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},y.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Rt(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},y.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Tt(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},y.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function At(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},y.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function Bt(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},y.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const ue=({children:t,className:s,...c})=>y.createElement("button",{type:"button",className:ge(["react-flow__controls-button",s]),...c},t);ue.displayName="ControlButton";const Ft=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),Ue=({style:t,showZoom:s=!0,showFitView:c=!0,showInteractive:u=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:d,onFitView:x,onInteractiveChange:l,className:i,children:g,position:p="bottom-left"})=>{const N=_e(),[n,v]=f.useState(!1),{isInteractive:k,minZoomReached:P,maxZoomReached:M}=me(Ft,ve),{zoomIn:E,zoomOut:S,fitView:A}=at();if(f.useEffect(()=>{v(!0)},[]),!n)return null;const $=()=>{E(),o==null||o()},R=()=>{S(),d==null||d()},I=()=>{A(r),x==null||x()},Q=()=>{N.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),l==null||l(!k)};return y.createElement(Le,{className:ge(["react-flow__controls",i]),position:p,style:t,"data-testid":"rf__controls"},s&&y.createElement(y.Fragment,null,y.createElement(ue,{onClick:$,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:M},y.createElement(Ot,null)),y.createElement(ue,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:P},y.createElement(Rt,null))),c&&y.createElement(ue,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},y.createElement(Tt,null)),u&&y.createElement(ue,{className:"react-flow__controls-interactive",onClick:Q,title:"toggle interactivity","aria-label":"toggle interactivity"},k?y.createElement(Bt,null):y.createElement(At,null)),g)};Ue.displayName="Controls";var Wt=f.memo(Ue),G;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(G||(G={}));function Vt({color:t,dimensions:s,lineWidth:c}){return y.createElement("path",{stroke:t,strokeWidth:c,d:`M${s[0]/2} 0 V${s[1]} M0 ${s[1]/2} H${s[0]}`})}function Ut({color:t,radius:s}){return y.createElement("circle",{cx:s,cy:s,r:s,fill:t})}const Gt={[G.Dots]:"#91919a",[G.Lines]:"#eee",[G.Cross]:"#e2e2e2"},qt={[G.Dots]:1,[G.Lines]:1,[G.Cross]:6},Xt=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Ge({id:t,variant:s=G.Dots,gap:c=20,size:u,lineWidth:r=1,offset:o=2,color:d,style:x,className:l}){const i=f.useRef(null),{transform:g,patternId:p}=me(Xt,ve),N=d||Gt[s],n=u||qt[s],v=s===G.Dots,k=s===G.Cross,P=Array.isArray(c)?c:[c,c],M=[P[0]*g[2]||1,P[1]*g[2]||1],E=n*g[2],S=k?[E,E]:M,A=v?[E/o,E/o]:[S[0]/o,S[1]/o];return y.createElement("svg",{className:ge(["react-flow__background",l]),style:{...x,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:i,"data-testid":"rf__background"},y.createElement("pattern",{id:p+t,x:g[0]%M[0],y:g[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`},v?y.createElement(Ut,{color:N,radius:E/o}):y.createElement(Vt,{dimensions:S,color:N,lineWidth:r})),y.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+t})`}))}Ge.displayName="Background";var Yt=f.memo(Ge);const qe={planned:he,"in-progress":Te,complete:Re,archived:Oe},Xe={critical:Fe,high:Be,medium:pe,low:Ae};function Ie({spec:t,type:s,depth:c,onClick:u}){const{t:r}=Ne(),o={upstream:"border-l-amber-500",downstream:"border-l-emerald-500"},d=c===1?r("dependenciesPage.sidebar.depth.direct"):r("dependenciesPage.sidebar.depth.level",{depth:c}),x=qe[t.status]||he,l=Xe[t.priority]||pe;return e.jsxs("button",{onClick:u,className:C("w-full text-left px-2 py-1.5 rounded border-l-2 bg-muted/30 hover:bg-muted/50 transition-colors",o[s]),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground",children:["#",t.number]}),e.jsx("div",{className:C("rounded p-0.5 flex items-center justify-center",t.status==="planned"&&"bg-blue-500/20",t.status==="in-progress"&&"bg-orange-500/20",t.status==="complete"&&"bg-green-500/20",t.status==="archived"&&"bg-gray-500/20"),title:r(`status.${t.status}`),children:e.jsx(x,{className:C("h-2.5 w-2.5",t.status==="planned"&&"text-blue-600 dark:text-blue-400",t.status==="in-progress"&&"text-orange-600 dark:text-orange-400",t.status==="complete"&&"text-green-600 dark:text-green-400",t.status==="archived"&&"text-gray-500 dark:text-gray-400")})}),e.jsx("div",{className:C("rounded p-0.5 flex items-center justify-center",t.priority==="critical"&&"bg-red-500/20",t.priority==="high"&&"bg-orange-500/20",t.priority==="medium"&&"bg-blue-500/20",t.priority==="low"&&"bg-gray-500/20"),title:t.priority?r(`priority.${t.priority}`):void 0,children:e.jsx(l,{className:C("h-2.5 w-2.5",t.priority==="critical"&&"text-red-600 dark:text-red-400",t.priority==="high"&&"text-orange-600 dark:text-orange-400",t.priority==="medium"&&"text-blue-600 dark:text-blue-400",t.priority==="low"&&"text-gray-500 dark:text-gray-400")})}),e.jsx("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium ml-auto",children:d})]}),e.jsx("p",{className:"text-[11px] text-foreground truncate leading-tight mt-0.5",children:t.name})]})}function Zt({focusedDetails:t,onSelectSpec:s,onOpenSpec:c}){const{t:u}=Ne();if(!t)return e.jsx("div",{className:"w-64 shrink-0 rounded-lg border border-border bg-background/95 overflow-hidden flex flex-col",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-muted/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})})}),e.jsx("p",{className:"text-sm font-medium",children:u("dependenciesPage.sidebar.emptyTitle")}),e.jsx("p",{className:"text-xs mt-1",children:u("dependenciesPage.sidebar.emptyDescription")})]})})});const{node:r,upstream:o,downstream:d}=t,x=qe[r.status]||he,l=Xe[r.priority]||pe;return e.jsxs("div",{className:"w-64 shrink-0 rounded-lg border border-border bg-background/95 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-bold text-sm",children:["#",r.number]}),e.jsx("div",{className:C("rounded p-1 flex items-center justify-center",r.status==="planned"&&"bg-blue-500/20",r.status==="in-progress"&&"bg-orange-500/20",r.status==="complete"&&"bg-green-500/20",r.status==="archived"&&"bg-gray-500/20"),title:r.status,children:e.jsx(x,{className:C("h-3 w-3",r.status==="planned"&&"text-blue-600 dark:text-blue-300",r.status==="in-progress"&&"text-orange-600 dark:text-orange-300",r.status==="complete"&&"text-green-600 dark:text-green-300",r.status==="archived"&&"text-gray-500 dark:text-gray-300")})}),e.jsx("div",{className:C("rounded p-1 flex items-center justify-center",r.priority==="critical"&&"bg-red-500/20",r.priority==="high"&&"bg-orange-500/20",r.priority==="medium"&&"bg-blue-500/20",r.priority==="low"&&"bg-gray-500/20"),title:r.priority,children:e.jsx(l,{className:C("h-3 w-3",r.priority==="critical"&&"text-red-600 dark:text-red-300",r.priority==="high"&&"text-orange-600 dark:text-orange-300",r.priority==="medium"&&"text-blue-600 dark:text-blue-300",r.priority==="low"&&"text-gray-500 dark:text-gray-300")})})]}),e.jsx("p",{className:"text-sm font-medium text-foreground leading-snug",children:r.name}),e.jsx("button",{onClick:()=>c(r.number),className:"mt-2 w-full rounded bg-primary/20 border border-primary/40 px-2 py-1.5 text-xs text-primary hover:bg-primary/30 font-medium",children:u("dependenciesPage.sidebar.openSpec")})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-3 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-500"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:u("dependenciesPage.sidebar.dependsOnHeading",{count:o.reduce((i,g)=>i+g.specs.length,0)})})]}),o.length>0?e.jsx("div",{className:"space-y-1.5",children:o.flatMap(i=>i.specs.map(g=>e.jsx(Ie,{spec:g,type:"upstream",depth:i.depth,onClick:()=>s(g.id)},g.id)))}):e.jsx("p",{className:"text-xs text-muted-foreground/60 italic",children:u("dependenciesPage.sidebar.emptyUpstream")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:u("dependenciesPage.sidebar.requiredByHeading",{count:d.reduce((i,g)=>i+g.specs.length,0)})})]}),d.length>0?e.jsx("div",{className:"space-y-1.5",children:d.flatMap(i=>i.specs.map(g=>e.jsx(Ie,{spec:g,type:"downstream",depth:i.depth,onClick:()=>s(g.id)},g.id)))}):e.jsx("p",{className:"text-xs text-muted-foreground/60 italic",children:u("dependenciesPage.sidebar.emptyDownstream")})]})]})]})}const Me=180,Ye=60,Pe=120,Ze=40,be="#f59e0b",Kt={planned:"border-blue-500 bg-blue-100 text-blue-800 dark:bg-blue-950/60 dark:text-blue-200","in-progress":"border-orange-500 bg-orange-100 text-orange-800 dark:bg-orange-950/60 dark:text-orange-200",complete:"border-green-500 bg-green-100 text-green-800 dark:bg-green-950/60 dark:text-green-200",archived:"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-500/80 dark:bg-gray-900/60 dark:text-gray-400"},Qt={planned:"#3b82f6","in-progress":"#f97316",complete:"#22c55e",archived:"#6b7280"};function Jt(t,s,c=2){const u=new Map;u.set(t,0);const r=new Map,o=new Map;s.forEach(l=>{r.has(l.source)||r.set(l.source,new Set),r.get(l.source).add(l.target),o.has(l.target)||o.set(l.target,new Set),o.get(l.target).add(l.source)});let d=new Set([t]),x=1;for(;d.size>0&&x<=c;){const l=new Set;d.forEach(i=>{const g=r.get(i);g&&g.forEach(p=>{u.has(p)||(u.set(p,x),l.add(p))})}),d=l,x++}for(d=new Set([t]),x=1;d.size>0&&x<=c;){const l=new Set;d.forEach(i=>{const g=o.get(i);g&&g.forEach(p=>{u.has(p)||(u.set(p,x),l.add(p))})}),d=l,x++}return u}function He(t,s,c,u,r={}){if(t.length===0)return{nodes:[],edges:[]};if((r.mode??"graph")==="focus"&&r.focusedNodeId)return es(t,s,c);const d=c?Pe:Me,x=c?Ze:Ye,l=c?30:50,i=new Set;s.forEach(n=>{i.add(n.source),i.add(n.target)});const g=t.filter(n=>i.has(n.id)),p=u?t.filter(n=>!i.has(n.id)):[],N=[];if(g.length>0){const n=new ye.graphlib.Graph;n.setGraph({rankdir:"LR",align:"UL",nodesep:c?30:50,ranksep:c?80:120,marginx:40,marginy:40}),n.setDefaultEdgeLabel(()=>({})),g.forEach(E=>{n.setNode(E.id,{width:d,height:x})}),s.forEach(E=>{i.has(E.source)&&i.has(E.target)&&n.setEdge(E.source,E.target)}),ye.layout(n);let v=1/0,k=1/0,P=0,M=0;if(g.forEach(E=>{const S=n.node(E.id);v=Math.min(v,S.x-d/2),k=Math.min(k,S.y-x/2),P=Math.max(P,S.x+d/2),M=Math.max(M,S.y+x/2)}),g.forEach(E=>{const S=n.node(E.id);N.push({...E,position:{x:S.x-v,y:S.y-k}})}),p.length>0){const E=M-k,S=P-v,A=E+l*2,$=Math.ceil(Math.sqrt(p.length*1.5)),R=$*(d+l),I=S>R?Math.floor((S-R)/2):0;p.forEach((Q,b)=>{const O=b%$,X=Math.floor(b/$);N.push({...Q,position:{x:I+O*(d+l),y:A+X*(x+l)}})})}}else{const n=Math.ceil(Math.sqrt(p.length*1.5));p.forEach((v,k)=>{const P=k%n,M=Math.floor(k/n);N.push({...v,position:{x:P*(d+l),y:M*(x+l)}})})}return{nodes:N,edges:s}}function es(t,s,c){const u=c?Pe:Me,r=c?Ze:Ye,o=new ye.graphlib.Graph;o.setGraph({rankdir:"LR",align:"UL",nodesep:c?30:50,ranksep:c?80:120,marginx:40,marginy:40}),o.setDefaultEdgeLabel(()=>({})),t.forEach(i=>{o.setNode(i.id,{width:u,height:r})}),s.forEach(i=>{o.setEdge(i.source,i.target)}),ye.layout(o);let d=1/0,x=1/0;return t.forEach(i=>{const g=o.node(i.id);d=Math.min(d,g.x-u/2),x=Math.min(x,g.y-r/2)}),{nodes:t.map(i=>{const g=o.node(i.id);return{...i,position:{x:g.x-d,y:g.y-x}}}),edges:s}}function ts({statusFilter:t,statusCounts:s,showStandalone:c,isCompact:u,viewMode:r,focusedNodeId:o,connectionStats:d,onToggleStatus:x,onToggleStandalone:l,onToggleCompact:i,onToggleViewMode:g,onClear:p,t:N}){const n=t.length>0||o;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[["draft","planned","in-progress","complete","archived"].map(v=>{const k=t.length===0||t.includes(v),P=N(`status.${v}`),M=s[v]||0;return e.jsxs("button",{onClick:()=>x(v),className:C("rounded border px-2 py-1 font-medium transition-colors",k&&v==="draft"&&"border-slate-500/60 bg-slate-500/20 text-slate-700 dark:text-slate-200",k&&v==="planned"&&"border-blue-500/60 bg-blue-500/20 text-blue-700 dark:text-blue-300",k&&v==="in-progress"&&"border-orange-500/60 bg-orange-500/20 text-orange-700 dark:text-orange-300",k&&v==="complete"&&"border-green-500/60 bg-green-500/20 text-green-700 dark:text-green-300",k&&v==="archived"&&"border-gray-500/60 bg-gray-500/20 text-gray-600 dark:text-gray-300",!k&&"border-border bg-background text-muted-foreground/40"),children:[P,e.jsx("span",{className:"ml-1 opacity-60",children:N("dependenciesPage.filters.count",{count:M})})]},v)}),e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:l,className:C("rounded border px-2 py-1 font-medium transition-colors",c?"border-violet-500/60 bg-violet-500/20 text-violet-700 dark:text-violet-300":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.showStandalone",{count:d.standalone})}),e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:i,className:C("rounded border px-2 py-1 font-medium transition-colors",u?"border-primary/60 bg-primary/20 text-primary":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.compact")}),o&&e.jsx("button",{onClick:g,className:C("rounded border px-2 py-1 font-medium transition-colors",r==="focus"?"border-primary/60 bg-primary/20 text-primary":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.focusMode")}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:p,className:"rounded border border-red-500/40 bg-red-500/10 px-2 py-1 font-medium text-red-400 hover:bg-red-500/20",children:N("dependenciesPage.filters.clear")})]})]})}function ss({data:t,focusedNodeId:s,onSelectSpec:c,onClearSelection:u,t:r}){const[o,d]=f.useState(!1),[x,l]=f.useState(""),i=f.useMemo(()=>s?t.nodes.find(p=>p.id===s):null,[s,t]),g=f.useMemo(()=>{const p=[...t.nodes].sort((n,v)=>v.number-n.number);if(!x.trim())return p.slice(0,15);const N=x.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(N)||n.number.toString().includes(N)||n.tags.some(v=>v.toLowerCase().includes(N))).slice(0,15)},[t,x]);return e.jsxs(it,{open:o,onOpenChange:d,children:[e.jsx(ct,{asChild:!0,children:e.jsxs(dt,{variant:"outline",role:"combobox","aria-expanded":o,className:C("w-[240px] h-9 justify-between px-3 text-xs",s&&"border-primary/60 bg-primary/10 text-foreground"),children:[i?e.jsxs("span",{className:"truncate flex items-center",children:[e.jsxs("span",{className:"text-muted-foreground mr-2 font-mono",children:["#",i.number]}),e.jsx("span",{className:"truncate",children:i.name})]}):e.jsx("span",{className:"text-muted-foreground font-normal",children:r("dependenciesPage.selector.placeholder")}),e.jsx(lt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ut,{className:"w-[300px] p-0",align:"end",children:e.jsxs(mt,{shouldFilter:!1,children:[e.jsx(gt,{placeholder:r("dependenciesPage.selector.filterPlaceholder"),value:x,onValueChange:l,className:"text-xs"}),e.jsxs(ht,{children:[e.jsx(pt,{className:"py-2 text-center text-xs text-muted-foreground",children:r("dependenciesPage.selector.empty")}),e.jsxs(xt,{children:[s&&e.jsxs(De,{onSelect:()=>{u(),d(!1),l("")},className:"text-muted-foreground",children:[e.jsx(ft,{className:"mr-2 h-3.5 w-3.5"}),r("dependenciesPage.selector.clearSelection")]}),g.map(p=>e.jsxs(De,{value:p.id,onSelect:()=>{c(p.id),d(!1),l("")},children:[e.jsxs("span",{className:"text-muted-foreground font-mono mr-2",children:["#",p.number]}),e.jsx("span",{className:"truncate flex-1",children:p.name}),e.jsx("span",{className:C("text-[9px] px-1 py-0.5 rounded uppercase font-medium ml-2 shrink-0",p.status==="draft"&&"bg-slate-500/20 text-slate-600 dark:text-slate-300",p.status==="planned"&&"bg-blue-500/20 text-blue-600 dark:text-blue-400",p.status==="in-progress"&&"bg-orange-500/20 text-orange-600 dark:text-orange-400",p.status==="complete"&&"bg-green-500/20 text-green-600 dark:text-green-400",p.status==="archived"&&"bg-gray-500/20 text-gray-500 dark:text-gray-400"),children:p.status==="in-progress"?"WIP":p.status.slice(0,3)}),e.jsx("div",{className:C("mr-2 flex h-4 w-4 items-center justify-center",s===p.id?"opacity-100":"opacity-0"),children:e.jsx(bt,{className:"h-4 w-4"})})]},p.id))]})]})]})})]})}const ns={planned:he,"in-progress":Te,complete:Re,archived:Oe},rs={critical:Fe,high:Be,medium:pe,low:Ae},Ke=f.memo(function({data:s}){const{t:c}=Ne(),u=s.isCompact,r=s.isSecondary,o=s.connectionDepth===0?1:s.connectionDepth===1?.95:s.connectionDepth===2?.7:s.isDimmed?.15:1,d=r?.65:1,x=ns[s.tone]||he,l=rs[s.priority]||pe;return e.jsxs("div",{className:C("flex flex-col rounded-lg shadow-lg transition-all duration-200",Kt[s.tone],s.interactive&&"cursor-pointer hover:scale-105 hover:shadow-xl hover:border-gray-400 dark:hover:border-white/50",s.isFocused&&"ring-2 ring-gray-800 dark:ring-white ring-offset-2 ring-offset-background scale-110 z-50",s.connectionDepth===1&&"ring-1 ring-gray-400 dark:ring-white/40",u?"px-2 py-1 gap-0.5":"px-2.5 py-1.5 gap-0.5",r?"border border-dashed":"border-2"),style:{width:u?Pe:Me,opacity:o*d,transform:s.isDimmed?"scale(0.9)":void 0},children:[e.jsx($e,{type:"target",position:we.Left,className:"opacity-0"}),e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsxs("span",{className:C("font-bold",u?"text-[9px]":"text-[10px]"),children:["#",s.number.toString().padStart(3,"0")]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{className:C("rounded flex items-center justify-center",u?"p-0.5":"p-1",s.tone==="planned"&&"bg-blue-500/30",s.tone==="in-progress"&&"bg-orange-500/30",s.tone==="complete"&&"bg-green-500/30",s.tone==="archived"&&"bg-gray-500/30"),title:c(`status.${s.tone}`),children:e.jsx(x,{className:C(u?"h-2 w-2":"h-2.5 w-2.5")})}),e.jsx("div",{className:C("rounded flex items-center justify-center",u?"p-0.5":"p-1",s.priority==="critical"&&"bg-red-500/30",s.priority==="high"&&"bg-orange-500/30",s.priority==="medium"&&"bg-blue-500/30",s.priority==="low"&&"bg-gray-500/30"),title:s.priority?c(`priority.${s.priority}`):void 0,children:e.jsx(l,{className:C(u?"h-2 w-2":"h-2.5 w-2.5")})}),s.connectionDepth!==void 0&&s.connectionDepth>0&&e.jsx("span",{className:C("font-medium rounded bg-muted/50 text-muted-foreground",u?"text-[7px] px-0.5 py-0.5":"text-[8px] px-1 py-0.5"),title:c("dependenciesPage.graph.levelTitle",{depth:s.connectionDepth}),children:c("dependenciesPage.graph.levelBadge",{depth:s.connectionDepth})})]})]}),e.jsx("span",{className:C("font-medium leading-tight truncate",u?"text-[8px]":"text-[10px]"),title:s.label,children:u?s.shortLabel:s.label}),e.jsx($e,{type:"source",position:we.Right,className:"opacity-0"})]})});Ke.displayName="SpecNode";const os={specNode:Ke};function as({nodes:t,edges:s,showStandalone:c,onNodeClick:u,onPaneClick:r,onInstance:o,t:d}){const x=f.useCallback(l=>{o(l),requestAnimationFrame(()=>{l.fitView({padding:.15,duration:300})})},[o]);return t.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:d("dependenciesPage.empty.title")}),e.jsx("p",{className:"text-xs mt-1",children:d(c?"dependenciesPage.empty.filters":"dependenciesPage.empty.standaloneHint")})]})}):e.jsxs(yt,{nodes:t,edges:s,nodeTypes:os,onInit:x,className:"h-full w-full",fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,panOnScroll:!0,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,minZoom:.05,maxZoom:2,onNodeClick:u,onPaneClick:r,children:[e.jsx(Yt,{gap:20,size:1,color:"rgba(100, 116, 139, 0.06)"}),e.jsx(Wt,{showInteractive:!1,className:"!bg-background/90 !border-border !rounded-md"}),e.jsx(Lt,{nodeColor:l=>{const i=l.data;return Qt[i.tone]||"#6b7280"},maskColor:"rgba(128, 128, 128, 0.6)",className:"!bg-white/95 dark:!bg-background/95 !border-border !rounded-md",style:{width:120,height:80},pannable:!0,zoomable:!0})]})}function cs(){const{specName:t,projectId:s}=wt(),c=vt(),[u,r]=Nt(),{t:o}=Ne(),{currentProject:d,loading:x}=jt(),l=!s||(d==null?void 0:d.id)===s,i=u.get("spec"),g=s??(d==null?void 0:d.id),p=g?`/projects/${g}`:"/projects",N=f.useCallback(a=>`${p}/specs/${a}`,[p]),[n,v]=f.useState(null),[k,P]=f.useState(!0),[M,E]=f.useState(null),[S,A]=f.useState(null),[$,R]=f.useState(!1),[I,Q]=f.useState([]),[b,O]=f.useState(null),[X,xe]=f.useState("graph"),[W,ce]=f.useState(!1),oe=f.useRef(!1),H=f.useRef(null);f.useEffect(()=>{!l||x||(P(!0),kt.getDependencies(t).then(a=>{v(a),ce(a.nodes.length>30)}).catch(a=>E(a instanceof Error?a.message:o("errors:loadingError"))).finally(()=>P(!1)))},[x,l,t,o]),f.useEffect(()=>{if(n&&!oe.current){if(i){const a=n.nodes.find(h=>h.number.toString()===i);a&&(H.current=a.id,O(a.id))}oe.current=!0}},[i,n]),f.useEffect(()=>{if(!n||!oe.current)return;if(H.current!==null){if(b===H.current){H.current=null;return}H.current=null}const a=b?n.nodes.find(w=>w.id===b):null,h=a?a.number.toString():null;if(h!==i){const w=new URLSearchParams(u);h?w.set("spec",h):w.delete("spec"),r(w,{replace:!0})}},[b,n,i,u,r]);const T=f.useMemo(()=>((n==null?void 0:n.edges)||[]).filter(a=>a.type==="dependsOn"),[n==null?void 0:n.edges]),Y=f.useMemo(()=>{const a=new Map,h=new Map;return T.forEach(w=>{a.has(w.source)||a.set(w.source,new Set),a.get(w.source).add(w.target),h.has(w.target)||h.set(w.target,new Set),h.get(w.target).add(w.source)}),{upstream:a,downstream:h}},[T]),z=f.useMemo(()=>b?Jt(b,T,1/0):null,[b,T]);f.useEffect(()=>{!b&&X==="focus"&&xe("graph")},[b,X]);const ae=f.useCallback((a,h)=>{const w=new Set,D=[a];for(;D.length>0;){const _=D.shift(),B=h.get(_);B&&B.forEach(F=>{w.has(F)||(w.add(F),D.push(F))})}return w},[]),fe=f.useMemo(()=>{if(!b||!n)return null;const a=n.nodes.find(D=>D.id===b);if(!a)return null;const h=new Map(n.nodes.map(D=>[D.id,D])),w=(D,_)=>{const B=new Set([D]),F=[];let V=new Set([D]),ee=1;for(;V.size>0;){const ie=new Set,re=[];V.forEach(Se=>{const m=_.get(Se);m&&m.forEach(j=>{if(!B.has(j)){B.add(j),ie.add(j);const U=h.get(j);U&&re.push(U)}})}),re.length>0&&F.push({depth:ee,specs:re}),V=ie,ee++}return F};return{node:a,upstream:w(b,Y.upstream),downstream:w(b,Y.downstream)}},[b,n,Y]),Z=f.useMemo(()=>{if(!n)return{nodes:[],edges:[]};const a=X==="focus"&&!!b,h=(m,j)=>({id:m.id,type:"specNode",data:{label:m.name,shortLabel:m.name.length>14?m.name.slice(0,12)+"…":m.name,badge:m.status==="in-progress"?"WIP":m.status.slice(0,3).toUpperCase(),number:m.number,tone:m.status,priority:m.priority,href:N(m.number),interactive:!0,isFocused:j.isFocused,connectionDepth:j.connectionDepth,isDimmed:j.isDimmed,isCompact:W,isSecondary:j.isSecondary},position:{x:0,y:0},draggable:!0,selectable:!0,sourcePosition:we.Right,targetPosition:we.Left});if(a&&b){const m=ae(b,Y.upstream),j=ae(b,Y.downstream),U=new Set([b,...m,...j]),se=n.nodes.filter(L=>U.has(L.id)).map(L=>{const le=b===L.id;return h(L,{isFocused:le,connectionDepth:le?0:z==null?void 0:z.get(L.id),isDimmed:!1,isSecondary:!1})}),Qe=T.filter(L=>U.has(L.source)&&U.has(L.target)).map(L=>{const le=L.source===b||L.target===b;return{id:`${L.source}-${L.target}-dependsOn`,source:L.source,target:L.target,type:"smoothstep",animated:le,markerEnd:{type:ze.ArrowClosed,color:be,width:18,height:18},style:{stroke:be,strokeWidth:le?2.75:2,opacity:1}}});return He(se,Qe,W,!1,{mode:"focus",focusedNodeId:b})}const w=n.nodes.filter(m=>I.length===0||I.includes(m.status)),D=new Set(w.map(m=>m.id)),_=new Set(D),B=[...D];for(;B.length>0;){const m=B.shift();T.forEach(j=>{j.source===m&&!_.has(j.target)&&(_.add(j.target),B.push(j.target)),j.target===m&&!_.has(j.source)&&(_.add(j.source),B.push(j.source))})}const F=T.filter(m=>_.has(m.source)&&_.has(m.target));let V=n.nodes.filter(m=>_.has(m.id));if(!$){const m=new Set;F.forEach(j=>{m.add(j.source),m.add(j.target)}),V=V.filter(j=>m.has(j.id))}const ee=new Set(V.map(m=>m.id)),ie=new Set([...ee].filter(m=>!D.has(m))),re=V.map(m=>{const j=b===m.id,U=ie.has(m.id);let te,se=!1;return b&&(te=z==null?void 0:z.get(m.id),se=te===void 0),h(m,{isFocused:j,connectionDepth:te,isDimmed:se,isSecondary:U})}),Se=F.filter(m=>ee.has(m.source)&&ee.has(m.target)).map(m=>{let j=!0,U=.7;if(b){const te=z==null?void 0:z.get(m.source),se=z==null?void 0:z.get(m.target);j=te!==void 0&&se!==void 0&&(te===0||se===0),U=j?1:te!==void 0&&se!==void 0?.4:.1}return{id:`${m.source}-${m.target}-dependsOn`,source:m.source,target:m.target,type:"smoothstep",animated:j&&b!==null,markerEnd:{type:ze.ArrowClosed,color:be,width:18,height:18},style:{stroke:be,strokeWidth:j?2.5:1.5,opacity:U}}});return He(re,Se,W,$,{mode:"graph"})},[n,T,I,b,z,W,$,Y,X,N,ae]),ne=f.useMemo(()=>{if(!n)return{connected:0,standalone:0};const a=new Set;return T.forEach(h=>{a.add(h.source),a.add(h.target)}),{connected:a.size,standalone:n.nodes.length-a.size}},[T,n]),je=f.useMemo(()=>{if(!n)return{};const a={};return n.nodes.forEach(h=>{a[h.status]=(a[h.status]||0)+1}),a},[n]);f.useEffect(()=>{if(!S)return;const a=setTimeout(()=>{S.fitView({padding:.15,duration:300})},50);return()=>clearTimeout(a)},[S,Z,I,$]),f.useEffect(()=>{if(!S||!b||!i)return;const a=Z.nodes.find(h=>h.id===b);if(a){const h=setTimeout(()=>{S.setCenter(a.position.x+80,a.position.y+30,{duration:400,zoom:1})},400);return()=>clearTimeout(h)}},[S,b,i,Z.nodes]);const K=f.useCallback((a,h)=>{if(h!=null&&h.data){if(a.detail===2&&h.data.href){c(h.data.href);return}O(w=>w===h.id?null:h.id)}},[c]),J=f.useCallback(()=>{O(null)},[]),de=a=>{Q(h=>h.includes(a)?h.filter(w=>w!==a):[...h,a]),O(null)},ke=()=>{Q([]),O(null)},q=a=>{if(O(a),S){const h=Z.nodes.find(w=>w.id===a);h&&S.setCenter(h.position.x+80,h.position.y+30,{duration:400,zoom:1})}};return k?e.jsx(St,{}):M||!n?e.jsx(Ee,{children:e.jsx("div",{className:"flex items-center justify-center h-[calc(100dvh-10rem)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-destructive mb-2",children:o("dependenciesPage.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:M||o("dependenciesPage.state.errorDescription")})]})})}):n.nodes.length===0?e.jsx(Ee,{children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold mb-2",children:o("dependenciesPage.empty.noDependencies")}),e.jsx("p",{className:"text-muted-foreground",children:o("dependenciesPage.empty.noDependenciesDescription")})]})}):e.jsx(Ee,{className:"h-[calc(100dvh-7rem)]",contentClassName:"flex h-full flex-col gap-4",children:e.jsxs("div",{className:"flex h-full flex-col gap-4",children:[e.jsx(Et,{title:o("dependenciesPage.title"),description:o("dependenciesPage.description"),actions:e.jsx(ss,{data:n,focusedNodeId:b,onSelectSpec:q,onClearSelection:()=>O(null),t:o})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ne.connected>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-600 dark:text-emerald-400",children:o("dependenciesPage.header.summary.connected",{count:ne.connected})}),ne.standalone>0&&e.jsxs(e.Fragment,{children:[" • ",e.jsx("span",{className:"text-muted-foreground",children:o("dependenciesPage.header.summary.standalone",{count:ne.standalone})})]})]}):e.jsx("span",{children:o("dependenciesPage.header.summary.none")})}),e.jsx(ts,{statusFilter:I,statusCounts:je,showStandalone:$,isCompact:W,viewMode:X,focusedNodeId:b,connectionStats:ne,onToggleStatus:de,onToggleStandalone:()=>R(!$),onToggleCompact:()=>ce(!W),onToggleViewMode:()=>xe(a=>a==="graph"?"focus":"graph"),onClear:ke,t:o}),e.jsxs("div",{className:"flex flex-1 gap-3 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg border border-border bg-gray-50 dark:bg-[#080c14]",children:e.jsx(as,{nodes:Z.nodes,edges:Z.edges,showStandalone:$,onNodeClick:K,onPaneClick:J,onInstance:A,t:o})}),e.jsx(Zt,{focusedDetails:fe,onSelectSpec:O,onOpenSpec:a=>c(N(a))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-0.5 w-6 bg-amber-400 rounded"}),o("dependenciesPage.legend.dependsOn")]}),e.jsx("span",{className:"text-muted-foreground/50 ml-auto",children:o("dependenciesPage.legend.instructions")})]})]})})}export{cs as DependenciesPage};
|