cartethyia 2.5.1 → 2.5.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 (208) hide show
  1. package/.env.example +5 -1
  2. package/dist/dashboard/assets/{AccountCooldown-ChpdzxRH.js → AccountCooldown-Bjo92Qat.js} +1 -1
  3. package/dist/dashboard/assets/AccountCooldown-Bjo92Qat.js.gz +0 -0
  4. package/dist/dashboard/assets/{BannedPage-ChqnTRpZ.js → BannedPage-MsQaeQTs.js} +1 -1
  5. package/dist/dashboard/assets/BannedPage-MsQaeQTs.js.gz +0 -0
  6. package/dist/dashboard/assets/CliToolDetailPage-BO9nKg9w.js +1 -0
  7. package/dist/dashboard/assets/CliToolDetailPage-BO9nKg9w.js.gz +0 -0
  8. package/dist/dashboard/assets/{CliToolsPage-BXUaRCQQ.js → CliToolsPage-DfWHTJ7v.js} +1 -1
  9. package/dist/dashboard/assets/CliToolsPage-DfWHTJ7v.js.gz +0 -0
  10. package/dist/dashboard/assets/CombosPage-BrCBQDAc.js +1 -0
  11. package/dist/dashboard/assets/CombosPage-BrCBQDAc.js.gz +0 -0
  12. package/dist/dashboard/assets/ConsoleLogPage-C6Uh33er.js +1 -0
  13. package/dist/dashboard/assets/ConsoleLogPage-C6Uh33er.js.gz +0 -0
  14. package/dist/dashboard/assets/CustomizationPage-8aS9hyJu.js +1 -0
  15. package/dist/dashboard/assets/CustomizationPage-8aS9hyJu.js.gz +0 -0
  16. package/dist/dashboard/assets/HealthEventsModal-qomXThxX.js +1 -0
  17. package/dist/dashboard/assets/HealthEventsModal-qomXThxX.js.gz +0 -0
  18. package/dist/dashboard/assets/LoginPage-C8hKyXBe.js +1 -0
  19. package/dist/dashboard/assets/LoginPage-C8hKyXBe.js.gz +0 -0
  20. package/dist/dashboard/assets/ModelPicker-CWkTUtpX.js +1 -0
  21. package/dist/dashboard/assets/ModelPicker-CWkTUtpX.js.gz +0 -0
  22. package/dist/dashboard/assets/OverviewPage-C-ExCy1V.js +1 -0
  23. package/dist/dashboard/assets/OverviewPage-C-ExCy1V.js.gz +0 -0
  24. package/dist/dashboard/assets/ProviderDetailPage-tr811uaF.js +3 -0
  25. package/dist/dashboard/assets/ProviderDetailPage-tr811uaF.js.gz +0 -0
  26. package/dist/dashboard/assets/ProvidersPage-BS9IEpvv.js +1 -0
  27. package/dist/dashboard/assets/ProvidersPage-BS9IEpvv.js.gz +0 -0
  28. package/dist/dashboard/assets/ProxyPage-Rn_qXScb.js +7 -0
  29. package/dist/dashboard/assets/ProxyPage-Rn_qXScb.js.gz +0 -0
  30. package/dist/dashboard/assets/QuotaPage-BihkgQSq.js +1 -0
  31. package/dist/dashboard/assets/QuotaPage-BihkgQSq.js.gz +0 -0
  32. package/dist/dashboard/assets/SettingsPage-DhiEjm6T.js +1 -0
  33. package/dist/dashboard/assets/SettingsPage-DhiEjm6T.js.gz +0 -0
  34. package/dist/dashboard/assets/SetupPage-CXjUlfqr.js +1 -0
  35. package/dist/dashboard/assets/SetupPage-CXjUlfqr.js.gz +0 -0
  36. package/dist/dashboard/assets/SortableList-C-_oD3F2.js +1 -0
  37. package/dist/dashboard/assets/SortableList-C-_oD3F2.js.gz +0 -0
  38. package/dist/dashboard/assets/{StudioPage-DqK5E26W.js → StudioPage-u9IxmYOI.js} +3 -3
  39. package/dist/dashboard/assets/StudioPage-u9IxmYOI.js.gz +0 -0
  40. package/dist/dashboard/assets/UsagePage-BEVLVrwP.js +56 -0
  41. package/dist/dashboard/assets/UsagePage-BEVLVrwP.js.gz +0 -0
  42. package/dist/dashboard/assets/{api-keys-BmDbsior.js → api-keys-uNywYlfv.js} +1 -1
  43. package/dist/dashboard/assets/api-keys-uNywYlfv.js.gz +0 -0
  44. package/dist/dashboard/assets/{app-C-Y4oZT0.js → app-CafWtVXA.js} +1 -1
  45. package/dist/dashboard/assets/{app-C-Y4oZT0.js.gz → app-CafWtVXA.js.gz} +0 -0
  46. package/dist/dashboard/assets/app-DxivpfYG.css +2 -0
  47. package/dist/dashboard/assets/app-DxivpfYG.css.gz +0 -0
  48. package/dist/dashboard/assets/{assert-BHfaei-X.js → assert-NHwYq95t.js} +1 -1
  49. package/dist/dashboard/assets/{assert-BHfaei-X.js.gz → assert-NHwYq95t.js.gz} +0 -0
  50. package/dist/dashboard/assets/badge-6uzDDvqs.js +1 -0
  51. package/dist/dashboard/assets/badge-6uzDDvqs.js.gz +0 -0
  52. package/dist/dashboard/assets/banner-4_WNg2WZ.js +1 -0
  53. package/dist/dashboard/assets/banner-4_WNg2WZ.js.gz +0 -0
  54. package/dist/dashboard/assets/card--AtFedAq.js +1 -0
  55. package/dist/dashboard/assets/card--AtFedAq.js.gz +0 -0
  56. package/dist/dashboard/assets/{cli-tools-B0wBq-RL.js → cli-tools-B3e7dx3N.js} +1 -1
  57. package/dist/dashboard/assets/cli-tools-B3e7dx3N.js.gz +0 -0
  58. package/dist/dashboard/assets/clipboard-button-NreUx6c8.js +1 -0
  59. package/dist/dashboard/assets/clipboard-button-NreUx6c8.js.gz +0 -0
  60. package/dist/dashboard/assets/dialog-BtpsJU98.js +1 -0
  61. package/dist/dashboard/assets/dialog-BtpsJU98.js.gz +0 -0
  62. package/dist/dashboard/assets/drawer-WwwtzihF.js +1 -0
  63. package/dist/dashboard/assets/drawer-WwwtzihF.js.gz +0 -0
  64. package/dist/dashboard/assets/entry-Dj9AR0gY.js +4 -0
  65. package/dist/dashboard/assets/entry-Dj9AR0gY.js.gz +0 -0
  66. package/dist/dashboard/assets/entry-TJIye_jT.js +1 -0
  67. package/dist/dashboard/assets/entry-TJIye_jT.js.gz +0 -0
  68. package/dist/dashboard/assets/{entry-D4O2229X.js → entry-jy9_4-Ke.js} +1 -1
  69. package/dist/dashboard/assets/entry-jy9_4-Ke.js.gz +0 -0
  70. package/dist/dashboard/assets/github-badge-D_eM3IgG.js +1 -0
  71. package/dist/dashboard/assets/github-badge-D_eM3IgG.js.gz +0 -0
  72. package/dist/dashboard/assets/{index-CcD1eSJ6.js → index-DCBtROoK.js} +2 -2
  73. package/dist/dashboard/assets/index-DCBtROoK.js.gz +0 -0
  74. package/dist/dashboard/assets/inline-BcNGF8Gr.js +1 -0
  75. package/dist/dashboard/assets/inline-BcNGF8Gr.js.gz +0 -0
  76. package/dist/dashboard/assets/input-BG41et9G.js +1 -0
  77. package/dist/dashboard/assets/input-BG41et9G.js.gz +0 -0
  78. package/dist/dashboard/assets/layout-C8mer_Ak.js +1 -0
  79. package/dist/dashboard/assets/layout-C8mer_Ak.js.gz +0 -0
  80. package/dist/dashboard/assets/list-row-Gh_W4OR_.js +1 -0
  81. package/dist/dashboard/assets/list-row-Gh_W4OR_.js.gz +0 -0
  82. package/dist/dashboard/assets/{live-yfEJFF9T.js → live-BJGYRBnR.js} +1 -1
  83. package/dist/dashboard/assets/live-BJGYRBnR.js.gz +0 -0
  84. package/dist/dashboard/assets/{model-bans-CT-TxSNX.js → model-bans-DeVLDA7I.js} +1 -1
  85. package/dist/dashboard/assets/model-bans-DeVLDA7I.js.gz +0 -0
  86. package/dist/dashboard/assets/numbers-Bs4LOOuf.js +2 -0
  87. package/dist/dashboard/assets/numbers-Bs4LOOuf.js.gz +0 -0
  88. package/dist/dashboard/assets/{routing-Cs6jl49L.js → routing-CcusqXA7.js} +1 -1
  89. package/dist/dashboard/assets/routing-CcusqXA7.js.gz +0 -0
  90. package/dist/dashboard/assets/select-DsX5QT8K.js +41 -0
  91. package/dist/dashboard/assets/select-DsX5QT8K.js.gz +0 -0
  92. package/dist/dashboard/assets/{settings-CfcTcOyU.js → settings-mpmXTgUa.js} +1 -1
  93. package/dist/dashboard/assets/settings-mpmXTgUa.js.gz +0 -0
  94. package/dist/dashboard/assets/stack-DwLmjUFK.js +1 -0
  95. package/dist/dashboard/assets/stack-DwLmjUFK.js.gz +0 -0
  96. package/dist/dashboard/assets/state-DYdQmdAl.js +1 -0
  97. package/dist/dashboard/assets/state-DYdQmdAl.js.gz +0 -0
  98. package/dist/dashboard/assets/switch-CidSfbG7.js +1 -0
  99. package/dist/dashboard/assets/switch-CidSfbG7.js.gz +0 -0
  100. package/dist/dashboard/assets/{useMutation-BQKMcJ1H.js → useMutation-w4u4CVue.js} +1 -1
  101. package/dist/dashboard/assets/useMutation-w4u4CVue.js.gz +0 -0
  102. package/dist/dashboard/index.html +1 -1
  103. package/dist/dashboard/index.html.gz +0 -0
  104. package/dist/dashboard/precompressed-assets.json +51 -54
  105. package/package.json +1 -1
  106. package/src/boot/app.ts +3 -2
  107. package/src/console/observability/contracts.ts +11 -1
  108. package/src/console/observability/store.ts +9 -6
  109. package/src/providers/discovery/openrouter-free-roster.ts +3 -11
  110. package/src/providers/discovery/probe-phases.ts +42 -5
  111. package/src/providers/discovery/probing-service.ts +25 -2
  112. package/src/providers/integrations/claude/claude.ts +3 -1
  113. package/src/providers/integrations/cloudflareai/cloudflareai-models.ts +3 -1
  114. package/src/providers/integrations/inferhub.ts +3 -1
  115. package/src/providers/integrations/kilo/kilo.ts +0 -1
  116. package/src/providers/integrations/kiro/kiro-catalog.ts +8 -2
  117. package/src/providers/integrations/openrouter/provider.ts +5 -15
  118. package/src/security/api-key-auth.ts +23 -0
  119. package/src/transport/guards/auth-guard.ts +2 -3
  120. package/dist/dashboard/assets/AccountCooldown-ChpdzxRH.js.gz +0 -0
  121. package/dist/dashboard/assets/BannedPage-ChqnTRpZ.js.gz +0 -0
  122. package/dist/dashboard/assets/CliToolDetailPage-Bb9CNuoh.js +0 -1
  123. package/dist/dashboard/assets/CliToolDetailPage-Bb9CNuoh.js.gz +0 -0
  124. package/dist/dashboard/assets/CliToolsPage-BXUaRCQQ.js.gz +0 -0
  125. package/dist/dashboard/assets/CombosPage-CisNZOUt.js +0 -1
  126. package/dist/dashboard/assets/CombosPage-CisNZOUt.js.gz +0 -0
  127. package/dist/dashboard/assets/ConsoleLogPage-BOpI_LOH.js +0 -1
  128. package/dist/dashboard/assets/ConsoleLogPage-BOpI_LOH.js.gz +0 -0
  129. package/dist/dashboard/assets/CustomizationPage-DAkdvJ4k.js +0 -1
  130. package/dist/dashboard/assets/CustomizationPage-DAkdvJ4k.js.gz +0 -0
  131. package/dist/dashboard/assets/HealthEventsModal-DeT-VXHd.js +0 -1
  132. package/dist/dashboard/assets/HealthEventsModal-DeT-VXHd.js.gz +0 -0
  133. package/dist/dashboard/assets/LoginPage-CytxSeGP.js +0 -1
  134. package/dist/dashboard/assets/LoginPage-CytxSeGP.js.gz +0 -0
  135. package/dist/dashboard/assets/ModelPicker-oQ-SDXp8.js +0 -1
  136. package/dist/dashboard/assets/ModelPicker-oQ-SDXp8.js.gz +0 -0
  137. package/dist/dashboard/assets/OverviewPage-CU7S1wJs.js +0 -1
  138. package/dist/dashboard/assets/OverviewPage-CU7S1wJs.js.gz +0 -0
  139. package/dist/dashboard/assets/ProviderDetailPage-DLm2baot.js +0 -3
  140. package/dist/dashboard/assets/ProviderDetailPage-DLm2baot.js.gz +0 -0
  141. package/dist/dashboard/assets/ProvidersPage-DOXfuzfL.js +0 -1
  142. package/dist/dashboard/assets/ProvidersPage-DOXfuzfL.js.gz +0 -0
  143. package/dist/dashboard/assets/ProxyPage-wvk0ciQN.js +0 -7
  144. package/dist/dashboard/assets/ProxyPage-wvk0ciQN.js.gz +0 -0
  145. package/dist/dashboard/assets/QuotaPage-Cn_fcUHE.js +0 -1
  146. package/dist/dashboard/assets/QuotaPage-Cn_fcUHE.js.gz +0 -0
  147. package/dist/dashboard/assets/SettingsPage-8-eVadhc.js +0 -1
  148. package/dist/dashboard/assets/SettingsPage-8-eVadhc.js.gz +0 -0
  149. package/dist/dashboard/assets/SetupPage-uEIXPyGO.js +0 -1
  150. package/dist/dashboard/assets/SetupPage-uEIXPyGO.js.gz +0 -0
  151. package/dist/dashboard/assets/SortableList-DCY0TPTZ.js +0 -1
  152. package/dist/dashboard/assets/SortableList-DCY0TPTZ.js.gz +0 -0
  153. package/dist/dashboard/assets/StudioPage-DqK5E26W.js.gz +0 -0
  154. package/dist/dashboard/assets/UsagePage-38JfiZ0H.js +0 -56
  155. package/dist/dashboard/assets/UsagePage-38JfiZ0H.js.gz +0 -0
  156. package/dist/dashboard/assets/api-keys-BmDbsior.js.gz +0 -0
  157. package/dist/dashboard/assets/app-BbpSarVV.css +0 -2
  158. package/dist/dashboard/assets/app-BbpSarVV.css.gz +0 -0
  159. package/dist/dashboard/assets/badge-DpXT4Ixt.js +0 -1
  160. package/dist/dashboard/assets/badge-DpXT4Ixt.js.gz +0 -0
  161. package/dist/dashboard/assets/banner-CSAAWLJv.js +0 -1
  162. package/dist/dashboard/assets/banner-CSAAWLJv.js.gz +0 -0
  163. package/dist/dashboard/assets/card-DEhRXXw4.js +0 -1
  164. package/dist/dashboard/assets/card-DEhRXXw4.js.gz +0 -0
  165. package/dist/dashboard/assets/check-D69FzdvC.js +0 -1
  166. package/dist/dashboard/assets/check-D69FzdvC.js.gz +0 -0
  167. package/dist/dashboard/assets/cli-tools-B0wBq-RL.js.gz +0 -0
  168. package/dist/dashboard/assets/clipboard-button-DOo6EU8O.js +0 -1
  169. package/dist/dashboard/assets/clipboard-button-DOo6EU8O.js.gz +0 -0
  170. package/dist/dashboard/assets/copy-ngmQ9zcZ.js +0 -1
  171. package/dist/dashboard/assets/copy-ngmQ9zcZ.js.gz +0 -0
  172. package/dist/dashboard/assets/dialog-BvQeBMfP.js +0 -1
  173. package/dist/dashboard/assets/dialog-BvQeBMfP.js.gz +0 -0
  174. package/dist/dashboard/assets/drawer-CMwPXwQB.js +0 -1
  175. package/dist/dashboard/assets/drawer-CMwPXwQB.js.gz +0 -0
  176. package/dist/dashboard/assets/entry--yj84zk3.js +0 -4
  177. package/dist/dashboard/assets/entry--yj84zk3.js.gz +0 -0
  178. package/dist/dashboard/assets/entry-D4O2229X.js.gz +0 -0
  179. package/dist/dashboard/assets/entry-DKvr5Q9K.js +0 -1
  180. package/dist/dashboard/assets/entry-DKvr5Q9K.js.gz +0 -0
  181. package/dist/dashboard/assets/github-badge-zliLvBwr.js +0 -1
  182. package/dist/dashboard/assets/github-badge-zliLvBwr.js.gz +0 -0
  183. package/dist/dashboard/assets/index-CcD1eSJ6.js.gz +0 -0
  184. package/dist/dashboard/assets/inline-D1IlZZ8H.js +0 -1
  185. package/dist/dashboard/assets/inline-D1IlZZ8H.js.gz +0 -0
  186. package/dist/dashboard/assets/input-BpVZdrbc.js +0 -1
  187. package/dist/dashboard/assets/input-BpVZdrbc.js.gz +0 -0
  188. package/dist/dashboard/assets/layout-BioLW7gN.js +0 -1
  189. package/dist/dashboard/assets/layout-BioLW7gN.js.gz +0 -0
  190. package/dist/dashboard/assets/list-row-CwVcGAIc.js +0 -1
  191. package/dist/dashboard/assets/list-row-CwVcGAIc.js.gz +0 -0
  192. package/dist/dashboard/assets/live-yfEJFF9T.js.gz +0 -0
  193. package/dist/dashboard/assets/model-bans-CT-TxSNX.js.gz +0 -0
  194. package/dist/dashboard/assets/numbers-CFL4_Dqc.js +0 -1
  195. package/dist/dashboard/assets/numbers-CFL4_Dqc.js.gz +0 -0
  196. package/dist/dashboard/assets/routing-Cs6jl49L.js.gz +0 -0
  197. package/dist/dashboard/assets/select-XPJ-dIw3.js +0 -41
  198. package/dist/dashboard/assets/select-XPJ-dIw3.js.gz +0 -0
  199. package/dist/dashboard/assets/settings-CfcTcOyU.js.gz +0 -0
  200. package/dist/dashboard/assets/stack-C9_uUjaA.js +0 -1
  201. package/dist/dashboard/assets/stack-C9_uUjaA.js.gz +0 -0
  202. package/dist/dashboard/assets/state-DA0B95UQ.js +0 -1
  203. package/dist/dashboard/assets/state-DA0B95UQ.js.gz +0 -0
  204. package/dist/dashboard/assets/switch-Cittxy-x.js +0 -1
  205. package/dist/dashboard/assets/switch-Cittxy-x.js.gz +0 -0
  206. package/dist/dashboard/assets/toast-CNt_jzO4.js +0 -2
  207. package/dist/dashboard/assets/toast-CNt_jzO4.js.gz +0 -0
  208. package/dist/dashboard/assets/useMutation-BQKMcJ1H.js.gz +0 -0
@@ -1 +0,0 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{a as r,r as i}from"./toast-CNt_jzO4.js";import{t as a}from"./eye-off-Bk5g2luF.js";import{t as o}from"./eye-C_hawfH4.js";import{n as s,r as c,t as l}from"./state-DA0B95UQ.js";import{t as u}from"./dialog-BvQeBMfP.js";import{t as d}from"./plus-DIdX_g-x.js";import{t as f}from"./trash-Cppn5c3R.js";import{l as p}from"./query-keys-D7wX2vM5.js";import{t as m}from"./dialog-actions-B1axpEg7.js";import{$ as h,C as ee,X as g,_,a as v,at as y,g as b,i as x,m as S,nt as C,s as w,w as T}from"./entry--yj84zk3.js";import{n as E,r as D,t as O}from"./card-DEhRXXw4.js";import{t as k}from"./badge-DpXT4Ixt.js";import{n as A}from"./input-BpVZdrbc.js";import{t as j}from"./select-XPJ-dIw3.js";import{t as M}from"./ProviderIcon-CmfzxpVM.js";import{t as N}from"./switch-Cittxy-x.js";import{t as P}from"./stack-C9_uUjaA.js";import{n as F}from"./inline-D1IlZZ8H.js";import{t as te}from"./list-row-CwVcGAIc.js";import{t as I}from"./privacy-mode-GM8bej85.js";import{r as L}from"./AccountCooldown-ChpdzxRH.js";var R=e(t(),1),z=n();function B(e){let t={};for(let[n,r]of e)n.trim()&&(t[n.trim()]=r);return t}function ne({pairs:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?r:e)),r=n=>t(e.filter((e,t)=>t!==n));return(0,z.jsxs)(`div`,{className:`form-group`,children:[(0,z.jsxs)(`label`,{className:`form-label block`,children:[(0,z.jsx)(`span`,{className:`block`,children:`Custom Headers`}),(0,z.jsx)(`span`,{className:`form-hint block mt-1`,children:`Optional — sent with every request, override built-in headers on a name collision`})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.map(([e,t],a)=>(0,z.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,z.jsx)(A,{placeholder:`Header-Name`,value:e,onChange:e=>n(a,[e.target.value,t]),className:`font-mono tabular-nums min-w-0 flex-1 text-caption`}),(0,z.jsx)(A,{placeholder:`value`,value:t,onChange:t=>n(a,[e,t.target.value]),className:`font-mono tabular-nums min-w-0 flex-1 text-caption`}),(0,z.jsx)(i,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove ${e||`header`}`,onClick:()=>r(a),children:(0,z.jsx)(f,{size:13})})]},a)),(0,z.jsxs)(i,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>t([...e,[``,``]]),children:[(0,z.jsx)(d,{size:13}),` Add header`]})]})]})}function V({children:e}){return(0,z.jsx)(`div`,{className:`provider-grid grid gap-6 w-full min-w-0`,children:e})}var H=r(`relative flex flex-col min-w-0 border border-inner-border rounded-card`,`transition-[transform,border-color,box-shadow]`),U=r(`block flex-1 p-6 no-underline text-inherit`),W=r(`text-body font-semibold overflow-hidden text-ellipsis whitespace-nowrap`);function G(e){let t=e.serviceKinds;return Array.isArray(t)&&t.length>0?t:[`llm`]}var K=/\/(?:v\d+\/)?(?:messages|chat\/completions|responses|completions|embeddings|images\/generations)$/;function re(e){let t=e.trim().replace(/\/+$/,``);if(t===``)return null;let n,r;try{n=new URL(t),r=n.pathname.replace(/\/+$/,``)}catch{return null}return K.test(r)?n.origin:null}function q({variant:e,open:t,onClose:n}){let a=x(),o=v(),s=ee(),c=T(),[l,d]=(0,R.useState)(``),[f,m]=(0,R.useState)(``),[h,g]=(0,R.useState)(``),[_,y]=(0,R.useState)(``),[b,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(!0),[E,D]=(0,R.useState)([]),[O,k]=(0,R.useState)(null),[M,P]=(0,R.useState)(!1),[I,L]=(0,R.useState)(null),[V,H]=(0,R.useState)(!1),U=e===`anthropic-compatible`,W=U?`messages`:`chat`,[G,K]=(0,R.useState)(W),q=(0,R.useMemo)(()=>re(h),[h]);(0,R.useEffect)(()=>{t&&(d(``),y(``),K(W),g(``),S(!1),w(!0),D([]),k(null),L(null))},[t]);let J=async e=>{try{let t=await navigator.clipboard.readText();t.trim()&&e(t.trim())}catch{k(`Clipboard access denied — paste manually instead.`)}},ie=async()=>{if(!h.trim()){L({ok:!1,message:`Base URL is required to test the connection.`});return}H(!0),L(null),k(null);try{let e=B(E),t=await c.mutateAsync({baseUrl:h.trim(),apiKey:_.trim(),wireFamily:G,cliIdentity:C,...Object.keys(e).length>0?{extraHeaders:e}:{}});if(t.ok){let e=typeof t.modelCount==`number`?` — upstream advertised ${t.modelCount} model(s)`:``;L({ok:!0,message:`Connected successfully (${t.latencyMs}ms)${e}.`,...t.warning===void 0?{}:{warning:t.warning}})}else L({ok:!1,message:t.error??`Connection failed.`,...t.warning===void 0?{}:{warning:t.warning}})}catch(e){L({ok:!1,message:p(e,`Connection test failed`)})}finally{H(!1)}};return(0,z.jsx)(u,{open:t,onClose:n,title:U?`Add Custom Anthropic Provider`:`Add Custom OpenAI Provider`,footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i,{variant:`secondary`,type:`button`,onClick:n,children:`Cancel`}),(0,z.jsx)(i,{variant:`primary`,type:`submit`,form:`add-compatible-provider`,disabled:M,children:M?`Creating...`:`Add Provider`})]}),children:(0,z.jsxs)(`form`,{id:`add-compatible-provider`,onSubmit:async e=>{if(e.preventDefault(),!l.trim()){k(`Display Name is required`);return}if(!f.trim()){k(`Provider ID (slug) is required`);return}if(!h.trim()){k(`Base URL is required`);return}let t=B(E),r=f.trim().toLowerCase();P(!0),k(null);try{let e={providerId:r,label:l.trim(),baseUrl:h.trim(),wireFamily:G,compatibilityProfile:{cli_identity:C,...Object.keys(t).length>0?{extra_headers:t}:{}}};await a.mutateAsync(e),_.trim()&&await o.mutateAsync({providerId:r,request:{credentialKind:`api_key`,secret:_.trim()}}),b&&await s.mutateAsync(r),n()}catch(e){k(p(e,`Failed to create provider`))}finally{P(!1)}},className:`flex flex-col gap-6`,children:[O?(0,z.jsx)(`div`,{className:`text-red text-caption`,children:O}):null,(0,z.jsx)(A,{label:`Display Name`,hint:`Required. A friendly label for this node.`,id:`compat-label`,value:l,onChange:e=>d(e.target.value),placeholder:U?`Anthropic Compatible (Prod)`:`OpenAI Compatible (Prod)`,required:!0}),(0,z.jsx)(A,{label:`Provider ID / Slug`,hint:`Required. Used as the provider prefix for model IDs.`,id:`compat-slug`,value:f,onChange:e=>m(e.target.value),placeholder:U?`ac-prod`:`oc-prod`,required:!0}),(0,z.jsxs)(`div`,{className:`form-group`,children:[(0,z.jsxs)(`label`,{className:`form-label`,htmlFor:`compat-url`,children:[(0,z.jsx)(`span`,{children:`Base URL`}),(0,z.jsxs)(`span`,{className:`form-hint`,children:[`The root only. Do not paste the full endpoint — leave off`,U?" `/v1/messages`.":" `/chat/completions`."]})]}),(0,z.jsxs)(F,{gap:`8px`,children:[(0,z.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,z.jsx)(A,{id:`compat-url`,value:h,onChange:e=>g(e.target.value),placeholder:U?`https://api.anthropic.com/v1`:`https://api.openai.com/v1`,required:!0})}),(0,z.jsx)(i,{type:`button`,variant:`secondary`,onClick:()=>J(g),children:`Paste`})]}),q===null?null:(0,z.jsxs)(`p`,{className:`mt-1.5 text-caption text-orange`,children:[`That looks like a full endpoint. Use`,` `,(0,z.jsx)(`code`,{className:`font-mono`,children:q}),` instead — Cartethyia appends the endpoint path itself.`]})]}),U?null:(0,z.jsx)(j,{id:`compat-wire`,label:`API format`,value:G,onValueChange:e=>K(e),options:[{value:`chat`,label:`Chat completions`},{value:`responses`,label:`Responses`}]}),(0,z.jsxs)(`div`,{className:`form-group`,children:[(0,z.jsxs)(`label`,{className:`form-label`,htmlFor:`compat-credential`,children:[(0,z.jsx)(`span`,{children:`API Key`}),(0,z.jsx)(`span`,{className:`form-hint`,children:`Optional — saved with this provider and used to authenticate every request.`})]}),(0,z.jsxs)(F,{gap:`8px`,children:[(0,z.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,z.jsx)(A,{id:`compat-credential`,type:`password`,placeholder:`sk-...`,value:_,onChange:e=>y(e.target.value)})}),(0,z.jsx)(i,{type:`button`,variant:`secondary`,disabled:V,onClick:()=>void ie(),children:V?`Testing...`:`Test connection`}),(0,z.jsx)(i,{type:`button`,variant:`secondary`,onClick:()=>J(y),children:`Paste`})]}),I?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:r(`mt-3 text-caption leading-[1.4] break-words`,I.ok?`text-green`:`text-red`),children:[I.ok?`✓ `:`✗ `,I.message]}),I.warning?(0,z.jsxs)(`div`,{className:`mt-2 text-caption leading-snug break-words text-orange`,children:[`⚠ `,I.warning]}):null]}):null]}),(0,z.jsx)(te,{actions:(0,z.jsx)(N,{checked:b,onChange:S,id:`compat-autofetch`}),children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-body font-semibold`,children:`Auto-fetch models`}),(0,z.jsx)(`div`,{className:`mt-1 text-badge text-text-tertiary`,children:`Discover this provider's model list automatically after creation`})]})}),(0,z.jsx)(te,{actions:(0,z.jsx)(N,{checked:C,onChange:w,id:`compat-cli-identity`}),children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-body font-semibold`,children:U?`Send request as Claude CLI`:`Send request as Codex CLI`}),(0,z.jsx)(`div`,{className:`mt-1 text-badge text-text-tertiary`,children:U?`Emits official Claude CLI User-Agent and Stainless headers to upstream`:`Emits official codex_cli_rs User-Agent and originator headers to upstream`})]})}),(0,z.jsx)(ne,{pairs:E,onChange:D})]})})}function J({customProvider:e}){let t=w(),[n,a]=(0,R.useState)(!1),o=b(e.providerId),s=o.data?.length,c=S(e.providerId),l=c.data,d=oe(l??[]);return(0,z.jsxs)(O,{className:H,children:[(0,z.jsx)(ce,{clientVersion:e.clientVersion}),(0,z.jsx)(g,{to:`/providers/${encodeURIComponent(e.providerId)}`,className:r(U,`pr-20 min-h-38`),children:(0,z.jsxs)(F,{gap:`10px`,children:[(0,z.jsx)(M,{icon:e.wireFamilyDefault===`messages`?`anthropic`:`openai`,name:e.label||e.providerId,size:32,imageSize:24}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:W,children:e.label||e.providerId}),e.baseUrl?(0,z.jsxs)(`div`,{className:`mt-1 min-w-0 truncate font-mono text-micro text-text-tertiary`,title:e.baseUrl,children:[(0,z.jsx)(`span`,{className:`font-semibold text-text-secondary`,children:`Base URL`}),` `,e.baseUrl]}):null,(0,z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2`,children:[l===void 0?(0,z.jsx)($,{kind:`accounts`,isPending:c.isPending,isError:c.isError,hasData:!1}):l.length===0?e.requiresAccount===!1?(0,z.jsx)(k,{tone:`ok`,children:`Free Endpoint`}):(0,z.jsx)(k,{children:`No connections`}):(0,z.jsx)(se,{counts:d,total:l.length}),c.isError&&l!==void 0?(0,z.jsx)(k,{tone:`warn`,children:`Connections unavailable`}):null]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,z.jsxs)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg px-2.5 py-0.5 rounded-chip text-text-secondary`,children:[e.providerId,`/`]}),s!==void 0&&s>0?(0,z.jsxs)(k,{tone:`info`,children:[s,` models`]}):null,o.isError?(0,z.jsx)(k,{tone:`warn`,children:`Models unavailable`}):s===void 0?(0,z.jsx)($,{kind:`models`,isPending:o.isPending,isError:!1,hasData:!1}):s===0?(0,z.jsx)($,{kind:`models`,isPending:!1,isError:!1,hasData:!0,isEmpty:!0}):null]})]})}),(0,z.jsx)(i,{variant:`ghost`,size:`sm`,icon:(0,z.jsx)(f,{size:12}),onClick:()=>a(!0),className:`absolute top-2 right-2 p-2 text-text-tertiary`,title:`Delete ${e.label||e.providerId}`}),(0,z.jsx)(u,{open:n,onClose:()=>a(!1),title:`Delete Custom Provider`,children:(0,z.jsxs)(P,{gap:`12px`,children:[(0,z.jsxs)(`p`,{className:`text-body text-text-secondary`,children:[`Are you sure you want to delete custom provider`,` `,(0,z.jsx)(`strong`,{children:e.label||e.providerId}),`? Its models, accounts, and routing preferences are deleted together, and requests to this provider will no longer route.`]}),t.isError?(0,z.jsx)(`p`,{className:`text-caption text-red`,children:p(t.error,`Delete failed`)}):null,(0,z.jsxs)(m,{children:[(0,z.jsx)(i,{variant:`secondary`,onClick:()=>a(!1),children:`Cancel`}),(0,z.jsx)(i,{variant:`danger`,onClick:()=>{t.mutate(e.providerId,{onSuccess:()=>a(!1),onError:()=>void 0})},disabled:t.isPending,children:t.isPending?`Deleting...`:`Delete Provider`})]})]})})]})}function ie({customProviders:e}){let[t,n]=(0,R.useState)(!1),[r,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(()=>{try{return window.localStorage.getItem(`cartethyia.customProvidersHidden`)===`1`}catch{return!1}});function u(){l(e=>{let t=!e;try{window.localStorage.setItem(`cartethyia.customProvidersHidden`,t?`1`:`0`)}catch{}return t})}return(0,z.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-4`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:u,"aria-expanded":!c,title:c?`Show custom providers`:`Hide custom providers`,className:`inline-flex items-center gap-3 bg-transparent border-none p-0 cursor-pointer text-inherit`,children:[(0,z.jsxs)(`h2`,{className:`text-body-lg font-bold tracking-[-0.01em]`,children:[`Custom Providers`,e.length>0?` (${e.length})`:``]}),(0,z.jsx)(y,{size:14,className:`text-text-tertiary transition-transform`,style:{transform:c?`rotate(-90deg)`:void 0}})]}),(0,z.jsxs)(F,{gap:`8px`,children:[(0,z.jsx)(i,{size:`sm`,variant:`ghost`,icon:c?(0,z.jsx)(o,{size:13}):(0,z.jsx)(a,{size:13}),onClick:u,title:c?`Show custom providers`:`Hide custom providers`,children:c?`Show`:`Hide`}),(0,z.jsx)(i,{size:`sm`,variant:`secondary`,icon:(0,z.jsx)(d,{size:13}),onClick:()=>n(!0),children:`Custom Anthropic`}),(0,z.jsx)(i,{size:`sm`,variant:`secondary`,icon:(0,z.jsx)(d,{size:13}),onClick:()=>s(!0),children:`Custom OpenAI`})]})]}),c?null:e.length===0?(0,z.jsx)(O,{children:(0,z.jsxs)(E,{className:`text-center px-7 py-10 border border-dashed border-inner-border rounded-card`,children:[(0,z.jsx)(`p`,{className:`text-body font-semibold text-text-primary`,children:`No custom providers yet`}),(0,z.jsx)(`p`,{className:`text-badge text-text-tertiary mt-1`,children:`Add an OpenAI- or Anthropic-compatible endpoint with the buttons above.`})]})}):(0,z.jsx)(V,{children:e.map(e=>(0,z.jsx)(J,{customProvider:e},e.providerId))}),(0,z.jsx)(q,{variant:`anthropic-compatible`,open:t,onClose:()=>n(!1)}),(0,z.jsx)(q,{variant:`openai-compatible`,open:r,onClose:()=>s(!1)})]})}var Y=new Set([`inferhub`]),X=new Set([`grok`,`opencode`,`cline`,`hermes`,`kilo`]),ae=new Set([`anthropic`,`openai`,`gemini`,`alibabacp`,`ollamacloud`,`opencode-zen`,`opencode-go`,`mistral`,`meta`,`deepseek`,`commandcode`,`dashscope`]);function Z(e){return e.oauthFlows?.browser===!0||e.oauthFlows?.device===!0}function Q(e){return e.oauthFlows?.refreshable===!0}function oe(e){return{active:e.filter(e=>e.status===`active`).length,cooldown:e.filter(e=>e.status===`cooldown`).length,disabled:e.filter(e=>e.status===`disabled`).length,cooling:L(e)}}function se({counts:e,total:t}){return e.active>0||e.cooldown>0||e.cooling>0||e.disabled>0?(0,z.jsxs)(z.Fragment,{children:[e.active>0?(0,z.jsxs)(k,{tone:`ok`,dot:!0,children:[e.active,` Healthy`]}):null,e.cooldown>0?(0,z.jsxs)(k,{tone:`warn`,dot:!0,children:[e.cooldown,` Cooldown`]}):null,e.cooling>0?(0,z.jsxs)(k,{tone:`warn`,dot:!0,children:[e.cooling,` Cooling`]}):null,e.disabled>0?(0,z.jsxs)(k,{tone:`warn`,dot:!0,children:[e.disabled,` Unhealthy`]}):null]}):(0,z.jsxs)(k,{tone:`warn`,dot:!0,children:[t,` Connected`]})}function $({kind:e,isPending:t,isError:n,hasData:r,isEmpty:i=!1}){let a=e===`models`?`Models`:`Connections`;return n?(0,z.jsxs)(k,{tone:`warn`,children:[a,` unavailable`]}):t&&!r?(0,z.jsxs)(k,{tone:`info`,children:[`Loading `,a.toLowerCase(),`…`]}):i?(0,z.jsx)(k,{children:e===`models`?`No models`:`No connections`}):null}function ce({clientVersion:e}){return e?(0,z.jsxs)(k,{className:`provider-version-badge absolute -top-4.5 left-5 right-auto z-chip max-w-[calc(100%-var(--spacing)*10)] truncate px-3 py-1 text-micro leading-[1.15] shadow-card max-small:left-4 max-small:max-w-[calc(100%-var(--spacing)*8)]`,tone:e.source===`latest`?`teal`:`default`,title:e.source===`latest`?`Latest discovered client version`:`Pinned fallback; background discovery has not succeeded yet`,children:[`v`,e.version,` · `,e.source]}):null}var le=(0,R.memo)(function({provider:e,serviceKind:t}){let n=Y.has(e.providerId.toLowerCase()),i=e.label||e.displayName,a=b(e.providerId),o=a.data?.filter(e=>t===void 0||e.serviceKind===t||t===`llm`&&e.serviceKind===void 0).length,s=S(e.providerId),c=s.data,l=oe(c??[]);return(0,z.jsxs)(O,{className:H,children:[(0,z.jsx)(ce,{clientVersion:e.clientVersion}),n?(0,z.jsx)(`span`,{"aria-label":`Friend sponsor`,title:`Friend sponsor`,className:`absolute top-0 right-0 z-2 w-36 h-36 overflow-hidden pointer-events-none`,children:(0,z.jsx)(`span`,{className:r(`absolute top-9 -right-11 w-38 py-1 rotate-45 bg-accent-soft`,`text-accent text-micro font-extrabold tracking-tight leading-[1.05]`,`text-center uppercase shadow-ribbon`),children:`Friend`})}):null,(0,z.jsx)(g,{to:`/providers/${encodeURIComponent(e.providerId)}${t===void 0?``:`?service=${t}`}`,className:U,children:(0,z.jsxs)(F,{gap:`10px`,children:[(0,z.jsx)(M,{icon:e.providerId,name:i,size:32,imageSize:24}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:W,children:i}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2`,children:[c===void 0?(0,z.jsx)($,{kind:`accounts`,isPending:s.isPending,isError:s.isError,hasData:!1}):c.length===0?e.requiresAccount===!1?(0,z.jsx)(k,{tone:`ok`,children:`Free Endpoint`}):(0,z.jsx)(k,{children:`No connections`}):(0,z.jsx)(se,{counts:l,total:c.length}),s.isError&&c!==void 0?(0,z.jsx)(k,{tone:`warn`,children:`Connections unavailable`}):null]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,z.jsxs)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg px-2.5 py-0.5 rounded-chip text-text-secondary`,children:[e.providerId,`/`]}),o!==void 0&&o>0?(0,z.jsxs)(k,{tone:`info`,children:[o,` models`]}):null,a.isError?(0,z.jsx)(k,{tone:`warn`,children:`Models unavailable`}):o===void 0?(0,z.jsx)($,{kind:`models`,isPending:a.isPending,isError:!1,hasData:!1}):o===0?(0,z.jsx)($,{kind:`models`,isPending:!1,isError:!1,hasData:!0,isEmpty:!0}):null]})]})})]})});function ue(e,t){let n=Number(!!t.configured)-Number(!!e.configured);return n===0?(e.label||e.displayName).localeCompare(t.label||t.displayName):n}var de=`cartethyia.providerSectionsCollapsed`;function fe(){try{let e=window.localStorage.getItem(de),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}var pe=[{title:`Founding Friend & Sponsors`,subtitle:`Super Cheap inference pool`,filter:e=>Y.has(e.providerId.toLowerCase())},{title:`Free Limited Providers`,filter:e=>X.has(e.providerId.toLowerCase())},{title:`OAuth & Agent Providers`,filter:e=>(Z(e)||Q(e))&&!X.has(e.providerId.toLowerCase())},{title:`Well Known API Key Providers`,subtitle:`The household names — sign up with a key and go`,filter:e=>e.isBuiltIn&&ae.has(e.providerId.toLowerCase())&&!Y.has(e.providerId.toLowerCase())&&!X.has(e.providerId.toLowerCase())&&!Z(e)&&!Q(e)},{title:`Other API Key Providers`,subtitle:`Free tier friendly — no credit card`,filter:e=>e.isBuiltIn&&!ae.has(e.providerId.toLowerCase())&&!Y.has(e.providerId.toLowerCase())&&!X.has(e.providerId.toLowerCase())&&!Z(e)&&!Q(e)}];function me(){let[e,t]=(0,R.useState)(fe),n=_(),u=I(),d=u.enabled,f=e=>!d||e.configured===!0||e.requiresAccount===!1,m=(0,R.useMemo)(()=>n.data??[],[n.data]),ee=(0,R.useMemo)(()=>[...m.filter(e=>!e.isBuiltIn&&f(e))].sort(ue),[m,d]),g=(0,R.useMemo)(()=>m.filter(e=>G(e).includes(`websearch`)&&f(e)),[m,d]),v=(0,R.useMemo)(()=>m.filter(e=>G(e).includes(`llm`)&&f(e)),[m,d]),[b,x]=h(),S=b.get(`tab`),w=S===`search`||S===`media`?S:`llm`,T=e=>{x(t=>{let n=new URLSearchParams(t);return e===`llm`?n.delete(`tab`):n.set(`tab`,e),n})},k=(0,R.useMemo)(()=>m.filter(e=>(G(e).includes(`imageGeneration`)||G(e).includes(`videoGeneration`))&&f(e)),[m,d]),A=(0,R.useMemo)(()=>[...g].sort((e,t)=>(e.label||e.displayName).localeCompare(t.label||t.displayName)),[g]),j=(e,t)=>{let n=Number(!!t.configured)-Number(!!e.configured);return n===0?(e.label||e.displayName).localeCompare(t.label||t.displayName):n},M=(0,R.useMemo)(()=>{if(w===`media`)return[{title:`Media Generation`,subtitle:`Providers that can return an image or a video`,providers:k}].filter(e=>e.providers.length>0);if(w===`search`)return[{title:`Search Providers`,subtitle:`Providers that can answer a web search request`,providers:A}].filter(e=>e.providers.length>0);let e=v;return pe.map(t=>({...t,providers:e.filter(t.filter).sort(j)})).filter(e=>e.providers.length>0)},[v,A,k,w]),N=n.isPending&&!n.data?(0,z.jsx)(c,{label:`Loading providers...`}):n.isError?(0,z.jsx)(s,{message:p(n.error,`Failed to load providers`),onRetry:()=>n.refetch()}):null;return N?(0,z.jsxs)(O,{children:[(0,z.jsx)(D,{title:`Providers`,icon:(0,z.jsx)(C,{size:16})}),(0,z.jsx)(E,{className:`flex flex-1`,children:N})]}):(0,z.jsx)(P,{gap:`24px`,children:(0,z.jsxs)(O,{children:[(0,z.jsx)(D,{title:`Providers`,subtitle:`Connected pinned first · A–Z`,icon:(0,z.jsx)(C,{size:16})}),(0,z.jsxs)(E,{className:`flex flex-col gap-8`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,z.jsx)(`div`,{className:`flex gap-2`,children:[`llm`,`search`,`media`].map(e=>(0,z.jsxs)(`button`,{onClick:()=>T(e),className:r(`px-6 py-3 rounded-inset text-caption font-semibold border cursor-pointer`,w===e?`border-accent bg-accent-soft text-accent`:`border-inner-border bg-surface-1 text-text-secondary`),children:[e===`llm`?`LLM`:e===`search`?`Search`:`Media`,e===`search`?` (${g.length})`:e===`media`?` (${k.length})`:` (${v.length})`]},e))}),(0,z.jsx)(i,{variant:`ghost`,size:`sm`,icon:d?(0,z.jsx)(a,{size:12}):(0,z.jsx)(o,{size:12}),onClick:()=>u.setEnabled(!d),title:d?`Show providers that have no account yet`:`Hide providers that have no account yet`,children:d?`Show unconfigured`:`Hide unconfigured`}),(0,z.jsx)(`span`,{className:`ml-auto text-micro text-text-tertiary`,children:w===`search`?`Fallback runs only when the model invokes Websearch`:w===`media`?`Image and video generation`:`Connected pinned first · A–Z`})]}),w===`llm`?(0,z.jsx)(ie,{customProviders:ee}):null,M.length===0?(0,z.jsx)(O,{children:(0,z.jsx)(E,{children:(0,z.jsx)(l,{title:`No providers found`,message:`No providers available.`})})}):M.map(n=>{let i=e.has(n.title);return(0,z.jsxs)(`section`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex items-start gap-4 border-0 bg-transparent p-0 text-left text-inherit`,"aria-expanded":!i,onClick:()=>t(e=>{let t=new Set(e);t.has(n.title)?t.delete(n.title):t.add(n.title);try{window.localStorage.setItem(de,JSON.stringify([...t]))}catch{}return t}),children:[(0,z.jsx)(y,{size:15,className:r(`mt-1 shrink-0 transition-transform`,i&&`-rotate-90`)}),(0,z.jsxs)(P,{gap:`1px`,children:[(0,z.jsxs)(`h2`,{className:`text-body font-bold tracking-[-0.01em]`,children:[n.title,` (`,n.providers.length,`)`,i?` (Hidden)`:``]}),!i&&n.subtitle?(0,z.jsx)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:n.subtitle}):null]})]}),i?null:(0,z.jsx)(V,{children:n.providers.map(e=>(0,z.jsx)(le,{provider:e,serviceKind:w===`search`?`websearch`:w===`media`?G(e).includes(`imageGeneration`)?`imageGeneration`:`videoGeneration`:`llm`},e.providerId))})]},n.title)})]})]})})}export{me as default};
@@ -1,7 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{r as i}from"./terminal-Bd4ee8TA.js";import{g as a,r as o,t as s,v as c}from"./toast-CNt_jzO4.js";import{t as l}from"./download-A0SW9OCW.js";import{t as u}from"./eye-off-Bk5g2luF.js";import{t as d}from"./eye-C_hawfH4.js";import{t as f}from"./gauge-BbIMy7MB.js";import{a as p,n as m,r as h,t as g}from"./state-DA0B95UQ.js";import{t as _}from"./dialog-BvQeBMfP.js";import{t as v}from"./pencil-768ysRAr.js";import{t as y}from"./plus-DIdX_g-x.js";import{t as b}from"./power-off-Yjw9GMJh.js";import{t as x}from"./rotate-ccw-CufcqITi.js";import{t as S}from"./shield-check-DVS0Foqh.js";import{t as C}from"./trash-Cppn5c3R.js";import{C as w,T,c as ee,v as E,y as D}from"./assert-BHfaei-X.js";import{a as O,i as k,l as A,o as j,t as M}from"./query-keys-D7wX2vM5.js";import{t as N}from"./useMutation-BQKMcJ1H.js";import{L as te,nt as P}from"./entry--yj84zk3.js";import{n as ne,r as re,t as ie}from"./card-DEhRXXw4.js";import{n as ae}from"./download-dRFo5_Wu.js";import{t as F}from"./numbers-CFL4_Dqc.js";import{t as I}from"./badge-DpXT4Ixt.js";import{n as L}from"./input-BpVZdrbc.js";import{t as oe}from"./select-XPJ-dIw3.js";import{t as R}from"./switch-Cittxy-x.js";import{t as se}from"./stack-C9_uUjaA.js";import{n as ce}from"./inline-D1IlZZ8H.js";import{r as z,t as le}from"./layout-BioLW7gN.js";import{i as ue,n as de}from"./privacy-mode-GM8bej85.js";import{n as B}from"./live-yfEJFF9T.js";var fe=e(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),pe=e(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),me=1e6,he=1e8,ge=5e6,_e=`sin1`,ve=[{label:`Asia Pacific`,regions:[{id:`sin1`,label:`Singapore`},{id:`hkg1`,label:`Hong Kong`},{id:`icn1`,label:`Seoul`},{id:`hnd1`,label:`Tokyo`},{id:`kix1`,label:`Osaka`},{id:`bom1`,label:`Mumbai`},{id:`syd1`,label:`Sydney`}]},{label:`Europe`,regions:[{id:`fra1`,label:`Frankfurt`},{id:`cdg1`,label:`Paris`},{id:`lhr1`,label:`London`},{id:`arn1`,label:`Stockholm`},{id:`dub1`,label:`Dublin`}]},{label:`North America`,regions:[{id:`iad1`,label:`Washington, D.C.`},{id:`sfo1`,label:`San Francisco`},{id:`pdx1`,label:`Portland`},{id:`cle1`,label:`Cleveland`},{id:`yul1`,label:`Montréal`}]},{label:`Other`,regions:[{id:`gru1`,label:`São Paulo`},{id:`cpt1`,label:`Cape Town`},{id:`dxb1`,label:`Dubai`}]}];function ye(){return w({queryKey:M.network.pools,queryFn:e=>j(`/network/pools`,{signal:E(e)}).then(ee),staleTime:k.staleTime,gcTime:k.gcTime})}function be(){let e=T();return N({mutationFn:e=>j(`/network/pools`,{method:`POST`,body:JSON.stringify(e)}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools}),s.success(`Proxy pool created`)},onError:e=>{s.error(`Could not create the proxy pool.`,A(e))}})}function xe(){let e=T();return N({mutationFn:e=>j(`/network/pools/relay/deploy`,{method:`POST`,body:JSON.stringify(e)}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools})}})}function Se(){return N({mutationFn:e=>j(`/network/pools/test-batch`,{method:`POST`,body:JSON.stringify({targets:e})})})}function Ce(){let e=T();return N({mutationFn:({poolId:e,request:t})=>j(`/network/pools/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools}),s.success(`Proxy updated`)},onError:e=>{s.error(`Could not update the proxy pool.`,A(e))}})}function we(e){return w({queryKey:[...M.network.pools,e,`health-events`],queryFn:t=>j(`/network/pools/${encodeURIComponent(e??``)}/health-events`,{signal:E(t)}),enabled:!!e,...k,refetchInterval:O.status})}function Te(){let e=T();return N({mutationFn:e=>j(`/network/pools/${encodeURIComponent(e)}/recover`,{method:`POST`,body:`{}`}),onSuccess:async(t,n)=>{await Promise.all([e.invalidateQueries({queryKey:M.network.pools}),e.invalidateQueries({queryKey:[...M.network.pools,n,`health-events`]})]),s.success(`Proxy pool recovered`)},onError:e=>{s.error(`Could not recover the proxy pool.`,A(e))}})}function Ee(){let e=T();return N({mutationFn:e=>j(`/network/pools/${encodeURIComponent(e)}`,{method:`DELETE`}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools}),s.success(`Proxy pool deleted`)},onError:e=>{s.error(`Could not delete the proxy pool.`,A(e))}})}function De(){let e=T();return N({mutationFn:({poolId:e,providerId:t})=>j(`/network/pools/${encodeURIComponent(e)}/provider-probe`,{method:`POST`,body:JSON.stringify({providerId:t})}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools})}})}function Oe(){return N({mutationFn:({providerId:e,targets:t})=>j(`/network/pools/test-batch/provider`,{method:`POST`,body:JSON.stringify({providerId:e,targets:t})})})}function ke(){let e=T();return N({mutationFn:e=>j(`/network/pools/${encodeURIComponent(e)}/health-check`,{method:`POST`,body:`{}`}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools}),s.success(`Health check complete`)},onError:e=>{s.error(`Health check failed.`,A(e))}})}function Ae(){let e=T();return N({mutationFn:({poolId:e,bytes:t})=>j(`/network/pools/${encodeURIComponent(e)}/speed-test`,{method:`POST`,body:JSON.stringify({bytes:t})}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools})}})}function je(){let e=T();return N({mutationFn:({poolId:e,providerId:t})=>j(`/network/pools/${encodeURIComponent(e)}/cooldowns/clear`,{method:`POST`,body:JSON.stringify(t?{providerId:t}:{})}),onSuccess:async()=>{await e.invalidateQueries({queryKey:M.network.pools}),s.success(`Provider cooldowns cleared`)},onError:e=>{s.error(`Could not clear provider cooldowns.`,A(e))}})}var V=t(n(),1),H=r(),U={cloudflare:{label:`Cloudflare Workers`,tokenLabel:`Cloudflare API token`,needsAccount:!0,host:`*.workers.dev`,hasRegion:!1},vercel:{label:`Vercel`,tokenLabel:`Vercel API token`,needsAccount:!1,host:`*.vercel.app`,hasRegion:!0},deno:{label:`Deno Deploy`,tokenLabel:`Deno Deploy token`,needsAccount:!1,host:`*.deno.dev`,hasRegion:!1}},Me=ve.flatMap(e=>e.regions.map(t=>({value:t.id,label:`${e.label} — ${t.label}`})));function Ne({onClose:e}){let t=xe(),[n,r]=(0,V.useState)(`cloudflare`),[i,a]=(0,V.useState)(_e),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(``),[f,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(null),v=U[n],y=c.trim().length>0&&(!v.needsAccount||u.trim().length>0);return(0,H.jsx)(_,{open:!0,onClose:e,title:`Deploy Relay`,description:`Run outbound traffic through a hosted relay (Cloudflare, Vercel, Deno).`,size:`md`,children:(0,H.jsxs)(se,{gap:`12px`,children:[(0,H.jsxs)(`p`,{className:`text-badge text-text-tertiary m-0 flex gap-3`,children:[(0,H.jsx)(P,{size:13,className:`shrink-0 mt-0.5`}),(0,H.jsxs)(`span`,{children:[`Deploys a small relay worker to your own `,v.label,` account and registers its URL (`,(0,H.jsx)(`code`,{children:v.host}),`) as an active HTTP pool. Your API token is used only for the deploy and is never stored.`]})]}),(0,H.jsx)(oe,{label:`Relay host`,id:`relay-target`,value:n,onValueChange:e=>r(e),options:D.map(e=>({value:e,label:U[e].label}))}),(0,H.jsx)(L,{label:v.tokenLabel,id:`relay-token`,type:`password`,value:c,placeholder:`Paste a deploy token`,onChange:e=>l(e.target.value)}),v.needsAccount?(0,H.jsx)(L,{label:`Account ID`,id:`relay-account`,value:u,placeholder:`Cloudflare account id`,onChange:e=>d(e.target.value)}):null,(0,H.jsx)(L,{label:`Project name (optional)`,id:`relay-project`,value:f,placeholder:`e.g. cartethyia-relay`,onChange:e=>m(e.target.value)}),v.hasRegion?(0,H.jsx)(oe,{label:`Deploy region`,id:`relay-region`,value:i,onValueChange:e=>a(e),options:Me}):null,v.hasRegion?(0,H.jsx)(`p`,{className:`text-badge text-text-tertiary m-0`,children:`Sets the region on the Vercel project, which is what decides the country outbound traffic leaves from. A region sent on the deployment alone is accepted but does not move the Function.`}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,H.jsx)(o,{variant:`primary`,size:`sm`,onClick:()=>{y&&t.mutate({target:n,token:c.trim(),...v.needsAccount&&u.trim()?{accountId:u.trim()}:{},...f.trim()?{projectName:f.trim()}:{},...v.hasRegion?{region:i}:{}},{onSuccess:e=>{g(e.relayUrl),l(``),s.success(`Relay deployed to ${e.relayUrl} and registered as a pool.`)},onError:e=>s.error(A(e,`Relay deploy failed.`))})},disabled:!y||t.isPending,children:t.isPending?`Deploying…`:`Deploy relay`}),h?(0,H.jsxs)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:[`Registered pool at `,(0,H.jsx)(`code`,{children:h})]}):null]}),t.isError?(0,H.jsxs)(`p`,{className:`text-badge text-red m-0 flex gap-3`,children:[(0,H.jsx)(p,{size:13,className:`shrink-0 mt-0.5`}),(0,H.jsx)(`span`,{children:A(t.error,`Relay deploy failed.`)})]}):null]})})}function Pe(e,t){if(e!==void 0)return e.endpoint===``||e.endpoint===(t??``)?e.result:void 0}function Fe(e,t,n){switch(t){case`name`:return(e.label||e.endpoint).toLowerCase();case`family`:return e.family===void 0||e.family===null||e.family===``?null:e.family.toLowerCase();case`address`:return e.egressIp??null;case`load`:return n??null}}function Ie(e,t,n,r){let i=n===`asc`?1:-1;return[...e].sort((e,n)=>{let a=Fe(e,t,r(e)),o=Fe(n,t,r(n));return a===null&&o===null?0:a===null?1:o===null?-1:typeof a==`number`&&typeof o==`number`?(a-o)*i:String(a).localeCompare(String(o))*i})}function W(e,t){let n=e.filter(e=>e.status===`active`),r=n.reduce((e,t)=>e+t.maxInflight,0),i=t===void 0?n.reduce((e,t)=>e+(t.inflight??0),0):n.reduce((e,n)=>e+(t.get(n.id)??0),0),a=0,o=0;for(let e of n)(t===void 0?e.inflight??0:t.get(e.id)??0)>=e.maxInflight?o+=1:a+=1;let s=null,c=Date.now(),l=e=>{if(!e)return;let t=Date.parse(e);if(Number.isNaN(t))return;let n=t-c;n<=0||(s===null||n<s)&&(s=n)};for(let t of e){l(t.cooldownUntil);for(let e of t.providerCooldowns??[])l(e.until)}let u=n.filter(e=>e.lastLatencyMs!==void 0&&Number.isFinite(e.lastLatencyMs)),d=u.length===0?null:Math.round(u.reduce((e,t)=>e+(t.lastLatencyMs??0),0)/u.length);return{totalPools:e.length,active:n.length,cooldown:e.filter(e=>e.status===`cooldown`).length,totalMaxConcurrency:r,usedInflight:i,availableCapacity:Math.max(0,r-i),routablePools:a,saturatedPools:o,soonestCooldownMs:s,avgLatencyMs:d,measuredPools:u.length}}var G=[`http`,`https`,`socks5`];function K(e){return/^[a-z][a-z0-9+.-]*:\/\//i.test(e.trim())}function Le(e,t){let n=e.trim();return t===null||K(n)?n:`${t}://${n}`}function q(e){return e.find(e=>e.trim()!==``)}function J(e){let t=e.trim().toLowerCase();return t.startsWith(`https://`)?`https`:t.startsWith(`socks5://`)||t.startsWith(`socks://`)?`socks5`:`http`}var Re=1024**3;function ze(e){let t=e.trim();if(t===``)return null;let n=Number(t);return!Number.isFinite(n)||n<=0?null:Math.max(1,Math.round(n*Re))}function Y(e,t,n){let r=new Map;if(t.trim().toLowerCase()===``||n<=0)return r;let i=Math.floor(e/n),a=e-i*n;for(let e=0;e<n;e+=1){let t=e===n-1?a:0;r.set(e,i+t)}return r}var Be=4,Ve=`cartethyia_proxy_test_payload`,He=`cartethyia_proxy_check_results`,Ue=[{value:`url`,label:`Test URL`},{value:`opencode`,label:`Test OpenCode`}],We=`opencode`,Ge=4,Ke=`Mysterious Proxy`;function X(e){return e.avgLatencyMs===null?`no measurement yet`:`avg across ${e.measuredPools} enabled ${e.measuredPools===1?`pool`:`pools`}`}function qe(e){let t=e.endpoint||``,n=t.includes(`://`)?t:`${e.kind}://${t}`,r={"https:":`443`,"http:":`80`,"socks5:":`1080`,"socks:":`1080`};try{let e=new URL(n),t=e.port||r[e.protocol]||``,i=`${e.hostname}${t?`:${t}`:``}`;return{name:i,endpoint:`${e.protocol}//${i}${e.pathname===`/`?``:e.pathname}${e.search}`}}catch{return{name:e.label||t,endpoint:t}}}function Z(e){return e.label||qe(e).name||e.id}var Q=1024**3;function Je(e){if(e.lastSpeedtestStatus===void 0||e.lastSpeedtestAt===void 0)return;let t=e.lastSpeedtestDurationMs??0,n=e.lastSpeedtestBytes??0,r=t>0?n/(t/1e3):void 0;return{poolId:e.id,status:e.lastSpeedtestStatus,bytes:n,durationMs:t,...r===void 0?{}:{bytesPerSecond:r,megabitsPerSecond:r*8/1e6},...e.lastSpeedtestError?{errorMessage:e.lastSpeedtestError}:{},measuredAt:e.lastSpeedtestAt}}function Ye(e,t){if(!e)return t;if(!t)return e;let n=e.measuredAt?new Date(e.measuredAt).getTime():0;return(t.measuredAt?new Date(t.measuredAt).getTime():0)>=n?t:e}var Xe=[{value:String(me),label:`1 MB`},{value:String(ge),label:`5 MB`},{value:`50000000`,label:`50 MB`},{value:String(he),label:`100 MB`}];function Ze({pool:e,onClose:t,actionsRef:n}){let r=Ce(),i=Oe(),l=ke(),[u,d]=(0,V.useState)(e.label??``),[f,p]=(0,V.useState)(e.family??``),[m,h]=(0,V.useState)(e.endpoint??``),[g,_]=(0,V.useState)(String(e.maxInflight??10)),[v,y]=(0,V.useState)(String(e.weight??100)),[b,x]=(0,V.useState)(e.quotaBytes?String(Math.round(e.quotaBytes/Q*1e3)/1e3):``),[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(!1),ee=m.trim()===e.endpoint,E=async()=>{T(!0),C(null);try{if(ee){let t=await l.mutateAsync(e.id),n=t.status===`healthy`||t.status===`reachable`;C({ok:n,message:t.status===`healthy`?`Connected in ${t.latencyMs??0}ms`:t.errorMessage??`Connection failed`});return}let t=[{kind:e.kind,endpoint:m.trim(),...e.family===null||e.family===void 0?{}:{family:e.family}}],[n]=await i.mutateAsync({providerId:We,targets:t}),r=n?.result;if(!r){C({ok:!1,message:`Probe returned no result`});return}let a=r.status===`allowed`||r.status===`throttled`;C({ok:a,message:r.reason??(r.status===`allowed`?`Reachable${r.latencyMs===void 0?``:` in ${r.latencyMs}ms`}`:r.status===`throttled`?`Reachable; rate limit spent`:`Probe could not complete`)})}catch(e){C({ok:!1,message:A(e,`Connection failed`)})}finally{T(!1)}},D=ze(b),O=async()=>{await r.mutateAsync({poolId:e.id,request:{...u.trim()===e.label?{}:{label:u.trim()||void 0},...f.trim()===(e.family??``)?{}:{family:f.trim()||null},...m.trim()!==e.endpoint&&m.trim()!==``?{endpoint:m.trim()}:{},...Number(g)===e.maxInflight?{}:{maxInflight:Number(g)},...Number(v)===e.weight?{}:{weight:Number(v)},...D===(e.quotaBytes??null)?{}:{quotaBytes:D}}}),s.success(`Proxy updated`),t()};return(0,V.useEffect)(()=>{n?.((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o,{variant:`secondary`,size:`sm`,onClick:t,children:`Cancel`}),(0,H.jsx)(o,{variant:`primary`,size:`sm`,disabled:r.isPending||!m.trim(),onClick:()=>void O(),children:`Save`})]}))}),(0,H.jsxs)(se,{gap:`12px`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(L,{label:`Name`,value:u,onChange:e=>d(e.target.value)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(L,{label:`Family`,value:f,placeholder:`e.g. residential-id`,onChange:e=>p(e.target.value)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(L,{label:`Endpoint`,value:m,onChange:e=>h(e.target.value),className:`font-mono tabular-nums`})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(L,{label:`Max concurrent`,type:`number`,min:1,value:g,onChange:e=>_(e.target.value)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(L,{label:`Weight`,type:`number`,min:1,value:v,onChange:e=>y(e.target.value)})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(L,{label:`Bandwidth quota (GB, blank = unmetered)`,type:`number`,min:.001,step:`0.1`,value:b,onChange:e=>x(e.target.value)}),(0,H.jsx)(`div`,{className:`text-micro text-text-tertiary mt-2`,children:D===null?`No quota — the bar shows a running total only.`:`Bar turns orange at 80% and red once ${F(D)} is exceeded.`})]}),S&&(0,H.jsx)(`div`,{className:`rounded-inset px-6 py-4 text-badge font-semibold ${S.ok?`bg-green-soft text-green`:`bg-red-soft text-red`}`,children:S.message}),(0,H.jsx)(`div`,{children:(0,H.jsx)(o,{variant:`secondary`,size:`sm`,disabled:w,icon:w?(0,H.jsx)(a,{size:13,className:`animate-spin`}):(0,H.jsx)(c,{size:13}),onClick:()=>void E(),children:w?`Testing…`:`Test connection`})})]})}function Qe({endpoint:e,chip:t,onChipChange:n}){return(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,role:`group`,"aria-label":`Scheme for the first endpoint`,children:[(0,H.jsx)(`span`,{className:`text-badge text-text-secondary`,children:`Scheme`}),G.map(r=>{let i=t===r;return(0,H.jsxs)(o,{type:`button`,variant:i?`primary`:`secondary`,size:`sm`,disabled:e===void 0,"aria-pressed":i,"data-scheme":r,onClick:()=>n(i?null:r),className:`font-mono`,children:[r,`://`]},r)}),t!==null&&(0,H.jsxs)(`span`,{className:`text-badge text-text-tertiary`,children:[`→ `,Le(e??``,t)]})]})}function $e({onClose:e,actionsRef:t,onProbeResult:n,onHealthResult:r}){let i=be(),a=Se(),c=Oe(),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)([]),[y,b]=(0,V.useState)({}),[x,S]=(0,V.useState)({}),[C,w]=(0,V.useState)(!1),[T,ee]=(0,V.useState)(null),E=l.split(`
2
- `).map(e=>e.trim()).filter(Boolean),D=q(E),O=(0,V.useMemo)(()=>T===null||D===void 0?E:E.map((e,t)=>e===D&&t===0?Le(e,T):e),[E,T,D]),k=E.length>100,j=ze(p),M=(0,V.useMemo)(()=>O.map(e=>({kind:J(e),endpoint:e})),[O]),N=async()=>{try{let e=await navigator.clipboard.readText();e&&u(t=>t?`${t}\n${e}`:e)}catch{s.error(`Paste failed`,`Clipboard access denied`)}},te=async()=>{if(M.length!==0){v([`Testing ${M.length} proxy target(s)…`]);try{let e=await a.mutateAsync(M),t=e.map(e=>{let t=e.result.status===`healthy`||e.result.status===`reachable`,n=e.result.latencyMs===void 0?``:` · ${e.result.latencyMs}ms`,r=e.result.egressIp?` · ${e.result.egressIp}`:``,i=t?``:` · ${e.result.errorMessage??e.result.status}`;return`${t?`OK `:`FAIL`} ${e.endpoint}${n}${r}${i}`}),n=e.filter(e=>e.result.status===`healthy`||e.result.status===`reachable`).length;S(t=>{let n={...t};for(let t of e)n[t.endpoint]=t.result;return n}),v([`${n}/${e.length} reachable`,...t]),n===e.length?s.success(`All ${e.length} proxies reachable`):s.error(`${e.length-n} of ${e.length} proxies failed`)}catch(e){v([`Test failed: ${A(e,`batch probe failed`)}`]),s.error(`Test failed`,A(e,`batch probe failed`))}}},P=async()=>{if(M.length!==0){v([`Testing ${M.length} proxy target(s) against OpenCode…`]);try{let e=await c.mutateAsync({providerId:We,targets:M}),t=e.map(e=>{let{status:t,latencyMs:n,reason:r}=e.result,i=n===void 0?``:` · ${n}ms`,a=r===void 0?``:` · ${r}`;return`${t===`allowed`?`OK `:t===`blocked`?`BLOCK`:`FAIL`} ${e.endpoint}${i}${a}`});b(t=>{let n={...t};for(let t of e)n[t.endpoint]=t.result;return n});let n=e.filter(e=>e.result.status===`allowed`).length,r=e.filter(e=>e.result.status===`blocked`).length;v([`${n}/${e.length} allowed · ${r} blocked`,...t]),r===0&&n===e.length?s.success(`OpenCode accepted all ${e.length} proxies`):s.error(`OpenCode: ${n} allowed · ${r} blocked`)}catch(e){v([`Test failed: ${A(e,`provider probe failed`)}`]),s.error(`Test failed`,A(e,`provider probe failed`))}}};return(0,V.useEffect)(()=>{t?.((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o,{variant:`secondary`,type:`button`,onClick:e,children:`Cancel`}),(0,H.jsx)(o,{variant:`primary`,type:`submit`,form:`add-proxy-form`,disabled:C||E.length===0,children:C?`Adding…`:`Add ${E.length} Prox${E.length===1?`y`:`ies`}`})]}))},[t,C,E.length,e]),(0,H.jsxs)(`form`,{id:`add-proxy-form`,onSubmit:async t=>{if(t.preventDefault(),E.length!==0){g(null),w(!0);try{let t=j===null?new Map:Y(j,d,O.length),a=Array(E.length),o=0,c=async()=>{for(;o<E.length;){let e=o++,s=O[e];try{let o=await i.mutateAsync({kind:J(s),endpoint:s,...t.has(e)?{quotaBytes:t.get(e)}:{},...d.trim()===``?{}:{family:d.trim()}}),c=y[s],l=x[s];o?.id&&(l!==void 0&&r?.(o.id,l),c!==void 0&&n?.(o.id,c)),a[e]={ok:!0}}catch(t){a[e]={ok:!1,error:A(t,`Proxy pool creation failed`)}}}};await Promise.all(Array.from({length:Math.min(Be,E.length)},()=>c()));let l=[],f=0;for(let[e,t]of a.entries())t.ok?f++:l.length<3&&l.push(`${E[e].slice(0,48)}…: ${t.error}`);let p=E.length-f,m=a.find(e=>!e.ok)?.error;f>0&&s.success(`Added ${f} proxy pool(s)`,p?`${p} failed: ${m??`see the import details`}`:void 0),p>0&&f===0&&s.error(`Failed to create pool`,m??`See the import details`),p>0&&g(l.join(`
3
- `)),f>0&&(u(``),e())}finally{w(!1)}}},className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`label`,{htmlFor:`proxy-endpoints`,className:`text-caption font-semibold text-text-primary`,children:`Proxy endpoints`}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,type:`button`,onClick:N,children:`Paste`})]}),(0,H.jsx)(`textarea`,{id:`proxy-endpoints`,value:l,onChange:e=>u(e.target.value),placeholder:`http://proxy.example:8080
4
- https://proxy.example:8443
5
- socks5://proxy.example:1080`,rows:5,"aria-describedby":`proxy-format-hint proxy-line-count`,"aria-invalid":!!h,className:`w-full min-h-32 max-h-64 resize-y overflow-y-auto rounded-control border border-inner-border bg-surface-1 p-3 font-mono text-caption text-text-primary outline-none transition-[border-color,box-shadow] duration-(--dur-micro) ease-spring focus:border-accent focus:shadow-focus`}),(0,H.jsx)(Qe,{endpoint:D,chip:T,onChipChange:ee}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,H.jsx)(`p`,{id:`proxy-format-hint`,className:`m-0 text-badge leading-normal text-text-secondary`,children:`HTTP, HTTPS, or SOCKS5 | one per line | authentication optional`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsxs)(`span`,{id:`proxy-line-count`,role:`status`,"aria-live":`polite`,className:`text-badge ${k?`text-red`:`text-text-tertiary`}`,children:[E.length===1?`1 proxy detected`:`${E.length} proxies detected`,k?` · max 100 per test`:``]}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,type:`button`,onClick:()=>void te(),disabled:a.isPending||c.isPending||E.length===0||k,children:a.isPending?`Testing…`:`Test URL`}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,type:`button`,onClick:()=>void P(),disabled:a.isPending||c.isPending||E.length===0||k,children:c.isPending?`Testing…`:`Test OpenCode`})]})]}),h&&(0,H.jsx)(`div`,{role:`alert`,className:`max-h-28 overflow-y-auto rounded-inset bg-red-soft px-4 py-3 text-badge text-red whitespace-pre-wrap break-words`,children:h}),_.length>0&&(0,H.jsx)(`div`,{role:`log`,"aria-label":`Proxy test results`,"aria-live":`polite`,className:`scroll-region max-h-40 overflow-y-auto whitespace-pre-wrap break-all rounded-inset border border-inner-border bg-surface-1 px-3 py-2 font-mono text-badge leading-[1.5] text-text-secondary`,children:_.join(`
6
- `)}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(L,{id:`proxy-family`,label:`Family`,hint:`Optional`,value:d,placeholder:`e.g. residential-id`,onChange:e=>f(e.target.value),className:`w-full`}),(0,H.jsx)(L,{id:`proxy-quota`,label:`Bandwidth quota (GB)`,hint:`Optional`,type:`number`,min:.001,step:`0.1`,value:p,onChange:e=>m(e.target.value),className:`w-full`})]})]})}function et(e,t){if(t?.status===`healthy`||t?.status===`reachable`)return t.latencyMs;if(e.lastSuccessAt)return e.lastLatencyMs??void 0}function tt(e){if(e===`proxy_payment_required`)return`HTTP 402 Payment Required`;if(e===`proxy_auth_required`)return`HTTP 407 Proxy Authentication Required`}var $=(0,V.createContext)({byId:new Map,live:!1});function nt({children:e}){let t=B(),n=(0,V.useMemo)(()=>new Map((t.pools??[]).map(e=>[e.poolId,e])),[t.pools]),r=(0,V.useMemo)(()=>({byId:n,live:t.live&&t.pools!==null}),[n,t.live,t.pools]);return(0,H.jsx)($.Provider,{value:r,children:e})}function rt({pools:e}){let{byId:t,live:n}=(0,V.useContext)($),r=(0,V.useMemo)(()=>W(e,n?new Map([...t].map(([e,t])=>[e,t.currentInflight])):void 0),[e,t,n]),a=(0,V.useMemo)(()=>{let r=0,i=0;for(let a of e){let e=n?t.get(a.id):void 0,o=(a.bytesSentTotal??0)+(a.bytesReceivedTotal??0),s=(e?.bytesSent??0)+(e?.bytesReceived??0);r+=Math.max(o,s),a.quotaBytes&&(i+=a.quotaBytes)}return{used:r,allowance:i}},[e,t,n]);return(0,H.jsxs)(`div`,{className:`signal-grid grid gap-7 w-full min-w-0 mb-7`,children:[(0,H.jsx)(z,{label:`Enabled pool`,value:String(r.active),detail:`/ ${r.totalPools} total`,tone:`accent`,icon:(0,H.jsx)(S,{size:13})}),(0,H.jsx)(z,{label:`Route capacity`,value:String(r.totalMaxConcurrency),detail:`${r.usedInflight} inflight · ${r.availableCapacity} available`,tone:r.availableCapacity===0?`orange`:`teal`,icon:(0,H.jsx)(f,{size:13})}),(0,H.jsx)(z,{label:`Latency`,value:r.avgLatencyMs===null?`—`:`${r.avgLatencyMs}ms`,detail:X(r),tone:r.avgLatencyMs===null?`accent`:r.avgLatencyMs>2e3?`orange`:`teal`,icon:(0,H.jsx)(i,{size:13})}),(0,H.jsx)(z,{label:`Quota usage`,value:F(a.used),detail:a.allowance>0?`of ${F(a.allowance)} allowance · ${e.length} pools`:`${e.length} pools · no allowance set`,tone:a.allowance>0&&a.used>a.allowance?`red`:a.allowance>0&&a.used/a.allowance>=.8?`orange`:`teal`,icon:(0,H.jsx)(fe,{size:13})})]})}function it(e,t,n,r,i){let a=qe(e),o=Z(e),s=e.status!==`disabled`,c=tt(e.lastErrorCategory),l=e.status===`disabled`&&c!==void 0,u=e.lastSuccessAt?new Date(e.lastSuccessAt).getTime():0,d=e.lastErrorAt?new Date(e.lastErrorAt).getTime():0,f=!t&&(u>0||d>0)?u>=d:null,p=n?`default`:l?`warn`:t?t.status===`healthy`?`ok`:t.status===`reachable`?`warn`:`err`:f===!0?`ok`:f===!1?`err`:`default`,m=l?e.lastError??c:t?.errorMessage??(f===null?void 0:`last check ${(e.lastHealthCheckAt?new Date(e.lastHealthCheckAt):new Date).toLocaleString()}`),h=et(e,t),g=r?.currentInflight??e.inflight,_=e.maxInflight>0?Math.min(1,g/e.maxInflight):1,v=e.providerCooldowns??[],y=v.filter(e=>e.blocked===!0),b=v.filter(e=>e.blocked!==!0),x=v.slice(0,2).map(e=>e.blocked===!0?`${e.providerId} blocked: ${e.reason}`:`${e.providerId} until ${new Date(e.until).toLocaleTimeString()}: ${e.reason}`).join(` · `),S=n?`Testing…`:l?`Proxy reachable`:t?t.status===`healthy`?`Connected`:t.status===`reachable`?`Proxy reachable`:t.status===`timeout`?`Timeout`:`Unhealthy`:f===!0?`Connected`:f===!1?e.lastErrorCategory===`timeout`?`Timeout`:`Unhealthy`:`Untested`,C=(e.bytesSentTotal??0)+(e.bytesReceivedTotal??0),w=(r?.bytesSent??0)+(r?.bytesReceived??0);return{display:a,poolLabel:o,isEnabled:s,checkTone:p,checkTooltip:m,statusText:S,latency:h,inflight:g,load:_,cooldowns:v,blocked:y,cooldownOnly:b,cooldownText:x,...i===void 0?{}:{probe:i},metered:C,session:w,used:Math.max(C,w),proxyFailureLabel:c}}function at({pool:e,view:t,maskValues:n}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`block text-caption font-semibold overflow-hidden truncate whitespace-nowrap`,title:n?Ke:t.poolLabel,children:n?Ke:t.poolLabel}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 min-w-0 flex-wrap`,children:[e.status===`disabled`?(0,H.jsxs)(I,{tone:`disabled`,title:e.lastError,children:[`Disabled`,t.proxyFailureLabel?` · ${t.proxyFailureLabel}`:``]}):(0,H.jsx)(I,{tone:t.checkTone,title:t.checkTooltip,children:t.latency===void 0?t.statusText:`${t.statusText} · ${t.latency}ms`}),t.blocked.length>0?(0,H.jsxs)(I,{tone:`disabled`,title:t.cooldownText,children:[t.blocked.length,` blocked`]}):null,t.probe?(0,H.jsx)(I,{tone:t.probe.status===`blocked`?`disabled`:t.probe.status===`allowed`?`ok`:`warn`,title:t.probe.reason??(t.probe.status===`allowed`?t.probe.httpStatus!==void 0&&t.probe.httpStatus>=400?`Reachable — upstream answered ${t.probe.httpStatus} for the probe body`:`OpenCode served a probe through this pool`:t.probe.status===`throttled`?`OpenCode accepted this egress; the rate is spent`:`The probe could not complete`),children:t.probe.status===`blocked`?`OpenCode blocked`:t.probe.status===`allowed`?t.probe.httpStatus!==void 0&&t.probe.httpStatus>=400?`OpenCode reachable`:`OpenCode OK`:t.probe.status===`throttled`?`OpenCode rate-limited`:`OpenCode unreachable`}):null,t.cooldownOnly.length>0?(0,H.jsxs)(I,{tone:`warn`,title:t.cooldownText,children:[t.cooldownOnly.length,` cooldown`,t.cooldownOnly.length>1?`s`:``]}):null]})]})}function ot({pool:e,view:t,speedResult:n,isSpeedTesting:r,maskIp:i}){return(0,H.jsxs)(H.Fragment,{children:[e.egressIp?(0,H.jsx)(`span`,{className:`font-mono tabular-nums block overflow-hidden text-ellipsis whitespace-nowrap text-badge`,title:i?`IP masked`:`egress ${e.egressIp} · ${t.display.endpoint}`,children:i?`IP masked`:e.egressIp}):(0,H.jsx)(`span`,{className:`text-badge text-text-tertiary`,title:`Test the pool to read its egress address`,children:`not probed`}),(r||n)&&(0,H.jsx)(`div`,{className:`mt-1.5`,children:(0,H.jsx)(I,{tone:r?`default`:n?.status===`ok`?`ok`:`err`,title:r?`Measuring download throughput`:n?.status===`ok`?`${F(n.bytes)} in ${n.durationMs}ms${n.measuredAt?` · last measured ${new Date(n.measuredAt).toLocaleString()}`:``}`:`${n?.errorMessage??`Speed test failed`}${n?.measuredAt?` · last measured ${new Date(n.measuredAt).toLocaleString()}`:``}`,children:r?`Speed…`:n?.status===`ok`?`${(n.megabitsPerSecond??0).toFixed(1)} Mbps`:`Speed failed`})})]})}function st({pool:e,view:t}){let n=e.quotaBytes,r=n&&n>0?Math.min(1,t.used/n):0,i=n!==void 0&&n>0&&t.used>n;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{title:`${t.inflight}/${e.maxInflight} inflight`,className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`flex-1 h-3 rounded-micro overflow-hidden`,children:(0,H.jsx)(`div`,{className:`h-full rounded-micro`,style:{width:`${Math.round(t.load*100)}%`,background:t.load>=.8?`var(--orange)`:`var(--green)`}})}),(0,H.jsxs)(`span`,{className:`font-mono tabular-nums text-micro text-text-secondary whitespace-nowrap`,children:[t.inflight,`/`,e.maxInflight]})]}),(0,H.jsxs)(`div`,{title:n?`${F(t.used)} of ${F(n)} used · ${F(t.metered)} metered lifetime`:`${F(t.used)} carried (no quota set) · ${F(t.session)} this session`,className:`flex items-center gap-3 mt-2`,children:[(0,H.jsx)(`div`,{className:`flex-1 h-3 rounded-micro overflow-hidden`,children:(0,H.jsx)(`div`,{className:`h-full rounded-micro`,style:{width:`${Math.round(r*100)}%`,background:i?`var(--red)`:r>=.8?`var(--orange)`:`var(--teal)`}})}),(0,H.jsxs)(`span`,{className:`font-mono tabular-nums whitespace-nowrap text-micro ${i?`text-red`:`text-text-secondary`}`,children:[F(t.used),n?` / ${F(n)}`:``]})]})]})}function ct({pool:e,view:t,isTesting:n,onDelete:r,onEdit:s,onHealthCheck:l,onActivity:u}){let d=Ce(),f=je(),p=Te();return(0,H.jsxs)(H.Fragment,{children:[t.cooldowns.length>0&&(0,H.jsx)(o,{size:`icon`,variant:`secondary`,disabled:f.isPending,icon:f.isPending?(0,H.jsx)(a,{size:12,className:`animate-spin`}):(0,H.jsx)(x,{size:12}),onClick:()=>f.mutate({poolId:e.id}),title:`Clear provider cooldowns — ${t.cooldownText}`,label:`Clear`}),(0,H.jsx)(o,{size:`icon`,variant:`secondary`,icon:(0,H.jsx)(i,{size:12}),onClick:()=>u(e),title:`Health and error activity`,label:`Activity`}),e.status===`cooldown`&&(0,H.jsx)(o,{size:`icon`,variant:`secondary`,disabled:p.isPending,icon:(0,H.jsx)(x,{size:12,className:p.isPending?`animate-spin`:``}),onClick:()=>p.mutate(e.id),title:`Recover pool`,children:`Recover`}),!(!t.isEnabled&&t.cooldowns.length>0)&&(0,H.jsx)(o,{size:`icon`,variant:`secondary`,disabled:n,icon:n?(0,H.jsx)(a,{size:12,className:`animate-spin`}):(0,H.jsx)(c,{size:12}),onClick:()=>l(e),title:t.checkTooltip??`Run health check`,label:`Test`}),(0,H.jsx)(o,{size:`icon`,variant:`secondary`,icon:(0,H.jsx)(v,{size:12}),onClick:()=>s(e),title:`Edit pool`,label:`Edit`}),(0,H.jsx)(o,{size:`icon`,variant:`secondary`,icon:(0,H.jsx)(C,{size:12}),onClick:()=>r(e.id),title:`Delete pool`,label:`Delete`}),(0,H.jsx)(R,{className:`ml-3`,checked:t.isEnabled,disabled:d.isPending,onChange:t=>d.mutate({poolId:e.id,request:{status:t?`active`:`disabled`}})})]})}var lt=(0,V.memo)(function({pool:e,isSelected:t,onToggleSelect:n,checkResult:r,isTesting:i,onDelete:a,onEdit:o,onHealthCheck:s,onActivity:c,speedResult:l,isSpeedTesting:u,maskValues:d,maskIp:f,probe:p}){let m=(0,V.useContext)($),h=it(e,r,i,(m.live?m.byId.get(e.id):void 0)??null,p);return(0,H.jsxs)(`tr`,{className:h.isEnabled?``:`opacity-60`,children:[(0,H.jsx)(`td`,{className:`w-13`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>n(e.id),"aria-label":`Select ${h.poolLabel}`})}),(0,H.jsx)(`td`,{className:`min-w-0 max-w-150`,children:(0,H.jsx)(at,{pool:e,view:h,maskValues:d})}),(0,H.jsx)(`td`,{className:`min-w-0 max-w-90`,children:e.family?(0,H.jsx)(`span`,{className:`truncate text-caption font-semibold text-text-secondary`,title:e.family,children:e.family}):(0,H.jsx)(`span`,{className:`text-badge text-text-tertiary`,children:`—`})}),(0,H.jsx)(`td`,{className:`max-w-110`,children:(0,H.jsx)(ot,{pool:e,view:h,speedResult:l,isSpeedTesting:u,maskIp:f})}),(0,H.jsx)(`td`,{className:`min-w-55`,children:(0,H.jsx)(st,{pool:e,view:h})}),(0,H.jsx)(`td`,{className:`whitespace-nowrap pl-36 text-right`,children:(0,H.jsx)(ce,{gap:`4px`,justify:`end`,children:(0,H.jsx)(ct,{pool:e,view:h,isTesting:i,onDelete:a,onEdit:o,onHealthCheck:s,onActivity:c})})})]})});function ut({pool:e,onClose:t}){let n=we(e.id),r=Te(),i=n.data??[],a=tt(e.lastErrorCategory),s=e.status===`disabled`&&a!==void 0,c=e.status===`active`?`ok`:e.status===`disabled`?`disabled`:`warn`;return(0,H.jsx)(_,{open:!0,onClose:t,title:`Health & Activity — ${Z(e)}`,children:(0,H.jsxs)(se,{gap:`14px`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-8 rounded-panel border bg-surface-2 p-8 ${s?`border-orange`:`border-inner-border`}`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`mb-2.5 text-text-tertiary text-micro font-bold tracking-label uppercase`,children:`Proxy health`}),(0,H.jsx)(`div`,{className:`text-title font-bold leading-[1.3]`,children:s?`Proxy reachable`:`Proxy ${e.status}`}),(0,H.jsx)(`p`,{className:`mt-3 mx-0 mb-0 text-text-secondary text-caption leading-normal wrap-anywhere`,children:s?`${a} · disabled from routing`:e.lastError??`No recent proxy errors.`})]}),(0,H.jsx)(I,{tone:c,dot:!0,children:e.status})]}),e.status===`cooldown`&&(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(o,{size:`sm`,variant:`secondary`,disabled:r.isPending,onClick:()=>r.mutate(e.id),icon:(0,H.jsx)(x,{size:12,className:r.isPending?`animate-spin`:``}),children:`Recover Now`})}),n.isPending?(0,H.jsx)(h,{label:`Loading pool activity…`}):null,n.isError?(0,H.jsx)(m,{message:`Failed to load pool activity`,onRetry:()=>void n.refetch()}):null,!n.isPending&&!n.isError&&i.length===0?(0,H.jsx)(g,{title:`No pool activity`,message:`Proxy checks, disable events, and recoveries will appear here.`}):null,i.length>0?(0,H.jsx)(`div`,{className:`grid gap-4 max-h-190 overflow-y-auto pr-1`,children:i.map(e=>(0,H.jsxs)(`div`,{className:`p-6 border border-inner-border rounded-control bg-surface-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,H.jsxs)(ce,{gap:`6px`,children:[(0,H.jsxs)(I,{tone:e.toStatus===`active`?`ok`:e.toStatus===`disabled`?`disabled`:`warn`,children:[e.fromStatus??`new`,` → `,e.toStatus]}),e.errorCategory?(0,H.jsx)(I,{tone:e.errorCategory.startsWith(`proxy_`)?`warn`:`err`,children:e.errorCategory}):null]}),(0,H.jsx)(`time`,{className:`text-text-tertiary text-badge tabular-nums`,children:new Date(e.createdAt).toLocaleString()})]}),(0,H.jsx)(`p`,{className:`mt-4 mx-0 mb-0 text-text-secondary text-caption leading-normal wrap-anywhere`,children:e.reason??`No additional details`})]},e.id))}):null]})})}function dt(){let e=ye(),t=Ee(),n=Ce(),r=ke(),[i,p]=(0,V.useState)(!1),v=(0,V.useCallback)(()=>p(!1),[]),[x,w]=(0,V.useState)(null),[T,ee]=(0,V.useState)(null),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(null),[j,M]=(0,V.useState)(new Set),N=ue(),P=N.enabled,F=de(),L=F.enabled,[R,z]=(0,V.useState)(new Set),[B,me]=(0,V.useState)(()=>{try{return localStorage.getItem(Ve)===`opencode`?`opencode`:`url`}catch{return`url`}});(0,V.useEffect)(()=>{try{localStorage.setItem(Ve,B)}catch{}},[B]);let[he,_e]=(0,V.useState)(new Set),[ve,be]=(0,V.useState)({}),xe=De(),Se=Ae(),[we,Te]=(0,V.useState)(ge),[Oe,je]=(0,V.useState)(()=>{try{let e=localStorage.getItem(`cartethyia_proxy_speed_results`);return e?JSON.parse(e):{}}catch{return{}}}),[U,Me]=(0,V.useState)(new Set),Fe=(0,V.useCallback)((e,t)=>{let n={...t,measuredAt:new Date().toISOString()};je(t=>{let r={...t,[e]:n};try{localStorage.setItem(`cartethyia_proxy_speed_results`,JSON.stringify(r))}catch{}return r})},[]),[W,G]=(0,V.useState)(()=>{try{let e=localStorage.getItem(He);return e?JSON.parse(e):{}}catch{return{}}}),[K,Le]=(0,V.useState)({key:`name`,direction:`asc`}),[q,J]=(0,V.useState)(null),[Re,ze]=(0,V.useState)(null),Y=e.data??[],Be=(0,V.useMemo)(()=>Ie(Y,K.key,K.direction,e=>et(e,W[e.id])),[Y,K,W]),Ke=(0,V.useCallback)(e=>{let t=e;Le(e=>e.key===t?{key:t,direction:e.direction===`asc`?`desc`:`asc`}:{key:t,direction:`asc`})},[]),X=e.isPending,Q=e.isError,Qe=Y.length>0&&Y.every(e=>j.has(e.id)),tt=()=>{M(Qe?new Set:new Set(Y.map(e=>e.id)))},$=(0,V.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);(0,V.useEffect)(()=>{try{localStorage.setItem(He,JSON.stringify(W))}catch{}},[W]);let it=Object.values(W),at=it.length,ot=it.filter(e=>e.status===`healthy`||e.status===`reachable`).length,st=it.filter(e=>e.status!==`healthy`&&e.status!==`reachable`).length,ct=(0,V.useCallback)(e=>{z(t=>new Set(t).add(e.id)),r.mutate(e.id,{onSuccess:t=>{G(n=>({...n,[e.id]:t}));let n=Z(e);t.status===`healthy`?s.success(`${n}: connected`,`${t.latencyMs??0}ms`):t.status===`reachable`?s.error(`${n}: proxy reachable · disabled`,t.errorMessage):s.error(`${n}: ${t.status===`timeout`?`timeout`:`unhealthy`}`,t.errorMessage)},onError:t=>{let n=Z(e);s.error(`${n}: check failed`,A(t,`Health check failed`))},onSettled:()=>{z(t=>{let n=new Set(t);return n.delete(e.id),n})}})},[r]),dt=async()=>{let e=Y;if(e.length===0)return;let t=0,n=0,i=0,a=async()=>{for(;;){let a=e[i++];if(!a)return;z(e=>new Set(e).add(a.id));try{let e=await r.mutateAsync(a.id);G(t=>({...t,[a.id]:e})),e.status===`healthy`?t+=1:n+=1}catch(e){n+=1;let t={poolId:a.id,status:`timeout`,errorMessage:A(e,`Health check failed`)};G(e=>({...e,[a.id]:t}))}finally{z(e=>{let t=new Set(e);return t.delete(a.id),t})}}};await Promise.all(Array.from({length:Math.min(8,e.length)},()=>a())),s.success(`Tested ${e.length} pools · ${t} healthy · ${n} failed`)},ft=async()=>{let e=Y.filter(e=>j.has(e.id));if(e.length===0)return;let t=0,n=0,i=0,a=async()=>{for(;;){let a=e[i++];if(!a)return;z(e=>new Set(e).add(a.id));try{let e=await r.mutateAsync(a.id);G(t=>({...t,[a.id]:e})),e.status===`healthy`?t+=1:n+=1}catch(e){n+=1;let t={poolId:a.id,status:`timeout`,errorMessage:A(e,`Health check failed`)};G(e=>({...e,[a.id]:t}))}finally{z(e=>{let t=new Set(e);return t.delete(a.id),t})}}};await Promise.all(Array.from({length:Math.min(8,e.length)},()=>a())),s.success(`Tested ${e.length} pools · ${t} healthy · ${n} failed`)},pt=async()=>{let e=Y.filter(e=>j.has(e.id));if(e.length===0)return;let t=0,n=0,r=0,i=0,a=0,o=async()=>{for(;;){let o=e[a++];if(!o)return;_e(e=>new Set(e).add(o.id));try{let e=await xe.mutateAsync({poolId:o.id,providerId:We});be(t=>({...t,[o.id]:{endpoint:o.endpoint??``,result:e}})),e.status===`allowed`?t+=1:e.status===`blocked`?n+=1:e.status===`throttled`?r+=1:i+=1}catch(e){i+=1,be(t=>({...t,[o.id]:{endpoint:o.endpoint??``,result:{poolId:o.id,providerId:We,status:`unreachable`,reason:A(e,`Provider probe failed`)}}}))}finally{_e(e=>{let t=new Set(e);return t.delete(o.id),t})}}};await Promise.all(Array.from({length:Math.min(Ge,e.length)},()=>o())),s.success(`OpenCode: ${t} allowed · ${n} blocked`+(r>0?` · ${r} rate-limited`:``)+(i>0?` · ${i} unreachable`:``))},mt=async()=>{let e=Y.filter(e=>j.has(e.id));if(e.length===0)return;let t=0;await(async()=>{for(;;){let n=e[t++];if(!n)return;Me(e=>new Set(e).add(n.id));try{let e=await Se.mutateAsync({poolId:n.id,bytes:we});Fe(n.id,e)}catch(e){Fe(n.id,{poolId:n.id,status:`failed`,bytes:0,durationMs:0,errorMessage:A(e,`Speed test failed`)})}finally{Me(e=>{let t=new Set(e);return t.delete(n.id),t})}}})(),s.success(`Speed tested ${e.length} pool(s)`)},ht=async()=>{let e=Y.filter(e=>j.has(e.id));e.length!==0&&(await Promise.all(e.map(e=>n.mutateAsync({poolId:e.id,request:{status:`active`}}))),M(new Set),s.success(`Enabled ${e.length} pool(s)`))},gt=async()=>{let e=Y.filter(e=>j.has(e.id));e.length!==0&&(await Promise.all(e.map(e=>n.mutateAsync({poolId:e.id,request:{status:`disabled`}}))),M(new Set),s.success(`Disabled ${e.length} pool(s)`))},_t=()=>{let e=j.size>0?Y.filter(e=>j.has(e.id)):Y;if(e.length===0)return;let t=e.map(e=>qe(e).endpoint||e.endpoint).join(`
7
- `);ae(`cartethyia-proxies.txt`,t,`text/plain;charset=utf-8`),s.success(`Exported ${e.length} pool(s)`)},vt=(0,V.useCallback)(e=>{let t=Y.find(t=>t.id===e);t&&J([t])},[Y]);return(0,H.jsx)(nt,{children:(0,H.jsxs)(se,{gap:`16px`,children:[(0,H.jsx)(_,{open:i,onClose:v,title:`Add Proxy`,footer:x,children:(0,H.jsx)($e,{onClose:v,actionsRef:w,onProbeResult:(e,t)=>{let n=Y.find(t=>t.id===e);be(r=>({...r,[e]:{endpoint:n?.endpoint??``,result:t}}))},onHealthResult:(e,t)=>{G(n=>({...n,[e]:t}))}})}),(0,H.jsx)(_,{open:O!==null,onClose:()=>k(null),title:`Edit pool`,footer:T,children:O&&(0,H.jsx)(Ze,{pool:O,onClose:()=>k(null),actionsRef:ee},O.id)}),(0,H.jsxs)(ie,{style:Y.length===0&&!X&&!Q?{minHeight:`min(78dvh, calc(100dvh - 160px))`,display:`flex`,flexDirection:`column`}:void 0,children:[(0,H.jsx)(re,{title:`Proxy Pool`,subtitle:`Outbound proxy servers — HTTP, HTTPS, and SOCKS5`,icon:(0,H.jsx)(S,{size:16}),action:(0,H.jsxs)(ce,{gap:`8px`,children:[(0,H.jsx)(o,{variant:`secondary`,size:`sm`,icon:(0,H.jsx)(fe,{size:13}),onClick:()=>D(!0),children:`Deploy relay`}),(0,H.jsx)(o,{variant:`primary`,size:`sm`,icon:(0,H.jsx)(y,{size:13}),onClick:()=>p(!0),children:`Add proxies`})]})}),(0,H.jsxs)(ne,{style:Y.length===0&&!X&&!Q?{flex:1,display:`flex`,flexDirection:`column`,gap:`16px`}:void 0,children:[(0,H.jsx)(rt,{pools:Y}),Y.length>0&&(0,H.jsxs)(`div`,{className:`nested-panel flex flex-wrap items-center justify-start overflow-x-auto rounded-card border border-inner-border bg-surface-2 p-4 text-badge`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,H.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer text-text-secondary`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:Qe,onChange:tt,"aria-label":`Select all proxies`}),`Select all`,j.size>0&&(0,H.jsxs)(`span`,{className:`text-text-tertiary`,children:[`(`,j.size,`)`]})]}),at>0&&(0,H.jsxs)(ce,{gap:`6px`,children:[(0,H.jsxs)(`span`,{className:`text-text-tertiary`,children:[`Tested `,at,`/`,Y.length]}),ot>0&&(0,H.jsxs)(I,{tone:`ok`,children:[ot,` success`]}),st>0&&(0,H.jsxs)(I,{tone:`err`,children:[st,` errors`]})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(o,{variant:`ghost`,size:`sm`,icon:P?(0,H.jsx)(u,{size:12}):(0,H.jsx)(d,{size:12}),onClick:()=>N.setEnabled(!P),title:P?`Show proxy names and addresses`:`Hide proxy names and addresses`,children:P?`Unmask`:`Mask`}),(0,H.jsx)(o,{variant:`ghost`,size:`sm`,icon:L?(0,H.jsx)(u,{size:12}):(0,H.jsx)(d,{size:12}),onClick:()=>F.setEnabled(!L),title:L?`Show egress addresses`:`Hide egress addresses`,children:L?`Show IP`:`Mask IP`}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,disabled:R.size>0||Y.length===0,icon:R.size>0?(0,H.jsx)(a,{size:12,className:`animate-spin`}):(0,H.jsx)(c,{size:12}),onClick:()=>void dt(),children:`Test all`}),(0,H.jsxs)(`div`,{className:`inline-flex items-stretch h-15`,children:[(0,H.jsx)(o,{variant:`secondary`,size:`sm`,className:`rounded-tr-none rounded-br-none`,disabled:R.size>0||he.size>0||j.size===0,icon:R.size>0||he.size>0?(0,H.jsx)(a,{size:12,className:`animate-spin`}):(0,H.jsx)(c,{size:12}),onClick:()=>void(B===`opencode`?pt():ft()),children:B===`opencode`?`Test OpenCode`:`Test URL`}),(0,H.jsx)(oe,{"aria-label":`Test payload`,value:B,onValueChange:e=>me(e),options:Ue,disabled:R.size>0||he.size>0,className:`w-auto min-w-38 h-15 rounded-tl-none rounded-bl-none -ml-0.5`})]}),(0,H.jsxs)(`div`,{className:`inline-flex items-stretch h-15`,children:[(0,H.jsx)(o,{variant:`secondary`,size:`sm`,className:`rounded-tr-none rounded-br-none`,disabled:j.size===0||U.size>0||Se.isPending,icon:U.size>0?(0,H.jsx)(a,{size:12,className:`animate-spin`}):(0,H.jsx)(f,{size:12}),onClick:()=>void mt(),children:`Speedtest selected`}),(0,H.jsx)(oe,{"aria-label":`Speed test payload size`,value:String(we),onValueChange:e=>Te(Number(e)),options:Xe,disabled:U.size>0||Se.isPending,className:`w-auto min-w-38 h-15 rounded-tl-none rounded-bl-none -ml-0.5`})]}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,disabled:Y.length===0,icon:(0,H.jsx)(l,{size:12}),onClick:_t,children:`Export`}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,disabled:j.size===0||n.isPending,icon:(0,H.jsx)(pe,{size:12}),onClick:()=>void ht(),children:`Enable selected`}),(0,H.jsx)(o,{variant:`secondary`,size:`sm`,disabled:j.size===0||n.isPending,icon:(0,H.jsx)(b,{size:12}),onClick:()=>void gt(),children:`Disable selected`}),(0,H.jsx)(o,{variant:`danger`,size:`sm`,disabled:j.size===0||t.isPending,icon:(0,H.jsx)(C,{size:12}),onClick:()=>{let e=Y.filter(e=>j.has(e.id));e.length!==0&&J(e)},children:`Delete selected`})]})]}),X&&(0,H.jsx)(h,{}),Q&&(0,H.jsx)(m,{title:`Error`,message:`Failed to load network pools`}),!X&&!Q&&Y.length===0&&(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-12 border border-dashed border-transparent rounded-card bg-transparent text-center`,children:(0,H.jsx)(g,{title:`No proxy pools configured`,message:`The summary above is empty because nothing is routing yet. Use Add proxies or Deploy relay in the header to start one.`})}),!X&&!Q&&Y.length>0&&(0,H.jsx)(`div`,{className:`proxy-table-scroll rounded-control border border-inner-border bg-surface-1`,children:(0,H.jsx)(le,{maxHeight:460,scrollRegion:!0,headers:[``,{key:`name`,label:`Proxy`,sortable:!0},{key:`family`,label:`Family`,sortable:!0},{key:`address`,label:`Address`,sortable:!0},{key:`load`,label:`Load`,sortable:!0},`Actions`],sortKey:K.key,sortDirection:K.direction,onSort:Ke,children:Be.map(e=>(0,H.jsx)(lt,{pool:e,isSelected:j.has(e.id),onToggleSelect:$,checkResult:W[e.id],probe:e.providerProbe===void 0?Pe(ve[e.id],e.endpoint):{poolId:e.id,providerId:e.providerProbe.providerId,status:e.providerProbe.status,...e.providerProbe.httpStatus===void 0?{}:{httpStatus:e.providerProbe.httpStatus},...e.providerProbe.reason===void 0?{}:{reason:e.providerProbe.reason},...e.providerProbe.latencyMs===void 0?{}:{latencyMs:e.providerProbe.latencyMs}},isTesting:R.has(e.id),onDelete:vt,onEdit:k,onHealthCheck:ct,onActivity:ze,speedResult:Ye(Oe[e.id],Je(e)),isSpeedTesting:U.has(e.id),maskValues:P,maskIp:L},e.id))})})]})]}),(0,H.jsx)(te,{open:q!==null,onClose:()=>J(null),onConfirm:async()=>{q&&(await Promise.all(q.map(e=>t.mutateAsync(e.id))),M(new Set),s.success(`Deleted ${q.length} pool(s)`),J(null))},title:`Delete proxy pool?`,message:q&&q.length===1?`Delete "${Z(q[0])}"? This cannot be undone.`:q?`Delete ${q.length} proxy pools? This cannot be undone.`:`Delete this proxy pool? This cannot be undone.`,confirmLabel:`Delete`,danger:!0}),Re?(0,H.jsx)(ut,{pool:Re,onClose:()=>ze(null)}):null,E?(0,H.jsx)(Ne,{onClose:()=>D(!1)}):null]})})}export{$e as ProxyBulkForm,nt as ProxyLiveProvider,Qe as SchemeChipRow,dt as default};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{r as i}from"./terminal-Bd4ee8TA.js";import{t as a}from"./check-D69FzdvC.js";import{t as o}from"./chevron-right-BXIy5l3h.js";import{g as s,r as c,t as l}from"./toast-CNt_jzO4.js";import{t as u}from"./eye-off-Bk5g2luF.js";import{a as ee,i as d,n as f,r as p,t as m}from"./state-DA0B95UQ.js";import{t as h}from"./dialog-BvQeBMfP.js";import{t as g}from"./refresh-cw-BqJFk4sU.js";import{t as _}from"./rotate-ccw-CufcqITi.js";import{t as te}from"./trash-Cppn5c3R.js";import{l as v}from"./query-keys-D7wX2vM5.js";import{L as y}from"./entry--yj84zk3.js";import{n as b,t as x}from"./card-DEhRXXw4.js";import{t as S}from"./badge-DpXT4Ixt.js";import{t as C}from"./select-XPJ-dIw3.js";import{t as w}from"./ProviderIcon-CmfzxpVM.js";import{t as T}from"./switch-Cittxy-x.js";import{t as E}from"./stack-C9_uUjaA.js";import{n as D}from"./inline-D1IlZZ8H.js";import{t as O}from"./layout-BioLW7gN.js";import{a as ne,i as k,n as A,o as j,r as M,s as N,t as P}from"./quota-DZGyp0N5.js";import{a as F,c as I,d as L,f as R,i as z,l as B,n as V,o as H,p as U,r as W,s as G,t as K,u as q}from"./HealthEventsModal-DeT-VXHd.js";var re=e(`calendar-check`,[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m9 15 2 2 4-4`,key:`1grp1n`}]]),ie=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),J=e(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Y=e(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),X=t(n(),1),Z=r();function Q(e){return!!(e.quota?.windows.length&&e.quota.windows.every(e=>e.remainingPercent!==null&&e.remainingPercent<=0))}function $(e){let t=e.quota?.windows.map(e=>e.resetsAt?new Date(e.resetsAt).getTime():1/0)??[];return Math.min(...t,1/0)}function ae({account:e,onClose:t}){let n=z(e.id,!0),r=q(e.id),i=n.data?.credits??[],a=e=>e?new Date(e).toLocaleString():`—`,o=e=>e?new Date(e).toLocaleString():`—`,s=e=>{if(!e)return``;let t=new Date(e).getTime()-Date.now();if(!Number.isFinite(t))return``;if(t<=0)return`expired`;let n=Math.floor(t/864e5);if(n>=1)return`in ${n}d`;let r=Math.floor(t/36e5);return r>=1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))}m`};return(0,Z.jsx)(h,{open:!0,onClose:t,size:`lg`,title:`Saved Rate-Limit Resets — ${e.name}`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-6 rounded-control border border-inner-border bg-surface-2 px-8 py-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Z.jsx)(Y,{size:14,className:`text-status-success`}),(0,Z.jsx)(`span`,{className:`text-body font-semibold`,children:`Available resets`})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-text-tertiary text-badge leading-normal`,children:`Each credit lifts a spent rate-limit window before its natural reset.`})]}),(0,Z.jsxs)(S,{tone:n.data&&n.data.availableCount>0?`ok`:`disabled`,dot:!0,children:[n.data?.availableCount??0,` reset`,(n.data?.availableCount??0)===1?``:`s`]})]}),n.isPending?(0,Z.jsx)(p,{label:`Reading saved resets…`}):n.isError?(0,Z.jsx)(f,{message:`Failed to read saved resets`,onRetry:()=>void n.refetch()}):i.length===0?(0,Z.jsx)(m,{title:`No saved resets`,message:`This account has no saved rate-limit reset credits right now.`,icon:(0,Z.jsx)(Y,{size:20})}):(0,Z.jsx)(`div`,{className:`max-h-170 overflow-y-auto rounded-control border border-inner-border`,children:(0,Z.jsx)(O,{headers:[`Status`,`Title`,`Granted`,`Expires`,``],children:i.map(e=>{let t=(e.status??`available`)===`available`,n=s(e.expiresAt);return(0,Z.jsxs)(`tr`,{children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap align-middle`,children:(0,Z.jsx)(S,{tone:t?`ok`:e.status===`expired`?`disabled`:`warn`,children:e.status??`available`})}),(0,Z.jsx)(`td`,{className:`text-caption font-medium whitespace-nowrap align-middle text-text-primary`,children:e.title??`Rate-limit reset`}),(0,Z.jsx)(`td`,{className:`text-badge whitespace-nowrap tabular-nums align-middle text-text-secondary`,children:a(e.grantedAt)}),(0,Z.jsxs)(`td`,{className:`text-badge whitespace-nowrap tabular-nums align-middle text-text-secondary`,children:[o(e.expiresAt),n&&(0,Z.jsxs)(`span`,{className:`ml-3 text-text-tertiary`,children:[`(`,n,`)`]})]}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap text-right align-middle`,children:(0,Z.jsx)(c,{size:`sm`,variant:t?`primary`:`secondary`,disabled:!t||r.isPending,onClick:()=>r.mutate({creditId:e.id},{onSuccess:e=>{e.ok?l.success(e.message??`Rate limit reset applied`):l.error(e.message??`Rate limit reset failed`)},onError:e=>{l.error(v(e,`Unable to redeem rate-limit reset`))}}),children:`Use`})})]},e.id)})})}),(0,Z.jsx)(D,{justify:`flex-end`,gap:`0px`,children:(0,Z.jsx)(c,{variant:`secondary`,size:`sm`,onClick:t,children:`Close`})})]})})}function oe({accounts:e}){let t=(0,X.useMemo)(()=>{let t=new Map;for(let n of e){if(!V(n.provider))continue;let e=t.get(n.provider);e?e.count+=1:t.set(n.provider,{id:n.provider,label:n.providerName||n.provider,count:1})}return[...t.values()]},[e]),[n,r]=(0,X.useState)(``),i=(t.find(e=>e.id===n)??t[0])?.id??``,a=R(i),o=i.length===0||a.isPending||t.length===0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2.5`,"aria-label":`Daily growth actions`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-67.5`,children:(0,Z.jsx)(C,{"aria-label":`Provider for the daily growth pass`,value:i,onValueChange:r,className:`w-full h-16`,options:t.length>0?t.map(e=>({value:e.id,label:`${e.label} · ${e.count}`})):[{value:``,label:`No buddy providers`}]})}),(0,Z.jsx)(c,{variant:`secondary`,size:`sm`,title:`Send the activity report, then claim the daily check-in, for every account of this provider`,"aria-label":`Run the daily growth pass for this provider`,disabled:o,className:`shrink-0`,icon:a.isPending?(0,Z.jsx)(s,{size:13,className:`animate-spin`}):(0,Z.jsx)(re,{size:13}),onClick:()=>a.mutate(void 0,{onSuccess:e=>{let t=e.data.filter(e=>!e.report.ok).length;t===0?l.success(e.message):l.error(`${e.message} — ${t} report${t===1?``:`s`} failed`)},onError:e=>l.error(v(e,`Unable to run the daily growth pass`))}),children:`Daily growth`})]})}function se({account:e,onToggle:t,onDelete:n,onShowHealth:r,onShowResets:a}){let u=G(e.id),d=L(e.id),f=V(e.provider),p=W(e.provider),m=z(e.id,p),h=e.quota,[g,y]=(0,X.useState)(0),b=h?.windows??[],S=j(b,g),C=S.pageCount;(0,X.useEffect)(()=>{y(e=>Math.min(e,Math.max(0,C-1)))},[C]);let E=u.isPending||d.isPending,D=m.data?.availableCount??0,[O,F]=(0,X.useState)(null),[I,R]=(0,X.useState)(!1),B=e.checkin?.attemptedToday??!1,H=`${O?O.state===`claimed`?`Checked in${O.credit===null?``:` +${O.credit}`}${O.streakDays===null?``:` · ${O.streakDays}d streak`}`:O.state===`already_claimed`?`Check-in attempted · already claimed`:O.state===`not_eligible`?`Check-in attempted · not eligible`:O.state===`event_ended`?`Check-in attempted · event ended`:`Check-in attempted · unavailable`:B?`Check-in attempted today`:`Check-in due`}${I?` · Reported today`:``}`,U=b.reduce((e,t)=>{let n=t.limit;if(typeof n!=`number`||!Number.isFinite(n))return e;let r=typeof t.remaining==`number`&&Number.isFinite(t.remaining)?t.remaining:typeof t.used==`number`&&Number.isFinite(t.used)?n-t.used:typeof t.remainingPercent==`number`&&Number.isFinite(t.remainingPercent)?n*t.remainingPercent/100:null;return r===null?e:e+Math.max(0,r)},0),K=(u.error?v(u.error,`Unable to refresh this account`):null)??h?.refreshError??h?.error??e.health?.sanitizedMessage,q=ne(K),J=q===`Quota tracking is not supported for this provider`?null:q,Q=P(e.credentialHint,e.name),$=e.health?.status??`unknown`;return(0,Z.jsxs)(x,{className:`flex h-full flex-col overflow-hidden`,"aria-busy":E,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5 px-7 py-4`,children:[(0,Z.jsx)(w,{icon:e.providerIcon,name:e.providerName,size:32}),(0,Z.jsxs)(`div`,{className:`flex-[1_1_160px]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:`truncate text-caption font-bold text-text-primary text-body`,children:e.providerName}),h?.plan&&(0,Z.jsx)(`span`,{className:`shrink-0 rounded-chip bg-accent-soft px-4 py-1 text-micro font-semibold text-accent`,children:h.plan})]}),(0,Z.jsx)(`div`,{className:`truncate text-badge text-text-secondary`,children:Q.primary}),Q.secondary!==null&&(0,Z.jsx)(`div`,{className:`truncate text-micro text-text-tertiary`,children:Q.secondary}),h&&(0,Z.jsx)(`div`,{className:`truncate text-micro text-text-tertiary`,children:A(h.lastSuccessAt??h.fetchedAt)}),p&&(0,Z.jsx)(`div`,{className:`truncate text-micro flex items-center gap-2 text-text-tertiary`,title:`Saved rate-limit reset credits available on this account`,children:m.isPending?`Checking saved resets…`:D>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{size:10,className:`text-status-success shrink-0`,"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`reset-credit-live`,children:[D,` rate-limit reset`,D===1?``:`s`,` available`]})]}):`No rate-limit resets available`}),f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{title:`Daily growth state: manual pass result, else the sweep ledger for today`,className:`truncate text-micro text-text-tertiary`,children:d.isPending?`Running growth pass…`:H}),b.some(e=>typeof e.limit==`number`&&Number.isFinite(e.limit))&&(0,Z.jsxs)(`div`,{className:`truncate text-micro text-text-tertiary`,children:[`Total credits: `,U.toLocaleString(void 0,{maximumFractionDigits:2})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.75 gap-3 ml-auto`,children:[p&&(0,Z.jsx)(c,{variant:`ghost`,size:`icon`,className:`w-16 h-16 p-0`,title:m.isPending?`Checking saved rate-limit resets…`:D>0?`Saved rate-limit resets (${D} available)`:`Saved rate-limit resets`,"aria-label":`Open saved rate-limit resets for ${e.name}`,disabled:E,onClick:()=>a(e),children:(0,Z.jsx)(Y,{size:14})}),f&&(0,Z.jsx)(c,{variant:`ghost`,size:`icon`,className:`w-16 h-16 p-0`,title:`Daily growth pass (check-in + activity report) — ${H}`,"aria-label":`Run daily growth pass for ${e.name}`,disabled:E,onClick:()=>d.mutate(void 0,{onSuccess:e=>{let t=e.checkin.data;t&&F({state:t.state,credit:t.credit,streakDays:t.streakDays}),e.report.ok&&R(!0),e.ok?l.success(e.message):l.error(e.message)},onError:e=>{l.error(v(e,`Unable to run daily growth pass`))}}),children:d.isPending?(0,Z.jsx)(s,{size:14,className:`animate-spin`}):(0,Z.jsx)(re,{size:14})}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,title:$===`active`?`Health & Error Log`:`${$} — Inspect account health details`,"aria-label":$===`active`?`Health log for ${e.name}`:`Account is ${$} — inspect health details for ${e.name}`,disabled:E,onClick:()=>r(e),icon:(0,Z.jsx)(i,{size:12})}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,title:`Refresh quota`,"aria-label":`Refresh ${e.name} quota`,disabled:E,onClick:()=>u.mutate(),icon:u.isPending?(0,Z.jsx)(s,{size:12,className:`animate-spin`}):(0,Z.jsx)(_,{size:12})}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,title:`Delete account`,"aria-label":`Delete ${e.name}`,onClick:()=>n(e),className:`text-red`,icon:(0,Z.jsx)(te,{size:12})}),(0,Z.jsx)(T,{checked:e.active,disabled:u.isPending,onChange:n=>t(e,n),label:``,id:`switch-${e.id}`})]})]}),J&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-4 border-t border-inner-border px-8 py-5 text-center text-badge text-red`,role:`alert`,children:[(0,Z.jsx)(ee,{size:13,className:`shrink-0`}),(0,Z.jsx)(`span`,{children:J})]}),h?.windows.length?(0,Z.jsxs)(`div`,{className:`quota-window-list flex flex-1 flex-col gap-4 border-t border-inner-border px-7 py-4.5`,children:[(0,Z.jsx)(`div`,{className:`quota-window-section-label text-micro font-bold tracking-label text-text-tertiary`,children:`QUOTA WINDOWS`}),S.items.map((e,t)=>{let n=e.remainingPercent??null,r=typeof e.limit==`number`&&Number.isFinite(e.limit)?e.limit:null,i=typeof e.used==`number`&&Number.isFinite(e.used)?e.used:r!==null&&e.usedPercent!==null&&e.usedPercent!==void 0?r*e.usedPercent/100:null,a=N(n),o=n===null?0:Math.max(0,Math.min(100,n)),s=e=>e.toLocaleString(void 0,{maximumFractionDigits:2}),c=e=>{let t=Math.round(e*10)/10;return t>0&&t<.1?`<0.1`:t.toLocaleString(void 0,{maximumFractionDigits:1})},l=M(e.label);return(0,Z.jsxs)(`div`,{className:`quota-window-row grid grid-cols-quota-window min-w-0 items-center gap-x-6 gap-y-2 max-small:grid-cols-[minmax(0,1fr)_auto] max-small:gap-x-4 max-small:gap-y-2.5`,children:[(0,Z.jsx)(`div`,{className:`quota-window-heading min-w-0 max-small:col-start-1`,children:(0,Z.jsx)(`span`,{className:`text-badge font-semibold text-text-primary`,children:l})}),(0,Z.jsx)(`div`,{className:`quota-bar-track quota-window-bar min-w-0 w-full h-5 rounded-tiny bg-inner-border overflow-hidden max-small:col-span-full max-small:row-start-2`,role:`progressbar`,"aria-label":`${l} remaining quota`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n===null?void 0:o,"aria-valuetext":n===null?`Quota only`:`${c(n)}% remaining`,children:(0,Z.jsx)(`div`,{className:`quota-bar-fill h-full rounded-tiny transition-[width] duration-(--dur-macro) ease-spring`,style:{width:`${o}%`,background:a.bar}})}),(0,Z.jsx)(`span`,{className:`quota-window-remaining whitespace-nowrap text-badge font-bold tabular-nums max-small:col-start-2 max-small:row-start-1`,style:{color:a.text},children:n===null?`—`:`${c(n)}%`}),(0,Z.jsxs)(`div`,{className:`quota-window-details col-span-full flex min-w-0 items-center justify-end gap-6 text-micro text-text-tertiary max-small:row-start-3 max-small:flex-wrap max-small:justify-between max-small:gap-4`,children:[(0,Z.jsx)(`span`,{className:`quota-window-usage mr-auto tabular-nums max-small:min-w-0`,children:i!==null&&r!==null?`${s(i)} / ${s(r)} Credits`:`Quota only`}),e.resetsAt&&(0,Z.jsx)(`span`,{className:`quota-window-reset whitespace-nowrap tabular-nums text-right max-small:ml-auto`,children:k(e.resetsAt,e.recurring)})]})]},`${e.kind??e.label}:${e.resetsAt??`none`}:${t}`)}),S.pageCount>1&&(0,Z.jsxs)(`nav`,{"aria-label":`Quota windows for ${e.name}`,className:`quota-window-pagination mt-auto flex items-center justify-between gap-4 border-t border-inner-border pt-4 max-small:flex-wrap`,children:[(0,Z.jsxs)(`span`,{"aria-live":`polite`,className:`text-micro text-text-tertiary`,children:[`Showing `,S.startIndex+1,`–`,S.startIndex+S.items.length,` of `,b.length]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,"aria-label":`Previous quota windows for ${e.name}`,disabled:S.page===0,icon:(0,Z.jsx)(ie,{size:13}),onClick:()=>y(S.page-1),className:`h-14 px-4 py-0`,children:`Previous`}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,"aria-label":`Next quota windows for ${e.name}`,disabled:S.page>=S.pageCount-1,icon:(0,Z.jsx)(o,{size:13}),onClick:()=>y(S.page+1),className:`h-14 px-4 py-0`,children:`Next`})]})]})]}):J?null:(0,Z.jsx)(`div`,{className:`border-t border-inner-border px-7 py-9 text-center text-badge text-text-tertiary`,children:E||e.pending?`Fetching quota…`:`No quota data`})]})}function ce(){let[e,t]=(0,X.useState)(`all`),[n,r]=(0,X.useState)(`all`),[i,o]=(0,X.useState)(!1),{data:s,isLoading:ee,isError:f,error:p,isFetching:h,dataUpdatedAt:_,refetch:te}=H(),v=(0,X.useMemo)(()=>[...s?.providers??[]].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),[s?.providers]),S=(0,X.useMemo)(()=>s?.accounts??[],[s?.accounts]),w=s?.refreshing??0,T=I(),D=U(),O=B(),ne=F(),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),L=(0,X.useMemo)(()=>{let t=S.filter(t=>{if(e!==`all`&&t.provider!==e)return!1;let r=!!t.quota?.windows.length;return n===`untracked`?!r:!(!r||n===`active`&&!t.active||n===`disabled`&&t.active)}),r=(e,t)=>e.providerName.localeCompare(t.providerName,void 0,{sensitivity:`base`})||e.name.localeCompare(t.name,void 0,{sensitivity:`base`});return[...t].sort(i?(e,t)=>$(e)-$(t)||r(e,t):r)},[n,S,i,e]),R=async(e,t)=>{try{await D.mutateAsync({id:e.id,active:t}),l.success(`${e.name} ${t?`enabled`:`disabled`}`)}catch(e){l.error(e instanceof Error?e.message:`Unable to update account`)}},z=async()=>{let e=S.filter(e=>e.active&&Q(e));await O.mutateAsync({ids:e.map(e=>e.id),active:!1}),l.success(`Disabled ${e.length} empty accounts`)},V=async()=>{let e=S.filter(e=>!e.active&&e.quota?.windows.some(e=>e.remainingPercent!==null&&e.remainingPercent>0));await O.mutateAsync({ids:e.map(e=>e.id),active:!0}),l.success(`Enabled ${e.length} available accounts`)},W=async e=>{await ne.mutateAsync(e.id),l.success(`${e.name} deleted`)},G=_>0?new Date(_).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):`Not updated`,q=S.filter(Q).length;return(0,Z.jsxs)(E,{gap:`16px`,className:`dashboard-page min-h-0 flex-1`,children:[(0,Z.jsx)(x,{children:(0,Z.jsxs)(b,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-4`,children:[(0,Z.jsx)(C,{"aria-label":`Filter quota by provider`,value:e,onValueChange:t,className:`w-full h-16 max-small:w-80`,options:[{value:`all`,label:`All Providers`},...v.map(e=>({value:e.id,label:e.name}))]}),(0,Z.jsx)(C,{"aria-label":`Filter quota by account`,value:n,onValueChange:r,className:`w-full h-16 max-small:w-67.5`,options:[{value:`all`,label:`With quota`},{value:`active`,label:`Active`},{value:`disabled`,label:`Disabled`},{value:`untracked`,label:`No quota`}]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Z.jsx)(c,{variant:i?`secondary`:`ghost`,size:`sm`,onClick:()=>o(e=>!e),"aria-pressed":i,icon:(0,Z.jsx)(J,{size:13}),children:`Expiring first`}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,className:`text-red`,disabled:q===0||h,onClick:()=>void z(),icon:(0,Z.jsx)(u,{size:13}),children:`Turn off Empty`}),(0,Z.jsx)(c,{variant:`ghost`,size:`sm`,className:`text-green`,disabled:h,onClick:()=>void V(),icon:(0,Z.jsx)(a,{size:13}),children:`Turn on Available`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 border-t border-inner-border pt-5`,children:[(0,Z.jsxs)(`span`,{className:`text-badge text-text-tertiary`,children:[L.length,` shown`,q>0?` · ${q} empty`:``]}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-5 gap-y-3 text-badge text-text-tertiary`,children:[w>0?`Refreshing ${w} account${w===1?``:`s`}…`:`Auto-refresh 60s · ${G}`,(0,Z.jsx)(oe,{accounts:S}),(0,Z.jsx)(c,{variant:`secondary`,size:`sm`,title:`Queue quota refresh`,"aria-label":`Queue quota refresh`,disabled:h||T.isPending||S.length===0,icon:(0,Z.jsx)(g,{size:13,className:T.isPending?`animate-spin`:void 0}),onClick:()=>T.mutate(S.map(e=>e.id),{onSuccess:e=>{l.success(e.failed===0?`Refreshed ${e.succeeded} quota${e.succeeded===1?``:`s`}`:`Refreshed ${e.succeeded}, ${e.failed} failed`)},onError:e=>l.error(e instanceof Error?e.message:`Unable to refresh quota`)}),children:`Refresh`})]})]})]})}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6`,children:ee?(0,Z.jsx)(d,{className:`min-h-0 flex flex-1 flex-col items-center justify-center`,kind:`loading`,title:`Loading quota data`,description:`Reading provider account limits…`}):f?(0,Z.jsx)(d,{className:`min-h-0 flex flex-1 flex-col items-center justify-center`,kind:`error`,title:`Unable to load quota data`,description:p instanceof Error?p.message:`Check the console session and retry.`,action:(0,Z.jsx)(c,{variant:`secondary`,onClick:()=>void te(),children:`Retry`})}):L.length===0?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-12 border border-dashed border-transparent rounded-card bg-transparent text-center`,children:(0,Z.jsx)(m,{title:`No account quota data`,message:`Nothing is reporting a quota window yet. Add a provider account and its limits will appear here.`})}):(0,Z.jsx)(`div`,{className:`quota-account-grid scroll-region min-h-0 flex-1 gap-6 [align-content:start]`,children:L.map(e=>(0,Z.jsx)(se,{account:e,onToggle:(e,t)=>void R(e,t),onDelete:e=>A(e),onShowHealth:e=>M(e),onShowResets:e=>P(e)},e.id))})}),j&&(0,Z.jsx)(K,{summary:{providerId:j.provider,accountId:j.id,title:j.name,status:j.health?.status??`unknown`,errorCategory:j.health?.lastErrorCategory??void 0,errorMessage:j.health?.sanitizedMessage??void 0,emptyMessage:`Status transitions, rate limits, quota refreshes, check-ins, and auto-recoveries will appear here.`},onClose:()=>M(null)}),N&&(0,Z.jsx)(ae,{account:N,onClose:()=>P(null)}),(0,Z.jsx)(y,{open:k!==null,onClose:()=>A(null),onConfirm:async()=>{k&&await W(k)},title:`Delete account?`,message:`Delete "${k?.name}"? This cannot be undone.`,confirmLabel:`Delete`,danger:!0})]})}export{ce as default};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{r as i,t as a}from"./toast-CNt_jzO4.js";import{t as o}from"./download-A0SW9OCW.js";import{t as s}from"./eye-C_hawfH4.js";import{n as c,r as l}from"./state-DA0B95UQ.js";import{t as u}from"./dialog-BvQeBMfP.js";import{n as d,r as f,t as p}from"./settings-CfcTcOyU.js";import{t as m}from"./trash-Cppn5c3R.js";import{T as h}from"./assert-BHfaei-X.js";import{l as g,o as _,s as v}from"./query-keys-D7wX2vM5.js";import{t as y}from"./useMutation-BQKMcJ1H.js";import{n as b,r as x,t as S}from"./card-DEhRXXw4.js";import{n as C,t as w}from"./download-dRFo5_Wu.js";import{n as T}from"./input-BpVZdrbc.js";import{t as E}from"./select-XPJ-dIw3.js";import{t as ee}from"./switch-Cittxy-x.js";import{t as D}from"./stack-C9_uUjaA.js";import{t as O}from"./banner-CSAAWLJv.js";import{t as k}from"./backup-file-gdKIlg8U.js";var te=e(`database-backup`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]),ne=e(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),A=t(n(),1);function re(){return y({mutationFn:async({password:e,sections:t,compressed:n,onProgress:r})=>{let i=new URLSearchParams({password:e});t!==void 0&&t.length>0&&i.set(`sections`,t),n===!0&&i.set(`compressed`,`1`);let a=`/backup/export?${i.toString()}`;if(n!==!0)return _(a);let o=await _(a),s=atob(o.bytes),c=Uint8Array.from(s,e=>e.charCodeAt(0));return r?.({loaded:c.byteLength,total:c.byteLength}),c}})}function ie(){let e=h();return y({mutationFn:({password:e,scopes:t})=>_(`/backup/delete-all`,{method:`POST`,body:JSON.stringify({password:e,scopes:t})}),onSuccess:async()=>{await e.invalidateQueries()}})}function j(){let e=h();return y({mutationFn:({password:e,backup:t,onProgress:n})=>v(`/backup/import`,JSON.stringify({password:e,backup:t}),n),onSuccess:async()=>{await e.invalidateQueries()}})}var M=r();function N({report:e}){let t=Object.entries(e.imported).filter(([,e])=>e>0);return(0,M.jsxs)(D,{gap:`8px`,children:[t.length>0?(0,M.jsxs)(`p`,{className:`text-caption`,children:[`Imported: `,t.map(([e,t])=>`${t} ${e}`).join(`, `)]}):null,e.remapped.length>0?(0,M.jsxs)(`p`,{className:`text-caption text-text-secondary`,children:[`Remapped provider ids: `,e.remapped.join(`, `)]}):null,e.skipped.length>0?(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`p`,{className:`text-caption text-yellow`,children:[`Skipped (`,e.skipped.length,`) — nothing was guessed:`]}),(0,M.jsx)(`ul`,{className:`text-badge text-text-tertiary mt-2 ml-8`,children:e.skipped.map(e=>(0,M.jsx)(`li`,{children:e},e))})]}):null,e.warnings.length>0?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-caption text-text-secondary`,children:`Warnings:`}),(0,M.jsx)(`ul`,{className:`text-badge text-text-tertiary mt-2 ml-8`,children:e.warnings.map(e=>(0,M.jsx)(`li`,{children:e},e))})]}):null]})}function P({warnings:e}){return e.length===0?null:(0,M.jsxs)(O,{tone:`warning`,surface:`raised`,live:`status`,children:[(0,M.jsxs)(`strong`,{children:[`Restore completed with `,e.length,` warning`,e.length===1?``:`s`]}),(0,M.jsx)(`ul`,{className:`mt-2 ml-8`,children:e.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.table?`${e.table}${e.column?`.${e.column}`:``}: `:``,e.reason]},`${e.table??`backup`}:${e.column??`general`}:${t}`))})]})}function F(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function I(e,t){if(e===null)return t;let n=Math.max((Date.now()-e.startedAt)/1e3,.1),r=F(e.loaded/n);return`${e.total===null?F(e.loaded):`${F(e.loaded)} / ${F(e.total)}`} · ${r}/s`}function L(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)(null),[s,c]=(0,A.useState)(!0),[l,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(!0),[h,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(null),[E,F]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(null),[V,H]=(0,A.useState)(null),[U,W]=(0,A.useState)(new Set),[G,K]=(0,A.useState)(null),q=(0,A.useRef)(null),J=re(),Y=j(),X=ie(),ae=e=>{W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Z=()=>{r(null),t(``)},oe=()=>{U.size!==0&&(t(``),r(`delete`))},se=async()=>{if(e.length===0)return;let t=await X.mutateAsync({password:e,scopes:[...U]});W(new Set),Z(),a.success(`Selected configuration deleted.`,Object.entries(t.deleted).map(([e,t])=>`${e}: ${t}`).join(` · `))},Q=()=>{let t=[...s?[`config`]:[],...l?[`telemetry`]:[]].join(`,`);if(t.length===0){a.error(`Select at least one backup section.`);return}J.mutate({password:e,sections:t,compressed:f,onProgress:e=>_(t=>({...e,startedAt:t?.startedAt??Date.now()}))},{onSuccess:e=>{let t=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`);e instanceof Uint8Array?w(`cartethyia_backup_${t}.json.gz`,e,`application/gzip`):C(`cartethyia_backup_${t}.json`,JSON.stringify(e,null,2),`application/json`),Z(),a.success(`Backup downloaded.`)},onError:e=>a.error(g(e,`Backup export failed.`))})},ce=e=>{K(e),y(null),F(null),R(null),B(null),H(null),t(``),r(`restore`)},le=async()=>{let t=G;if(t!==null){R(null);try{let n=await k(t),r=await Y.mutateAsync({password:e,backup:n,onProgress:e=>_(t=>({...e,startedAt:t?.startedAt??Date.now()}))});y(r.restored),F(r.warnings),B(r.report??null),H(r.format),Z(),K(null),a.success(r.warnings.length===0?`Restore complete.`:`Restore completed with warnings.`,r.warnings.length===0?null:`${r.warnings.length} item(s) need attention. See the restore report below.`)}catch(e){let t=g(e,`Backup restore failed.`);R(t),a.error(`Backup restore failed`,t)}}},$=v===null?[]:Object.entries(v);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-8 w-full min-w-0 max-medium:grid-cols-1`,children:[(0,M.jsxs)(S,{className:`h-full`,children:[(0,M.jsx)(x,{title:`Backup`,subtitle:`Download a JSON snapshot, or restore one you already trust`,icon:(0,M.jsx)(te,{size:16})}),(0,M.jsx)(b,{className:`flex flex-1 flex-col`,children:(0,M.jsxs)(D,{gap:`14px`,className:`flex-1`,children:[(0,M.jsxs)(`fieldset`,{className:`grid grid-cols-2 gap-5 min-w-0 border-0 m-0 p-0 max-medium:grid-cols-1`,children:[(0,M.jsx)(`legend`,{className:`mb-4 text-text-secondary text-badge font-semibold`,children:`Include in the download`}),(0,M.jsxs)(`label`,{className:`flex items-start gap-5 min-h-21 px-6 py-5 border border-inner-border rounded-control bg-surface-2 text-text-primary text-caption leading-snug cursor-pointer hover:border-border-strong hover:bg-hover has-checked:border-accent has-checked:bg-accent-soft`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,M.jsxs)(`span`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,M.jsx)(`strong`,{children:`Account, proxy & settings`}),(0,M.jsx)(`small`,{className:`text-text-tertiary text-badge`,children:`Credentials, API-key hashes, routing, and settings`})]})]}),(0,M.jsxs)(`label`,{className:`flex items-start gap-5 min-h-21 px-6 py-5 border border-inner-border rounded-control bg-surface-2 text-text-primary text-caption leading-snug cursor-pointer hover:border-border-strong hover:bg-hover has-checked:border-accent has-checked:bg-accent-soft`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>d(e.target.checked)}),(0,M.jsxs)(`span`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,M.jsx)(`strong`,{children:`Telemetry history`}),(0,M.jsx)(`small`,{className:`text-text-tertiary text-badge`,children:`Status, tokens, cost, latency — never prompt bodies`})]})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-6 rounded-control border border-inner-border px-6 py-5`,children:[(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{className:`block text-body`,children:`Highly Compress Backup`}),(0,M.jsx)(`small`,{className:`text-badge text-text-tertiary`,children:`Makes the download smaller.`})]}),(0,M.jsx)(ee,{checked:f,onChange:p,"aria-label":`Highly Compress Backup`})]}),(0,M.jsx)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:`The file contains provider credentials. Treat it like the database. Prompt and response bodies, health-event history, and console sessions are left out.`}),(0,M.jsxs)(`div`,{className:`mt-auto flex justify-end gap-4`,children:[(0,M.jsx)(i,{variant:`primary`,size:`sm`,onClick:()=>{t(``),r(`download`)},disabled:!s&&!l,icon:(0,M.jsx)(o,{size:13}),children:`Download backup`}),(0,M.jsx)(i,{variant:`secondary`,size:`sm`,onClick:()=>q.current?.click(),icon:(0,M.jsx)(ne,{size:13}),children:`Restore from file`}),(0,M.jsx)(`input`,{ref:q,type:`file`,accept:`application/json,.json,.gz,application/gzip`,className:`sr-only`,onChange:e=>{let t=e.target.files?.[0];t&&ce(t),e.target.value=``}})]}),V===null?null:(0,M.jsxs)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:[`Detected format: `,V===`nine_router`?`router export`:`Cartethyia backup`]}),v===null?null:(0,M.jsxs)(O,{tone:`success`,surface:`raised`,live:`status`,children:[(0,M.jsx)(`strong`,{children:`Restore complete`}),$.length>0?(0,M.jsx)(`ul`,{children:$.map(([e,t])=>(0,M.jsxs)(`li`,{children:[e,`: `,t]},e))}):(0,M.jsx)(`p`,{children:`No rows were imported.`})]}),E===null?null:(0,M.jsx)(P,{warnings:E}),z===null?null:(0,M.jsx)(N,{report:z})]})})]}),(0,M.jsxs)(S,{className:`settings-danger h-full`,children:[(0,M.jsx)(x,{title:`Delete data`,subtitle:`Removes the scopes you check. Console users, sessions, and audit history stay.`,icon:(0,M.jsx)(m,{size:16})}),(0,M.jsx)(b,{className:`flex flex-1 flex-col`,children:(0,M.jsxs)(D,{gap:`12px`,className:`flex-1`,children:[(0,M.jsxs)(`fieldset`,{className:`grid grid-cols-1 gap-5 min-w-0 border-0 m-0 p-0`,children:[(0,M.jsx)(`legend`,{className:`mb-4 text-text-secondary text-badge font-semibold`,children:`Delete`}),[[`providers`,`Providers`,`Accounts, credentials, tenant models, routing, and account health`],[`proxies`,`Proxies`,`Network pools, pool settings, and pool health`],[`configuration`,`All configuration`,`Providers, proxies, aliases, combos, API keys, CLI tools, and settings`]].map(([e,t,n])=>(0,M.jsxs)(`label`,{className:`flex items-start gap-5 min-h-21 px-6 py-5 border border-inner-border rounded-control bg-surface-2 text-text-primary text-caption leading-snug cursor-pointer hover:border-border-strong hover:bg-hover has-checked:border-accent has-checked:bg-accent-soft`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:U.has(e),onChange:()=>ae(e)}),(0,M.jsxs)(`span`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,M.jsx)(`strong`,{children:t}),(0,M.jsx)(`small`,{className:`text-text-tertiary text-badge`,children:n})]})]},e))]}),(0,M.jsx)(`div`,{className:`mt-auto flex justify-end`,children:(0,M.jsx)(i,{variant:`danger`,size:`sm`,icon:(0,M.jsx)(m,{size:14}),disabled:U.size===0,onClick:oe,children:`Delete selected`})})]})})]})]}),(0,M.jsx)(u,{open:n!==null,onClose:Z,title:n===`delete`?`Confirm deletion`:n===`restore`?`Restore backup`:`Download backup`,description:`The console password is checked again before this runs.`,size:`sm`,footer:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(i,{variant:`secondary`,size:`sm`,onClick:Z,children:`Cancel`}),(0,M.jsx)(i,{variant:n===`delete`?`danger`:`primary`,size:`sm`,loading:J.isPending||Y.isPending||X.isPending,disabled:e.length===0||J.isPending||Y.isPending||X.isPending,onClick:()=>{_(null),n===`download`?Q():n===`restore`?le():se()},children:J.isPending?I(h,`Downloading…`):Y.isPending?I(h,`Uploading…`):X.isPending?`Working…`:n===`delete`?`Delete permanently`:n===`restore`?`Restore`:`Download`})]}),children:(0,M.jsxs)(D,{gap:`10px`,children:[n===`restore`&&L!==null?(0,M.jsx)(`p`,{role:`alert`,className:`text-caption text-red`,children:L}):null,(0,M.jsx)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:n===`delete`?`This cannot be undone. The password is verified again before anything is removed.`:n===`restore`?`Restore replaces the tenant configuration in this file. Continue only if the file is trusted.`:`The export is plain JSON and contains provider credentials.`}),(0,M.jsx)(T,{label:`Console password`,type:`password`,value:e,onChange:e=>t(e.target.value),autoComplete:`current-password`,"data-autofocus":!0})]})})]})}function R(){return y({mutationFn:e=>_(`/auth/change-password`,{method:`POST`,body:JSON.stringify(e)})})}function z(){let e=p(),t=d(),n=e.data;return e.isPending?(0,M.jsx)(l,{label:`Loading privacy settings…`}):e.isError||!n?(0,M.jsx)(c,{message:g(e.error,`Failed to load runtime settings`),onRetry:()=>void e.refetch()}):(0,M.jsxs)(S,{className:`h-full`,children:[(0,M.jsx)(x,{title:`Privacy`,subtitle:`What request telemetry stores, and how client addresses are shown`,icon:(0,M.jsx)(s,{size:16})}),(0,M.jsx)(b,{children:(0,M.jsxs)(D,{gap:`16px`,children:[(0,M.jsxs)(`div`,{className:`settings-field`,children:[(0,M.jsx)(E,{label:`Telemetry payloads`,id:`privacy-payloads`,value:n.telemetryPayloads,onValueChange:e=>t.mutate({telemetryPayloads:e===`full`||e===`metadata`?e:`none`},{onSuccess:()=>a.success(`Payload capture updated`),onError:e=>a.error(g(e,`Could not update payload capture.`))}),options:[{value:`none`,label:`Off — no payload capture`},{value:`metadata`,label:`Metadata — method and headers, 15 minutes`},{value:`full`,label:`Full — redacted bodies, 15 minutes`}]}),(0,M.jsx)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:`Request metadata is always kept. Bodies stay off until you turn them on, and anything captured is redacted and deleted after 15 minutes.`})]}),n.telemetryPayloads===`full`?(0,M.jsxs)(`div`,{className:`settings-field`,children:[(0,M.jsx)(E,{label:`Capture depth`,id:`privacy-payload-depth`,value:n.telemetryPayloadDepth,onValueChange:e=>t.mutate({telemetryPayloadDepth:e===`moderate`||e===`maximum`?e:`minimum`},{onSuccess:()=>a.success(`Capture depth updated`),onError:e=>a.error(g(e,`Could not update capture depth.`))}),options:[{value:`minimum`,label:`Minimum — 1 MiB cap`},{value:`moderate`,label:`Moderate — 8 MiB cap`},{value:`maximum`,label:`Maximum — 16 MiB cap`}]}),n.telemetryPayloadDepth===`minimum`?null:(0,M.jsxs)(O,{tone:`warning`,surface:`raised`,className:`text-text-secondary`,children:[(0,M.jsx)(`strong`,{children:`High CPU and memory while this is on.`}),` Use it to debug, then switch back to Metadata or Minimum.`]})]}):null,(0,M.jsxs)(`div`,{className:`settings-field`,children:[(0,M.jsx)(E,{label:`Client IP display`,id:`privacy-ip`,value:n.privacyMode,onValueChange:e=>t.mutate({privacyMode:e===`full`?`full`:`masked`},{onSuccess:()=>a.success(`IP display updated`),onError:e=>a.error(g(e,`Could not update IP display.`))}),options:[{value:`masked`,label:`Masked — recommended`},{value:`full`,label:`Show full IP`}]}),(0,M.jsx)(`p`,{className:`mt-1 text-badge text-text-tertiary`,children:`Raw addresses stay stored. This only changes how they are shown.`})]})]})})]})}function B(){let e=R(),[t,n]=(0,A.useState)(``),[r,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(!1);return(0,M.jsxs)(D,{gap:`12px`,className:`flex-1`,children:[(0,M.jsx)(T,{id:`current-password`,label:`Current password`,type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:`current-password`}),(0,M.jsxs)(`div`,{className:`settings-pair settings-pair-tight`,children:[(0,M.jsx)(T,{id:`new-password`,label:`New password`,type:`password`,value:r,onChange:e=>a(e.target.value),autoComplete:`new-password`}),(0,M.jsx)(T,{id:`confirm-password`,label:`Confirm new password`,type:`password`,value:o,onChange:e=>s(e.target.value),autoComplete:`new-password`})]}),c?(0,M.jsx)(`p`,{role:`alert`,className:`settings-feedback`,"data-tone":`err`,children:c}):null,u?(0,M.jsx)(`p`,{role:`status`,className:`settings-feedback`,"data-tone":`ok`,children:`Password updated.`}):null,(0,M.jsx)(`div`,{className:`mt-auto flex justify-end`,children:(0,M.jsx)(i,{variant:`primary`,size:`sm`,onClick:()=>{if(d(!1),r.length<8){l(`New password must be at least 8 characters.`);return}if(r!==o){l(`New password and confirmation do not match.`);return}l(null),e.mutate({currentPassword:t,newPassword:r},{onSuccess:()=>{d(!0),n(``),a(``),s(``)},onError:e=>l(g(e,`Password change failed.`))})},disabled:e.isPending||!t||!r||!o,children:e.isPending?`Updating…`:`Update password`})})]})}function V(){return(0,M.jsxs)(S,{children:[(0,M.jsx)(x,{title:`Settings`,subtitle:`Account security, privacy, and tenant data`,icon:(0,M.jsx)(f,{size:16})}),(0,M.jsxs)(b,{className:`flex flex-col gap-10`,children:[(0,M.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,M.jsx)(`h2`,{className:`text-badge font-bold uppercase tracking-label text-text-tertiary`,children:`Account`}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-8 w-full min-w-0 max-medium:grid-cols-1`,children:[(0,M.jsxs)(S,{className:`h-full`,children:[(0,M.jsx)(x,{title:`Security`,subtitle:`Change the password used to sign in to this console`,icon:(0,M.jsx)(f,{size:16})}),(0,M.jsx)(b,{className:`flex flex-1 flex-col`,children:(0,M.jsx)(B,{})})]}),(0,M.jsx)(z,{})]})]}),(0,M.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,M.jsx)(`h2`,{className:`text-badge font-bold uppercase tracking-label text-text-tertiary`,children:`Data`}),(0,M.jsx)(L,{})]})]})]})}export{V as default};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{r as i}from"./toast-CNt_jzO4.js";import{o as a,t as o}from"./query-keys-D7wX2vM5.js";import{I as s,X as c,Z as l}from"./entry--yj84zk3.js";import{n as u}from"./input-BpVZdrbc.js";import{t as d}from"./layout-BioLW7gN.js";import{t as f}from"./backup-file-gdKIlg8U.js";var p=e(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),m=t(n(),1),h=r();function g(){let e=l(),[t,n]=(0,m.useState)(null),[r,d]=(0,m.useState)(`admin`),[g,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(null),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(`create`),[A,j]=(0,m.useState)(null),[M,N]=(0,m.useState)(null),P=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=!0;return a(`/auth/first-boot`).then(r=>{t&&(n(r.requires_setup),r.requires_setup||e(`/login`,{replace:!0}))}).catch(()=>{t&&n(!0)}),()=>{t=!1}},[e]);let F=async n=>{if(n.preventDefault(),t===!1){T(`This console already has an account. Sign in instead.`);return}if(!r.trim()){T(`Administrator username is required.`);return}if(b.length<8){T(`Administrator password must be at least 8 characters.`);return}if(b!==S){T(`Passwords do not match.`);return}D(!0),T(null);try{let t=await a(`/auth/setup`,{method:`POST`,body:JSON.stringify({username:r.trim(),password:b,...g.trim()?{display_name:g.trim()}:{}})});if(t.status!==`success`){T(t.message??`Setup failed. Please try again.`);return}s.removeQueries({queryKey:o.session.current}),e(`/login`,{replace:!0})}catch(e){if(e&&typeof e==`object`&&`message`in e){let t=e.message;if(typeof t==`string`){T(t);return}}T(`An unexpected network error occurred.`)}finally{D(!1)}},I=async t=>{D(!0),T(null);try{if(b.length<8){T(`Administrator password must be at least 8 characters.`);return}if(b!==S){T(`Passwords do not match.`);return}let n=await f(t),i=await a(`/auth/setup/restore`,{method:`POST`,body:JSON.stringify({backup:n,username:r.trim(),password:b,...g.trim()?{display_name:g.trim()}:{}})});if(i.status!==`success`){T(i.message??`Restore failed. Please try again.`);return}s.removeQueries({queryKey:o.session.current}),e(`/login`,{replace:!0})}catch(e){if(e instanceof Error){T(e.message);return}T(`An unexpected network error occurred.`)}finally{D(!1)}},L=e=>{if(j(e),T(null),e===null){N(null);return}f(e).then(async t=>{try{let n=await a(`/auth/setup/inspect`,{method:`POST`,body:JSON.stringify({backup:t})});if(n.status!==`success`){N(null),T(n.message??`Could not read that backup.`);return}N({fileName:e.name,version:n.version??0,exportedAt:n.exportedAt??``,rows:n.rows??[],total:n.total??0,warnings:n.warnings??[]})}catch{N(null)}}).catch(e=>{N(null),T(e instanceof Error?e.message:`That file is not a JSON backup.`)})};return t===!1?(0,h.jsx)(`main`,{className:`auth-viewport`,children:(0,h.jsxs)(`div`,{className:`card-solid auth-window`,children:[(0,h.jsxs)(`div`,{className:`auth-header`,children:[(0,h.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,h.jsx)(`h1`,{className:`auth-title`,children:`Account Already Registered`}),(0,h.jsx)(`p`,{className:`auth-desc`,children:`This console already has an administrator account, so setup is closed. Sign in with the account that was created.`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,h.jsx)(v,{message:`Setup is already finished. Creating a second administrator is not possible from here.`}),(0,h.jsx)(c,{to:`/login`,className:`no-underline`,children:(0,h.jsx)(i,{variant:`primary`,type:`button`,className:`w-full h-20`,children:`Go to sign in`})})]})]})}):(0,h.jsx)(`main`,{className:`auth-viewport`,children:(0,h.jsxs)(`div`,{className:`card-solid auth-window`,children:[(0,h.jsxs)(`div`,{className:`auth-header`,children:[(0,h.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,h.jsx)(`h1`,{className:`auth-title`,children:`Cartethyia Console Setup`}),O===`create`?(0,h.jsx)(`p`,{className:`auth-desc`,children:`Configure the administrator account for Cartethyia AI Gateway`}):null]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 mb-7`,children:[(0,h.jsx)(i,{type:`button`,variant:O===`create`?`primary`:`secondary`,onClick:()=>k(`create`),children:`New account`}),(0,h.jsx)(i,{type:`button`,variant:O===`restore`?`primary`:`secondary`,onClick:()=>k(`restore`),children:`Restore`})]}),O===`restore`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`text-text-secondary text-caption`,children:`Backup file`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border-subtle px-3 py-2.5`,children:[(0,h.jsx)(i,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>P.current?.click(),disabled:E||t===null,children:`Choose file…`}),(0,h.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-caption text-text-secondary`,children:A?.name??`No file chosen`})]})]}),(0,h.jsx)(`input`,{ref:P,id:`setup-backup`,type:`file`,accept:`application/json,.json,.gz,application/gzip`,disabled:E,className:`hidden`,onChange:e=>{let t=e.target.files?.[0]??null;L(t),e.target.value=``}}),M?(0,h.jsx)(_,{preview:M}):null,(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`p`,{className:`m-0 text-text-secondary text-caption`,children:`Backups carry settings only — no logins. Create the administrator for this install.`}),(0,h.jsx)(u,{label:`Administrator Username`,id:`restore-username`,value:r,onChange:e=>d(e.target.value),required:!0,autoComplete:`username`}),(0,h.jsx)(u,{label:`Master Password`,hint:`(min. 8 chars)`,id:`restore-password`,type:`password`,required:!0,minLength:8,value:b,onChange:e=>x(e.target.value),autoComplete:`new-password`}),(0,h.jsx)(u,{label:`Confirm Password`,id:`restore-confirm`,type:`password`,required:!0,minLength:8,value:S,onChange:e=>C(e.target.value),autoComplete:`new-password`})]}),w?(0,h.jsx)(v,{message:w}):null,(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,h.jsx)(i,{type:`button`,variant:`secondary`,onClick:()=>k(`create`),disabled:E,children:`Cancel`}),(0,h.jsx)(i,{type:`button`,variant:`primary`,disabled:E||t===null||A===null,onClick:()=>{A&&I(A)},children:E?`Restoring…`:`Restore this backup`})]})]}):(0,h.jsxs)(`form`,{onSubmit:F,className:`flex flex-col gap-7`,children:[(0,h.jsx)(u,{label:`Administrator Username`,id:`setup-username`,value:r,onChange:e=>d(e.target.value),required:!0,autoComplete:`username`,placeholder:`e.g. admin, risun`}),(0,h.jsx)(u,{label:`Display Name`,hint:`(optional)`,id:`display-name`,value:g,onChange:e=>y(e.target.value),autoComplete:`name`,placeholder:`e.g. Administrator, risun`}),(0,h.jsx)(u,{label:`Master Password`,hint:`(min. 8 chars)`,id:`setup-password`,type:`password`,required:!0,minLength:8,value:b,onChange:e=>x(e.target.value),autoComplete:`new-password`}),(0,h.jsx)(u,{label:`Confirm Password`,id:`setup-confirm`,type:`password`,required:!0,minLength:8,value:S,onChange:e=>C(e.target.value),autoComplete:`new-password`}),w?(0,h.jsx)(v,{message:w}):null,(0,h.jsx)(i,{variant:`primary`,type:`submit`,disabled:E||t===null,className:`w-full mt-3 h-20`,icon:(0,h.jsx)(p,{size:15}),children:E?`Initializing…`:`Complete Setup`})]})]})})}function _({preview:e}){let t=e.rows.filter(e=>!e.supported),n=e.rows.filter(e=>e.supported),r=e.exportedAt?e.exportedAt.replace(`T`,` `).slice(0,19):`unknown`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 border border-inner-border rounded-control bg-surface-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center flex-wrap gap-1.5`,children:[(0,h.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap text-ellipsis text-body font-semibold`,title:e.fileName,children:e.fileName}),(0,h.jsxs)(`span`,{className:`inline-flex items-center flex-none px-3.5 py-px border border-inner-border rounded-md bg-surface-2 text-text-secondary text-badge tabular-nums`,children:[`v`,e.version]}),t.length>0?(0,h.jsxs)(`span`,{className:`inline-flex items-center flex-none px-3.5 py-px border rounded-md bg-surface-2 text-badge tabular-nums border-warning-line text-status-warning`,children:[t.length,` unsupported`]}):null]}),(0,h.jsxs)(`p`,{className:`m-0 text-text-secondary text-caption`,children:[e.total,` rows across `,e.rows.length,` tables · exported `,r]}),t.length>0?(0,h.jsx)(`p`,{className:`m-0 text-caption text-status-warning`,children:t.length===e.rows.length?`None of these tables exist in this build, so nothing can be restored.`:`This build no longer has some of these tables. The rest still restores.`}):null,e.rows.length===0?(0,h.jsx)(`p`,{className:`m-0 text-text-secondary text-caption`,children:`This backup is empty.`}):(0,h.jsx)(`div`,{className:`max-h-110 overflow-auto`,children:(0,h.jsx)(d,{headers:[`Table`,`Section`,`Rows`],dense:!0,children:[...n,...t].map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{children:e.table}),(0,h.jsx)(`td`,{children:e.section}),(0,h.jsx)(`td`,{className:`text-right`,children:e.supported?e.count:(0,h.jsx)(`span`,{className:`inline-flex items-center flex-none px-3.5 py-px border rounded-md bg-surface-2 text-badge tabular-nums border-warning-line text-status-warning`,children:`unsupported`})})]},`${e.section}/${e.table}`))})})]})}function v({message:e}){return(0,h.jsx)(`div`,{className:`py-5 px-7 rounded-control bg-red-soft text-red text-caption font-medium`,role:`alert`,children:e})}export{g as default};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{a as i}from"./toast-CNt_jzO4.js";import{at as a}from"./entry--yj84zk3.js";import{n as o}from"./stack-C9_uUjaA.js";var s=e(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),c=e(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),l=t(n(),1),u=r();function d({items:e,onReorder:t,disabled:n=!1,gap:r=`10px`,renderItem:d,label:f}){let[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(null),_=(0,l.useRef)(null),v=()=>{_.current=null,m(null),g(null)},y=(n,r)=>{if(n===r)return;let i=e.map(e=>e.id),a=i.indexOf(n),o=i.indexOf(r);a!==-1&&o!==-1&&(i.splice(o,0,...i.splice(a,1)),t(i))};return(0,u.jsx)(`div`,{role:`list`,"aria-label":f,className:i(`flex flex-col min-w-0`,o(r)??`gap-5`),children:e.map((r,o)=>{let l=p===r.id,f=h===r.id&&p!==null&&p!==r.id,b=r=>{let i=o+r;if(n||i<0||i>=e.length)return;let a=e.map(e=>e.id),[s]=a.splice(o,1);s!==void 0&&(a.splice(i,0,s),t(a))};return(0,u.jsxs)(`div`,{role:`listitem`,className:i(`relative flex items-stretch gap-5 min-w-0 rounded-card transition-opacity duration-150 ease-spring`,l&&`opacity-50`,f&&`before:absolute before:inset-x-0 before:top-0 before:h-0.5 before:bg-accent before:content-['']`),"data-dragging":l?`true`:void 0,"data-drop-target":f?`true`:void 0,onDragOver:e=>{n||_.current===null||(e.preventDefault(),e.dataTransfer.dropEffect=`move`,h!==r.id&&g(r.id))},onDrop:e=>{e.preventDefault();let t=_.current;t!==null&&y(t,r.id),v()},children:[(0,u.jsxs)(`div`,{className:`flex flex-none flex-col items-center gap-1 pt-4 text-text-tertiary select-none`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,u.jsx)(`span`,{className:`font-mono text-badge tabular-nums leading-none`,children:o+1}),(0,u.jsx)(`button`,{type:`button`,draggable:!n,"aria-label":`Drag item at position ${o+1} to reorder`,title:`Drag to reorder`,disabled:n,onDragStart:e=>{_.current=r.id,m(r.id),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,r.id)},onDragEnd:v,className:`grid size-7 cursor-grab place-items-center rounded-control text-text-tertiary hover:bg-hover active:cursor-grabbing disabled:cursor-not-allowed`,children:(0,u.jsx)(c,{size:14})})]}),(0,u.jsxs)(`div`,{className:`flex gap-1`,children:[(0,u.jsx)(`button`,{type:`button`,"aria-label":`Move item ${o+1} up`,title:`Move up`,disabled:n||o===0,onClick:()=>b(-1),className:`grid size-7 place-items-center rounded-control text-text-tertiary hover:bg-hover disabled:cursor-not-allowed disabled:opacity-40`,children:(0,u.jsx)(s,{size:14})}),(0,u.jsx)(`button`,{type:`button`,"aria-label":`Move item ${o+1} down`,title:`Move down`,disabled:n||o===e.length-1,onClick:()=>b(1),className:`grid size-7 place-items-center rounded-control text-text-tertiary hover:bg-hover disabled:cursor-not-allowed disabled:opacity-40`,children:(0,u.jsx)(a,{size:14})})]})]}),(0,u.jsx)(`div`,{className:`flex-auto min-w-0`,children:d(r,o)})]},r.id)})})}export{d as t};