@antseed/gateway-console 0.1.7 → 0.1.9

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 (167) hide show
  1. package/dist/assets/{Activity-C_HO7qSL.js → Activity-DrhhsiYE.js} +1 -1
  2. package/dist/assets/{Audit-CPbMBpcn.js → Audit-tBcMBtG2.js} +1 -1
  3. package/dist/assets/{ChainGate-XojWG6ik.js → ChainGate-bxLjo_3b.js} +1 -1
  4. package/dist/assets/ChannelClose-C0Y19KzJ.js +1 -0
  5. package/dist/assets/{Charts-BskMsr_y.js → Charts-CHTi7z3n.js} +1 -1
  6. package/dist/assets/{Chat-D0VwXSTJ.js → Chat-C1AfYZwW.js} +3 -3
  7. package/dist/assets/{ConnectWallet-bv1j8xJR.js → ConnectWallet-fHEv854J.js} +1 -1
  8. package/dist/assets/{DataTable-D-JhP6Cu.js → DataTable-CCEZoIzX.js} +1 -1
  9. package/dist/assets/{Disclosure-2Zc4btXj.js → Disclosure-BitAjv2r.js} +1 -1
  10. package/dist/assets/{KeyHolder-D2dEBiu4.js → KeyHolder-DSLJe1Wc.js} +1 -1
  11. package/dist/assets/{Keys-C8eP--Dj.js → Keys-C22oAYzQ.js} +1 -1
  12. package/dist/assets/{Logs-CkyveD5I.js → Logs-DHuR0CKc.js} +1 -1
  13. package/dist/assets/{Members-CstL7rtd.js → Members-ZyqdMsMd.js} +1 -1
  14. package/dist/assets/{Migrate-DWKWE9N-.js → Migrate-TGloMMad.js} +1 -1
  15. package/dist/assets/Models-CM4ay6RE.js +1 -0
  16. package/dist/assets/OperatorActions-DPQvd1zg.js +1 -0
  17. package/dist/assets/{OperatorGateAlert-CQtV_buR.js → OperatorGateAlert-CEK2vyQ9.js} +1 -1
  18. package/dist/assets/{Overview-DTWHu-uz.js → Overview-CPoqW_Mi.js} +1 -1
  19. package/dist/assets/{PeerPicker-DrpM2w08.js → PeerPicker-w_ZaksUm.js} +1 -1
  20. package/dist/assets/{PolicyEditor-DNb3bKbN.js → PolicyEditor-BOjadRE8.js} +1 -1
  21. package/dist/assets/{PolicyField-CfklGeps.js → PolicyField-BbDSVgcK.js} +1 -1
  22. package/dist/assets/{Presets-CHEpKMLB.js → Presets-9x2m9R-f.js} +1 -1
  23. package/dist/assets/Providers-CqYXx8xK.js +1 -0
  24. package/dist/assets/RequestLog-39L0RtJc.js +1 -0
  25. package/dist/assets/Rewards-D9omoUfP.js +2 -0
  26. package/dist/assets/RewardsClaim-CWJBaJEv.js +1 -0
  27. package/dist/assets/{Routing-D7AS9ogG.js → Routing-4gxa6VdE.js} +1 -1
  28. package/dist/assets/{Segmented-BJMfyrv9.js → Segmented-D_Yun-tG.js} +1 -1
  29. package/dist/assets/SelectField-D3qPiNQz.js +1 -0
  30. package/dist/assets/{Settings-DYAb7Idr.js → Settings-Bo654hg3.js} +6 -6
  31. package/dist/assets/Staking-HKOLSr5r.js +1 -0
  32. package/dist/assets/StakingDashboard-BHU6EJ_h.js +1 -0
  33. package/dist/assets/StakingDashboard-CJbBUUQE.css +1 -0
  34. package/dist/assets/{Switch-DQFMOyMT.js → Switch-BmFsXcr8.js} +1 -1
  35. package/dist/assets/{Tabs-0IMgC9uU.js → Tabs-DmkE9BPd.js} +1 -1
  36. package/dist/assets/TextAreaField-RZPCzhKZ.js +1 -0
  37. package/dist/assets/{UsageByModel-D-xMV8ke.js → UsageByModel-nhGKdBi8.js} +1 -1
  38. package/dist/assets/Wallet-jy4q5mLQ.js +9 -0
  39. package/dist/assets/{WalletConfirm-D_hppAfp.js → WalletConfirm-dV_LWLAS.js} +1 -1
  40. package/dist/assets/WalletFunding-B3t7wm--.js +1 -0
  41. package/dist/assets/{WalletSignIn-Dml1bE7_.js → WalletSignIn-BTt56Pbi.js} +1 -1
  42. package/dist/assets/{Workspaces-Dc7lPxxi.js → Workspaces-mfw5erSQ.js} +1 -1
  43. package/dist/assets/{add-DhKjYYaW.js → add-BWOpvuwn.js} +1 -1
  44. package/dist/assets/{all-wallets-B1SSU1TF.js → all-wallets-Dzo5pBZj.js} +1 -1
  45. package/dist/assets/{app-store-fOZ_23bX.js → app-store-D7NT8p3m.js} +1 -1
  46. package/dist/assets/{apple-_8Zbl9Z_.js → apple-DZKBu-O0.js} +1 -1
  47. package/dist/assets/{arrow-bottom-DPc1Zc38.js → arrow-bottom-CL8pk1cz.js} +1 -1
  48. package/dist/assets/{arrow-bottom-circle-B0tSexI5.js → arrow-bottom-circle-CfYYPCEB.js} +1 -1
  49. package/dist/assets/{arrow-left-BRvgjm8f.js → arrow-left-DVKw3BfQ.js} +1 -1
  50. package/dist/assets/{arrow-right-0-kK_2Ru.js → arrow-right-LIBetaMw.js} +1 -1
  51. package/dist/assets/{arrow-top-Bxpi_NOR.js → arrow-top-Bdq-JU1Z.js} +1 -1
  52. package/dist/assets/{bank-CDSQYgdF.js → bank-BYRxGjPq.js} +1 -1
  53. package/dist/assets/{basic-75Z8JR0c.js → basic-CZ6XfWue.js} +1 -1
  54. package/dist/assets/{browser-BdywFN9y.js → browser-4mXAG82s.js} +1 -1
  55. package/dist/assets/{bundle-full-zTuzz_v7.js → bundle-full-BIYMHvS6.js} +1 -1
  56. package/dist/assets/{card-GqsikqTj.js → card-CHQPd736.js} +1 -1
  57. package/dist/assets/ccip-CDMxOoDo.js +1 -0
  58. package/dist/assets/{checkmark-Bq0DRPd3.js → checkmark-8o_U76Ey.js} +1 -1
  59. package/dist/assets/{checkmark-bold-BbhqFFvY.js → checkmark-bold-DLi4Gcn_.js} +1 -1
  60. package/dist/assets/{chevron-bottom-LkblkfKl.js → chevron-bottom-DmX6fEDV.js} +1 -1
  61. package/dist/assets/{chevron-left-D5ZHrKz6.js → chevron-left-AyKJMTQa.js} +1 -1
  62. package/dist/assets/{chevron-right-CZEpGP_Y.js → chevron-right-DQ8e2bPT.js} +1 -1
  63. package/dist/assets/{chevron-top-D081n7MO.js → chevron-top-B5o-6za5.js} +1 -1
  64. package/dist/assets/{chrome-store-DD4b3pix.js → chrome-store-BSncx9O2.js} +1 -1
  65. package/dist/assets/{clock-CIkNUdlW.js → clock-DBlIwqMs.js} +1 -1
  66. package/dist/assets/{close-MjqlUFnr.js → close-CGfPRgam.js} +1 -1
  67. package/dist/assets/{code-block-BDV3hPqW.js → code-block-B9znTLtr.js} +1 -1
  68. package/dist/assets/{coinPlaceholder-CQSfO1WN.js → coinPlaceholder-BUSXHM7f.js} +1 -1
  69. package/dist/assets/{compass-C5kD2161.js → compass-WMx9aHQn.js} +1 -1
  70. package/dist/assets/{copy-Zrz0R86f.js → copy-4QWyzVbB.js} +1 -1
  71. package/dist/assets/{core-CH8pl6He.js → core-4C0uPyns.js} +21 -22
  72. package/dist/assets/cursor-C_vrGLpb.js +3 -0
  73. package/dist/assets/{cursor-transparent-DsWWbUhZ.js → cursor-transparent-BaithBa8.js} +1 -1
  74. package/dist/assets/{desktop-C0-agZjr.js → desktop-pj3LdQx_.js} +1 -1
  75. package/dist/assets/{disconnect-DMDC_Xs6.js → disconnect-cmEUajMk.js} +1 -1
  76. package/dist/assets/{discord-C3cOERbi.js → discord-BYVJX-t1.js} +1 -1
  77. package/dist/assets/{en_US-Y4ZOVFV4-D2zZwqC_.js → en_US-Y4ZOVFV4-BZ-715IV.js} +22 -22
  78. package/dist/assets/{etherscan-m6ykHpsX.js → etherscan-BdQaeBLV.js} +1 -1
  79. package/dist/assets/{exclamation-triangle-Ndf0Nf0N.js → exclamation-triangle-B5R8OH8o.js} +1 -1
  80. package/dist/assets/{extension-nQAe1Vqe.js → extension-DrkCTDz1.js} +1 -1
  81. package/dist/assets/{external-link-Ct2elSIz.js → external-link-CZIsXhQB.js} +1 -1
  82. package/dist/assets/{facebook-BcEQkgXt.js → facebook-B8mGiKom.js} +1 -1
  83. package/dist/assets/{farcaster-Bm-SoK56.js → farcaster-BlEPprye.js} +1 -1
  84. package/dist/assets/{filters-DkNOeYpX.js → filters-QpslZY8t.js} +1 -1
  85. package/dist/assets/{github-CLUyT4GZ.js → github-3U8av1u0.js} +1 -1
  86. package/dist/assets/{google-Bzb8d8aw.js → google-DuIQFQyG.js} +1 -1
  87. package/dist/assets/{help-circle-C5S7GK9d.js → help-circle-BKX8azWY.js} +1 -1
  88. package/dist/assets/{highlighted-body-KQOG7T2V-4RHbDcyq.js → highlighted-body-KQOG7T2V-9-ocLujg.js} +1 -1
  89. package/dist/assets/{id-CjwfmICa.js → id-DoN-p9_h.js} +1 -1
  90. package/dist/assets/{image-CZAX7pOB.js → image-DnOVeCbR.js} +1 -1
  91. package/dist/assets/{index-BGpZJvqT.js → index-A9482YJO.js} +1 -1
  92. package/dist/assets/index-B25V3jQV.js +16 -0
  93. package/dist/assets/{index-k_E0JTj8.js → index-BPmBiG1M.js} +3 -3
  94. package/dist/assets/index-BhwNCc8y.js +1 -0
  95. package/dist/assets/index-BpFwvYMF.js +91 -0
  96. package/dist/assets/{index-D8vXwUTI.css → index-C9evdHF9.css} +1 -1
  97. package/dist/assets/index-DeVTk1EB.js +1 -0
  98. package/dist/assets/index.es-C1jtws71.js +38 -0
  99. package/dist/assets/{info-CRdyUurs.js → info-CdmGz8ET.js} +1 -1
  100. package/dist/assets/{info-circle-Bulr5-X0.js → info-circle-C6CmWEn4.js} +1 -1
  101. package/dist/assets/{lightbulb-BccTnGBf.js → lightbulb-BAyNXoa1.js} +1 -1
  102. package/dist/assets/{limits-DnXi8KYO.js → limits-DjiKmaDB.js} +1 -1
  103. package/dist/assets/{mail-J1p7aEAL.js → mail-CiF1vNhi.js} +1 -1
  104. package/dist/assets/{mermaid-MCJ5UELQ-DS0t3vui.js → mermaid-MCJ5UELQ-nKICVXNz.js} +3 -3
  105. package/dist/assets/{metamask-sdk-DIbH7ulQ.js → metamask-sdk-DkF2jP-o.js} +1 -1
  106. package/dist/assets/{mobile-DweZDHJs.js → mobile-C1sek6EE.js} +1 -1
  107. package/dist/assets/models-CJU4tPJk.js +1 -0
  108. package/dist/assets/{more-ftCZ78Ri.js → more-Dg3gTue9.js} +1 -1
  109. package/dist/assets/{network-placeholder-C56vppZF.js → network-placeholder-DjgO487Z.js} +1 -1
  110. package/dist/assets/{nftPlaceholder-VVSPOtjy.js → nftPlaceholder-CJQkl27U.js} +1 -1
  111. package/dist/assets/{off-CB6AUEcL.js → off-CH17X0ZN.js} +1 -1
  112. package/dist/assets/{play-store-Cbt8S4Fy.js → play-store-CQuK3mcO.js} +1 -1
  113. package/dist/assets/{plus-D4MGLM7H.js → plus-pEvbyOXN.js} +1 -1
  114. package/dist/assets/{qr-code-BcnaLoHb.js → qr-code-Cl8u00kF.js} +1 -1
  115. package/dist/assets/{recycle-horizontal-CbXg23Et.js → recycle-horizontal-C2j4VihN.js} +1 -1
  116. package/dist/assets/{refresh-DIF_EhZz.js → refresh-DiGzIXYL.js} +1 -1
  117. package/dist/assets/{reown-logo-C6kx1Dpz.js → reown-logo-lnPAI4aT.js} +1 -1
  118. package/dist/assets/{search-DuCbGgsb.js → search-yadtJ599.js} +1 -1
  119. package/dist/assets/{send-DkMK92qb.js → send-C3NLDzpo.js} +1 -1
  120. package/dist/assets/sendTransaction-qrdT91Tm.js +1 -0
  121. package/dist/assets/{swapHorizontal-m5CpC7Qf.js → swapHorizontal-C3NCkGQo.js} +1 -1
  122. package/dist/assets/{swapHorizontalBold-15eicY1d.js → swapHorizontalBold-BZwhavke.js} +1 -1
  123. package/dist/assets/{swapHorizontalMedium-Dgs4j9qs.js → swapHorizontalMedium-Cmnd2nih.js} +1 -1
  124. package/dist/assets/{swapHorizontalRoundedBold-C9M5muAI.js → swapHorizontalRoundedBold-gSkn4e0W.js} +1 -1
  125. package/dist/assets/{swapVertical-Drjd1fn6.js → swapVertical-B3cp9dIz.js} +1 -1
  126. package/dist/assets/{telegram-BgkRAeS_.js → telegram-CCcfHXb2.js} +1 -1
  127. package/dist/assets/{three-dots-C5xkxl8k.js → three-dots-Dn7VO-lq.js} +1 -1
  128. package/dist/assets/{twitch-CQfDaj1f.js → twitch-C46oL1KF.js} +1 -1
  129. package/dist/assets/{twitterIcon-XiikTDVV.js → twitterIcon-CAkiEmDS.js} +1 -1
  130. package/dist/assets/usage-yuqGLybi.js +1 -0
  131. package/dist/assets/{useInfiniteQuery-D4a4EjtW.js → useInfiniteQuery-Dwl-oWNd.js} +1 -1
  132. package/dist/assets/useTx-CT2tKEAI.js +1 -0
  133. package/dist/assets/{verify-filled-o6LejTdA.js → verify-filled-CtFkkLAN.js} +1 -1
  134. package/dist/assets/{verify-B_XwiCO4.js → verify-jbEYtj7t.js} +1 -1
  135. package/dist/assets/{w3m-modal-BmGCQizE.js → w3m-modal-Drzo9R1s.js} +1 -1
  136. package/dist/assets/waitForCallsStatus-CU9lZ8Vj.js +1 -0
  137. package/dist/assets/{wallet-2tmSJ8kt.js → wallet-B11Hl0Lf.js} +1 -1
  138. package/dist/assets/{wallet-placeholder-BEYpeK2m.js → wallet-placeholder-DwLspbFR.js} +1 -1
  139. package/dist/assets/{walletconnect-COxaZlsg.js → walletconnect-3aC0SnNJ.js} +1 -1
  140. package/dist/assets/{warning-circle-CF-y1g4G.js → warning-circle-DuqXAhpW.js} +1 -1
  141. package/dist/assets/writeContract-m5SoBxcM.js +1 -0
  142. package/dist/assets/{x-YfU_qc_f.js → x-DTeu3B0J.js} +1 -1
  143. package/dist/index.html +2 -2
  144. package/package.json +1 -1
  145. package/dist/assets/ChannelClose-DoIyd3cZ.js +0 -1
  146. package/dist/assets/Models-WCJJM5l5.js +0 -1
  147. package/dist/assets/OperatorActions-C13p8Mup.js +0 -1
  148. package/dist/assets/Providers-CT_U_xku.js +0 -1
  149. package/dist/assets/RequestLog-aPr3ty82.js +0 -1
  150. package/dist/assets/Rewards-DLmqivnL.js +0 -2
  151. package/dist/assets/RewardsClaim-CcLsyzPs.js +0 -1
  152. package/dist/assets/SelectField-Yrfi46XZ.js +0 -1
  153. package/dist/assets/TextAreaField-CKrBh0oZ.js +0 -1
  154. package/dist/assets/Wallet-eX5k-E9r.js +0 -9
  155. package/dist/assets/WalletFunding-Cd8311aj.js +0 -1
  156. package/dist/assets/ccip-CGkS6Jyg.js +0 -1
  157. package/dist/assets/cursor-BkEr5_-X.js +0 -3
  158. package/dist/assets/index-B8VMfX86.js +0 -1
  159. package/dist/assets/index-BadBPNlq.js +0 -91
  160. package/dist/assets/index-BwpQbdIU.js +0 -1
  161. package/dist/assets/index-CZ-EHDzh.js +0 -16
  162. package/dist/assets/index.es-CQ9CIS6P.js +0 -39
  163. package/dist/assets/models-KtwCOBAB.js +0 -1
  164. package/dist/assets/secp256k1-Cb4vPU9D.js +0 -1
  165. package/dist/assets/secp256k1-qeEbqQxX.js +0 -1
  166. package/dist/assets/usage-E97PY8Eg.js +0 -1
  167. package/dist/assets/useTx-sWvJMTA4.js +0 -1
@@ -1 +1 @@
1
- import{j as n,B as i}from"./index-BadBPNlq.js";import{C as c}from"./en_US-Y4ZOVFV4-D2zZwqC_.js";function u({label:e="Connect wallet",fullWidth:s=!0,size:r,variant:t}){return n.jsx(c.Custom,{children:({openConnectModal:a,mounted:l})=>n.jsx(i,{fullWidth:s,size:r,variant:t,disabled:!l,onClick:a,children:e})})}function h(){return n.jsx(c.Custom,{children:({account:e,chain:s,mounted:r,openAccountModal:t,openChainModal:a})=>!r||!e||!s?null:n.jsxs("div",{className:"gc-connected",children:[n.jsx("span",{className:"gc-connected__dot","aria-hidden":"true"}),n.jsxs("span",{children:["Connected ",n.jsx("code",{className:"gc-mono",children:e.displayName})]}),s.unsupported&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"gc-warn",children:"Wrong network"}),n.jsx(i,{variant:"link",size:"sm",onClick:a,children:"Switch network"})]}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx(i,{variant:"link",size:"sm",onClick:t,children:"Change"})]})})}export{u as C,h as a};
1
+ import{j as n,B as i}from"./index-BpFwvYMF.js";import{C as c}from"./en_US-Y4ZOVFV4-BZ-715IV.js";function u({label:e="Connect wallet",fullWidth:s=!0,size:r,variant:t}){return n.jsx(c.Custom,{children:({openConnectModal:a,mounted:l})=>n.jsx(i,{fullWidth:s,size:r,variant:t,disabled:!l,onClick:a,children:e})})}function h(){return n.jsx(c.Custom,{children:({account:e,chain:s,mounted:r,openAccountModal:t,openChainModal:a})=>!r||!e||!s?null:n.jsxs("div",{className:"gc-connected",children:[n.jsx("span",{className:"gc-connected__dot","aria-hidden":"true"}),n.jsxs("span",{children:["Connected ",n.jsx("code",{className:"gc-mono",children:e.displayName})]}),s.unsupported&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"gc-warn",children:"Wrong network"}),n.jsx(i,{variant:"link",size:"sm",onClick:a,children:"Switch network"})]}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx(i,{variant:"link",size:"sm",onClick:t,children:"Change"})]})})}export{u as C,h as a};
@@ -1 +1 @@
1
- import{r as j,j as t,aA as m,B as b}from"./index-BadBPNlq.js";function _(e){return[e.align==="right"?"as-num":null,e.secondary?"as-secondary":null,e.optional?"as-optional":null].filter(Boolean).join(" ")||void 0}function A(e,s){if((e==null?void 0:e.key)===s)return e.direction==="asc"?"ascending":"descending"}function M(e,s){return(e==null?void 0:e.key)!==s?"":e.direction==="asc"?"↑":"↓"}function C({rows:e,columns:s,rowKey:p,onRowClick:r,rowLabel:l,actions:d,empty:u,label:y,initialSort:k,selectedKey:g}){const[n,v]=j.useState(k??null),N=j.useMemo(()=>{if(!n)return e;const a=s.find(h=>h.key===n.key);if(!(a!=null&&a.sortValue))return e;const c=a.sortValue,x=n.direction==="asc"?1:-1;return[...e].sort((h,i)=>{const f=c(h),o=c(i);return f===o?0:f===null?1:o===null?-1:(f<o?-1:1)*x})},[e,s,n]);return e.length===0&&u?t.jsx(t.Fragment,{children:u}):t.jsx("div",{className:"as-table-wrap",children:t.jsxs("table",{className:"as-table","aria-label":y,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[s.map(a=>{const c=(n==null?void 0:n.key)===a.key;return t.jsx("th",{className:_(a),style:a.width?{width:a.width}:void 0,"aria-sort":A(n,a.key),children:a.sortValue?t.jsxs("button",{type:"button",className:"as-table__sort",onClick:()=>v({key:a.key,direction:c&&n.direction==="desc"?"asc":"desc"}),children:[a.header,t.jsx("span",{"aria-hidden":"true",className:"as-table__arrow",children:M(n,a.key)})]}):a.header},a.key)}),d&&t.jsx("th",{className:"as-table__actions",children:t.jsx("span",{className:"as-sr",children:"Actions"})})]})}),t.jsx("tbody",{children:N.map(a=>{const c=p(a),x=g!=null&&c===g,h=[r?"as-table__row--click":null,x?"as-table__row--selected":null].filter(Boolean).join(" ");return t.jsxs("tr",{className:h||void 0,"aria-current":x?"true":void 0,onClick:r?()=>r(a):void 0,children:[s.map((i,f)=>t.jsx("td",{className:_(i),children:(()=>{const o=f===0&&r?t.jsx("button",{type:"button",className:"as-table__open","aria-label":l?`Open ${l(a)}`:void 0,onClick:P=>{P.stopPropagation(),r(a)},children:i.render(a)}):i.render(a);return i.after?t.jsxs("div",{className:"as-table__lead",children:[o,i.after(a)]}):o})()},i.key)),d&&t.jsx("td",{className:"as-table__actions",onClick:i=>i.stopPropagation(),children:t.jsx(m,{label:l?`Actions for ${l(a)}`:"Actions",items:d(a)})})]},c)})})]})})}function S(e,s,p=""){const[r,l]=j.useState(0);j.useEffect(()=>{l(0)},[p]);const d=Math.max(1,Math.ceil(e.length/s)),u=Math.min(r,d-1);return{items:e.slice(u*s,(u+1)*s),page:u,pages:d,total:e.length,setPage:l}}function E({pager:e,noun:s}){return e.pages<=1?null:t.jsxs("nav",{className:"as-pager","aria-label":`${s} pages`,children:[t.jsxs("span",{className:"as-pager__status",children:["Page ",e.page+1," of ",e.pages," · ",e.total," ",s]}),t.jsxs("div",{className:"as-pager__buttons",children:[t.jsx(b,{variant:"outline",size:"sm",disabled:e.page===0,onClick:()=>e.setPage(e.page-1),children:"Previous"}),t.jsx(b,{variant:"outline",size:"sm",disabled:e.page>=e.pages-1,onClick:()=>e.setPage(e.page+1),children:"Next"})]})]})}export{C as D,E as P,S as u};
1
+ import{r as j,j as t,aB as m,B as b}from"./index-BpFwvYMF.js";function _(e){return[e.align==="right"?"as-num":null,e.secondary?"as-secondary":null,e.optional?"as-optional":null].filter(Boolean).join(" ")||void 0}function A(e,s){if((e==null?void 0:e.key)===s)return e.direction==="asc"?"ascending":"descending"}function B(e,s){return(e==null?void 0:e.key)!==s?"":e.direction==="asc"?"↑":"↓"}function C({rows:e,columns:s,rowKey:p,onRowClick:r,rowLabel:l,actions:d,empty:u,label:y,initialSort:k,selectedKey:g}){const[n,v]=j.useState(k??null),N=j.useMemo(()=>{if(!n)return e;const a=s.find(h=>h.key===n.key);if(!(a!=null&&a.sortValue))return e;const c=a.sortValue,x=n.direction==="asc"?1:-1;return[...e].sort((h,i)=>{const f=c(h),o=c(i);return f===o?0:f===null?1:o===null?-1:(f<o?-1:1)*x})},[e,s,n]);return e.length===0&&u?t.jsx(t.Fragment,{children:u}):t.jsx("div",{className:"as-table-wrap",children:t.jsxs("table",{className:"as-table","aria-label":y,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[s.map(a=>{const c=(n==null?void 0:n.key)===a.key;return t.jsx("th",{className:_(a),style:a.width?{width:a.width}:void 0,"aria-sort":A(n,a.key),children:a.sortValue?t.jsxs("button",{type:"button",className:"as-table__sort",onClick:()=>v({key:a.key,direction:c&&n.direction==="desc"?"asc":"desc"}),children:[a.header,t.jsx("span",{"aria-hidden":"true",className:"as-table__arrow",children:B(n,a.key)})]}):a.header},a.key)}),d&&t.jsx("th",{className:"as-table__actions",children:t.jsx("span",{className:"as-sr",children:"Actions"})})]})}),t.jsx("tbody",{children:N.map(a=>{const c=p(a),x=g!=null&&c===g,h=[r?"as-table__row--click":null,x?"as-table__row--selected":null].filter(Boolean).join(" ");return t.jsxs("tr",{className:h||void 0,"aria-current":x?"true":void 0,onClick:r?()=>r(a):void 0,children:[s.map((i,f)=>t.jsx("td",{className:_(i),children:(()=>{const o=f===0&&r?t.jsx("button",{type:"button",className:"as-table__open","aria-label":l?`Open ${l(a)}`:void 0,onClick:P=>{P.stopPropagation(),r(a)},children:i.render(a)}):i.render(a);return i.after?t.jsxs("div",{className:"as-table__lead",children:[o,i.after(a)]}):o})()},i.key)),d&&t.jsx("td",{className:"as-table__actions",onClick:i=>i.stopPropagation(),children:t.jsx(m,{label:l?`Actions for ${l(a)}`:"Actions",items:d(a)})})]},c)})})]})})}function S(e,s,p=""){const[r,l]=j.useState(0);j.useEffect(()=>{l(0)},[p]);const d=Math.max(1,Math.ceil(e.length/s)),u=Math.min(r,d-1);return{items:e.slice(u*s,(u+1)*s),page:u,pages:d,total:e.length,setPage:l}}function E({pager:e,noun:s}){return e.pages<=1?null:t.jsxs("nav",{className:"as-pager","aria-label":`${s} pages`,children:[t.jsxs("span",{className:"as-pager__status",children:["Page ",e.page+1," of ",e.pages," · ",e.total," ",s]}),t.jsxs("div",{className:"as-pager__buttons",children:[t.jsx(b,{variant:"outline",size:"sm",disabled:e.page===0,onClick:()=>e.setPage(e.page-1),children:"Previous"}),t.jsx(b,{variant:"outline",size:"sm",disabled:e.page>=e.pages-1,onClick:()=>e.setPage(e.page+1),children:"Next"})]})]})}export{C as D,E as P,S as u};
@@ -1 +1 @@
1
- import{j as s}from"./index-BadBPNlq.js";function n({title:i,summary:e,children:o,defaultOpen:r,className:a}){return s.jsxs("details",{className:["as-disclosure",a].filter(Boolean).join(" "),open:r,children:[s.jsxs("summary",{className:"as-disclosure__summary",children:[s.jsx("span",{className:"as-disclosure__title",children:i}),e!=null&&e!==""&&s.jsx("span",{className:"as-disclosure__meta",children:e}),s.jsx("svg",{className:"as-disclosure__chevron",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s.jsx("div",{className:"as-disclosure__body",children:o})]})}export{n as D};
1
+ import{j as s}from"./index-BpFwvYMF.js";function n({title:i,summary:e,children:o,defaultOpen:r,className:a}){return s.jsxs("details",{className:["as-disclosure",a].filter(Boolean).join(" "),open:r,children:[s.jsxs("summary",{className:"as-disclosure__summary",children:[s.jsx("span",{className:"as-disclosure__title",children:i}),e!=null&&e!==""&&s.jsx("span",{className:"as-disclosure__meta",children:e}),s.jsx("svg",{className:"as-disclosure__chevron",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s.jsx("div",{className:"as-disclosure__body",children:o})]})}export{n as D};
@@ -1 +1 @@
1
- import{al as v,am as N,e as g,q,j as e,an as k,ao as x,ap as w,B as R,I as S,P as B,v as y,aq as E,S as P,ar as _,g as n,l as d,Q as A,W as I,h as D,as as K,at as L,A as O,m as c,f as j,au as T}from"./index-BadBPNlq.js";import{R as F}from"./RequestLog-aPr3ty82.js";import{r as M,e as Q}from"./usage-E97PY8Eg.js";import{B as $}from"./Charts-BskMsr_y.js";import"./useInfiniteQuery-D4a4EjtW.js";import"./PeerPicker-DrpM2w08.js";import"./DataTable-D-JhP6Cu.js";function J(){var m;const h=v(),u=N(),s=((m=u.data)==null?void 0:m.kind)==="key"?u.data.me.key:null,l=Date.now(),o=M("30d",l),f=g({queryKey:q.usage({key:s==null?void 0:s.id,from:o,groupBy:"day"}),queryFn:()=>j.usage.report({key:s.id,from:o,to:l,groupBy:"day"}),enabled:!!s}),b=g({queryKey:["key-periods",s==null?void 0:s.id],enabled:!!s,queryFn:async()=>{const a=await Promise.all(["daily","weekly","monthly"].map(async i=>{const t=await j.usage.report({key:s.id,from:T(i,l)});return[i,c(t.totals.spent)]}));return Object.fromEntries([...a,["total",c(s.usage.spent)]])}});return e.jsxs("div",{className:"gc-keyholder",children:[e.jsxs("header",{className:"gc-topbar",children:[e.jsxs("div",{className:"gc-topbar__inner",children:[e.jsx(k,{to:null,tagged:!0}),e.jsx("div",{className:"gc-topbar__spacer"}),e.jsx(x,{className:"gc-endpoint--inline"}),e.jsx(w,{}),e.jsx(R,{variant:"outline",size:"sm",leadingIcon:e.jsx(S.logout,{size:14}),onClick:()=>void h(),children:"Sign out"})]}),e.jsx("div",{className:"gc-topbar__strip",children:e.jsx(x,{})})]}),e.jsx("main",{className:"gc-main",id:"gc-main",children:s&&e.jsxs("div",{className:"gc-page",children:[e.jsx(B,{title:s.label,description:e.jsxs(e.Fragment,{children:["Key ",e.jsx("code",{children:s.hint})," · ",s.status==="active"?e.jsx(y,{tone:"success",children:"Active"}):e.jsx(y,{tone:"danger",children:"Revoked"})]})}),e.jsx("div",{className:"gc-grid gc-grid--4",children:E.map(a=>{var p;const i=s.limits[a],t=((p=b.data)==null?void 0:p[a])??null,r=i===null?null:c(i);return e.jsx(P,{label:`${_[a]} spend`,value:t===null?"…":n(t),sub:r===null?"No limit":`${n(Math.max(r-(t??0),0))} left of ${n(r)}`,meter:r&&t!==null?t/r:null},a)})}),e.jsx(d,{title:"Spend, last 30 days",children:e.jsx(A,{query:f,rows:1,children:a=>e.jsx($,{format:n,label:"Daily spend",points:Q(a,o,l)})})}),e.jsx(d,{title:"Key details",children:e.jsx(I,{items:[["Requests",D(s.usage.requests)],["Spent in total",n(s.usage.spent)],["Last used",K(s.lastUsedAt)],["Expires",s.expiresAt?L(s.expiresAt):"Never"],["Top-ups",s.topupEnabled?"Allowed":"Off"],["Routing",O(s.routingPolicy)]]})}),e.jsx(d,{flush:!0,title:"Requests",children:e.jsx(F,{filter:{key:s.id},showKey:!1})})]})})]})}export{J as default};
1
+ import{am as b,an as N,e as g,q,j as e,ao as k,ap as x,aq as w,B as R,I as S,P as B,v as y,ar as E,S as P,as as _,g as n,l as d,Q as A,X as I,h as D,at as K,au as L,A as O,m as c,f as j,av as T}from"./index-BpFwvYMF.js";import{R as F}from"./RequestLog-39L0RtJc.js";import{r as M,e as Q}from"./usage-yuqGLybi.js";import{B as $}from"./Charts-CHTi7z3n.js";import"./useInfiniteQuery-Dwl-oWNd.js";import"./PeerPicker-w_ZaksUm.js";import"./DataTable-CCEZoIzX.js";function J(){var m;const h=b(),u=N(),s=((m=u.data)==null?void 0:m.kind)==="key"?u.data.me.key:null,l=Date.now(),o=M("30d",l),f=g({queryKey:q.usage({key:s==null?void 0:s.id,from:o,groupBy:"day"}),queryFn:()=>j.usage.report({key:s.id,from:o,to:l,groupBy:"day"}),enabled:!!s}),v=g({queryKey:["key-periods",s==null?void 0:s.id],enabled:!!s,queryFn:async()=>{const a=await Promise.all(["daily","weekly","monthly"].map(async i=>{const t=await j.usage.report({key:s.id,from:T(i,l)});return[i,c(t.totals.spent)]}));return Object.fromEntries([...a,["total",c(s.usage.spent)]])}});return e.jsxs("div",{className:"gc-keyholder",children:[e.jsxs("header",{className:"gc-topbar",children:[e.jsxs("div",{className:"gc-topbar__inner",children:[e.jsx(k,{to:null,tagged:!0}),e.jsx("div",{className:"gc-topbar__spacer"}),e.jsx(x,{className:"gc-endpoint--inline"}),e.jsx(w,{}),e.jsx(R,{variant:"outline",size:"sm",leadingIcon:e.jsx(S.logout,{size:14}),onClick:()=>void h(),children:"Sign out"})]}),e.jsx("div",{className:"gc-topbar__strip",children:e.jsx(x,{})})]}),e.jsx("main",{className:"gc-main",id:"gc-main",children:s&&e.jsxs("div",{className:"gc-page",children:[e.jsx(B,{title:s.label,description:e.jsxs(e.Fragment,{children:["Key ",e.jsx("code",{children:s.hint})," · ",s.status==="active"?e.jsx(y,{tone:"success",children:"Active"}):e.jsx(y,{tone:"danger",children:"Revoked"})]})}),e.jsx("div",{className:"gc-grid gc-grid--4",children:E.map(a=>{var p;const i=s.limits[a],t=((p=v.data)==null?void 0:p[a])??null,r=i===null?null:c(i);return e.jsx(P,{label:`${_[a]} spend`,value:t===null?"…":n(t),sub:r===null?"No limit":`${n(Math.max(r-(t??0),0))} left of ${n(r)}`,meter:r&&t!==null?t/r:null},a)})}),e.jsx(d,{title:"Spend, last 30 days",children:e.jsx(A,{query:f,rows:1,children:a=>e.jsx($,{format:n,label:"Daily spend",points:Q(a,o,l)})})}),e.jsx(d,{title:"Key details",children:e.jsx(I,{items:[["Requests",D(s.usage.requests)],["Spent in total",n(s.usage.spent)],["Last used",K(s.lastUsedAt)],["Expires",s.expiresAt?L(s.expiresAt):"Never"],["Top-ups",s.topupEnabled?"Allowed":"Off"],["Routing",O(s.routingPolicy)]]})}),e.jsx(d,{flush:!0,title:"Requests",children:e.jsx(F,{filter:{key:s.id},showKey:!1})})]})})]})}export{J as default};
@@ -1 +1 @@
1
- import{aB as ke,r as m,a_ as je,a$ as fe,j as s,C as ne,b0 as ve,X as Se,B as S,u as le,a as Ce,i as ce,d as de,c as Pe,t as ie,P as Le,I as K,T as U,l as Ne,Q as Ae,b1 as Ee,z as ue,b2 as X,A as me,g as ye,m as Te,as as Re,E as Z,b3 as pe,D as De,q as F,f as C,v,at as J,e as Ie,b4 as Me,b5 as Ke,b6 as Ue,b7 as ee,o as Fe,W as _e}from"./index-BadBPNlq.js";import{u as se,a as Be,P as Oe}from"./PolicyField-CfklGeps.js";import{T as Ye}from"./Tabs-0IMgC9uU.js";import{l as te,d as ae,L as We}from"./limits-DnXi8KYO.js";import{t as $e}from"./dates-Pi3-Ywng.js";import{r as qe,e as ze}from"./usage-E97PY8Eg.js";import{S as he}from"./Switch-DQFMOyMT.js";import{D as Ve,u as He,P as Qe}from"./DataTable-D-JhP6Cu.js";import{b as Ge}from"./Charts-BskMsr_y.js";import{S as Xe}from"./SelectField-Yrfi46XZ.js";import"./PolicyEditor-DNb3bKbN.js";import"./PeerPicker-DrpM2w08.js";import"./Segmented-BJMfyrv9.js";import"./roving-DkptacxO.js";import"./Disclosure-2Zc4btXj.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Ye,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Je="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=qe(Je,l),c=Ie({queryKey:F.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Ge,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:ze(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${J(e.expiresAt)}`,children:["Until ",J(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(_e,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx(We,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Oe,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var q;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[x,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState($e((e==null?void 0:e.expiresAt)??null)),[g,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,b]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),be=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((q=be.data)==null?void 0:q.buyerIdentity))==="default",B=de(y.id,a&&!e),R=Be(),[O,Y]=m.useState(null),D=p.admin,W=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let $=null;T&&($=p.admin?"Your restrictions as the key owner":"Your restrictions");const ge=e?"Save":"Create key",xe=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,z=D?w.build():null,V=W?t.build():null,H=ae(x),Q=ae(L);if(e){const f=Ue(p,e,{label:h.trim(),expiresAt:u,topupEnabled:g,adminLimits:H,adminPolicy:z,ownerLimits:Q,ownerPolicy:V}),G=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return G===ee?ee:{key:G}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:Q,routingPolicy:p.admin?z:V,topupEnabled:p.admin?g:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[F.group("keys")],toast:u=>u.secret?null:"Key saved",onError:Y});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),Y(null),I.mutate()},children:[s.jsx(U,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&B.data&&s.jsx(Xe,{label:"Owner",value:n,onChange:b,options:B.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:T?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:x,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&T&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),W&&s.jsx(oe,{title:$,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:xe,policy:t}),T&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(U,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:g,onChange:E,disabled:_&&!g,label:"Allow top-ups",description:_?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),O?s.jsx(Fe,{error:O,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":ge})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=He(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(Qe,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,x]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),g=ie({mutationFn:async({kind:n,key:b})=>{n==="rotate"?h(await C.keys.rotate(b.id)):await C.keys.revoke(b.id)},onSuccess:()=>x(null),invalidate:[F.group("keys")],toast:(n,{kind:b})=>b==="revoke"?"Key revoked":null}),E=n=>{var b,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(b=d.data)==null?void 0:b.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(U,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:E,render:(b,w)=>s.jsx(Ve,{label:"API keys",rows:b,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>x({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>x({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Ee,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:E},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(X(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(X(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Te(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:g.isPending,error:g.error,onClose:()=>{x(null),g.reset()},onConfirm:()=>k&&g.mutate(k),...os(k)})]})}export{js as default};
1
+ import{aC as ke,r as m,a$ as je,b0 as fe,j as s,C as ne,b1 as ve,Y as Se,B as S,u as le,a as Ce,i as ce,d as de,c as Pe,t as ie,P as Le,I as K,T as U,l as Ne,Q as Ae,b2 as Ee,z as ue,b3 as X,A as me,g as ye,m as Te,at as Re,E as Z,b4 as pe,D as De,q as F,f as C,v,au as J,e as Ie,b5 as Me,b6 as Ke,b7 as Ue,b8 as ee,o as Fe,X as _e}from"./index-BpFwvYMF.js";import{u as se,a as Oe,P as Ye}from"./PolicyField-BbDSVgcK.js";import{T as Be}from"./Tabs-DmkE9BPd.js";import{l as te,d as ae,L as $e}from"./limits-DjiKmaDB.js";import{t as qe}from"./dates-Pi3-Ywng.js";import{r as ze,e as We}from"./usage-yuqGLybi.js";import{S as he}from"./Switch-BmFsXcr8.js";import{D as Ve,u as He,P as Qe}from"./DataTable-CCEZoIzX.js";import{b as Ge}from"./Charts-CHTi7z3n.js";import{S as Xe}from"./SelectField-D3qPiNQz.js";import"./PolicyEditor-BOjadRE8.js";import"./PeerPicker-w_ZaksUm.js";import"./Segmented-D_Yun-tG.js";import"./roving-DkptacxO.js";import"./Disclosure-BitAjv2r.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Be,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Je="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=ze(Je,l),c=Ie({queryKey:F.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Ge,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:We(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${J(e.expiresAt)}`,children:["Until ",J(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(_e,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx($e,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Ye,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var z;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[x,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState(qe((e==null?void 0:e.expiresAt)??null)),[g,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,b]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),be=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((z=be.data)==null?void 0:z.buyerIdentity))==="default",O=de(y.id,a&&!e),R=Oe(),[Y,B]=m.useState(null),D=p.admin,$=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let q=null;T&&(q=p.admin?"Your restrictions as the key owner":"Your restrictions");const ge=e?"Save":"Create key",xe=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,W=D?w.build():null,V=$?t.build():null,H=ae(x),Q=ae(L);if(e){const f=Ue(p,e,{label:h.trim(),expiresAt:u,topupEnabled:g,adminLimits:H,adminPolicy:W,ownerLimits:Q,ownerPolicy:V}),G=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return G===ee?ee:{key:G}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:Q,routingPolicy:p.admin?W:V,topupEnabled:p.admin?g:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[F.group("keys")],toast:u=>u.secret?null:"Key saved",onError:B});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),B(null),I.mutate()},children:[s.jsx(U,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&O.data&&s.jsx(Xe,{label:"Owner",value:n,onChange:b,options:O.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:T?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:x,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&T&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),$&&s.jsx(oe,{title:q,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:xe,policy:t}),T&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(U,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:g,onChange:E,disabled:_&&!g,label:"Allow top-ups",description:_?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),Y?s.jsx(Fe,{error:Y,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":ge})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=He(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(Qe,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,x]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),g=ie({mutationFn:async({kind:n,key:b})=>{n==="rotate"?h(await C.keys.rotate(b.id)):await C.keys.revoke(b.id)},onSuccess:()=>x(null),invalidate:[F.group("keys")],toast:(n,{kind:b})=>b==="revoke"?"Key revoked":null}),E=n=>{var b,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(b=d.data)==null?void 0:b.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(U,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:E,render:(b,w)=>s.jsx(Ve,{label:"API keys",rows:b,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>x({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>x({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Ee,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:E},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(X(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(X(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Te(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:g.isPending,error:g.error,onClose:()=>{x(null),g.reset()},onConfirm:()=>k&&g.mutate(k),...os(k)})]})}export{js as default};
@@ -1 +1 @@
1
- import{r as s,a as D,c as E,j as e,P as I,B as y,I as U,f as q,T as p,l as M}from"./index-BadBPNlq.js";import{R as B}from"./RequestLog-aPr3ty82.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-Yrfi46XZ.js";import"./useInfiniteQuery-D4a4EjtW.js";import"./PeerPicker-DrpM2w08.js";import"./usage-E97PY8Eg.js";import"./DataTable-D-JhP6Cu.js";function F(a,o=300){const[l,r]=s.useState(a);return s.useEffect(()=>{const i=window.setTimeout(()=>r(a),o);return()=>window.clearTimeout(i)},[a,o]),l}function V(){const a=D(),[o,l]=s.useState(""),[r,i]=s.useState(""),[n,h]=s.useState(""),[v,b]=s.useState(""),[c,g]=s.useState(""),[d,x]=s.useState(""),k=E(a),f=F(r.trim()),S=F(v.trim()),u=C(c,"start"),m=C(d,"end"),w=u!==void 0&&m!==void 0&&u>m,j=s.useMemo(()=>({...a,key:o||void 0,model:f||void 0,status:n||void 0,q:S||void 0,from:u,to:m}),[a.workspace,a.member,o,f,n,S,u,m]),z=!!(o||r||n||v||c||d);return e.jsxs("div",{className:"gc-page",children:[e.jsx(I,{title:"Logs",description:"Every request through this workspace's keys.",actions:e.jsx(y,{variant:"outline",size:"sm",href:q.usage.exportUrl(j),download:!0,leadingIcon:e.jsx(U.download,{size:14}),children:"Export CSV"})}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(p,{size:"sm",type:"search","aria-label":"Search requests",placeholder:"Search model, key, end user or error",value:v,onChange:t=>b(t.target.value),className:"gc-toolbar__grow"}),e.jsx(T,{size:"sm","aria-label":"Filter by key",value:o,onChange:l,options:[{value:"",label:"All keys"},...(k.data??[]).map(t=>({value:t.id,label:t.label}))]}),e.jsx(p,{size:"sm","aria-label":"Filter by model",placeholder:"Model",value:r,onChange:t=>i(t.target.value)}),e.jsx(T,{size:"sm","aria-label":"Filter by status",value:n,onChange:h,options:[{value:"",label:"Any status"},{value:"success",label:"Succeeded"},{value:"error",label:"Failed"}]}),e.jsx(p,{size:"sm",type:"date","aria-label":"From date (UTC)",title:"From (UTC)",value:c,max:d||void 0,onChange:t=>g(t.target.value)}),e.jsx(p,{size:"sm",type:"date","aria-label":"To date (UTC)",title:"To (UTC)",value:d,min:c||void 0,onChange:t=>x(t.target.value),error:w?"Ends before it starts":void 0}),z&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{l(""),i(""),h(""),b(""),g(""),x("")},children:"Clear filters"})]}),e.jsx(M,{flush:!0,children:e.jsx(B,{filter:j})})]})}export{V as default};
1
+ import{r as s,a as D,c as E,j as e,P as I,B as y,I as U,f as q,T as p,l as M}from"./index-BpFwvYMF.js";import{R as B}from"./RequestLog-39L0RtJc.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-D3qPiNQz.js";import"./useInfiniteQuery-Dwl-oWNd.js";import"./PeerPicker-w_ZaksUm.js";import"./usage-yuqGLybi.js";import"./DataTable-CCEZoIzX.js";function F(a,o=300){const[l,r]=s.useState(a);return s.useEffect(()=>{const i=window.setTimeout(()=>r(a),o);return()=>window.clearTimeout(i)},[a,o]),l}function V(){const a=D(),[o,l]=s.useState(""),[r,i]=s.useState(""),[n,h]=s.useState(""),[v,b]=s.useState(""),[c,g]=s.useState(""),[d,x]=s.useState(""),k=E(a),f=F(r.trim()),S=F(v.trim()),u=C(c,"start"),m=C(d,"end"),w=u!==void 0&&m!==void 0&&u>m,j=s.useMemo(()=>({...a,key:o||void 0,model:f||void 0,status:n||void 0,q:S||void 0,from:u,to:m}),[a.workspace,a.member,o,f,n,S,u,m]),z=!!(o||r||n||v||c||d);return e.jsxs("div",{className:"gc-page",children:[e.jsx(I,{title:"Logs",description:"Every request through this workspace's keys.",actions:e.jsx(y,{variant:"outline",size:"sm",href:q.usage.exportUrl(j),download:!0,leadingIcon:e.jsx(U.download,{size:14}),children:"Export CSV"})}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(p,{size:"sm",type:"search","aria-label":"Search requests",placeholder:"Search model, key, end user or error",value:v,onChange:t=>b(t.target.value),className:"gc-toolbar__grow"}),e.jsx(T,{size:"sm","aria-label":"Filter by key",value:o,onChange:l,options:[{value:"",label:"All keys"},...(k.data??[]).map(t=>({value:t.id,label:t.label}))]}),e.jsx(p,{size:"sm","aria-label":"Filter by model",placeholder:"Model",value:r,onChange:t=>i(t.target.value)}),e.jsx(T,{size:"sm","aria-label":"Filter by status",value:n,onChange:h,options:[{value:"",label:"Any status"},{value:"success",label:"Succeeded"},{value:"error",label:"Failed"}]}),e.jsx(p,{size:"sm",type:"date","aria-label":"From date (UTC)",title:"From (UTC)",value:c,max:d||void 0,onChange:t=>g(t.target.value)}),e.jsx(p,{size:"sm",type:"date","aria-label":"To date (UTC)",title:"To (UTC)",value:d,min:c||void 0,onChange:t=>x(t.target.value),error:w?"Ends before it starts":void 0}),z&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{l(""),i(""),h(""),b(""),g(""),x("")},children:"Clear filters"})]}),e.jsx(M,{flush:!0,children:e.jsx(B,{filter:j})})]})}export{V as default};
@@ -1 +1 @@
1
- import{u as W,n as G,r as d,d as ce,R as U,t as N,j as e,P as de,B as f,I as q,l as H,Q,b8 as _,z as me,A as ue,E as ae,C as B,D as T,f as w,G as ge,q as P,aE as be,v as D,at as se,b9 as ne,ba as he,as as J,T as I,ag as X,o as ie,b0 as pe,aM as ve}from"./index-BadBPNlq.js";import{u as xe,a as je,P as ye}from"./PolicyField-CfklGeps.js";import{l as ke,d as fe,L as we}from"./limits-DnXi8KYO.js";import{D as Y}from"./DataTable-D-JhP6Cu.js";import{S as M}from"./SelectField-Yrfi46XZ.js";import"./PolicyEditor-DNb3bKbN.js";import"./PeerPicker-DrpM2w08.js";import"./Segmented-BJMfyrv9.js";import"./roving-DkptacxO.js";import"./Switch-DQFMOyMT.js";import"./Disclosure-2Zc4btXj.js";const z=(s,t)=>!!s&&!!t&&s.trim().toLowerCase()===t.trim().toLowerCase();function Ce(s,t,o){const n=[],m=Date.now();for(const i of t)z(i.email,s.email)?n.push(`${i.label} already uses ${i.email}.`):z(i.label,s.label)&&n.push(`A member named ${i.label} already exists${i.status==="invited"?" (invited, not joined yet)":""}.`);for(const i of o)i.expiresAt<m||(z(i.email,s.email)?n.push(`A pending invite already goes to ${i.email}.`):z(i.label,s.label)&&n.push(`A pending invite for ${i.label} already exists.`));return[...new Set(n)]}const F=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...F,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function V(s){return s.status==="disabled"?e.jsx(D,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(D,{tone:"warning",children:"Invited"}):e.jsx(D,{tone:"success",children:"Active"})}function le(s,t){return s==="owner"?["member","admin","owner"]:t?["member","admin"]:["member"]}function re(s){return s.map(t=>({value:t,label:_[t]}))}function Se({onCreated:s,onCancel:t}){const{me:o,viewer:n,workspace:m}=W(),i=G(n),C=o.workspaces.filter(a=>i||a.role==="admin").map(a=>a.workspace),[c,u]=d.useState(""),[g,p]=d.useState(""),[v,R]=d.useState("member"),[j,E]=d.useState("72"),[y,b]=d.useState({[m.id]:"member"}),S=U(i),L=ne(),x=Ce({label:c,email:g},S.data??[],L.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,O])=>({workspaceId:k,role:O})),expiresInHours:Number(j)||72};return w.invites.create(a)},onSuccess:s,invalidate:K}),l=x.length?"Create anyway":"Create invite link";return e.jsxs("form",{className:"gc-stack",onSubmit:a=>{a.preventDefault(),h.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",required:!0,value:c,onChange:a=>u(a.target.value)}),e.jsx(I,{label:"Email (optional)",type:"email",value:g,onChange:a=>p(a.target.value),hint:"Required when they will sign in with your identity provider."})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(M,{label:"Organization role",value:v,onChange:a=>R(a),options:re(le(o.member.orgRole,i)),hint:v==="member"?"Sees only the workspaces below.":"Can manage every workspace."}),e.jsx(M,{label:"Link expires after",value:j,onChange:E,options:[{value:"24",label:"1 day"},{value:"72",label:"3 days"},{value:"168",label:"7 days"}]})]}),e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:"Workspaces"}),C.map(a=>e.jsxs("div",{className:"gc-inline gc-inline--between",children:[e.jsx("span",{children:a.name}),e.jsx(M,{"aria-label":`Role in ${a.name}`,value:y[a.id]??"",onChange:k=>b({...y,[a.id]:k}),options:[{value:"",label:"No access"},...te]})]},a.id))]}),x.length>0&&e.jsx(X,{tone:"warning",title:"Possible duplicate",children:e.jsx("ul",{className:"gc-list",children:x.map(a=>e.jsx("li",{children:a},a))})}),h.error?e.jsx(ie,{error:h.error,title:"Could not create the invite"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:h.isPending||!c.trim(),children:h.isPending?"Creating…":l})]})]})}function Ne({member:s,onDone:t}){const{me:o,viewer:n}=W(),m=G(n),[i,C]=d.useState(s.label),[c,u]=d.useState(s.email??""),[g,p]=d.useState(s.orgRole),[v,R]=d.useState(ke(s.limits)),[j,E]=d.useState(s.maxKeys===null?"":String(s.maxKeys)),y=xe(s.routingPolicy),[b,S]=d.useState(null),[L,x]=d.useState(!1),h=je(),l=N({mutationFn:async()=>{const r=j.trim()===""?null:Number(j);if(r!==null&&(!Number.isInteger(r)||r<0))throw new Error("Key limit must be a whole number.");const ee={label:i.trim(),email:c.trim()||null,limits:fe(v),maxKeys:r,routingPolicy:y.build(),...m?{orgRole:g}:{}};return h.save([ee.routingPolicy],oe=>w.members.update(s.id,ee,oe))},onSuccess:t,invalidate:F,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:F}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:F}),O=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=O&&s.credentials.length<=1;return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),l.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",value:i,onChange:r=>C(r.target.value)}),e.jsx(I,{label:"Email",type:"email",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[m&&e.jsx(M,{label:"Organization role",value:g,disabled:O||s.orgRole==="owner"&&o.member.orgRole!=="owner",onChange:r=>p(r),options:re(le(o.member.orgRole,!0))}),e.jsx(I,{label:"Keys they may create",inputMode:"numeric",placeholder:"No limit",value:j,onChange:r=>E(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits across their keys (USD)"}),e.jsx(we,{idPrefix:"member-limit",value:v,onChange:R})]}),e.jsx(ye,{draft:y.draft,setDraft:y.setDraft}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Sign-in methods"}),s.credentials.length===0?e.jsx("p",{className:"gc-muted",children:"None yet."}):e.jsx("ul",{className:"gc-list",children:s.credentials.map(r=>e.jsxs("li",{className:"gc-inline gc-inline--between",children:[e.jsxs("span",{children:[e.jsx(D,{children:r.kind})," ",r.label," ",e.jsxs("span",{className:"gc-muted",children:["· last used ",J(r.lastUsedAt)]})]}),$&&e.jsx(f,{variant:"ghost",size:"sm",disabled:Z,title:Z?"Add another sign-in method first":void 0,onClick:()=>S(r),children:"Remove"})]},r.id))})]}),!$&&e.jsx(X,{tone:"info",children:"Only an owner can change an owner's profile, status or sign-in methods."}),l.error?e.jsx(ie,{error:l.error,title:"Could not save"}):null,e.jsxs("div",{className:"gc-actions gc-actions--split",children:[$&&!O?e.jsx(f,{variant:A?"outline":"danger",size:"sm",onClick:()=>x(!0),children:A?"Enable member":"Disable member"}):e.jsx("span",{}),e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),$&&e.jsx(f,{type:"submit",disabled:l.isPending,children:l.isPending?"Saving…":"Save"})]})]}),e.jsx(T,{isOpen:L,busy:a.isPending,error:a.error,onClose:()=>x(!1),onConfirm:()=>a.mutate(),title:A?"Enable this member?":"Disable this member?",tone:A?"primary":"danger",confirmLabel:A?"Enable":"Disable",body:A?`${s.label} can sign in again. Their revoked keys stay revoked.`:`${s.label} is signed out and all of their keys are revoked.`}),e.jsx(T,{isOpen:b!==null,busy:k.isPending,error:k.error,onClose:()=>S(null),onConfirm:()=>b&&k.mutate(b.id),title:"Remove this sign-in method?",confirmLabel:"Remove",body:`${(b==null?void 0:b.label)??""} can no longer be used to sign in as ${s.label}.`}),h.dialog]})}function Re({member:s,role:t}){const{workspace:o,me:n}=W(),m=ge(),i=N({mutationFn:c=>w.workspaces.setMember(o.id,s.id,c),invalidate:s.id===n.member.id?[P.workspaceMembers(o.id),P.me]:[P.workspaceMembers(o.id)],toast:(c,u)=>`${s.label} is now a workspace ${u}`,onError:c=>m(`Could not change ${s.label}'s role: ${be(c)}`,"danger")}),C=s.orgRole!=="member";return e.jsx("div",{onClick:c=>c.stopPropagation(),children:e.jsx(M,{size:"sm","aria-label":`Workspace role for ${s.label}`,value:t,disabled:i.isPending||C,title:C?"Organization admins administer every workspace":void 0,onChange:c=>i.mutate(c),options:te})})}function Pe({onEdit:s}){const t=U();return e.jsx(H,{flush:!0,title:"Everyone in the organization",children:e.jsx(Q,{query:t,children:o=>e.jsx(Y,{label:"All members",rows:o,rowKey:n=>n.id,onRowClick:s,rowLabel:n=>n.label,actions:n=>[{label:"Edit member",onSelect:()=>s(n)}],columns:[{key:"name",header:"Name",sortValue:n=>n.label,render:n=>e.jsxs("span",{className:"gc-strong",children:[n.label,n.status!=="active"&&e.jsxs("span",{className:"gc-narrow-only",children:[" ",V(n)]})]})},{key:"email",header:"Email",secondary:!0,render:n=>n.email??"—"},{key:"role",header:"Role",render:n=>_[n.orgRole]},{key:"keys",header:"Key limit",secondary:!0,optional:!0,render:n=>n.maxKeys??"No limit"},{key:"since",header:"Joined",secondary:!0,sortValue:n=>n.createdAt,render:n=>n.status==="invited"?e.jsxs("span",{className:"gc-muted",children:["Invited ",se(n.createdAt)]}):se(n.createdAt)},{key:"status",header:"Status",secondary:!0,render:V}]})})})}function Ee(){const s=ne(),[t,o]=d.useState(null),n=N({mutationFn:m=>w.invites.revoke(m.id),onSuccess:()=>o(null),invalidate:K});return e.jsxs(H,{flush:!0,title:"Pending invites",children:[e.jsx(Q,{query:s,children:m=>e.jsx(Y,{label:"Pending invites",rows:m,rowKey:i=>i.id,rowLabel:i=>`invite for ${i.label}`,empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No pending invites"}),actions:i=>[{label:"Revoke invite",tone:"danger",onSelect:()=>o(i)}],columns:[{key:"name",header:"Name",render:i=>e.jsx("span",{className:"gc-strong",children:i.label})},{key:"email",header:"Email",secondary:!0,render:i=>i.email??"—"},{key:"role",header:"Role",render:i=>_[i.orgRole]},{key:"expires",header:"Expires",secondary:!0,render:i=>e.jsx(he,{at:i.expiresAt,format:J})}]})}),e.jsx(T,{isOpen:t!==null,busy:n.isPending,error:n.error,onClose:()=>o(null),onConfirm:()=>t&&n.mutate(t),title:"Revoke this invite?",confirmLabel:"Revoke",body:"The link stops working."})]})}function Ae({invite:s,onClose:t}){return e.jsx(B,{isOpen:s!==null,onClose:t,title:"Invite link",size:"lg",children:s&&e.jsxs("div",{className:"gc-stack",children:[s.url?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send this link to ",e.jsx("strong",{children:s.label}),". It works once and expires ",J(s.expiresAt),"."]}),e.jsx(pe,{secret:s.url,note:"This link is shown only once. Anyone with it can join as this member."})]}):e.jsx(X,{tone:"warning",children:"The gateway did not return a link for this invite."}),e.jsxs("div",{className:"gc-actions",children:[s.url&&e.jsx(ve,{value:s.url,label:"Copy link",size:"md"}),e.jsx(f,{onClick:t,children:"Done"})]})]})})}function _e(){var h;const{viewer:s,workspace:t,me:o}=W(),n=G(s),[m,i]=d.useState(!1),[C,c]=d.useState(null),[u,g]=d.useState(null),[p,v]=d.useState(null),[R,j]=d.useState(""),E=ce(t.id),y=U(n),b=N({mutationFn:l=>w.workspaces.removeMember(t.id,l.id),onSuccess:()=>v(null),invalidate:K,toast:"Removed from workspace"}),S=N({mutationFn:l=>w.workspaces.setMember(t.id,l,"member"),onSuccess:()=>j(""),invalidate:K,toast:"Added to workspace"}),L=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!L.has(l.id)&&l.status==="active");return e.jsxs("div",{className:"gc-page",children:[e.jsx(de,{title:"Members",description:"Who can use this gateway, their budgets and routing.",actions:e.jsx(f,{variant:"brand",leadingIcon:e.jsx(q.plus,{size:14}),onClick:()=>i(!0),children:"Invite member"})}),e.jsx(H,{flush:!0,title:`${t.name} workspace`,actions:n&&x.length>0?e.jsxs("div",{className:"gc-inline",children:[e.jsx(M,{size:"sm","aria-label":"Add an existing member",value:R,onChange:j,options:[{value:"",label:"Add existing member…"},...x.map(l=>({value:l.id,label:l.label}))]}),e.jsx(f,{size:"sm",variant:"outline",disabled:!R||S.isPending,onClick:()=>S.mutate(R),children:"Add"})]}):void 0,children:e.jsx(Q,{query:E,children:l=>e.jsx(Y,{label:"Workspace members",rows:l,rowKey:a=>a.member.id,onRowClick:n?a=>g(a.member):void 0,rowLabel:a=>a.member.label,actions:a=>[n&&{label:"Edit member",onSelect:()=>g(a.member)},a.member.id!==o.member.id&&{label:"Remove from workspace",tone:"danger",onSelect:()=>v(a.member)}],empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No members in this workspace"}),columns:[{key:"name",header:"Name",sortValue:a=>a.member.label,render:a=>e.jsxs("div",{children:[e.jsx("div",{className:"gc-strong",children:a.member.label}),e.jsx("div",{className:"gc-muted",children:a.member.email??_[a.member.orgRole]})]})},{key:"role",header:"Workspace role",render:a=>e.jsx(Re,{member:a.member,role:a.role})},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:me(a.member.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:ue(a.member.routingPolicy)})},{key:"status",header:"Status",secondary:!0,render:a=>V(a.member)}]})})}),n&&e.jsx(Pe,{onEdit:g}),e.jsx(Ee,{}),e.jsx(B,{isOpen:m,onClose:()=>i(!1),size:"lg",title:"Invite a member",children:m&&e.jsx(Se,{onCancel:()=>i(!1),onCreated:l=>{i(!1),c(l)}})}),e.jsx(Ae,{invite:C,onClose:()=>c(null)}),e.jsx(B,{isOpen:u!==null,onClose:()=>g(null),size:"lg",title:(u==null?void 0:u.label)??"",eyebrow:"Member",children:u&&e.jsx(Ne,{member:u,onDone:()=>g(null)},u.id)}),e.jsx(T,{isOpen:p!==null,busy:b.isPending,error:b.error,onClose:()=>v(null),onConfirm:()=>p&&b.mutate(p),title:"Remove from workspace?",confirmLabel:"Remove",body:`${(p==null?void 0:p.label)??""} loses access to ${t.name}. Their keys in this workspace stop working.`})]})}export{_e as default};
1
+ import{u as W,n as V,r as d,d as ce,U as G,t as N,j as e,P as de,B as f,I as q,l as H,Q,b9 as _,z as me,A as ue,E as ae,C as B,D as T,f as w,G as ge,q as P,aF as be,v as D,au as se,ba as ne,bb as he,at as J,T as I,ah as X,o as ie,b1 as pe,aN as ve}from"./index-BpFwvYMF.js";import{u as xe,a as je,P as ye}from"./PolicyField-BbDSVgcK.js";import{l as ke,d as fe,L as we}from"./limits-DjiKmaDB.js";import{D as Y}from"./DataTable-CCEZoIzX.js";import{S as M}from"./SelectField-D3qPiNQz.js";import"./PolicyEditor-BOjadRE8.js";import"./PeerPicker-w_ZaksUm.js";import"./Segmented-D_Yun-tG.js";import"./roving-DkptacxO.js";import"./Switch-BmFsXcr8.js";import"./Disclosure-BitAjv2r.js";const z=(s,t)=>!!s&&!!t&&s.trim().toLowerCase()===t.trim().toLowerCase();function Ce(s,t,o){const n=[],m=Date.now();for(const i of t)z(i.email,s.email)?n.push(`${i.label} already uses ${i.email}.`):z(i.label,s.label)&&n.push(`A member named ${i.label} already exists${i.status==="invited"?" (invited, not joined yet)":""}.`);for(const i of o)i.expiresAt<m||(z(i.email,s.email)?n.push(`A pending invite already goes to ${i.email}.`):z(i.label,s.label)&&n.push(`A pending invite for ${i.label} already exists.`));return[...new Set(n)]}const F=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...F,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function U(s){return s.status==="disabled"?e.jsx(D,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(D,{tone:"warning",children:"Invited"}):e.jsx(D,{tone:"success",children:"Active"})}function le(s,t){return s==="owner"?["member","admin","owner"]:t?["member","admin"]:["member"]}function re(s){return s.map(t=>({value:t,label:_[t]}))}function Se({onCreated:s,onCancel:t}){const{me:o,viewer:n,workspace:m}=W(),i=V(n),C=o.workspaces.filter(a=>i||a.role==="admin").map(a=>a.workspace),[c,u]=d.useState(""),[g,p]=d.useState(""),[v,R]=d.useState("member"),[j,E]=d.useState("72"),[y,b]=d.useState({[m.id]:"member"}),S=G(i),L=ne(),x=Ce({label:c,email:g},S.data??[],L.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,O])=>({workspaceId:k,role:O})),expiresInHours:Number(j)||72};return w.invites.create(a)},onSuccess:s,invalidate:K}),l=x.length?"Create anyway":"Create invite link";return e.jsxs("form",{className:"gc-stack",onSubmit:a=>{a.preventDefault(),h.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",required:!0,value:c,onChange:a=>u(a.target.value)}),e.jsx(I,{label:"Email (optional)",type:"email",value:g,onChange:a=>p(a.target.value),hint:"Required when they will sign in with your identity provider."})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(M,{label:"Organization role",value:v,onChange:a=>R(a),options:re(le(o.member.orgRole,i)),hint:v==="member"?"Sees only the workspaces below.":"Can manage every workspace."}),e.jsx(M,{label:"Link expires after",value:j,onChange:E,options:[{value:"24",label:"1 day"},{value:"72",label:"3 days"},{value:"168",label:"7 days"}]})]}),e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:"Workspaces"}),C.map(a=>e.jsxs("div",{className:"gc-inline gc-inline--between",children:[e.jsx("span",{children:a.name}),e.jsx(M,{"aria-label":`Role in ${a.name}`,value:y[a.id]??"",onChange:k=>b({...y,[a.id]:k}),options:[{value:"",label:"No access"},...te]})]},a.id))]}),x.length>0&&e.jsx(X,{tone:"warning",title:"Possible duplicate",children:e.jsx("ul",{className:"gc-list",children:x.map(a=>e.jsx("li",{children:a},a))})}),h.error?e.jsx(ie,{error:h.error,title:"Could not create the invite"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:h.isPending||!c.trim(),children:h.isPending?"Creating…":l})]})]})}function Ne({member:s,onDone:t}){const{me:o,viewer:n}=W(),m=V(n),[i,C]=d.useState(s.label),[c,u]=d.useState(s.email??""),[g,p]=d.useState(s.orgRole),[v,R]=d.useState(ke(s.limits)),[j,E]=d.useState(s.maxKeys===null?"":String(s.maxKeys)),y=xe(s.routingPolicy),[b,S]=d.useState(null),[L,x]=d.useState(!1),h=je(),l=N({mutationFn:async()=>{const r=j.trim()===""?null:Number(j);if(r!==null&&(!Number.isInteger(r)||r<0))throw new Error("Key limit must be a whole number.");const ee={label:i.trim(),email:c.trim()||null,limits:fe(v),maxKeys:r,routingPolicy:y.build(),...m?{orgRole:g}:{}};return h.save([ee.routingPolicy],oe=>w.members.update(s.id,ee,oe))},onSuccess:t,invalidate:F,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:F}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:F}),O=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=O&&s.credentials.length<=1;return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),l.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",value:i,onChange:r=>C(r.target.value)}),e.jsx(I,{label:"Email",type:"email",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[m&&e.jsx(M,{label:"Organization role",value:g,disabled:O||s.orgRole==="owner"&&o.member.orgRole!=="owner",onChange:r=>p(r),options:re(le(o.member.orgRole,!0))}),e.jsx(I,{label:"Keys they may create",inputMode:"numeric",placeholder:"No limit",value:j,onChange:r=>E(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits across their keys (USD)"}),e.jsx(we,{idPrefix:"member-limit",value:v,onChange:R})]}),e.jsx(ye,{draft:y.draft,setDraft:y.setDraft}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Sign-in methods"}),s.credentials.length===0?e.jsx("p",{className:"gc-muted",children:"None yet."}):e.jsx("ul",{className:"gc-list",children:s.credentials.map(r=>e.jsxs("li",{className:"gc-inline gc-inline--between",children:[e.jsxs("span",{children:[e.jsx(D,{children:r.kind})," ",r.label," ",e.jsxs("span",{className:"gc-muted",children:["· last used ",J(r.lastUsedAt)]})]}),$&&e.jsx(f,{variant:"ghost",size:"sm",disabled:Z,title:Z?"Add another sign-in method first":void 0,onClick:()=>S(r),children:"Remove"})]},r.id))})]}),!$&&e.jsx(X,{tone:"info",children:"Only an owner can change an owner's profile, status or sign-in methods."}),l.error?e.jsx(ie,{error:l.error,title:"Could not save"}):null,e.jsxs("div",{className:"gc-actions gc-actions--split",children:[$&&!O?e.jsx(f,{variant:A?"outline":"danger",size:"sm",onClick:()=>x(!0),children:A?"Enable member":"Disable member"}):e.jsx("span",{}),e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),$&&e.jsx(f,{type:"submit",disabled:l.isPending,children:l.isPending?"Saving…":"Save"})]})]}),e.jsx(T,{isOpen:L,busy:a.isPending,error:a.error,onClose:()=>x(!1),onConfirm:()=>a.mutate(),title:A?"Enable this member?":"Disable this member?",tone:A?"primary":"danger",confirmLabel:A?"Enable":"Disable",body:A?`${s.label} can sign in again. Their revoked keys stay revoked.`:`${s.label} is signed out and all of their keys are revoked.`}),e.jsx(T,{isOpen:b!==null,busy:k.isPending,error:k.error,onClose:()=>S(null),onConfirm:()=>b&&k.mutate(b.id),title:"Remove this sign-in method?",confirmLabel:"Remove",body:`${(b==null?void 0:b.label)??""} can no longer be used to sign in as ${s.label}.`}),h.dialog]})}function Re({member:s,role:t}){const{workspace:o,me:n}=W(),m=ge(),i=N({mutationFn:c=>w.workspaces.setMember(o.id,s.id,c),invalidate:s.id===n.member.id?[P.workspaceMembers(o.id),P.me]:[P.workspaceMembers(o.id)],toast:(c,u)=>`${s.label} is now a workspace ${u}`,onError:c=>m(`Could not change ${s.label}'s role: ${be(c)}`,"danger")}),C=s.orgRole!=="member";return e.jsx("div",{onClick:c=>c.stopPropagation(),children:e.jsx(M,{size:"sm","aria-label":`Workspace role for ${s.label}`,value:t,disabled:i.isPending||C,title:C?"Organization admins administer every workspace":void 0,onChange:c=>i.mutate(c),options:te})})}function Pe({onEdit:s}){const t=G();return e.jsx(H,{flush:!0,title:"Everyone in the organization",children:e.jsx(Q,{query:t,children:o=>e.jsx(Y,{label:"All members",rows:o,rowKey:n=>n.id,onRowClick:s,rowLabel:n=>n.label,actions:n=>[{label:"Edit member",onSelect:()=>s(n)}],columns:[{key:"name",header:"Name",sortValue:n=>n.label,render:n=>e.jsxs("span",{className:"gc-strong",children:[n.label,n.status!=="active"&&e.jsxs("span",{className:"gc-narrow-only",children:[" ",U(n)]})]})},{key:"email",header:"Email",secondary:!0,render:n=>n.email??"—"},{key:"role",header:"Role",render:n=>_[n.orgRole]},{key:"keys",header:"Key limit",secondary:!0,optional:!0,render:n=>n.maxKeys??"No limit"},{key:"since",header:"Joined",secondary:!0,sortValue:n=>n.createdAt,render:n=>n.status==="invited"?e.jsxs("span",{className:"gc-muted",children:["Invited ",se(n.createdAt)]}):se(n.createdAt)},{key:"status",header:"Status",secondary:!0,render:U}]})})})}function Ee(){const s=ne(),[t,o]=d.useState(null),n=N({mutationFn:m=>w.invites.revoke(m.id),onSuccess:()=>o(null),invalidate:K});return e.jsxs(H,{flush:!0,title:"Pending invites",children:[e.jsx(Q,{query:s,children:m=>e.jsx(Y,{label:"Pending invites",rows:m,rowKey:i=>i.id,rowLabel:i=>`invite for ${i.label}`,empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No pending invites"}),actions:i=>[{label:"Revoke invite",tone:"danger",onSelect:()=>o(i)}],columns:[{key:"name",header:"Name",render:i=>e.jsx("span",{className:"gc-strong",children:i.label})},{key:"email",header:"Email",secondary:!0,render:i=>i.email??"—"},{key:"role",header:"Role",render:i=>_[i.orgRole]},{key:"expires",header:"Expires",secondary:!0,render:i=>e.jsx(he,{at:i.expiresAt,format:J})}]})}),e.jsx(T,{isOpen:t!==null,busy:n.isPending,error:n.error,onClose:()=>o(null),onConfirm:()=>t&&n.mutate(t),title:"Revoke this invite?",confirmLabel:"Revoke",body:"The link stops working."})]})}function Ae({invite:s,onClose:t}){return e.jsx(B,{isOpen:s!==null,onClose:t,title:"Invite link",size:"lg",children:s&&e.jsxs("div",{className:"gc-stack",children:[s.url?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send this link to ",e.jsx("strong",{children:s.label}),". It works once and expires ",J(s.expiresAt),"."]}),e.jsx(pe,{secret:s.url,note:"This link is shown only once. Anyone with it can join as this member."})]}):e.jsx(X,{tone:"warning",children:"The gateway did not return a link for this invite."}),e.jsxs("div",{className:"gc-actions",children:[s.url&&e.jsx(ve,{value:s.url,label:"Copy link",size:"md"}),e.jsx(f,{onClick:t,children:"Done"})]})]})})}function _e(){var h;const{viewer:s,workspace:t,me:o}=W(),n=V(s),[m,i]=d.useState(!1),[C,c]=d.useState(null),[u,g]=d.useState(null),[p,v]=d.useState(null),[R,j]=d.useState(""),E=ce(t.id),y=G(n),b=N({mutationFn:l=>w.workspaces.removeMember(t.id,l.id),onSuccess:()=>v(null),invalidate:K,toast:"Removed from workspace"}),S=N({mutationFn:l=>w.workspaces.setMember(t.id,l,"member"),onSuccess:()=>j(""),invalidate:K,toast:"Added to workspace"}),L=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!L.has(l.id)&&l.status==="active");return e.jsxs("div",{className:"gc-page",children:[e.jsx(de,{title:"Members",description:"Who can use this gateway, their budgets and routing.",actions:e.jsx(f,{variant:"brand",leadingIcon:e.jsx(q.plus,{size:14}),onClick:()=>i(!0),children:"Invite member"})}),e.jsx(H,{flush:!0,title:`${t.name} workspace`,actions:n&&x.length>0?e.jsxs("div",{className:"gc-inline",children:[e.jsx(M,{size:"sm","aria-label":"Add an existing member",value:R,onChange:j,options:[{value:"",label:"Add existing member…"},...x.map(l=>({value:l.id,label:l.label}))]}),e.jsx(f,{size:"sm",variant:"outline",disabled:!R||S.isPending,onClick:()=>S.mutate(R),children:"Add"})]}):void 0,children:e.jsx(Q,{query:E,children:l=>e.jsx(Y,{label:"Workspace members",rows:l,rowKey:a=>a.member.id,onRowClick:n?a=>g(a.member):void 0,rowLabel:a=>a.member.label,actions:a=>[n&&{label:"Edit member",onSelect:()=>g(a.member)},a.member.id!==o.member.id&&{label:"Remove from workspace",tone:"danger",onSelect:()=>v(a.member)}],empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No members in this workspace"}),columns:[{key:"name",header:"Name",sortValue:a=>a.member.label,render:a=>e.jsxs("div",{children:[e.jsx("div",{className:"gc-strong",children:a.member.label}),e.jsx("div",{className:"gc-muted",children:a.member.email??_[a.member.orgRole]})]})},{key:"role",header:"Workspace role",render:a=>e.jsx(Re,{member:a.member,role:a.role})},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:me(a.member.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:ue(a.member.routingPolicy)})},{key:"status",header:"Status",secondary:!0,render:a=>U(a.member)}]})})}),n&&e.jsx(Pe,{onEdit:g}),e.jsx(Ee,{}),e.jsx(B,{isOpen:m,onClose:()=>i(!1),size:"lg",title:"Invite a member",children:m&&e.jsx(Se,{onCancel:()=>i(!1),onCreated:l=>{i(!1),c(l)}})}),e.jsx(Ae,{invite:C,onClose:()=>c(null)}),e.jsx(B,{isOpen:u!==null,onClose:()=>g(null),size:"lg",title:(u==null?void 0:u.label)??"",eyebrow:"Member",children:u&&e.jsx(Ne,{member:u,onDone:()=>g(null)},u.id)}),e.jsx(T,{isOpen:p!==null,busy:b.isPending,error:b.error,onClose:()=>v(null),onConfirm:()=>p&&b.mutate(p),title:"Remove from workspace?",confirmLabel:"Remove",body:`${(p==null?void 0:p.label)??""} loses access to ${t.name}. Their keys in this workspace stop working.`})]})}export{_e as default};
@@ -1 +1 @@
1
- import{u as v,aB as _,r as g,aC as f,aD as N,n as k,j as e,ag as p,P as S,I as l,l as x,T as j,X as r,v as y}from"./index-BadBPNlq.js";const C="https://antseed.com/docs/gateway/migrate",T="https://antseed.com/docs/tunnels",P={local:"This computer only",lan:"Your network only",public:"Public"};function o({n:s,title:a,children:t}){return e.jsxs("li",{className:"gc-migrate__step",children:[e.jsx("span",{className:"gc-migrate__num","aria-hidden":"true",children:s}),e.jsxs("div",{className:"gc-migrate__body",children:[e.jsx("h3",{className:"gc-migrate__title",children:a}),t]})]})}function d({icon:s,title:a,children:t}){return e.jsxs("div",{className:"gc-migrate__why",children:[e.jsx("span",{className:"gc-migrate__why-icon","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"gc-migrate__why-title",children:a}),e.jsx("p",{className:"gc-migrate__why-text",children:t})]})]})}function I({exposure:s}){return e.jsxs("div",{className:"gc-migrate__now",children:[e.jsxs("div",{className:"gc-migrate__now-head",children:[e.jsx("span",{className:"gc-muted",children:"Right now"}),e.jsx(y,{tone:s.mode==="public"?"neutral":"warning",children:P[s.mode]}),s.listenHost&&e.jsx("code",{className:"gc-migrate__addr",children:s.listenHost})]}),s.reasons.length>0&&e.jsx("ul",{className:"gc-migrate__reasons",children:s.reasons.map(a=>e.jsx("li",{children:a},a))})]})}function A(){var u;const{viewer:s}=v(),a=_(),[t,w]=g.useState(""),[h,b]=g.useState(""),m=f(t),n=N({domain:m,server:h}),i=(u=a.data)==null?void 0:u.exposure;return k(s)?e.jsxs("div",{className:"gc-page gc-migrate",children:[e.jsx(S,{title:"Move this gateway to a server",description:"Keep every key, member, workspace, wallet and its usage history. Your apps only need the new base URL."}),i&&e.jsx(I,{exposure:i}),(i==null?void 0:i.mode)==="public"&&e.jsxs(p,{tone:"info",title:"Already public",children:["This gateway has a public address (",i.publicUrl,"). You can still move it to another machine with the same steps."]}),e.jsxs("div",{className:"gc-migrate__whys",children:[e.jsx(d,{icon:e.jsx(l.activity,{size:16}),title:"Always on",children:"Keys keep working when your laptop sleeps, travels or restarts."}),e.jsx(d,{icon:e.jsx(l.shield,{size:16}),title:"HTTPS on your domain",children:"Automatic TLS at an address like https://llm.example.com, with passkeys and single sign-on."}),e.jsx(d,{icon:e.jsx(l.members,{size:16}),title:"Team access",children:"Teammates, CI and hosted tools reach it from anywhere, each with their own key and budget."})]}),e.jsxs(x,{title:e.jsxs("span",{className:"gc-inline",children:["Recommended: a small Linux server ",e.jsx(y,{tone:"neutral",children:"About 10 minutes"})]}),description:"Any VPS with a public IP works (1 vCPU, 1 GB RAM). Point a DNS name at it and open ports 80 and 443.",children:[e.jsxs("div",{className:"gc-migrate__inputs",children:[e.jsx(j,{label:"Domain for the gateway",placeholder:"llm.example.com",value:t,onChange:c=>w(c.target.value),error:t.trim()&&!m?"Enter a host name such as llm.example.com":void 0,spellCheck:!1,autoCapitalize:"off"}),e.jsx(j,{label:"Server SSH login",placeholder:"user@your-server",value:h,onChange:c=>b(c.target.value),spellCheck:!1,autoCapitalize:"off",mono:!0})]}),e.jsxs("ol",{className:"gc-migrate__steps",children:[e.jsxs(o,{n:1,title:"Export it on this computer",children:[e.jsx("p",{children:"Writes a password-protected bundle readable only by you. It holds the wallet keys, so keep the password apart from the file."}),e.jsx(r,{code:n.exportBundle,label:"This computer"})]}),e.jsx(o,{n:2,title:"Copy the bundle to the server",children:e.jsx(r,{code:n.copy,label:"This computer"})}),e.jsxs(o,{n:3,title:"Install the gateway on the server and import the bundle",children:[e.jsx("p",{children:"Installs the CLI, restores the bundle as the service user, starts the buyer and gateway with automatic HTTPS. It asks for the bundle password."}),e.jsx(r,{code:n.install,label:"Server"})]}),e.jsxs(o,{n:4,title:"Point your apps at the new address",children:[e.jsx("p",{children:"API keys stay the same. Only the base URL changes:"}),e.jsx(r,{code:n.baseUrl,label:"New base URL"})]}),e.jsxs(o,{n:5,title:"Stop the gateway on this computer",children:[e.jsxs("p",{children:["Press Ctrl+C where ",e.jsx("code",{children:"antseed gateway start"})," runs, which also stops the buyer it started (stop a buyer you run yourself too, or quit the desktop app's gateway), then delete the bundle on both machines. Never run both gateways: two buyers paying from the same wallet conflict."]}),e.jsx(r,{code:n.stop,label:"Both machines"})]})]}),e.jsxs("div",{className:"gc-migrate__note",children:[e.jsx("strong",{children:"Signing in afterwards."})," Everyone signs in again on the new address. Wallet and single sign-on keep working; passkeys are tied to the domain they were made on, so add a new one with a one-time link from the server:",e.jsx(r,{code:n.recover,label:"Server"})]}),e.jsxs("p",{className:"gc-fineprint",children:[e.jsx(l.shield,{size:12})," Wallet keys never pass through this browser: the console only shows commands. ",e.jsx("a",{className:"gc-link",href:C,target:"_blank",rel:"noreferrer",children:"Full guide"})]})]}),e.jsx(x,{title:"Alternative: keep it here behind a Cloudflare tunnel",description:"Gives this computer a public HTTPS address without moving anything.",children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(r,{code:n.tunnel,label:"This computer, instead of gateway start"}),e.jsxs("ul",{className:"gc-migrate__caveats",children:[e.jsx("li",{children:"Keys still stop working whenever this computer sleeps, loses its connection or restarts."}),e.jsxs("li",{children:["Needs a Cloudflare account and a named tunnel whose public hostname points at ",e.jsx("code",{children:"http://localhost:8379"}),"."]}),e.jsx("li",{children:"Traffic and model responses run through your home or office connection."})]}),e.jsxs("a",{className:"gc-link",href:T,target:"_blank",rel:"noreferrer",children:["Tunnel guide ",e.jsx(l.external,{size:12})]})]})})]}):e.jsx(p,{tone:"warning",title:"Not available",children:"Only organization owners and admins can move the gateway."})}export{A as default};
1
+ import{u as v,aC as _,r as g,aD as f,aE as N,n as k,j as e,ah as p,P as S,I as l,l as x,T as j,Y as r,v as y}from"./index-BpFwvYMF.js";const C="https://antseed.com/docs/gateway/migrate",T="https://antseed.com/docs/tunnels",P={local:"This computer only",lan:"Your network only",public:"Public"};function o({n:s,title:a,children:t}){return e.jsxs("li",{className:"gc-migrate__step",children:[e.jsx("span",{className:"gc-migrate__num","aria-hidden":"true",children:s}),e.jsxs("div",{className:"gc-migrate__body",children:[e.jsx("h3",{className:"gc-migrate__title",children:a}),t]})]})}function d({icon:s,title:a,children:t}){return e.jsxs("div",{className:"gc-migrate__why",children:[e.jsx("span",{className:"gc-migrate__why-icon","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"gc-migrate__why-title",children:a}),e.jsx("p",{className:"gc-migrate__why-text",children:t})]})]})}function I({exposure:s}){return e.jsxs("div",{className:"gc-migrate__now",children:[e.jsxs("div",{className:"gc-migrate__now-head",children:[e.jsx("span",{className:"gc-muted",children:"Right now"}),e.jsx(y,{tone:s.mode==="public"?"neutral":"warning",children:P[s.mode]}),s.listenHost&&e.jsx("code",{className:"gc-migrate__addr",children:s.listenHost})]}),s.reasons.length>0&&e.jsx("ul",{className:"gc-migrate__reasons",children:s.reasons.map(a=>e.jsx("li",{children:a},a))})]})}function A(){var u;const{viewer:s}=v(),a=_(),[t,w]=g.useState(""),[h,b]=g.useState(""),m=f(t),n=N({domain:m,server:h}),i=(u=a.data)==null?void 0:u.exposure;return k(s)?e.jsxs("div",{className:"gc-page gc-migrate",children:[e.jsx(S,{title:"Move this gateway to a server",description:"Keep every key, member, workspace, wallet and its usage history. Your apps only need the new base URL."}),i&&e.jsx(I,{exposure:i}),(i==null?void 0:i.mode)==="public"&&e.jsxs(p,{tone:"info",title:"Already public",children:["This gateway has a public address (",i.publicUrl,"). You can still move it to another machine with the same steps."]}),e.jsxs("div",{className:"gc-migrate__whys",children:[e.jsx(d,{icon:e.jsx(l.activity,{size:16}),title:"Always on",children:"Keys keep working when your laptop sleeps, travels or restarts."}),e.jsx(d,{icon:e.jsx(l.shield,{size:16}),title:"HTTPS on your domain",children:"Automatic TLS at an address like https://llm.example.com, with passkeys and single sign-on."}),e.jsx(d,{icon:e.jsx(l.members,{size:16}),title:"Team access",children:"Teammates, CI and hosted tools reach it from anywhere, each with their own key and budget."})]}),e.jsxs(x,{title:e.jsxs("span",{className:"gc-inline",children:["Recommended: a small Linux server ",e.jsx(y,{tone:"neutral",children:"About 10 minutes"})]}),description:"Any VPS with a public IP works (1 vCPU, 1 GB RAM). Point a DNS name at it and open ports 80 and 443.",children:[e.jsxs("div",{className:"gc-migrate__inputs",children:[e.jsx(j,{label:"Domain for the gateway",placeholder:"llm.example.com",value:t,onChange:c=>w(c.target.value),error:t.trim()&&!m?"Enter a host name such as llm.example.com":void 0,spellCheck:!1,autoCapitalize:"off"}),e.jsx(j,{label:"Server SSH login",placeholder:"user@your-server",value:h,onChange:c=>b(c.target.value),spellCheck:!1,autoCapitalize:"off",mono:!0})]}),e.jsxs("ol",{className:"gc-migrate__steps",children:[e.jsxs(o,{n:1,title:"Export it on this computer",children:[e.jsx("p",{children:"Writes a password-protected bundle readable only by you. It holds the wallet keys, so keep the password apart from the file."}),e.jsx(r,{code:n.exportBundle,label:"This computer"})]}),e.jsx(o,{n:2,title:"Copy the bundle to the server",children:e.jsx(r,{code:n.copy,label:"This computer"})}),e.jsxs(o,{n:3,title:"Install the gateway on the server and import the bundle",children:[e.jsx("p",{children:"Installs the CLI, restores the bundle as the service user, starts the buyer and gateway with automatic HTTPS. It asks for the bundle password."}),e.jsx(r,{code:n.install,label:"Server"})]}),e.jsxs(o,{n:4,title:"Point your apps at the new address",children:[e.jsx("p",{children:"API keys stay the same. Only the base URL changes:"}),e.jsx(r,{code:n.baseUrl,label:"New base URL"})]}),e.jsxs(o,{n:5,title:"Stop the gateway on this computer",children:[e.jsxs("p",{children:["Press Ctrl+C where ",e.jsx("code",{children:"antseed gateway start"})," runs, which also stops the buyer it started (stop a buyer you run yourself too, or quit the desktop app's gateway), then delete the bundle on both machines. Never run both gateways: two buyers paying from the same wallet conflict."]}),e.jsx(r,{code:n.stop,label:"Both machines"})]})]}),e.jsxs("div",{className:"gc-migrate__note",children:[e.jsx("strong",{children:"Signing in afterwards."})," Everyone signs in again on the new address. Wallet and single sign-on keep working; passkeys are tied to the domain they were made on, so add a new one with a one-time link from the server:",e.jsx(r,{code:n.recover,label:"Server"})]}),e.jsxs("p",{className:"gc-fineprint",children:[e.jsx(l.shield,{size:12})," Wallet keys never pass through this browser: the console only shows commands. ",e.jsx("a",{className:"gc-link",href:C,target:"_blank",rel:"noreferrer",children:"Full guide"})]})]}),e.jsx(x,{title:"Alternative: keep it here behind a Cloudflare tunnel",description:"Gives this computer a public HTTPS address without moving anything.",children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(r,{code:n.tunnel,label:"This computer, instead of gateway start"}),e.jsxs("ul",{className:"gc-migrate__caveats",children:[e.jsx("li",{children:"Keys still stop working whenever this computer sleeps, loses its connection or restarts."}),e.jsxs("li",{children:["Needs a Cloudflare account and a named tunnel whose public hostname points at ",e.jsx("code",{children:"http://localhost:8379"}),"."]}),e.jsx("li",{children:"Traffic and model responses run through your home or office connection."})]}),e.jsxs("a",{className:"gc-link",href:T,target:"_blank",rel:"noreferrer",children:["Tunnel guide ",e.jsx(l.external,{size:12})]})]})})]}):e.jsx(p,{tone:"warning",title:"Not available",children:"Only organization owners and admins can move the gateway."})}export{A as default};
@@ -0,0 +1 @@
1
+ import{be as E,r as m,j as e,bf as V,Y as $,bg as R,O as C,R as U,bh as O,bi as _,bj as z,L as D,E as f,I as M,P as K,T as Y,y as I,l as q,Q,bk as G,M as b,h as H,bl as v,bm as T,bn as S,bo as X,aN as N,v as x,X as J,B as W,aw as Z,ax as ee,w as L,k as se}from"./index-BpFwvYMF.js";import{T as te,a as ae}from"./Tabs-DmkE9BPd.js";import{m as ne,f as le,M as P,S as ie,a as re,T as k,C as oe,P as w,b as ce,V as de,p as ue}from"./models-CJU4tPJk.js";import{S as A}from"./SelectField-D3qPiNQz.js";import{S as pe}from"./Switch-BmFsXcr8.js";import{D as he}from"./DataTable-CCEZoIzX.js";import"./roving-DkptacxO.js";function ge({model:s,format:n,id:o="gc-api-call",unsupported:i}){const p=E(),[h,r]=m.useState("curl");if(!n)return e.jsx("p",{className:"gc-fineprint",children:i??"The gateway does not serve this model through its API."});const a=V(p,s,n),d=a.find(c=>c.id===h)??a[0];return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(te,{id:o,label:"Request examples",value:d.id,onChange:r,className:"gc-connect-tabs",tabs:a.map(c=>({id:c.id,label:c.label}))}),e.jsx(ae,{tabsId:o,tab:d.id,children:e.jsx($,{code:d.code,label:d.label})}),e.jsxs("p",{className:"gc-fineprint",children:["Set ",e.jsx("code",{children:R})," to one of your API keys first. ",e.jsx(C,{to:"keys",children:"API keys"})]})]})}function xe(s){return s===null?"—":String(Math.round(s))}function B(s){return s===null?"—":se(s)}function F(s){return s.fullTeeSellers>0?"end-to-end":s.offers.some(n=>n.teeScope==="seller-node")?"seller-node":null}function me({model:s}){return e.jsxs("div",{className:"gc-badges",children:[s.free&&e.jsx(x,{tone:"success",children:"Free"}),e.jsx(k,{tee:s.teeSellers>0,scope:F(s)})]})}function y(s){return s.displayName??L(s.peerId,8,4)}function Ie(){const s=U(),n=O(s.rest),o=_(),[i,p]=m.useState({search:"",type:"",free:!1}),h=m.useMemo(()=>ne(o.data),[o.data]),r=m.useMemo(()=>n?le(o.data,n):null,[o.data,n]),a=z(),d=(l,t)=>p(u=>({...u,[l]:t})),c=n===null?null:{eyebrow:"Model",title:(r==null?void 0:r.name)??n,body:o.isLoading?e.jsx(D,{rows:6}):r?e.jsx(je,{model:r},r.id):e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:"Model not found",body:`No provider on the network offers ${n} right now.`})},j=e.jsx(q,{flush:!0,children:e.jsx(Q,{query:o,rows:8,children:l=>e.jsx(he,{label:"Models",rows:re(l,i),rowKey:t=>t.id,selectedKey:(r==null?void 0:r.id)??null,onRowClick:t=>I(T("models",t.id)),rowLabel:t=>t.name,actions:t=>[{label:"Copy model id",onSelect:()=>void a(t.id)}],initialSort:{key:"sellers",direction:"desc"},empty:e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:l.length?"No models match these filters":"No models found yet",body:l.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"model",header:"Model",sortValue:t=>t.name.toLowerCase(),render:t=>e.jsxs("div",{className:"gc-cell-lines",children:[e.jsx("div",{className:"gc-strong gc-ellipsis",title:t.id,children:t.name}),t.name!==t.id&&e.jsx("div",{className:"gc-muted gc-ellipsis",children:e.jsx(b,{children:t.id})}),e.jsx(me,{model:t})]}),after:t=>e.jsx(G,{value:t.id,label:`Copy model id ${t.id}`})},{key:"type",header:"Type",secondary:!0,sortValue:t=>t.type,render:t=>e.jsx("span",{className:"gc-muted",children:P[t.type]})},{key:"sellers",header:"Providers",align:"right",sortValue:t=>t.sellers,render:t=>H(t.sellers)},{key:"input",header:"Input $/M",align:"right",sortValue:t=>{var u;return((u=t.inputUsdPerMillion)==null?void 0:u.min)??null},render:t=>v(t.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:t=>{var u;return((u=t.outputUsdPerMillion)==null?void 0:u.min)??null},render:t=>v(t.outputUsdPerMillion)},{key:"context",header:"Context",align:"right",secondary:!0,optional:!0,sortValue:t=>t.contextLength,render:t=>B(t.contextLength)}]})})});return e.jsxs("div",{className:"gc-page",children:[e.jsx(K,{title:"Models",description:"Every model on the network. Open one to see its providers, copy a model id and get a ready-to-run API call."}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(Y,{size:"sm",type:"search","aria-label":"Search models",placeholder:"Search model or alias",value:i.search,onChange:l=>d("search",l.target.value)}),h.length>1&&e.jsx(A,{size:"sm","aria-label":"Filter by type",value:i.type,onChange:l=>d("type",l),options:[{value:"",label:"All types"},...h.map(l=>({value:l,label:P[l]}))]}),e.jsx(pe,{checked:i.free,onChange:l=>d("free",l),label:"Free"})]}),e.jsx(ie,{list:j,panel:c,onClose:()=>I("models"),closeLabel:"Close model"})]})}function g(s){return`${s.peerId}:${s.serviceId}`}function je({model:s}){const[n,o]=m.useState(""),i=s.offers.find(a=>g(a)===n)??null,p=i?S(i.peerId,i.serviceId):s.id,h=X(s.type,i),r=s.offers.some(a=>a.usdPerImage!==null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsxs("span",{className:"gc-seller__meta",children:[e.jsxs("span",{className:"gc-peer-id",children:[e.jsx(b,{title:s.id,children:s.id}),e.jsx(N,{iconOnly:!0,value:s.id,label:"Copy model id"})]}),e.jsx(x,{children:P[s.type]}),s.free&&e.jsx(x,{tone:"success",children:"Free"}),e.jsx(k,{tee:s.teeSellers>0,scope:F(s)})]}),e.jsx(J,{items:[["Context",B(s.contextLength)],["Capabilities",s.capabilities.length?e.jsx("span",{className:"gc-badges",children:s.capabilities.map(a=>e.jsx(x,{children:oe[a]},a))}):"—"],["Aliases",s.aliases.length?e.jsx(b,{children:s.aliases.join(", ")}):"—"],...r?[]:[["Input $/M",v(s.inputUsdPerMillion)],["Output $/M",v(s.outputUsdPerMillion)]]]})]}),e.jsx(w,{title:`Providers (${s.offers.length})`,children:s.offers.length===0?e.jsx("p",{className:"gc-fineprint",children:"No provider offers this model right now."}):e.jsx("ul",{className:"gc-panel-rows","aria-label":"Providers offering this model",children:s.offers.map(a=>{var j;const d=S(a.peerId,a.serviceId),c=n===g(a);return e.jsx(ce,{selected:c,title:e.jsx(C,{to:T("providers",a.peerId),children:y(a)}),meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ue(a)}),e.jsxs("span",{children:["Trust ",xe(a.trustScore)]}),a.firstTokenMsP50!==null&&e.jsxs("span",{children:[Z(a.firstTokenMsP50)," first token"]}),a.tokensPerSecondP50!==null&&e.jsx("span",{children:ee(a.tokensPerSecondP50)}),a.serviceId!==s.id&&e.jsx(b,{children:a.serviceId})]}),badges:(((j=a.verificationLinks)==null?void 0:j.length)||a.tee||a.free)&&e.jsxs("div",{className:"gc-badges",children:[e.jsx(de,{links:a.verificationLinks}),e.jsx(k,{tee:a.tee,scope:a.teeScope}),a.free&&e.jsx(x,{tone:"success",children:"Free"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{iconOnly:!0,value:d,label:`Copy ${y(a)}'s model id (peer@model)`}),e.jsx(W,{size:"sm",variant:c?"outline":"ghost","aria-pressed":c,title:"Use this provider in the API call below",onClick:()=>o(c?"":g(a)),children:c?"Pinned":"Pin"})]})},g(a))})})}),e.jsxs(w,{title:"API call",actions:s.offers.length>0&&e.jsx(A,{size:"sm","aria-label":"Route the call",value:n,onChange:o,options:[{value:"",label:"Best provider (automatic)"},...s.offers.map(a=>({value:g(a),label:y(a)}))]}),children:[e.jsx("p",{className:"gc-fineprint",children:i?e.jsxs(e.Fragment,{children:["Pinned to ",y(i)," with ",e.jsx("code",{children:L(p,10,12)}),"."]}):e.jsxs(e.Fragment,{children:["The gateway picks the best provider for ",e.jsx("code",{children:s.id})," under your routing policy."]})}),e.jsx(ge,{id:"gc-model-call",model:p,format:h,unsupported:`${P[s.type]} models are not served through the gateway's /v1 API.`})]})]})}export{Ie as default};
@@ -0,0 +1 @@
1
+ import{j as e,u as te,F as ae,r as k,aI as q,ah as I,aQ as ne,aR as re,w,Z as se,aS as p,B as N,aT as ie,aU as y,T as oe,D as le,aO as M,aV as ce,aG as de,aW as he,q as ue,aX as we,aY as fe,aF as Y,aZ as Q,a_ as R,$ as P}from"./index-BpFwvYMF.js";import{u as H,a as V,T as G,D as C,s as K}from"./useTx-CT2tKEAI.js";import{a as ge,C as U}from"./ConnectWallet-fHEv854J.js";import{W as me,u as X,c as F,b as pe,r as Z}from"./en_US-Y4ZOVFV4-BZ-715IV.js";import"./writeContract-m5SoBxcM.js";import"./sendTransaction-qrdT91Tm.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";async function J(s,i,a){let c=await R.sync(s,i);for(let d=0;d<3&&!p(c.operator??y,a??y);d+=1)await new Promise(n=>setTimeout(n,3500)),c=await R.sync(s,i);return c}function ee(s){const i=F(),a=q(s,"deposits");return async c=>{if(!a)throw new M("The gateway did not report the deposits contract address.",!1);const[d,n]=await Promise.all([Z(i,{address:a,abi:C,functionName:"getOperator",args:[c],chainId:s.chainId}),Z(i,{address:a,abi:C,functionName:"getOperatorNonce",args:[c],chainId:s.chainId})]);return{operator:p(d,y)?null:d,nonce:n}}}function ye({workspaceId:s,state:i,chain:a,onChanged:c,onStale:d}){const{address:n}=X(),W=F(),o=H(a.chainId),{writeContractAsync:B}=V(),{signMessageAsync:_}=pe(),{me:z}=te(),E=ae(),v=ee(a),[x,h]=k.useState(!1),[f,b]=k.useState(!1),[g,u]=k.useState(null),m=q(a,"deposits");if(!m)return e.jsx(I,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(U,{label:"Connect the wallet to authorize"});const j=ne(i,n);async function A(r){try{const t=await R.authorize(s,r);return h(!1),t}catch(t){return P(t,"reauth_required")?(h("any"),o.setError(null),null):P(t,"reauth_other_credential")?(h("other"),o.setError(null),null):(P(t,"operator_already_set")&&d(),o.setError(Y(t)),null)}}async function S(r){u(r);let t=await A(r);if(!t)return;const O={depositsContract:m,chainId:a.chainId,operator:r},L=await o.run([{label:"Authorize wallet",check:async()=>{try{Q(t,await v(t.buyer),O)}catch($){if(!($ instanceof M)||!$.retryAuth)throw $;o.setStatus("The operator nonce changed; getting a fresh authorization…");const D=await R.authorize(s,r);Q(D,await v(D.buyer),O),t=D}await K(W,{account:n,address:m,abi:C,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})},send:()=>B({address:m,abi:C,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})}],{onStale:d});L&&c(await J(s,L,r))}async function l(r){b(!0),o.setError(null);try{const t=r==="passkey"?await ce():await de(n,O=>_({message:O}));if(he(t,z.member.id),E.setQueryData(ue.me,t),h(!1),g&&n&&!p(g,n)){o.setError(`Confirmed. Switch back to ${w(g)}, then authorize it.`);return}await S(g??n)}catch(t){o.setError(fe(t)?we:Y(t))}finally{b(!1)}}const T=re(i);return e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{children:["Authorize ",e.jsx("code",{children:w(n)})," to withdraw this workspace's funds and claim its ANTS rewards. It will be the only wallet able to transfer or remove the role later."]}),T.length>0&&e.jsx("ul",{className:"gc-fineprint",children:T.map(r=>e.jsxs("li",{children:[e.jsx("code",{children:w(r.address)})," ",r.ready?"can be authorized":`can be authorized from ${se(r.eligibleAt)}`,p(r.address,n)?" (connected)":""]},r.address))}),j&&e.jsx(I,{tone:"warning",children:j}),x&&e.jsx(I,{tone:"info",title:"Confirm it is you",children:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:x==="other"?`Confirm with a different sign-in method than ${w(g??n)}, the wallet you are authorizing: a passkey, or another of your wallets (connect it, confirm, then switch back).`:"Authorizing a withdrawal wallet needs a fresh sign-in."}),e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(N,{size:"sm",disabled:f,onClick:()=>void l("passkey"),children:"Confirm with a passkey"}),e.jsx(N,{size:"sm",variant:"outline",disabled:f,onClick:()=>void l("wallet"),children:f?"Check your wallet…":`Confirm with ${w(n)}`})]})]})}),e.jsx(G,{chain:a,runner:o,done:"Wallet authorized."}),e.jsx(N,{fullWidth:!0,disabled:o.running||f||!!j,onClick:()=>void S(n),children:o.running?"Working…":"Authorize this wallet"}),e.jsxs("p",{className:"gc-fineprint",children:["You will sign in again, then confirm one transaction from this wallet (it pays the network fee in ETH on ",a.name,")."]})]})}function xe({workspaceId:s,state:i,chain:a,onChanged:c,onStale:d}){const{address:n}=X(),W=F(),o=H(a.chainId),{writeContractAsync:B}=V(),_=ee(a),[z,E]=k.useState(""),[v,x]=k.useState(!1),[h,f]=k.useState(null),b=q(a,"deposits"),g=ie(i,n);if(!b)return e.jsx(I,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(U,{label:`Connect ${w(i.operator)} to manage it`});if(!g.canManage)return e.jsx(I,{tone:"warning",children:g.manageHint??"Only the authorized wallet can transfer or remove the role."});const u=z.trim(),m=/^0x[0-9a-fA-F]{40}$/.test(u)&&!p(u,y),j=i.eligibleWallets.some(l=>p(l.address,u)),A=p(u,i.buyer);async function S(l){f(null);const T=await o.run([{label:l===y?"Remove authorized wallet":"Transfer authorization",check:async()=>{const r=await _(i.buyer);if(!p(r.operator,n))throw new M(`The authorized wallet is now ${r.operator?w(r.operator):"not set"}, not the connected wallet. The panel now shows it.`,!0);await K(W,{account:n,address:b,abi:C,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})},send:()=>B({address:b,abi:C,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})}],{onStale:d});T&&(E(""),x(!1),c(await J(s,T,l===y?null:l)))}return e.jsxs("div",{className:"gc-stack",children:[e.jsx("p",{children:"The connected wallet is the authorized wallet. You can hand the role to another wallet or remove it. Both are immediate and only the new wallet (or, after removal, the organization owner through the gateway) can change it again."}),e.jsx(oe,{label:"New authorized wallet",placeholder:"0x…",value:z,onChange:l=>{E(l.target.value),x(!1)},error:z&&!m?"Enter a 0x wallet address.":A?"That is the workspace wallet itself; the gateway CLI handles that case.":void 0}),m&&!A&&!j&&e.jsxs("label",{className:"gc-inline",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:l=>x(l.target.checked)}),e.jsxs("span",{children:[w(u)," is not one of your sign-in wallets. I control it, or trust whoever does with this workspace's withdrawals and rewards."]})]}),e.jsx(G,{chain:a,runner:o,done:"Authorized wallet updated."}),e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(N,{disabled:o.running||!m||A||!j&&!v,onClick:()=>f("transfer"),children:"Transfer authorization"}),e.jsx(N,{variant:"outline",disabled:o.running,onClick:()=>f("clear"),children:"Remove authorized wallet"})]}),e.jsx(le,{isOpen:h!==null,onClose:()=>f(null),tone:"danger",title:h==="clear"?"Remove the authorized wallet?":`Transfer to ${w(u)}?`,confirmLabel:h==="clear"?"Remove":"Transfer",body:h==="clear"?"Nobody will be able to withdraw or claim rewards until the organization owner authorizes a wallet again through the gateway. Requests keep working.":`${w(u)} will receive all future withdrawals and ANTS rewards, and only it can change this again. Your connected wallet loses the role.`,onConfirm:()=>void S(h==="clear"?y:u)})]})}function Ie(s){return e.jsx(me,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(ge,{}),s.mode==="authorize"?e.jsx(ye,{...s}):e.jsx(xe,{...s})]})})}export{Ie as default};
@@ -1 +1 @@
1
- import{j as o,ag as l,w as n,B as i,y as s}from"./index-BadBPNlq.js";import{C as c}from"./ConnectWallet-bv1j8xJR.js";function p({gate:r,state:t,connected:e,onAuthorize:a}){return o.jsxs("div",{className:"gc-stack",children:[o.jsx(l,{tone:r.operator?"warning":"info",title:r.operator?"Use the authorized wallet":"No authorized wallet",children:r.reason}),r.operator&&!e&&o.jsx(c,{label:`Connect ${n(r.operator)}`}),!r.operator&&(t==null?void 0:t.canAuthorize)&&o.jsx(i,{fullWidth:!0,onClick:a??(()=>s("wallet")),children:"Authorize a wallet"})]})}export{p as O};
1
+ import{j as o,ah as l,w as n,B as i,y as s}from"./index-BpFwvYMF.js";import{C as c}from"./ConnectWallet-fHEv854J.js";function p({gate:r,state:t,connected:e,onAuthorize:a}){return o.jsxs("div",{className:"gc-stack",children:[o.jsx(l,{tone:r.operator?"warning":"info",title:r.operator?"Use the authorized wallet":"No authorized wallet",children:r.reason}),r.operator&&!e&&o.jsx(c,{label:`Connect ${n(r.operator)}`}),!r.operator&&(t==null?void 0:t.canAuthorize)&&o.jsx(i,{fullWidth:!0,onClick:a??(()=>s("wallet")),children:"Authorize a wallet"})]})}export{p as O};
@@ -1 +1 @@
1
- var fe=s=>{throw TypeError(s)};var ee=(s,t,r)=>t.has(s)||fe("Cannot "+r);var l=(s,t,r)=>(ee(s,t,"read from private field"),r?r.call(s):t.get(s)),v=(s,t,r)=>t.has(s)?fe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),y=(s,t,r,a)=>(ee(s,t,"write to private field"),a?a.call(s,r):t.set(s,r),r),k=(s,t,r)=>(ee(s,t,"access private method"),r);import{bG as $e,bH as oe,bI as Me,bJ as Qe,by as Oe,F as Te,bK as Le,bL as _e,r as E,bM as Pe,bN as Fe,bO as Ie,bP as ze,bQ as we,bR as He,bS as We,ar as Ke,m as $,u as Ee,a6 as ve,j as e,B as se,y as te,I as P,n as Ue,a7 as xe,a8 as je,a as De,i as Ge,b5 as Ve,bT as Je,aB as Xe,au as re,f as X,q as Y,e as ae,bU as Ye,c as Ze,P as ke,ag as Z,g as b,O as F,S as qe,h as z,l as I,L as pe,o as ye,bV as A,E as es,v as Re,bW as ss}from"./index-BadBPNlq.js";import{U as ts,M as rs,c as as}from"./UsageByModel-D-xMV8ke.js";import{g as is}from"./usage-E97PY8Eg.js";import{S as ns}from"./Segmented-BJMfyrv9.js";import{c as os}from"./Charts-BskMsr_y.js";import"./roving-DkptacxO.js";function Ne(s,t){const r=new Set(t);return s.filter(a=>!r.has(a))}function ls(s,t,r){const a=s.slice(0);return a[t]=r,a}var Q,m,T,L,x,q,H,W,K,U,p,le,ce,ue,de,he,Ce,cs=(Ce=class extends $e{constructor(t,r,a){super();v(this,p);v(this,Q);v(this,m);v(this,T);v(this,L);v(this,x);v(this,q);v(this,H);v(this,W);v(this,K);v(this,U,[]);y(this,Q,t),y(this,L,a),y(this,T,[]),y(this,x,[]),y(this,m,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&l(this,x).forEach(t=>{t.subscribe(r=>{k(this,p,de).call(this,t,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,l(this,x).forEach(t=>{t.destroy()})}setQueries(t,r){y(this,T,t),y(this,L,r),oe.batch(()=>{const a=l(this,x),o=k(this,p,ue).call(this,l(this,T));o.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=o.map(d=>d.observer),n=i.map(d=>d.getCurrentResult()),c=a.length!==i.length,R=i.some((d,C)=>d!==a[C]),N=c||R,_=N?!0:n.some((d,C)=>{const S=l(this,m)[C];return!S||!Me(d,S)});!N&&!_||(N&&(y(this,U,o),y(this,x,i)),y(this,m,n),this.hasListeners()&&(N&&(Ne(a,i).forEach(d=>{d.destroy()}),Ne(i,a).forEach(d=>{d.subscribe(C=>{k(this,p,de).call(this,d,C)})})),k(this,p,he).call(this)))})}getCurrentResult(){return l(this,m)}getQueries(){return l(this,x).map(t=>t.getCurrentQuery())}getObservers(){return l(this,x)}getOptimisticResult(t,r){const a=k(this,p,ue).call(this,t),o=a.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=a.map(n=>n.defaultedQueryOptions.queryHash);return[o,n=>k(this,p,ce).call(this,n??o,r,i),()=>k(this,p,le).call(this,o,a)]}},Q=new WeakMap,m=new WeakMap,T=new WeakMap,L=new WeakMap,x=new WeakMap,q=new WeakMap,H=new WeakMap,W=new WeakMap,K=new WeakMap,U=new WeakMap,p=new WeakSet,le=function(t,r){return r.map((a,o)=>{const i=t[o];return a.defaultedQueryOptions.notifyOnChangeProps?i:a.observer.trackResult(i,n=>{r.forEach(c=>{c.observer.trackProp(n)})})})},ce=function(t,r,a){if(r){const o=l(this,K),i=a!==void 0&&o!==void 0&&(o.length!==a.length||a.some((n,c)=>n!==o[c]));return(!l(this,q)||l(this,m)!==l(this,W)||i||r!==l(this,H))&&(y(this,H,r),y(this,W,l(this,m)),a!==void 0&&y(this,K,a),y(this,q,Qe(l(this,q),r(t)))),l(this,q)}return t},ue=function(t){const r=new Map;l(this,x).forEach(o=>{const i=o.options.queryHash;if(!i)return;const n=r.get(i);n?n.push(o):r.set(i,[o])});const a=[];return t.forEach(o=>{var R;const i=l(this,Q).defaultQueryOptions(o),c=((R=r.get(i.queryHash))==null?void 0:R.shift())??new Oe(l(this,Q),i);a.push({defaultedQueryOptions:i,observer:c})}),a},de=function(t,r){const a=l(this,x).indexOf(t);a!==-1&&(y(this,m,ls(l(this,m),a,r)),k(this,p,he).call(this))},he=function(){var t;if(this.hasListeners()){const r=l(this,q),a=k(this,p,le).call(this,l(this,m),l(this,U)),o=k(this,p,ce).call(this,a,(t=l(this,L))==null?void 0:t.combine);r!==o&&oe.batch(()=>{this.listeners.forEach(i=>{i(l(this,m))})})}},Ce);function us({queries:s,...t},r){const a=Te(),o=Le(),i=_e(),n=E.useMemo(()=>s.map(h=>{const g=a.defaultQueryOptions(h);return g._optimisticResults=o?"isRestoring":"optimistic",g}),[s,a,o]);n.forEach(h=>{Pe(h);const g=a.getQueryCache().get(h.queryHash);Fe(h,i,g)}),Ie(i);const[c]=E.useState(()=>new cs(a,n,t)),[R,N,_]=c.getOptimisticResult(n,t.combine),d=!o&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(h=>d?c.subscribe(oe.batchCalls(h)):ze,[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setQueries(n,t)},[n,t,c]);const S=R.some((h,g)=>we(n[g],h))?R.flatMap((h,g)=>{const f=n[g];if(f&&we(f,h)){const D=new Oe(a,f);return He(f,D,i)}return[]}):[];if(S.length>0)throw Promise.all(S);const O=R.find((h,g)=>{const f=n[g];return f&&We({result:h,errorResetBoundary:i,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(O!=null&&O.error)throw O.error;return N(_())}const ds=.8;function hs(s,t){if(!s)return[];const r=[];for(const[a,o]of t){const i=s[a];if(i===null||o===null)continue;const n=$(i),c=n===0?1:o/n;c>=ds&&r.push({period:a,label:Ke[a],spent:o,limit:n,fraction:c,reached:c>=1})}return r}function ps(s,t,r){const a=t/r,o=a>0?s/a:null,i=o===null?s<1:o<7;return{available:s,dailySpend:a,days:o,low:i}}function ie({title:s,body:t,action:r}){return e.jsxs("div",{className:"gc-setup",children:[e.jsxs("div",{className:"gc-setup__text",children:[e.jsx("div",{className:"gc-setup__title",children:s}),e.jsx("div",{className:"gc-setup__body",children:t})]}),r]})}const ys=e.jsxs("svg",{width:"28",height:"24",viewBox:"0 0 28 24","aria-hidden":"true",className:"gc-empty-tile__bars",children:[e.jsx("rect",{x:"2",y:"12",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"11",y:"6",width:"6",height:"18",rx:"1.5"}),e.jsx("rect",{x:"20",y:"0",width:"6",height:"24",rx:"1.5"})]}),gs=[{id:"keys",title:"API keys",body:"Create keys for apps and people, with budgets and their own routing."},{id:"chat",title:"Chat",body:"Try any model on the network and see which seller answers."},{id:"wallet",title:"Wallet & Funding",body:"Fund the workspace wallet and authorize who can withdraw."},{id:"routing",title:"Routing",body:"Choose which sellers may serve, price caps, TEE only, fallbacks."},{id:"providers",title:"Providers",body:"Every provider this gateway sees, with prices, trust and latency."},{id:"models",title:"Models",body:"Every model on the network, its providers and a ready-to-run API call."},{id:"presets",title:"Presets",body:"Save a model, system prompt and parameters as @preset/<name>."},{id:"members",title:"Members",body:"Invite people and choose what each of them may do."},{id:"activity",title:"Activity",body:"Spend, requests and tokens by model, key and member."},{id:"settings",title:"Settings",body:"Buyer settings every policy starts from, observability and sign-in."}];function ms({hasKeys:s,fundsKnown:t,funded:r}){const{workspace:a,viewer:o}=Ee(),i=gs.filter(n=>ve(n.id,o));return e.jsxs(e.Fragment,{children:[!s&&e.jsx(ie,{title:"No API keys yet",body:"Create your first API key to start using this workspace from your apps.",action:e.jsx(se,{variant:"brand",leadingIcon:e.jsx(P.plus,{size:14}),onClick:()=>te("keys?new=1"),children:"Create API key"})}),t&&!r&&ve("wallet",o)&&e.jsx(ie,{title:"No funds yet",body:e.jsxs(e.Fragment,{children:["Requests to paid sellers are paid in USDC from the ",a.name," wallet. Free sellers work without funds."]}),action:e.jsx(se,{variant:"outline",onClick:()=>te("wallet?fund=1"),children:"Add funds"})}),Ue(o)&&e.jsx(ie,{title:"Review buyer settings",body:"Price caps, minimum trust (60 by default) and verification apply to every key.",action:e.jsx(se,{variant:"ghost",onClick:()=>te("settings"),children:"Open settings"})}),e.jsxs("div",{className:"gc-section-head",children:[e.jsx("h2",{children:"This week's usage"}),e.jsxs("a",{className:"gc-link",href:je("activity"),onClick:xe("activity"),children:["View activity ",e.jsx(P.right,{size:13})]})]}),e.jsx("div",{className:"gc-grid gc-grid--3",children:["No spend this week","No requests this week","No tokens this week"].map(n=>e.jsxs("div",{className:"gc-empty-tile",children:[ys,e.jsx("span",{children:n})]},n))}),e.jsx("div",{className:"gc-grid gc-grid--3",children:i.map(n=>{const c=P[n.id]??P.overview;return e.jsxs("a",{className:"gc-section-card",href:je(n.id),onClick:xe(n.id),children:[e.jsx("span",{className:"gc-section-card__icon",children:e.jsx(c,{size:16})}),e.jsxs("span",{className:"gc-section-card__text",children:[e.jsx("span",{className:"gc-section-card__title",children:n.title}),e.jsx("span",{className:"gc-section-card__body",children:n.body})]}),e.jsx(P.right,{size:14,className:"gc-section-card__chevron"})]},n.id)})})]})}const ne=[{period:"daily",label:"Today"},{period:"weekly",label:"This week"},{period:"monthly",label:"This month"}];function bs(s,t){return t&&s!==null?s/t:t===0?1:null}function fs({label:s,spent:t,limit:r}){const a=r===null?null:$(r);return e.jsx(qe,{label:`Spend ${s.toLowerCase()}`,value:t===null?"…":b(t),sub:a===null?"No budget":`of ${b(a)} budget`,meter:bs(t,a)})}function ws(s){return s?s.days===null?"No recent spend":Ae(s.days):"…"}function vs({wallet:s,funds:t}){return s.isLoading?e.jsx(pe,{rows:1,height:48}):s.error?e.jsx(ye,{error:s.error,onRetry:()=>void s.refetch()}):s.data?e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Available",value:b(s.data.available),strong:!0}),e.jsx(A,{label:"Reserved in channels",value:b(s.data.reserved)}),e.jsx(A,{label:"In wallet, not deposited",value:b(s.data.walletUsdc)}),e.jsx(A,{label:"Runway",value:ws(t)})]}):null}function xs({status:s}){if(s.isLoading)return e.jsx(pe,{rows:1,height:40});if(s.error)return e.jsx(ye,{error:s.error});if(!s.data)return null;const{buyer:t}=s.data;return e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Buyer",value:t.reachable?e.jsx(Re,{tone:"success",children:"Connected"}):e.jsx(Re,{tone:"danger",children:"Unreachable"})}),e.jsx(A,{label:"Sellers seen",value:z(t.peers)}),e.jsx(A,{label:"DHT nodes",value:z(t.dhtNodes)}),e.jsx(A,{label:"Buyer uptime",value:t.uptimeMs===null?"—":ss(t.uptimeMs)})]})}function qs(){var me,be;const{workspace:s,viewer:t}=Ee(),r=De(),a=Ge(t),o=Ve(s.id),i=Je(s.id,a),n=Xe(),c=Date.now(),[R]=E.useState(c),[N,_]=E.useState("spend"),d=E.useMemo(()=>({...r}),[r.workspace,r.member]),C=us({queries:ne.map(({period:u})=>{const w=re(u,c);return{queryKey:Y.usage({...r,from:w,groupBy:"day"}),queryFn:()=>X.usage.report({...r,from:w,groupBy:"day"})}})}),S=re("monthly",c),O=ae({queryKey:Y.usage({...r,from:S,groupBy:"key"}),queryFn:()=>X.usage.report({...r,from:S,groupBy:"key"})}),h=ae({queryKey:Y.usage({...r,from:S,groupBy:"model"}),queryFn:()=>X.usage.report({...r,from:S,groupBy:"model"})}),g=re("daily",c),f=g-7*864e5,D=ae({queryKey:Y.usage({workspace:s.id,from:f,to:g,groupBy:"day"}),queryFn:()=>X.usage.report({workspace:s.id,from:f,to:g-1,groupBy:"day"}),enabled:a}),B=Ye(),G=Ze({workspace:s.id}),V=((me=o.data)==null?void 0:me.limits)??null,M=(be=C[2])==null?void 0:be.data,ge=u=>{var J;const w=(J=C[u])==null?void 0:J.data;return w?$(w.totals.spent):null},Be=hs(V,ne.map(({period:u},w)=>[u,ge(w)])),j=i.data&&D.data?ps($(i.data.available),$(D.data.totals.spent),7):null;if(M!==void 0&&M.totals.requests===0&&G.data!==void 0&&G.data.every(u=>u.usage.requests===0)){const u=(G.data??[]).some(w=>w.status==="active"&&!w.label.startsWith("Web chat"));return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:s.name,description:"Nothing has run through this workspace yet. Here is where to start."}),e.jsx(ms,{hasKeys:G.isLoading||u,fundsKnown:a&&i.data!==void 0,funded:i.data?$(i.data.available)>0:!0})]})}return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:"Overview",description:`${s.name} workspace${r.member?" · your usage":""}`}),(j==null?void 0:j.low)&&e.jsx(Z,{tone:j.days!==null&&j.days<1?"danger":"warning",title:"Balance is running low",action:e.jsx(F,{to:"wallet",children:"Add funds"}),children:j.days===null?`Only ${b(j.available)} is available.`:`${b(j.available)} available lasts about ${Ae(j.days)} at last week's pace (${b(j.dailySpend)} a day).`}),B.currentMissingOperator&&e.jsx(Z,{tone:"warning",title:"No authorized wallet",action:e.jsx(F,{to:"wallet",children:B.canAuthorize?"Authorize a wallet":"View wallet"}),children:B.canAuthorize?`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until you authorize one of your wallets. Requests keep working.`:`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until the organization owner authorizes a wallet. Requests keep working.`}),B.withdrawable.count>0&&e.jsxs(Z,{tone:"warning",title:`${B.withdrawable.count} channel${B.withdrawable.count===1?"":"s"} ready to withdraw`,action:e.jsx(F,{to:"wallet",children:"Withdraw"}),children:["About ",b(B.withdrawable.amount)," of unused reserve can return to the balance."]}),Be.map(u=>e.jsx(Z,{tone:u.reached?"danger":"warning",title:u.reached?`${u.label} budget reached`:`${u.label} budget almost used`,children:u.reached?`${s.name} has spent ${b(u.spent)} of its ${b(u.limit)} ${u.label.toLowerCase()} budget. New requests are refused until the period resets.`:`${Math.round(u.fraction*100)}% of the ${b(u.limit)} ${u.label.toLowerCase()} budget is used.`},u.period)),e.jsxs("div",{className:"gc-grid gc-grid--4",children:[ne.map(({period:u,label:w},J)=>e.jsx(fs,{label:w,spent:ge(J),limit:(V==null?void 0:V[u])??null},u)),e.jsx(qe,{label:"Requests this month",value:M?z(M.totals.requests):"…",sub:M?`${z(M.totals.failedRequests)} failed`:void 0})]}),e.jsx(I,{title:"Last 7 days",description:as(N,"7d"),actions:e.jsxs(e.Fragment,{children:[e.jsx(ns,{label:"Chart metric",value:N,onChange:_,options:rs}),e.jsx(F,{to:"activity",children:"All activity"})]}),children:e.jsx(ts,{filter:d,range:"7d",now:R,metric:N,height:200})}),a&&e.jsx(I,{title:"Balance",actions:e.jsx(F,{to:"wallet",children:"Add funds"}),children:e.jsx(vs,{wallet:i,funds:j})}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{title:"Top keys this month",children:e.jsx(Se,{report:O.data,loading:O.isLoading,error:O.error,empty:"No spend this month."})}),e.jsx(I,{title:"Top models this month",children:e.jsx(Se,{report:h.data,loading:h.isLoading,error:h.error,empty:"No spend this month."})})]}),e.jsx(I,{title:"Gateway",children:e.jsx(xs,{status:n})})]})}function Ae(s){return s<1?"under a day":s<60?`${Math.floor(s)} day${Math.floor(s)===1?"":"s"}`:`${Math.floor(s/30)} months`}function Se({report:s,loading:t,error:r,empty:a}){if(t)return e.jsx(pe,{rows:4,height:22});if(r)return e.jsx(ye,{error:r});const o=((s==null?void 0:s.groups)??[]).map(i=>({label:is(i),value:$(i.spent),sub:`${z(i.requests)} requests`})).filter(i=>i.value>0).sort((i,n)=>n.value-i.value).slice(0,5);return o.length===0?e.jsx(es,{title:a}):e.jsx(os,{items:o,format:b})}export{qs as default};
1
+ var fe=s=>{throw TypeError(s)};var ee=(s,t,r)=>t.has(s)||fe("Cannot "+r);var l=(s,t,r)=>(ee(s,t,"read from private field"),r?r.call(s):t.get(s)),v=(s,t,r)=>t.has(s)?fe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),y=(s,t,r,a)=>(ee(s,t,"write to private field"),a?a.call(s,r):t.set(s,r),r),k=(s,t,r)=>(ee(s,t,"access private method"),r);import{bH as $e,bI as oe,bJ as Me,bK as Qe,by as Oe,F as Te,bL as Le,bM as _e,r as E,bN as Pe,bO as Fe,bP as Ie,bQ as ze,bR as we,bS as He,bT as We,as as Ke,m as $,u as Ee,a7 as ve,j as e,B as se,y as te,I as P,n as Ue,a8 as xe,a9 as je,a as De,i as Ge,b6 as Ve,bU as Je,aC as Xe,av as re,f as X,q as Y,e as ae,bV as Ye,c as Ze,P as ke,ah as Z,g as b,O as F,S as qe,h as z,l as I,L as pe,o as ye,bW as A,E as es,v as Re,bX as ss}from"./index-BpFwvYMF.js";import{U as ts,M as rs,c as as}from"./UsageByModel-nhGKdBi8.js";import{g as is}from"./usage-yuqGLybi.js";import{S as ns}from"./Segmented-D_Yun-tG.js";import{c as os}from"./Charts-CHTi7z3n.js";import"./roving-DkptacxO.js";function Ne(s,t){const r=new Set(t);return s.filter(a=>!r.has(a))}function ls(s,t,r){const a=s.slice(0);return a[t]=r,a}var Q,m,T,L,x,q,H,W,K,U,p,le,ce,ue,de,he,Se,cs=(Se=class extends $e{constructor(t,r,a){super();v(this,p);v(this,Q);v(this,m);v(this,T);v(this,L);v(this,x);v(this,q);v(this,H);v(this,W);v(this,K);v(this,U,[]);y(this,Q,t),y(this,L,a),y(this,T,[]),y(this,x,[]),y(this,m,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&l(this,x).forEach(t=>{t.subscribe(r=>{k(this,p,de).call(this,t,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,l(this,x).forEach(t=>{t.destroy()})}setQueries(t,r){y(this,T,t),y(this,L,r),oe.batch(()=>{const a=l(this,x),o=k(this,p,ue).call(this,l(this,T));o.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=o.map(d=>d.observer),n=i.map(d=>d.getCurrentResult()),c=a.length!==i.length,R=i.some((d,S)=>d!==a[S]),N=c||R,_=N?!0:n.some((d,S)=>{const C=l(this,m)[S];return!C||!Me(d,C)});!N&&!_||(N&&(y(this,U,o),y(this,x,i)),y(this,m,n),this.hasListeners()&&(N&&(Ne(a,i).forEach(d=>{d.destroy()}),Ne(i,a).forEach(d=>{d.subscribe(S=>{k(this,p,de).call(this,d,S)})})),k(this,p,he).call(this)))})}getCurrentResult(){return l(this,m)}getQueries(){return l(this,x).map(t=>t.getCurrentQuery())}getObservers(){return l(this,x)}getOptimisticResult(t,r){const a=k(this,p,ue).call(this,t),o=a.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=a.map(n=>n.defaultedQueryOptions.queryHash);return[o,n=>k(this,p,ce).call(this,n??o,r,i),()=>k(this,p,le).call(this,o,a)]}},Q=new WeakMap,m=new WeakMap,T=new WeakMap,L=new WeakMap,x=new WeakMap,q=new WeakMap,H=new WeakMap,W=new WeakMap,K=new WeakMap,U=new WeakMap,p=new WeakSet,le=function(t,r){return r.map((a,o)=>{const i=t[o];return a.defaultedQueryOptions.notifyOnChangeProps?i:a.observer.trackResult(i,n=>{r.forEach(c=>{c.observer.trackProp(n)})})})},ce=function(t,r,a){if(r){const o=l(this,K),i=a!==void 0&&o!==void 0&&(o.length!==a.length||a.some((n,c)=>n!==o[c]));return(!l(this,q)||l(this,m)!==l(this,W)||i||r!==l(this,H))&&(y(this,H,r),y(this,W,l(this,m)),a!==void 0&&y(this,K,a),y(this,q,Qe(l(this,q),r(t)))),l(this,q)}return t},ue=function(t){const r=new Map;l(this,x).forEach(o=>{const i=o.options.queryHash;if(!i)return;const n=r.get(i);n?n.push(o):r.set(i,[o])});const a=[];return t.forEach(o=>{var R;const i=l(this,Q).defaultQueryOptions(o),c=((R=r.get(i.queryHash))==null?void 0:R.shift())??new Oe(l(this,Q),i);a.push({defaultedQueryOptions:i,observer:c})}),a},de=function(t,r){const a=l(this,x).indexOf(t);a!==-1&&(y(this,m,ls(l(this,m),a,r)),k(this,p,he).call(this))},he=function(){var t;if(this.hasListeners()){const r=l(this,q),a=k(this,p,le).call(this,l(this,m),l(this,U)),o=k(this,p,ce).call(this,a,(t=l(this,L))==null?void 0:t.combine);r!==o&&oe.batch(()=>{this.listeners.forEach(i=>{i(l(this,m))})})}},Se);function us({queries:s,...t},r){const a=Te(),o=Le(),i=_e(),n=E.useMemo(()=>s.map(h=>{const g=a.defaultQueryOptions(h);return g._optimisticResults=o?"isRestoring":"optimistic",g}),[s,a,o]);n.forEach(h=>{Pe(h);const g=a.getQueryCache().get(h.queryHash);Fe(h,i,g)}),Ie(i);const[c]=E.useState(()=>new cs(a,n,t)),[R,N,_]=c.getOptimisticResult(n,t.combine),d=!o&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(h=>d?c.subscribe(oe.batchCalls(h)):ze,[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setQueries(n,t)},[n,t,c]);const C=R.some((h,g)=>we(n[g],h))?R.flatMap((h,g)=>{const f=n[g];if(f&&we(f,h)){const D=new Oe(a,f);return He(f,D,i)}return[]}):[];if(C.length>0)throw Promise.all(C);const O=R.find((h,g)=>{const f=n[g];return f&&We({result:h,errorResetBoundary:i,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(O!=null&&O.error)throw O.error;return N(_())}const ds=.8;function hs(s,t){if(!s)return[];const r=[];for(const[a,o]of t){const i=s[a];if(i===null||o===null)continue;const n=$(i),c=n===0?1:o/n;c>=ds&&r.push({period:a,label:Ke[a],spent:o,limit:n,fraction:c,reached:c>=1})}return r}function ps(s,t,r){const a=t/r,o=a>0?s/a:null,i=o===null?s<1:o<7;return{available:s,dailySpend:a,days:o,low:i}}function ie({title:s,body:t,action:r}){return e.jsxs("div",{className:"gc-setup",children:[e.jsxs("div",{className:"gc-setup__text",children:[e.jsx("div",{className:"gc-setup__title",children:s}),e.jsx("div",{className:"gc-setup__body",children:t})]}),r]})}const ys=e.jsxs("svg",{width:"28",height:"24",viewBox:"0 0 28 24","aria-hidden":"true",className:"gc-empty-tile__bars",children:[e.jsx("rect",{x:"2",y:"12",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"11",y:"6",width:"6",height:"18",rx:"1.5"}),e.jsx("rect",{x:"20",y:"0",width:"6",height:"24",rx:"1.5"})]}),gs=[{id:"keys",title:"API keys",body:"Create keys for apps and people, with budgets and their own routing."},{id:"chat",title:"Chat",body:"Try any model on the network and see which seller answers."},{id:"wallet",title:"Wallet & Funding",body:"Fund the workspace wallet and authorize who can withdraw."},{id:"routing",title:"Routing",body:"Choose which sellers may serve, price caps, TEE only, fallbacks."},{id:"providers",title:"Providers",body:"Every provider this gateway sees, with prices, trust and latency."},{id:"models",title:"Models",body:"Every model on the network, its providers and a ready-to-run API call."},{id:"presets",title:"Presets",body:"Save a model, system prompt and parameters as @preset/<name>."},{id:"members",title:"Members",body:"Invite people and choose what each of them may do."},{id:"activity",title:"Activity",body:"Spend, requests and tokens by model, key and member."},{id:"settings",title:"Settings",body:"Buyer settings every policy starts from, observability and sign-in."}];function ms({hasKeys:s,fundsKnown:t,funded:r}){const{workspace:a,viewer:o}=Ee(),i=gs.filter(n=>ve(n.id,o));return e.jsxs(e.Fragment,{children:[!s&&e.jsx(ie,{title:"No API keys yet",body:"Create your first API key to start using this workspace from your apps.",action:e.jsx(se,{variant:"brand",leadingIcon:e.jsx(P.plus,{size:14}),onClick:()=>te("keys?new=1"),children:"Create API key"})}),t&&!r&&ve("wallet",o)&&e.jsx(ie,{title:"No funds yet",body:e.jsxs(e.Fragment,{children:["Requests to paid sellers are paid in USDC from the ",a.name," wallet. Free sellers work without funds."]}),action:e.jsx(se,{variant:"outline",onClick:()=>te("wallet?fund=1"),children:"Add funds"})}),Ue(o)&&e.jsx(ie,{title:"Review buyer settings",body:"Price caps, minimum trust (60 by default) and verification apply to every key.",action:e.jsx(se,{variant:"ghost",onClick:()=>te("settings"),children:"Open settings"})}),e.jsxs("div",{className:"gc-section-head",children:[e.jsx("h2",{children:"This week's usage"}),e.jsxs("a",{className:"gc-link",href:je("activity"),onClick:xe("activity"),children:["View activity ",e.jsx(P.right,{size:13})]})]}),e.jsx("div",{className:"gc-grid gc-grid--3",children:["No spend this week","No requests this week","No tokens this week"].map(n=>e.jsxs("div",{className:"gc-empty-tile",children:[ys,e.jsx("span",{children:n})]},n))}),e.jsx("div",{className:"gc-grid gc-grid--3",children:i.map(n=>{const c=P[n.id]??P.overview;return e.jsxs("a",{className:"gc-section-card",href:je(n.id),onClick:xe(n.id),children:[e.jsx("span",{className:"gc-section-card__icon",children:e.jsx(c,{size:16})}),e.jsxs("span",{className:"gc-section-card__text",children:[e.jsx("span",{className:"gc-section-card__title",children:n.title}),e.jsx("span",{className:"gc-section-card__body",children:n.body})]}),e.jsx(P.right,{size:14,className:"gc-section-card__chevron"})]},n.id)})})]})}const ne=[{period:"daily",label:"Today"},{period:"weekly",label:"This week"},{period:"monthly",label:"This month"}];function bs(s,t){return t&&s!==null?s/t:t===0?1:null}function fs({label:s,spent:t,limit:r}){const a=r===null?null:$(r);return e.jsx(qe,{label:`Spend ${s.toLowerCase()}`,value:t===null?"…":b(t),sub:a===null?"No budget":`of ${b(a)} budget`,meter:bs(t,a)})}function ws(s){return s?s.days===null?"No recent spend":Ae(s.days):"…"}function vs({wallet:s,funds:t}){return s.isLoading?e.jsx(pe,{rows:1,height:48}):s.error?e.jsx(ye,{error:s.error,onRetry:()=>void s.refetch()}):s.data?e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Available",value:b(s.data.available),strong:!0}),e.jsx(A,{label:"Reserved in channels",value:b(s.data.reserved)}),e.jsx(A,{label:"In wallet, not deposited",value:b(s.data.walletUsdc)}),e.jsx(A,{label:"Runway",value:ws(t)})]}):null}function xs({status:s}){if(s.isLoading)return e.jsx(pe,{rows:1,height:40});if(s.error)return e.jsx(ye,{error:s.error});if(!s.data)return null;const{buyer:t}=s.data;return e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Buyer",value:t.reachable?e.jsx(Re,{tone:"success",children:"Connected"}):e.jsx(Re,{tone:"danger",children:"Unreachable"})}),e.jsx(A,{label:"Sellers seen",value:z(t.peers)}),e.jsx(A,{label:"DHT nodes",value:z(t.dhtNodes)}),e.jsx(A,{label:"Buyer uptime",value:t.uptimeMs===null?"—":ss(t.uptimeMs)})]})}function qs(){var me,be;const{workspace:s,viewer:t}=Ee(),r=De(),a=Ge(t),o=Ve(s.id),i=Je(s.id,a),n=Xe(),c=Date.now(),[R]=E.useState(c),[N,_]=E.useState("spend"),d=E.useMemo(()=>({...r}),[r.workspace,r.member]),S=us({queries:ne.map(({period:u})=>{const w=re(u,c);return{queryKey:Y.usage({...r,from:w,groupBy:"day"}),queryFn:()=>X.usage.report({...r,from:w,groupBy:"day"})}})}),C=re("monthly",c),O=ae({queryKey:Y.usage({...r,from:C,groupBy:"key"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"key"})}),h=ae({queryKey:Y.usage({...r,from:C,groupBy:"model"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"model"})}),g=re("daily",c),f=g-7*864e5,D=ae({queryKey:Y.usage({workspace:s.id,from:f,to:g,groupBy:"day"}),queryFn:()=>X.usage.report({workspace:s.id,from:f,to:g-1,groupBy:"day"}),enabled:a}),B=Ye(),G=Ze({workspace:s.id}),V=((me=o.data)==null?void 0:me.limits)??null,M=(be=S[2])==null?void 0:be.data,ge=u=>{var J;const w=(J=S[u])==null?void 0:J.data;return w?$(w.totals.spent):null},Be=hs(V,ne.map(({period:u},w)=>[u,ge(w)])),j=i.data&&D.data?ps($(i.data.available),$(D.data.totals.spent),7):null;if(M!==void 0&&M.totals.requests===0&&G.data!==void 0&&G.data.every(u=>u.usage.requests===0)){const u=(G.data??[]).some(w=>w.status==="active"&&!w.label.startsWith("Web chat"));return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:s.name,description:"Nothing has run through this workspace yet. Here is where to start."}),e.jsx(ms,{hasKeys:G.isLoading||u,fundsKnown:a&&i.data!==void 0,funded:i.data?$(i.data.available)>0:!0})]})}return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:"Overview",description:`${s.name} workspace${r.member?" · your usage":""}`}),(j==null?void 0:j.low)&&e.jsx(Z,{tone:j.days!==null&&j.days<1?"danger":"warning",title:"Balance is running low",action:e.jsx(F,{to:"wallet",children:"Add funds"}),children:j.days===null?`Only ${b(j.available)} is available.`:`${b(j.available)} available lasts about ${Ae(j.days)} at last week's pace (${b(j.dailySpend)} a day).`}),B.currentMissingOperator&&e.jsx(Z,{tone:"warning",title:"No authorized wallet",action:e.jsx(F,{to:"wallet",children:B.canAuthorize?"Authorize a wallet":"View wallet"}),children:B.canAuthorize?`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until you authorize one of your wallets. Requests keep working.`:`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until the organization owner authorizes a wallet. Requests keep working.`}),B.withdrawable.count>0&&e.jsxs(Z,{tone:"warning",title:`${B.withdrawable.count} channel${B.withdrawable.count===1?"":"s"} ready to withdraw`,action:e.jsx(F,{to:"wallet",children:"Withdraw"}),children:["About ",b(B.withdrawable.amount)," of unused reserve can return to the balance."]}),Be.map(u=>e.jsx(Z,{tone:u.reached?"danger":"warning",title:u.reached?`${u.label} budget reached`:`${u.label} budget almost used`,children:u.reached?`${s.name} has spent ${b(u.spent)} of its ${b(u.limit)} ${u.label.toLowerCase()} budget. New requests are refused until the period resets.`:`${Math.round(u.fraction*100)}% of the ${b(u.limit)} ${u.label.toLowerCase()} budget is used.`},u.period)),e.jsxs("div",{className:"gc-grid gc-grid--4",children:[ne.map(({period:u,label:w},J)=>e.jsx(fs,{label:w,spent:ge(J),limit:(V==null?void 0:V[u])??null},u)),e.jsx(qe,{label:"Requests this month",value:M?z(M.totals.requests):"…",sub:M?`${z(M.totals.failedRequests)} failed`:void 0})]}),e.jsx(I,{title:"Last 7 days",description:as(N,"7d"),actions:e.jsxs(e.Fragment,{children:[e.jsx(ns,{label:"Chart metric",value:N,onChange:_,options:rs}),e.jsx(F,{to:"activity",children:"All activity"})]}),children:e.jsx(ts,{filter:d,range:"7d",now:R,metric:N,height:200})}),a&&e.jsx(I,{title:"Balance",actions:e.jsx(F,{to:"wallet",children:"Add funds"}),children:e.jsx(vs,{wallet:i,funds:j})}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{title:"Top keys this month",children:e.jsx(Ce,{report:O.data,loading:O.isLoading,error:O.error,empty:"No spend this month."})}),e.jsx(I,{title:"Top models this month",children:e.jsx(Ce,{report:h.data,loading:h.isLoading,error:h.error,empty:"No spend this month."})})]}),e.jsx(I,{title:"Gateway",children:e.jsx(xs,{status:n})})]})}function Ae(s){return s<1?"under a day":s<60?`${Math.floor(s)} day${Math.floor(s)===1?"":"s"}`:`${Math.floor(s/30)} months`}function Ce({report:s,loading:t,error:r,empty:a}){if(t)return e.jsx(pe,{rows:4,height:22});if(r)return e.jsx(ye,{error:r});const o=((s==null?void 0:s.groups)??[]).map(i=>({label:is(i),value:$(i.spent),sub:`${z(i.requests)} requests`})).filter(i=>i.value>0).sort((i,n)=>n.value-i.value).slice(0,5);return o.length===0?e.jsx(es,{title:a}):e.jsx(os,{items:o,format:b})}export{qs as default};
@@ -1 +1 @@
1
- import{ax as C,w as k,r as o,j as s,ay as N,I as _,az as b,B as w}from"./index-BadBPNlq.js";function f(l,e){const c=l==null?void 0:l.find(n=>C(n.peerId,e));return(c==null?void 0:c.displayName)??k(e,8,4)}function z({value:l,onChange:e,peers:c,label:n,ordered:r,placeholder:m="Search sellers or paste a peer id"}){const[d,x]=o.useState(""),h=o.useId(),j=o.useId();function a(){const i=d.trim();if(!i)return;const t=c==null?void 0:c.find(p=>{var I;return((I=p.displayName)==null?void 0:I.toLowerCase())===i.toLowerCase()||p.peerId.toLowerCase()===i.toLowerCase()}),u=(t==null?void 0:t.peerId)??i;l.some(p=>p.toLowerCase()===u.toLowerCase())||e([...l,u]),x("")}return s.jsxs("div",{className:"gc-picker",children:[s.jsx("label",{className:"as-field__label",htmlFor:j,children:n}),l.length>0&&s.jsx("ol",{className:r?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((i,t)=>s.jsxs("li",{className:"gc-chip",children:[r&&s.jsx("span",{className:"gc-chip__index",children:t+1}),s.jsx("span",{className:"gc-chip__label",title:i,children:f(c,i)}),r&&s.jsxs(s.Fragment,{children:[s.jsx(N,{label:`Move ${f(c,i)} up`,size:"sm",disabled:t===0,onClick:()=>e(b(l,t,-1)),children:s.jsx(_.up,{size:12})}),s.jsx(N,{label:`Move ${f(c,i)} down`,size:"sm",disabled:t===l.length-1,onClick:()=>e(b(l,t,1)),children:s.jsx(_.down,{size:12})})]}),s.jsx(N,{label:`Remove ${f(c,i)}`,size:"sm",onClick:()=>e(l.filter(u=>u!==i)),children:s.jsx(_.x,{size:12})})]},i))}),s.jsxs("div",{className:"gc-inline",children:[s.jsx("input",{id:j,className:"as-field__input gc-picker__input",list:h,value:d,placeholder:m,onChange:i=>x(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),a())}}),s.jsx("datalist",{id:h,children:c==null?void 0:c.map(i=>s.jsx("option",{value:i.peerId,children:i.displayName??k(i.peerId)},i.peerId))}),s.jsx(w,{variant:"outline",size:"sm",onClick:a,disabled:!d.trim(),children:"Add"})]})]})}function y({value:l,onChange:e,label:c,suggestions:n,placeholder:r}){const[m,d]=o.useState(""),x=o.useId(),h=o.useId();function j(){const a=m.trim();a&&!l.includes(a)&&e([...l,a]),d("")}return s.jsxs("div",{className:"gc-picker",children:[s.jsx("label",{className:"as-field__label",htmlFor:h,children:c}),l.length>0&&s.jsx("ul",{className:"gc-chips",children:l.map(a=>s.jsxs("li",{className:"gc-chip",children:[s.jsx("span",{className:"gc-chip__label",children:a}),s.jsx(N,{label:`Remove ${a}`,size:"sm",onClick:()=>e(l.filter(i=>i!==a)),children:s.jsx(_.x,{size:12})})]},a))}),s.jsxs("div",{className:"gc-inline",children:[s.jsx("input",{id:h,className:"as-field__input gc-picker__input",list:x,value:m,placeholder:r,onChange:a=>d(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),j())}}),s.jsx("datalist",{id:x,children:n==null?void 0:n.map(a=>s.jsx("option",{value:a},a))}),s.jsx(w,{variant:"outline",size:"sm",onClick:j,disabled:!m.trim(),children:"Add"})]})]})}export{y as C,z as P,f as p};
1
+ import{ay as C,w as k,r as o,j as s,az as N,I as _,aA as b,B as w}from"./index-BpFwvYMF.js";function f(l,e){const c=l==null?void 0:l.find(n=>C(n.peerId,e));return(c==null?void 0:c.displayName)??k(e,8,4)}function z({value:l,onChange:e,peers:c,label:n,ordered:r,placeholder:m="Search sellers or paste a peer id"}){const[d,h]=o.useState(""),x=o.useId(),j=o.useId();function a(){const i=d.trim();if(!i)return;const t=c==null?void 0:c.find(p=>{var I;return((I=p.displayName)==null?void 0:I.toLowerCase())===i.toLowerCase()||p.peerId.toLowerCase()===i.toLowerCase()}),u=(t==null?void 0:t.peerId)??i;l.some(p=>p.toLowerCase()===u.toLowerCase())||e([...l,u]),h("")}return s.jsxs("div",{className:"gc-picker",children:[s.jsx("label",{className:"as-field__label",htmlFor:j,children:n}),l.length>0&&s.jsx("ol",{className:r?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((i,t)=>s.jsxs("li",{className:"gc-chip",children:[r&&s.jsx("span",{className:"gc-chip__index",children:t+1}),s.jsx("span",{className:"gc-chip__label",title:i,children:f(c,i)}),r&&s.jsxs(s.Fragment,{children:[s.jsx(N,{label:`Move ${f(c,i)} up`,size:"sm",disabled:t===0,onClick:()=>e(b(l,t,-1)),children:s.jsx(_.up,{size:12})}),s.jsx(N,{label:`Move ${f(c,i)} down`,size:"sm",disabled:t===l.length-1,onClick:()=>e(b(l,t,1)),children:s.jsx(_.down,{size:12})})]}),s.jsx(N,{label:`Remove ${f(c,i)}`,size:"sm",onClick:()=>e(l.filter(u=>u!==i)),children:s.jsx(_.x,{size:12})})]},i))}),s.jsxs("div",{className:"gc-inline",children:[s.jsx("input",{id:j,className:"as-field__input gc-picker__input",list:x,value:d,placeholder:m,onChange:i=>h(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),a())}}),s.jsx("datalist",{id:x,children:c==null?void 0:c.map(i=>s.jsx("option",{value:i.peerId,children:i.displayName??k(i.peerId)},i.peerId))}),s.jsx(w,{variant:"outline",size:"sm",onClick:a,disabled:!d.trim(),children:"Add"})]})]})}function y({value:l,onChange:e,label:c,suggestions:n,placeholder:r}){const[m,d]=o.useState(""),h=o.useId(),x=o.useId();function j(){const a=m.trim();a&&!l.includes(a)&&e([...l,a]),d("")}return s.jsxs("div",{className:"gc-picker",children:[s.jsx("label",{className:"as-field__label",htmlFor:x,children:c}),l.length>0&&s.jsx("ul",{className:"gc-chips",children:l.map(a=>s.jsxs("li",{className:"gc-chip",children:[s.jsx("span",{className:"gc-chip__label",children:a}),s.jsx(N,{label:`Remove ${a}`,size:"sm",onClick:()=>e(l.filter(i=>i!==a)),children:s.jsx(_.x,{size:12})})]},a))}),s.jsxs("div",{className:"gc-inline",children:[s.jsx("input",{id:x,className:"as-field__input gc-picker__input",list:h,value:m,placeholder:r,onChange:a=>d(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),j())}}),s.jsx("datalist",{id:h,children:n==null?void 0:n.map(a=>s.jsx("option",{value:a},a))}),s.jsx(w,{variant:"outline",size:"sm",onClick:j,disabled:!m.trim(),children:"Add"})]})]})}export{y as C,z as P,f as p};
@@ -1 +1 @@
1
- import{r as y,a2 as G,a3 as J,a4 as K,a5 as B,u as X,a6 as Z,j as e,a7 as ee,a8 as se,a9 as le,aa as A,B as j,ab as ie,ac as F,T as z,D as ne,ad as E,I as ae,ae as te,af as re,ag as ce,ah as oe,ai as de,aj as me,ak as he}from"./index-BadBPNlq.js";import{P as k,C as ue}from"./PeerPicker-DrpM2w08.js";import{S}from"./SelectField-Yrfi46XZ.js";import{S as v}from"./Segmented-BJMfyrv9.js";import{S as T}from"./Switch-DQFMOyMT.js";import{D as R}from"./Disclosure-2Zc4btXj.js";function pe({draft:l,parent:d,above:t,peers:c,lists:m}){const n=y.useMemo(()=>{if(!c||c.length===0)return null;let h;try{h=te(l,m)}catch{return null}return{matched:re(B(d,h),c,m).length,total:c.length}},[l,d,c,m]);return n?n.matched===0?e.jsxs(ce,{tone:"warning",title:"No seller matches this policy",children:["With ",t?`${t} and `:"","these settings, none of the ",n.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",n.matched," of ",n.total," sellers",t?` after ${t}`:"","."]}):null}function Ne({value:l,onChange:d,peers:t,lists:c,showTemplates:m=!0,parent:n,disabled:h}){const[x,b]=y.useState(""),[o,p]=y.useState(null),a=(s,r)=>d({...l,[s]:r}),N=G(t),I=c.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),g=J(K().data),i=y.useMemo(()=>g||n?B(g,n):null,[g,n]),D=g&&n?"the buyer config and the levels above":g?"the buyer config":n?"the levels above":"",w=s=>(g==null?void 0:g[s])!==void 0&&g[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",{viewer:W}=X(),Y=Z("settings",W)?e.jsx("a",{className:"gc-link",href:se("settings?tab=buyer"),onClick:ee("settings?tab=buyer"),children:"Change"}):null,O=s=>w(s)==="The buyer config"?Y:null,H=le(t)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var $;let r;if(s==="own"){const C=c.find(Q=>Q.id===x);if(!C)return;r={allowMode:"only",allowedPeerIds:[],allowedListIds:[C.id]}}else r=oe(de(s));const u=me(l,r),f=(($=A.find(C=>C.id===s))==null?void 0:$.label)??s;u.length>0?p({label:f,template:r,conflicts:u}):d(E(l,r))}function P(s,r){a("routes",l.routes.map((u,f)=>f===s?r:u))}const M=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,_=(s,r)=>e.jsx(z,{size:"sm",className:"gc-num",label:r,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${he(i[s])} above`:"No cap",onChange:u=>a(s,u.target.value)}),L=e.jsxs(e.Fragment,{children:[e.jsx(pe,{draft:l,parent:i,above:D,peers:t,lists:c}),m&&!h&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(j,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),c.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(S,{size:"sm","aria-label":"Peer list for Own peers only",value:x,onChange:b,options:[{value:"",label:"Own peer list…"},...I]}),e.jsx(j,{size:"sm",variant:"outline",disabled:!x,onClick:()=>q("own"),children:"Use"})]}),e.jsx(j,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>d(ie()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(v,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>a("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>a("allowedPeerIds",s),peers:t}),e.jsx(V,{label:"Allowed peer lists",lists:c,value:l.allowedListIds,onChange:s=>a("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(k,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>a("blockedPeerIds",s),peers:t}),e.jsx(V,{label:"Blocked peer lists",lists:c,value:l.blockedListIds,onChange:s=>a("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(U,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>a("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:w("minTrustScore"),floorAction:O("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(T,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>a("requireTee",s),label:"TEE sellers only"}),e.jsx(T,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>a("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(S,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>a("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(F).map(s=>({value:s,label:F[s]}))]}),e.jsx(S,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>a("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(v,{label:"Which models may be used",value:l.modelsMode,onChange:s=>a("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(ue,{label:"Allowed models",value:l.allowedModels,onChange:s=>a("allowedModels",s),suggestions:N,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:M?`${M} set`:"None",defaultOpen:h&&M>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[_("maxInputUsdPerMillion","Input $/M"),_("maxOutputUsdPerMillion","Output $/M"),_("maxCachedInputUsdPerMillion","Cached input $/M"),_("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:h&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,r)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(z,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:u=>P(r,{...s,model:u.target.value})}),e.jsx(T,{checked:s.strict,onChange:u=>P(r,{...s,strict:u}),label:"Strict"}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>a("routes",l.routes.filter((u,f)=>f!==r)),children:"Remove"})]}),e.jsx(k,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:u=>P(r,{...s,peerIds:u}),peers:t})]},r)),e.jsx("datalist",{id:"gc-policy-models",children:N.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(j,{variant:"outline",size:"sm",onClick:()=>a("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),H&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:h&&l.minReputation!=="",children:e.jsx(U,{label:"Minimum reputation",value:l.minReputation,onChange:s=>a("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:w("minReputation"),floorAction:O("minReputation")})})]}),e.jsx(ne,{isOpen:o!==null,tone:"primary",title:`Apply “${(o==null?void 0:o.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:o==null?void 0:o.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>p(null),onConfirm:()=>{o&&d(E(l,o.template)),p(null)}})]});return h?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:L}):e.jsx("div",{className:"gc-policy",children:L})}function U({label:l,value:d,onChange:t,clearable:c=!0,hint:m,floor:n,floorSource:h="The levels above",floorAction:x}){const b=y.useId(),o=d!=="",p=n!==void 0&&n>0,a=p&&o&&Number(d)<=n,N=a?String(n):o?d:p?`${n} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:b,children:l}),e.jsx("span",{className:o?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:N})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:o?Math.max(Number(d),p?n:0):p?n:0,"aria-labelledby":b,onChange:I=>t(String(Math.max(Number(I.target.value),p?n:0)))}),c&&o&&e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>t(""),children:"Clear"})]}),p&&(o&&!a?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",n,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(ae.lock,{size:12})," Locked at ",n," by ",h.replace(/^The /,"the "),".",x?e.jsxs(e.Fragment,{children:[" ",x]}):null]})),m&&e.jsx("span",{className:"as-field__hint",children:m})]})}function V({label:l,lists:d,value:t,onChange:c}){return d.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),d.map(m=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:t.includes(m.id),onChange:n=>c(n.target.checked?[...t,m.id]:t.filter(h=>h!==m.id))}),m.name," ",e.jsxs("span",{className:"gc-muted",children:["(",m.peerIds.length,")"]})]},m.id))]})}export{Ne as P,U as S};
1
+ import{r as y,a3 as G,a4 as J,a5 as K,a6 as B,u as X,a7 as Z,j as e,a8 as ee,a9 as se,aa as le,ab as A,B as j,ac as ie,ad as F,T as z,D as ne,ae as E,I as ae,af as te,ag as re,ah as ce,ai as oe,aj as de,ak as me,al as he}from"./index-BpFwvYMF.js";import{P as k,C as ue}from"./PeerPicker-w_ZaksUm.js";import{S}from"./SelectField-D3qPiNQz.js";import{S as v}from"./Segmented-D_Yun-tG.js";import{S as T}from"./Switch-BmFsXcr8.js";import{D as R}from"./Disclosure-BitAjv2r.js";function pe({draft:l,parent:d,above:t,peers:c,lists:m}){const n=y.useMemo(()=>{if(!c||c.length===0)return null;let h;try{h=te(l,m)}catch{return null}return{matched:re(B(d,h),c,m).length,total:c.length}},[l,d,c,m]);return n?n.matched===0?e.jsxs(ce,{tone:"warning",title:"No seller matches this policy",children:["With ",t?`${t} and `:"","these settings, none of the ",n.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",n.matched," of ",n.total," sellers",t?` after ${t}`:"","."]}):null}function Ne({value:l,onChange:d,peers:t,lists:c,showTemplates:m=!0,parent:n,disabled:h}){const[x,b]=y.useState(""),[o,p]=y.useState(null),a=(s,r)=>d({...l,[s]:r}),N=G(t),I=c.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),g=J(K().data),i=y.useMemo(()=>g||n?B(g,n):null,[g,n]),D=g&&n?"the buyer config and the levels above":g?"the buyer config":n?"the levels above":"",w=s=>(g==null?void 0:g[s])!==void 0&&g[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",{viewer:W}=X(),Y=Z("settings",W)?e.jsx("a",{className:"gc-link",href:se("settings?tab=buyer"),onClick:ee("settings?tab=buyer"),children:"Change"}):null,O=s=>w(s)==="The buyer config"?Y:null,H=le(t)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var $;let r;if(s==="own"){const C=c.find(Q=>Q.id===x);if(!C)return;r={allowMode:"only",allowedPeerIds:[],allowedListIds:[C.id]}}else r=oe(de(s));const u=me(l,r),f=(($=A.find(C=>C.id===s))==null?void 0:$.label)??s;u.length>0?p({label:f,template:r,conflicts:u}):d(E(l,r))}function P(s,r){a("routes",l.routes.map((u,f)=>f===s?r:u))}const M=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,_=(s,r)=>e.jsx(z,{size:"sm",className:"gc-num",label:r,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${he(i[s])} above`:"No cap",onChange:u=>a(s,u.target.value)}),L=e.jsxs(e.Fragment,{children:[e.jsx(pe,{draft:l,parent:i,above:D,peers:t,lists:c}),m&&!h&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(j,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),c.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(S,{size:"sm","aria-label":"Peer list for Own peers only",value:x,onChange:b,options:[{value:"",label:"Own peer list…"},...I]}),e.jsx(j,{size:"sm",variant:"outline",disabled:!x,onClick:()=>q("own"),children:"Use"})]}),e.jsx(j,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>d(ie()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(v,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>a("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>a("allowedPeerIds",s),peers:t}),e.jsx(V,{label:"Allowed peer lists",lists:c,value:l.allowedListIds,onChange:s=>a("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(k,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>a("blockedPeerIds",s),peers:t}),e.jsx(V,{label:"Blocked peer lists",lists:c,value:l.blockedListIds,onChange:s=>a("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(U,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>a("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:w("minTrustScore"),floorAction:O("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(T,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>a("requireTee",s),label:"TEE sellers only"}),e.jsx(T,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>a("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(S,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>a("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(F).map(s=>({value:s,label:F[s]}))]}),e.jsx(S,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>a("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(v,{label:"Which models may be used",value:l.modelsMode,onChange:s=>a("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(ue,{label:"Allowed models",value:l.allowedModels,onChange:s=>a("allowedModels",s),suggestions:N,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:M?`${M} set`:"None",defaultOpen:h&&M>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[_("maxInputUsdPerMillion","Input $/M"),_("maxOutputUsdPerMillion","Output $/M"),_("maxCachedInputUsdPerMillion","Cached input $/M"),_("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:h&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,r)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(z,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:u=>P(r,{...s,model:u.target.value})}),e.jsx(T,{checked:s.strict,onChange:u=>P(r,{...s,strict:u}),label:"Strict"}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>a("routes",l.routes.filter((u,f)=>f!==r)),children:"Remove"})]}),e.jsx(k,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:u=>P(r,{...s,peerIds:u}),peers:t})]},r)),e.jsx("datalist",{id:"gc-policy-models",children:N.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(j,{variant:"outline",size:"sm",onClick:()=>a("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),H&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:h&&l.minReputation!=="",children:e.jsx(U,{label:"Minimum reputation",value:l.minReputation,onChange:s=>a("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:w("minReputation"),floorAction:O("minReputation")})})]}),e.jsx(ne,{isOpen:o!==null,tone:"primary",title:`Apply “${(o==null?void 0:o.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:o==null?void 0:o.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>p(null),onConfirm:()=>{o&&d(E(l,o.template)),p(null)}})]});return h?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:L}):e.jsx("div",{className:"gc-policy",children:L})}function U({label:l,value:d,onChange:t,clearable:c=!0,hint:m,floor:n,floorSource:h="The levels above",floorAction:x}){const b=y.useId(),o=d!=="",p=n!==void 0&&n>0,a=p&&o&&Number(d)<=n,N=a?String(n):o?d:p?`${n} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:b,children:l}),e.jsx("span",{className:o?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:N})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:o?Math.max(Number(d),p?n:0):p?n:0,"aria-labelledby":b,onChange:I=>t(String(Math.max(Number(I.target.value),p?n:0)))}),c&&o&&e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>t(""),children:"Clear"})]}),p&&(o&&!a?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",n,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(ae.lock,{size:12})," Locked at ",n," by ",h.replace(/^The /,"the "),".",x?e.jsxs(e.Fragment,{children:[" ",x]}):null]})),m&&e.jsx("span",{className:"as-field__hint",children:m})]})}function V({label:l,lists:d,value:t,onChange:c}){return d.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),d.map(m=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:t.includes(m.id),onChange:n=>c(n.target.checked?[...t,m.id]:t.filter(h=>h!==m.id))}),m.name," ",e.jsxs("span",{className:"gc-muted",children:["(",m.peerIds.length,")"]})]},m.id))]})}export{Ne as P,U as S};
@@ -1 +1 @@
1
- import{bs as p,r as d,j as e,D as m,bD as x,bE as v,bF as b,v as j,bw as y,bv as w,ae as f,b as C,B as h,C as k}from"./index-BadBPNlq.js";import{P}from"./PolicyEditor-DNb3bKbN.js";function L(){const l=p(),[s,n]=d.useState(null),a=d.useRef(null),r=t=>new Promise(u=>{a.current=u,n(t)}),o=t=>{var u;n(null),(u=a.current)==null||u.call(a,t),a.current=null},i=(t,u)=>x(t.some(g=>v(g,l.data??null)),u,r),c=(s==null?void 0:s.kind)==="narrowed"?e.jsx(m,{isOpen:!0,tone:"primary",title:"The levels above allow less",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:"Part of this change has no effect, because a workspace, member or admin restriction above it is tighter. Saving stores it as you entered it; only what the levels above allow applies."}),s.lines.length>0&&e.jsx("ul",{className:"gc-list",children:s.lines.map(t=>e.jsx("li",{children:t},t))})]})}):e.jsx(m,{isOpen:(s==null?void 0:s.kind)==="empty",tone:"danger",title:"Save an empty allow list?",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs(e.Fragment,{children:["With this allow list ",e.jsx("strong",{children:"no seller can serve"})," requests here (it names no seller, or none the levels above allow), so they fail until you change it. To let any seller serve, choose “Any seller” instead."]})});return{save:i,dialog:c}}function S({policy:l,invalid:s,empty:n="Inherits everything"}){if(s)return e.jsx("span",{className:"gc-warn",children:"Has an invalid setting; open it to fix."});const a=b(l);return a.length===0?e.jsx("span",{className:"gc-muted",children:n}):e.jsx("span",{className:"gc-chiprow",children:a.map(r=>e.jsx(j,{children:r},r))})}function B(l){const[s,n]=d.useState(()=>y(l)),a=p();return{draft:s,setDraft:n,reset:r=>n(y(r)),build:()=>w(f(s,a.data??null))}}function N(l,s){try{return{policy:f(l,s),error:null}}catch(n){return{policy:null,error:n instanceof Error?n.message:String(n)}}}function F({draft:l,setDraft:s,title:n="Routing policy"}){const a=C(),r=p(),[o,i]=d.useState(null),c=N(l,r.data??null),t=()=>{o&&s(o),i(null)};return e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx("span",{className:"as-field__label",children:n}),e.jsx(S,{policy:c.policy,invalid:c.error!==null})]}),e.jsx(h,{size:"sm",variant:"outline",onClick:()=>i(l),children:"Edit"}),e.jsx(k,{isOpen:o!==null,onClose:()=>i(null),size:"xl",title:n,subtitle:"Blank settings inherit from the level above, which this can only narrow. Saved with the form.",footer:e.jsxs(e.Fragment,{children:[c.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:c.error}),e.jsx(h,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(h,{onClick:()=>i(null),children:"Done"})]}),children:e.jsx(P,{value:l,onChange:s,peers:a.data,lists:r.data??[]})})]})}export{F as P,L as a,S as b,N as d,B as u};
1
+ import{bs as p,r as d,j as e,D as m,bD as x,bE as v,bF as b,v as j,bw as f,bv as w,af as y,b as C,B as h,C as k}from"./index-BpFwvYMF.js";import{P}from"./PolicyEditor-BOjadRE8.js";function L(){const l=p(),[s,n]=d.useState(null),a=d.useRef(null),r=t=>new Promise(u=>{a.current=u,n(t)}),o=t=>{var u;n(null),(u=a.current)==null||u.call(a,t),a.current=null},i=(t,u)=>x(t.some(g=>v(g,l.data??null)),u,r),c=(s==null?void 0:s.kind)==="narrowed"?e.jsx(m,{isOpen:!0,tone:"primary",title:"The levels above allow less",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:"Part of this change has no effect, because a workspace, member or admin restriction above it is tighter. Saving stores it as you entered it; only what the levels above allow applies."}),s.lines.length>0&&e.jsx("ul",{className:"gc-list",children:s.lines.map(t=>e.jsx("li",{children:t},t))})]})}):e.jsx(m,{isOpen:(s==null?void 0:s.kind)==="empty",tone:"danger",title:"Save an empty allow list?",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs(e.Fragment,{children:["With this allow list ",e.jsx("strong",{children:"no seller can serve"})," requests here (it names no seller, or none the levels above allow), so they fail until you change it. To let any seller serve, choose “Any seller” instead."]})});return{save:i,dialog:c}}function S({policy:l,invalid:s,empty:n="Inherits everything"}){if(s)return e.jsx("span",{className:"gc-warn",children:"Has an invalid setting; open it to fix."});const a=b(l);return a.length===0?e.jsx("span",{className:"gc-muted",children:n}):e.jsx("span",{className:"gc-chiprow",children:a.map(r=>e.jsx(j,{children:r},r))})}function B(l){const[s,n]=d.useState(()=>f(l)),a=p();return{draft:s,setDraft:n,reset:r=>n(f(r)),build:()=>w(y(s,a.data??null))}}function N(l,s){try{return{policy:y(l,s),error:null}}catch(n){return{policy:null,error:n instanceof Error?n.message:String(n)}}}function F({draft:l,setDraft:s,title:n="Routing policy"}){const a=C(),r=p(),[o,i]=d.useState(null),c=N(l,r.data??null),t=()=>{o&&s(o),i(null)};return e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx("span",{className:"as-field__label",children:n}),e.jsx(S,{policy:c.policy,invalid:c.error!==null})]}),e.jsx(h,{size:"sm",variant:"outline",onClick:()=>i(l),children:"Edit"}),e.jsx(k,{isOpen:o!==null,onClose:()=>i(null),size:"xl",title:n,subtitle:"Blank settings inherit from the level above, which this can only narrow. Saved with the form.",footer:e.jsxs(e.Fragment,{children:[c.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:c.error}),e.jsx(h,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(h,{onClick:()=>i(null),children:"Done"})]}),children:e.jsx(P,{value:l,onChange:s,peers:a.data,lists:r.data??[]})})]})}export{F as P,L as a,S as b,N as d,B as u};
@@ -1,4 +1,4 @@
1
- import{u as A,i as J,bp as B,r as n,t as E,j as e,P as $,B as y,I as k,l as L,Q as R,M as Q,aM as U,v as C,A as V,E as W,n as F,C as G,D as H,b as K,T as j,a2 as _,o as X,q as O,f as v}from"./index-BadBPNlq.js";import{u as Y,a as Z,P as ee}from"./PolicyField-CfklGeps.js";import{D as se}from"./DataTable-D-JhP6Cu.js";import{S as re}from"./SelectField-Yrfi46XZ.js";import{T as N}from"./TextAreaField-CKrBh0oZ.js";import"./PolicyEditor-DNb3bKbN.js";import"./PeerPicker-DrpM2w08.js";import"./Segmented-BJMfyrv9.js";import"./roving-DkptacxO.js";import"./Switch-DQFMOyMT.js";import"./Disclosure-2Zc4btXj.js";function D(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function te(s){return/^[a-z0-9][a-z0-9-]{0,47}$/.test(s)}function ae(s){if(!s.trim())return{};let a;try{a=JSON.parse(s)}catch{throw new Error("Parameters must be valid JSON.")}if(!a||typeof a!="object"||Array.isArray(a))throw new Error('Parameters must be a JSON object, like {"temperature": 0.2}.');return a}function oe({initial:s,prefill:a,onDone:m}){const{workspace:p,viewer:c}=A(),u=K(),[o,g]=n.useState((s==null?void 0:s.name)??(a==null?void 0:a.name)??""),[l,d]=n.useState((s==null?void 0:s.slug)??(a?D(a.name):"")),[t,M]=n.useState(!!s),[h,q]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,I]=n.useState(s?s.workspaceId??"":p.id),[S,T]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,z]=n.useState(s&&Object.keys(s.params).length?JSON.stringify(s.params,null,2):""),x=Y(s==null?void 0:s.routingPolicy),P=Z(),i=E({mutationFn:()=>{if(!te(l))throw new Error("Slug must be lowercase letters, numbers and dashes.");const r={name:o.trim(),slug:l,model:h.trim(),workspaceId:b||null,systemPrompt:S.trim()||null,params:ae(w),routingPolicy:x.build()};return P.save([r.routingPolicy],f=>s?v.presets.update(s.id,r,f):v.presets.create(r,f))},onSuccess:r=>m(r),invalidate:[O.group("presets")],toast:"Preset saved"});return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),i.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Name",required:!0,value:o,onChange:r=>{g(r.target.value),t||d(D(r.target.value))}}),e.jsx(j,{label:"Slug",required:!0,value:l,onChange:r=>{M(!0),d(r.target.value)},hint:e.jsxs(e.Fragment,{children:["Called as ",e.jsxs("code",{children:["@preset/",l||"slug"]})]})})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Model",required:!0,list:"gc-preset-models",value:h,onChange:r=>q(r.target.value)}),e.jsx("datalist",{id:"gc-preset-models",children:_(u.data).map(r=>e.jsx("option",{value:r},r))}),e.jsx(re,{label:"Available in",value:b,onChange:I,options:[{value:p.id,label:`${p.name} workspace`},...F(c)?[{value:"",label:"All workspaces"}]:[]]})]}),e.jsx(N,{label:"System prompt",rows:4,value:S,onChange:r=>T(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
1
+ import{u as A,i as J,bp as B,r as n,t as E,j as e,P as $,B as y,I as k,l as L,Q as R,M as Q,aN as U,v as C,A as V,E as W,n as F,C as G,D as H,b as K,T as j,a3 as _,o as X,q as O,f as v}from"./index-BpFwvYMF.js";import{u as Y,a as Z,P as ee}from"./PolicyField-BbDSVgcK.js";import{D as se}from"./DataTable-CCEZoIzX.js";import{S as re}from"./SelectField-D3qPiNQz.js";import{T as N}from"./TextAreaField-RZPCzhKZ.js";import"./PolicyEditor-BOjadRE8.js";import"./PeerPicker-w_ZaksUm.js";import"./Segmented-D_Yun-tG.js";import"./roving-DkptacxO.js";import"./Switch-BmFsXcr8.js";import"./Disclosure-BitAjv2r.js";function D(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function te(s){return/^[a-z0-9][a-z0-9-]{0,47}$/.test(s)}function ae(s){if(!s.trim())return{};let a;try{a=JSON.parse(s)}catch{throw new Error("Parameters must be valid JSON.")}if(!a||typeof a!="object"||Array.isArray(a))throw new Error('Parameters must be a JSON object, like {"temperature": 0.2}.');return a}function oe({initial:s,prefill:a,onDone:m}){const{workspace:p,viewer:c}=A(),u=K(),[o,g]=n.useState((s==null?void 0:s.name)??(a==null?void 0:a.name)??""),[l,d]=n.useState((s==null?void 0:s.slug)??(a?D(a.name):"")),[t,q]=n.useState(!!s),[h,I]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,M]=n.useState(s?s.workspaceId??"":p.id),[S,T]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,z]=n.useState(s&&Object.keys(s.params).length?JSON.stringify(s.params,null,2):""),x=Y(s==null?void 0:s.routingPolicy),P=Z(),i=E({mutationFn:()=>{if(!te(l))throw new Error("Slug must be lowercase letters, numbers and dashes.");const r={name:o.trim(),slug:l,model:h.trim(),workspaceId:b||null,systemPrompt:S.trim()||null,params:ae(w),routingPolicy:x.build()};return P.save([r.routingPolicy],f=>s?v.presets.update(s.id,r,f):v.presets.create(r,f))},onSuccess:r=>m(r),invalidate:[O.group("presets")],toast:"Preset saved"});return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),i.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Name",required:!0,value:o,onChange:r=>{g(r.target.value),t||d(D(r.target.value))}}),e.jsx(j,{label:"Slug",required:!0,value:l,onChange:r=>{q(!0),d(r.target.value)},hint:e.jsxs(e.Fragment,{children:["Called as ",e.jsxs("code",{children:["@preset/",l||"slug"]})]})})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Model",required:!0,list:"gc-preset-models",value:h,onChange:r=>I(r.target.value)}),e.jsx("datalist",{id:"gc-preset-models",children:_(u.data).map(r=>e.jsx("option",{value:r},r))}),e.jsx(re,{label:"Available in",value:b,onChange:M,options:[{value:p.id,label:`${p.name} workspace`},...F(c)?[{value:"",label:"All workspaces"}]:[]]})]}),e.jsx(N,{label:"System prompt",rows:4,value:S,onChange:r=>T(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
2
2
  "temperature": 0.2,
3
3
  "max_tokens": 2048
4
4
  }`,onChange:r=>z(r.target.value),hint:"Defaults merged under the client's own parameters."}),e.jsx(ee,{draft:x.draft,setDraft:x.setDraft}),i.error?e.jsx(X,{error:i.error,title:"Could not save the preset"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(y,{variant:"ghost",onClick:()=>m(),children:"Cancel"}),e.jsx(y,{type:"submit",disabled:i.isPending||!o.trim()||!h.trim(),children:i.isPending?"Saving…":"Save preset"})]}),P.dialog]})}function je(){const{workspace:s,viewer:a}=A(),m=J(a),p=B(s.id),[c,u]=n.useState(null),[o,g]=n.useState(null),l=E({mutationFn:d=>v.presets.remove(d.id),onSuccess:()=>g(null),invalidate:[O.group("presets")]});return e.jsxs("div",{className:"gc-page",children:[e.jsx($,{title:"Presets",description:e.jsxs(e.Fragment,{children:["A saved model, prompt, parameters and routing. Use one by sending ",e.jsx("code",{children:'"model": "@preset/<slug>"'}),"."]}),actions:m&&e.jsx(y,{variant:"brand",leadingIcon:e.jsx(k.plus,{size:14}),onClick:()=>u("new"),children:"New preset"})}),e.jsx(L,{flush:!0,children:e.jsx(R,{query:p,children:d=>e.jsx(se,{label:"Presets",rows:d,rowKey:t=>t.id,rowLabel:t=>t.name,actions:t=>m&&(t.workspaceId||F(a))?[{label:"Edit",onSelect:()=>u(t)},{label:"Delete",tone:"danger",onSelect:()=>g(t)}]:[],empty:e.jsx(W,{icon:e.jsx(k.presets,{size:18}),title:"No presets yet",body:"Presets let every client share one tuned setup without changing code."}),columns:[{key:"name",header:"Name",render:t=>e.jsx("span",{className:"gc-strong",children:t.name})},{key:"usage",header:"Use as model",render:t=>e.jsxs("span",{className:"gc-inline gc-inline--wrap",children:[e.jsxs(Q,{children:["@preset/",t.slug]}),e.jsx(U,{value:`@preset/${t.slug}`})]})},{key:"model",header:"Model",secondary:!0,render:t=>t.model},{key:"scope",header:"Scope",secondary:!0,render:t=>t.workspaceId?e.jsx(C,{children:"Workspace"}):e.jsx(C,{tone:"info",children:"All workspaces"})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>e.jsx("span",{className:"gc-muted",children:V(t.routingPolicy)})}]})})}),e.jsx(G,{isOpen:c!==null,onClose:()=>u(null),size:"lg",title:c==="new"?"New preset":"Edit preset",children:c!==null&&e.jsx(oe,{initial:c==="new"?null:c,onDone:()=>u(null)})}),e.jsx(H,{isOpen:o!==null,busy:l.isPending,error:l.error,onClose:()=>g(null),onConfirm:()=>o&&l.mutate(o),title:"Delete this preset?",confirmLabel:"Delete preset",body:e.jsxs(e.Fragment,{children:["Requests that use ",e.jsxs("code",{children:["@preset/",o==null?void 0:o.slug]})," will fail."]})})]})}export{oe as PresetForm,je as default};