@antseed/gateway-console 0.1.4 → 0.1.6

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 (188) hide show
  1. package/dist/assets/Activity-CoD1LZfl.js +1 -0
  2. package/dist/assets/Audit-CNmmoaeN.js +1 -0
  3. package/dist/assets/ChainGate-CeDu6YYJ.js +1 -0
  4. package/dist/assets/ChannelClose-C_SM1g28.js +1 -0
  5. package/dist/assets/{Charts-DAh9h4sf.js → Charts-Dm9j6cVy.js} +1 -1
  6. package/dist/assets/{Chat-DznobJkE.js → Chat-D1yVH5Y-.js} +4 -4
  7. package/dist/assets/{ConnectWallet-DSqRjyNA.js → ConnectWallet-phY-Bf7w.js} +1 -1
  8. package/dist/assets/DataTable-D65CSQpj.js +1 -0
  9. package/dist/assets/{Disclosure-UjXa2WU7.js → Disclosure-DrGE-NkF.js} +1 -1
  10. package/dist/assets/{KeyHolder-e5NvqLQn.js → KeyHolder-CmffMcZD.js} +1 -1
  11. package/dist/assets/{Keys-CxaYteT3.js → Keys-BovEuhch.js} +1 -1
  12. package/dist/assets/Logs-B-T-V-pM.js +1 -0
  13. package/dist/assets/Members-tWNaQdIJ.js +1 -0
  14. package/dist/assets/{Migrate-I3FULNOQ.js → Migrate-IZJLx1xU.js} +1 -1
  15. package/dist/assets/Models-gJrRx-QV.js +1 -0
  16. package/dist/assets/OperatorActions-DfjEKPUD.js +1 -0
  17. package/dist/assets/{OperatorGateAlert-CCPFpK6Y.js → OperatorGateAlert-Bq1ilVp6.js} +1 -1
  18. package/dist/assets/{Overview-zEyUG_qA.js → Overview-CAxieiTF.js} +1 -1
  19. package/dist/assets/PeerPicker-JK4q0ZO9.js +1 -0
  20. package/dist/assets/PolicyEditor-BLo1sheV.js +1 -0
  21. package/dist/assets/PolicyField-CNEZju4W.js +1 -0
  22. package/dist/assets/Presets-DBRoMTo4.js +4 -0
  23. package/dist/assets/Providers-B3qO68z-.js +1 -0
  24. package/dist/assets/RequestLog-vl46fVIZ.js +1 -0
  25. package/dist/assets/Rewards-CRiw-wXO.js +2 -0
  26. package/dist/assets/RewardsClaim-D6P8go-K.js +1 -0
  27. package/dist/assets/Routing-YpzgjNx_.js +1 -0
  28. package/dist/assets/{Segmented-Qx6JB6EU.js → Segmented-YOSVapPh.js} +1 -1
  29. package/dist/assets/SelectField-Cog9tKMb.js +1 -0
  30. package/dist/assets/{Settings-CvfS7lxA.js → Settings-CSXJvDLz.js} +2 -2
  31. package/dist/assets/{Switch-Ba56zux7.js → Switch-CGhLd0Ay.js} +1 -1
  32. package/dist/assets/{Tabs-BmjCmD5T.js → Tabs-DuL015VX.js} +1 -1
  33. package/dist/assets/TextAreaField-Cxpnr6YH.js +1 -0
  34. package/dist/assets/{UsageByModel-BBqXiIqo.js → UsageByModel-5QuGhD1d.js} +1 -1
  35. package/dist/assets/Wallet-BOMYI48H.js +9 -0
  36. package/dist/assets/WalletConfirm-Dc0AMNYH.js +1 -0
  37. package/dist/assets/WalletFunding-CsUmR_iR.js +1 -0
  38. package/dist/assets/WalletSignIn-_VjhsjCt.js +1 -0
  39. package/dist/assets/Workspaces-Da-rLWlz.js +1 -0
  40. package/dist/assets/{add-1gRRQJKT.js → add-Btpjkoo6.js} +2 -2
  41. package/dist/assets/all-wallets-BfrjmkEM.js +6 -0
  42. package/dist/assets/{app-store-DFWwIQzp.js → app-store-CjAKxMNO.js} +2 -2
  43. package/dist/assets/{apple-DgwSchgH.js → apple-BcO7LcJZ.js} +2 -2
  44. package/dist/assets/arrow-bottom-DYhsTHhV.js +8 -0
  45. package/dist/assets/{arrow-bottom-circle-PbZ344lB.js → arrow-bottom-circle-DH3-k8Pr.js} +2 -2
  46. package/dist/assets/arrow-left-i-RgLGSY.js +8 -0
  47. package/dist/assets/arrow-right-Byrj5OIH.js +8 -0
  48. package/dist/assets/arrow-top-BvEWR8S0.js +8 -0
  49. package/dist/assets/{bank-wStsFuNb.js → bank-CqGqrPxl.js} +2 -2
  50. package/dist/assets/{basic-CsVGrHuh.js → basic-DWDkRcdy.js} +1 -1
  51. package/dist/assets/{browser-DlwffXFC.js → browser-CQNym1bY.js} +2 -2
  52. package/dist/assets/{bundle-full-sn1k_IQV.js → bundle-full-C55tgBr2.js} +1 -1
  53. package/dist/assets/{card-pVIbVhmB.js → card-D2zVsWGG.js} +2 -2
  54. package/dist/assets/ccip-2-SkbDQO.js +1 -0
  55. package/dist/assets/{checkmark-BpTw56ma.js → checkmark-FRmQx2A8.js} +2 -2
  56. package/dist/assets/{checkmark-bold-kTaP3XxB.js → checkmark-bold-BQmDzpHv.js} +2 -2
  57. package/dist/assets/chevron-bottom-iNshLmUE.js +8 -0
  58. package/dist/assets/chevron-left-DZ-hTSFy.js +8 -0
  59. package/dist/assets/chevron-right-ftn9B4r7.js +8 -0
  60. package/dist/assets/chevron-top-nKnnD3BB.js +8 -0
  61. package/dist/assets/{chrome-store-PaJUtH_w.js → chrome-store-Jvo-YJCr.js} +2 -2
  62. package/dist/assets/{clock-CMJ0qXc5.js → clock-J68M1oCn.js} +2 -2
  63. package/dist/assets/close-Bb5jO3su.js +8 -0
  64. package/dist/assets/{code-block-xCUZ4Wg2.js → code-block-6bmX2qDf.js} +2 -2
  65. package/dist/assets/coinPlaceholder-BzR2PaE2.js +8 -0
  66. package/dist/assets/{compass-CGS5aeKg.js → compass-_xiCm8H2.js} +2 -2
  67. package/dist/assets/{copy-BES3eNqf.js → copy-Cn8HQUQ0.js} +2 -2
  68. package/dist/assets/{core-Cw7VIz-a.js → core-z96MxYDt.js} +3 -3
  69. package/dist/assets/cursor-AmgDWaYf.js +3 -0
  70. package/dist/assets/{cursor-transparent-Dqx5HyjH.js → cursor-transparent-BtLB_SMp.js} +2 -2
  71. package/dist/assets/{desktop-83z42M8J.js → desktop-BbxKfMA_.js} +2 -2
  72. package/dist/assets/{disconnect-D49VmdOl.js → disconnect-BLztvIUd.js} +2 -2
  73. package/dist/assets/{discord-MHKJZWwF.js → discord-CHUWozPc.js} +2 -2
  74. package/dist/assets/{en_US-Y4ZOVFV4-CzjJ6dvA.js → en_US-Y4ZOVFV4-CAcvlKBB.js} +10 -10
  75. package/dist/assets/{etherscan-_rlcuy0M.js → etherscan-D5vLd5La.js} +2 -2
  76. package/dist/assets/{exclamation-triangle-Bw5MhRmd.js → exclamation-triangle-qrQeSTv8.js} +2 -2
  77. package/dist/assets/{extension-D7frsaxu.js → extension-4gVUPN7H.js} +2 -2
  78. package/dist/assets/external-link-B14WJWrF.js +8 -0
  79. package/dist/assets/{facebook-D2S1lToP.js → facebook-CIMBt82S.js} +1 -1
  80. package/dist/assets/{farcaster-BKD1k1GK.js → farcaster-c2htRu7g.js} +1 -1
  81. package/dist/assets/filters-Bv71E2AR.js +8 -0
  82. package/dist/assets/{github-CanBnK1J.js → github-UYR2U4eW.js} +2 -2
  83. package/dist/assets/{google-DcyjnYXY.js → google-n2NyY3Dw.js} +2 -2
  84. package/dist/assets/{help-circle-EWFFZOKF.js → help-circle-BLFRE_d4.js} +2 -2
  85. package/dist/assets/highlighted-body-KQOG7T2V-BPvcfizq.js +1 -0
  86. package/dist/assets/{id-CwpQkL3B.js → id-Bx-RYygz.js} +2 -2
  87. package/dist/assets/{image-Bru4L9C0.js → image-BOkMzreg.js} +2 -2
  88. package/dist/assets/index-BG30WuBG.js +91 -0
  89. package/dist/assets/index-D8vXwUTI.css +1 -0
  90. package/dist/assets/{index-DI3oIpGN.js → index-DUGIknuZ.js} +2 -2
  91. package/dist/assets/{index-BTqmifYb.js → index-DzFVk9QK.js} +1 -1
  92. package/dist/assets/{index-CO2ldxDL.js → index-FSpcDkTF.js} +3 -3
  93. package/dist/assets/index-RORHmLec.js +1 -0
  94. package/dist/assets/{index.es-Dajqanx_.js → index.es-CA2ape1X.js} +4 -4
  95. package/dist/assets/{info-BiKqTS2d.js → info-Cn0tJEtZ.js} +2 -2
  96. package/dist/assets/info-circle-Bu4Zfbo-.js +12 -0
  97. package/dist/assets/{lightbulb-DOHEz8mA.js → lightbulb-CEuGFxl3.js} +2 -2
  98. package/dist/assets/{limits-DETkh9Vy.js → limits-Cv54gck6.js} +1 -1
  99. package/dist/assets/{mail-B58fLIk0.js → mail-DTJ1wl6n.js} +1 -1
  100. package/dist/assets/{mermaid-MCJ5UELQ-CNEVzFUk.js → mermaid-MCJ5UELQ-BedJEojm.js} +6 -6
  101. package/dist/assets/{metamask-sdk-CgV17tbH.js → metamask-sdk-CQV3kKmz.js} +1 -1
  102. package/dist/assets/{mobile-Der0Vnyo.js → mobile-D5XkpStI.js} +2 -2
  103. package/dist/assets/{models-Ben8ko6c.js → models-DMYWCgsM.js} +1 -1
  104. package/dist/assets/more-DdrXAXX1.js +11 -0
  105. package/dist/assets/{network-placeholder-DgO-AHV1.js → network-placeholder-DYxULQKf.js} +2 -2
  106. package/dist/assets/{nftPlaceholder-DQN5ewFX.js → nftPlaceholder-DNCBtU2V.js} +2 -2
  107. package/dist/assets/off-x6tIm6IU.js +8 -0
  108. package/dist/assets/{play-store-DGLOVnal.js → play-store-DH_0xG8x.js} +1 -1
  109. package/dist/assets/{plus-BiSIXTnl.js → plus-D6bTrOQ5.js} +2 -2
  110. package/dist/assets/{qr-code-CqHp65c8.js → qr-code-nZ-ywovk.js} +1 -1
  111. package/dist/assets/{recycle-horizontal-CRSsOzCz.js → recycle-horizontal-Dfef9bS8.js} +2 -2
  112. package/dist/assets/refresh-DjaTupr6.js +8 -0
  113. package/dist/assets/{reown-logo-DHp9kF6o.js → reown-logo-8xfPxyEW.js} +1 -1
  114. package/dist/assets/search-CTyg9yLr.js +8 -0
  115. package/dist/assets/{secp256k1-eRLZxtys.js → secp256k1-C3GZOk0r.js} +1 -1
  116. package/dist/assets/{send-Ctv_HF2O.js → send-BRCwXyYl.js} +1 -1
  117. package/dist/assets/{swapHorizontal-zaD-84iv.js → swapHorizontal-DQysA-xv.js} +2 -2
  118. package/dist/assets/{swapHorizontalBold-f_5MNh3F.js → swapHorizontalBold-CfvpnhxX.js} +2 -2
  119. package/dist/assets/{swapHorizontalMedium-CnARNDiR.js → swapHorizontalMedium-Ei15IdQU.js} +1 -1
  120. package/dist/assets/{swapHorizontalRoundedBold-BxdOAjIc.js → swapHorizontalRoundedBold-BrdyV7V9.js} +2 -2
  121. package/dist/assets/{swapVertical-BS-jDYcd.js → swapVertical-Chu7IZEN.js} +2 -2
  122. package/dist/assets/{telegram-DfO33sxQ.js → telegram-WX2YRbPh.js} +2 -2
  123. package/dist/assets/{three-dots-K3AmCfOo.js → three-dots-DxlCOrsx.js} +2 -2
  124. package/dist/assets/{twitch-DfjpmeLa.js → twitch-DnDwl6Wp.js} +2 -2
  125. package/dist/assets/{twitterIcon-CXaUDkHK.js → twitterIcon-BRzgYnIv.js} +2 -2
  126. package/dist/assets/{usage-CjxizGfE.js → usage-CSmvbieU.js} +1 -1
  127. package/dist/assets/{useInfiniteQuery-Dm7RR6wI.js → useInfiniteQuery-Dd787Fyg.js} +1 -1
  128. package/dist/assets/{useTx-BRRWrJlB.js → useTx-BMOzJPjG.js} +1 -1
  129. package/dist/assets/{verify-CplHry9Z.js → verify-BDEQw6N7.js} +2 -2
  130. package/dist/assets/{verify-filled-CLSOHfSX.js → verify-filled-4pi90YF-.js} +2 -2
  131. package/dist/assets/{w3m-modal-CQNWLiT9.js → w3m-modal-0lsUnIxD.js} +1 -1
  132. package/dist/assets/{wallet-C3roxttu.js → wallet-Cdj3wKM9.js} +2 -2
  133. package/dist/assets/{wallet-placeholder-CC9q2-xU.js → wallet-placeholder-9WrqEYA6.js} +2 -2
  134. package/dist/assets/{walletconnect-Bnkz4udx.js → walletconnect-Dxw2wfHl.js} +3 -3
  135. package/dist/assets/warning-circle-BS-8TEUR.js +12 -0
  136. package/dist/assets/{x-5eg1spDB.js → x-BuEdoHYI.js} +2 -2
  137. package/dist/index.html +2 -2
  138. package/package.json +3 -3
  139. package/dist/assets/Activity-BsmDMcni.js +0 -1
  140. package/dist/assets/Audit-TIDz29y6.js +0 -1
  141. package/dist/assets/ChainGate-Dvm-SUef.js +0 -1
  142. package/dist/assets/ChannelClose-9Lq8KHLH.js +0 -1
  143. package/dist/assets/DataTable-CDFSD9Kq.js +0 -1
  144. package/dist/assets/Logs-CNCQTTeZ.js +0 -1
  145. package/dist/assets/Members-Bme-PLUh.js +0 -1
  146. package/dist/assets/Models-Bt59XWgD.js +0 -1
  147. package/dist/assets/OperatorActions-DTrUYN6Z.js +0 -1
  148. package/dist/assets/PolicyEditor-BdoaX9gK.js +0 -1
  149. package/dist/assets/PolicyField-DIPl0B1x.js +0 -1
  150. package/dist/assets/Presets-CoTmwoy_.js +0 -4
  151. package/dist/assets/Providers-BxpNjH9s.js +0 -1
  152. package/dist/assets/RequestLog-DhID_VN7.js +0 -1
  153. package/dist/assets/Rewards-XyWhpm9Z.js +0 -2
  154. package/dist/assets/RewardsClaim-BSNDTCMG.js +0 -1
  155. package/dist/assets/Routing-Du8GLQCH.js +0 -1
  156. package/dist/assets/SelectField-D8fxDUNO.js +0 -1
  157. package/dist/assets/TextAreaField-CF9_zjuC.js +0 -1
  158. package/dist/assets/Wallet-DggtuX-0.js +0 -9
  159. package/dist/assets/WalletConfirm-BQCbOnNv.js +0 -1
  160. package/dist/assets/WalletFunding-CvDkcGVU.js +0 -1
  161. package/dist/assets/WalletSignIn-B9g_MY0h.js +0 -1
  162. package/dist/assets/Workspaces-DUn5iA_D.js +0 -1
  163. package/dist/assets/all-wallets-vhiMb1eR.js +0 -6
  164. package/dist/assets/arrow-bottom-Cq4YmOQg.js +0 -8
  165. package/dist/assets/arrow-left-BLB_Dkvm.js +0 -8
  166. package/dist/assets/arrow-right-DpKTBsRx.js +0 -8
  167. package/dist/assets/arrow-top-DSAScZJW.js +0 -8
  168. package/dist/assets/ccip-DAldItLP.js +0 -1
  169. package/dist/assets/chevron-bottom-bMFNlOX_.js +0 -8
  170. package/dist/assets/chevron-left-BvUO5nig.js +0 -8
  171. package/dist/assets/chevron-right-CsjPzxKK.js +0 -8
  172. package/dist/assets/chevron-top-k0xp7Can.js +0 -8
  173. package/dist/assets/close-D_Xc77Yh.js +0 -8
  174. package/dist/assets/coinPlaceholder-D-kUAKbs.js +0 -8
  175. package/dist/assets/cursor-BG-gmA3f.js +0 -3
  176. package/dist/assets/external-link-C7l3-PhY.js +0 -8
  177. package/dist/assets/filters-LINb1X7z.js +0 -8
  178. package/dist/assets/highlighted-body-KQOG7T2V-4q_hgdCF.js +0 -1
  179. package/dist/assets/index-D5ERwHFX.js +0 -1
  180. package/dist/assets/index-DqdaAEyo.js +0 -91
  181. package/dist/assets/index-M34IaZVB.css +0 -1
  182. package/dist/assets/index-mLThkLKM.js +0 -1
  183. package/dist/assets/info-circle-BBN-kA77.js +0 -12
  184. package/dist/assets/more-BoKgpjap.js +0 -11
  185. package/dist/assets/off-M-ZEZL9r.js +0 -8
  186. package/dist/assets/refresh-CNcLCWXe.js +0 -8
  187. package/dist/assets/search-Bk2sMNiB.js +0 -8
  188. package/dist/assets/warning-circle-Be9gSeqg.js +0 -12
@@ -1 +1 @@
1
- import{bx as v,by as g,bz as x,bA as l,bB as p}from"./index-DqdaAEyo.js";var N=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:g()})}getOptimisticResult(e){return e.behavior=g(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:d,isError:c,isRefetchError:b}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:l(t,s.data),hasPreviousPage:x(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:b&&!h&&!n,isRefetching:d&&!o&&!u}}};function w(e,t){return p(e,N)}export{w as u};
1
+ import{bx as v,by as g,bz as x,bA as l,bB as p}from"./index-BG30WuBG.js";var N=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:g()})}getOptimisticResult(e){return e.behavior=g(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:d,isError:c,isRefetchError:b}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:l(t,s.data),hasPreviousPage:x(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:b&&!h&&!n,isRefetching:d&&!o&&!u}}};function w(e,t){return p(e,N)}export{w as u};
@@ -1 +1 @@
1
- import{x as J,y as Q,A as D,z as X,D as Z,B as tt,E as F,F as et,G as at,h as U,I as nt,L as rt,J as st,K as ot,M as it,N as z,O as ct,P as W,Q as ut,R as dt,S as Y,T as I,U as lt,V as ft,X as ht,f as wt,Y as pt,c as K,q as O,u as mt,Z as yt,w as Ct}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import{bf as gt,c0 as At,j as R,ac as B,r as b,c1 as Et,aq as Rt}from"./index-DqdaAEyo.js";function St({chain:t,currentChainId:e}){if(!t)throw new J;if(e!==t.id)throw new Q({chain:t,currentChainId:e})}const G=new rt(128);async function Tt(t,e){var T,d,p,_,L;const{account:a=t.account,assertChainId:s=!0,chain:r=t.chain,accessList:n,authorizationList:o,blobs:c,data:l,dataSuffix:f=typeof t.dataSuffix=="string"?t.dataSuffix:(T=t.dataSuffix)==null?void 0:T.value,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:g,nonce:N,type:w,value:C,...S}=e;if(typeof a>"u")throw new D({docsPath:"/docs/actions/wallet/sendTransaction"});const i=a?W(a):null;try{X(e);const A=await(async()=>{if(e.to)return e.to;if(e.to!==null&&o&&o.length>0)return await Z({authorization:o[0]}).catch(()=>{throw new tt("`to` is required. Could not infer from `authorizationList`.")})})();if((i==null?void 0:i.type)==="json-rpc"||i===null){let x;r!==null&&(x=await F(t,et,"getChainId")({}),s&&St({currentChainId:x,chain:r}));const P=(_=(p=(d=t.chain)==null?void 0:d.formatters)==null?void 0:p.transactionRequest)==null?void 0:_.format,k=(P||at)({...nt(S,{format:P}),accessList:n,account:i,authorizationList:o,blobs:c,chainId:x,data:f?U([l??"0x",f]):l,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:g,nonce:N,to:A,type:w,value:C},"sendTransaction"),$=G.get(t.uid),V=$?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:V,params:[k]},{retryCount:0})}catch(H){if($===!1)throw H;const E=H;if(E.name==="InvalidInputRpcError"||E.name==="InvalidParamsRpcError"||E.name==="MethodNotFoundRpcError"||E.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[k]},{retryCount:0}).then(v=>(G.set(t.uid,!0),v)).catch(v=>{const M=v;throw M.name==="MethodNotFoundRpcError"||M.name==="MethodNotSupportedRpcError"?(G.set(t.uid,!1),E):M});throw E}}if((i==null?void 0:i.type)==="local"){const x=await F(t,st,"prepareTransactionRequest")({account:i,accessList:n,authorizationList:o,blobs:c,chain:r,data:f?U([l??"0x",f]):l,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:g,nonce:N,nonceManager:i.nonceManager,parameters:[...ot,"sidecars"],type:w,value:C,...S,to:A}),P=(L=r==null?void 0:r.serializers)==null?void 0:L.transaction,j=await i.signTransaction(x,{serializer:P});return await F(t,it,"sendRawTransaction")({serializedTransaction:j})}throw(i==null?void 0:i.type)==="smart"?new z({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new z({docsPath:"/docs/actions/wallet/sendTransaction",type:i==null?void 0:i.type})}catch(A){throw A instanceof z?A:ct(A,{...e,account:i,chain:e.chain||void 0})}}async function q(t,e){return q.internal(t,Tt,"sendTransaction",e)}(function(t){async function e(a,s,r,n){const{abi:o,account:c=a.account,address:l,args:f,functionName:u,...m}=n;if(typeof c>"u")throw new D({docsPath:"/docs/contract/writeContract"});const h=c?W(c):null,y=ut({abi:o,args:f,functionName:u});try{return await F(a,s,r)({data:y,to:l,account:h,...m})}catch(g){throw dt(g,{abi:o,address:l,args:f,docsPath:"/docs/contract/writeContract",functionName:u,sender:h==null?void 0:h.address})}}t.internal=e})(q||(q={}));async function Ft(t,e){const{abi:a,chainId:s,connector:r,...n}=e;let o;e.account?o=e.account:o=(await Y(t,{assertChainId:!1,chainId:s,connector:r})).account;const c=t.getClient({chainId:s}),l=I(c,lt,"simulateContract"),{result:f,request:u}=await l({...n,abi:a,account:o});return{chainId:c.chain.id,result:f,request:{...u,chainId:s}}}async function xt(t,e){const{chainId:a,timeout:s=0,...r}=e,n=t.getClient({chainId:a}),c=await I(n,ft,"waitForTransactionReceipt")({...r,timeout:s});if(c.status==="reverted"){const l=I(n,ht,"getTransaction"),{from:f,...u}=await l({hash:c.transactionHash}),h=await I(n,wt,"call")({...u,account:f,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),y=h!=null&&h.data?pt(`0x${h.data.substring(138)}`):"unknown reason";throw new Error(y)}return{...c,chainId:n.chain.id}}async function bt(t,e){const{account:a,chainId:s,connector:r,...n}=e;let o;return typeof a=="object"&&(a==null?void 0:a.type)==="local"?o=t.getClient({chainId:s}):o=await Y(t,{account:a??void 0,assertChainId:!1,chainId:s,connector:r}),await I(o,q,"writeContract")({...n,...a?{account:a}:{},chain:s?{id:s}:null})}function It(t){return{mutationFn(e){return bt(t,e)},mutationKey:["writeContract"]}}function qt(t={}){const{mutation:e}=t,a=K(t),s=It(a),{mutate:r,mutateAsync:n,...o}=gt({...e,...s});return{...o,writeContract:r,writeContractAsync:n}}const Ot=O(["function getOperator(address buyer) view returns (address)","function getOperatorNonce(address buyer) view returns (uint256)","function setOperator(address buyer, address operator, uint256 nonce, bytes buyerSig)","function transferOperator(address buyer, address newOperator)","function withdraw(address buyer, uint256 amount)","error NotAuthorized()","error InvalidAmount()","error InvalidAddress()","error InsufficientBalance()","error InvalidSignature()","error InvalidNonce()","error OperatorAlreadySet()"]),_t=O(["function claimBuyerReward(address buyer, uint256 epoch)","error NotRewardRecipient()","error RewardRecipientUnavailable()"]),vt=O(["function channels(bytes32 channelId) view returns (address buyer, address seller, uint128 deposit, uint128 settled, bytes32 metadataHash, uint256 deadline, uint256 settledAt, uint256 closeRequestedAt, uint8 status)","function requestClose(bytes32 channelId)","function withdraw(bytes32 channelId)","error ChannelNotActive()","error NotAuthorized()","error CloseAlreadyRequested()","error CloseNotReady()"]),Mt=O(["function claimBuyerEmissions(address buyer, uint256[] epochs)","error NotAuthorized()","error EpochNotFinalized()"]);function zt({chain:t,runner:e,done:a="Confirmed on chain."}){const s=e.lastHash?At(t,e.lastHash):null,r=s&&R.jsx("a",{className:"gc-link",href:s,target:"_blank",rel:"noopener noreferrer",children:"View transaction"});return R.jsxs(R.Fragment,{children:[e.status&&R.jsxs(B,{tone:"info",children:[e.status," ",e.running&&e.lastHash&&r]}),e.error&&R.jsxs(B,{tone:"danger",children:[e.error," ",!e.running&&r]}),!e.running&&!e.error&&e.confirmed&&R.jsxs(B,{tone:"success",children:[a," ",r]})]})}function Bt(t){const e=K(),{chainId:a}=mt(),{switchChainAsync:s}=yt(),[r,n]=b.useState(null),[o,c]=b.useState(null),[l,f]=b.useState(null),[u,m]=b.useState(null),[h,y]=b.useState(!1);async function g(N,w={}){var S,i,T;let C=null;y(!0),c(null),m(null),f(null);try{a!==t&&(n("Switch network in your wallet…"),await s({chainId:t}));for(const d of N){d.check&&(n(`${d.label}: checking…`),await d.check()),n(`${d.label}: confirm in your wallet…`);const p=await d.send();if(C=p,f(p),n(`${d.label}: waiting for confirmation…`),(await xt(e,{hash:p,chainId:t})).status!=="success")throw new Error(`${d.label} reverted on chain.`)}return n(null),m(C),C}catch(d){n(null);const p=Et(d);return p?(c(p.message),p.refresh&&((S=w.onStale)==null||S.call(w))):d instanceof Rt?(c(d.message),d.refresh&&((i=w.onStale)==null||i.call(w))):(c(Ct(d)),C&&((T=w.onStale)==null||T.call(w))),null}finally{y(!1)}}return{run:g,running:h,status:r,setStatus:n,error:o,lastHash:l,confirmed:u,wrongChain:a!==void 0&&a!==t,setError:c}}export{vt as C,Ot as D,Mt as L,zt as T,_t as U,qt as a,Ft as s,Bt as u};
1
+ import{x as J,y as Q,A as D,z as X,D as Z,B as tt,E as F,F as et,G as at,h as U,I as nt,L as rt,J as st,K as ot,M as it,N as z,O as ct,P as W,Q as ut,R as dt,S as Y,T as I,U as lt,V as ft,X as ht,f as wt,Y as pt,c as K,q as _,u as mt,Z as yt,w as gt}from"./en_US-Y4ZOVFV4-CAcvlKBB.js";import{bw as Ct,c0 as At,j as R,ag as B,r as b,c1 as Et,aM as Rt}from"./index-BG30WuBG.js";function St({chain:t,currentChainId:e}){if(!t)throw new J;if(e!==t.id)throw new Q({chain:t,currentChainId:e})}const G=new rt(128);async function Tt(t,e){var T,d,p,q,L;const{account:a=t.account,assertChainId:s=!0,chain:r=t.chain,accessList:n,authorizationList:o,blobs:c,data:l,dataSuffix:f=typeof t.dataSuffix=="string"?t.dataSuffix:(T=t.dataSuffix)==null?void 0:T.value,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:C,nonce:N,type:w,value:g,...S}=e;if(typeof a>"u")throw new D({docsPath:"/docs/actions/wallet/sendTransaction"});const i=a?W(a):null;try{X(e);const A=await(async()=>{if(e.to)return e.to;if(e.to!==null&&o&&o.length>0)return await Z({authorization:o[0]}).catch(()=>{throw new tt("`to` is required. Could not infer from `authorizationList`.")})})();if((i==null?void 0:i.type)==="json-rpc"||i===null){let x;r!==null&&(x=await F(t,et,"getChainId")({}),s&&St({currentChainId:x,chain:r}));const P=(q=(p=(d=t.chain)==null?void 0:d.formatters)==null?void 0:p.transactionRequest)==null?void 0:q.format,k=(P||at)({...nt(S,{format:P}),accessList:n,account:i,authorizationList:o,blobs:c,chainId:x,data:f?U([l??"0x",f]):l,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:C,nonce:N,to:A,type:w,value:g},"sendTransaction"),$=G.get(t.uid),V=$?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:V,params:[k]},{retryCount:0})}catch(H){if($===!1)throw H;const E=H;if(E.name==="InvalidInputRpcError"||E.name==="InvalidParamsRpcError"||E.name==="MethodNotFoundRpcError"||E.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[k]},{retryCount:0}).then(v=>(G.set(t.uid,!0),v)).catch(v=>{const M=v;throw M.name==="MethodNotFoundRpcError"||M.name==="MethodNotSupportedRpcError"?(G.set(t.uid,!1),E):M});throw E}}if((i==null?void 0:i.type)==="local"){const x=await F(t,st,"prepareTransactionRequest")({account:i,accessList:n,authorizationList:o,blobs:c,chain:r,data:f?U([l??"0x",f]):l,gas:u,gasPrice:m,maxFeePerBlobGas:h,maxFeePerGas:y,maxPriorityFeePerGas:C,nonce:N,nonceManager:i.nonceManager,parameters:[...ot,"sidecars"],type:w,value:g,...S,to:A}),P=(L=r==null?void 0:r.serializers)==null?void 0:L.transaction,j=await i.signTransaction(x,{serializer:P});return await F(t,it,"sendRawTransaction")({serializedTransaction:j})}throw(i==null?void 0:i.type)==="smart"?new z({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new z({docsPath:"/docs/actions/wallet/sendTransaction",type:i==null?void 0:i.type})}catch(A){throw A instanceof z?A:ct(A,{...e,account:i,chain:e.chain||void 0})}}async function O(t,e){return O.internal(t,Tt,"sendTransaction",e)}(function(t){async function e(a,s,r,n){const{abi:o,account:c=a.account,address:l,args:f,functionName:u,...m}=n;if(typeof c>"u")throw new D({docsPath:"/docs/contract/writeContract"});const h=c?W(c):null,y=ut({abi:o,args:f,functionName:u});try{return await F(a,s,r)({data:y,to:l,account:h,...m})}catch(C){throw dt(C,{abi:o,address:l,args:f,docsPath:"/docs/contract/writeContract",functionName:u,sender:h==null?void 0:h.address})}}t.internal=e})(O||(O={}));async function Ft(t,e){const{abi:a,chainId:s,connector:r,...n}=e;let o;e.account?o=e.account:o=(await Y(t,{assertChainId:!1,chainId:s,connector:r})).account;const c=t.getClient({chainId:s}),l=I(c,lt,"simulateContract"),{result:f,request:u}=await l({...n,abi:a,account:o});return{chainId:c.chain.id,result:f,request:{...u,chainId:s}}}async function xt(t,e){const{chainId:a,timeout:s=0,...r}=e,n=t.getClient({chainId:a}),c=await I(n,ft,"waitForTransactionReceipt")({...r,timeout:s});if(c.status==="reverted"){const l=I(n,ht,"getTransaction"),{from:f,...u}=await l({hash:c.transactionHash}),h=await I(n,wt,"call")({...u,account:f,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),y=h!=null&&h.data?pt(`0x${h.data.substring(138)}`):"unknown reason";throw new Error(y)}return{...c,chainId:n.chain.id}}async function bt(t,e){const{account:a,chainId:s,connector:r,...n}=e;let o;return typeof a=="object"&&(a==null?void 0:a.type)==="local"?o=t.getClient({chainId:s}):o=await Y(t,{account:a??void 0,assertChainId:!1,chainId:s,connector:r}),await I(o,O,"writeContract")({...n,...a?{account:a}:{},chain:s?{id:s}:null})}function It(t){return{mutationFn(e){return bt(t,e)},mutationKey:["writeContract"]}}function Ot(t={}){const{mutation:e}=t,a=K(t),s=It(a),{mutate:r,mutateAsync:n,...o}=Ct({...e,...s});return{...o,writeContract:r,writeContractAsync:n}}const _t=_(["function getOperator(address buyer) view returns (address)","function getOperatorNonce(address buyer) view returns (uint256)","function setOperator(address buyer, address operator, uint256 nonce, bytes buyerSig)","function transferOperator(address buyer, address newOperator)","function withdraw(address buyer, uint256 amount)","error NotAuthorized()","error InvalidAmount()","error InvalidAddress()","error InsufficientBalance()","error InvalidSignature()","error InvalidNonce()","error OperatorAlreadySet()"]),qt=_(["function claimBuyerReward(address buyer, uint256 epoch)","error NotRewardRecipient()","error RewardRecipientUnavailable()"]),vt=_(["function channels(bytes32 channelId) view returns (address buyer, address seller, uint128 deposit, uint128 settled, bytes32 metadataHash, uint256 deadline, uint256 settledAt, uint256 closeRequestedAt, uint8 status)","function requestClose(bytes32 channelId)","function withdraw(bytes32 channelId)","error ChannelNotActive()","error NotAuthorized()","error CloseAlreadyRequested()","error CloseNotReady()"]),Mt=_(["function claimBuyerEmissions(address buyer, uint256[] epochs)","error NotAuthorized()","error EpochNotFinalized()"]);function zt({chain:t,runner:e,done:a="Confirmed on chain."}){const s=e.lastHash?At(t,e.lastHash):null,r=s&&R.jsx("a",{className:"gc-link",href:s,target:"_blank",rel:"noopener noreferrer",children:"View transaction"});return R.jsxs(R.Fragment,{children:[e.status&&R.jsxs(B,{tone:"info",children:[e.status," ",e.running&&e.lastHash&&r]}),e.error&&R.jsxs(B,{tone:"danger",children:[e.error," ",!e.running&&r]}),!e.running&&!e.error&&e.confirmed&&R.jsxs(B,{tone:"success",children:[a," ",r]})]})}function Bt(t){const e=K(),{chainId:a}=mt(),{switchChainAsync:s}=yt(),[r,n]=b.useState(null),[o,c]=b.useState(null),[l,f]=b.useState(null),[u,m]=b.useState(null),[h,y]=b.useState(!1);async function C(N,w={}){var S,i,T;let g=null;y(!0),c(null),m(null),f(null);try{a!==t&&(n("Switch network in your wallet…"),await s({chainId:t}));for(const d of N){d.check&&(n(`${d.label}: checking…`),await d.check()),n(`${d.label}: confirm in your wallet…`);const p=await d.send();if(g=p,f(p),n(`${d.label}: waiting for confirmation…`),(await xt(e,{hash:p,chainId:t})).status!=="success")throw new Error(`${d.label} reverted on chain.`)}return n(null),m(g),g}catch(d){n(null);const p=Et(d);return p?(c(p.message),p.refresh&&((S=w.onStale)==null||S.call(w))):d instanceof Rt?(c(d.message),d.refresh&&((i=w.onStale)==null||i.call(w))):(c(gt(d)),g&&((T=w.onStale)==null||T.call(w))),null}finally{y(!1)}}return{run:C,running:h,status:r,setStatus:n,error:o,lastHash:l,confirmed:u,wrongChain:a!==void 0&&a!==t,setError:c}}export{vt as C,_t as D,Mt as L,zt as T,qt as U,Ot as a,Ft as s,Bt as u};
@@ -1,8 +1,8 @@
1
- import{w as l}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const m=l`<svg fill="none" viewBox="0 0 28 28">
1
+ import{w as l}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const p=l`<svg fill="none" viewBox="0 0 28 28">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
5
5
  d="M18.1 4.76c-.42-.73-1.33-1.01-2.09-.66l-1.42.66c-.37.18-.8.18-1.18 0l-1.4-.65a1.63 1.63 0 0 0-2.1.66l-.84 1.45c-.2.34-.53.59-.92.67l-1.7.35c-.83.17-1.39.94-1.3 1.78l.19 1.56c.04.39-.08.78-.33 1.07l-1.12 1.3c-.52.6-.52 1.5 0 2.11L5 16.38c.25.3.37.68.33 1.06l-.18 1.57c-.1.83.46 1.6 1.28 1.78l1.7.35c.4.08.73.32.93.66l.84 1.43a1.63 1.63 0 0 0 2.09.66l1.41-.66c.37-.17.8-.17 1.18 0l1.43.67c.76.35 1.66.07 2.08-.65l.86-1.45c.2-.34.54-.58.92-.66l1.68-.35A1.63 1.63 0 0 0 22.84 19l-.18-1.57a1.4 1.4 0 0 1 .33-1.06l1.12-1.32c.52-.6.52-1.5 0-2.11l-1.12-1.3a1.4 1.4 0 0 1-.33-1.07l.18-1.57c.1-.83-.46-1.6-1.28-1.77l-1.68-.35a1.4 1.4 0 0 1-.92-.66l-.86-1.47Zm-3.27-3.2a4.43 4.43 0 0 1 5.69 1.78l.54.93 1.07.22a4.43 4.43 0 0 1 3.5 4.84l-.11.96.7.83a4.43 4.43 0 0 1 .02 5.76l-.72.85.1.96a4.43 4.43 0 0 1-3.5 4.84l-1.06.22-.54.92a4.43 4.43 0 0 1-5.68 1.77l-.84-.4-.82.39a4.43 4.43 0 0 1-5.7-1.79l-.51-.89-1.09-.22a4.43 4.43 0 0 1-3.5-4.84l.1-.96-.72-.85a4.43 4.43 0 0 1 .01-5.76l.71-.83-.1-.95a4.43 4.43 0 0 1 3.5-4.84l1.08-.23.53-.9a4.43 4.43 0 0 1 5.7-1.8l.81.38.83-.39ZM18.2 9.4c.65.42.84 1.28.42 1.93l-4.4 6.87a1.4 1.4 0 0 1-2.26.14L9.5 15.39a1.4 1.4 0 0 1 2.15-1.8l1.23 1.48 3.38-5.26a1.4 1.4 0 0 1 1.93-.42Z"
6
6
  clip-rule="evenodd"
7
7
  />
8
- </svg>`;export{m as verifySvg};
8
+ </svg>`;export{p as verifySvg};
@@ -1,8 +1,8 @@
1
- import{w as l}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const a=l`<svg fill="none" viewBox="0 0 14 14">
1
+ import{w as l}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const c=l`<svg fill="none" viewBox="0 0 14 14">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
5
5
  d="m4.1 12.43-.45-.78-.93-.2a1.65 1.65 0 0 1-1.31-1.8l.1-.86-.61-.71a1.65 1.65 0 0 1 0-2.16l.6-.7-.09-.85c-.1-.86.47-1.64 1.3-1.81l.94-.2.45-.78A1.65 1.65 0 0 1 6.23.9l.77.36.78-.36c.77-.36 1.69-.07 2.12.66l.47.8.91.2c.84.17 1.4.95 1.31 1.8l-.1.86.6.7c.54.62.54 1.54.01 2.16l-.6.71.09.86c.1.85-.47 1.63-1.3 1.8l-.92.2-.47.79a1.65 1.65 0 0 1-2.12.66L7 12.74l-.77.36c-.78.35-1.7.07-2.13-.67Zm5.74-6.9a1 1 0 1 0-1.68-1.07L6.32 7.3l-.55-.66a1 1 0 0 0-1.54 1.28l1.43 1.71a1 1 0 0 0 1.61-.1l2.57-4Z"
6
6
  clip-rule="evenodd"
7
7
  />
8
- </svg>`;export{a as verifyFilledSvg};
8
+ </svg>`;export{c as verifyFilledSvg};
@@ -1,4 +1,4 @@
1
- import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-Cw7VIz-a.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-CO2ldxDL.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
1
+ import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-z96MxYDt.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-FSpcDkTF.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
2
2
  :host {
3
3
  display: block;
4
4
  border-radius: clamp(0px, var(--wui-border-radius-l), 44px);
@@ -1,8 +1,8 @@
1
- import{w as o}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const p=o`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as o}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const m=o`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
5
5
  d="M0 5.5c0-1.8 1.46-3.25 3.25-3.25H14.5c1.8 0 3.25 1.46 3.25 3.25v.28A3.25 3.25 0 0 1 20 8.88v2.24c0 1.45-.94 2.68-2.25 3.1v.28c0 1.8-1.46 3.25-3.25 3.25H3.25A3.25 3.25 0 0 1 0 14.5v-9Zm15.75 8.88h-2.38a4.38 4.38 0 0 1 0-8.76h2.38V5.5c0-.69-.56-1.25-1.25-1.25H3.25C2.56 4.25 2 4.81 2 5.5v9c0 .69.56 1.25 1.25 1.25H14.5c.69 0 1.25-.56 1.25-1.25v-.13Zm-2.38-6.76a2.37 2.37 0 1 0 0 4.75h3.38c.69 0 1.25-.55 1.25-1.24V8.87c0-.69-.56-1.24-1.25-1.24h-3.38Z"
6
6
  clip-rule="evenodd"
7
7
  />
8
- </svg>`;export{p as walletSvg};
8
+ </svg>`;export{m as walletSvg};
@@ -1,4 +1,4 @@
1
- import{w as a}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const p=a`
1
+ import{w as a}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const c=a`
2
2
  <svg fill="none" viewBox="0 0 48 44">
3
3
  <path
4
4
  style="fill: var(--wui-color-bg-300);"
@@ -11,4 +11,4 @@ import{w as a}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./inde
11
11
  clip-rule="evenodd"
12
12
  />
13
13
  </svg>
14
- `;export{p as walletPlaceholderSvg};
14
+ `;export{c as walletPlaceholderSvg};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const p=l`<svg fill="none" viewBox="0 0 96 67">
1
+ import{w as l}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const r=l`<svg fill="none" viewBox="0 0 96 67">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M25.32 18.8a32.56 32.56 0 0 1 45.36 0l1.5 1.47c.63.62.63 1.61 0 2.22l-5.15 5.05c-.31.3-.82.3-1.14 0l-2.07-2.03a22.71 22.71 0 0 0-31.64 0l-2.22 2.18c-.31.3-.82.3-1.14 0l-5.15-5.05a1.55 1.55 0 0 1 0-2.22l1.65-1.62Zm56.02 10.44 4.59 4.5c.63.6.63 1.6 0 2.21l-20.7 20.26c-.62.61-1.63.61-2.26 0L48.28 41.83a.4.4 0 0 0-.56 0L33.03 56.21c-.63.61-1.64.61-2.27 0L10.07 35.95a1.55 1.55 0 0 1 0-2.22l4.59-4.5a1.63 1.63 0 0 1 2.27 0L31.6 43.63a.4.4 0 0 0 .57 0l14.69-14.38a1.63 1.63 0 0 1 2.26 0l14.69 14.38a.4.4 0 0 0 .57 0l14.68-14.38a1.63 1.63 0 0 1 2.27 0Z"
@@ -20,11 +20,11 @@ import{w as l}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./inde
20
20
  </clipPath>
21
21
  </defs>
22
22
  </svg>
23
- `,n=l`
23
+ `,p=l`
24
24
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
25
25
  <circle cx="11" cy="11" r="11" transform="matrix(-1 0 0 1 23 1)" fill="#202020"/>
26
26
  <circle cx="11" cy="11" r="11.5" transform="matrix(-1 0 0 1 23 1)" stroke="#C7B994" stroke-opacity="0.7"/>
27
27
  <path d="M15.4523 11.0686L16.7472 9.78167C13.8205 6.87297 10.1838 6.87297 7.25708 9.78167L8.55201 11.0686C10.7779 8.85645 13.2279 8.85645 15.4538 11.0686H15.4523Z" fill="#C7B994"/>
28
28
  <path d="M15.0199 14.067L12 11.0656L8.98 14.067L5.96004 11.0656L4.66663 12.3511L8.98 16.6393L12 13.638L15.0199 16.6393L19.3333 12.3511L18.0399 11.0656L15.0199 14.067Z" fill="#C7B994"/>
29
29
  </svg>
30
- `;export{n as walletConnectBrownSvg,e as walletConnectLightBrownSvg,p as walletConnectSvg};
30
+ `;export{p as walletConnectBrownSvg,e as walletConnectLightBrownSvg,r as walletConnectSvg};
@@ -0,0 +1,12 @@
1
+ import{w as r}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const n=r`<svg fill="none" viewBox="0 0 20 20">
2
+ <path
3
+ fill="currentColor"
4
+ d="M11 6.67a1 1 0 1 0-2 0v2.66a1 1 0 0 0 2 0V6.67ZM10 14.5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
5
+ />
6
+ <path
7
+ fill="currentColor"
8
+ fill-rule="evenodd"
9
+ d="M10 1a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm-7 9a7 7 0 1 1 14 0 7 7 0 0 1-14 0Z"
10
+ clip-rule="evenodd"
11
+ />
12
+ </svg>`;export{n as warningCircleSvg};
@@ -1,4 +1,4 @@
1
- import{w as i}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./index.es-Dajqanx_.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const a=i`<svg fill="none" viewBox="0 0 41 40">
1
+ import{w as l}from"./core-z96MxYDt.js";import"./index-BG30WuBG.js";import"./index.es-CA2ape1X.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CAcvlKBB.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const r=l`<svg fill="none" viewBox="0 0 41 40">
2
2
  <g clip-path="url(#a)">
3
3
  <path fill="#000" d="M.8 0h40v40H.8z" />
4
4
  <path
@@ -9,4 +9,4 @@ import{w as i}from"./core-Cw7VIz-a.js";import"./index-DqdaAEyo.js";import"./inde
9
9
  <defs>
10
10
  <clipPath id="a"><path fill="#fff" d="M.8 20a20 20 0 1 1 40 0 20 20 0 0 1-40 0Z" /></clipPath>
11
11
  </defs>
12
- </svg>`;export{a as xSvg};
12
+ </svg>`;export{r as xSvg};
package/dist/index.html CHANGED
@@ -7,8 +7,8 @@
7
7
  <meta name="referrer" content="no-referrer" />
8
8
  <title>Antseed Console</title>
9
9
  <link rel="icon" type="image/svg+xml" href="/console/assets/antseed-mark-3TDLhfuw.svg" />
10
- <script type="module" crossorigin src="/console/assets/index-DqdaAEyo.js"></script>
11
- <link rel="stylesheet" crossorigin href="/console/assets/index-M34IaZVB.css">
10
+ <script type="module" crossorigin src="/console/assets/index-BG30WuBG.js"></script>
11
+ <link rel="stylesheet" crossorigin href="/console/assets/index-D8vXwUTI.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antseed/gateway-console",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Antseed gateway console: the web app the gateway serves at /console",
5
5
  "type": "module",
6
6
  "files": [
@@ -46,8 +46,8 @@
46
46
  "vite": "^6.0.0",
47
47
  "vitest": "^2.1.9",
48
48
  "wagmi": "^2.14.0",
49
- "@antseed/wallet-config": "0.0.0",
50
- "@antseed/ui": "0.0.0"
49
+ "@antseed/ui": "0.0.0",
50
+ "@antseed/wallet-config": "0.0.0"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "vite build",
@@ -1 +0,0 @@
1
- import{u as O,a as P,r,i as Q,b as W,c as $,d as T,j as s,P as L,B as C,I,e as h,S as p,f as R,g as b,h as l,k as B,Q as H,l as J,E as X,m as Y,q as M}from"./index-DqdaAEyo.js";import{U as Z,M as _,c as ee}from"./UsageByModel-BBqXiIqo.js";import{r as se,R as ae,g as k}from"./usage-CjxizGfE.js";import{S as V}from"./Segmented-Qx6JB6EU.js";import{S as v}from"./SelectField-D8fxDUNO.js";import{D as te}from"./DataTable-CDFSD9Kq.js";import"./Charts-DAh9h4sf.js";import"./roving-DkptacxO.js";import"./index-D5ERwHFX.js";const E=[{value:"model",label:"Model"},{value:"key",label:"Key"},{value:"peer",label:"Seller"},{value:"user",label:"End user"},{value:"member",label:"Member",admin:!0},{value:"workspace",label:"Workspace",org:!0},{value:"day",label:"Day"}];function pe(){var q;const{viewer:x,workspace:j}=O(),o=P(),[n,F]=r.useState("30d"),[i,N]=r.useState("model"),[d,z]=r.useState("spend"),[c,f]=r.useState(""),[m,S]=r.useState(""),g=Q(x),y=r.useMemo(()=>Date.now(),[n]),A=se(n,y),u={...o,key:c||void 0,member:m||o.member,from:A,to:y},U=W({workspace:j.id,member:o.member}),K=$(j.id,g),D=T({queryKey:M.usage({...u,groupBy:"day"}),queryFn:()=>h.usage.report({...u,groupBy:"day"})}),G=T({queryKey:M.usage({...u,groupBy:i}),queryFn:()=>h.usage.report({...u,groupBy:i})}),t=(q=D.data)==null?void 0:q.totals;return s.jsxs("div",{className:"gc-page",children:[s.jsx(L,{title:"Activity",description:"Spend and token usage over time.",actions:s.jsx(C,{variant:"outline",size:"sm",href:h.usage.exportUrl({...u,groupBy:i}),download:!0,leadingIcon:s.jsx(I.download,{size:14}),children:"Export CSV"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(V,{label:"Time range",value:n,onChange:F,options:ae.map(a=>({value:a.id,label:a.label}))}),s.jsx(v,{size:"sm","aria-label":"Filter by key",value:c,onChange:f,options:[{value:"",label:"All keys"},...(U.data??[]).map(a=>({value:a.id,label:a.label}))]}),g&&s.jsx(v,{size:"sm","aria-label":"Filter by member",value:m,onChange:S,options:[{value:"",label:"All members"},...(K.data??[]).map(({member:a})=>({value:a.id,label:a.label}))]}),(c||m)&&s.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{f(""),S("")},children:"Clear filters"})]}),s.jsxs("div",{className:"gc-grid gc-grid--4",children:[s.jsx(p,{label:"Spend",value:t?R(t.spent):"…"}),s.jsx(p,{label:"Requests",value:t?b(t.requests):"…",sub:t?`${b(t.failedRequests)} failed`:void 0}),s.jsx(p,{label:"Input tokens",value:t?l(t.inputTokens):"…",sub:t?`${l(t.cachedInputTokens)} cached`:void 0}),s.jsx(p,{label:"Output tokens",value:t?l(t.outputTokens):"…"})]}),s.jsx(B,{title:d==="tokens"?"Tokens by type":"Usage by model",description:ee(d,n),actions:s.jsx(V,{label:"Chart metric",value:d,onChange:z,options:_}),children:s.jsx(Z,{filter:{...o,key:c||void 0,member:m||o.member},range:n,now:y,metric:d})}),s.jsx(B,{title:"Breakdown",flush:!0,actions:s.jsx(v,{size:"sm","aria-label":"Group by",value:i,onChange:a=>N(a),options:E.filter(a=>(!a.admin||g)&&(!a.org||Y(x))).map(a=>({value:a.value,label:`By ${a.label.toLowerCase()}`}))}),children:s.jsx(H,{query:G,children:a=>{var w;return s.jsx(te,{label:"Usage breakdown",rows:a.groups,rowKey:e=>e.group,initialSort:{key:"spent",direction:"desc"},empty:s.jsx(X,{icon:s.jsx(I.activity,{size:18}),title:"No usage in this range",body:"Requests made with this workspace's keys show up here."}),columns:[{key:"label",header:((w=E.find(e=>e.value===i))==null?void 0:w.label)??"Group",render:e=>s.jsx("span",{className:"gc-ellipsis",title:k(e),children:k(e)}),sortValue:e=>k(e)},{key:"requests",header:"Requests",align:"right",render:e=>b(e.requests),sortValue:e=>e.requests},{key:"failed",header:"Failed",align:"right",secondary:!0,render:e=>b(e.failedRequests),sortValue:e=>e.failedRequests},{key:"input",header:"Input",align:"right",secondary:!0,render:e=>l(e.inputTokens),sortValue:e=>e.inputTokens},{key:"cached",header:"Cached",align:"right",secondary:!0,render:e=>l(e.cachedInputTokens),sortValue:e=>e.cachedInputTokens},{key:"output",header:"Output",align:"right",secondary:!0,render:e=>l(e.outputTokens),sortValue:e=>e.outputTokens},{key:"spent",header:"Spend",align:"right",render:e=>R(e.spent),sortValue:e=>J(e.spent)}]})}})})]})}export{pe as default};
@@ -1 +0,0 @@
1
- import{r as o,O as A,R as y,j as e,P as w,B as b,k as P,U as N,V as S,M as d,W as C,X as x,L as E,Y as I,E as g,I as m,n as L,t as T,e as F,q as M}from"./index-DqdaAEyo.js";import{u as z}from"./useInfiniteQuery-Dm7RR6wI.js";import{S as h}from"./SelectField-D8fxDUNO.js";import{D as B}from"./DataTable-CDFSD9Kq.js";import"./index-D5ERwHFX.js";const R=50,W=[{value:"",label:"All actions"},{value:"auth",label:"Sign-ins"},{value:"key",label:"API keys"},{value:"member",label:"Members"},{value:"invite",label:"Invites"},{value:"workspace",label:"Workspaces"},{value:"routing",label:"Gateway routing"},{value:"peer_list",label:"Peer lists"},{value:"preset",label:"Presets"},{value:"wallet",label:"Wallets"},{value:"channel",label:"Channels"},{value:"settings",label:"Settings"},{value:"token",label:"Management tokens"}],u={member:"Member",token:"Token",key:"API key",system:"System",cli:"CLI"};function c(t){return t.actor.label??t.actor.id??u[t.actor.kind]}function $(t){return z({queryKey:M.audit(t),queryFn:({pageParam:i})=>F.audit.list({...t,before:i??void 0,limit:R}),initialPageParam:null,getNextPageParam:i=>i.nextBefore})}function D({query:t,filtered:i,onSelect:l}){var s;if(t.isLoading)return e.jsx(E,{rows:8});if(I(t.error)&&t.error.status===404)return e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:"Audit log not available",body:"This gateway version does not record an audit log yet."});if(t.error)return e.jsx(L,{error:t.error,onRetry:()=>void t.refetch()});const n=((s=t.data)==null?void 0:s.pages.flatMap(a=>a.entries))??[];return e.jsxs(e.Fragment,{children:[e.jsx(B,{label:"Audit log",rows:n,rowKey:a=>a.id,onRowClick:l,rowLabel:a=>`${a.action} by ${c(a)}`,empty:e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:i?"No entries match":"Nothing recorded yet"}),columns:[{key:"at",header:"When",render:a=>e.jsx("span",{className:"gc-nowrap",children:x(a.at)})},{key:"actor",header:"Who",secondary:!0,render:a=>e.jsxs("span",{children:[c(a)," ",e.jsx(T,{children:u[a.actor.kind]})]})},{key:"action",header:"Action",render:a=>e.jsxs(e.Fragment,{children:[e.jsx(d,{children:a.action}),e.jsx("div",{className:"gc-narrow-only gc-muted",children:c(a)})]})},{key:"target",header:"Target",secondary:!0,render:a=>a.target?a.target.label??a.target.id??a.target.kind:"—"},{key:"ip",header:"IP",secondary:!0,optional:!0,render:a=>a.ip?e.jsx(d,{children:a.ip}):"—"}]}),t.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(b,{variant:"outline",size:"sm",disabled:t.isFetchingNextPage,onClick:()=>void t.fetchNextPage(),children:t.isFetchingNextPage?"Loading…":"Load older entries"})})]})}function J(){const[t,i]=o.useState(""),[l,n]=o.useState(""),[s,a]=o.useState(null),j=A(),v=y(),p=[{value:"",label:"Anyone"},...(j.data??[]).map(r=>({value:r.id,label:r.label})),...(v.data??[]).map(r=>({value:r.id,label:`Token: ${r.label}`}))],k=o.useMemo(()=>({actor:t||void 0,action:l||void 0}),[t,l]),f=$(k);return e.jsxs("div",{className:"gc-page",children:[e.jsx(w,{title:"Audit log",description:"Who changed what in this organization: keys, members, workspaces, routing, wallets and settings."}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(h,{size:"sm","aria-label":"Filter by who",value:t,onChange:i,options:p}),e.jsx(h,{size:"sm","aria-label":"Filter by action",value:l,onChange:n,options:W}),(t||l)&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>{i(""),n("")},children:"Clear filters"})]}),e.jsx(P,{flush:!0,children:e.jsx(D,{query:f,filtered:!!(t||l),onSelect:a})}),e.jsx(N,{isOpen:s!==null,onClose:()=>a(null),eyebrow:"Audit entry",title:(s==null?void 0:s.action)??"",subtitle:s?x(s.at):void 0,children:s&&e.jsxs(e.Fragment,{children:[e.jsx(S,{items:[["Who",`${c(s)} (${u[s.actor.kind]})`],["Actor id",s.actor.id?e.jsx(d,{children:s.actor.id},"a"):"—"],["Target",s.target?`${s.target.kind}: ${s.target.label??s.target.id??"—"}`:"—"],["IP address",s.ip??"—"],["Entry id",e.jsx(d,{children:s.id},"i")]]}),Object.keys(s.details).length>0&&e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:"Details"}),e.jsx(C,{code:JSON.stringify(s.details,null,2)})]})]})})]})}export{J as default};
@@ -1 +0,0 @@
1
- import{j as r,n,L as a,r as o}from"./index-DqdaAEyo.js";function i({chain:s,error:t,children:e}){return t?r.jsx(n,{error:t}):s?r.jsx(o.Suspense,{fallback:r.jsx(a,{rows:2}),children:e(s)}):r.jsx(a,{rows:2})}export{i as C};
@@ -1 +0,0 @@
1
- import{j as e,H as T,aj as I,ak as E,ac as W,al as R,am as O,f as C,an as b,v as B,ao as x,B as S,ap as H,aq as w,ar as j}from"./index-DqdaAEyo.js";import{u as _,a as L,T as $,C as m,s as G}from"./useTx-BRRWrJlB.js";import{a as z}from"./ConnectWallet-DSqRjyNA.js";import{O as F}from"./OperatorGateAlert-CCPFpK6Y.js";import{W as P,u as V,c as D,r as M}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";const U=1,J={request:"close channels on chain",withdraw:"withdraw channel reserves"};function K({channel:s,step:r}){const a=`antseed buyer channels ${r==="request"?"request-close":"withdraw"} ${s.channelId}`;return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("p",{className:"gc-muted",children:"This workspace's authorized wallet is the wallet the gateway holds, so a browser wallet cannot sign this. Run on the gateway host (the workspace wallet pays the network fee in ETH):"}),e.jsxs("div",{className:"gc-address",children:[e.jsx("code",{className:"gc-mono",children:a}),e.jsx(H,{value:a,label:"Copy command"})]})]})}function Q({workspaceId:s,channel:r,chain:a,step:t,onDone:f,onAuthorize:v}){var p;const{address:i}=V(),g=D(),d=T(s),{refresh:k}=I(s),n=_(a.chainId),{writeContractAsync:q}=L(),o=E(a,"channels");if(!o)return e.jsx(W,{tone:"warning",children:"The gateway did not report the payment channels contract address."});if(((p=d.data)==null?void 0:p.relation)==="self")return e.jsx(K,{channel:r,step:t});const h=R(d.data,i,J[t]);if(!h.ok)return e.jsx(F,{gate:h,state:d.data,connected:i,onAuthorize:v});const l=r.channelId;async function N(){const[,,,,,,,c,A]=await M(g,{address:o,abi:m,functionName:"channels",args:[l],chainId:a.chainId});if(A!==U)throw new w("This channel is already settled or closed; nothing is left to do. The list now shows it.",!0);if(t==="request"&&c>0n)throw new w("A close was already requested for this channel. The list now shows when the reserve can be withdrawn.",!0);if(t==="withdraw"&&Number(c)*1e3+j>Date.now())throw new w(`The grace period ends in ${x(Number(c)*1e3+j)}. Withdraw then.`,!0);await G(g,{account:i,address:o,abi:m,functionName:t==="request"?"requestClose":"withdraw",args:[l],chainId:a.chainId})}async function y(){await n.run([{label:t==="request"?"Request close":"Withdraw reserve",check:N,send:()=>q({address:o,abi:m,functionName:t==="request"?"requestClose":"withdraw",args:[l],chainId:a.chainId})}],{onStale:()=>{k().catch(()=>{}),f(t)}})&&f(t)}const u=O(r);return e.jsxs("div",{className:"gc-stack",children:[t==="request"?e.jsxs("p",{className:"gc-muted",children:["The seller gets 15 minutes to settle what was spent. After that, withdraw the unused reserve (about ",C(b(r)),") back to the workspace balance. Both steps are signed by the authorized wallet ",B(h.operator),", which pays the network fee in ETH on ",a.name,"."]}):e.jsxs("p",{className:"gc-muted",children:["The grace period ",u&&u>Date.now()?`ends in ${x(u)}`:"has ended",". Withdrawing returns the unused reserve (about ",C(b(r)),") to the workspace balance; nothing leaves the workspace."]}),e.jsx($,{chain:a,runner:n,done:t==="request"?"Close requested. Withdraw the reserve in 15 minutes.":"Reserve returned to the balance."}),e.jsx(S,{fullWidth:!0,disabled:n.running,onClick:()=>void y(),children:n.running?"Working…":t==="request"?"Request on-chain close":"Withdraw unused reserve"})]})}function ne(s){return e.jsx(P,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(z,{}),e.jsx(Q,{...s})]})})}export{ne as default};
@@ -1 +0,0 @@
1
- import{r as h,j as n,B as E}from"./index-DqdaAEyo.js";import{r as D}from"./index-D5ERwHFX.js";function w(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.7"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.7"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.7"})]})}const v=176;function M({label:t,items:i,trigger:b,className:g}){const d=i.filter(Boolean),[o,p]=h.useState(!1),[_,k]=h.useState({}),m=h.useRef(null),l=h.useRef(null),y=h.useId(),x=h.useCallback(e=>{var s;p(!1),e&&((s=m.current)==null||s.focus())},[]);if(h.useLayoutEffect(()=>{var u,c;if(!o||!m.current)return;const e=m.current.getBoundingClientRect(),s=d.length*34+10,f=e.bottom+4+s<=window.innerHeight,r=Math.max(8,Math.min(e.right-v,window.innerWidth-v-8));k(f?{top:e.bottom+4,left:r}:{top:Math.max(8,e.top-4-s),left:r}),(c=(u=l.current)==null?void 0:u.querySelector('[role="menuitem"]:not([disabled])'))==null||c.focus()},[o,d.length]),h.useEffect(()=>{if(!o)return;const e=f=>{var u,c;const r=f.target;(u=l.current)!=null&&u.contains(r)||(c=m.current)!=null&&c.contains(r)||x(!1)},s=()=>x(!1);return document.addEventListener("mousedown",e),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[o,x]),d.length===0)return null;function a(e){var r,u,c,j,N;const s=[...((r=l.current)==null?void 0:r.querySelectorAll('[role="menuitem"]:not([disabled])'))??[]],f=s.indexOf(document.activeElement);e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),x(!0)):e.key==="ArrowDown"?(e.preventDefault(),(u=s[(f+1)%s.length])==null||u.focus()):e.key==="ArrowUp"?(e.preventDefault(),(c=s[(f-1+s.length)%s.length])==null||c.focus()):e.key==="Home"?(e.preventDefault(),(j=s[0])==null||j.focus()):e.key==="End"?(e.preventDefault(),(N=s[s.length-1])==null||N.focus()):e.key==="Tab"&&x(!1)}return n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:m,type:"button",className:["as-icon-button","as-action-menu__trigger",g].filter(Boolean).join(" "),"aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?y:void 0,onClick:e=>{e.stopPropagation(),p(s=>!s)},onKeyDown:e=>{e.key==="ArrowDown"&&!o&&(e.preventDefault(),p(!0))},children:b??n.jsx(w,{})}),o&&typeof document<"u"&&D.createPortal(n.jsx("div",{ref:l,id:y,role:"menu","aria-label":t,className:"as-action-menu",style:{..._,width:v},onKeyDown:a,onClick:e=>e.stopPropagation(),children:d.map((e,s)=>n.jsx("button",{type:"button",role:"menuitem",tabIndex:-1,disabled:e.disabled,className:e.tone==="danger"?"as-action-menu__item as-action-menu__item--danger":"as-action-menu__item",onClick:()=>{x(!0),e.onSelect()},children:e.label},s))}),document.body)]})}function P(t){return[t.align==="right"?"as-num":null,t.secondary?"as-secondary":null,t.optional?"as-optional":null].filter(Boolean).join(" ")||void 0}function C(t,i){if((t==null?void 0:t.key)===i)return t.direction==="asc"?"ascending":"descending"}function S(t,i){return(t==null?void 0:t.key)!==i?"":t.direction==="asc"?"↑":"↓"}function I({rows:t,columns:i,rowKey:b,onRowClick:g,rowLabel:d,actions:o,empty:p,label:_,initialSort:k,selectedKey:m}){const[l,y]=h.useState(k??null),x=h.useMemo(()=>{if(!l)return t;const a=i.find(f=>f.key===l.key);if(!(a!=null&&a.sortValue))return t;const e=a.sortValue,s=l.direction==="asc"?1:-1;return[...t].sort((f,r)=>{const u=e(f),c=e(r);return u===c?0:u===null?1:c===null?-1:(u<c?-1:1)*s})},[t,i,l]);return t.length===0&&p?n.jsx(n.Fragment,{children:p}):n.jsx("div",{className:"as-table-wrap",children:n.jsxs("table",{className:"as-table","aria-label":_,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[i.map(a=>{const e=(l==null?void 0:l.key)===a.key;return n.jsx("th",{className:P(a),style:a.width?{width:a.width}:void 0,"aria-sort":C(l,a.key),children:a.sortValue?n.jsxs("button",{type:"button",className:"as-table__sort",onClick:()=>y({key:a.key,direction:e&&l.direction==="desc"?"asc":"desc"}),children:[a.header,n.jsx("span",{"aria-hidden":"true",className:"as-table__arrow",children:S(l,a.key)})]}):a.header},a.key)}),o&&n.jsx("th",{className:"as-table__actions",children:n.jsx("span",{className:"as-sr",children:"Actions"})})]})}),n.jsx("tbody",{children:x.map(a=>{const e=b(a),s=m!=null&&e===m,f=[g?"as-table__row--click":null,s?"as-table__row--selected":null].filter(Boolean).join(" ");return n.jsxs("tr",{className:f||void 0,"aria-current":s?"true":void 0,onClick:g?()=>g(a):void 0,children:[i.map((r,u)=>n.jsx("td",{className:P(r),children:(()=>{const c=u===0&&g?n.jsx("button",{type:"button",className:"as-table__open","aria-label":d?`Open ${d(a)}`:void 0,onClick:j=>{j.stopPropagation(),g(a)},children:r.render(a)}):r.render(a);return r.after?n.jsxs("div",{className:"as-table__lead",children:[c,r.after(a)]}):c})()},r.key)),o&&n.jsx("td",{className:"as-table__actions",onClick:r=>r.stopPropagation(),children:n.jsx(M,{label:d?`Actions for ${d(a)}`:"Actions",items:o(a)})})]},e)})})]})})}function L(t,i,b=""){const[g,d]=h.useState(0);h.useEffect(()=>{d(0)},[b]);const o=Math.max(1,Math.ceil(t.length/i)),p=Math.min(g,o-1);return{items:t.slice(p*i,(p+1)*i),page:p,pages:o,total:t.length,setPage:d}}function H({pager:t,noun:i}){return t.pages<=1?null:n.jsxs("nav",{className:"as-pager","aria-label":`${i} pages`,children:[n.jsxs("span",{className:"as-pager__status",children:["Page ",t.page+1," of ",t.pages," · ",t.total," ",i]}),n.jsxs("div",{className:"as-pager__buttons",children:[n.jsx(E,{variant:"outline",size:"sm",disabled:t.page===0,onClick:()=>t.setPage(t.page-1),children:"Previous"}),n.jsx(E,{variant:"outline",size:"sm",disabled:t.page>=t.pages-1,onClick:()=>t.setPage(t.page+1),children:"Next"})]})]})}export{I as D,H as P,L as u};
@@ -1 +0,0 @@
1
- import{r as s,a as D,b as E,j as e,P as I,B as y,I as U,e as q,T as p,k as M}from"./index-DqdaAEyo.js";import{R as B}from"./RequestLog-DhID_VN7.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-D8fxDUNO.js";import"./useInfiniteQuery-Dm7RR6wI.js";import"./usage-CjxizGfE.js";import"./DataTable-CDFSD9Kq.js";import"./index-D5ERwHFX.js";function k(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,b]=s.useState(""),[v,h]=s.useState(""),[c,g]=s.useState(""),[d,x]=s.useState(""),F=E(a),f=k(r.trim()),S=k(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=>h(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"},...(F.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:b,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(""),b(""),h(""),g(""),x("")},children:"Clear filters"})]}),e.jsx(M,{flush:!0,children:e.jsx(B,{filter:j})})]})}export{V as default};
@@ -1 +0,0 @@
1
- import{u as W,m as U,r as d,c as ce,O as G,s as N,j as e,P as de,B as f,I as q,k as H,Q,aN as _,y as me,z as ue,E as ae,A as B,C as T,e as w,F as ge,q as P,ag as be,t as F,a9 as se,aO as ne,aP as he,a8 as J,T as I,ac as X,n as ie,aF as pe,ap as ve}from"./index-DqdaAEyo.js";import{u as xe,a as je,P as ye}from"./PolicyField-DIPl0B1x.js";import{l as ke,d as fe,L as we}from"./limits-DETkh9Vy.js";import{D as Y}from"./DataTable-CDFSD9Kq.js";import{S as O}from"./SelectField-D8fxDUNO.js";import"./PolicyEditor-BdoaX9gK.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Switch-Ba56zux7.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.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 D=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...D,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function V(s){return s.status==="disabled"?e.jsx(F,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(F,{tone:"warning",children:"Invited"}):e.jsx(F,{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=U(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),M=ne(),x=Ce({label:c,email:g},S.data??[],M.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,L])=>({workspaceId:k,role:L})),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(O,{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(O,{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(O,{"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=U(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),[M,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:D,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:D}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:D}),L=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=L&&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(O,{label:"Organization role",value:g,disabled:L||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(F,{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:[$&&!L?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:M,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(O,{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:[" ",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=U(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"}),M=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!M.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(O,{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 +0,0 @@
1
- import{aS as A,r as m,j as e,aT as F,W as B,aU as V,N as w,aV as $,aW as U,aX as R,aY as _,L as z,E as f,I as M,P as O,T as D,x as k,k as K,Q as Y,aZ as q,M as b,g as Q,a_ as v,a$ as S,b0 as I,b1 as W,ap as N,t as u,V as G,B as H,ab as X,v as L,h as Z}from"./index-DqdaAEyo.js";import{T as J,a as ee}from"./Tabs-BmjCmD5T.js";import{m as se,f as ae,M as P,S as te,a as ne,C as ie,P as C,b as le,V as re,p as oe}from"./models-Ben8ko6c.js";import{S as T}from"./SelectField-D8fxDUNO.js";import{S as ce}from"./Switch-Ba56zux7.js";import{D as de}from"./DataTable-CDFSD9Kq.js";import"./roving-DkptacxO.js";import"./index-D5ERwHFX.js";function ue({model:s,format:i,id:o="gc-api-call",unsupported:l}){const p=A(),[g,r]=m.useState("curl");if(!i)return e.jsx("p",{className:"gc-fineprint",children:l??"The gateway does not serve this model through its API."});const t=F(p,s,i),d=t.find(c=>c.id===g)??t[0];return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(J,{id:o,label:"Request examples",value:d.id,onChange:r,className:"gc-connect-tabs",tabs:t.map(c=>({id:c.id,label:c.label}))}),e.jsx(ee,{tabsId:o,tab:d.id,children:e.jsx(B,{code:d.code,label:d.label})}),e.jsxs("p",{className:"gc-fineprint",children:["Set ",e.jsx("code",{children:V})," to one of your API keys first. ",e.jsx(w,{to:"keys",children:"API keys"})]})]})}function he(s){return s===null?"—":String(Math.round(s))}function E(s){return s===null?"—":Z(s)}function pe({model:s}){return e.jsxs("div",{className:"gc-badges",children:[s.free&&e.jsx(u,{tone:"success",children:"Free"}),s.teeSellers>0&&e.jsx(u,{tone:"info",children:"TEE"})]})}function y(s){return s.displayName??L(s.peerId,8,4)}function Me(){const s=$(),i=U(s.rest),o=R(),[l,p]=m.useState({search:"",type:"",free:!1}),g=m.useMemo(()=>se(o.data),[o.data]),r=m.useMemo(()=>i?ae(o.data,i):null,[o.data,i]),t=_(),d=(n,a)=>p(h=>({...h,[n]:a})),c=i===null?null:{eyebrow:"Model",title:(r==null?void 0:r.name)??i,body:o.isLoading?e.jsx(z,{rows:6}):r?e.jsx(ge,{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 ${i} right now.`})},j=e.jsx(K,{flush:!0,children:e.jsx(Y,{query:o,rows:8,children:n=>e.jsx(de,{label:"Models",rows:ne(n,l),rowKey:a=>a.id,selectedKey:(r==null?void 0:r.id)??null,onRowClick:a=>k(S("models",a.id)),rowLabel:a=>a.name,actions:a=>[{label:"Copy model id",onSelect:()=>void t(a.id)}],initialSort:{key:"sellers",direction:"desc"},empty:e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:n.length?"No models match these filters":"No models found yet",body:n.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"model",header:"Model",sortValue:a=>a.name.toLowerCase(),render:a=>e.jsxs("div",{className:"gc-cell-lines",children:[e.jsx("div",{className:"gc-strong gc-ellipsis",title:a.id,children:a.name}),a.name!==a.id&&e.jsx("div",{className:"gc-muted gc-ellipsis",children:e.jsx(b,{children:a.id})}),e.jsx(pe,{model:a})]}),after:a=>e.jsx(q,{value:a.id,label:`Copy model id ${a.id}`})},{key:"type",header:"Type",secondary:!0,sortValue:a=>a.type,render:a=>e.jsx("span",{className:"gc-muted",children:P[a.type]})},{key:"sellers",header:"Providers",align:"right",sortValue:a=>a.sellers,render:a=>Q(a.sellers)},{key:"input",header:"Input $/M",align:"right",sortValue:a=>{var h;return((h=a.inputUsdPerMillion)==null?void 0:h.min)??null},render:a=>v(a.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:a=>{var h;return((h=a.outputUsdPerMillion)==null?void 0:h.min)??null},render:a=>v(a.outputUsdPerMillion)},{key:"context",header:"Context",align:"right",secondary:!0,optional:!0,sortValue:a=>a.contextLength,render:a=>E(a.contextLength)}]})})});return e.jsxs("div",{className:"gc-page",children:[e.jsx(O,{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(D,{size:"sm",type:"search","aria-label":"Search models",placeholder:"Search model or alias",value:l.search,onChange:n=>d("search",n.target.value)}),g.length>1&&e.jsx(T,{size:"sm","aria-label":"Filter by type",value:l.type,onChange:n=>d("type",n),options:[{value:"",label:"All types"},...g.map(n=>({value:n,label:P[n]}))]}),e.jsx(ce,{checked:l.free,onChange:n=>d("free",n),label:"Free"})]}),e.jsx(te,{list:j,panel:c,onClose:()=>k("models"),closeLabel:"Close model"})]})}function x(s){return`${s.peerId}:${s.serviceId}`}function ge({model:s}){const[i,o]=m.useState(""),l=s.offers.find(t=>x(t)===i)??null,p=l?I(l.peerId,l.serviceId):s.id,g=W(s.type,l),r=s.offers.some(t=>t.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(u,{children:P[s.type]}),s.free&&e.jsx(u,{tone:"success",children:"Free"}),s.teeSellers>0&&e.jsx(u,{tone:"info",children:"TEE"})]}),e.jsx(G,{items:[["Context",E(s.contextLength)],["Capabilities",s.capabilities.length?e.jsx("span",{className:"gc-badges",children:s.capabilities.map(t=>e.jsx(u,{children:ie[t]},t))}):"—"],["Aliases",s.aliases.length?e.jsx(b,{children:s.aliases.join(", ")}):"—"],...r?[]:[["Input $/M",v(s.inputUsdPerMillion)],["Output $/M",v(s.outputUsdPerMillion)]]]})]}),e.jsx(C,{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(t=>{var j;const d=I(t.peerId,t.serviceId),c=i===x(t);return e.jsx(le,{selected:c,title:e.jsx(w,{to:S("providers",t.peerId),children:y(t)}),meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:oe(t)}),e.jsxs("span",{children:["Trust ",he(t.trustScore)]}),t.latencyMsP50!==null&&e.jsx("span",{children:X(t.latencyMsP50)}),t.serviceId!==s.id&&e.jsx(b,{children:t.serviceId})]}),badges:(((j=t.verificationLinks)==null?void 0:j.length)||t.tee||t.free)&&e.jsxs("div",{className:"gc-badges",children:[e.jsx(re,{links:t.verificationLinks}),t.tee&&e.jsx(u,{tone:"info",children:"TEE"}),t.free&&e.jsx(u,{tone:"success",children:"Free"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{iconOnly:!0,value:d,label:`Copy ${y(t)}'s model id (peer@model)`}),e.jsx(H,{size:"sm",variant:c?"outline":"ghost","aria-pressed":c,title:"Use this provider in the API call below",onClick:()=>o(c?"":x(t)),children:c?"Pinned":"Pin"})]})},x(t))})})}),e.jsxs(C,{title:"API call",actions:s.offers.length>0&&e.jsx(T,{size:"sm","aria-label":"Route the call",value:i,onChange:o,options:[{value:"",label:"Best provider (automatic)"},...s.offers.map(t=>({value:x(t),label:y(t)}))]}),children:[e.jsx("p",{className:"gc-fineprint",children:l?e.jsxs(e.Fragment,{children:["Pinned to ",y(l)," 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(ue,{id:"gc-model-call",model:p,format:g,unsupported:`${P[s.type]} models are not served through the gateway's /v1 API.`})]})]})}export{Me as default};
@@ -1 +0,0 @@
1
- import{j as e,u as te,D as ae,r as C,ak as q,ac as I,as as ne,at as re,v as w,X as se,au as y,B as N,av as ie,T as oe,C as le,aq as M,aw as p,ax as ce,ah as de,ay as he,q as ue,az as we,aA as fe,ag as F,aB as H,aC as R,Y as $}from"./index-DqdaAEyo.js";import{u as K,a as V,T as X,D as k,s as Z}from"./useTx-BRRWrJlB.js";import{a as ge,C as G}from"./ConnectWallet-DSqRjyNA.js";import{W as me,u as J,c as L,b as ye,r as Q}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";async function U(s,i,a){let c=await R.sync(s,i);for(let d=0;d<3&&!y(c.operator??p,a??p);d+=1)await new Promise(n=>setTimeout(n,3500)),c=await R.sync(s,i);return c}function ee(s){const i=L(),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([Q(i,{address:a,abi:k,functionName:"getOperator",args:[c],chainId:s.chainId}),Q(i,{address:a,abi:k,functionName:"getOperatorNonce",args:[c],chainId:s.chainId})]);return{operator:y(d,p)?null:d,nonce:n}}}function pe({workspaceId:s,state:i,chain:a,onChanged:c,onStale:d}){const{address:n}=J(),W=L(),o=K(a.chainId),{writeContractAsync:B}=V(),{signMessageAsync:D}=ye(),{me:z}=te(),E=ae(),v=ee(a),[x,h]=C.useState(!1),[f,b]=C.useState(!1),[g,u]=C.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(G,{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 $(t,"reauth_required")?(h("any"),o.setError(null),null):$(t,"reauth_other_credential")?(h("other"),o.setError(null),null):($(t,"operator_already_set")&&d(),o.setError(F(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},Y=await o.run([{label:"Authorize wallet",check:async()=>{try{H(t,await v(t.buyer),O)}catch(P){if(!(P instanceof M)||!P.retryAuth)throw P;o.setStatus("The operator nonce changed; getting a fresh authorization…");const _=await R.authorize(s,r);H(_,await v(_.buyer),O),t=_}await Z(W,{account:n,address:m,abi:k,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})},send:()=>B({address:m,abi:k,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})}],{onStale:d});Y&&c(await U(s,Y,r))}async function l(r){b(!0),o.setError(null);try{const t=r==="passkey"?await ce():await de(n,O=>D({message:O}));if(he(t,z.member.id),E.setQueryData(ue.me,t),h(!1),g&&n&&!y(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:F(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)}`,y(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(X,{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}=J(),W=L(),o=K(a.chainId),{writeContractAsync:B}=V(),D=ee(a),[z,E]=C.useState(""),[v,x]=C.useState(!1),[h,f]=C.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(G,{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)&&!y(u,p),j=i.eligibleWallets.some(l=>y(l.address,u)),A=y(u,i.buyer);async function S(l){f(null);const T=await o.run([{label:l===p?"Remove authorized wallet":"Transfer authorization",check:async()=>{const r=await D(i.buyer);if(!y(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 Z(W,{account:n,address:b,abi:k,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})},send:()=>B({address:b,abi:k,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})}],{onStale:d});T&&(E(""),x(!1),c(await U(s,T,l===p?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(X,{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"?p:u)})]})}function Te(s){return e.jsx(me,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(ge,{}),s.mode==="authorize"?e.jsx(pe,{...s}):e.jsx(xe,{...s})]})})}export{Te as default};
@@ -1 +0,0 @@
1
- import{bh as ee,v as K,r as f,j as e,bi as P,I,bj as A,B as N,b3 as se,bk as le,b7 as ie,bc as H,u as ne,bl as ae,bm as te,bn as ce,bo as re,bp as E,bq as oe,br as D,T as U,C as de,bs as B,bg as me,bt as he,ac as ue,bu as pe,bv as xe,bw as ge,b5 as je}from"./index-DqdaAEyo.js";import{S as L}from"./SelectField-D8fxDUNO.js";import{S as V}from"./Segmented-Qx6JB6EU.js";import{S as R}from"./Switch-Ba56zux7.js";import{D as z}from"./Disclosure-UjXa2WU7.js";function k(l,r){const a=l==null?void 0:l.find(o=>ee(o.peerId,r));return(a==null?void 0:a.displayName)??K(r,8,4)}function $({value:l,onChange:r,peers:a,label:o,ordered:m,placeholder:t="Search sellers or paste a peer id"}){const[h,g]=f.useState(""),b=f.useId(),d=f.useId();function c(){const i=h.trim();if(!i)return;const p=a==null?void 0:a.find(x=>{var n;return((n=x.displayName)==null?void 0:n.toLowerCase())===i.toLowerCase()||x.peerId.toLowerCase()===i.toLowerCase()}),y=(p==null?void 0:p.peerId)??i;l.some(x=>x.toLowerCase()===y.toLowerCase())||r([...l,y]),g("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:d,children:o}),l.length>0&&e.jsx("ol",{className:m?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((i,p)=>e.jsxs("li",{className:"gc-chip",children:[m&&e.jsx("span",{className:"gc-chip__index",children:p+1}),e.jsx("span",{className:"gc-chip__label",title:i,children:k(a,i)}),m&&e.jsxs(e.Fragment,{children:[e.jsx(P,{label:`Move ${k(a,i)} up`,size:"sm",disabled:p===0,onClick:()=>r(A(l,p,-1)),children:e.jsx(I.up,{size:12})}),e.jsx(P,{label:`Move ${k(a,i)} down`,size:"sm",disabled:p===l.length-1,onClick:()=>r(A(l,p,1)),children:e.jsx(I.down,{size:12})})]}),e.jsx(P,{label:`Remove ${k(a,i)}`,size:"sm",onClick:()=>r(l.filter(y=>y!==i)),children:e.jsx(I.x,{size:12})})]},i))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:d,className:"as-field__input gc-picker__input",list:b,value:h,placeholder:t,onChange:i=>g(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),c())}}),e.jsx("datalist",{id:b,children:a==null?void 0:a.map(i=>e.jsx("option",{value:i.peerId,children:i.displayName??K(i.peerId)},i.peerId))}),e.jsx(N,{variant:"outline",size:"sm",onClick:c,disabled:!h.trim(),children:"Add"})]})]})}function fe({value:l,onChange:r,label:a,suggestions:o,placeholder:m}){const[t,h]=f.useState(""),g=f.useId(),b=f.useId();function d(){const c=t.trim();c&&!l.includes(c)&&r([...l,c]),h("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:b,children:a}),l.length>0&&e.jsx("ul",{className:"gc-chips",children:l.map(c=>e.jsxs("li",{className:"gc-chip",children:[e.jsx("span",{className:"gc-chip__label",children:c}),e.jsx(P,{label:`Remove ${c}`,size:"sm",onClick:()=>r(l.filter(i=>i!==c)),children:e.jsx(I.x,{size:12})})]},c))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:b,className:"as-field__input gc-picker__input",list:g,value:t,placeholder:m,onChange:c=>h(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),d())}}),e.jsx("datalist",{id:g,children:o==null?void 0:o.map(c=>e.jsx("option",{value:c},c))}),e.jsx(N,{variant:"outline",size:"sm",onClick:d,disabled:!t.trim(),children:"Add"})]})]})}function be({draft:l,parent:r,above:a,peers:o,lists:m}){const t=f.useMemo(()=>{if(!o||o.length===0)return null;let h;try{h=me(l,m)}catch{return null}return{matched:he(H(r,h),o,m).length,total:o.length}},[l,r,o,m]);return t?t.matched===0?e.jsxs(ue,{tone:"warning",title:"No seller matches this policy",children:["With ",a?`${a} and `:"","these settings, none of the ",t.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 ",t.matched," of ",t.total," sellers",a?` after ${a}`:"","."]}):null}function Ce({value:l,onChange:r,peers:a,lists:o,showTemplates:m=!0,parent:t,disabled:h}){const[g,b]=f.useState(""),[d,c]=f.useState(null),i=(s,u)=>r({...l,[s]:u}),p=se(a),y=o.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),x=le(ie().data),n=f.useMemo(()=>x||t?H(x,t):null,[x,t]),Q=x&&t?"the buyer config and the levels above":x?"the buyer config":t?"the levels above":"",M=s=>(x==null?void 0:x[s])!==void 0&&x[s]===(n==null?void 0:n[s])?"The buyer config":"The levels above",{viewer:G}=ne(),J=ae("settings",G)?e.jsx("a",{className:"gc-link",href:ce("settings?tab=buyer"),onClick:te("settings?tab=buyer"),children:"Change"}):null,v=s=>M(s)==="The buyer config"?J:null,X=re(a)||l.minReputation!==""||(n==null?void 0:n.minReputation)!==void 0;function q(s){var F;let u;if(s==="own"){const C=o.find(Z=>Z.id===g);if(!C)return;u={allowMode:"only",allowedPeerIds:[],allowedListIds:[C.id]}}else u=pe(xe(s));const j=ge(l,u),_=((F=E.find(C=>C.id===s))==null?void 0:F.label)??s;j.length>0?c({label:_,template:u,conflicts:j}):r(B(l,u))}function S(s,u){i("routes",l.routes.map((j,_)=>_===s?u:j))}const T=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,w=(s,u)=>e.jsx(U,{size:"sm",className:"gc-num",label:u,inputMode:"decimal",value:l[s],placeholder:(n==null?void 0:n[s])!==void 0?`≤ ${je(n[s])} above`:"No cap",onChange:j=>i(s,j.target.value)}),O=e.jsxs(e.Fragment,{children:[e.jsx(be,{draft:l,parent:n,above:Q,peers:a,lists:o}),m&&!h&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),E.filter(s=>s.id!=="own").map(s=>e.jsx(N,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),o.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(L,{size:"sm","aria-label":"Peer list for Own peers only",value:g,onChange:b,options:[{value:"",label:"Own peer list…"},...y]}),e.jsx(N,{size:"sm",variant:"outline",disabled:!g,onClick:()=>q("own"),children:"Use"})]}),e.jsx(N,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>r(oe()),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=>i("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>i("allowedPeerIds",s),peers:a}),e.jsx(Y,{label:"Allowed peer lists",lists:o,value:l.allowedListIds,onChange:s=>i("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($,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>i("blockedPeerIds",s),peers:a}),e.jsx(Y,{label:"Blocked peer lists",lists:o,value:l.blockedListIds,onChange:s=>i("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(W,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>i("minTrustScore",s),floor:n==null?void 0:n.minTrustScore,floorSource:M("minTrustScore"),floorAction:v("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(R,{checked:l.requireTee||!!(n!=null&&n.requireTee),disabled:!!(n!=null&&n.requireTee),onChange:s=>i("requireTee",s),label:"TEE sellers only"}),e.jsx(R,{checked:l.requireVerified||!!(n!=null&&n.requireVerified),disabled:!!(n!=null&&n.requireVerified),onChange:s=>i("requireVerified",s),label:"Verified sellers only"})]}),((n==null?void 0:n.requireTee)||(n==null?void 0:n.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[n.requireTee&&n.requireVerified?"TEE and verified sellers are":n.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(L,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>i("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(D).map(s=>({value:s,label:D[s]}))]}),e.jsx(L,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>i("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=>i("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(fe,{label:"Allowed models",value:l.allowedModels,onChange:s=>i("allowedModels",s),suggestions:p,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(z,{title:"Price caps",summary:T?`${T} set`:"None",defaultOpen:h&&T>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[w("maxInputUsdPerMillion","Input $/M"),w("maxOutputUsdPerMillion","Output $/M"),w("maxCachedInputUsdPerMillion","Cached input $/M"),w("maxImageUsdPerImage","$ per image")]})}),e.jsxs(z,{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,u)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(U,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:j=>S(u,{...s,model:j.target.value})}),e.jsx(R,{checked:s.strict,onChange:j=>S(u,{...s,strict:j}),label:"Strict"}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>i("routes",l.routes.filter((j,_)=>_!==u)),children:"Remove"})]}),e.jsx($,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:j=>S(u,{...s,peerIds:j}),peers:a})]},u)),e.jsx("datalist",{id:"gc-policy-models",children:p.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(N,{variant:"outline",size:"sm",onClick:()=>i("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),X&&e.jsx(z,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(n==null?void 0:n.minReputation)!==void 0?`Inherit (≥ ${n.minReputation})`:"Inherit",defaultOpen:h&&l.minReputation!=="",children:e.jsx(W,{label:"Minimum reputation",value:l.minReputation,onChange:s=>i("minReputation",s),floor:n==null?void 0:n.minReputation,floorSource:M("minReputation"),floorAction:v("minReputation")})})]}),e.jsx(de,{isOpen:d!==null,tone:"primary",title:`Apply “${(d==null?void 0:d.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:d==null?void 0:d.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>c(null),onConfirm:()=>{d&&r(B(l,d.template)),c(null)}})]});return h?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:O}):e.jsx("div",{className:"gc-policy",children:O})}function W({label:l,value:r,onChange:a,clearable:o=!0,hint:m,floor:t,floorSource:h="The levels above",floorAction:g}){const b=f.useId(),d=r!=="",c=t!==void 0&&t>0,i=c&&d&&Number(r)<=t,p=i?String(t):d?r:c?`${t} 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:d?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:p})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:d?Math.max(Number(r),c?t:0):c?t:0,"aria-labelledby":b,onChange:y=>a(String(Math.max(Number(y.target.value),c?t:0)))}),o&&d&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>a(""),children:"Clear"})]}),c&&(d&&!i?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",t,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(I.lock,{size:12})," Locked at ",t," by ",h.replace(/^The /,"the "),".",g?e.jsxs(e.Fragment,{children:[" ",g]}):null]})),m&&e.jsx("span",{className:"as-field__hint",children:m})]})}function Y({label:l,lists:r,value:a,onChange:o}){return r.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),r.map(m=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:a.includes(m.id),onChange:t=>o(t.target.checked?[...a,m.id]:a.filter(h=>h!==m.id))}),m.name," ",e.jsxs("span",{className:"gc-muted",children:["(",m.peerIds.length,")"]})]},m.id))]})}export{Ce as P,W as S,$ as a,k as p};
@@ -1 +0,0 @@
1
- import{b9 as p,r as d,j as e,C as m,bC as x,bD as b,bE as v,t as j,be as y,bd as w,bg as f,b2 as C,B as h,A as k}from"./index-DqdaAEyo.js";import{P}from"./PolicyEditor-BdoaX9gK.js";function B(){const a=p(),[s,n]=d.useState(null),l=d.useRef(null),r=t=>new Promise(u=>{l.current=u,n(t)}),o=t=>{var u;n(null),(u=l.current)==null||u.call(l,t),l.current=null},i=(t,u)=>x(t.some(g=>b(g,a.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:a,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 l=v(a);return l.length===0?e.jsx("span",{className:"gc-muted",children:n}):e.jsx("span",{className:"gc-chiprow",children:l.map(r=>e.jsx(j,{children:r},r))})}function D(a){const[s,n]=d.useState(()=>y(a)),l=p();return{draft:s,setDraft:n,reset:r=>n(y(r)),build:()=>w(f(s,l.data??null))}}function N(a,s){try{return{policy:f(a,s),error:null}}catch(n){return{policy:null,error:n instanceof Error?n.message:String(n)}}}function O({draft:a,setDraft:s,title:n="Routing policy"}){const l=C(),r=p(),[o,i]=d.useState(null),c=N(a,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(a),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:a,onChange:s,peers:l.data,lists:r.data??[]})})]})}export{O as P,B as a,S as b,N as d,D as u};
@@ -1,4 +0,0 @@
1
- import{u as D,i as J,b4 as B,r as n,s as E,j as e,P as $,B as y,I as f,k as L,Q as R,M as Q,ap as U,t as C,z as V,E as W,m as F,A as G,C as H,b2 as K,T as j,b3 as _,n as X,q as O,e as v}from"./index-DqdaAEyo.js";import{u as Y,a as Z,P as ee}from"./PolicyField-DIPl0B1x.js";import{D as se}from"./DataTable-CDFSD9Kq.js";import{S as re}from"./SelectField-D8fxDUNO.js";import{T as N}from"./TextAreaField-CF9_zjuC.js";import"./PolicyEditor-BdoaX9gK.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Switch-Ba56zux7.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.js";function A(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}=D(),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?A(a.name):"")),[t,q]=n.useState(!!s),[h,z]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,I]=n.useState(s?s.workspaceId??"":p.id),[S,M]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,T]=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],k=>s?v.presets.update(s.id,r,k):v.presets.create(r,k))},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(A(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=>z(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=>M(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
2
- "temperature": 0.2,
3
- "max_tokens": 2048
4
- }`,onChange:r=>T(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}=D(),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(f.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(f.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};
@@ -1 +0,0 @@
1
- import{bW as qe,bh as pe,aI as Ve,u as X,a as fe,D as Ke,F as Ge,m as we,i as ye,r as p,O as Ye,b as ve,d as Qe,bX as We,bf as He,Y as U,bY as Je,bZ as Xe,e as L,ag as Ze,j as s,A as Z,ac as Y,n as ee,B as x,L as be,z as es,b9 as ss,s as xe,q as ke,k as je,Q as Pe,E as J,I as _,C as ts,T as q,v as F,M as Ce,ap as Se,t as N,a8 as ns,bU as $,ab as Ie,g as Ne,X as rs,b0 as $e,b_ as Ae,aS as as,b4 as os,b$ as ls,W as is,aU as cs,N as ds,aV as us,aW as ms,b2 as hs,b3 as gs,bo as ps,aY as fs,aZ as ws,a_ as ce,b6 as ys,x as de,a$ as vs,P as bs}from"./index-DqdaAEyo.js";import{p as Q,a as xs}from"./PolicyEditor-BdoaX9gK.js";import{S as A}from"./SelectField-D8fxDUNO.js";import{D as Le}from"./DataTable-CDFSD9Kq.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-Ben8ko6c.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-CoTmwoy_.js";import{T as Is,a as Ns}from"./Tabs-BmjCmD5T.js";import{S as W}from"./Switch-Ba56zux7.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.js";import"./PolicyField-DIPl0B1x.js";import"./TextAreaField-CF9_zjuC.js";function Te(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Ee(e,t){const n=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!n)throw new Error("That key no longer exists.");return n}async function De(e,t){switch(t.kind){case"gateway":return e.network.gatewayPolicy();case"workspace-org":return(await e.workspaces.get(t.workspaceId)).orgRoutingPolicy;case"workspace":return(await e.workspaces.get(t.workspaceId)).routingPolicy;case"member":{const n=(await e.members.list()).find(a=>a.id===t.memberId);if(!n)throw new Error("That member no longer exists.");return n.routingPolicy}case"key":{const n=await Ee(e,t);return n[Te(n,t.layer)]??null}}}async function $s(e,t,n,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(n??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:n},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:n},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:n},...o);return;case"key":{const i=t.layer==="owner"?Te(await Ee(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:n},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function As(e,t,n,a,o,i){const m=await De(e,t),c=qe(m,n,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await $s(e,t,c,i),{before:m,after:c,changed:g}}function Ls(e,t,n){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:n}:e.kind==="gateway"?{model:t,workspace:n}:{model:t,workspace:e.workspaceId}}const Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ms(e){const{action:t,name:n,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Fs[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${n} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${n} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Ts(e,t,n,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:n}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:n,layer:a?"admin":"owner"}:null}function Es(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Ds({fetching:e,error:t,ready:n,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):n?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",es(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Oe({peer:e,action:t,onClose:n,peers:a}){var te,ne,re,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Ke(),f=Ge(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[r,b]=p.useState(""),[k,D]=p.useState(""),O=Ye(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;D(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Ts(y,r,i.id,u),[S,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,r,e]);const B=Qe({queryKey:["routing","scope-policy",j],queryFn:()=>De(L,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||k!==""),I=B.data??null,ze=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ue=t==="block"&&z&&e!==null&&We(I,e.peerId);let E=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(E=`key “${((ne=w.find(d=>d.id===r))==null?void 0:ne.label)??r}”`),y==="member"&&(E=`member “${((ae=(re=O.data)==null?void 0:re.find(d=>d.id===r))==null?void 0:ae.label)??r}”`);const P=He({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const C=k||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await As(L,j,t,e.peerId,k||void 0,d);let oe=null,le=null;if(C)try{oe=await L.network.routePreview(Ls(j,C,i.id))}catch(_e){le=Ze(_e)}return Ms({action:t,name:Q(a,e.peerId),scopeLabel:E,changed:G,model:C,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const C of Xe)g.invalidateQueries({queryKey:[C]});d&&(d.tone==="success"?(f(d.text),n()):T(d))},onError:d=>{const C=e?Q(a,e.peerId):"this seller";if(U(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${E} do not allow ${C}, so saving this would not let it serve. ${Je(d.details).join(" ")}`.trim()});else if(U(d,"empty_allow_list")){const G=t==="block"?`Blocking ${C}`:`Allowing only ${C}`;T({tone:"warning",text:`Nothing changed. ${G} on ${E} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Q(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:n,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(A,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx(A,{label:"Member",value:r,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx(A,{label:"Key",value:r,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx(A,{label:"For model",value:k,onChange:D,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Ds,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),ze&&s.jsxs(Y,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ue&&s.jsxs(Y,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!U(P.error,"narrowed")&&!U(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(Y,{tone:S.tone,title:Es(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(x,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(x,{onClick:n,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Os({initial:e,peers:t,onDone:n}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=xe({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?L.network.updatePeerList(e.id,l):L.network.createPeerList(l)},onSuccess:n,invalidate:[ke.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(q,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(q,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(xs,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function Rs({peers:e}){const{viewer:t}=X(),n=we(t),a=ss(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=xe({mutationFn:f=>L.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[ke.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:n&&s.jsx(x,{size:"sm",variant:"outline",leadingIcon:s.jsx(_.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>n?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(J,{icon:s.jsx(_.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Os,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ts,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function Re(e,t){return t?e.services.filter(n=>n.service===t):e.services}function V(e,t,n=""){const a=Re(e,n).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function Bs(e,t=""){var n;return((n=V(e,"inputUsdPerMillion",t))==null?void 0:n.min)??null}function zs(e,t=""){var n;return((n=V(e,"outputUsdPerMillion",t))==null?void 0:n.min)??null}function se(e,t=""){return Re(e,t).some(n=>n.inputUsdPerMillion===0&&(n.outputUsdPerMillion??0)===0)}function Us(e,t){const n=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(n&&!a.peerId.toLowerCase().includes(n)&&!(a.displayName??"").toLowerCase().includes(n)&&!a.services.some(i=>i.service.toLowerCase().includes(n))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function H(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Ce,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Se,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Fe,{links:e.verificationLinks}),e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,"")&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),t&&s.jsx(N,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",ns(e.lastSeen)]})]})}function qs({peer:e,showReputation:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx($,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx($,{label:"Reputation",value:he(e.reputationScore)}),s.jsx($,{label:"Stake",value:e.stakeAnts?Cs(e.stakeAnts):"—"}),s.jsx($,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx($,{label:"Latency p50 (this gateway)",value:Ie(e.latencyMsP50)}),s.jsx($,{label:"Requests, 24h (this gateway)",value:Ne(e.requests24h)}),s.jsx($,{label:"Failure streak",value:n?`${e.health.failureStreak}, cooling down until ${rs(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:n}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(Me,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(q,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(ks,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:js(c)}),s.jsx("span",{children:Be[Ae(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Se,{iconOnly:!0,value:$e(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(x,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>n(c),children:"API call"})]})},M(c))})})})}function Ks({peer:e,service:t,onSelect:n}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=as(),c=ve(i),g=os(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Ae(t),h=$e(e.peerId,t.service),r=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=ls(m,e.peerId,t.service,y,r?`@preset/${r.slug}`:null),k=b.find(w=>w.id===f)??b[0],D=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(Me,{title:"API call",actions:e.services.length>1&&s.jsx(A,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(S=>M(S)===w);j&&n(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx(Is,{id:"gc-connect",label:"Ways to connect",value:k.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(Ns,{tabsId:"gc-connect",tab:k.id,className:"gc-stack",children:[k.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:r?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",r.slug]})," for this model. Codex needs a preset: with a raw GPT model name it switches to a tool format some sellers drop."]}):s.jsx(s.Fragment,{children:"Codex needs a preset, not a raw model name: with a GPT model name it switches to a tool format some sellers drop. Create one for this model, then use its slug."})}),!r&&O&&s.jsx(x,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),k.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(is,{code:k.code,label:`${t.service} · ${k.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:cs})," to one of your API keys first."," ",c.data&&!D&&s.jsx(ds,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ss,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Gs({peer:e,peers:t,showReputation:n}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(x,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(qs,{peer:e,showReputation:n})]}),s.jsx(Vs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Ks,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Oe,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Ys({peer:e,model:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,t)&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),n&&s.jsx(N,{tone:"warning",children:"Cooling down"})]})}function ct(){const e=us(),t=ms(e.rest),n=hs(),a=p.useMemo(()=>{var h;return t?((h=n.data)==null?void 0:h.find(r=>pe(r.peerId,t)))??null:null},[n.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>gs(n.data),[n.data]),f=ps(n.data),l=fs(),u=(h,r)=>i(b=>({...b,[h]:r})),v=t===null?null:{eyebrow:"Provider",title:a?H(a):F(t,8,6),body:n.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Gs,{peer:a,peers:n.data,showReputation:f},a.peerId):s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:n,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Us(h,o),rowKey:r=>r.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:r=>de(vs("providers",r.peerId)),rowLabel:r=>H(r),actions:r=>[o.model!==""&&ys(l,r.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:r,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:r,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:r,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:r=>r.displayName??r.peerId,render:r=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:r.displayName??r.peerId,children:H(r)}),r.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Ce,{title:r.peerId,children:F(r.peerId,6,4)})}),s.jsx(Ys,{peer:r,model:o.model})]}),after:r=>s.jsx(ws,{value:r.peerId,label:`Copy peer id ${r.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:r=>{var b;return(b=r.verificationLinks)!=null&&b.length?s.jsx(Fe,{links:r.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:r=>s.jsx("span",{className:"gc-muted",children:r.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:r=>Bs(r,o.model),render:r=>ce(V(r,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:r=>zs(r,o.model),render:r=>ce(V(r,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:r=>r.trustScore,render:r=>ge(r.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:r=>r.reputationScore,render:r=>ge(r.reputationScore)}]:[],{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,sortValue:r=>r.latencyMsP50,render:r=>Ie(r.latencyMsP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:r=>r.requests24h,render:r=>Ne(r.requests24h)}]})})}),s.jsx(Rs,{peers:n.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(bs,{title:"Providers",description:"Providers on the network this gateway can route to. Open one to copy its models and an API call, or allow, block or prefer it for any scope."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(q,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx(A,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(W,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(W,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(W,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Ps,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Oe,{peer:m.peer,action:m.kind,peers:n.data,onClose:()=>c(null)})]})}export{ct as default};
@@ -1 +0,0 @@
1
- import{r as R,j as e,L as p,n as x,X as y,M as d,v as I,ab as u,g as o,E as L,I as P,B as v,U as S,e as f,q as j,t as l,f as T,d as C,Y as M,ac as w,V as A,W as D}from"./index-DqdaAEyo.js";import{u as E}from"./useInfiniteQuery-Dm7RR6wI.js";import{f as q}from"./usage-CjxizGfE.js";import{D as F}from"./DataTable-CDFSD9Kq.js";const K=50;function c(r){return r===null?e.jsx(l,{tone:"info",children:"In flight"}):r<400?e.jsx(l,{tone:"success",children:r}):r<500?e.jsx(l,{tone:"warning",children:r}):e.jsx(l,{tone:"danger",children:r})}function k({entry:r}){const n=q(r,Date.now());return n==="free"?e.jsx("span",{className:"gc-muted",title:"Served by a free seller: $0",children:"Free"}):n==="pending"?e.jsx("span",{className:"gc-muted",title:"The buyer reports spend a moment after the response",children:"pending"}):n==="not-recorded"?e.jsx("span",{className:"gc-muted",title:"No spend was reported for this request: the buyer lost it",children:"not recorded"}):e.jsx(e.Fragment,{children:T(r.spent)})}function O(r){try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}function m({title:r,body:n}){return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:r}),e.jsx(D,{code:O(n)})]})}function $({detail:r}){return!r.requestBody&&!r.responseBody?e.jsx("p",{className:"gc-fineprint",children:"Bodies are not stored for this request. Turn on content logging under Settings → Observability to keep them."}):e.jsxs(e.Fragment,{children:[r.requestBody&&e.jsx(m,{title:"Request body",body:r.requestBody}),r.responseBody&&e.jsx(m,{title:"Response body",body:r.responseBody})]})}function U({entry:r}){const n=C({queryKey:j.request(r.tag),queryFn:()=>f.usage.request(r.tag),retry:!1,staleTime:6e4}),t=n.data??r,i=M(n.error)&&n.error.status===404;return e.jsxs(e.Fragment,{children:[t.errorCode||t.errorMessage?e.jsx(w,{tone:"danger",title:t.errorCode??"Request failed",children:t.errorMessage??"No message was returned."}):null,e.jsx(A,{items:[["Status",c(t.status)],["Request",e.jsxs(d,{children:[t.method," ",t.path]},"p")],["Model",t.model??"—"],["Key",t.keyLabel],["End user",t.endUser??"—"],["Seller",t.sellerPeerId?e.jsx(d,{children:t.sellerPeerId},"s"):"—"],["Latency",u(t.latencyMs)],["Duration",t.finishedAt?u(t.finishedAt-t.startedAt):"—"],["Input tokens",o(t.inputTokens)],["Cached input",o(t.cachedInputTokens)],["Output tokens",o(t.outputTokens)],["Cost",e.jsx(k,{entry:t},"c")],["Tag",e.jsx(d,{children:t.tag},"t")]]}),n.isLoading&&e.jsx(p,{rows:2}),n.error&&!i?e.jsx(x,{error:n.error,title:"Could not load the bodies"}):null,n.data&&e.jsx($,{detail:n.data})]})}function V({filter:r,showKey:n=!0}){var g;const[t,i]=R.useState(null),a=E({queryKey:j.requests(r),queryFn:({pageParam:s})=>f.usage.requests({...r,before:s??void 0,limit:K}),initialPageParam:null,getNextPageParam:s=>s.nextBefore,refetchInterval:s=>{var h;return(h=s.state.data)!=null&&h.pages.some(N=>N.requests.some(B=>q(B,Date.now())==="pending"))?5e3:!1}});if(a.isLoading)return e.jsx(p,{rows:8});if(a.error)return e.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const b=((g=a.data)==null?void 0:g.pages.flatMap(s=>s.requests))??[];return e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Request log",rows:b,rowKey:s=>s.tag,onRowClick:i,rowLabel:s=>`request ${s.tag}`,empty:e.jsx(L,{icon:e.jsx(P.logs,{size:18}),title:"No requests found",body:"Requests appear here as soon as a key is used. Check the filters if you expected some."}),columns:[{key:"time",header:"Time",render:s=>e.jsx("span",{className:"gc-nowrap",children:y(s.startedAt)})},...n?[{key:"key",header:"Key",secondary:!0,render:s=>s.keyLabel}]:[],{key:"model",header:"Model",render:s=>e.jsxs("span",{className:"gc-ellipsis",children:[s.model??s.path,s.status!==null&&s.status>=400?e.jsxs("span",{className:"gc-narrow-only",children:[" ",c(s.status)]}):null]})},{key:"seller",header:"Seller",secondary:!0,optional:!0,render:s=>s.sellerPeerId?e.jsx(d,{title:s.sellerPeerId,children:I(s.sellerPeerId)}):"—"},{key:"status",header:"Status",secondary:!0,render:s=>e.jsx("span",{title:s.errorMessage??void 0,children:c(s.status)})},{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,render:s=>u(s.latencyMs)},{key:"tokens",header:"Tokens",align:"right",secondary:!0,render:s=>`${o(s.inputTokens)} → ${o(s.outputTokens)}`},{key:"cost",header:"Cost",align:"right",render:s=>e.jsx(k,{entry:s})}]}),a.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(v,{variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load older requests"})}),e.jsx(S,{isOpen:t!==null,onClose:()=>i(null),title:(t==null?void 0:t.model)??"Request",subtitle:t?y(t.startedAt):void 0,eyebrow:"Request",children:t&&e.jsx(U,{entry:t},t.tag)})]})}export{V as R};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-BSNDTCMG.js","assets/index-DqdaAEyo.js","assets/index-M34IaZVB.css","assets/ants-B38m9Phv.js","assets/useTx-BRRWrJlB.js","assets/en_US-Y4ZOVFV4-CzjJ6dvA.js","assets/clsx-B-dksMZM.js","assets/index-D5ERwHFX.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/ConnectWallet-DSqRjyNA.js","assets/OperatorGateAlert-CCPFpK6Y.js"])))=>i.map(i=>d[i]);
2
- import{u as v,D as b,F as k,d as N,q as m,G as S,H as R,r as c,j as e,P as z,Q as _,J as q,S as l,K as o,M as E,v as d,k as g,N as F,B as P,A as T,L as D,t as w,E as I,I as Q,_ as K,e as L}from"./index-DqdaAEyo.js";import{C as O}from"./ChainGate-Dvm-SUef.js";import{f as r,a as $}from"./ants-B38m9Phv.js";import{D as B}from"./DataTable-CDFSD9Kq.js";import"./index-D5ERwHFX.js";const H=c.lazy(()=>K(()=>import("./RewardsClaim-BSNDTCMG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function W(){const{workspace:t}=v(),x=b(),y=k(),j=N({queryKey:m.rewards(t.id),queryFn:()=>L.wallet.rewards(t.id)}),h=S(),p=R(t.id),[C,i]=c.useState(!1);return e.jsxs("div",{className:"gc-page",children:[e.jsx(z,{title:"Rewards",description:"ANTS earned by this workspace's usage. Claimed ANTS go to the authorized wallet."}),e.jsx(_,{query:j,rows:3,children:n=>{var u;const A=p.data?p.data.operator:n.operator,a={...n,operator:A};return e.jsxs(e.Fragment,{children:[e.jsx(q,{stale:n.stale}),e.jsxs("div",{className:"gc-grid gc-grid--3",children:[e.jsx(l,{label:"Ready to claim",value:r(a.pendingAnts)}),e.jsx(l,{label:"From the legacy program",value:r(((u=a.legacy)==null?void 0:u.pendingAnts)??"0"),sub:a.legacy?"Claimed together with the rest":void 0}),e.jsx(l,{label:"Authorized wallet",value:o(a.operator)?e.jsx(E,{title:a.operator,children:d(a.operator)}):"Not set"})]}),e.jsx(g,{children:e.jsxs("div",{className:"gc-summary-row",children:[e.jsxs("div",{className:"gc-summary-row__text",children:[e.jsx("span",{className:"gc-strong",children:$(a.pendingAnts)?`${r(a.pendingAnts)} ready to claim`:"Nothing to claim yet"}),e.jsx("span",{className:"gc-fineprint",children:o(a.operator)?e.jsxs(e.Fragment,{children:["Claimed ANTS go to the authorized wallet ",d(a.operator),", which signs the claim."]}):e.jsxs(e.Fragment,{children:["Only the authorized wallet can claim, and none is set. Authorize one on ",e.jsx(F,{to:"wallet",children:"Wallet & Funding"}),"."]})})]}),e.jsx(P,{size:"sm",variant:"outline",disabled:!o(a.operator),onClick:()=>i(!0),children:"Claim rewards"})]})}),e.jsx(T,{isOpen:C,onClose:()=>i(!1),title:"Claim rewards",subtitle:`${r(a.pendingAnts)} ready. Sent to the authorized wallet${o(a.operator)?` ${d(a.operator)}`:""}.`,children:e.jsx(O,{chain:h.data,error:h.error,children:s=>e.jsx(c.Suspense,{fallback:e.jsx(D,{rows:2}),children:e.jsx(H,{rewards:a,chain:s,onDone:()=>{y("Rewards claimed"),i(!1),x.invalidateQueries({queryKey:m.rewards(t.id)})}})})})}),e.jsx(g,{flush:!0,title:"Current program by epoch",description:"Rewards accrue at each epoch boundary from this workspace's paid usage.",children:e.jsx(B,{label:"Reward epochs",rows:[...a.epochs].sort((s,f)=>f.epoch-s.epoch),rowKey:s=>String(s.epoch),empty:e.jsx(I,{icon:e.jsx(Q.rewards,{size:18}),title:"No rewards yet",body:"Rewards accrue per epoch as this workspace's keys are used."}),columns:[{key:"epoch",header:"Epoch",render:s=>s.epoch},{key:"amount",header:"Amount",align:"right",render:s=>r(s.pendingAnts)},{key:"state",header:"Status",render:s=>s.claimed?e.jsx(w,{tone:"success",children:"Claimed"}):e.jsx(w,{tone:"warning",children:"Unclaimed"})}]})})]})}})]})}export{W as default};
@@ -1 +0,0 @@
1
- import{j as e,u as R,H as B,aj as N,ak as E,ac as b,al as k,v as w,B as v}from"./index-DqdaAEyo.js";import{a as I}from"./ants-B38m9Phv.js";import{u as O,a as S,T,U as x,s as C,L as j}from"./useTx-BRRWrJlB.js";import{a as _}from"./ConnectWallet-DSqRjyNA.js";import{O as W}from"./OperatorGateAlert-CCPFpK6Y.js";import{W as G,u as L,c as P}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";function U(a,s){return a?"Claiming…":s===0?"Nothing to claim":s===1?"Claim":`Claim (${s} transactions)`}function Y({rewards:a,chain:s,onDone:A}){const{address:r}=L(),u=P(),{workspace:h}=R(),p=B(h.id),{refresh:y}=N(h.id),i=O(s.chainId),{writeContractAsync:g}=S(),d=E(s,"usageRewards"),f=a.epochs.filter(t=>!t.claimed&&I(t.pendingAnts)),o=a.legacy&&I(a.legacy.pendingAnts)?a.legacy:null,l=f.length+(o?1:0);if(!d)return e.jsx(b,{tone:"warning",children:"The gateway did not report the usage rewards contract address."});const m=k(p.data,r,"claim rewards");return m.ok?e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{className:"gc-fineprint",children:["The ANTS go to ",w(m.operator),", the connected authorized wallet."]}),e.jsx(T,{chain:s,runner:i,done:"Rewards claimed."}),e.jsx(v,{disabled:i.running||l===0,onClick:async()=>{const t=f.map(n=>{const c=[a.address,BigInt(n.epoch)];return{label:`Claim epoch ${n.epoch}`,check:()=>C(u,{account:r,address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId}),send:()=>g({address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId})}});if(o){const n=[a.address,o.epochs.map(BigInt)],c=o.contract;t.push({label:"Claim legacy emissions",check:()=>C(u,{account:r,address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId}),send:()=>g({address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId})})}await i.run(t,{onStale:()=>void y().catch(()=>{})})&&A()},children:U(i.running,l)}),l>1&&e.jsx("p",{className:"gc-fineprint",children:"Each current-program epoch is its own transaction; legacy emissions are one more."})]}):e.jsx(W,{gate:m,state:p.data,connected:r})}function V(a){return e.jsx(G,{chain:a.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(_,{}),e.jsx(Y,{...a})]})})}export{V as default};
@@ -1 +0,0 @@
1
- import{u as C,a as se,b2 as O,b3 as ae,m as D,r as u,b as te,c as re,b4 as ie,d as ne,j as e,k as K,T as le,B as b,L as $,n as z,aY as oe,ac as q,z as N,t as A,b5 as G,E as ce,b6 as de,e as T,q as W,P as ue,b7 as pe,b8 as ge,D as V,b9 as H,aK as ye,ba as X,bb as M,bc as _,bd as Q,i as me,F as he,be as R,bf as we,bg as fe,aM as ve,A as xe}from"./index-DqdaAEyo.js";import{b as Z,a as je,d as be}from"./PolicyField-DIPl0B1x.js";import{p as Y,P as ke}from"./PolicyEditor-BdoaX9gK.js";import{S as U}from"./SelectField-D8fxDUNO.js";import{D as Pe}from"./DataTable-CDFSD9Kq.js";import{T as Se,a as Ne}from"./Tabs-BmjCmD5T.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Switch-Ba56zux7.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=D(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(K,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(U,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(U,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx($,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??Y(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??Y(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>G(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>G(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(K,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",children:"Someone saved this policy while you were editing it. Open it to reload theirs or keep yours."}),e.jsx(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(null)},children:"Keep editing"})]}),children:"Someone saved this policy while you were editing it. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx($,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx($,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(K,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:D(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=D(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ye(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ye as default};