@geminilight/mindos 0.7.1 → 0.7.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.
Files changed (180) hide show
  1. package/_standalone/.mindos-build-version +1 -1
  2. package/_standalone/.next/BUILD_ID +1 -1
  3. package/_standalone/.next/app-path-routes-manifest.json +28 -28
  4. package/_standalone/.next/build-manifest.json +3 -3
  5. package/_standalone/.next/cache/.previewinfo +1 -1
  6. package/_standalone/.next/cache/.rscinfo +1 -1
  7. package/_standalone/.next/cache/config.json +3 -3
  8. package/_standalone/.next/prerender-manifest.json +3 -3
  9. package/_standalone/.next/react-loadable-manifest.json +4 -4
  10. package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
  11. package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  12. package/_standalone/.next/server/app/_global-error.html +2 -2
  13. package/_standalone/.next/server/app/_global-error.rsc +1 -1
  14. package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  15. package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  16. package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  17. package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  18. package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  19. package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  20. package/_standalone/.next/server/app/_not-found/page.js +1 -1
  21. package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  22. package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  23. package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
  24. package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
  25. package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
  26. package/_standalone/.next/server/app/agents/page.js +1 -1
  27. package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
  28. package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  29. package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
  30. package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
  31. package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
  32. package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
  33. package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
  34. package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
  35. package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
  36. package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
  37. package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
  38. package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
  39. package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -1
  40. package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
  41. package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
  42. package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
  43. package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
  44. package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
  45. package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
  46. package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
  47. package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
  48. package/_standalone/.next/server/app/api/channels/verify/route_client-reference-manifest.js +1 -1
  49. package/_standalone/.next/server/app/api/connect/route_client-reference-manifest.js +1 -1
  50. package/_standalone/.next/server/app/api/embedding/route_client-reference-manifest.js +1 -1
  51. package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
  52. package/_standalone/.next/server/app/api/extract-docx/route_client-reference-manifest.js +1 -1
  53. package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
  54. package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
  55. package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
  56. package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
  57. package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  58. package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  59. package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
  60. package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  61. package/_standalone/.next/server/app/api/im/activity/route_client-reference-manifest.js +1 -1
  62. package/_standalone/.next/server/app/api/im/config/route_client-reference-manifest.js +1 -1
  63. package/_standalone/.next/server/app/api/im/feishu/long-connection/event/route_client-reference-manifest.js +1 -1
  64. package/_standalone/.next/server/app/api/im/feishu/long-connection/route_client-reference-manifest.js +1 -1
  65. package/_standalone/.next/server/app/api/im/status/route_client-reference-manifest.js +1 -1
  66. package/_standalone/.next/server/app/api/im/test/route_client-reference-manifest.js +1 -1
  67. package/_standalone/.next/server/app/api/im/webhook/feishu/route_client-reference-manifest.js +1 -1
  68. package/_standalone/.next/server/app/api/im/webhook-status/route_client-reference-manifest.js +1 -1
  69. package/_standalone/.next/server/app/api/inbox/clip/route_client-reference-manifest.js +1 -1
  70. package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
  71. package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  72. package/_standalone/.next/server/app/api/lint/route_client-reference-manifest.js +1 -1
  73. package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
  74. package/_standalone/.next/server/app/api/mcp/direct-tools/route_client-reference-manifest.js +1 -1
  75. package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
  76. package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
  77. package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
  78. package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
  79. package/_standalone/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
  80. package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
  81. package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
  82. package/_standalone/.next/server/app/api/obsidian/compat-report/route_client-reference-manifest.js +1 -1
  83. package/_standalone/.next/server/app/api/obsidian/import/route_client-reference-manifest.js +1 -1
  84. package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
  85. package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  86. package/_standalone/.next/server/app/api/search/prewarm/route_client-reference-manifest.js +1 -1
  87. package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
  88. package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
  89. package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
  90. package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  91. package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
  92. package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
  93. package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
  94. package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
  95. package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
  96. package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
  97. package/_standalone/.next/server/app/api/skills/route.js +1 -1
  98. package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  99. package/_standalone/.next/server/app/api/space-overview/route_client-reference-manifest.js +1 -1
  100. package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
  101. package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
  102. package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
  103. package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  104. package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
  105. package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
  106. package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
  107. package/_standalone/.next/server/app/capture/history/page.js +1 -1
  108. package/_standalone/.next/server/app/capture/history/page.js.nft.json +1 -1
  109. package/_standalone/.next/server/app/capture/history/page_client-reference-manifest.js +1 -1
  110. package/_standalone/.next/server/app/capture/page.js +1 -1
  111. package/_standalone/.next/server/app/capture/page.js.nft.json +1 -1
  112. package/_standalone/.next/server/app/capture/page_client-reference-manifest.js +1 -1
  113. package/_standalone/.next/server/app/changelog/page.js +1 -1
  114. package/_standalone/.next/server/app/changelog/page.js.nft.json +1 -1
  115. package/_standalone/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  116. package/_standalone/.next/server/app/changes/page.js +1 -1
  117. package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
  118. package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
  119. package/_standalone/.next/server/app/echo/[segment]/page.js +1 -1
  120. package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
  121. package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
  122. package/_standalone/.next/server/app/echo/page.js +1 -1
  123. package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
  124. package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
  125. package/_standalone/.next/server/app/explore/page.js +1 -1
  126. package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
  127. package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
  128. package/_standalone/.next/server/app/help/page.js +1 -1
  129. package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
  130. package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
  131. package/_standalone/.next/server/app/inbox/history/page.js +1 -1
  132. package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
  133. package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
  134. package/_standalone/.next/server/app/login/page.js +1 -1
  135. package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
  136. package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
  137. package/_standalone/.next/server/app/page.js +1 -1
  138. package/_standalone/.next/server/app/page.js.nft.json +1 -1
  139. package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  140. package/_standalone/.next/server/app/setup/page.js +1 -1
  141. package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
  142. package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  143. package/_standalone/.next/server/app/todo/page.js +1 -1
  144. package/_standalone/.next/server/app/todo/page.js.nft.json +1 -1
  145. package/_standalone/.next/server/app/todo/page_client-reference-manifest.js +1 -1
  146. package/_standalone/.next/server/app/trash/page.js +3 -3
  147. package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
  148. package/_standalone/.next/server/app/view/[...path]/page.js +3 -3
  149. package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
  150. package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
  151. package/_standalone/.next/server/app-paths-manifest.json +28 -28
  152. package/_standalone/.next/server/chunks/{8961.js → 1057.js} +2 -2
  153. package/_standalone/.next/server/chunks/4802.js +33 -33
  154. package/_standalone/.next/server/chunks/5299.js +1 -1
  155. package/_standalone/.next/server/chunks/7662.js +2 -2
  156. package/_standalone/.next/server/chunks/7875.js +1 -1
  157. package/_standalone/.next/server/middleware-build-manifest.js +1 -1
  158. package/_standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  159. package/_standalone/.next/server/pages/500.html +2 -2
  160. package/_standalone/.next/server/server-reference-manifest.js +1 -1
  161. package/_standalone/.next/server/server-reference-manifest.json +1 -1
  162. package/_standalone/.next/static/chunks/{3075.8f1a041fa66ec389.js → 3985.695651f6b5cd768c.js} +1 -1
  163. package/_standalone/.next/static/chunks/576.3cae31209383ddbd.js +1 -0
  164. package/_standalone/.next/static/chunks/app/{layout-15a1f9f4d125afd8.js → layout-0cf6f2a65f605a0d.js} +10 -10
  165. package/_standalone/.next/static/chunks/app/trash/page-085f121c0815d542.js +1 -0
  166. package/_standalone/.next/static/chunks/app/view/[...path]/page-faeaf8c09c1c6d7c.js +12 -0
  167. package/_standalone/.next/static/chunks/webpack-a1bb35f2d540e463.js +1 -0
  168. package/_standalone/.next/trace +97 -97
  169. package/_standalone/package-lock.json +4 -61
  170. package/_standalone/package.json +1 -2
  171. package/_standalone/tsconfig.tsbuildinfo +1 -1
  172. package/app/lib/agent/skill-paths.ts +0 -3
  173. package/app/package.json +1 -2
  174. package/package.json +1 -1
  175. package/_standalone/.next/static/chunks/1779.7ac1978c310b0526.js +0 -1
  176. package/_standalone/.next/static/chunks/app/trash/page-7a7712edc3f5d61e.js +0 -1
  177. package/_standalone/.next/static/chunks/app/view/[...path]/page-8914026061e43f47.js +0 -12
  178. package/_standalone/.next/static/chunks/webpack-78e11caabdc37bf9.js +0 -1
  179. /package/_standalone/.next/static/{2h98GBT8FKRdQOfcpLky6 → q5RP_Mx8BrCfvVDnLpRRc}/_buildManifest.js +0 -0
  180. /package/_standalone/.next/static/{2h98GBT8FKRdQOfcpLky6 → q5RP_Mx8BrCfvVDnLpRRc}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3075],{439:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(90425).A)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},23075:(e,t,s)=>{s.r(t),s.d(t,{default:()=>tA});var r=s(95155),a=s(12115),n=s(86901),l=s(68806),o=s(90425);let i=(0,o.A)("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);var d=s(89363);let c=(0,o.A)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);var m=s(91958),u=s(6962),x=s(68459),p=s(13545),g=s(6296),h=s(9199),b=s(12651),f=s(33210),v=s(94961),j=s(73321),y=s(35581),N=s(22356),k=s(22164),w=s(49619),S=s(61878),C=s(94514),A=s(92451),z=s(92972),T=s(4235),M=s(20171),E=s(47376),R=s(51842),P=s(79704),I=s(60112);function U(e,t=[],s,r){let a=E.T_[e],n="zh"===r?a.nameZh:a.name,l=new Set(t.filter(e=>e&&e!==s).map(e=>e.trim().toLowerCase()));if(!l.has(n.trim().toLowerCase()))return n;let o=2;for(;l.has(`${n} ${o}`.toLowerCase());)o++;return`${n} ${o}`}function D({form:e,t,locale:s,layout:a="full"}){let n=E.T_[e.protocol],l="zh"===s?"名称":"Name",o="zh"===s?"协议":"Protocol",i="zh"===s?"可选,默认使用协议名称":"Optional, defaults to protocol name",d=e.isDuplicateName?"zh"===s?"名称已存在":"Name already exists":void 0;return(0,r.jsxs)("div",{className:"space-y-3",children:["compact"===a?(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(M.D0,{label:l,hint:d,hintError:e.isDuplicateName,children:(0,r.jsx)(M.pd,{value:e.name,onChange:t=>e.setName(t.target.value),placeholder:i,autoFocus:!0})}),(0,r.jsx)(M.D0,{label:o,children:(0,r.jsx)(M.l6,{value:e.protocol,onChange:t=>e.setProtocol(t.target.value),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===s?E.T_[e].nameZh:E.T_[e].name},e))})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.D0,{label:l,hint:d,hintError:e.isDuplicateName,children:(0,r.jsx)(M.pd,{value:e.name,onChange:t=>e.setName(t.target.value),placeholder:i})}),(0,r.jsx)(M.D0,{label:o,children:(0,r.jsx)(M.l6,{value:e.protocol,onChange:t=>e.setProtocol(t.target.value),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===s?E.T_[e].nameZh:E.T_[e].name},e))})})]}),(0,r.jsx)(M.D0,{label:"Base URL",children:(0,r.jsx)(M.pd,{value:e.baseUrl,onChange:t=>e.setBaseUrl(t.target.value),placeholder:n.fixedBaseUrl||"https://api.example.com/v1"})}),(0,r.jsx)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:["API Key ",(0,r.jsx)("span",{className:"text-muted-foreground/50 font-normal",children:"zh"===s?"(可选)":"(optional)"})]}),children:(0,r.jsx)(M.yA,{value:e.apiKey,onChange:e.setApiKey,placeholder:"sk-..."})}),(0,r.jsx)(M.D0,{label:"zh"===s?"模型":"Model",children:(0,r.jsx)(P.A,{value:e.model,onChange:e.setModel,placeholder:n.defaultModel,provider:e.protocol,apiKey:e.apiKey,baseUrl:e.baseUrl,supportsListModels:!!e.baseUrl.trim(),allowNoKey:!0,browseLabel:t.settings.ai.listModels,noModelsLabel:t.settings.ai.noModelsFound})})]})}var $=s(53961);function F({result:e,disabled:t,onTest:s,t:a}){let n="testing"===e.state,l="ok"===e.state,o="error"===e.state;return(0,r.jsxs)("button",{type:"button",disabled:t||n,onClick:s,className:`inline-flex items-center gap-1.5 px-3.5 py-1.5 text-sm font-medium rounded-lg transition-all duration-200 disabled:cursor-not-allowed ${l?"bg-success/10 text-success border border-success/20":o?"bg-destructive/8 text-destructive border border-destructive/20 hover:bg-destructive/12":"border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 disabled:opacity-40"}`,children:[n?(0,r.jsx)(g.A,{size:13,className:"animate-spin"}):l?(0,r.jsx)(C.A,{size:13}):o?(0,r.jsx)(p.A,{size:13}):(0,r.jsx)($.A,{size:13}),n?a.settings.ai.testKeyTesting:l&&null!=e.latency?a.settings.ai.testKeyOk(e.latency):o?function(e,t){switch(t){case"auth_error":return e.settings.ai.testKeyAuthError;case"model_not_found":return e.settings.ai.testKeyModelNotFound;case"endpoint_error":return e.settings.ai.testKeyEndpointError;case"rate_limited":return e.settings.ai.testKeyRateLimited;case"network_error":return e.settings.ai.testKeyNetworkError;default:return e.settings.ai.testKeyUnknown}}(a,e.code):a.settings.ai.testKey]})}let L=[10,20,30,40,50,999];function O({value:e,onChange:t}){let s=L.includes(e),[n,l]=(0,a.useState)(!s);return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(M.l6,{value:n?"custom":String(e),onChange:e=>{let s=e.target.value;"custom"===s?l(!0):(l(!1),t(Number(s)))},className:"w-28",children:[(0,r.jsx)("option",{value:"10",children:"10"}),(0,r.jsx)("option",{value:"20",children:"20"}),(0,r.jsx)("option",{value:"30",children:"30"}),(0,r.jsx)("option",{value:"40",children:"40"}),(0,r.jsx)("option",{value:"50",children:"50"}),(0,r.jsx)("option",{value:"999",children:"Unlimited"}),(0,r.jsx)("option",{value:"custom",children:"Custom"})]}),n&&(0,r.jsx)("input",{type:"number",value:999===e?"":e,onChange:e=>{let s=parseInt(e.target.value,10);!isNaN(s)&&s>0&&t(Math.min(999,s))},placeholder:"1-999",min:1,max:999,autoFocus:!0,className:"w-20 px-2 py-1 rounded-md border border-border/60 bg-muted/50 text-sm text-foreground"})]})}function K({data:e,setData:t,updateAi:s,updateAgent:l,t:o}){let{locale:i}=(0,y.Y)(),d=e.envOverrides??{},c=e.ai.providers.find(t=>t.id===e.ai.activeProvider),m=c?E.T_[c.protocol]:null,[u,x]=(0,a.useState)({}),[p,g]=(0,a.useState)(!1),h=(0,a.useRef)(void 0),b=(0,a.useRef)(e.ai.activeProvider);(0,a.useEffect)(()=>{b.current!==e.ai.activeProvider&&(b.current=e.ai.activeProvider,x({}),h.current&&(clearTimeout(h.current),h.current=void 0))},[e.ai.activeProvider]),(0,a.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,a.useEffect)(()=>{let t=e.agent?.reconnectRetries??3;try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},[e.agent?.reconnectRetries]);let f=(0,a.useCallback)(async()=>{if(!c)return;let e=c.id;x(t=>({...t,[e]:{state:"testing"}}));try{let t={provider:c.protocol};c.apiKey&&(t.apiKey=c.apiKey),c.model&&(t.model=c.model),c.baseUrl&&(t.baseUrl=c.baseUrl);let s=await fetch("/api/settings/test-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json();r.ok?(x(t=>({...t,[e]:{state:"ok",latency:r.latency}})),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{x(t=>({...t,[e]:{state:"idle"}}))},8e3)):x(t=>({...t,[e]:{state:"error",error:r.error,code:r.code}}))}catch{x(t=>({...t,[e]:{state:"error",code:"network_error",error:"Network error"}}))}},[c]),v=(0,a.useCallback)(t=>{c&&("apiKey"in t&&x(e=>({...e,[c.id]:{state:"idle"}})),s({providers:e.ai.providers.map(e=>e.id===c.id?{...e,...t}:e)}))},[c,e.ai.providers,s]),j=c?(0,E.Ux)(c.protocol):void 0,N=!!j&&d[j],S=!!m?.apiKeyFallback,C=(0,a.useCallback)(()=>{if(!c)return;let t=E.T_[c.protocol];x(e=>({...e,[c.id]:{state:"idle"}})),s({providers:e.ai.providers.map(e=>e.id===c.id?{...e,apiKey:"",model:"",baseUrl:t?.fixedBaseUrl??""}:e)})},[c,e.ai.providers,s]),A=(0,a.useCallback)(()=>{if(!c)return;let t=e.ai.providers.filter(e=>e.id!==c.id);s({activeProvider:t.length>0?t[0].id:"",providers:t}),x(e=>{let t={...e};return delete t[c.id],t})},[c,e.ai.providers,s]),z=(0,a.useCallback)(t=>{let r={id:t.id||(0,I.mV)(),name:t.name,protocol:t.protocol,apiKey:t.apiKey,model:t.model,baseUrl:t.baseUrl};s({activeProvider:r.id,providers:[...e.ai.providers,r]}),g(!1)},[e.ai.providers,s]),T=c?.name??("zh"===i?"未选择":"No provider");return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(n.A,{size:15}),title:o.settings.ai.provider,description:T,children:[(0,r.jsx)(R.A,{value:e.ai.activeProvider,onChange:e=>{"skip"!==e&&s({activeProvider:e}),g(!1)},compact:!0,customProviders:e.ai.providers,onAdd:()=>{let t=E.T_.openai,s="zh"===i?t.nameZh:t.name,r=new Set(e.ai.providers.map(e=>e.name.toLowerCase())),a=s;if(r.has(a.toLowerCase())){let e=2;for(;r.has(`${s} (${e})`.toLowerCase());)e++;a=`${s} (${e})`}g(!0)}}),p&&(0,r.jsx)(_,{onSave:z,onCancel:()=>g(!1),t:o,existingNames:e.ai.providers.map(e=>e.name)},"new"),!p&&c&&(0,r.jsxs)("div",{className:"space-y-3 pt-3 border-t border-border",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(M.D0,{label:"zh"===i?"名称":"Name",children:(0,r.jsx)(M.pd,{value:c.name,onChange:e=>v({name:e.target.value}),placeholder:"zh"===i?"输入名称":"Enter name"})}),(0,r.jsx)(M.D0,{label:"zh"===i?"协议":"Protocol",children:(0,r.jsx)(M.l6,{value:c.protocol,onChange:e=>v({protocol:e.target.value}),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===i?E.T_[e].nameZh:E.T_[e].name},e))})})]}),(0,r.jsxs)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:[o.settings.ai.apiKey," ",j&&(0,r.jsx)(M.Bt,{overridden:d[j]})]}),hint:m&&N?o.settings.ai.envFieldNote(j):m&&S?o.settings.ai.keyOptionalHint:void 0,children:[(0,r.jsx)(M.yA,{value:c.apiKey,onChange:e=>v({apiKey:e}),placeholder:"sk-..."}),m?.signupUrl&&!c.apiKey&&!N&&(0,r.jsxs)("a",{href:m.signupUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs mt-1.5 hover:underline",style:{color:"var(--amber)"},children:[(0,r.jsx)(k.A,{size:10}),S?"zh"===i?`下载 ${m.nameZh}`:`Download ${m.name}`:"zh"===i?`获取 ${m.nameZh} API Key`:`Get ${m.name} API Key`]})]}),(m?.supportsBaseUrl||c.baseUrl)&&(0,r.jsx)(M.D0,{label:"Base URL",children:(0,r.jsx)(M.pd,{value:c.baseUrl,onChange:e=>v({baseUrl:e.target.value}),placeholder:m?.fixedBaseUrl||(0,E.Ot)(c.protocol)||"https://api.openai.com/v1"})}),(0,r.jsx)(M.D0,{label:"zh"===i?"模型":"Model",children:(0,r.jsx)(P.A,{value:c.model,onChange:e=>v({model:e}),placeholder:m?.defaultModel??"",provider:c.protocol,apiKey:c.apiKey,envKey:!!N,baseUrl:c.baseUrl,supportsListModels:!!c.baseUrl?.trim()||!!m?.supportsListModels,allowNoKey:!!c.baseUrl?.trim(),browseLabel:o.settings.ai.listModels,noModelsLabel:o.settings.ai.noModelsFound})}),(0,r.jsx)(B,{provider:c.protocol,result:u[c.id]??{state:"idle"},hasKey:!!c.apiKey,hasEnv:!!N,hasConfig:!!(c.apiKey||c.model||c.baseUrl),onTest:f,onReset:C,onDelete:A,t:o})]})]}),(0,r.jsx)(J,{data:e,setData:t,t:o}),(0,r.jsx)(q,{data:e,setData:t,t:o}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(w.A,{size:15}),title:o.settings.agent.title,description:o.settings.agent.subtitle??"Configure how the AI agent operates",children:[(0,r.jsx)(M.pM,{label:o.settings.agent.maxSteps,hint:o.settings.agent.maxStepsHint,children:(0,r.jsx)(O,{value:e.agent?.maxSteps??20,onChange:e=>l({maxSteps:e})})}),(0,r.jsx)(M.pM,{label:o.settings.agent.contextStrategy,hint:o.settings.agent.contextStrategyHint,children:(0,r.jsxs)(M.l6,{value:e.agent?.contextStrategy??"auto",onChange:e=>l({contextStrategy:e.target.value}),className:"w-24",children:[(0,r.jsx)("option",{value:"auto",children:o.settings.agent.contextStrategyAuto}),(0,r.jsx)("option",{value:"off",children:o.settings.agent.contextStrategyOff})]})}),(0,r.jsx)(M.pM,{label:o.settings.agent.reconnectRetries,hint:o.settings.agent.reconnectRetriesHint,children:(0,r.jsxs)(M.l6,{value:String(e.agent?.reconnectRetries??3),onChange:e=>{let t=Number(e.target.value);l({reconnectRetries:t});try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},className:"w-20",children:[(0,r.jsx)("option",{value:"0",children:"Off"}),(0,r.jsx)("option",{value:"1",children:"1"}),(0,r.jsx)("option",{value:"2",children:"2"}),(0,r.jsx)("option",{value:"3",children:"3"}),(0,r.jsx)("option",{value:"5",children:"5"}),(0,r.jsx)("option",{value:"10",children:"10"})]})}),m?.supportsThinking&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.pM,{label:o.settings.agent.thinking,hint:o.settings.agent.thinkingHint,children:(0,r.jsx)(M.lM,{checked:e.agent?.enableThinking??!1,onChange:()=>l({enableThinking:!e.agent?.enableThinking})})}),e.agent?.enableThinking&&(0,r.jsx)(M.D0,{label:o.settings.agent.thinkingBudget,hint:o.settings.agent.thinkingBudgetHint,children:(0,r.jsx)(M.pd,{type:"number",value:String(e.agent?.thinkingBudget??5e3),onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||l({thinkingBudget:Math.max(1e3,Math.min(5e4,t))})},min:1e3,max:5e4,step:1e3})})]})]}),(0,r.jsx)(Y,{})]})}function B({provider:e,result:t,hasKey:s,hasEnv:n,hasConfig:l,onTest:o,onReset:i,onDelete:d,t:c}){let[m,u]=(0,a.useState)(null),p=(0,a.useRef)(void 0),g=!!E.T_[e]?.apiKeyFallback;(0,a.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let b=e=>{m===e?("reset"===e?i?.():d?.(),u(null),p.current&&clearTimeout(p.current)):(u(e),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>u(null),3e3))},{locale:f}=(0,y.Y)();return(0,r.jsx)("div",{className:"space-y-2 pt-2",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(F,{result:t,disabled:!(s||n||g),onTest:o,t:c}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[i&&l&&(0,r.jsxs)("button",{type:"button",onClick:()=>b("reset"),onBlur:()=>{"reset"===m&&(u(null),p.current&&clearTimeout(p.current))},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${"reset"===m?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(h.A,{size:12}),"reset"===m?"zh"===f?"确认重置?":"Confirm?":"zh"===f?"重置":"Reset"]}),d&&(0,r.jsxs)("button",{type:"button",onClick:()=>b("delete"),onBlur:()=>{"delete"===m&&(u(null),p.current&&clearTimeout(p.current))},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${"delete"===m?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(x.A,{size:12}),"delete"===m?"zh"===f?"确认删除?":"Confirm?":"zh"===f?"删除":"Delete"]})]})]})})}function _({initial:e,onSave:t,onCancel:s,onDelete:n,t:l,existingNames:o}){let{locale:i}=(0,y.Y)(),d=function({initial:e,onSave:t,locale:s,existingNames:r}){let n=(0,a.useMemo)(()=>e?.name??U(e?.protocol??"openai",r,e?.name,s),[e?.name,e?.protocol,r,s]),[l,o]=(0,a.useState)(n),[i,d]=(0,a.useState)(e?.protocol??"openai"),[c,m]=(0,a.useState)(e?.apiKey??""),[u,x]=(0,a.useState)(e?.model??""),[p,g]=(0,a.useState)(e?.baseUrl??""),[h,b]=(0,a.useState)({state:"idle"}),[f,v]=(0,a.useState)(!!e?.name),j=(0,a.useMemo)(()=>U(i,r,e?.name,s),[i,r,e?.name,s]);(0,a.useEffect)(()=>{f||o(j)},[j,f]);let y=(0,a.useCallback)(e=>{v(!0),o(e)},[]),N=(0,a.useCallback)(e=>{d(e),b({state:"idle"})},[]),k=l.trim()||j,w=!!(k&&r?.some(t=>t!==e?.name&&t.toLowerCase()===k.toLowerCase())),S=!!(p.trim()&&u.trim()&&!w),C="zh"===s?"接口地址和模型为必填":"Base URL and model are required",A="zh"===s?"名称已存在,请使用其他名称":"Name already exists, please use a different name",z=(0,a.useCallback)(async()=>{if(w)return void b({state:"error",error:A});if(!p.trim()||!u.trim())return void b({state:"error",error:C});b({state:"testing"});try{let t=await fetch("/api/settings/test-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?.id?{provider:e.id,apiKey:c,model:u,baseUrl:p}:{provider:i,apiKey:c,model:u,baseUrl:p,baseProviderId:i})}),s=await t.json();s.ok?b({state:"ok",latency:s.latency}):b({state:"error",error:s.error||"Test failed",code:s.code})}catch{b({state:"error",code:"network_error",error:"Network error"})}},[w,A,p,u,e?.id,c,i,C]),T=(0,a.useCallback)(()=>{w?b({state:"error",error:A}):p.trim()&&u.trim()?t({id:e?.id||(0,I.mV)(),name:k,protocol:i,apiKey:c,model:u.trim(),baseUrl:p.trim()}):b({state:"error",error:C})},[w,A,p,u,C,t,e?.id,k,i,c]);return{name:l,setName:y,protocol:i,setProtocol:N,apiKey:c,setApiKey:m,model:u,setModel:x,baseUrl:p,setBaseUrl:g,testResult:h,canSave:S,isDuplicateName:w,handleTest:z,handleSave:T}}({initial:e,onSave:t,locale:i,existingNames:o}),[c,m]=(0,a.useState)(!1),u=(0,a.useRef)(void 0);(0,a.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=e?.id?"zh"===i?"编辑 Provider":"Edit Provider":"zh"===i?"添加 Provider":"Add Provider",g=[];return d.name.trim()||g.push("zh"===i?"名称":"Name"),d.baseUrl.trim()||g.push("zh"===i?"接口地址":"Base URL"),d.model.trim()||g.push("zh"===i?"模型":"Model"),(0,r.jsxs)("div",{className:"mt-3 rounded-lg border border-border overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:p}),(0,r.jsx)("button",{type:"button",onClick:s,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"zh"===i?"关闭":"Close",children:(0,r.jsx)(f.A,{size:14})})]}),(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(D,{form:d,t:l,locale:i,layout:"compact"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-4",children:[(0,r.jsx)(F,{result:d.testResult,disabled:!d.canSave,onTest:d.handleTest,t:l}),n&&e?.id&&(0,r.jsxs)("button",{type:"button",onClick:()=>{c?(n(),u.current&&clearTimeout(u.current)):(m(!0),u.current=setTimeout(()=>m(!1),3e3))},onBlur:()=>{m(!1),u.current&&clearTimeout(u.current)},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${c?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(x.A,{size:12}),c?"zh"===i?"确认删除?":"Confirm?":"zh"===i?"删除":"Delete"]}),(0,r.jsxs)("div",{className:"flex-1",children:[d.isDuplicateName&&(0,r.jsx)("span",{className:"text-2xs text-destructive pl-2",children:"zh"===i?"名称已存在":"Name already exists"}),!d.isDuplicateName&&!d.canSave&&g.length>0&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/60 pl-2",children:"zh"===i?`需要: ${g.join("、")}`:`Required: ${g.join(", ")}`})]}),(0,r.jsx)("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-sm rounded-lg text-muted-foreground hover:text-foreground transition-colors",children:l.settings?.customProviders?.modal?.buttonCancel??"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:d.handleSave,disabled:!d.canSave,className:"px-4 py-1.5 text-sm font-medium rounded-lg bg-[var(--amber)] text-[var(--amber-foreground)] hover:bg-[var(--amber)]/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"zh"===i?"保存":"Save"})]})]})]})}let H=[{label:"SiliconFlow",baseUrl:"https://api.siliconflow.cn/v1",model:"BAAI/bge-m3",badge:"free"},{label:"OpenAI",baseUrl:"https://api.openai.com/v1",model:"text-embedding-3-small",badge:null},{label:"DeepSeek",baseUrl:"https://api.deepseek.com/v1",model:"deepseek-embed",badge:null},{label:"Ollama",baseUrl:"http://localhost:11434/v1",model:"nomic-embed-text",badge:"local"}],G=[{id:"Xenova/bge-small-zh-v1.5",label:"BGE Small ZH (33MB)",desc:"Chinese + English"},{id:"Xenova/all-MiniLM-L6-v2",label:"MiniLM L6 (23MB)",desc:"English only"},{id:"Xenova/bge-small-en-v1.5",label:"BGE Small EN (33MB)",desc:"English only"}];function J({data:e,setData:t,t:s}){let{locale:n}=(0,y.Y)(),l=s.settings.embedding??{},o=e.embedding??{enabled:!1,provider:"local",baseUrl:"",apiKey:"",model:""},i=e.embeddingStatus??{enabled:!1,ready:!1,building:!1,docCount:0},d=o.provider||"local",[c,m]=(0,a.useState)(null),[x,p]=(0,a.useState)("idle"),[b,v]=(0,a.useState)(null);(0,a.useEffect)(()=>{o.enabled&&"local"===d&&(0,N.n)("/api/embedding").then(e=>m(e.downloaded)).catch(()=>m(!1))},[o.enabled,d]),(0,a.useEffect)(()=>{if("downloading"!==x)return;let e=setInterval(()=>{(0,N.n)("/api/embedding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"status"})}).then(e=>{e.downloaded&&(m(!0),p("idle"),T.oR.success?.(l.modelReady??"Model downloaded")??(0,T.oR)(l.modelReady??"Model downloaded")),e.error&&(p("error"),v(e.error),T.oR.error?.(e.error)??(0,T.oR)(e.error))}).catch(()=>{})},3e3);return()=>clearInterval(e)},[x,l.modelReady]);let j=(0,a.useCallback)(()=>{p("starting"),v(null),(0,N.n)("/api/embedding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"download",model:o.model||void 0})}).then(e=>{e.ok?p("downloading"):(p("error"),v(e.error??"Download request failed"))}).catch(e=>{p("error"),v(e instanceof Error?e.message:"Network error")})},[o.model]),k=(0,a.useCallback)(()=>{p("idle"),v(null)},[]);return(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(S.A,{size:15}),title:l.title??"Embedding Search",description:l.description??"Semantic search with vector embeddings.",children:[(0,r.jsx)(M.pM,{label:l.enable??"Enable embedding search",hint:l.enableHint,children:(0,r.jsx)(M.lM,{checked:o.enabled,onChange:()=>{t(e=>e?{...e,embedding:{...o,enabled:!o.enabled}}:e)}})}),o.enabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>t(e=>e?{...e,embedding:{...o,provider:"local",model:o.model||"Xenova/bge-small-zh-v1.5"}}:e),className:`flex-1 px-3 py-2 text-sm rounded-lg border transition-colors text-center ${"local"===d?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[(0,r.jsxs)("span",{className:"font-medium",children:[l.providerLocal??"Local"," (",l.providerLocalFree??"Free",")"]}),(0,r.jsx)("span",{className:"block text-xs opacity-70 mt-0.5",children:l.providerLocalDesc??"Runs on your machine"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>t(e=>e?{...e,embedding:{...o,provider:"api",model:o.model||"BAAI/bge-m3",baseUrl:o.baseUrl||"https://api.siliconflow.cn/v1"}}:e),className:`flex-1 px-3 py-2 text-sm rounded-lg border transition-colors text-center ${"api"===d?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[(0,r.jsx)("span",{className:"font-medium",children:l.providerApi??"API"}),(0,r.jsx)("span",{className:"block text-xs opacity-70 mt-0.5",children:l.providerApiDesc??"OpenAI, DeepSeek, Ollama, etc."})]})]}),"local"===d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.D0,{label:l.model??"Model",hint:l.modelHint,children:(0,r.jsx)("div",{className:"space-y-1.5",children:G.map(e=>(0,r.jsxs)("label",{className:`flex items-center gap-3 px-3 py-2 rounded-lg border cursor-pointer transition-colors ${o.model===e.id?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:bg-muted"}`,children:[(0,r.jsx)("input",{type:"radio",name:"local-model",checked:o.model===e.id,onChange:()=>t(t=>t?{...t,embedding:{...o,model:e.id}}:t),className:"accent-[var(--amber)]"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:e.desc})]})]},e.id))})}),!1===c&&"idle"===x&&(0,r.jsxs)("button",{type:"button",onClick:j,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:[(0,r.jsx)(u.A,{size:14}),l.downloadModel??"Download Model"]}),"starting"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{size:14,className:"animate-spin"}),(0,r.jsx)("span",{children:l.starting??"Starting download..."})]}),"downloading"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{size:14,className:"animate-spin"}),(0,r.jsx)("span",{children:l.downloading??"Downloading model..."})]}),"error"===x&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[(0,r.jsx)(f.A,{size:14}),(0,r.jsx)("span",{children:b??"Download failed"})]}),(0,r.jsxs)("button",{type:"button",onClick:k,className:"flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(h.A,{size:12}),l.retry??"Retry"]})]}),!0===c&&"idle"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(C.A,{size:12}),(0,r.jsx)("span",{children:l.modelReady??"Model ready"})]})]}),"api"===d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2",children:H.map(e=>{let s=o.baseUrl===e.baseUrl;return(0,r.jsxs)("button",{type:"button",onClick:()=>{t(t=>t?{...t,embedding:{...o,baseUrl:e.baseUrl,model:e.model}}:t)},className:`relative px-3 py-2 text-left text-sm rounded-lg border transition-colors ${s?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:bg-muted"}`,children:[(0,r.jsx)("span",{className:`font-medium ${s?"text-[var(--amber)]":"text-foreground"}`,children:e.label}),e.badge&&(0,r.jsx)("span",{className:`ml-1.5 inline-flex items-center px-1.5 py-0.5 text-2xs rounded-full font-medium ${"free"===e.badge?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:"free"===e.badge?"zh"===n?"免费":"Free":"zh"===n?"本地":"Local"}),(0,r.jsx)("span",{className:"block text-2xs text-muted-foreground mt-0.5 truncate",children:e.model})]},e.label)})}),!o.baseUrl&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"zh"===n?"推荐使用硅基流动 (SiliconFlow),注册即可免费使用嵌入模型。":"SiliconFlow recommended — free embedding models with registration."}),(0,r.jsx)(M.D0,{label:l.baseUrl??"Base URL",hint:l.baseUrlHint,children:(0,r.jsx)(M.pd,{value:o.baseUrl,onChange:e=>t(t=>t?{...t,embedding:{...o,baseUrl:e.target.value}}:t),placeholder:"https://api.siliconflow.cn/v1"})}),(0,r.jsx)(M.D0,{label:l.apiKey??"API Key",hint:o.baseUrl?.includes("localhost")||o.baseUrl?.includes("127.0.0.1")?l.apiKeyHintLocal??("zh"===n?"本地服务可留空":"Leave empty for local services"):l.apiKeyHint??("zh"===n?"在服务商网站获取 API Key":"Get your API key from the provider"),children:(0,r.jsx)(M.yA,{value:o.apiKey,onChange:e=>t(t=>t?{...t,embedding:{...o,apiKey:e}}:t),placeholder:"sk-..."})}),(0,r.jsx)(M.D0,{label:l.model??"Model",hint:l.modelName,children:(0,r.jsx)(M.pd,{value:o.model,onChange:e=>t(t=>t?{...t,embedding:{...o,model:e.target.value}}:t),placeholder:"BAAI/bge-m3"})})]}),(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pt-1",children:i.building?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{size:12,className:"animate-spin"}),(0,r.jsx)("span",{children:l.indexBuilding??"Building embedding index..."})]}):i.ready?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{children:"function"==typeof l.indexReady?l.indexReady(i.docCount):`${i.docCount} documents indexed`})]}):(0,r.jsx)("span",{children:l.indexPending??"Index will be built on first search"})})]})]})}let V=[{id:"auto",labelKey:"providerAuto",descKey:"providerAutoDesc"},{id:"exa",labelKey:"providerExa",descKey:"providerExaDesc"},{id:"perplexity",labelKey:"providerPerplexity",descKey:"providerPerplexityDesc"},{id:"gemini",labelKey:"providerGemini",descKey:"providerGeminiDesc"}],W=[{key:"exaApiKey",labelKey:"exaApiKey",placeholder:"exa-..."},{key:"perplexityApiKey",labelKey:"perplexityApiKey",placeholder:"pplx-..."},{key:"geminiApiKey",labelKey:"geminiApiKey",placeholder:"AIza..."}];function q({data:e,setData:t,t:s}){let a=s.settings.webSearch??{},n=e.webSearch??{provider:"auto",exaApiKey:"",perplexityApiKey:"",geminiApiKey:""},l=n.provider||"auto";return(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(A.A,{size:15}),title:a.title??"Web Search",description:a.description??"Configure search providers.",children:[(0,r.jsx)("div",{className:"flex gap-2 flex-wrap",children:V.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{t(t=>t?{...t,webSearch:{...n,provider:e.id}}:t)},className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${l===e.id?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:a[e.labelKey]??e.id},e.id))}),(()=>{let e=V.find(e=>e.id===l);if(!e)return null;let t=a[e.descKey];return t?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t}):null})(),W.map(e=>(0,r.jsx)(M.D0,{label:a[e.labelKey]??e.key,hint:a.apiKeyHint,children:(0,r.jsx)(M.yA,{value:n[e.key]??"",onChange:s=>t(t=>t?{...t,webSearch:{...n,[e.key]:s}}:t),placeholder:e.placeholder})},e.key)),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a.noKeysHint??"Works without API keys via Exa MCP (zero-config)."})]})}function Y(){let{t:e}=(0,y.Y)(),[t,s]=(0,a.useState)("panel");return(0,a.useEffect)(()=>{try{let e=localStorage.getItem("ask-mode");"popup"===e&&s("popup")}catch(e){console.warn("[AiTab] localStorage getItem ask-mode failed:",e)}},[]),(0,r.jsx)(M.L7,{icon:(0,r.jsx)(z.A,{size:15}),title:e.settings.askDisplayMode?.label??"Display Mode",description:e.settings.askDisplayMode?.hint??"Side panel stays docked on the right. Popup opens a floating dialog.",children:(0,r.jsxs)(M.l6,{value:t,onChange:e=>(e=>{s(e);try{localStorage.setItem("ask-mode",e)}catch(e){console.warn("[AiTab] localStorage setItem ask-mode failed:",e)}window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:e}))})(e.target.value),children:[(0,r.jsx)("option",{value:"panel",children:e.settings.askDisplayMode?.panel??"Side Panel"}),(0,r.jsx)("option",{value:"popup",children:e.settings.askDisplayMode?.popup??"Popup"})]})})}var Z=s(51900),X=s(36999),Q=s(97810);let ee=(0,o.A)("type",[["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"}]]),et=(0,o.A)("a-large-small",[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]]),es=(0,o.A)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);var er=s(66088),ea=s(21362);let en=[{value:"lora",label:"Lora",category:"Serif",style:{fontFamily:"Lora, Georgia, serif"}},{value:"ibm-plex-sans",label:"IBM Plex Sans",category:"Sans",style:{fontFamily:"'IBM Plex Sans', sans-serif"}},{value:"inter",label:"Inter",category:"Sans",style:{fontFamily:"var(--font-inter), sans-serif"}},{value:"ibm-plex-mono",label:"IBM Plex Mono",category:"Mono",style:{fontFamily:"'IBM Plex Mono', monospace"}}];function el({icon:e,label:t,children:s}){return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t})]}),s]})}function eo({options:e,value:t,onChange:s}){return(0,r.jsx)("div",{className:"flex gap-2",children:e.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.value),className:`flex items-center gap-1.5 px-3.5 py-2 text-sm font-medium rounded-xl transition-all ${t===e.value?"bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm":"bg-muted/50 text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[e.icon,e.label]},e.value))})}function ei({font:e,setFont:t,fontSize:s,setFontSize:n,contentWidth:l,setContentWidth:o,dark:i,setDark:d,locale:m,setLocale:u,t:x}){let[p,g]=(0,a.useState)(!1),[h,b]=(0,a.useState)(()=>localStorage.getItem("theme")??"system"),[f,v]=(0,a.useState)(()=>localStorage.getItem("locale")??"system"),j=x.settings.appearance;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(c,{size:15}),title:j.preferencesTitle??"Preferences",children:[(0,r.jsx)(el,{icon:(0,r.jsx)(Z.A,{size:14}),label:j.colorTheme,children:(0,r.jsx)(eo,{options:[{value:"system",label:j.system,icon:(0,r.jsx)(z.A,{size:14})},{value:"dark",label:j.dark,icon:(0,r.jsx)(X.A,{size:14})},{value:"light",label:j.light,icon:(0,r.jsx)(Z.A,{size:14})}],value:h,onChange:e=>{b(e),localStorage.setItem("theme",e);let t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches:"dark"===e;d(t),document.documentElement.classList.toggle("dark",t)}})}),(0,r.jsx)(el,{icon:(0,r.jsx)(A.A,{size:14}),label:j.language,children:(0,r.jsx)(eo,{options:[{value:"system",label:j.system,icon:(0,r.jsx)(z.A,{size:14})},{value:"en",label:"EN"},{value:"zh",label:"中文"}],value:f,onChange:e=>{v(e),localStorage.setItem("locale",e);let t="system"===e?navigator.language.startsWith("zh")?"zh":"en":e;u(t),document.cookie=`locale=${t};path=/;max-age=31536000;SameSite=Lax`}})})]}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(Q.A,{size:15}),title:j.readingTitle??"Reading",description:j.readingDesc??"Customize how your notes look",children:[(0,r.jsx)(el,{icon:(0,r.jsx)(ee,{size:14}),label:j.readingFont,children:(0,r.jsx)("div",{className:"space-y-0.5",children:en.map(s=>{let a=e===s.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>t(s.value),className:`flex items-center gap-4 w-full px-3 py-2.5 rounded-lg transition-all text-left relative ${a?"bg-[var(--amber-subtle)]":"hover:bg-muted/50"}`,children:[a&&(0,r.jsx)("div",{className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r-full bg-[var(--amber)]"}),(0,r.jsx)("span",{className:`text-xl font-medium w-10 text-center shrink-0 ${a?"text-foreground":"text-muted-foreground/60"}`,style:{fontFamily:s.style.fontFamily},children:"Aa"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,style:{fontFamily:s.style.fontFamily},children:s.label}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/50",children:s.category})]}),(0,r.jsx)("p",{className:`text-sm truncate mt-0.5 ${a?"text-muted-foreground":"text-muted-foreground/40"}`,style:{fontFamily:s.style.fontFamily},children:j.fontPreview})]})]},s.value)})})}),(0,r.jsx)(el,{icon:(0,r.jsx)(et,{size:14}),label:j.fontSize,children:(0,r.jsxs)("div",{className:"px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",style:{fontSize:"11px"},children:"A"}),(0,r.jsx)("input",{type:"range",min:12,max:22,step:1,value:parseInt(s),onChange:e=>n(`${e.target.value}px`),className:"flex-1 h-1.5 rounded-full appearance-none bg-muted cursor-pointer accent-[var(--amber)] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--amber)] [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-110 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--amber)] [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:cursor-pointer"}),(0,r.jsx)("span",{className:"text-base text-muted-foreground/60 shrink-0",children:"A"})]}),(0,r.jsx)("div",{className:"text-center mt-1.5",children:(0,r.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[parseInt(s),"px"]})}),(0,r.jsx)("p",{className:"text-muted-foreground leading-relaxed mt-2 px-1",style:{fontSize:s,fontFamily:en.find(t=>t.value===e)?.style.fontFamily},children:j.fontSizePreview})]})}),(0,r.jsx)(el,{icon:(0,r.jsx)(es,{size:14}),label:j.contentWidth,children:(0,r.jsxs)("div",{className:"px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"▬"}),(0,r.jsx)("input",{type:"range",min:50,max:100,step:5,value:parseInt(l)||80,onChange:e=>o(`${e.target.value}%`),className:"flex-1 h-1.5 rounded-full appearance-none bg-muted cursor-pointer accent-[var(--amber)] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--amber)] [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-110 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--amber)] [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:cursor-pointer"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"▬▬▬"})]}),(0,r.jsx)("div",{className:"text-center mt-1.5",children:(0,r.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[parseInt(l)||80,"%"]})})]})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground/40 px-0.5",children:j.browserNote}),(0,r.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(!p),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:[p?(0,r.jsx)(er.A,{size:14}):(0,r.jsx)(ea.A,{size:14}),x.settings.tabs.shortcuts]}),p&&(0,r.jsx)("div",{className:"mt-3 space-y-0.5",children:x.shortcuts.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between py-1.5 px-1",children:[(0,r.jsx)("span",{className:"text-sm text-foreground",children:e.description}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:e.keys.map((e,t)=>(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs font-mono bg-muted border border-border rounded text-muted-foreground",children:e},t))})]},t))})]})]})}let ed=(0,o.A)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),ec=(0,o.A)("hard-drive",[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]);var em=s(67635);let eu=(0,o.A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);var ex=s(65576),ep=s(39498),eg=s(7834);function eh(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<0x40000000?`${(e/1048576).toFixed(1)} MB`:`${(e/0x40000000).toFixed(2)} GB`}var eb=s(76917),ef=s(9339);let ev=(0,ef.createServerReference)("009af0e2370263a914709c04ba2b336c55f0598849",ef.callServer,void 0,ef.findSourceMapURL,"scanExampleFilesAction"),ej=(0,ef.createServerReference)("003b479491cfec22ab703af600fcda015b27208bc6",ef.callServer,void 0,ef.findSourceMapURL,"cleanupExamplesAction");var ey=s(41585);let eN={checking:!1,available:null,isSelf:!1,suggestion:null};function ek({message:e,sub:t}){return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center space-y-4 max-w-sm px-6",children:[(0,r.jsx)(g.A,{size:32,className:"animate-spin mx-auto text-[var(--amber)]"}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:e}),t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t})]})})}function ew({m:e}){let[t,s]=(0,a.useState)(0),[n,l]=(0,a.useState)(0),[o,i]=(0,a.useState)(eN),[d,c]=(0,a.useState)(!1),[m,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(void 0),h=(0,a.useRef)(void 0),f=(0,a.useRef)(void 0);(0,a.useEffect)(()=>{(0,N.n)("/api/settings").then(e=>{let t=e.port||3456;s(t),l(t)}).catch(()=>{})},[]),(0,a.useEffect)(()=>()=>{clearInterval(h.current),clearTimeout(f.current)},[]);let v=n!==t,j=n<1024||n>65535,y=o.checking||!1===o.available&&!o.isSelf,k=(0,a.useCallback)(async e=>{if(e<1024||e>65535)return void i({...eN,available:!1,invalid:!0});i({...eN,checking:!0});try{let t=await (0,N.n)("/api/setup/check-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:e})});i({checking:!1,available:t.available,isSelf:t.isSelf??!1,suggestion:t.suggestion??null})}catch{i(eN)}},[]),w=async()=>{if(v&&!j&&!y&&!d){c(!0);try{let t=await (0,N.n)("/api/setup/check-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:n})});if(!t.available&&!t.isSelf){i({checking:!1,available:!1,isSelf:!1,suggestion:t.suggestion??null}),c(!1),T.oR.error(e.portInUse(n));return}await (0,N.n)("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:n})}),u(e.portWebRestarting),p(e.portRedirecting);try{await (0,N.n)("/api/restart",{method:"POST"})}catch{}let s=`${window.location.protocol}//${window.location.hostname}:${n}`,r=Date.now()+3e4;h.current=setInterval(async()=>{if(Date.now()>r){clearInterval(h.current),u(null),c(!1),T.oR.error(e.portRestartTimeout);return}try{(await fetch(`${s}/api/health`,{signal:AbortSignal.timeout(2e3)})).ok&&(clearInterval(h.current),window.location.href=s)}catch{}},1500)}catch{c(!1),T.oR.error(e.portUpdateFailed)}}};return 0===t?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.L7,{icon:(0,r.jsx)(z.A,{size:15}),title:e.webPortLabel,description:e.webPortHint,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"number",min:1024,max:65535,value:n,onChange:e=>{let t=parseInt(e.target.value,10)||n;l(t),i(eN),clearTimeout(f.current),t>=1024&&t<=65535&&(f.current=setTimeout(()=>k(t),500))},onBlur:()=>{clearTimeout(f.current),n>=1024&&n<=65535&&k(n)},className:"flex-1 px-2.5 py-1.5 text-sm rounded-lg border border-border bg-muted/30 text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring tabular-nums"}),(0,r.jsx)("button",{type:"button",onClick:w,disabled:!v||j||y||d,className:"shrink-0 px-4 py-1.5 rounded-lg text-xs font-medium transition-colors bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:d?e.portUpdating:e.portUpdateBtn})]}),o.checking&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-muted-foreground",children:[(0,r.jsx)(g.A,{size:11,className:"animate-spin"})," ",e.portChecking]}),!o.checking&&!1===o.available&&!o.invalid&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-[var(--amber)]",children:[(0,r.jsx)(ey.A,{size:11})," ",e.portInUse(n)]}),null!==o.suggestion&&(0,r.jsx)("button",{type:"button",onClick:()=>{l(o.suggestion),i(eN),setTimeout(()=>k(o.suggestion),0)},className:"text-xs px-2 py-0.5 rounded border border-[var(--amber)] text-[var(--amber)] transition-colors hover:bg-[var(--amber-subtle)]",children:e.portSuggest(o.suggestion)})]}),!o.checking&&o.invalid&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-destructive",children:[(0,r.jsx)(ey.A,{size:11})," 1024 – 65535"]}),!o.checking&&!0===o.available&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-success",children:[(0,r.jsx)(b.A,{size:11})," ",o.isSelf?e.portSelf:e.portAvailable]})]})}),m&&(0,r.jsx)(ek,{message:m,sub:x})]})}function eS({data:e,setData:t,t:s}){let l=e.envOverrides??{},o=s.settings.knowledge,i=s.settings.appearance,[d,c]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-echo")),[u,p]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-workflows")),[b,f]=(0,a.useState)(()=>"true"===localStorage.getItem("show-hidden-files")),[v,j]=(0,a.useState)(null),[y,k]=(0,a.useState)(!1),[w,S]=(0,a.useState)(null);(0,a.useEffect)(()=>{ev().then(e=>j(e.files.length)).catch(e=>{console.warn("[KnowledgeTab] scanExampleFilesAction failed:",e)})},[]);let[A,z]=(0,a.useState)(null),[E,R]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(0,N.n)("/api/setup").then(e=>{let t=e.guideState;t&&(z(t.active),R(!!t.dismissed))}).catch(e=>{console.error("Failed to fetch guide state:",e)})},[]);let P=(0,a.useCallback)(()=>{let e=!E;R(e);let t={dismissed:e};e||(t.active=!0),(0,N.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:t})}).then(()=>window.dispatchEvent(new Event("guide-state-updated"))).catch(t=>{console.error("Failed to update guide state:",t),R(!e)})},[E]),I=(0,a.useCallback)(()=>{(0,N.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{active:!0,dismissed:!1,walkthroughStep:0,walkthroughDismissed:!1}})}).then(()=>{z(!0),R(!1),window.dispatchEvent(new Event("guide-state-updated"))}).catch(e=>console.error("Failed to restart walkthrough:",e))},[]),U=(0,a.useSyncExternalStore)(()=>()=>{},()=>`${window.location.protocol}//${window.location.hostname}`,()=>"http://localhost"),[D,$]=(0,a.useState)(!1),[F,L]=(0,a.useState)(null),[O,K]=(0,a.useState)(!1),[B,_]=(0,a.useState)(!1),H=!!e.authToken,G=F??e.authToken??"";async function J(){$(!0);try{let e=await (0,N.n)("/api/settings/reset-token",{method:"POST"});L(e.token),t(t=>t?{...t,authToken:e.token}:t)}finally{$(!1)}}async function V(){t(e=>e?{...e,authToken:""}:e),L(null)}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(ed,{size:15}),title:o.cardTitle??"Knowledge Base",description:o.mindRootHint,children:[(0,r.jsx)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:[o.mindRoot," ",(0,r.jsx)(M.Bt,{overridden:l.MIND_ROOT})]}),hint:l.MIND_ROOT?o.envNote:o.mindRootHint,children:(0,r.jsx)(M.pd,{value:e.mindRoot,onChange:e=>t(t=>t?{...t,mindRoot:e.target.value}:t),placeholder:"/path/to/your/notes"})}),(0,r.jsx)(M.pM,{label:o.showHiddenFiles,hint:o.showHiddenFilesHint,children:(0,r.jsx)(M.lM,{checked:b,onChange:()=>{let e=!b;f(e),(0,eb.Fo)(e)}})}),null!==v&&v>0&&null===w&&(0,r.jsx)(M.pM,{label:o.cleanupExamples,hint:o.cleanupExamplesHint,children:(0,r.jsxs)("button",{onClick:()=>_(!0),disabled:y,title:y?s.hints.cleanupInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0 disabled:opacity-50",children:[y?(0,r.jsx)(g.A,{size:12,className:"animate-spin"}):(0,r.jsx)(x.A,{size:12}),o.cleanupExamplesButton,(0,r.jsx)("span",{className:"ml-1 tabular-nums text-2xs opacity-70",children:v})]})}),null!==w&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(C.A,{size:14}),o.cleanupExamplesDone(w)]})]}),(0,r.jsx)(ew,{m:s.settings?.mcp??{}}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(ec,{size:15}),title:o.securityTitle??"Security",children:[(0,r.jsx)(M.D0,{label:o.webPassword,hint:o.webPasswordHint,children:(0,r.jsx)(M.yA,{value:e.webPassword??"",onChange:e=>t(t=>t?{...t,webPassword:e}:t),placeholder:o.passwordPlaceholder??"Leave empty to disable"})}),(0,r.jsx)(M.D0,{label:o.authToken,hint:H?o.authTokenHint:o.authTokenNone,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-background border border-border rounded-lg min-h-[38px]",children:[(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground break-all select-all",children:G||(0,r.jsx)("span",{className:"text-muted-foreground italic",children:o.tokenNotSet??"— not set —"})}),G&&(0,r.jsx)("button",{type:"button",onClick:function(){let t=F??e.authToken??"";t&&(0,eg.l)(t).then(e=>{e&&T.oR.copy()})},className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground transition-colors",title:o.authTokenCopy,children:(0,r.jsx)(em.A,{size:13})})]}),e.mcpPort&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.authTokenMcpPort,": ",(0,r.jsx)("code",{className:"font-mono",children:e.mcpPort}),G&&(0,r.jsxs)(r.Fragment,{children:[" \xa0\xb7\xa0 ",o.mcpUrl??"MCP URL",": ",(0,r.jsx)("code",{className:"font-mono select-all",children:`${U}:${e.mcpPort}/mcp`})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:function(){K(!0)},disabled:D,title:D?s.hints.tokenResetInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(m.A,{size:14,className:D?"animate-spin":""}),o.authTokenReset]}),H&&(0,r.jsxs)("button",{type:"button",onClick:V,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors",children:[(0,r.jsx)(x.A,{size:14}),o.authTokenClear]})]}),F&&(0,r.jsx)("p",{className:"text-xs text-[var(--amber-text)]",children:o.tokenGenerated})]})})]}),null!==A&&(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(n.A,{size:15}),title:s.guide?.title??"Getting Started",children:[(0,r.jsx)(M.pM,{label:s.guide?.showGuide??"Show getting started guide",children:(0,r.jsx)(M.lM,{checked:!E,onChange:()=>P()})}),(0,r.jsxs)("button",{onClick:I,className:"flex items-center gap-1.5 mt-2 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(h.A,{size:14}),o.restartWalkthrough??"Restart walkthrough"]})]}),(0,r.jsx)(M.L7,{icon:(0,r.jsx)(eu,{size:15}),title:i.labsTitle??"Labs",description:i.labsDesc??"Experimental features that are still in development.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(eC,{label:i.labsEcho??"Echo",description:i.labsEchoDesc??"Reflective journaling powered by your notes.",checked:d,onChange:e=>{c(e),localStorage.setItem("mindos:labs-echo",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}}),(0,r.jsx)(eC,{label:i.labsWorkflows??"Flows",description:i.labsWorkflowsDesc??"Visual workflow automation for agents.",checked:u,onChange:e=>{p(e),localStorage.setItem("mindos:labs-workflows",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}})]})}),(0,r.jsx)(eA,{k:o}),(0,r.jsx)(ep.TM,{open:O,title:o.authTokenReset??"Regenerate Token",message:o.authTokenResetConfirm,confirmLabel:o.authTokenReset??"Regenerate",cancelLabel:o.cancel??"Cancel",onConfirm:()=>{K(!1),J()},onCancel:()=>K(!1)}),(0,r.jsx)(ep.TM,{open:B,title:o.cleanupExamples??"Cleanup Examples",message:null!==v?o.cleanupExamplesConfirm(v):"",confirmLabel:o.cleanupExamplesButton??"Clean up",cancelLabel:o.cancel??"Cancel",variant:"destructive",onConfirm:async()=>{_(!1),k(!0);let e=await ej();k(!1),e.success&&(S(e.deleted),j(0))},onCancel:()=>_(!1)})]})}function eC({label:e,description:t,checked:s,onChange:a}){return(0,r.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground block",children:e}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>a(!s),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${s?"bg-[var(--amber)]":"bg-muted-foreground/20"}`,children:(0,r.jsx)("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${s?"translate-x-4":"translate-x-0"}`})})]})}function eA({k:e}){let[t,s]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null),[o,i]=(0,a.useState)(!1),d=(0,a.useCallback)(async()=>{i(!0);try{let e=await (0,N.n)("/api/monitoring",{timeout:5e3});l(e)}catch{}i(!1)},[]),c=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!t){c.current=!1;return}c.current||(d(),c.current=!0);let e=setInterval(d,1e4);return()=>clearInterval(e)},[t,d]),(0,r.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,r.jsxs)("button",{onClick:()=>s(e=>!e),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[t?(0,r.jsx)(er.A,{size:14}):(0,r.jsx)(ea.A,{size:14}),(0,r.jsx)(ex.A,{size:12}),e.monitoringTitle??"System Monitoring",o&&(0,r.jsx)(g.A,{size:10,className:"animate-spin ml-1"})]}),t&&n&&(0,r.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-x-6 gap-y-2 text-xs",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorHeap??"Heap"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[eh(n.system.memory.heapUsed)," / ",eh(n.system.memory.heapTotal)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRss??"RSS"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:eh(n.system.memory.rss)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorUptime??"Uptime"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:function(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60);if(s<60)return`${s}m ${t%60}s`;let r=Math.floor(s/60);if(r<24)return`${r}h ${s%60}m`;let a=Math.floor(r/24);return`${a}d ${r%24}h`}(n.system.uptimeMs)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorNode??"Node"}),(0,r.jsx)("span",{className:"ml-2",children:n.system.nodeVersion})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRequests??"Requests"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.agentRequests})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorToolCalls??"Tool Calls"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.toolExecutions})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorTokens??"Tokens"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:(n.application.totalTokens.input+n.application.totalTokens.output).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorFiles??"Files"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[n.knowledgeBase.fileCount," (",eh(n.knowledgeBase.totalSizeBytes),")"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"MCP"}),(0,r.jsx)("span",{className:"ml-2",children:n.mcp.running?e.monitorMcpRunning?.(n.mcp.port)??`Running :${n.mcp.port}`:e.monitorMcpStopped??"Stopped"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorErrors??"Errors"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.errors})]})]}),t&&!n&&!o&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.monitoringFailed??"Failed to load monitoring data"})]})}var ez=s(402),eT=s(10762),eM=s(439),eE=s(15411),eR=s(7915),eP=s(70617),eI=s(51914),eU=s(42129),eD=s(49387);let e$=(0,s(37206).default)(()=>Promise.all([s.e(7011),s.e(3399)]).then(s.bind(s,83399)),{loadableGenerated:{webpack:()=>[83399]},ssr:!1});function eF({skill:e,expanded:t,onExpand:s,onToggle:a,onDelete:n,onEditStart:l,onEditSave:o,onEditCancel:i,editing:d,editContent:c,setEditContent:m,editError:u,saving:h,fullContent:b,loadingContent:f,loadErrors:v,m:j}){return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>s(e.name),children:[t?(0,r.jsx)(er.A,{size:12}):(0,r.jsx)(ea.A,{size:12}),(0,r.jsx)("span",{className:"text-xs font-medium flex-1",children:e.name}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded ${"builtin"===e.source?"bg-muted text-muted-foreground":"bg-[var(--amber-subtle)] text-[var(--amber-text)]"}`,children:"builtin"===e.source?j?.skillBuiltin??"Built-in":j?.skillUser??"Custom"}),(0,r.jsx)(M.lM,{size:"sm",checked:e.enabled,onClick:t=>{t.stopPropagation(),a(e.name,!e.enabled)}})]}),t&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border text-xs space-y-2 bg-muted/20",children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:e.description||"No description"}),(0,r.jsx)("p",{className:"text-muted-foreground font-mono text-2xs",children:e.path}),f===e.name?(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(g.A,{size:10,className:"animate-spin"}),(0,r.jsx)("span",{className:"text-2xs",children:"Loading..."})]}):b[e.name]?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-2xs text-muted-foreground font-medium",children:j?.skillContent??"Content"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.editable&&d!==e.name&&(0,r.jsxs)("button",{onClick:()=>l(e.name),className:"flex items-center gap-1 text-2xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(eD.A,{size:10}),j?.editSkill??"Edit"]}),e.editable&&(0,r.jsxs)("button",{onClick:()=>n(e.name),className:"flex items-center gap-1 text-2xs text-destructive hover:underline",children:[(0,r.jsx)(x.A,{size:10}),j?.deleteSkill??"Delete"]})]})]}),d===e.name?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("textarea",{value:c,onChange:e=>m(e.target.value),rows:Math.min(20,(c.match(/\n/g)||[]).length+3),className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y font-mono"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>o(e.name),disabled:h,className:"flex items-center gap-1 px-2.5 py-1 text-xs rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-[var(--amber)] text-[var(--amber-foreground)]",children:[h&&(0,r.jsx)(g.A,{size:10,className:"animate-spin"}),j?.saveSkill??"Save"]}),(0,r.jsx)("button",{onClick:i,className:"px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground transition-colors",children:j?.cancelSkill??"Cancel"})]}),u&&(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(p.A,{size:10}),u]})]}):(0,r.jsx)("div",{className:"w-full rounded-md border border-border bg-background/50 max-h-[300px] overflow-y-auto px-2.5 py-1.5 text-xs [&_.prose]:max-w-none [&_.prose]:text-xs [&_h1]:text-sm [&_h2]:text-xs [&_h3]:text-xs [&_pre]:text-2xs [&_code]:text-2xs",children:(0,r.jsx)(e$,{content:function(e){if(!e.startsWith("---"))return e;let t=e.indexOf("\n---",3);return -1===t?e:e.slice(t+4).replace(/^\n+/,"")}(b[e.name])})})]}):v[e.name]?(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(p.A,{size:10}),v[e.name]]}):null]})]})}let eL=e=>`---
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3985],{439:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(90425).A)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},33985:(e,t,s)=>{s.r(t),s.d(t,{default:()=>tA});var r=s(95155),a=s(12115),n=s(86901),l=s(68806),o=s(90425);let i=(0,o.A)("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);var d=s(89363);let c=(0,o.A)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);var m=s(91958),u=s(6962),x=s(68459),p=s(13545),g=s(6296),h=s(9199),b=s(12651),f=s(33210),v=s(94961),j=s(73321),y=s(35581),N=s(22356),k=s(22164),w=s(49619),S=s(61878),C=s(94514),A=s(92451),z=s(92972),T=s(4235),M=s(20171),E=s(47376),R=s(51842),P=s(79704),I=s(60112);function U(e,t=[],s,r){let a=E.T_[e],n="zh"===r?a.nameZh:a.name,l=new Set(t.filter(e=>e&&e!==s).map(e=>e.trim().toLowerCase()));if(!l.has(n.trim().toLowerCase()))return n;let o=2;for(;l.has(`${n} ${o}`.toLowerCase());)o++;return`${n} ${o}`}function D({form:e,t,locale:s,layout:a="full"}){let n=E.T_[e.protocol],l="zh"===s?"名称":"Name",o="zh"===s?"协议":"Protocol",i="zh"===s?"可选,默认使用协议名称":"Optional, defaults to protocol name",d=e.isDuplicateName?"zh"===s?"名称已存在":"Name already exists":void 0;return(0,r.jsxs)("div",{className:"space-y-3",children:["compact"===a?(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(M.D0,{label:l,hint:d,hintError:e.isDuplicateName,children:(0,r.jsx)(M.pd,{value:e.name,onChange:t=>e.setName(t.target.value),placeholder:i,autoFocus:!0})}),(0,r.jsx)(M.D0,{label:o,children:(0,r.jsx)(M.l6,{value:e.protocol,onChange:t=>e.setProtocol(t.target.value),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===s?E.T_[e].nameZh:E.T_[e].name},e))})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.D0,{label:l,hint:d,hintError:e.isDuplicateName,children:(0,r.jsx)(M.pd,{value:e.name,onChange:t=>e.setName(t.target.value),placeholder:i})}),(0,r.jsx)(M.D0,{label:o,children:(0,r.jsx)(M.l6,{value:e.protocol,onChange:t=>e.setProtocol(t.target.value),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===s?E.T_[e].nameZh:E.T_[e].name},e))})})]}),(0,r.jsx)(M.D0,{label:"Base URL",children:(0,r.jsx)(M.pd,{value:e.baseUrl,onChange:t=>e.setBaseUrl(t.target.value),placeholder:n.fixedBaseUrl||"https://api.example.com/v1"})}),(0,r.jsx)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:["API Key ",(0,r.jsx)("span",{className:"text-muted-foreground/50 font-normal",children:"zh"===s?"(可选)":"(optional)"})]}),children:(0,r.jsx)(M.yA,{value:e.apiKey,onChange:e.setApiKey,placeholder:"sk-..."})}),(0,r.jsx)(M.D0,{label:"zh"===s?"模型":"Model",children:(0,r.jsx)(P.A,{value:e.model,onChange:e.setModel,placeholder:n.defaultModel,provider:e.protocol,apiKey:e.apiKey,baseUrl:e.baseUrl,supportsListModels:!!e.baseUrl.trim(),allowNoKey:!0,browseLabel:t.settings.ai.listModels,noModelsLabel:t.settings.ai.noModelsFound})})]})}var $=s(53961);function F({result:e,disabled:t,onTest:s,t:a}){let n="testing"===e.state,l="ok"===e.state,o="error"===e.state;return(0,r.jsxs)("button",{type:"button",disabled:t||n,onClick:s,className:`inline-flex items-center gap-1.5 px-3.5 py-1.5 text-sm font-medium rounded-lg transition-all duration-200 disabled:cursor-not-allowed ${l?"bg-success/10 text-success border border-success/20":o?"bg-destructive/8 text-destructive border border-destructive/20 hover:bg-destructive/12":"border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 disabled:opacity-40"}`,children:[n?(0,r.jsx)(g.A,{size:13,className:"animate-spin"}):l?(0,r.jsx)(C.A,{size:13}):o?(0,r.jsx)(p.A,{size:13}):(0,r.jsx)($.A,{size:13}),n?a.settings.ai.testKeyTesting:l&&null!=e.latency?a.settings.ai.testKeyOk(e.latency):o?function(e,t){switch(t){case"auth_error":return e.settings.ai.testKeyAuthError;case"model_not_found":return e.settings.ai.testKeyModelNotFound;case"endpoint_error":return e.settings.ai.testKeyEndpointError;case"rate_limited":return e.settings.ai.testKeyRateLimited;case"network_error":return e.settings.ai.testKeyNetworkError;default:return e.settings.ai.testKeyUnknown}}(a,e.code):a.settings.ai.testKey]})}let L=[10,20,30,40,50,999];function O({value:e,onChange:t}){let s=L.includes(e),[n,l]=(0,a.useState)(!s);return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(M.l6,{value:n?"custom":String(e),onChange:e=>{let s=e.target.value;"custom"===s?l(!0):(l(!1),t(Number(s)))},className:"w-28",children:[(0,r.jsx)("option",{value:"10",children:"10"}),(0,r.jsx)("option",{value:"20",children:"20"}),(0,r.jsx)("option",{value:"30",children:"30"}),(0,r.jsx)("option",{value:"40",children:"40"}),(0,r.jsx)("option",{value:"50",children:"50"}),(0,r.jsx)("option",{value:"999",children:"Unlimited"}),(0,r.jsx)("option",{value:"custom",children:"Custom"})]}),n&&(0,r.jsx)("input",{type:"number",value:999===e?"":e,onChange:e=>{let s=parseInt(e.target.value,10);!isNaN(s)&&s>0&&t(Math.min(999,s))},placeholder:"1-999",min:1,max:999,autoFocus:!0,className:"w-20 px-2 py-1 rounded-md border border-border/60 bg-muted/50 text-sm text-foreground"})]})}function K({data:e,setData:t,updateAi:s,updateAgent:l,t:o}){let{locale:i}=(0,y.Y)(),d=e.envOverrides??{},c=e.ai.providers.find(t=>t.id===e.ai.activeProvider),m=c?E.T_[c.protocol]:null,[u,x]=(0,a.useState)({}),[p,g]=(0,a.useState)(!1),h=(0,a.useRef)(void 0),b=(0,a.useRef)(e.ai.activeProvider);(0,a.useEffect)(()=>{b.current!==e.ai.activeProvider&&(b.current=e.ai.activeProvider,x({}),h.current&&(clearTimeout(h.current),h.current=void 0))},[e.ai.activeProvider]),(0,a.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,a.useEffect)(()=>{let t=e.agent?.reconnectRetries??3;try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},[e.agent?.reconnectRetries]);let f=(0,a.useCallback)(async()=>{if(!c)return;let e=c.id;x(t=>({...t,[e]:{state:"testing"}}));try{let t={provider:c.protocol};c.apiKey&&(t.apiKey=c.apiKey),c.model&&(t.model=c.model),c.baseUrl&&(t.baseUrl=c.baseUrl);let s=await fetch("/api/settings/test-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json();r.ok?(x(t=>({...t,[e]:{state:"ok",latency:r.latency}})),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{x(t=>({...t,[e]:{state:"idle"}}))},8e3)):x(t=>({...t,[e]:{state:"error",error:r.error,code:r.code}}))}catch{x(t=>({...t,[e]:{state:"error",code:"network_error",error:"Network error"}}))}},[c]),v=(0,a.useCallback)(t=>{c&&("apiKey"in t&&x(e=>({...e,[c.id]:{state:"idle"}})),s({providers:e.ai.providers.map(e=>e.id===c.id?{...e,...t}:e)}))},[c,e.ai.providers,s]),j=c?(0,E.Ux)(c.protocol):void 0,N=!!j&&d[j],S=!!m?.apiKeyFallback,C=(0,a.useCallback)(()=>{if(!c)return;let t=E.T_[c.protocol];x(e=>({...e,[c.id]:{state:"idle"}})),s({providers:e.ai.providers.map(e=>e.id===c.id?{...e,apiKey:"",model:"",baseUrl:t?.fixedBaseUrl??""}:e)})},[c,e.ai.providers,s]),A=(0,a.useCallback)(()=>{if(!c)return;let t=e.ai.providers.filter(e=>e.id!==c.id);s({activeProvider:t.length>0?t[0].id:"",providers:t}),x(e=>{let t={...e};return delete t[c.id],t})},[c,e.ai.providers,s]),z=(0,a.useCallback)(t=>{let r={id:t.id||(0,I.mV)(),name:t.name,protocol:t.protocol,apiKey:t.apiKey,model:t.model,baseUrl:t.baseUrl};s({activeProvider:r.id,providers:[...e.ai.providers,r]}),g(!1)},[e.ai.providers,s]),T=c?.name??("zh"===i?"未选择":"No provider");return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(n.A,{size:15}),title:o.settings.ai.provider,description:T,children:[(0,r.jsx)(R.A,{value:e.ai.activeProvider,onChange:e=>{"skip"!==e&&s({activeProvider:e}),g(!1)},compact:!0,customProviders:e.ai.providers,onAdd:()=>{let t=E.T_.openai,s="zh"===i?t.nameZh:t.name,r=new Set(e.ai.providers.map(e=>e.name.toLowerCase())),a=s;if(r.has(a.toLowerCase())){let e=2;for(;r.has(`${s} (${e})`.toLowerCase());)e++;a=`${s} (${e})`}g(!0)}}),p&&(0,r.jsx)(_,{onSave:z,onCancel:()=>g(!1),t:o,existingNames:e.ai.providers.map(e=>e.name)},"new"),!p&&c&&(0,r.jsxs)("div",{className:"space-y-3 pt-3 border-t border-border",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(M.D0,{label:"zh"===i?"名称":"Name",children:(0,r.jsx)(M.pd,{value:c.name,onChange:e=>v({name:e.target.value}),placeholder:"zh"===i?"输入名称":"Enter name"})}),(0,r.jsx)(M.D0,{label:"zh"===i?"协议":"Protocol",children:(0,r.jsx)(M.l6,{value:c.protocol,onChange:e=>v({protocol:e.target.value}),children:E.jt.map(e=>(0,r.jsx)("option",{value:e,children:"zh"===i?E.T_[e].nameZh:E.T_[e].name},e))})})]}),(0,r.jsxs)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:[o.settings.ai.apiKey," ",j&&(0,r.jsx)(M.Bt,{overridden:d[j]})]}),hint:m&&N?o.settings.ai.envFieldNote(j):m&&S?o.settings.ai.keyOptionalHint:void 0,children:[(0,r.jsx)(M.yA,{value:c.apiKey,onChange:e=>v({apiKey:e}),placeholder:"sk-..."}),m?.signupUrl&&!c.apiKey&&!N&&(0,r.jsxs)("a",{href:m.signupUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs mt-1.5 hover:underline",style:{color:"var(--amber)"},children:[(0,r.jsx)(k.A,{size:10}),S?"zh"===i?`下载 ${m.nameZh}`:`Download ${m.name}`:"zh"===i?`获取 ${m.nameZh} API Key`:`Get ${m.name} API Key`]})]}),(m?.supportsBaseUrl||c.baseUrl)&&(0,r.jsx)(M.D0,{label:"Base URL",children:(0,r.jsx)(M.pd,{value:c.baseUrl,onChange:e=>v({baseUrl:e.target.value}),placeholder:m?.fixedBaseUrl||(0,E.Ot)(c.protocol)||"https://api.openai.com/v1"})}),(0,r.jsx)(M.D0,{label:"zh"===i?"模型":"Model",children:(0,r.jsx)(P.A,{value:c.model,onChange:e=>v({model:e}),placeholder:m?.defaultModel??"",provider:c.protocol,apiKey:c.apiKey,envKey:!!N,baseUrl:c.baseUrl,supportsListModels:!!c.baseUrl?.trim()||!!m?.supportsListModels,allowNoKey:!!c.baseUrl?.trim(),browseLabel:o.settings.ai.listModels,noModelsLabel:o.settings.ai.noModelsFound})}),(0,r.jsx)(B,{provider:c.protocol,result:u[c.id]??{state:"idle"},hasKey:!!c.apiKey,hasEnv:!!N,hasConfig:!!(c.apiKey||c.model||c.baseUrl),onTest:f,onReset:C,onDelete:A,t:o})]})]}),(0,r.jsx)(J,{data:e,setData:t,t:o}),(0,r.jsx)(q,{data:e,setData:t,t:o}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(w.A,{size:15}),title:o.settings.agent.title,description:o.settings.agent.subtitle??"Configure how the AI agent operates",children:[(0,r.jsx)(M.pM,{label:o.settings.agent.maxSteps,hint:o.settings.agent.maxStepsHint,children:(0,r.jsx)(O,{value:e.agent?.maxSteps??20,onChange:e=>l({maxSteps:e})})}),(0,r.jsx)(M.pM,{label:o.settings.agent.contextStrategy,hint:o.settings.agent.contextStrategyHint,children:(0,r.jsxs)(M.l6,{value:e.agent?.contextStrategy??"auto",onChange:e=>l({contextStrategy:e.target.value}),className:"w-24",children:[(0,r.jsx)("option",{value:"auto",children:o.settings.agent.contextStrategyAuto}),(0,r.jsx)("option",{value:"off",children:o.settings.agent.contextStrategyOff})]})}),(0,r.jsx)(M.pM,{label:o.settings.agent.reconnectRetries,hint:o.settings.agent.reconnectRetriesHint,children:(0,r.jsxs)(M.l6,{value:String(e.agent?.reconnectRetries??3),onChange:e=>{let t=Number(e.target.value);l({reconnectRetries:t});try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},className:"w-20",children:[(0,r.jsx)("option",{value:"0",children:"Off"}),(0,r.jsx)("option",{value:"1",children:"1"}),(0,r.jsx)("option",{value:"2",children:"2"}),(0,r.jsx)("option",{value:"3",children:"3"}),(0,r.jsx)("option",{value:"5",children:"5"}),(0,r.jsx)("option",{value:"10",children:"10"})]})}),m?.supportsThinking&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.pM,{label:o.settings.agent.thinking,hint:o.settings.agent.thinkingHint,children:(0,r.jsx)(M.lM,{checked:e.agent?.enableThinking??!1,onChange:()=>l({enableThinking:!e.agent?.enableThinking})})}),e.agent?.enableThinking&&(0,r.jsx)(M.D0,{label:o.settings.agent.thinkingBudget,hint:o.settings.agent.thinkingBudgetHint,children:(0,r.jsx)(M.pd,{type:"number",value:String(e.agent?.thinkingBudget??5e3),onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||l({thinkingBudget:Math.max(1e3,Math.min(5e4,t))})},min:1e3,max:5e4,step:1e3})})]})]}),(0,r.jsx)(Y,{})]})}function B({provider:e,result:t,hasKey:s,hasEnv:n,hasConfig:l,onTest:o,onReset:i,onDelete:d,t:c}){let[m,u]=(0,a.useState)(null),p=(0,a.useRef)(void 0),g=!!E.T_[e]?.apiKeyFallback;(0,a.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let b=e=>{m===e?("reset"===e?i?.():d?.(),u(null),p.current&&clearTimeout(p.current)):(u(e),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>u(null),3e3))},{locale:f}=(0,y.Y)();return(0,r.jsx)("div",{className:"space-y-2 pt-2",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(F,{result:t,disabled:!(s||n||g),onTest:o,t:c}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[i&&l&&(0,r.jsxs)("button",{type:"button",onClick:()=>b("reset"),onBlur:()=>{"reset"===m&&(u(null),p.current&&clearTimeout(p.current))},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${"reset"===m?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(h.A,{size:12}),"reset"===m?"zh"===f?"确认重置?":"Confirm?":"zh"===f?"重置":"Reset"]}),d&&(0,r.jsxs)("button",{type:"button",onClick:()=>b("delete"),onBlur:()=>{"delete"===m&&(u(null),p.current&&clearTimeout(p.current))},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${"delete"===m?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(x.A,{size:12}),"delete"===m?"zh"===f?"确认删除?":"Confirm?":"zh"===f?"删除":"Delete"]})]})]})})}function _({initial:e,onSave:t,onCancel:s,onDelete:n,t:l,existingNames:o}){let{locale:i}=(0,y.Y)(),d=function({initial:e,onSave:t,locale:s,existingNames:r}){let n=(0,a.useMemo)(()=>e?.name??U(e?.protocol??"openai",r,e?.name,s),[e?.name,e?.protocol,r,s]),[l,o]=(0,a.useState)(n),[i,d]=(0,a.useState)(e?.protocol??"openai"),[c,m]=(0,a.useState)(e?.apiKey??""),[u,x]=(0,a.useState)(e?.model??""),[p,g]=(0,a.useState)(e?.baseUrl??""),[h,b]=(0,a.useState)({state:"idle"}),[f,v]=(0,a.useState)(!!e?.name),j=(0,a.useMemo)(()=>U(i,r,e?.name,s),[i,r,e?.name,s]);(0,a.useEffect)(()=>{f||o(j)},[j,f]);let y=(0,a.useCallback)(e=>{v(!0),o(e)},[]),N=(0,a.useCallback)(e=>{d(e),b({state:"idle"})},[]),k=l.trim()||j,w=!!(k&&r?.some(t=>t!==e?.name&&t.toLowerCase()===k.toLowerCase())),S=!!(p.trim()&&u.trim()&&!w),C="zh"===s?"接口地址和模型为必填":"Base URL and model are required",A="zh"===s?"名称已存在,请使用其他名称":"Name already exists, please use a different name",z=(0,a.useCallback)(async()=>{if(w)return void b({state:"error",error:A});if(!p.trim()||!u.trim())return void b({state:"error",error:C});b({state:"testing"});try{let t=await fetch("/api/settings/test-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?.id?{provider:e.id,apiKey:c,model:u,baseUrl:p}:{provider:i,apiKey:c,model:u,baseUrl:p,baseProviderId:i})}),s=await t.json();s.ok?b({state:"ok",latency:s.latency}):b({state:"error",error:s.error||"Test failed",code:s.code})}catch{b({state:"error",code:"network_error",error:"Network error"})}},[w,A,p,u,e?.id,c,i,C]),T=(0,a.useCallback)(()=>{w?b({state:"error",error:A}):p.trim()&&u.trim()?t({id:e?.id||(0,I.mV)(),name:k,protocol:i,apiKey:c,model:u.trim(),baseUrl:p.trim()}):b({state:"error",error:C})},[w,A,p,u,C,t,e?.id,k,i,c]);return{name:l,setName:y,protocol:i,setProtocol:N,apiKey:c,setApiKey:m,model:u,setModel:x,baseUrl:p,setBaseUrl:g,testResult:h,canSave:S,isDuplicateName:w,handleTest:z,handleSave:T}}({initial:e,onSave:t,locale:i,existingNames:o}),[c,m]=(0,a.useState)(!1),u=(0,a.useRef)(void 0);(0,a.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=e?.id?"zh"===i?"编辑 Provider":"Edit Provider":"zh"===i?"添加 Provider":"Add Provider",g=[];return d.name.trim()||g.push("zh"===i?"名称":"Name"),d.baseUrl.trim()||g.push("zh"===i?"接口地址":"Base URL"),d.model.trim()||g.push("zh"===i?"模型":"Model"),(0,r.jsxs)("div",{className:"mt-3 rounded-lg border border-border overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:p}),(0,r.jsx)("button",{type:"button",onClick:s,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"zh"===i?"关闭":"Close",children:(0,r.jsx)(f.A,{size:14})})]}),(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(D,{form:d,t:l,locale:i,layout:"compact"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-4",children:[(0,r.jsx)(F,{result:d.testResult,disabled:!d.canSave,onTest:d.handleTest,t:l}),n&&e?.id&&(0,r.jsxs)("button",{type:"button",onClick:()=>{c?(n(),u.current&&clearTimeout(u.current)):(m(!0),u.current=setTimeout(()=>m(!1),3e3))},onBlur:()=>{m(!1),u.current&&clearTimeout(u.current)},className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-all duration-200 ${c?"bg-destructive/10 text-destructive border border-destructive/25 font-medium":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(x.A,{size:12}),c?"zh"===i?"确认删除?":"Confirm?":"zh"===i?"删除":"Delete"]}),(0,r.jsxs)("div",{className:"flex-1",children:[d.isDuplicateName&&(0,r.jsx)("span",{className:"text-2xs text-destructive pl-2",children:"zh"===i?"名称已存在":"Name already exists"}),!d.isDuplicateName&&!d.canSave&&g.length>0&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/60 pl-2",children:"zh"===i?`需要: ${g.join("、")}`:`Required: ${g.join(", ")}`})]}),(0,r.jsx)("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-sm rounded-lg text-muted-foreground hover:text-foreground transition-colors",children:l.settings?.customProviders?.modal?.buttonCancel??"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:d.handleSave,disabled:!d.canSave,className:"px-4 py-1.5 text-sm font-medium rounded-lg bg-[var(--amber)] text-[var(--amber-foreground)] hover:bg-[var(--amber)]/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"zh"===i?"保存":"Save"})]})]})]})}let H=[{label:"SiliconFlow",baseUrl:"https://api.siliconflow.cn/v1",model:"BAAI/bge-m3",badge:"free"},{label:"OpenAI",baseUrl:"https://api.openai.com/v1",model:"text-embedding-3-small",badge:null},{label:"DeepSeek",baseUrl:"https://api.deepseek.com/v1",model:"deepseek-embed",badge:null},{label:"Ollama",baseUrl:"http://localhost:11434/v1",model:"nomic-embed-text",badge:"local"}],G=[{id:"Xenova/bge-small-zh-v1.5",label:"BGE Small ZH (33MB)",desc:"Chinese + English"},{id:"Xenova/all-MiniLM-L6-v2",label:"MiniLM L6 (23MB)",desc:"English only"},{id:"Xenova/bge-small-en-v1.5",label:"BGE Small EN (33MB)",desc:"English only"}];function J({data:e,setData:t,t:s}){let{locale:n}=(0,y.Y)(),l=s.settings.embedding??{},o=e.embedding??{enabled:!1,provider:"local",baseUrl:"",apiKey:"",model:""},i=e.embeddingStatus??{enabled:!1,ready:!1,building:!1,docCount:0},d=o.provider||"local",[c,m]=(0,a.useState)(null),[x,p]=(0,a.useState)("idle"),[b,v]=(0,a.useState)(null);(0,a.useEffect)(()=>{o.enabled&&"local"===d&&(0,N.n)("/api/embedding").then(e=>m(e.downloaded)).catch(()=>m(!1))},[o.enabled,d]),(0,a.useEffect)(()=>{if("downloading"!==x)return;let e=setInterval(()=>{(0,N.n)("/api/embedding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"status"})}).then(e=>{e.downloaded&&(m(!0),p("idle"),T.oR.success?.(l.modelReady??"Model downloaded")??(0,T.oR)(l.modelReady??"Model downloaded")),e.error&&(p("error"),v(e.error),T.oR.error?.(e.error)??(0,T.oR)(e.error))}).catch(()=>{})},3e3);return()=>clearInterval(e)},[x,l.modelReady]);let j=(0,a.useCallback)(()=>{p("starting"),v(null),(0,N.n)("/api/embedding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"download",model:o.model||void 0})}).then(e=>{e.ok?p("downloading"):(p("error"),v(e.error??"Download request failed"))}).catch(e=>{p("error"),v(e instanceof Error?e.message:"Network error")})},[o.model]),k=(0,a.useCallback)(()=>{p("idle"),v(null)},[]);return(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(S.A,{size:15}),title:l.title??"Embedding Search",description:l.description??"Semantic search with vector embeddings.",children:[(0,r.jsx)(M.pM,{label:l.enable??"Enable embedding search",hint:l.enableHint,children:(0,r.jsx)(M.lM,{checked:o.enabled,onChange:()=>{t(e=>e?{...e,embedding:{...o,enabled:!o.enabled}}:e)}})}),o.enabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>t(e=>e?{...e,embedding:{...o,provider:"local",model:o.model||"Xenova/bge-small-zh-v1.5"}}:e),className:`flex-1 px-3 py-2 text-sm rounded-lg border transition-colors text-center ${"local"===d?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[(0,r.jsxs)("span",{className:"font-medium",children:[l.providerLocal??"Local"," (",l.providerLocalFree??"Free",")"]}),(0,r.jsx)("span",{className:"block text-xs opacity-70 mt-0.5",children:l.providerLocalDesc??"Runs on your machine"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>t(e=>e?{...e,embedding:{...o,provider:"api",model:o.model||"BAAI/bge-m3",baseUrl:o.baseUrl||"https://api.siliconflow.cn/v1"}}:e),className:`flex-1 px-3 py-2 text-sm rounded-lg border transition-colors text-center ${"api"===d?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[(0,r.jsx)("span",{className:"font-medium",children:l.providerApi??"API"}),(0,r.jsx)("span",{className:"block text-xs opacity-70 mt-0.5",children:l.providerApiDesc??"OpenAI, DeepSeek, Ollama, etc."})]})]}),"local"===d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.D0,{label:l.model??"Model",hint:l.modelHint,children:(0,r.jsx)("div",{className:"space-y-1.5",children:G.map(e=>(0,r.jsxs)("label",{className:`flex items-center gap-3 px-3 py-2 rounded-lg border cursor-pointer transition-colors ${o.model===e.id?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:bg-muted"}`,children:[(0,r.jsx)("input",{type:"radio",name:"local-model",checked:o.model===e.id,onChange:()=>t(t=>t?{...t,embedding:{...o,model:e.id}}:t),className:"accent-[var(--amber)]"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,r.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:e.desc})]})]},e.id))})}),!1===c&&"idle"===x&&(0,r.jsxs)("button",{type:"button",onClick:j,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:[(0,r.jsx)(u.A,{size:14}),l.downloadModel??"Download Model"]}),"starting"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{size:14,className:"animate-spin"}),(0,r.jsx)("span",{children:l.starting??"Starting download..."})]}),"downloading"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(g.A,{size:14,className:"animate-spin"}),(0,r.jsx)("span",{children:l.downloading??"Downloading model..."})]}),"error"===x&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[(0,r.jsx)(f.A,{size:14}),(0,r.jsx)("span",{children:b??"Download failed"})]}),(0,r.jsxs)("button",{type:"button",onClick:k,className:"flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(h.A,{size:12}),l.retry??"Retry"]})]}),!0===c&&"idle"===x&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(C.A,{size:12}),(0,r.jsx)("span",{children:l.modelReady??"Model ready"})]})]}),"api"===d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2",children:H.map(e=>{let s=o.baseUrl===e.baseUrl;return(0,r.jsxs)("button",{type:"button",onClick:()=>{t(t=>t?{...t,embedding:{...o,baseUrl:e.baseUrl,model:e.model}}:t)},className:`relative px-3 py-2 text-left text-sm rounded-lg border transition-colors ${s?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:bg-muted"}`,children:[(0,r.jsx)("span",{className:`font-medium ${s?"text-[var(--amber)]":"text-foreground"}`,children:e.label}),e.badge&&(0,r.jsx)("span",{className:`ml-1.5 inline-flex items-center px-1.5 py-0.5 text-2xs rounded-full font-medium ${"free"===e.badge?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:"free"===e.badge?"zh"===n?"免费":"Free":"zh"===n?"本地":"Local"}),(0,r.jsx)("span",{className:"block text-2xs text-muted-foreground mt-0.5 truncate",children:e.model})]},e.label)})}),!o.baseUrl&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"zh"===n?"推荐使用硅基流动 (SiliconFlow),注册即可免费使用嵌入模型。":"SiliconFlow recommended — free embedding models with registration."}),(0,r.jsx)(M.D0,{label:l.baseUrl??"Base URL",hint:l.baseUrlHint,children:(0,r.jsx)(M.pd,{value:o.baseUrl,onChange:e=>t(t=>t?{...t,embedding:{...o,baseUrl:e.target.value}}:t),placeholder:"https://api.siliconflow.cn/v1"})}),(0,r.jsx)(M.D0,{label:l.apiKey??"API Key",hint:o.baseUrl?.includes("localhost")||o.baseUrl?.includes("127.0.0.1")?l.apiKeyHintLocal??("zh"===n?"本地服务可留空":"Leave empty for local services"):l.apiKeyHint??("zh"===n?"在服务商网站获取 API Key":"Get your API key from the provider"),children:(0,r.jsx)(M.yA,{value:o.apiKey,onChange:e=>t(t=>t?{...t,embedding:{...o,apiKey:e}}:t),placeholder:"sk-..."})}),(0,r.jsx)(M.D0,{label:l.model??"Model",hint:l.modelName,children:(0,r.jsx)(M.pd,{value:o.model,onChange:e=>t(t=>t?{...t,embedding:{...o,model:e.target.value}}:t),placeholder:"BAAI/bge-m3"})})]}),(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pt-1",children:i.building?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{size:12,className:"animate-spin"}),(0,r.jsx)("span",{children:l.indexBuilding??"Building embedding index..."})]}):i.ready?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{children:"function"==typeof l.indexReady?l.indexReady(i.docCount):`${i.docCount} documents indexed`})]}):(0,r.jsx)("span",{children:l.indexPending??"Index will be built on first search"})})]})]})}let V=[{id:"auto",labelKey:"providerAuto",descKey:"providerAutoDesc"},{id:"exa",labelKey:"providerExa",descKey:"providerExaDesc"},{id:"perplexity",labelKey:"providerPerplexity",descKey:"providerPerplexityDesc"},{id:"gemini",labelKey:"providerGemini",descKey:"providerGeminiDesc"}],W=[{key:"exaApiKey",labelKey:"exaApiKey",placeholder:"exa-..."},{key:"perplexityApiKey",labelKey:"perplexityApiKey",placeholder:"pplx-..."},{key:"geminiApiKey",labelKey:"geminiApiKey",placeholder:"AIza..."}];function q({data:e,setData:t,t:s}){let a=s.settings.webSearch??{},n=e.webSearch??{provider:"auto",exaApiKey:"",perplexityApiKey:"",geminiApiKey:""},l=n.provider||"auto";return(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(A.A,{size:15}),title:a.title??"Web Search",description:a.description??"Configure search providers.",children:[(0,r.jsx)("div",{className:"flex gap-2 flex-wrap",children:V.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{t(t=>t?{...t,webSearch:{...n,provider:e.id}}:t)},className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${l===e.id?"border-[var(--amber)] text-[var(--amber)] bg-[var(--amber)]/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:a[e.labelKey]??e.id},e.id))}),(()=>{let e=V.find(e=>e.id===l);if(!e)return null;let t=a[e.descKey];return t?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t}):null})(),W.map(e=>(0,r.jsx)(M.D0,{label:a[e.labelKey]??e.key,hint:a.apiKeyHint,children:(0,r.jsx)(M.yA,{value:n[e.key]??"",onChange:s=>t(t=>t?{...t,webSearch:{...n,[e.key]:s}}:t),placeholder:e.placeholder})},e.key)),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a.noKeysHint??"Works without API keys via Exa MCP (zero-config)."})]})}function Y(){let{t:e}=(0,y.Y)(),[t,s]=(0,a.useState)("panel");return(0,a.useEffect)(()=>{try{let e=localStorage.getItem("ask-mode");"popup"===e&&s("popup")}catch(e){console.warn("[AiTab] localStorage getItem ask-mode failed:",e)}},[]),(0,r.jsx)(M.L7,{icon:(0,r.jsx)(z.A,{size:15}),title:e.settings.askDisplayMode?.label??"Display Mode",description:e.settings.askDisplayMode?.hint??"Side panel stays docked on the right. Popup opens a floating dialog.",children:(0,r.jsxs)(M.l6,{value:t,onChange:e=>(e=>{s(e);try{localStorage.setItem("ask-mode",e)}catch(e){console.warn("[AiTab] localStorage setItem ask-mode failed:",e)}window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:e}))})(e.target.value),children:[(0,r.jsx)("option",{value:"panel",children:e.settings.askDisplayMode?.panel??"Side Panel"}),(0,r.jsx)("option",{value:"popup",children:e.settings.askDisplayMode?.popup??"Popup"})]})})}var Z=s(51900),X=s(36999),Q=s(97810);let ee=(0,o.A)("type",[["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"}]]),et=(0,o.A)("a-large-small",[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]]),es=(0,o.A)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);var er=s(66088),ea=s(21362);let en=[{value:"lora",label:"Lora",category:"Serif",style:{fontFamily:"Lora, Georgia, serif"}},{value:"ibm-plex-sans",label:"IBM Plex Sans",category:"Sans",style:{fontFamily:"'IBM Plex Sans', sans-serif"}},{value:"inter",label:"Inter",category:"Sans",style:{fontFamily:"var(--font-inter), sans-serif"}},{value:"ibm-plex-mono",label:"IBM Plex Mono",category:"Mono",style:{fontFamily:"'IBM Plex Mono', monospace"}}];function el({icon:e,label:t,children:s}){return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t})]}),s]})}function eo({options:e,value:t,onChange:s}){return(0,r.jsx)("div",{className:"flex gap-2",children:e.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.value),className:`flex items-center gap-1.5 px-3.5 py-2 text-sm font-medium rounded-xl transition-all ${t===e.value?"bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm":"bg-muted/50 text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[e.icon,e.label]},e.value))})}function ei({font:e,setFont:t,fontSize:s,setFontSize:n,contentWidth:l,setContentWidth:o,dark:i,setDark:d,locale:m,setLocale:u,t:x}){let[p,g]=(0,a.useState)(!1),[h,b]=(0,a.useState)(()=>localStorage.getItem("theme")??"system"),[f,v]=(0,a.useState)(()=>localStorage.getItem("locale")??"system"),j=x.settings.appearance;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(c,{size:15}),title:j.preferencesTitle??"Preferences",children:[(0,r.jsx)(el,{icon:(0,r.jsx)(Z.A,{size:14}),label:j.colorTheme,children:(0,r.jsx)(eo,{options:[{value:"system",label:j.system,icon:(0,r.jsx)(z.A,{size:14})},{value:"dark",label:j.dark,icon:(0,r.jsx)(X.A,{size:14})},{value:"light",label:j.light,icon:(0,r.jsx)(Z.A,{size:14})}],value:h,onChange:e=>{b(e),localStorage.setItem("theme",e);let t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches:"dark"===e;d(t),document.documentElement.classList.toggle("dark",t)}})}),(0,r.jsx)(el,{icon:(0,r.jsx)(A.A,{size:14}),label:j.language,children:(0,r.jsx)(eo,{options:[{value:"system",label:j.system,icon:(0,r.jsx)(z.A,{size:14})},{value:"en",label:"EN"},{value:"zh",label:"中文"}],value:f,onChange:e=>{v(e),localStorage.setItem("locale",e);let t="system"===e?navigator.language.startsWith("zh")?"zh":"en":e;u(t),document.cookie=`locale=${t};path=/;max-age=31536000;SameSite=Lax`}})})]}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(Q.A,{size:15}),title:j.readingTitle??"Reading",description:j.readingDesc??"Customize how your notes look",children:[(0,r.jsx)(el,{icon:(0,r.jsx)(ee,{size:14}),label:j.readingFont,children:(0,r.jsx)("div",{className:"space-y-0.5",children:en.map(s=>{let a=e===s.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>t(s.value),className:`flex items-center gap-4 w-full px-3 py-2.5 rounded-lg transition-all text-left relative ${a?"bg-[var(--amber-subtle)]":"hover:bg-muted/50"}`,children:[a&&(0,r.jsx)("div",{className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r-full bg-[var(--amber)]"}),(0,r.jsx)("span",{className:`text-xl font-medium w-10 text-center shrink-0 ${a?"text-foreground":"text-muted-foreground/60"}`,style:{fontFamily:s.style.fontFamily},children:"Aa"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,style:{fontFamily:s.style.fontFamily},children:s.label}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/50",children:s.category})]}),(0,r.jsx)("p",{className:`text-sm truncate mt-0.5 ${a?"text-muted-foreground":"text-muted-foreground/40"}`,style:{fontFamily:s.style.fontFamily},children:j.fontPreview})]})]},s.value)})})}),(0,r.jsx)(el,{icon:(0,r.jsx)(et,{size:14}),label:j.fontSize,children:(0,r.jsxs)("div",{className:"px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",style:{fontSize:"11px"},children:"A"}),(0,r.jsx)("input",{type:"range",min:12,max:22,step:1,value:parseInt(s),onChange:e=>n(`${e.target.value}px`),className:"flex-1 h-1.5 rounded-full appearance-none bg-muted cursor-pointer accent-[var(--amber)] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--amber)] [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-110 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--amber)] [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:cursor-pointer"}),(0,r.jsx)("span",{className:"text-base text-muted-foreground/60 shrink-0",children:"A"})]}),(0,r.jsx)("div",{className:"text-center mt-1.5",children:(0,r.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[parseInt(s),"px"]})}),(0,r.jsx)("p",{className:"text-muted-foreground leading-relaxed mt-2 px-1",style:{fontSize:s,fontFamily:en.find(t=>t.value===e)?.style.fontFamily},children:j.fontSizePreview})]})}),(0,r.jsx)(el,{icon:(0,r.jsx)(es,{size:14}),label:j.contentWidth,children:(0,r.jsxs)("div",{className:"px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"▬"}),(0,r.jsx)("input",{type:"range",min:50,max:100,step:5,value:parseInt(l)||80,onChange:e=>o(`${e.target.value}%`),className:"flex-1 h-1.5 rounded-full appearance-none bg-muted cursor-pointer accent-[var(--amber)] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--amber)] [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-110 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--amber)] [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:cursor-pointer"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"▬▬▬"})]}),(0,r.jsx)("div",{className:"text-center mt-1.5",children:(0,r.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[parseInt(l)||80,"%"]})})]})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground/40 px-0.5",children:j.browserNote}),(0,r.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(!p),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:[p?(0,r.jsx)(er.A,{size:14}):(0,r.jsx)(ea.A,{size:14}),x.settings.tabs.shortcuts]}),p&&(0,r.jsx)("div",{className:"mt-3 space-y-0.5",children:x.shortcuts.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between py-1.5 px-1",children:[(0,r.jsx)("span",{className:"text-sm text-foreground",children:e.description}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:e.keys.map((e,t)=>(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs font-mono bg-muted border border-border rounded text-muted-foreground",children:e},t))})]},t))})]})]})}let ed=(0,o.A)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),ec=(0,o.A)("hard-drive",[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]);var em=s(67635);let eu=(0,o.A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);var ex=s(65576),ep=s(39498),eg=s(7834);function eh(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<0x40000000?`${(e/1048576).toFixed(1)} MB`:`${(e/0x40000000).toFixed(2)} GB`}var eb=s(89504),ef=s(9339);let ev=(0,ef.createServerReference)("000d8b5a896219b55ea96c84b4bbdc143cf08395ad",ef.callServer,void 0,ef.findSourceMapURL,"scanExampleFilesAction"),ej=(0,ef.createServerReference)("004c109f9398f52c5114dd350bffa0af8debe5ba76",ef.callServer,void 0,ef.findSourceMapURL,"cleanupExamplesAction");var ey=s(41585);let eN={checking:!1,available:null,isSelf:!1,suggestion:null};function ek({message:e,sub:t}){return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center space-y-4 max-w-sm px-6",children:[(0,r.jsx)(g.A,{size:32,className:"animate-spin mx-auto text-[var(--amber)]"}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:e}),t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t})]})})}function ew({m:e}){let[t,s]=(0,a.useState)(0),[n,l]=(0,a.useState)(0),[o,i]=(0,a.useState)(eN),[d,c]=(0,a.useState)(!1),[m,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(void 0),h=(0,a.useRef)(void 0),f=(0,a.useRef)(void 0);(0,a.useEffect)(()=>{(0,N.n)("/api/settings").then(e=>{let t=e.port||3456;s(t),l(t)}).catch(()=>{})},[]),(0,a.useEffect)(()=>()=>{clearInterval(h.current),clearTimeout(f.current)},[]);let v=n!==t,j=n<1024||n>65535,y=o.checking||!1===o.available&&!o.isSelf,k=(0,a.useCallback)(async e=>{if(e<1024||e>65535)return void i({...eN,available:!1,invalid:!0});i({...eN,checking:!0});try{let t=await (0,N.n)("/api/setup/check-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:e})});i({checking:!1,available:t.available,isSelf:t.isSelf??!1,suggestion:t.suggestion??null})}catch{i(eN)}},[]),w=async()=>{if(v&&!j&&!y&&!d){c(!0);try{let t=await (0,N.n)("/api/setup/check-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:n})});if(!t.available&&!t.isSelf){i({checking:!1,available:!1,isSelf:!1,suggestion:t.suggestion??null}),c(!1),T.oR.error(e.portInUse(n));return}await (0,N.n)("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:n})}),u(e.portWebRestarting),p(e.portRedirecting);try{await (0,N.n)("/api/restart",{method:"POST"})}catch{}let s=`${window.location.protocol}//${window.location.hostname}:${n}`,r=Date.now()+3e4;h.current=setInterval(async()=>{if(Date.now()>r){clearInterval(h.current),u(null),c(!1),T.oR.error(e.portRestartTimeout);return}try{(await fetch(`${s}/api/health`,{signal:AbortSignal.timeout(2e3)})).ok&&(clearInterval(h.current),window.location.href=s)}catch{}},1500)}catch{c(!1),T.oR.error(e.portUpdateFailed)}}};return 0===t?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M.L7,{icon:(0,r.jsx)(z.A,{size:15}),title:e.webPortLabel,description:e.webPortHint,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"number",min:1024,max:65535,value:n,onChange:e=>{let t=parseInt(e.target.value,10)||n;l(t),i(eN),clearTimeout(f.current),t>=1024&&t<=65535&&(f.current=setTimeout(()=>k(t),500))},onBlur:()=>{clearTimeout(f.current),n>=1024&&n<=65535&&k(n)},className:"flex-1 px-2.5 py-1.5 text-sm rounded-lg border border-border bg-muted/30 text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring tabular-nums"}),(0,r.jsx)("button",{type:"button",onClick:w,disabled:!v||j||y||d,className:"shrink-0 px-4 py-1.5 rounded-lg text-xs font-medium transition-colors bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:d?e.portUpdating:e.portUpdateBtn})]}),o.checking&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-muted-foreground",children:[(0,r.jsx)(g.A,{size:11,className:"animate-spin"})," ",e.portChecking]}),!o.checking&&!1===o.available&&!o.invalid&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-[var(--amber)]",children:[(0,r.jsx)(ey.A,{size:11})," ",e.portInUse(n)]}),null!==o.suggestion&&(0,r.jsx)("button",{type:"button",onClick:()=>{l(o.suggestion),i(eN),setTimeout(()=>k(o.suggestion),0)},className:"text-xs px-2 py-0.5 rounded border border-[var(--amber)] text-[var(--amber)] transition-colors hover:bg-[var(--amber-subtle)]",children:e.portSuggest(o.suggestion)})]}),!o.checking&&o.invalid&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-destructive",children:[(0,r.jsx)(ey.A,{size:11})," 1024 – 65535"]}),!o.checking&&!0===o.available&&(0,r.jsxs)("p",{className:"text-xs flex items-center gap-1 text-success",children:[(0,r.jsx)(b.A,{size:11})," ",o.isSelf?e.portSelf:e.portAvailable]})]})}),m&&(0,r.jsx)(ek,{message:m,sub:x})]})}function eS({data:e,setData:t,t:s}){let l=e.envOverrides??{},o=s.settings.knowledge,i=s.settings.appearance,[d,c]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-echo")),[u,p]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-workflows")),[b,f]=(0,a.useState)(()=>"true"===localStorage.getItem("show-hidden-files")),[v,j]=(0,a.useState)(null),[y,k]=(0,a.useState)(!1),[w,S]=(0,a.useState)(null);(0,a.useEffect)(()=>{ev().then(e=>j(e.files.length)).catch(e=>{console.warn("[KnowledgeTab] scanExampleFilesAction failed:",e)})},[]);let[A,z]=(0,a.useState)(null),[E,R]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(0,N.n)("/api/setup").then(e=>{let t=e.guideState;t&&(z(t.active),R(!!t.dismissed))}).catch(e=>{console.error("Failed to fetch guide state:",e)})},[]);let P=(0,a.useCallback)(()=>{let e=!E;R(e);let t={dismissed:e};e||(t.active=!0),(0,N.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:t})}).then(()=>window.dispatchEvent(new Event("guide-state-updated"))).catch(t=>{console.error("Failed to update guide state:",t),R(!e)})},[E]),I=(0,a.useCallback)(()=>{(0,N.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{active:!0,dismissed:!1,walkthroughStep:0,walkthroughDismissed:!1}})}).then(()=>{z(!0),R(!1),window.dispatchEvent(new Event("guide-state-updated"))}).catch(e=>console.error("Failed to restart walkthrough:",e))},[]),U=(0,a.useSyncExternalStore)(()=>()=>{},()=>`${window.location.protocol}//${window.location.hostname}`,()=>"http://localhost"),[D,$]=(0,a.useState)(!1),[F,L]=(0,a.useState)(null),[O,K]=(0,a.useState)(!1),[B,_]=(0,a.useState)(!1),H=!!e.authToken,G=F??e.authToken??"";async function J(){$(!0);try{let e=await (0,N.n)("/api/settings/reset-token",{method:"POST"});L(e.token),t(t=>t?{...t,authToken:e.token}:t)}finally{$(!1)}}async function V(){t(e=>e?{...e,authToken:""}:e),L(null)}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(ed,{size:15}),title:o.cardTitle??"Knowledge Base",description:o.mindRootHint,children:[(0,r.jsx)(M.D0,{label:(0,r.jsxs)(r.Fragment,{children:[o.mindRoot," ",(0,r.jsx)(M.Bt,{overridden:l.MIND_ROOT})]}),hint:l.MIND_ROOT?o.envNote:o.mindRootHint,children:(0,r.jsx)(M.pd,{value:e.mindRoot,onChange:e=>t(t=>t?{...t,mindRoot:e.target.value}:t),placeholder:"/path/to/your/notes"})}),(0,r.jsx)(M.pM,{label:o.showHiddenFiles,hint:o.showHiddenFilesHint,children:(0,r.jsx)(M.lM,{checked:b,onChange:()=>{let e=!b;f(e),(0,eb.Fo)(e)}})}),null!==v&&v>0&&null===w&&(0,r.jsx)(M.pM,{label:o.cleanupExamples,hint:o.cleanupExamplesHint,children:(0,r.jsxs)("button",{onClick:()=>_(!0),disabled:y,title:y?s.hints.cleanupInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0 disabled:opacity-50",children:[y?(0,r.jsx)(g.A,{size:12,className:"animate-spin"}):(0,r.jsx)(x.A,{size:12}),o.cleanupExamplesButton,(0,r.jsx)("span",{className:"ml-1 tabular-nums text-2xs opacity-70",children:v})]})}),null!==w&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(C.A,{size:14}),o.cleanupExamplesDone(w)]})]}),(0,r.jsx)(ew,{m:s.settings?.mcp??{}}),(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(ec,{size:15}),title:o.securityTitle??"Security",children:[(0,r.jsx)(M.D0,{label:o.webPassword,hint:o.webPasswordHint,children:(0,r.jsx)(M.yA,{value:e.webPassword??"",onChange:e=>t(t=>t?{...t,webPassword:e}:t),placeholder:o.passwordPlaceholder??"Leave empty to disable"})}),(0,r.jsx)(M.D0,{label:o.authToken,hint:H?o.authTokenHint:o.authTokenNone,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-background border border-border rounded-lg min-h-[38px]",children:[(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground break-all select-all",children:G||(0,r.jsx)("span",{className:"text-muted-foreground italic",children:o.tokenNotSet??"— not set —"})}),G&&(0,r.jsx)("button",{type:"button",onClick:function(){let t=F??e.authToken??"";t&&(0,eg.l)(t).then(e=>{e&&T.oR.copy()})},className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground transition-colors",title:o.authTokenCopy,children:(0,r.jsx)(em.A,{size:13})})]}),e.mcpPort&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.authTokenMcpPort,": ",(0,r.jsx)("code",{className:"font-mono",children:e.mcpPort}),G&&(0,r.jsxs)(r.Fragment,{children:[" \xa0\xb7\xa0 ",o.mcpUrl??"MCP URL",": ",(0,r.jsx)("code",{className:"font-mono select-all",children:`${U}:${e.mcpPort}/mcp`})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:function(){K(!0)},disabled:D,title:D?s.hints.tokenResetInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(m.A,{size:14,className:D?"animate-spin":""}),o.authTokenReset]}),H&&(0,r.jsxs)("button",{type:"button",onClick:V,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors",children:[(0,r.jsx)(x.A,{size:14}),o.authTokenClear]})]}),F&&(0,r.jsx)("p",{className:"text-xs text-[var(--amber-text)]",children:o.tokenGenerated})]})})]}),null!==A&&(0,r.jsxs)(M.L7,{icon:(0,r.jsx)(n.A,{size:15}),title:s.guide?.title??"Getting Started",children:[(0,r.jsx)(M.pM,{label:s.guide?.showGuide??"Show getting started guide",children:(0,r.jsx)(M.lM,{checked:!E,onChange:()=>P()})}),(0,r.jsxs)("button",{onClick:I,className:"flex items-center gap-1.5 mt-2 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(h.A,{size:14}),o.restartWalkthrough??"Restart walkthrough"]})]}),(0,r.jsx)(M.L7,{icon:(0,r.jsx)(eu,{size:15}),title:i.labsTitle??"Labs",description:i.labsDesc??"Experimental features that are still in development.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(eC,{label:i.labsEcho??"Echo",description:i.labsEchoDesc??"Reflective journaling powered by your notes.",checked:d,onChange:e=>{c(e),localStorage.setItem("mindos:labs-echo",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}}),(0,r.jsx)(eC,{label:i.labsWorkflows??"Flows",description:i.labsWorkflowsDesc??"Visual workflow automation for agents.",checked:u,onChange:e=>{p(e),localStorage.setItem("mindos:labs-workflows",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}})]})}),(0,r.jsx)(eA,{k:o}),(0,r.jsx)(ep.TM,{open:O,title:o.authTokenReset??"Regenerate Token",message:o.authTokenResetConfirm,confirmLabel:o.authTokenReset??"Regenerate",cancelLabel:o.cancel??"Cancel",onConfirm:()=>{K(!1),J()},onCancel:()=>K(!1)}),(0,r.jsx)(ep.TM,{open:B,title:o.cleanupExamples??"Cleanup Examples",message:null!==v?o.cleanupExamplesConfirm(v):"",confirmLabel:o.cleanupExamplesButton??"Clean up",cancelLabel:o.cancel??"Cancel",variant:"destructive",onConfirm:async()=>{_(!1),k(!0);let e=await ej();k(!1),e.success&&(S(e.deleted),j(0))},onCancel:()=>_(!1)})]})}function eC({label:e,description:t,checked:s,onChange:a}){return(0,r.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground block",children:e}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>a(!s),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${s?"bg-[var(--amber)]":"bg-muted-foreground/20"}`,children:(0,r.jsx)("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${s?"translate-x-4":"translate-x-0"}`})})]})}function eA({k:e}){let[t,s]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null),[o,i]=(0,a.useState)(!1),d=(0,a.useCallback)(async()=>{i(!0);try{let e=await (0,N.n)("/api/monitoring",{timeout:5e3});l(e)}catch{}i(!1)},[]),c=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!t){c.current=!1;return}c.current||(d(),c.current=!0);let e=setInterval(d,1e4);return()=>clearInterval(e)},[t,d]),(0,r.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,r.jsxs)("button",{onClick:()=>s(e=>!e),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[t?(0,r.jsx)(er.A,{size:14}):(0,r.jsx)(ea.A,{size:14}),(0,r.jsx)(ex.A,{size:12}),e.monitoringTitle??"System Monitoring",o&&(0,r.jsx)(g.A,{size:10,className:"animate-spin ml-1"})]}),t&&n&&(0,r.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-x-6 gap-y-2 text-xs",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorHeap??"Heap"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[eh(n.system.memory.heapUsed)," / ",eh(n.system.memory.heapTotal)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRss??"RSS"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:eh(n.system.memory.rss)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorUptime??"Uptime"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:function(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60);if(s<60)return`${s}m ${t%60}s`;let r=Math.floor(s/60);if(r<24)return`${r}h ${s%60}m`;let a=Math.floor(r/24);return`${a}d ${r%24}h`}(n.system.uptimeMs)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorNode??"Node"}),(0,r.jsx)("span",{className:"ml-2",children:n.system.nodeVersion})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRequests??"Requests"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.agentRequests})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorToolCalls??"Tool Calls"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.toolExecutions})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorTokens??"Tokens"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:(n.application.totalTokens.input+n.application.totalTokens.output).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorFiles??"Files"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[n.knowledgeBase.fileCount," (",eh(n.knowledgeBase.totalSizeBytes),")"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"MCP"}),(0,r.jsx)("span",{className:"ml-2",children:n.mcp.running?e.monitorMcpRunning?.(n.mcp.port)??`Running :${n.mcp.port}`:e.monitorMcpStopped??"Stopped"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorErrors??"Errors"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.errors})]})]}),t&&!n&&!o&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.monitoringFailed??"Failed to load monitoring data"})]})}var ez=s(402),eT=s(10762),eM=s(439),eE=s(15411),eR=s(7915),eP=s(70617),eI=s(51914),eU=s(42129),eD=s(49387);let e$=(0,s(37206).default)(()=>Promise.all([s.e(7011),s.e(3399)]).then(s.bind(s,83399)),{loadableGenerated:{webpack:()=>[83399]},ssr:!1});function eF({skill:e,expanded:t,onExpand:s,onToggle:a,onDelete:n,onEditStart:l,onEditSave:o,onEditCancel:i,editing:d,editContent:c,setEditContent:m,editError:u,saving:h,fullContent:b,loadingContent:f,loadErrors:v,m:j}){return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>s(e.name),children:[t?(0,r.jsx)(er.A,{size:12}):(0,r.jsx)(ea.A,{size:12}),(0,r.jsx)("span",{className:"text-xs font-medium flex-1",children:e.name}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded ${"builtin"===e.source?"bg-muted text-muted-foreground":"bg-[var(--amber-subtle)] text-[var(--amber-text)]"}`,children:"builtin"===e.source?j?.skillBuiltin??"Built-in":j?.skillUser??"Custom"}),(0,r.jsx)(M.lM,{size:"sm",checked:e.enabled,onClick:t=>{t.stopPropagation(),a(e.name,!e.enabled)}})]}),t&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border text-xs space-y-2 bg-muted/20",children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:e.description||"No description"}),(0,r.jsx)("p",{className:"text-muted-foreground font-mono text-2xs",children:e.path}),f===e.name?(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(g.A,{size:10,className:"animate-spin"}),(0,r.jsx)("span",{className:"text-2xs",children:"Loading..."})]}):b[e.name]?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-2xs text-muted-foreground font-medium",children:j?.skillContent??"Content"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.editable&&d!==e.name&&(0,r.jsxs)("button",{onClick:()=>l(e.name),className:"flex items-center gap-1 text-2xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(eD.A,{size:10}),j?.editSkill??"Edit"]}),e.editable&&(0,r.jsxs)("button",{onClick:()=>n(e.name),className:"flex items-center gap-1 text-2xs text-destructive hover:underline",children:[(0,r.jsx)(x.A,{size:10}),j?.deleteSkill??"Delete"]})]})]}),d===e.name?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("textarea",{value:c,onChange:e=>m(e.target.value),rows:Math.min(20,(c.match(/\n/g)||[]).length+3),className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y font-mono"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>o(e.name),disabled:h,className:"flex items-center gap-1 px-2.5 py-1 text-xs rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-[var(--amber)] text-[var(--amber-foreground)]",children:[h&&(0,r.jsx)(g.A,{size:10,className:"animate-spin"}),j?.saveSkill??"Save"]}),(0,r.jsx)("button",{onClick:i,className:"px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground transition-colors",children:j?.cancelSkill??"Cancel"})]}),u&&(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(p.A,{size:10}),u]})]}):(0,r.jsx)("div",{className:"w-full rounded-md border border-border bg-background/50 max-h-[300px] overflow-y-auto px-2.5 py-1.5 text-xs [&_.prose]:max-w-none [&_.prose]:text-xs [&_h1]:text-sm [&_h2]:text-xs [&_h3]:text-xs [&_pre]:text-2xs [&_code]:text-2xs",children:(0,r.jsx)(e$,{content:function(e){if(!e.startsWith("---"))return e;let t=e.indexOf("\n---",3);return -1===t?e:e.slice(t+4).replace(/^\n+/,"")}(b[e.name])})})]}):v[e.name]?(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(p.A,{size:10}),v[e.name]]}):null]})]})}let eL=e=>`---
2
2
  name: ${e}
3
3
  description: >
4
4
  Describe WHEN the agent should use this
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[576],{70576:(e,s,t)=>{t.r(s),t.d(s,{default:()=>h});var a=t(95155),r=t(12115),n=t(47650),i=t(33210),l=t(86901),o=t(41585),c=t(38798),d=t(6296),u=t(73321),m=t(91337),x=t(9339);let p=(0,x.createServerReference)("70ca3bb479db3eb8e727cb8bb2a175833dbd13e573",x.callServer,void 0,x.findSourceMapURL,"createSpaceAction");var b=t(5292),f=t(70620);function h({t:e,dirPaths:s}){let t=(0,u.useRouter)(),[x,h]=(0,r.useState)(!1),[g,v]=(0,r.useState)(""),[N,j]=(0,r.useState)(""),[w,y]=(0,r.useState)(""),[k,S]=(0,r.useState)(!1),[C,A]=(0,r.useState)(""),[E,I]=(0,r.useState)(""),[L,z]=(0,r.useState)(null),[R,D]=(0,r.useState)(!0),K=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=()=>{h(!0),A(""),I(""),setTimeout(()=>K.current?.focus(),80)};return window.addEventListener("mindos:create-space",e),()=>window.removeEventListener("mindos:create-space",e)},[]),(0,r.useEffect)(()=>{x&&null===L&&(0,b.w)().then(e=>{z(e),D(e)})},[x,L]);let M=(0,r.useCallback)(()=>{h(!1),v(""),j(""),y(""),A(""),I(""),z(null)},[]),P=(0,r.useCallback)(s=>s.includes("/")||s.includes("\\")?(I(e.home.spaceNameNoSlash??"Name cannot contain / or \\"),!1):(I(""),!0),[e]),T=(0,r.useMemo)(()=>{let e=g.trim();return e?(w?w+"/":"")+e+"/":""},[g,w]),$=(0,r.useCallback)(async()=>{if(!g.trim()||k||!P(g))return;S(!0),A("");let s=g.trim(),a=await p(s,N,w);if(a.success){let e=a.path??s;R&&L&&(0,b.V)(s,e,N),M(),t.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),t.push(`/view/${(0,m.O0)(e+"/")}`)}else(a.error??"").includes("already exists")?A(e.home.spaceExists??"A space with this name already exists"):A(e.home.spaceCreateFailed??"Failed to create space");S(!1)},[g,N,w,k,M,t,e,P,R,L]),_=(0,r.useCallback)(e=>{"Escape"===e.key&&M(),"Enter"===e.key&&!e.shiftKey&&e.target instanceof HTMLInputElement&&(e.preventDefault(),$())},[M,$]);if(!x)return null;let F=e.home;return(0,n.createPortal)((0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onKeyDown:_,children:[(0,a.jsx)("div",{className:"absolute inset-0 overlay-backdrop",onClick:M}),(0,a.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":F.newSpace,className:"relative w-full max-w-md mx-4 rounded-2xl border border-border bg-card shadow-xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-foreground",children:F.newSpace}),(0,a.jsx)("button",{onClick:M,className:"p-1 rounded-md text-muted-foreground hover:bg-muted transition-colors",children:(0,a.jsx)(i.A,{size:14})})]}),(0,a.jsxs)("div",{className:"px-5 pb-5 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:F.spaceLocation??"Location"}),(0,a.jsx)(f.A,{dirPaths:s,value:w,onChange:y,rootLabel:F.rootLevel??"Root"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:F.spaceName}),(0,a.jsx)("input",{ref:K,type:"text",value:g,onChange:e=>{v(e.target.value),A(""),P(e.target.value)},placeholder:"e.g. \uD83D\uDCDD Notes",maxLength:80,"aria-invalid":!!E,"aria-describedby":E?"space-name-hint":void 0,className:`w-full px-3 py-2 text-sm rounded-lg border bg-background outline-none transition-colors ${E?"border-error focus-visible:border-error":"border-border focus-visible:ring-1 focus-visible:ring-ring"}`}),E&&(0,a.jsx)("span",{id:"space-name-hint",className:"text-xs text-error",children:E})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("label",{className:"text-xs font-medium text-muted-foreground",children:[F.spaceDescription," ",(0,a.jsxs)("span",{className:"opacity-50",children:["(",F.optional??"optional",")"]})]}),(0,a.jsx)("input",{type:"text",value:N,onChange:e=>j(e.target.value),placeholder:F.spaceDescPlaceholder??"Describe the purpose of this space",maxLength:200,className:"w-full px-3 py-2 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring transition-colors"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2.5 px-1 py-1",children:[(0,a.jsx)("button",{type:"button",role:"switch","aria-checked":R,disabled:!L,title:L?void 0:e.hints.configureAiKey,onClick:()=>D(e=>!e),className:`relative mt-0.5 inline-flex shrink-0 h-4 w-7 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${R?"bg-[var(--amber)]":"bg-muted"}`,children:(0,a.jsx)("span",{className:`pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${R?"translate-x-3":"translate-x-0"}`})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(l.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:F.aiInit??"AI initialize content"})]}),!1===L&&(0,a.jsxs)("p",{className:"text-2xs text-muted-foreground mt-0.5 flex items-center gap-1",children:[(0,a.jsx)(o.A,{size:10,className:"text-[var(--amber)] shrink-0"}),F.aiInitNoKey??"Configure an API key in Settings → AI to enable"]}),L&&R&&(0,a.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:F.aiInitHint??"AI will generate README and INSTRUCTION for this space"})]})]}),T&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono px-1",children:[(0,a.jsx)(c.A,{size:12,className:"shrink-0 text-[var(--amber)]"}),(0,a.jsx)("span",{className:"truncate",children:T})]}),C&&(0,a.jsx)("span",{role:"alert",className:"text-xs text-error px-1",children:C}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,a.jsx)("button",{onClick:M,className:"px-4 py-2 rounded-lg text-sm font-medium text-muted-foreground transition-colors hover:bg-muted",children:F.cancelCreate}),(0,a.jsxs)("button",{onClick:$,disabled:!g.trim()||k||!!E,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium bg-[var(--amber)] text-[var(--amber-foreground)] transition-colors hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed",children:[k&&(0,a.jsx)(d.A,{size:14,className:"animate-spin"}),F.createSpace]})]})]})]})]}),document.body)}}}]);