@antseed/gateway-console 0.1.3 → 0.1.5

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 (189) hide show
  1. package/dist/assets/Activity-62ACSef_.js +1 -0
  2. package/dist/assets/Audit-DqVdOhlJ.js +1 -0
  3. package/dist/assets/{ChainGate-B_PADueu.js → ChainGate-B1xi2PsC.js} +1 -1
  4. package/dist/assets/ChannelClose-OIfxrL05.js +1 -0
  5. package/dist/assets/{Charts-BjppB8Po.js → Charts-C40fH8xu.js} +1 -1
  6. package/dist/assets/Chat-BvGYJ5Y8.js +220 -0
  7. package/dist/assets/Chat-Dtte195G.css +1 -0
  8. package/dist/assets/{ConnectWallet-Ba-nE-Ex.js → ConnectWallet-CIF1O-b8.js} +1 -1
  9. package/dist/assets/DataTable-sbVT8kP1.js +1 -0
  10. package/dist/assets/{Disclosure-CYz0evEi.js → Disclosure-Cx-awmr6.js} +1 -1
  11. package/dist/assets/KeyHolder-CPmUp8lv.js +1 -0
  12. package/dist/assets/Keys-stljGmXA.js +1 -0
  13. package/dist/assets/Logs-C2h0OUd6.js +1 -0
  14. package/dist/assets/Members-CvRczTwo.js +1 -0
  15. package/dist/assets/{Migrate-D5lsM7jR.js → Migrate-DSwqmuYZ.js} +1 -1
  16. package/dist/assets/Models-DRrQ0eaX.js +1 -0
  17. package/dist/assets/OperatorActions-CDFST6SU.js +1 -0
  18. package/dist/assets/{OperatorGateAlert-DAmQCyeN.js → OperatorGateAlert-C3dHqq3P.js} +1 -1
  19. package/dist/assets/{Overview-D5G2tGEo.js → Overview-zCE_XZV5.js} +1 -1
  20. package/dist/assets/PolicyEditor-B52YQzMa.js +1 -0
  21. package/dist/assets/{PolicyField-B3b2T_KJ.js → PolicyField-Djk40GaH.js} +1 -1
  22. package/dist/assets/Presets-MqSKjh0_.js +4 -0
  23. package/dist/assets/Providers-Deprr6b6.js +1 -0
  24. package/dist/assets/{RequestLog-DFYOMsBa.js → RequestLog-C5PR-cpV.js} +1 -1
  25. package/dist/assets/Rewards-EtGJVAbO.js +2 -0
  26. package/dist/assets/RewardsClaim-DRzi4dnv.js +1 -0
  27. package/dist/assets/Routing-B4sVpf47.js +1 -0
  28. package/dist/assets/{Segmented-JCEKIWY7.js → Segmented-D3p0uCs7.js} +1 -1
  29. package/dist/assets/{SelectField-DgDdipP1.js → SelectField-BSkxMNGk.js} +1 -1
  30. package/dist/assets/Settings-mk_D9qwH.js +7 -0
  31. package/dist/assets/{Switch-BasD00zg.js → Switch-C1JjKdQ3.js} +1 -1
  32. package/dist/assets/{Tabs-eMKdE-iz.js → Tabs-4vclgTgN.js} +1 -1
  33. package/dist/assets/{TextAreaField-DeGuklpV.js → TextAreaField-CYcKNNwk.js} +1 -1
  34. package/dist/assets/{UsageByModel-BFNAtlZ4.js → UsageByModel-DrWRsB8W.js} +1 -1
  35. package/dist/assets/Wallet-B73Wye2M.js +9 -0
  36. package/dist/assets/WalletConfirm-DR1uVQ0x.js +1 -0
  37. package/dist/assets/WalletFunding-CctnzIgN.js +1 -0
  38. package/dist/assets/WalletSignIn-CE39ggEH.js +1 -0
  39. package/dist/assets/Workspaces-CmwBRhwh.js +1 -0
  40. package/dist/assets/{add-BODkAe-c.js → add-D-7UccYb.js} +2 -2
  41. package/dist/assets/all-wallets-BGxRkpcp.js +6 -0
  42. package/dist/assets/{app-store-mosenM4j.js → app-store-s1uoA2ti.js} +2 -2
  43. package/dist/assets/{apple-DjSmNz7B.js → apple-BRpXhQwe.js} +2 -2
  44. package/dist/assets/arrow-bottom-FKCC1_cZ.js +8 -0
  45. package/dist/assets/{arrow-bottom-circle-DcX_G-xh.js → arrow-bottom-circle-CJkzZmsc.js} +2 -2
  46. package/dist/assets/arrow-left-De1oRzmY.js +8 -0
  47. package/dist/assets/arrow-right-2NX2NyRD.js +8 -0
  48. package/dist/assets/arrow-top-CgrB8jyp.js +8 -0
  49. package/dist/assets/{bank-SDwW3Dkp.js → bank-CMkHQ1al.js} +2 -2
  50. package/dist/assets/{basic-HWgx8ne-.js → basic-BkMqokQN.js} +1 -1
  51. package/dist/assets/{browser-Cs1coMqG.js → browser-7RnxNloE.js} +2 -2
  52. package/dist/assets/{bundle-full-B6fi0-ms.js → bundle-full-DUUqKkjA.js} +1 -1
  53. package/dist/assets/{card-DZo9bdfS.js → card-B_HxJTZt.js} +2 -2
  54. package/dist/assets/ccip-Co0K3XbT.js +1 -0
  55. package/dist/assets/{checkmark-DAOulFxE.js → checkmark-CFWVDR6z.js} +2 -2
  56. package/dist/assets/{checkmark-bold-DXiCBLB8.js → checkmark-bold-CNBCmpUc.js} +2 -2
  57. package/dist/assets/chevron-bottom-CTGYD88S.js +8 -0
  58. package/dist/assets/chevron-left-mTki2Hbr.js +8 -0
  59. package/dist/assets/chevron-right-DayB9xK6.js +8 -0
  60. package/dist/assets/chevron-top-9WSiSGRy.js +8 -0
  61. package/dist/assets/{chrome-store-DD0QyBx7.js → chrome-store-CgM5Miz5.js} +2 -2
  62. package/dist/assets/{clock-CUWl2UXI.js → clock-BxY5-pG7.js} +2 -2
  63. package/dist/assets/close-CDUCKnVv.js +8 -0
  64. package/dist/assets/{code-block-0KvO9_Pn.js → code-block-D5n56Bu8.js} +2 -2
  65. package/dist/assets/coinPlaceholder-Ds_PtIse.js +8 -0
  66. package/dist/assets/{compass-D2F47cHp.js → compass-C649LqmC.js} +2 -2
  67. package/dist/assets/{copy-2dFkZNac.js → copy-DYxsyU2w.js} +2 -2
  68. package/dist/assets/{core-FBx8iqx5.js → core-CX6jme4T.js} +3 -3
  69. package/dist/assets/cursor-BXlarUDb.js +3 -0
  70. package/dist/assets/{cursor-transparent-D0luUhMB.js → cursor-transparent-Dq6J5BgS.js} +2 -2
  71. package/dist/assets/{desktop-DdbSeEv5.js → desktop-Do922EUE.js} +2 -2
  72. package/dist/assets/{disconnect-CfKuUcu9.js → disconnect-DUKdDBRk.js} +2 -2
  73. package/dist/assets/{discord-D4PzntCV.js → discord-JwdabNcm.js} +2 -2
  74. package/dist/assets/{en_US-Y4ZOVFV4-C1wt0O8b.js → en_US-Y4ZOVFV4-CReY5kLU.js} +10 -10
  75. package/dist/assets/{etherscan-DP-dOCS7.js → etherscan-DTBHIFki.js} +2 -2
  76. package/dist/assets/{exclamation-triangle-Cz73ROGX.js → exclamation-triangle-BpP327Fo.js} +2 -2
  77. package/dist/assets/{extension-CJFWp4eM.js → extension-j6JOf27o.js} +2 -2
  78. package/dist/assets/external-link-KPnIyOs2.js +8 -0
  79. package/dist/assets/{facebook-Dr31tYhh.js → facebook-CUm5rmxi.js} +1 -1
  80. package/dist/assets/{farcaster-UjSyQW0m.js → farcaster-B0vG6PgN.js} +1 -1
  81. package/dist/assets/filters-lRsk33JN.js +8 -0
  82. package/dist/assets/{github-BUU3xNn6.js → github-CxYb478W.js} +2 -2
  83. package/dist/assets/{google-D4Sl_6wx.js → google-AoLkuqHM.js} +2 -2
  84. package/dist/assets/{help-circle-BdORni3L.js → help-circle-B4PduW5F.js} +2 -2
  85. package/dist/assets/highlighted-body-KQOG7T2V-tu6WaGd1.js +1 -0
  86. package/dist/assets/{id-BeI-jz4T.js → id-L7tAEkKG.js} +2 -2
  87. package/dist/assets/{image-BSmuE4jA.js → image-DOQYBepB.js} +2 -2
  88. package/dist/assets/index-17PEzKx_.js +1 -0
  89. package/dist/assets/index-Bgrmz5Gh.js +91 -0
  90. package/dist/assets/{index-CBpN3RR7.js → index-BqGpfOnj.js} +3 -3
  91. package/dist/assets/{index-DMFnEtmX.js → index-DK7xhF9m.js} +2 -2
  92. package/dist/assets/index-DNT4SsKr.css +1 -0
  93. package/dist/assets/{index-CxJO1Ljw.js → index-y9ajgRFv.js} +1 -1
  94. package/dist/assets/{index.es-B5dC6ZPc.js → index.es-kR-uCv4P.js} +4 -4
  95. package/dist/assets/info-circle-BvfVUJNy.js +12 -0
  96. package/dist/assets/{info-Be24SYro.js → info-uKWVCo_C.js} +2 -2
  97. package/dist/assets/{lightbulb-BOxJlIam.js → lightbulb-DO32OYdV.js} +2 -2
  98. package/dist/assets/{limits-CE9uA1mE.js → limits-I4Xri5kH.js} +1 -1
  99. package/dist/assets/{mail-CIPLYvTV.js → mail-MlMfOV0O.js} +1 -1
  100. package/dist/assets/{mermaid-MCJ5UELQ-Djb0AMyx.js → mermaid-MCJ5UELQ-CXGXvvLA.js} +6 -6
  101. package/dist/assets/{metamask-sdk-fc1iADZM.js → metamask-sdk-CZTQzdZy.js} +1 -1
  102. package/dist/assets/{mobile-BVbitISP.js → mobile-DxWEXY-d.js} +2 -2
  103. package/dist/assets/{models-g5FVBi3I.js → models-DGQYrtKn.js} +1 -1
  104. package/dist/assets/more-CDCHQLT3.js +11 -0
  105. package/dist/assets/{network-placeholder-b_cq5dDb.js → network-placeholder-Bscumk_y.js} +2 -2
  106. package/dist/assets/{nftPlaceholder-D6VuHH4L.js → nftPlaceholder-CZj8ym45.js} +2 -2
  107. package/dist/assets/off-DZcfy0ut.js +8 -0
  108. package/dist/assets/{play-store-BwuovnpF.js → play-store-DMcFVzJl.js} +1 -1
  109. package/dist/assets/{plus-DsiiE_0r.js → plus-CrMZIqkK.js} +2 -2
  110. package/dist/assets/{qr-code-Ciyg_r5_.js → qr-code-BmydgyiV.js} +1 -1
  111. package/dist/assets/{recycle-horizontal-Dt_UN1jS.js → recycle-horizontal-CSrs8rul.js} +2 -2
  112. package/dist/assets/refresh-Bghm7ATF.js +8 -0
  113. package/dist/assets/{reown-logo-Bq4Gp-eF.js → reown-logo-BE_YCUWl.js} +1 -1
  114. package/dist/assets/search-BVKO89aW.js +8 -0
  115. package/dist/assets/{secp256k1-Jjx6bzii.js → secp256k1-BYFo74Iy.js} +1 -1
  116. package/dist/assets/{send-CdsLof8L.js → send-pY0DB7x7.js} +1 -1
  117. package/dist/assets/{swapHorizontal-3pzJ0fK5.js → swapHorizontal-DLJaB22K.js} +2 -2
  118. package/dist/assets/{swapHorizontalBold-CttCNoHf.js → swapHorizontalBold-DGAu8PHD.js} +2 -2
  119. package/dist/assets/{swapHorizontalMedium-C-WPorgo.js → swapHorizontalMedium-CgNljeNo.js} +1 -1
  120. package/dist/assets/{swapHorizontalRoundedBold-C5VJDqCA.js → swapHorizontalRoundedBold-Cj5OUnOy.js} +2 -2
  121. package/dist/assets/{swapVertical-jp-7l-n1.js → swapVertical-BrZopBF4.js} +2 -2
  122. package/dist/assets/{telegram-B8LqO8ML.js → telegram-XorPgtmK.js} +2 -2
  123. package/dist/assets/{three-dots-D3booDJ4.js → three-dots-BJhNCCn5.js} +2 -2
  124. package/dist/assets/{twitch-B3H8D0Lu.js → twitch-BEbiCzO2.js} +2 -2
  125. package/dist/assets/{twitterIcon-__3pOZUO.js → twitterIcon-CkcUz9fu.js} +2 -2
  126. package/dist/assets/{usage-AvFyjxl-.js → usage-D2MGES9n.js} +1 -1
  127. package/dist/assets/{useInfiniteQuery-Dn0V4FRG.js → useInfiniteQuery-DWwzEQdC.js} +1 -1
  128. package/dist/assets/{useTx-B_KdxpeJ.js → useTx-CIkBd_D3.js} +1 -1
  129. package/dist/assets/{verify-DKhrB_jr.js → verify-9cqPQDU3.js} +2 -2
  130. package/dist/assets/{verify-filled-DXI3-Yqh.js → verify-filled-Da6z020R.js} +2 -2
  131. package/dist/assets/{w3m-modal-BdNwk4FV.js → w3m-modal-DYYWuCzk.js} +1 -1
  132. package/dist/assets/{wallet-DKsa0YqH.js → wallet-ctGTkC8h.js} +2 -2
  133. package/dist/assets/{wallet-placeholder-DAigD97U.js → wallet-placeholder-CMKbW-yz.js} +2 -2
  134. package/dist/assets/{walletconnect-CKlXyEvq.js → walletconnect-Cyg39b3w.js} +3 -3
  135. package/dist/assets/warning-circle-D9mA3kC3.js +12 -0
  136. package/dist/assets/{x-D7Opg1tU.js → x-DVGEd37g.js} +2 -2
  137. package/dist/index.html +2 -2
  138. package/package.json +3 -3
  139. package/dist/assets/Activity-DmBxVhX7.js +0 -1
  140. package/dist/assets/Audit-xjujDcFx.js +0 -1
  141. package/dist/assets/ChannelClose-DBF_JUwr.js +0 -1
  142. package/dist/assets/Chat-CUWxcJqH.css +0 -1
  143. package/dist/assets/Chat-T0qS59Xu.js +0 -220
  144. package/dist/assets/DataTable-C7t_4-zX.js +0 -1
  145. package/dist/assets/KeyHolder-BFM8S7rC.js +0 -1
  146. package/dist/assets/Keys-DrSAHaHB.js +0 -1
  147. package/dist/assets/Logs-BsAM5FMh.js +0 -1
  148. package/dist/assets/Members-Dt4m03ab.js +0 -1
  149. package/dist/assets/Models-DjTeLItT.js +0 -1
  150. package/dist/assets/OperatorActions-BZHwECbE.js +0 -1
  151. package/dist/assets/PolicyEditor-Gmmqb9Cc.js +0 -1
  152. package/dist/assets/Presets-DbjhaVl4.js +0 -4
  153. package/dist/assets/Providers-DwVfGgZj.js +0 -1
  154. package/dist/assets/Rewards-DJj-p9Np.js +0 -2
  155. package/dist/assets/RewardsClaim-Bswnd4Du.js +0 -1
  156. package/dist/assets/Routing-LfYjjbov.js +0 -1
  157. package/dist/assets/Settings-CPqBAsTx.js +0 -7
  158. package/dist/assets/Wallet-ByJgGxqY.js +0 -9
  159. package/dist/assets/WalletConfirm-DLpdkgEI.js +0 -1
  160. package/dist/assets/WalletFunding-C5dOeiPL.js +0 -1
  161. package/dist/assets/WalletSignIn-Cq__V2L6.js +0 -1
  162. package/dist/assets/Workspaces-CYixrYxE.js +0 -1
  163. package/dist/assets/all-wallets-DhpA95KH.js +0 -6
  164. package/dist/assets/ant-icon-zZhiTevn.svg +0 -25
  165. package/dist/assets/arrow-bottom-CeDSRmNE.js +0 -8
  166. package/dist/assets/arrow-left-DUoqf10U.js +0 -8
  167. package/dist/assets/arrow-right-DHoa2pF7.js +0 -8
  168. package/dist/assets/arrow-top-BR-QE9T9.js +0 -8
  169. package/dist/assets/ccip-DIM-P7wd.js +0 -1
  170. package/dist/assets/chevron-bottom-CxXQ-qE-.js +0 -8
  171. package/dist/assets/chevron-left-CNg3LJR0.js +0 -8
  172. package/dist/assets/chevron-right-BEgGXp3W.js +0 -8
  173. package/dist/assets/chevron-top-DTt9-y9n.js +0 -8
  174. package/dist/assets/close-KGY7xRXQ.js +0 -8
  175. package/dist/assets/coinPlaceholder-D5WWISbz.js +0 -8
  176. package/dist/assets/cursor-CWTguKCx.js +0 -3
  177. package/dist/assets/external-link-CgBWYupV.js +0 -8
  178. package/dist/assets/filters-DjumokIU.js +0 -8
  179. package/dist/assets/highlighted-body-KQOG7T2V-DZDubho7.js +0 -1
  180. package/dist/assets/index-9dOi2Cir.js +0 -1
  181. package/dist/assets/index-CAEBOGcb.js +0 -1
  182. package/dist/assets/index-CqEPMnZS.css +0 -1
  183. package/dist/assets/index-jbhwAQ05.js +0 -91
  184. package/dist/assets/info-circle-B1UBH84l.js +0 -12
  185. package/dist/assets/more-dZBFgnEq.js +0 -11
  186. package/dist/assets/off-DIVE_Apr.js +0 -8
  187. package/dist/assets/refresh-CcEqjcUE.js +0 -8
  188. package/dist/assets/search-D5f3v5zH.js +0 -8
  189. package/dist/assets/warning-circle-W9Rnd_B_.js +0 -12
@@ -1 +0,0 @@
1
- import{r as h,j as n,B as E}from"./index-jbhwAQ05.js";import{r as D}from"./index-9dOi2Cir.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{a1 as v,a2 as N,d as g,q as k,j as e,a3 as q,a4 as x,a5 as w,B as R,I as S,P as B,t as y,a6 as E,S as P,a7 as _,f as n,k as d,Q as I,V as A,g as D,a8 as K,a9 as L,z as O,l as c,e as j,aa as T}from"./index-jbhwAQ05.js";import{R as F}from"./RequestLog-DFYOMsBa.js";import{r as z,e as M}from"./usage-AvFyjxl-.js";import{B as Q}from"./Charts-BjppB8Po.js";import"./useInfiniteQuery-Dn0V4FRG.js";import"./DataTable-C7t_4-zX.js";import"./index-9dOi2Cir.js";function W(){var m;const h=v(),u=N(),s=((m=u.data)==null?void 0:m.kind)==="key"?u.data.me.key:null,l=Date.now(),o=z("30d",l),f=g({queryKey:k.usage({key:s==null?void 0:s.id,from:o,groupBy:"day"}),queryFn:()=>j.usage.report({key:s.id,from:o,to:l,groupBy:"day"}),enabled:!!s}),b=g({queryKey:["key-periods",s==null?void 0:s.id],enabled:!!s,queryFn:async()=>{const a=await Promise.all(["daily","weekly","monthly"].map(async i=>{const t=await j.usage.report({key:s.id,from:T(i,l)});return[i,c(t.totals.spent)]}));return Object.fromEntries([...a,["total",c(s.usage.spent)]])}});return e.jsxs("div",{className:"gc-keyholder",children:[e.jsxs("header",{className:"gc-topbar",children:[e.jsxs("div",{className:"gc-topbar__inner",children:[e.jsx(q,{to:null,tagged:!0}),e.jsx("div",{className:"gc-topbar__spacer"}),e.jsx(x,{className:"gc-endpoint--inline"}),e.jsx(w,{}),e.jsx(R,{variant:"outline",size:"sm",leadingIcon:e.jsx(S.logout,{size:14}),onClick:()=>void h(),children:"Sign out"})]}),e.jsx("div",{className:"gc-topbar__strip",children:e.jsx(x,{})})]}),e.jsx("main",{className:"gc-main",id:"gc-main",children:s&&e.jsxs("div",{className:"gc-page",children:[e.jsx(B,{title:s.label,description:e.jsxs(e.Fragment,{children:["Key ",e.jsx("code",{children:s.hint})," · ",s.status==="active"?e.jsx(y,{tone:"success",children:"Active"}):e.jsx(y,{tone:"danger",children:"Revoked"})]})}),e.jsx("div",{className:"gc-grid gc-grid--4",children:E.map(a=>{var p;const i=s.limits[a],t=((p=b.data)==null?void 0:p[a])??null,r=i===null?null:c(i);return e.jsx(P,{label:`${_[a]} spend`,value:t===null?"…":n(t),sub:r===null?"No limit":`${n(Math.max(r-(t??0),0))} left of ${n(r)}`,meter:r&&t!==null?t/r:null},a)})}),e.jsx(d,{title:"Spend, last 30 days",children:e.jsx(I,{query:f,rows:1,children:a=>e.jsx(Q,{format:n,label:"Daily spend",points:M(a,o,l)})})}),e.jsx(d,{title:"Key details",children:e.jsx(A,{items:[["Requests",D(s.usage.requests)],["Spent in total",n(s.usage.spent)],["Last used",K(s.lastUsedAt)],["Expires",s.expiresAt?L(s.expiresAt):"Never"],["Top-ups",s.topupEnabled?"Allowed":"Off"],["Routing",O(s.routingPolicy)]]})}),e.jsx(d,{flush:!0,title:"Requests",children:e.jsx(F,{filter:{key:s.id},showKey:!1})})]})})]})}export{W as default};
@@ -1 +0,0 @@
1
- import{ad as ke,r as m,aD as je,aE as fe,j as s,A as ne,aF as ve,W as Se,B as S,u as le,a as Ce,i as ce,c as de,b as Pe,s as ie,P as Le,I as K,T as F,k as Ne,Q as Ae,aG as Ee,y as ue,aH as J,z as me,f as ye,l as Te,a8 as Re,E as Z,aI as pe,C as De,q as U,e as C,t as v,a9 as X,d as Ie,aJ as Me,aK as Ke,aL as Fe,aM as ee,n as Ue,V as _e}from"./index-jbhwAQ05.js";import{u as se,a as Oe,P as Be}from"./PolicyField-B3b2T_KJ.js";import{T as Ye}from"./Tabs-eMKdE-iz.js";import{l as te,d as ae,L as We}from"./limits-CE9uA1mE.js";import{t as qe}from"./dates-Pi3-Ywng.js";import{r as ze,e as $e}from"./usage-AvFyjxl-.js";import{S as he}from"./Switch-BasD00zg.js";import{D as Ve,u as He,P as Ge}from"./DataTable-C7t_4-zX.js";import{b as Qe}from"./Charts-BjppB8Po.js";import{S as Je}from"./SelectField-DgDdipP1.js";import"./PolicyEditor-Gmmqb9Cc.js";import"./Segmented-JCEKIWY7.js";import"./roving-DkptacxO.js";import"./Disclosure-CYz0evEi.js";import"./index-9dOi2Cir.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Ye,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Xe="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=ze(Xe,l),c=Ie({queryKey:U.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Qe,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:$e(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${X(e.expiresAt)}`,children:["Until ",X(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(_e,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx(We,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Be,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var z;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[b,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState(qe((e==null?void 0:e.expiresAt)??null)),[x,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,g]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),ge=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((z=ge.data)==null?void 0:z.buyerIdentity))==="default",O=de(y.id,a&&!e),R=Oe(),[B,Y]=m.useState(null),D=p.admin,W=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let q=null;T&&(q=p.admin?"Your restrictions as the key owner":"Your restrictions");const xe=e?"Save":"Create key",be=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,$=D?w.build():null,V=W?t.build():null,H=ae(b),G=ae(L);if(e){const f=Fe(p,e,{label:h.trim(),expiresAt:u,topupEnabled:x,adminLimits:H,adminPolicy:$,ownerLimits:G,ownerPolicy:V}),Q=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return Q===ee?ee:{key:Q}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:G,routingPolicy:p.admin?$:V,topupEnabled:p.admin?x:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[U.group("keys")],toast:u=>u.secret?null:"Key saved",onError:Y});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),Y(null),I.mutate()},children:[s.jsx(F,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&O.data&&s.jsx(Je,{label:"Owner",value:n,onChange:g,options:O.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:T?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:b,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&T&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),W&&s.jsx(oe,{title:q,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:be,policy:t}),T&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(F,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:x,onChange:E,disabled:_&&!x,label:"Allow top-ups",description:_?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),B?s.jsx(Ue,{error:B,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":xe})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=He(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(Ge,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,b]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),x=ie({mutationFn:async({kind:n,key:g})=>{n==="rotate"?h(await C.keys.rotate(g.id)):await C.keys.revoke(g.id)},onSuccess:()=>b(null),invalidate:[U.group("keys")],toast:(n,{kind:g})=>g==="revoke"?"Key revoked":null}),E=n=>{var g,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(g=d.data)==null?void 0:g.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(F,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:E,render:(g,w)=>s.jsx(Ve,{label:"API keys",rows:g,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>b({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>b({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Ee,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:E},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(J(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(J(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Te(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:x.isPending,error:x.error,onClose:()=>{b(null),x.reset()},onConfirm:()=>k&&x.mutate(k),...os(k)})]})}export{js as default};
@@ -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-jbhwAQ05.js";import{R as B}from"./RequestLog-DFYOMsBa.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-DgDdipP1.js";import"./useInfiniteQuery-Dn0V4FRG.js";import"./usage-AvFyjxl-.js";import"./DataTable-C7t_4-zX.js";import"./index-9dOi2Cir.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-jbhwAQ05.js";import{u as xe,a as je,P as ye}from"./PolicyField-B3b2T_KJ.js";import{l as ke,d as fe,L as we}from"./limits-CE9uA1mE.js";import{D as Y}from"./DataTable-C7t_4-zX.js";import{S as O}from"./SelectField-DgDdipP1.js";import"./PolicyEditor-Gmmqb9Cc.js";import"./Segmented-JCEKIWY7.js";import"./roving-DkptacxO.js";import"./Switch-BasD00zg.js";import"./Disclosure-CYz0evEi.js";import"./index-9dOi2Cir.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-jbhwAQ05.js";import{T as J,a as ee}from"./Tabs-eMKdE-iz.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-g5FVBi3I.js";import{S as T}from"./SelectField-DgDdipP1.js";import{S as ce}from"./Switch-BasD00zg.js";import{D as de}from"./DataTable-C7t_4-zX.js";import"./roving-DkptacxO.js";import"./index-9dOi2Cir.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-jbhwAQ05.js";import{u as K,a as V,T as X,D as k,s as Z}from"./useTx-B_KdxpeJ.js";import{a as ge,C as G}from"./ConnectWallet-Ba-nE-Ex.js";import{W as me,u as J,c as L,b as ye,r as Q}from"./en_US-Y4ZOVFV4-C1wt0O8b.js";import"./clsx-B-dksMZM.js";import"./index-9dOi2Cir.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 J,v as Y,r as b,j as e,bi as k,I as P,bj as F,B as y,b3 as X,bk as Z,b7 as ee,bc as K,bl as se,bm as A,bn as le,bo as E,T as D,C as ie,bp as U,bg as ne,bq as ae,ac as te,br as ce,bs as re,bt as oe,b5 as de}from"./index-jbhwAQ05.js";import{S as T}from"./SelectField-DgDdipP1.js";import{S as V}from"./Segmented-JCEKIWY7.js";import{S as L}from"./Switch-BasD00zg.js";import{D as R}from"./Disclosure-CYz0evEi.js";function C(l,c){const a=l==null?void 0:l.find(o=>J(o.peerId,c));return(a==null?void 0:a.displayName)??Y(c,8,4)}function z({value:l,onChange:c,peers:a,label:o,ordered:d,placeholder:t="Search sellers or paste a peer id"}){const[m,g]=b.useState(""),j=b.useId(),h=b.useId();function r(){const n=m.trim();if(!n)return;const p=a==null?void 0:a.find(x=>{var i;return((i=x.displayName)==null?void 0:i.toLowerCase())===n.toLowerCase()||x.peerId.toLowerCase()===n.toLowerCase()}),N=(p==null?void 0:p.peerId)??n;l.some(x=>x.toLowerCase()===N.toLowerCase())||c([...l,N]),g("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:h,children:o}),l.length>0&&e.jsx("ol",{className:d?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((n,p)=>e.jsxs("li",{className:"gc-chip",children:[d&&e.jsx("span",{className:"gc-chip__index",children:p+1}),e.jsx("span",{className:"gc-chip__label",title:n,children:C(a,n)}),d&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:`Move ${C(a,n)} up`,size:"sm",disabled:p===0,onClick:()=>c(F(l,p,-1)),children:e.jsx(P.up,{size:12})}),e.jsx(k,{label:`Move ${C(a,n)} down`,size:"sm",disabled:p===l.length-1,onClick:()=>c(F(l,p,1)),children:e.jsx(P.down,{size:12})})]}),e.jsx(k,{label:`Remove ${C(a,n)}`,size:"sm",onClick:()=>c(l.filter(N=>N!==n)),children:e.jsx(P.x,{size:12})})]},n))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:h,className:"as-field__input gc-picker__input",list:j,value:m,placeholder:t,onChange:n=>g(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),r())}}),e.jsx("datalist",{id:j,children:a==null?void 0:a.map(n=>e.jsx("option",{value:n.peerId,children:n.displayName??Y(n.peerId)},n.peerId))}),e.jsx(y,{variant:"outline",size:"sm",onClick:r,disabled:!m.trim(),children:"Add"})]})]})}function me({value:l,onChange:c,label:a,suggestions:o,placeholder:d}){const[t,m]=b.useState(""),g=b.useId(),j=b.useId();function h(){const r=t.trim();r&&!l.includes(r)&&c([...l,r]),m("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:j,children:a}),l.length>0&&e.jsx("ul",{className:"gc-chips",children:l.map(r=>e.jsxs("li",{className:"gc-chip",children:[e.jsx("span",{className:"gc-chip__label",children:r}),e.jsx(k,{label:`Remove ${r}`,size:"sm",onClick:()=>c(l.filter(n=>n!==r)),children:e.jsx(P.x,{size:12})})]},r))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:j,className:"as-field__input gc-picker__input",list:g,value:t,placeholder:d,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),h())}}),e.jsx("datalist",{id:g,children:o==null?void 0:o.map(r=>e.jsx("option",{value:r},r))}),e.jsx(y,{variant:"outline",size:"sm",onClick:h,disabled:!t.trim(),children:"Add"})]})]})}function he({draft:l,parent:c,above:a,peers:o,lists:d}){const t=b.useMemo(()=>{if(!o||o.length===0)return null;let m;try{m=ne(l,d)}catch{return null}return{matched:ae(K(c,m),o,d).length,total:o.length}},[l,c,o,d]);return t?t.matched===0?e.jsxs(te,{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 fe({value:l,onChange:c,peers:a,lists:o,showTemplates:d=!0,parent:t,disabled:m}){const[g,j]=b.useState(""),[h,r]=b.useState(null),n=(s,u)=>c({...l,[s]:u}),p=X(a),N=o.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),x=Z(ee().data),i=b.useMemo(()=>x||t?K(x,t):null,[x,t]),Q=x&&t?"the buyer config and the levels above":x?"the buyer config":t?"the levels above":"",$=s=>(x==null?void 0:x[s])!==void 0&&x[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",G=se(a)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var O;let u;if(s==="own"){const w=o.find(H=>H.id===g);if(!w)return;u={allowMode:"only",allowedPeerIds:[],allowedListIds:[w.id]}}else u=ce(re(s));const f=oe(l,u),_=((O=A.find(w=>w.id===s))==null?void 0:O.label)??s;f.length>0?r({label:_,template:u,conflicts:f}):c(U(l,u))}function M(s,u){n("routes",l.routes.map((f,_)=>_===s?u:f))}const S=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,I=(s,u)=>e.jsx(D,{size:"sm",className:"gc-num",label:u,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${de(i[s])} above`:"No cap",onChange:f=>n(s,f.target.value)}),v=e.jsxs(e.Fragment,{children:[e.jsx(he,{draft:l,parent:i,above:Q,peers:a,lists:o}),d&&!m&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(y,{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(T,{size:"sm","aria-label":"Peer list for Own peers only",value:g,onChange:j,options:[{value:"",label:"Own peer list…"},...N]}),e.jsx(y,{size:"sm",variant:"outline",disabled:!g,onClick:()=>q("own"),children:"Use"})]}),e.jsx(y,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>c(le()),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=>n("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>n("allowedPeerIds",s),peers:a}),e.jsx(W,{label:"Allowed peer lists",lists:o,value:l.allowedListIds,onChange:s=>n("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(z,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>n("blockedPeerIds",s),peers:a}),e.jsx(W,{label:"Blocked peer lists",lists:o,value:l.blockedListIds,onChange:s=>n("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(B,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>n("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:$("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(L,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>n("requireTee",s),label:"TEE sellers only"}),e.jsx(L,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>n("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(T,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>n("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(E).map(s=>({value:s,label:E[s]}))]}),e.jsx(T,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>n("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=>n("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(me,{label:"Allowed models",value:l.allowedModels,onChange:s=>n("allowedModels",s),suggestions:p,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:S?`${S} set`:"None",defaultOpen:m&&S>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[I("maxInputUsdPerMillion","Input $/M"),I("maxOutputUsdPerMillion","Output $/M"),I("maxCachedInputUsdPerMillion","Cached input $/M"),I("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:m&&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(D,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:f=>M(u,{...s,model:f.target.value})}),e.jsx(L,{checked:s.strict,onChange:f=>M(u,{...s,strict:f}),label:"Strict"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>n("routes",l.routes.filter((f,_)=>_!==u)),children:"Remove"})]}),e.jsx(z,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:f=>M(u,{...s,peerIds:f}),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(y,{variant:"outline",size:"sm",onClick:()=>n("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),G&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:m&&l.minReputation!=="",children:e.jsx(B,{label:"Minimum reputation",value:l.minReputation,onChange:s=>n("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:$("minReputation")})})]}),e.jsx(ie,{isOpen:h!==null,tone:"primary",title:`Apply “${(h==null?void 0:h.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:h==null?void 0:h.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>r(null),onConfirm:()=>{h&&c(U(l,h.template)),r(null)}})]});return m?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:v}):e.jsx("div",{className:"gc-policy",children:v})}function B({label:l,value:c,onChange:a,clearable:o=!0,hint:d,floor:t,floorSource:m="The levels above"}){const g=b.useId(),j=c!=="",h=t!==void 0&&t>0,r=h&&j&&Number(c)<=t,n=j?c:h?`${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:g,children:l}),e.jsx("span",{className:j?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:n})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:j?Number(c):h?t:0,"aria-labelledby":g,onChange:p=>a(p.target.value)}),o&&j&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>a(""),children:"Clear"})]}),r?e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx("span",{className:"gc-attention","aria-hidden":"true"}),m," already requires ≥ ",t,". No effect."]}):h&&e.jsxs("span",{className:"as-field__hint",children:[m," requires ≥ ",t,". Only a higher value narrows it."]}),d&&e.jsx("span",{className:"as-field__hint",children:d})]})}function W({label:l,lists:c,value:a,onChange:o}){return c.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),c.map(d=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:a.includes(d.id),onChange:t=>o(t.target.checked?[...a,d.id]:a.filter(m=>m!==d.id))}),d.name," ",e.jsxs("span",{className:"gc-muted",children:["(",d.peerIds.length,")"]})]},d.id))]})}export{fe as P,B as S,z as a,C as p};
@@ -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-jbhwAQ05.js";import{u as Y,a as Z,P as ee}from"./PolicyField-B3b2T_KJ.js";import{D as se}from"./DataTable-C7t_4-zX.js";import{S as re}from"./SelectField-DgDdipP1.js";import{T as N}from"./TextAreaField-DeGuklpV.js";import"./PolicyEditor-Gmmqb9Cc.js";import"./Segmented-JCEKIWY7.js";import"./roving-DkptacxO.js";import"./Switch-BasD00zg.js";import"./Disclosure-CYz0evEi.js";import"./index-9dOi2Cir.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,bl 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-jbhwAQ05.js";import{p as Q,a as xs}from"./PolicyEditor-Gmmqb9Cc.js";import{S as A}from"./SelectField-DgDdipP1.js";import{D as Le}from"./DataTable-C7t_4-zX.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-g5FVBi3I.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-DbjhaVl4.js";import{T as Is,a as Ns}from"./Tabs-eMKdE-iz.js";import{S as W}from"./Switch-BasD00zg.js";import"./Segmented-JCEKIWY7.js";import"./roving-DkptacxO.js";import"./Disclosure-CYz0evEi.js";import"./index-9dOi2Cir.js";import"./PolicyField-B3b2T_KJ.js";import"./TextAreaField-DeGuklpV.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,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-Bswnd4Du.js","assets/index-jbhwAQ05.js","assets/index-CqEPMnZS.css","assets/ants-B38m9Phv.js","assets/useTx-B_KdxpeJ.js","assets/en_US-Y4ZOVFV4-C1wt0O8b.js","assets/clsx-B-dksMZM.js","assets/index-9dOi2Cir.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/ConnectWallet-Ba-nE-Ex.js","assets/OperatorGateAlert-DAmQCyeN.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-jbhwAQ05.js";import{C as O}from"./ChainGate-B_PADueu.js";import{f as r,a as $}from"./ants-B38m9Phv.js";import{D as B}from"./DataTable-C7t_4-zX.js";import"./index-9dOi2Cir.js";const H=c.lazy(()=>K(()=>import("./RewardsClaim-Bswnd4Du.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-jbhwAQ05.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-B_KdxpeJ.js";import{a as _}from"./ConnectWallet-Ba-nE-Ex.js";import{O as W}from"./OperatorGateAlert-DAmQCyeN.js";import{W as G,u as L,c as P}from"./en_US-Y4ZOVFV4-C1wt0O8b.js";import"./clsx-B-dksMZM.js";import"./index-9dOi2Cir.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-jbhwAQ05.js";import{b as Z,a as je,d as be}from"./PolicyField-B3b2T_KJ.js";import{p as Y,P as ke}from"./PolicyEditor-Gmmqb9Cc.js";import{S as U}from"./SelectField-DgDdipP1.js";import{D as Pe}from"./DataTable-C7t_4-zX.js";import{T as Se,a as Ne}from"./Tabs-eMKdE-iz.js";import"./Segmented-JCEKIWY7.js";import"./roving-DkptacxO.js";import"./Switch-BasD00zg.js";import"./Disclosure-CYz0evEi.js";import"./index-9dOi2Cir.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};
@@ -1,7 +0,0 @@
1
- import{D as re,F as ne,b2 as ge,b9 as xe,r as d,bf as ae,q,e as E,bq as ve,bc as be,b5 as K,f as fe,j as t,ac as D,bl as ye,T as O,B as y,n as $,C as ie,d as Se,P as je,Q as z,ad as we,k as A,V as le,M as ke,t as M,u as Pe,R as Re,s as Q,aG as Ne,a9 as W,aP as Ce,a8 as Me,E as Ie,I as G,A as Y,aF as qe,Y as Ue}from"./index-jbhwAQ05.js";import{a as J,S as Z}from"./PolicyEditor-Gmmqb9Cc.js";import{S as Te}from"./Segmented-JCEKIWY7.js";import{S as I}from"./Switch-BasD00zg.js";import{D as F}from"./Disclosure-CYz0evEi.js";import{T as oe}from"./TextAreaField-DeGuklpV.js";import{T as Oe,a as Ee}from"./Tabs-eMKdE-iz.js";import{D as Ae}from"./DataTable-C7t_4-zX.js";import{S as B}from"./SelectField-DgDdipP1.js";import"./roving-DkptacxO.js";import"./index-9dOi2Cir.js";function Fe(e){return Object.entries(e).map(([s,r])=>`${s}: ${r}`).join(`
2
- `)}function De(e){const s={};for(const[r,a]of e.split(`
3
- `).entries()){if(!a.trim())continue;const c=a.indexOf(":");if(c<=0)throw new Error(`Line ${r+1}: use "Name: value".`);const u=a.slice(0,c).trim();if(!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(u))throw new Error(`Line ${r+1}: "${u}" is not a valid header name.`);s[u]=a.slice(c+1).trim()}return s}const ce="••••";function $e(e){return e.split(`
4
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?s.slice(0,r).trim():null}).filter(s=>!!s)}function X(e){return e.split(`
5
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?`${s.slice(0,r)}: `:s}).join(`
6
- `)}function _e(e,s){if(!e||!s)return!1;try{return new URL(e).origin!==new URL(s).origin}catch{return e!==s}}function Le(e){const s={},r=(a,c,u)=>{const n=e[a].trim();if(n===""){c&&(s[a]="Required.");return}const h=Number(n);!Number.isFinite(h)||h<0?s[a]="Use a number of 0 or more.":u!==void 0&&h>u&&(s[a]=`At most ${u}.`)};return r("input",!0),r("output",!0),r("cached",!1),r("reputation",!0,100),s}function w(e,s={}){const r=e.trim();if(r==="")return s.required?"Required.":void 0;const a=Number(r),c=s.min??0;if(!Number.isFinite(a))return"Use a number.";if(s.integer&&!Number.isInteger(a))return"Use a whole number.";if(a<c)return`Use ${c} or more.`;if(s.max!==void 0&&a>s.max)return`At most ${s.max}.`}function V(e){return e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)}function ee(e){const s=e.find(r=>!/^(?:0x)?[0-9a-f]{40}$/i.test(r));return s?`"${s}" is not a 40-character hex seller id.`:void 0}function te(e){const s=e.find(r=>!/^https?:\/\/\S+$/.test(r));return s?`"${s}" is not an http(s) URL.`:void 0}function ue(e,s){return e.some(r=>r===s||s.startsWith(`${r}.`)||r.startsWith(`${s}.`))}function Be(){return t.jsxs("span",{className:"gc-override",children:[t.jsx("span",{className:"gc-attention","aria-hidden":"true"}),"Overridden by the buyer's environment or start flags"]})}function se(e){const s=e.routingPreferences,r=a=>a===null?"":String(a);return{allowMode:s.allowedPeerIds.length>0?"only":"any",allowedPeerIds:[...s.allowedPeerIds],blockedPeerIds:[...s.blockedPeerIds],minTrustScore:String(s.minTrustScore),minReputation:String(e.minPeerReputation),preferFree:s.preferFreePeers,softInputCap:String(s.maxInputUsdPerMillion),maxInput:String(e.maxPricing.inputUsdPerMillion),maxOutput:String(e.maxPricing.outputUsdPerMillion),maxCached:r(e.maxPricing.cachedInputUsdPerMillion),verify:e.verifier.enabled,requireVerified:e.verifier.require,verifiers:e.verifier.prefer.join(", "),sampleRate:r(e.evidence.sampleRate),maxSampleBytes:r(e.evidence.maxSampleBytes),autoSweep:e.payments.autoSweep,maxPerRequest:String(e.payments.maxPerRequestUsdc),maxReserve:String(e.payments.maxReserveUsdc),rpcUrl:e.payments.rpcUrl??"",fallbackRpcUrls:e.payments.fallbackRpcUrls.join(`
7
- `),peerRefreshMs:String(e.network.peerRefreshIntervalMs),metadataTimeoutMs:String(e.network.metadataFetchTimeoutMs),requestTimeoutMs:String(e.network.requestTimeoutMs),maxStreamMs:String(e.network.maxStreamDurationMs),perServiceMetadata:!e.network.disableMetadataV2Services}}function Ve(e){const s=Le({input:e.maxInput,output:e.maxOutput,cached:e.maxCached,reputation:e.minReputation}),r={maxInput:s.input,maxOutput:s.output,maxCached:s.cached,softInputCap:w(e.softInputCap,{required:!0}),allowedPeerIds:e.allowMode==="only"?ee(e.allowedPeerIds):void 0,blockedPeerIds:ee(e.blockedPeerIds),sampleRate:w(e.sampleRate,{max:1}),maxSampleBytes:w(e.maxSampleBytes,{min:1,integer:!0}),maxPerRequest:w(e.maxPerRequest,{required:!0,min:1e-6}),maxReserve:w(e.maxReserve,{required:!0,min:1e-6}),rpcUrl:e.rpcUrl.trim()?te([e.rpcUrl.trim()]):void 0,fallbackRpcUrls:te(V(e.fallbackRpcUrls)),peerRefreshMs:w(e.peerRefreshMs,{required:!0,min:1e3,integer:!0}),metadataTimeoutMs:w(e.metadataTimeoutMs,{required:!0,min:100,integer:!0}),requestTimeoutMs:w(e.requestTimeoutMs,{required:!0,min:1,integer:!0}),maxStreamMs:w(e.maxStreamMs,{required:!0,min:1,integer:!0})};return Object.fromEntries(Object.entries(r).filter(([,a])=>a))}function ze(e){const s=r=>r.trim()?Number(r):null;return{routingPreferences:{minTrustScore:Number(e.minTrustScore),maxInputUsdPerMillion:Number(e.softInputCap),preferFreePeers:e.preferFree,allowedPeerIds:e.allowMode==="only"?e.allowedPeerIds:[],blockedPeerIds:e.blockedPeerIds},maxPricing:{inputUsdPerMillion:Number(e.maxInput),outputUsdPerMillion:Number(e.maxOutput),cachedInputUsdPerMillion:s(e.maxCached)},minPeerReputation:Number(e.minReputation),verifier:{enabled:e.verify,require:e.verify&&e.requireVerified,prefer:e.verify?V(e.verifiers):[]},evidence:{sampleRate:s(e.sampleRate),maxSampleBytes:s(e.maxSampleBytes)},payments:{autoSweep:e.autoSweep,maxPerRequestUsdc:Number(e.maxPerRequest),maxReserveUsdc:Number(e.maxReserve),rpcUrl:e.rpcUrl.trim()||null,fallbackRpcUrls:V(e.fallbackRpcUrls)},network:{peerRefreshIntervalMs:Number(e.peerRefreshMs),metadataFetchTimeoutMs:Number(e.metadataTimeoutMs),requestTimeoutMs:Number(e.requestTimeoutMs),maxStreamDurationMs:Number(e.maxStreamMs),disableMetadataV2Services:!e.perServiceMetadata}}}const He=["allowMode","allowedPeerIds","blockedPeerIds","minTrustScore","preferFree","softInputCap"];function L(e,s){return Object.keys(s).filter(r=>JSON.stringify(e[r])!==JSON.stringify(s[r]))}function Ke(e){const s=r=>r.trim()&&Number.isFinite(Number(r))?Number(r):void 0;return{...e.allowMode==="only"&&e.allowedPeerIds.length>0?{allowedPeerIds:e.allowedPeerIds}:{},...e.blockedPeerIds.length>0?{blockedPeerIds:e.blockedPeerIds}:{},...s(e.minTrustScore)?{minTrustScore:s(e.minTrustScore)}:{},...s(e.minReputation)?{minReputation:s(e.minReputation)}:{},...s(e.maxInput)!==void 0?{maxInputUsdPerMillion:s(e.maxInput)}:{},...s(e.maxOutput)!==void 0?{maxOutputUsdPerMillion:s(e.maxOutput)}:{},...s(e.maxCached)!==void 0?{maxCachedInputUsdPerMillion:s(e.maxCached)}:{}}}function Qe({buyer:e}){const s=re(),r=ne(),a=ge(),c=xe(),u=d.useMemo(()=>se(e),[e]),[n,h]=d.useState(u),[k,P]=d.useState(u),[v,S]=d.useState(null),[b,p]=d.useState(!1),[j,g]=d.useState(!1),l=(i,R)=>h(N=>({...N,[i]:R})),m=i=>{h(i),P(i),S(null)},o=Ve(n),U=L(k,n);d.useEffect(()=>{L(k,u).length!==0&&(U.length===0||L(u,n).length===0?m(u):S(u))},[u]);const _=U.some(i=>!He.includes(i)),C=i=>ue(e.overrides,i)?t.jsx(Be,{}):void 0,H=(i,R)=>C(i)??R,f=ae({mutationFn:()=>E.settings.updateBuyer(ze(n)),onSuccess:i=>{const{restartRequired:R,...N}=i;s.setQueryData(q.settings,N),m(se(N.buyer)),s.invalidateQueries({queryKey:q.buyerLimits}),p(!1),g(R===!0),r(_?R?"Saved. Restart the buyer to apply them.":"Saved. The buyer is restarting.":"Saved. The buyer applies these at once.")}}),T=d.useMemo(()=>!a.data||a.data.length===0?null:{matched:ve(be(Ke(n)),a.data,c.data??[]).length,total:a.data.length},[n,a.data,c.data]),de=`${K(Number(n.maxInput))} in · ${K(Number(n.maxOutput))} out`,me=n.verify?n.requireVerified?"Required":"On":"Off",pe=`${n.autoSweep?"Auto-sweep on":"Auto-sweep off"} · ${fe(Number(n.maxPerRequest))} per request`,x=(i,R,N={})=>t.jsx(O,{size:"sm",className:N.className??"gc-num",label:R,inputMode:"decimal",placeholder:N.placeholder,value:n[i],error:o[i],hint:N.hint,onChange:he=>l(i,he.target.value)});return t.jsxs("div",{className:"gc-stack",children:[t.jsxs("div",{className:"gc-policy",children:[T&&(T.matched===0?t.jsxs(D,{tone:"warning",title:"No seller matches these settings",children:["None of the ",T.total," sellers this gateway sees passes them, so every request will fail."]}):t.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",T.matched," of ",T.total," sellers. Every key can only narrow this."]})),t.jsxs("div",{className:"gc-policy__cols",children:[t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Sellers"}),t.jsx(Te,{label:"Which sellers may serve",value:n.allowMode,onChange:i=>l("allowMode",i),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),n.allowMode==="only"&&t.jsxs(t.Fragment,{children:[t.jsx(J,{label:"Allowed sellers",value:n.allowedPeerIds,onChange:i=>l("allowedPeerIds",i),peers:a.data}),o.allowedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.allowedPeerIds}),n.allowedPeerIds.length===0&&t.jsx("p",{className:"gc-fineprint",children:"With no sellers listed, any seller may serve."})]}),t.jsx(J,{label:"Blocked sellers",value:n.blockedPeerIds,onChange:i=>l("blockedPeerIds",i),peers:a.data}),o.blockedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.blockedPeerIds}),t.jsx("p",{className:"gc-fineprint",children:"Blocked here means blocked for every key."})]}),t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Quality and ranking"}),t.jsx(Z,{label:"Minimum trust score",clearable:!1,value:n.minTrustScore,onChange:i=>l("minTrustScore",i),hint:"Keys can raise it, not lower it."}),(ye(a.data)||n.minReputation!=="0")&&t.jsx(Z,{label:"Minimum reputation",clearable:!1,value:n.minReputation,onChange:i=>l("minReputation",i),hint:H("minPeerReputation","Applies to pinned sellers too.")}),t.jsx("div",{className:"gc-policy__switches",children:t.jsx(I,{checked:n.preferFree,onChange:i=>l("preferFree",i),label:"Free sellers first"})}),x("softInputCap","Soft input price limit $/M",{hint:"Pricier sellers rank lower; none is excluded.",className:"gc-num gc-num--wide"})]})]}),t.jsxs("div",{className:"gc-policy__advanced",children:[t.jsxs(F,{title:"Price caps",summary:de,children:[t.jsx("p",{className:"gc-fineprint",children:"Hard limits for every request, pinned sellers included."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxInput","Input $/M",{hint:C("maxPricing.inputUsdPerMillion")}),x("maxOutput","Output $/M",{hint:C("maxPricing.outputUsdPerMillion")}),x("maxCached","Cached input $/M",{placeholder:"Same as input"})]})]}),t.jsxs(F,{title:"Verification",summary:me,children:[C("verifier"),t.jsxs("div",{className:"gc-policy__switches",children:[t.jsx(I,{checked:n.verify,onChange:i=>l("verify",i),label:"Verify sellers"}),t.jsx(I,{checked:n.verify&&n.requireVerified,disabled:!n.verify,onChange:i=>l("requireVerified",i),label:"Require verification"})]}),t.jsx(O,{size:"sm",label:"Verifiers",value:n.verifiers,disabled:!n.verify,placeholder:"Seller's trusted default",hint:"Ordered, comma-separated verifier ids, e.g. TEE attestation.",onChange:i=>l("verifiers",i.target.value)}),t.jsxs("div",{className:"gc-policy__caps",children:[x("sampleRate","Evidence sample rate",{placeholder:"Default",hint:"Share of responses kept, 0 to 1."}),x("maxSampleBytes","Largest sample (bytes)",{placeholder:"Default",className:"gc-num gc-num--wide"})]})]}),t.jsxs(F,{title:"Payments",summary:pe,children:[t.jsx(I,{checked:n.autoSweep,onChange:i=>l("autoSweep",i),label:"Sweep deposits automatically",description:"Move USDC that arrives in the workspace wallets into their deposits."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxPerRequest","Max per request (USDC)",{className:"gc-num gc-num--wide"}),x("maxReserve","Max channel reserve (USDC)",{className:"gc-num gc-num--wide"})]}),t.jsx(O,{size:"sm",label:"Base RPC URL",value:n.rpcUrl,error:o.rpcUrl,placeholder:"Chain default",hint:H("payments.rpcUrl","Your own endpoint avoids public rate limits. Saved URLs show without their path; leave them as they are to keep them."),onChange:i=>l("rpcUrl",i.target.value)}),t.jsx(oe,{label:"Fallback RPC URLs",rows:2,mono:!0,value:n.fallbackRpcUrls,error:o.fallbackRpcUrls,hint:"One per line, tried in order.",onChange:i=>l("fallbackRpcUrls",i.target.value)})]}),t.jsxs(F,{title:"Network and timeouts",summary:`Refresh ${Math.round(Number(n.peerRefreshMs)/1e3)} s`,children:[t.jsxs("div",{className:"gc-policy__caps",children:[x("peerRefreshMs","Peer refresh (ms)",{className:"gc-num gc-num--wide"}),x("metadataTimeoutMs","Metadata timeout (ms)",{className:"gc-num gc-num--wide",hint:C("network.metadataFetchTimeoutMs")}),x("requestTimeoutMs","Response start timeout (ms)",{className:"gc-num gc-num--wide"}),x("maxStreamMs","Longest stream (ms)",{className:"gc-num gc-num--wide",hint:C("network.maxStreamDurationMs")})]}),t.jsx(I,{checked:n.perServiceMetadata,onChange:i=>l("perServiceMetadata",i),label:"Per-service attribution in signed metadata",description:C("network.disableMetadataV2Services")??"Tells sellers which service each request used."})]})]})]}),j&&t.jsxs(D,{tone:"warning",title:"Restart the buyer to apply",children:["Saved, but this buyer was not restarted automatically. Restart it (for example ",t.jsx("code",{children:"systemctl restart antseed-buyer"}),", or stop and start ",t.jsx("code",{children:"antseed buyer start"}),") to use the new settings."]}),v&&t.jsx(D,{tone:"warning",title:"Changed elsewhere",action:t.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[t.jsx(y,{size:"sm",variant:"outline",onClick:()=>m(v),children:"Reload"}),t.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{P(v),S(null)},children:"Keep editing"})]}),children:"Someone saved the buyer settings while you were editing them. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),!b&&f.error?t.jsx($,{error:f.error,title:"Could not save"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx("span",{className:"gc-fineprint gc-actions__note",children:U.length===0?"No changes.":_?"Saving restarts the buyer.":"Applies at once, without a restart."}),t.jsx(y,{variant:"ghost",disabled:U.length===0||f.isPending,onClick:()=>m(v??k),children:"Reset"}),t.jsx(y,{disabled:U.length===0||Object.keys(o).length>0||f.isPending,onClick:()=>_?p(!0):f.mutate(),children:f.isPending?"Saving…":"Save"})]}),t.jsx(ie,{isOpen:b,busy:f.isPending,error:f.error,onClose:()=>{p(!1),f.reset()},onConfirm:()=>f.mutate(),title:"Restart the buyer?",confirmLabel:"Save and restart",tone:"primary",body:"These changes need a buyer restart. Requests in flight finish first; new requests wait a few seconds while it reconnects."})]})}function We(){const e=we();return t.jsx(A,{title:"Gateway",children:t.jsx(z,{query:e,children:s=>t.jsx(le,{items:[["Public URL",s.publicUrl?t.jsx(ke,{children:s.publicUrl},"u"):t.jsx("span",{className:"gc-muted",children:"Not set. Clients use this console's address."})],["Version",s.version],["Buyer",s.buyer.reachable?t.jsx(M,{tone:"success",children:"Connected"},"b"):t.jsx(M,{tone:"danger",children:"Unreachable"},"b")],["Sellers seen",String(s.buyer.peers)],["Spend feed",s.spendFeed],["USDC top-ups (x402)",s.x402?"On":"Off"]]})})})}function Ge({settings:e}){const s=e.buyer;return t.jsx(A,{title:"Buyer",description:t.jsxs(t.Fragment,{children:["The top of every routing policy: workspaces, members, keys and presets can only narrow it. Saved to the config file of the buyer on port ",s.proxyPort,ue(s.overrides,"proxyPort")?" (set by its start flags)":"","."]}),children:t.jsx(Qe,{buyer:s})})}function Ye({settings:e}){const s=re(),r=ne(),a=e.observability,[c,u]=d.useState(a.otlpEndpoint??""),[n,h]=d.useState(Fe(a.otlpHeaders)),[k,P]=d.useState(a.logContent),[v,S]=d.useState(a.retentionDays===null?"":String(a.retentionDays)),b=c.trim()&&!/^https?:\/\/\S+$/.test(c.trim())?"Use an http:// or https:// URL.":void 0,p=_e(a.otlpEndpoint,c.trim()||null)?$e(n):[],j=p.length?`Enter the value of ${p.join(", ")} again: saved values are not sent to a new endpoint.`:void 0,g=ae({mutationFn:()=>{if(b)throw new Error(b);if(j)throw new Error(j);const l=v===""?null:Number(v);return E.settings.setObservability({otlpEndpoint:c.trim()||null,otlpHeaders:De(n),logContent:k,retentionDays:l})},onSuccess:l=>{const{restartRequired:m,...o}=l;s.setQueryData(q.settings,o),r(m?"Observability saved. Restart the gateway to apply it.":"Observability saved")},onError:l=>{Ue(l,"otlp_headers_required")&&h(X(n))}});return t.jsx(A,{title:"Observability",description:"Send one OpenTelemetry trace per request, and choose what the request log keeps.",children:t.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"OTLP/HTTP endpoint",placeholder:"https://otel.example.com/v1/traces",value:c,error:b,onChange:l=>u(l.target.value)}),t.jsx(oe,{label:"Headers",rows:3,mono:!0,placeholder:"Authorization: Bearer …",value:n,onChange:l=>h(l.target.value),error:j,hint:"One per line, as Name: value. Saved values show as ••••; leave them as they are to keep them (for the same endpoint only)."}),p.length>0&&t.jsx("div",{children:t.jsx(y,{size:"sm",variant:"outline",onClick:()=>h(X(n)),children:"Clear saved values to re-enter them"})}),t.jsx(I,{checked:k,onChange:P,label:"Store request and response bodies",description:"Off by default. Bodies can contain personal data; only turn this on if you need it."}),t.jsx(B,{label:"Keep the request log for",value:v,onChange:S,options:[{value:"7",label:"7 days"},{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},{value:"",label:"Forever"}]}),g.error?t.jsx($,{error:g.error,title:"Could not save"}):null,t.jsx("div",{className:"gc-actions",children:t.jsx(y,{type:"submit",disabled:g.isPending,children:g.isPending?"Saving…":"Save"})})]})})}function Je(){const{me:e}=Pe(),s=e.member.orgRole==="owner",r=Re(),[a,c]=d.useState(!1),[u,n]=d.useState(""),[h,k]=d.useState("read"),[P,v]=d.useState("90"),[S,b]=d.useState(null),[p,j]=d.useState(null),g=Q({mutationFn:()=>E.adminTokens.create(u.trim(),h,P==="never"?null:Number(P)),onSuccess:m=>{c(!1),n(""),b(m.secret)},invalidate:[q.adminTokens]}),l=Q({mutationFn:m=>E.adminTokens.revoke(m.id),onSuccess:()=>j(null),invalidate:[q.adminTokens]});return t.jsxs(A,{flush:!0,title:"Management tokens",description:t.jsxs(t.Fragment,{children:["For scripts and CI. Send as ",t.jsx("code",{children:"Authorization: Bearer …"})," to ",t.jsx("code",{children:"/console/api"}),"."]}),actions:t.jsx(y,{size:"sm",leadingIcon:t.jsx(G.plus,{size:14}),onClick:()=>c(!0),children:"New token"}),children:[t.jsx(z,{query:r,children:m=>t.jsx(Ae,{label:"Management tokens",rows:m,rowKey:o=>o.id,rowLabel:o=>o.label,actions:o=>[{label:"Revoke",tone:"danger",onSelect:()=>j(o)}],empty:t.jsx(Ie,{icon:t.jsx(G.keys,{size:18}),title:"No management tokens"}),columns:[{key:"label",header:"Name",render:o=>t.jsx(Ne,{name:o.label,hint:o.hint})},{key:"scope",header:"Scope",render:o=>o.scope==="admin"?t.jsx(M,{tone:"warning",children:"Admin"}):t.jsx(M,{children:"Read only"})},{key:"created",header:"Created",secondary:!0,optional:!0,render:o=>W(o.createdAt)},{key:"expires",header:"Expires",secondary:!0,render:o=>t.jsx(Ce,{at:o.expiresAt,format:W})},{key:"used",header:"Last used",secondary:!0,optional:!0,render:o=>Me(o.lastUsedAt)}]})}),t.jsx(Y,{isOpen:a,onClose:()=>c(!1),title:"New management token",children:t.jsxs("form",{className:"gc-stack",onSubmit:m=>{m.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"Name",required:!0,value:u,onChange:m=>n(m.target.value),placeholder:"e.g. Terraform"}),t.jsx(B,{label:"Scope",value:h,onChange:m=>k(m),options:[{value:"read",label:"Read only (GET requests)"},{value:"admin",label:"Admin (everything an org admin can do)"}]}),t.jsx(B,{label:"Expires after",value:P,onChange:v,options:[{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},...s?[{value:"never",label:"Never"}]:[]],hint:"Short-lived tokens limit the damage if one leaks."}),g.error?t.jsx($,{error:g.error,title:"Could not create the token"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx(y,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),t.jsx(y,{type:"submit",disabled:g.isPending||!u.trim(),children:"Create token"})]})]})}),t.jsx(Y,{isOpen:S!==null,onClose:()=>b(null),title:"Token created",children:S&&t.jsxs("div",{className:"gc-stack",children:[t.jsx(qe,{secret:S}),t.jsx("div",{className:"gc-actions",children:t.jsx(y,{onClick:()=>b(null),children:"Done"})})]})}),t.jsx(ie,{isOpen:p!==null,busy:l.isPending,error:l.error,onClose:()=>j(null),onConfirm:()=>p&&l.mutate(p),title:"Revoke this token?",confirmLabel:"Revoke",body:`Anything using ${(p==null?void 0:p.label)??"this token"} loses access immediately.`})]})}function Ze({settings:e}){const s=e.auth,r=a=>a?t.jsx(M,{tone:"success",children:"On"}):t.jsx(M,{children:"Off"});return t.jsx(A,{title:"Sign-in methods",description:"Configured on the gateway host with environment variables. Read only here.",children:t.jsxs("div",{className:"gc-stack",children:[t.jsx(le,{items:[["Passkeys",r(s.passkey)],["Wallet (Sign-In with Ethereum)",r(s.wallet)],["OpenID Connect",s.oidc?t.jsx(M,{tone:"success",children:s.oidc.label},"o"):r(!1)],["Cloudflare Access",r(s.cloudflareAccess)],["API key view for key holders",r(s.apiKeyLogin)]]}),t.jsx(D,{tone:"info",title:"Using your own identity provider",children:"Set the OpenID Connect issuer, client id and secret in the gateway's environment and restart it, or put the console behind Cloudflare Access and enable trusted Access headers. The gateway docs list the exact variables. Antseed runs no sign-in service of its own."})]})})}function Xe({tab:e,settings:s}){return e==="buyer"?t.jsx(Ge,{settings:s}):e==="observability"?t.jsx(Ye,{settings:s}):t.jsx(Ze,{settings:s})}function dt(){const[e,s]=d.useState("general"),r=Se({queryKey:q.settings,queryFn:E.settings.get});return d.useEffect(()=>{var a;(a=window.scrollTo)==null||a.call(window,0,0)},[e]),t.jsxs("div",{className:"gc-page",children:[t.jsx(je,{title:"Settings"}),t.jsx(Oe,{id:"gc-settings",label:"Settings sections",value:e,onChange:s,tabs:[{id:"general",label:"General"},{id:"buyer",label:"Buyer"},{id:"observability",label:"Observability"},{id:"tokens",label:"Management tokens"},{id:"auth",label:"Sign-in"}]}),t.jsxs(Ee,{tabsId:"gc-settings",tab:e,className:"gc-stack",children:[e==="general"&&t.jsx(We,{}),e==="tokens"&&t.jsx(Je,{}),(e==="buyer"||e==="observability"||e==="auth")&&t.jsx(z,{query:r,children:a=>t.jsx(Xe,{tab:e,settings:a})}),r.error&&e==="general"?t.jsx($,{error:r.error}):null]})]})}export{dt as default};
@@ -1,9 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalletFunding-C5dOeiPL.js","assets/index-jbhwAQ05.js","assets/index-CqEPMnZS.css","assets/en_US-Y4ZOVFV4-C1wt0O8b.js","assets/clsx-B-dksMZM.js","assets/index-9dOi2Cir.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/useTx-B_KdxpeJ.js","assets/ConnectWallet-Ba-nE-Ex.js","assets/OperatorGateAlert-DAmQCyeN.js","assets/OperatorActions-BZHwECbE.js","assets/ChannelClose-DBF_JUwr.js"])))=>i.map(i=>d[i]);
2
- import{j as t,r as L,Y as Dt,e as te,D as oe,c3 as qt,F as ae,c4 as Bt,f as T,l as ee,c5 as Mt,ak as Ut,c0 as Ft,B as P,I as z,q as W,L as le,v as H,ap as Ue,A as Z,ac as ne,_ as ce,ag as Fe,H as Rt,G as ue,aj as Ot,k as Oe,Q as Ve,K as He,c6 as Vt,av as Ht,t as Lt,a8 as Kt,u as Wt,bS as Jt,P as Qt,J as Yt,m as Gt,c7 as Zt,bU as re,c8 as Xt,M as kt,d as $t,am as en,s as tn,c9 as nn,ca as rn,cb as sn,cc as on,an as Qe,X as an,E as ln,cd as Ye,ce as cn}from"./index-jbhwAQ05.js";import{C as de}from"./ChainGate-B_PADueu.js";import{b as un}from"./index-BwpQbdIU.js";import{r as dn}from"./dijkstra-COg3n3zL.js";import{D as hn}from"./Disclosure-CYz0evEi.js";import{D as fn}from"./DataTable-C7t_4-zX.js";import{S as gn}from"./Switch-BasD00zg.js";import"./index-9dOi2Cir.js";const mn="#2775CA";function pn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:mn}),t.jsx("text",{x:"12",y:"16.6",textAnchor:"middle",fontSize:"13.5",fontWeight:"700",fill:"#fff",children:"$"})]})}function wn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#0052FF"}),t.jsx("rect",{x:"1",y:"10.95",width:"15.85",height:"2.1",fill:"#fff"})]})}const yn="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z";function xn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsx("path",{d:yn,fill:"#000",transform:"translate(7.3 6.4) scale(0.0115)"})]})}function Ge({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsx("circle",{cx:"9.4",cy:"12",r:"4.6",fill:"#EB001B"}),t.jsx("circle",{cx:"14.6",cy:"12",r:"4.6",fill:"#F79E1B",fillOpacity:"0.9"})]})}function Cn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsxs("g",{transform:"translate(6 6) scale(0.5)",children:[t.jsx("path",{fill:"#4285F4",d:"M23.49 12.27c0-.79-.07-1.54-.19-2.27H12v4.51h6.47c-.29 1.48-1.14 2.73-2.4 3.58v3h3.86c2.26-2.09 3.56-5.17 3.56-8.82z"}),t.jsx("path",{fill:"#34A853",d:"M12 24c3.24 0 5.95-1.08 7.93-2.91l-3.86-3c-1.08.72-2.45 1.16-4.07 1.16-3.13 0-5.78-2.11-6.73-4.96H1.29v3.09C3.26 21.31 7.31 24 12 24z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.27 14.29c-.25-.72-.38-1.49-.38-2.29s.14-1.57.38-2.29V6.62H1.29C.47 8.24 0 10.06 0 12s.47 3.76 1.29 5.38l3.98-3.09z"}),t.jsx("path",{fill:"#EA4335",d:"M12 4.75c1.77 0 3.35.61 4.6 1.8l3.42-3.42C17.95 1.19 15.24 0 12 0 7.31 0 3.26 2.69 1.29 6.62l3.98 3.09C6.22 6.86 8.87 4.75 12 4.75z"})]})]})}function Ze({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#1434CB"}),t.jsx("text",{x:"12",y:"14.6",textAnchor:"middle",fontSize:"7",fontWeight:"800",fontStyle:"italic",fill:"#fff",children:"VISA"})]})}function vn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#016FD0"}),t.jsx("text",{x:"12",y:"14.6",textAnchor:"middle",fontSize:"6",fontWeight:"800",fill:"#fff",children:"AMEX"})]})}function jn({size:e=22}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 512 512","aria-hidden":"true",children:[t.jsx("rect",{width:"512",height:"512",rx:"64",fill:"#533AFD"}),t.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M120 392L392 334.317V120L120 178.357V392Z",fill:"#fff"})]})}function bn({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 542.25 542.25",fill:"#34D399","aria-hidden":"true",children:[t.jsx("path",{d:"M493.18,424.48l-106.09,106.09c-7.48,7.48-17.63,11.69-28.21,11.69h-192.03l250.27-250.27,76.06,76.06c15.58,15.58,15.58,40.85,0,56.43Z"}),t.jsx("path",{d:"M375.41,0L125.14,250.27l-76.06-76.06c-15.58-15.58-15.58-40.85,0-56.43L155.16,11.69c7.48-7.48,17.63-11.69,28.21-11.69h192.03Z"}),t.jsx("path",{d:"M542.25,375.41l-250.27-250.27,76.06-76.06c15.58-15.58,40.85-15.58,56.43,0l106.09,106.09c7.48,7.48,11.69,17.63,11.69,28.21v192.03Z"}),t.jsx("path",{d:"M250.27,417.12l-76.06,76.06c-15.58,15.58-40.85,15.58-56.43,0L11.69,387.09c-7.48-7.48-11.69-17.63-11.69-28.21v-192.03l250.27,250.27Z"})]})}function En({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 2500 2500","aria-hidden":"true",children:[t.jsx("path",{fill:"#213147",d:"M226,760v980c0,63,33,120,88,152l849,490c54,31,121,31,175,0l849-490c54-31,88-89,88-152V760c0-63-33-120-88-152l-849-490c-54-31-121-31-175,0L314,608c-54,31-87,89-87,152H226z"}),t.jsx("path",{fill:"#12AAFF",d:"M1435,1440l-121,332c-3,9-3,19,0,29l208,571l241-139l-289-793C1467,1422,1442,1422,1435,1440z"}),t.jsx("path",{fill:"#12AAFF",d:"M1678,882c-7-18-32-18-39,0l-121,332c-3,9-3,19,0,29l341,935l241-139L1678,883V882z"}),t.jsx("path",{fill:"#9DCCED",d:"M1250,155c6,0,12,2,17,5l918,530c11,6,17,18,17,30v1060c0,12-7,24-17,30l-918,530c-5,3-11,5-17,5s-12-2-17-5l-918-530c-11-6-17-18-17-30V719c0-12,7-24,17-30l918-530c5-3,11-5,17-5l0,0V155z M1250,0c-33,0-65,8-95,25L237,555c-59,34-95,96-95,164v1060c0,68,36,130,95,164l918,530c29,17,62,25,95,25s65-8,95-25l918-530c59-34,95-96,95-164V719c0-68-36-130-95-164L1344,25c-29-17-62-25-95-25l0,0H1250z"}),t.jsx("polygon",{fill:"#213147",points:"642,2179 727,1947 897,2088 738,2234"}),t.jsx("path",{fill:"#fff",d:"M1172,644H939c-17,0-33,11-39,27L401,2039l241,139l550-1507c5-14-5-28-19-28L1172,644z"}),t.jsx("path",{fill:"#fff",d:"M1580,644h-233c-17,0-33,11-39,27L738,2233l241,139l620-1701c5-14-5-28-19-28V644z"})]})}function Nn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 2496 2496","aria-hidden":"true",children:[t.jsx("path",{fill:"#F0B90B",fillRule:"evenodd",clipRule:"evenodd",d:"M1248,0c689.3,0,1248,558.7,1248,1248s-558.7,1248-1248,1248S0,1937.3,0,1248S558.7,0,1248,0L1248,0z"}),t.jsxs("g",{fill:"#fff",children:[t.jsx("path",{d:"M685.9,1248l0.9,330l280.4,165v193.2l-444.5-260.7v-524L685.9,1248L685.9,1248z M685.9,918v192.3l-163.3-96.6V821.4l163.3-96.6l164.1,96.6L685.9,918L685.9,918z M1084.3,821.4l163.3-96.6l164.1,96.6L1247.6,918L1084.3,821.4L1084.3,821.4z"}),t.jsx("path",{d:"M803.9,1509.6v-193.2l163.3,96.6v192.3L803.9,1509.6L803.9,1509.6z M1084.3,1812.2l163.3,96.6l164.1-96.6v192.3l-164.1,96.6l-163.3-96.6V1812.2L1084.3,1812.2z M1645.9,821.4l163.3-96.6l164.1,96.6v192.3l-164.1,96.6V918L1645.9,821.4L1645.9,821.4L1645.9,821.4z M1809.2,1578l0.9-330l163.3-96.6v524l-444.5,260.7v-193.2L1809.2,1578L1809.2,1578L1809.2,1578z"}),t.jsx("polygon",{points:"1692.1,1509.6 1528.8,1605.3 1528.8,1413 1692.1,1316.4 1692.1,1509.6"}),t.jsx("path",{d:"M1692.1,986.4l0.9,193.2l-281.2,165v330.8l-163.3,95.7l-163.3-95.7v-330.8l-281.2-165V986.4L968,889.8l279.5,165.8l281.2-165.8l164.1,96.6H1692.1L1692.1,986.4z M803.9,656.5l443.7-261.6l444.5,261.6l-163.3,96.6l-281.2-165.8L967.2,753.1L803.9,656.5L803.9,656.5z"})]})]})}function An({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#6C00F6"}),t.jsx("path",{fill:"#fff",transform:"translate(5.5 6.15) scale(0.0731)",d:"M66.8,54.7l-16.7-9.7L0,74.1v58l50.1,29l50.1-29V41.9L128,25.8l27.8,16.1v32.2L128,90.2l-16.7-9.7v25.8l16.7,9.7l50.1-29V29L128,0L77.9,29v90.2l-27.8,16.1l-27.8-16.1V86.9l27.8-16.1l16.7,9.7V54.7z"})]})}function Sn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32","aria-hidden":"true",children:[t.jsx("circle",{cx:"16",cy:"16",r:"16",fill:"#627EEA"}),t.jsxs("g",{fill:"#fff",fillRule:"nonzero",children:[t.jsx("path",{fillOpacity:"0.602",d:"M16.498 4v8.87l7.497 3.35z"}),t.jsx("path",{d:"M16.498 4L9 16.22l7.498-3.35z"}),t.jsx("path",{fillOpacity:"0.602",d:"M16.498 21.968v6.027L24 17.616z"}),t.jsx("path",{d:"M16.498 27.995v-6.028L9 17.616z"}),t.jsx("path",{fillOpacity:"0.2",d:"M16.498 20.573l7.497-4.353-7.497-3.348z"}),t.jsx("path",{fillOpacity:"0.602",d:"M9 16.22l7.498 4.353v-7.701z"})]})]})}const Bn=6e4;function Mn(e,s,o=document){let r,n=!1,i=!1;const a=m=>{n||(i=m==="active",s.wallet.watch(e,m).catch(x=>{Dt(x)&&x.status===409&&(n=!0)}))},c=()=>{clearInterval(r),a("active"),r=setInterval(()=>a("active"),Bn)},l=()=>{clearInterval(r),i&&a("background")},f=()=>o.visibilityState==="hidden"?l():c();return o.visibilityState!=="hidden"&&c(),o.addEventListener("visibilitychange",f),()=>{o.removeEventListener("visibilitychange",f),l(),n=!0}}function Rn(e){L.useEffect(()=>Mn(e,te),[e])}const se=3e4;function Ln(e,s=se,{minIntervalMs:o=se,doc:r=document}={}){const n=Math.max(s,o);let i;const a=()=>{clearInterval(i),i=setInterval(e,n)},c=()=>{r.visibilityState==="hidden"?(clearInterval(i),i=void 0):(e(),a())};return r.visibilityState!=="hidden"&&a(),r.addEventListener("visibilitychange",c),()=>{clearInterval(i),r.removeEventListener("visibilitychange",c)}}function kn(e,s=se,o=se){const r=oe(),n=JSON.stringify(e);L.useEffect(()=>Ln(()=>void r.invalidateQueries({queryKey:JSON.parse(n)}),s,{minIntervalMs:o}),[n,s,o,r])}var G={},pe,Xe;function Tn(){return Xe||(Xe=1,pe=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),pe}var we={},V={},$e;function J(){if($e)return V;$e=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return V.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},V.getSymbolTotalCodewords=function(r){return s[r]},V.getBCHDigit=function(o){let r=0;for(;o!==0;)r++,o>>>=1;return r},V.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');e=r},V.isKanjiModeEnabled=function(){return typeof e<"u"},V.toSJIS=function(r){return e(r)},V}var ye={},et;function Ke(){return et||(et=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,n){if(e.isValid(r))return r;try{return s(r)}catch{return n}}})(ye)),ye}var xe,tt;function Pn(){if(tt)return xe;tt=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const o=Math.floor(s/8);return(this.buffer[o]>>>7-s%8&1)===1},put:function(s,o){for(let r=0;r<o;r++)this.putBit((s>>>o-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),s&&(this.buffer[o]|=128>>>this.length%8),this.length++}},xe=e,xe}var Ce,nt;function In(){if(nt)return Ce;nt=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,o,r,n){const i=s*this.size+o;this.data[i]=r,n&&(this.reservedBit[i]=!0)},e.prototype.get=function(s,o){return this.data[s*this.size+o]},e.prototype.xor=function(s,o,r){this.data[s*this.size+o]^=r},e.prototype.isReserved=function(s,o){return this.reservedBit[s*this.size+o]},Ce=e,Ce}var ve={},rt;function _n(){return rt||(rt=1,(function(e){const s=J().getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const n=Math.floor(r/7)+2,i=s(r),a=i===145?26:Math.ceil((i-13)/(2*n-2))*2,c=[i-7];for(let l=1;l<n-1;l++)c[l]=c[l-1]-a;return c.push(6),c.reverse()},e.getPositions=function(r){const n=[],i=e.getRowColCoords(r),a=i.length;for(let c=0;c<a;c++)for(let l=0;l<a;l++)c===0&&l===0||c===0&&l===a-1||c===a-1&&l===0||n.push([i[c],i[l]]);return n}})(ve)),ve}var je={},it;function zn(){if(it)return je;it=1;const e=J().getSymbolSize,s=7;return je.getPositions=function(r){const n=e(r);return[[0,0],[n-s,0],[0,n-s]]},je}var be={},st;function Dn(){return st||(st=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},e.from=function(n){return e.isValid(n)?parseInt(n,10):void 0},e.getPenaltyN1=function(n){const i=n.size;let a=0,c=0,l=0,f=null,m=null;for(let x=0;x<i;x++){c=l=0,f=m=null;for(let g=0;g<i;g++){let h=n.get(x,g);h===f?c++:(c>=5&&(a+=s.N1+(c-5)),f=h,c=1),h=n.get(g,x),h===m?l++:(l>=5&&(a+=s.N1+(l-5)),m=h,l=1)}c>=5&&(a+=s.N1+(c-5)),l>=5&&(a+=s.N1+(l-5))}return a},e.getPenaltyN2=function(n){const i=n.size;let a=0;for(let c=0;c<i-1;c++)for(let l=0;l<i-1;l++){const f=n.get(c,l)+n.get(c,l+1)+n.get(c+1,l)+n.get(c+1,l+1);(f===4||f===0)&&a++}return a*s.N2},e.getPenaltyN3=function(n){const i=n.size;let a=0,c=0,l=0;for(let f=0;f<i;f++){c=l=0;for(let m=0;m<i;m++)c=c<<1&2047|n.get(f,m),m>=10&&(c===1488||c===93)&&a++,l=l<<1&2047|n.get(m,f),m>=10&&(l===1488||l===93)&&a++}return a*s.N3},e.getPenaltyN4=function(n){let i=0;const a=n.data.length;for(let l=0;l<a;l++)i+=n.data[l];return Math.abs(Math.ceil(i*100/a/5)-10)*s.N4};function o(r,n,i){switch(r){case e.Patterns.PATTERN000:return(n+i)%2===0;case e.Patterns.PATTERN001:return n%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(n+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return n*i%2+n*i%3===0;case e.Patterns.PATTERN110:return(n*i%2+n*i%3)%2===0;case e.Patterns.PATTERN111:return(n*i%3+(n+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(n,i){const a=i.size;for(let c=0;c<a;c++)for(let l=0;l<a;l++)i.isReserved(l,c)||i.xor(l,c,o(n,l,c))},e.getBestMask=function(n,i){const a=Object.keys(e.Patterns).length;let c=0,l=1/0;for(let f=0;f<a;f++){i(f),e.applyMask(f,n);const m=e.getPenaltyN1(n)+e.getPenaltyN2(n)+e.getPenaltyN3(n)+e.getPenaltyN4(n);e.applyMask(f,n),m<l&&(l=m,c=f)}return c}})(be)),be}var ie={},ot;function Tt(){if(ot)return ie;ot=1;const e=Ke(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return ie.getBlocksCount=function(n,i){switch(i){case e.L:return s[(n-1)*4+0];case e.M:return s[(n-1)*4+1];case e.Q:return s[(n-1)*4+2];case e.H:return s[(n-1)*4+3];default:return}},ie.getTotalCodewordsCount=function(n,i){switch(i){case e.L:return o[(n-1)*4+0];case e.M:return o[(n-1)*4+1];case e.Q:return o[(n-1)*4+2];case e.H:return o[(n-1)*4+3];default:return}},ie}var Ee={},$={},at;function qn(){if(at)return $;at=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let r=1;for(let n=0;n<255;n++)e[n]=r,s[r]=n,r<<=1,r&256&&(r^=285);for(let n=255;n<512;n++)e[n]=e[n-255]})(),$.log=function(r){if(r<1)throw new Error("log("+r+")");return s[r]},$.exp=function(r){return e[r]},$.mul=function(r,n){return r===0||n===0?0:e[s[r]+s[n]]},$}var lt;function Un(){return lt||(lt=1,(function(e){const s=qn();e.mul=function(r,n){const i=new Uint8Array(r.length+n.length-1);for(let a=0;a<r.length;a++)for(let c=0;c<n.length;c++)i[a+c]^=s.mul(r[a],n[c]);return i},e.mod=function(r,n){let i=new Uint8Array(r);for(;i.length-n.length>=0;){const a=i[0];for(let l=0;l<n.length;l++)i[l]^=s.mul(n[l],a);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}return i},e.generateECPolynomial=function(r){let n=new Uint8Array([1]);for(let i=0;i<r;i++)n=e.mul(n,new Uint8Array([1,s.exp(i)]));return n}})(Ee)),Ee}var Ne,ct;function Fn(){if(ct)return Ne;ct=1;const e=Un();function s(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(r){this.degree=r,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(r.length+this.degree);n.set(r);const i=e.mod(n,this.genPoly),a=this.degree-i.length;if(a>0){const c=new Uint8Array(this.degree);return c.set(i,a),c}return i},Ne=s,Ne}var Ae={},Se={},Be={},ut;function Pt(){return ut||(ut=1,Be.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Be}var q={},dt;function It(){if(dt)return q;dt=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
3
- ]))+`;q.KANJI=new RegExp(o,"g"),q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),q.BYTE=new RegExp(r,"g"),q.NUMERIC=new RegExp(e,"g"),q.ALPHANUMERIC=new RegExp(s,"g");const n=new RegExp("^"+o+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return q.testKanji=function(l){return n.test(l)},q.testNumeric=function(l){return i.test(l)},q.testAlphanumeric=function(l){return a.test(l)},q}var ht;function Q(){return ht||(ht=1,(function(e){const s=Pt(),o=It();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!s.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return o.testNumeric(i)?e.NUMERIC:o.testAlphanumeric(i)?e.ALPHANUMERIC:o.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function r(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+n)}}e.from=function(i,a){if(e.isValid(i))return i;try{return r(i)}catch{return a}}})(Se)),Se}var ft;function On(){return ft||(ft=1,(function(e){const s=J(),o=Tt(),r=Ke(),n=Q(),i=Pt(),a=7973,c=s.getBCHDigit(a);function l(g,h,B){for(let S=1;S<=40;S++)if(h<=e.getCapacity(S,B,g))return S}function f(g,h){return n.getCharCountIndicator(g,h)+4}function m(g,h){let B=0;return g.forEach(function(S){const k=f(S.mode,h);B+=k+S.getBitsLength()}),B}function x(g,h){for(let B=1;B<=40;B++)if(m(g,B)<=e.getCapacity(B,h,n.MIXED))return B}e.from=function(h,B){return i.isValid(h)?parseInt(h,10):B},e.getCapacity=function(h,B,S){if(!i.isValid(h))throw new Error("Invalid QR Code version");typeof S>"u"&&(S=n.BYTE);const k=s.getSymbolTotalCodewords(h),N=o.getTotalCodewordsCount(h,B),y=(k-N)*8;if(S===n.MIXED)return y;const v=y-f(S,h);switch(S){case n.NUMERIC:return Math.floor(v/10*3);case n.ALPHANUMERIC:return Math.floor(v/11*2);case n.KANJI:return Math.floor(v/13);case n.BYTE:default:return Math.floor(v/8)}},e.getBestVersionForData=function(h,B){let S;const k=r.from(B,r.M);if(Array.isArray(h)){if(h.length>1)return x(h,k);if(h.length===0)return 1;S=h[0]}else S=h;return l(S.mode,S.getLength(),k)},e.getEncodedBits=function(h){if(!i.isValid(h)||h<7)throw new Error("Invalid QR Code version");let B=h<<12;for(;s.getBCHDigit(B)-c>=0;)B^=a<<s.getBCHDigit(B)-c;return h<<12|B}})(Ae)),Ae}var Me={},gt;function Vn(){if(gt)return Me;gt=1;const e=J(),s=1335,o=21522,r=e.getBCHDigit(s);return Me.getEncodedBits=function(i,a){const c=i.bit<<3|a;let l=c<<10;for(;e.getBCHDigit(l)-r>=0;)l^=s<<e.getBCHDigit(l)-r;return(c<<10|l)^o},Me}var Re={},Le,mt;function Hn(){if(mt)return Le;mt=1;const e=Q();function s(o){this.mode=e.NUMERIC,this.data=o.toString()}return s.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){let n,i,a;for(n=0;n+3<=this.data.length;n+=3)i=this.data.substr(n,3),a=parseInt(i,10),r.put(a,10);const c=this.data.length-n;c>0&&(i=this.data.substr(n),a=parseInt(i,10),r.put(a,c*3+1))},Le=s,Le}var ke,pt;function Kn(){if(pt)return ke;pt=1;const e=Q(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(r){this.mode=e.ALPHANUMERIC,this.data=r}return o.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let i;for(i=0;i+2<=this.data.length;i+=2){let a=s.indexOf(this.data[i])*45;a+=s.indexOf(this.data[i+1]),n.put(a,11)}this.data.length%2&&n.put(s.indexOf(this.data[i]),6)},ke=o,ke}var Te,wt;function Wn(){if(wt)return Te;wt=1;const e=Q();function s(o){this.mode=e.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return s.getBitsLength=function(r){return r*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){for(let r=0,n=this.data.length;r<n;r++)o.put(this.data[r],8)},Te=s,Te}var Pe,yt;function Jn(){if(yt)return Pe;yt=1;const e=Q(),s=J();function o(r){this.mode=e.KANJI,this.data=r}return o.getBitsLength=function(n){return n*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let n;for(n=0;n<this.data.length;n++){let i=s.toSJIS(this.data[n]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
4
- Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Pe=o,Pe}var xt;function Qn(){return xt||(xt=1,(function(e){const s=Q(),o=Hn(),r=Kn(),n=Wn(),i=Jn(),a=It(),c=J(),l=dn();function f(N){return unescape(encodeURIComponent(N)).length}function m(N,y,v){const p=[];let R;for(;(R=N.exec(v))!==null;)p.push({data:R[0],index:R.index,mode:y,length:R[0].length});return p}function x(N){const y=m(a.NUMERIC,s.NUMERIC,N),v=m(a.ALPHANUMERIC,s.ALPHANUMERIC,N);let p,R;return c.isKanjiModeEnabled()?(p=m(a.BYTE,s.BYTE,N),R=m(a.KANJI,s.KANJI,N)):(p=m(a.BYTE_KANJI,s.BYTE,N),R=[]),y.concat(v,p,R).sort(function(d,w){return d.index-w.index}).map(function(d){return{data:d.data,mode:d.mode,length:d.length}})}function g(N,y){switch(y){case s.NUMERIC:return o.getBitsLength(N);case s.ALPHANUMERIC:return r.getBitsLength(N);case s.KANJI:return i.getBitsLength(N);case s.BYTE:return n.getBitsLength(N)}}function h(N){return N.reduce(function(y,v){const p=y.length-1>=0?y[y.length-1]:null;return p&&p.mode===v.mode?(y[y.length-1].data+=v.data,y):(y.push(v),y)},[])}function B(N){const y=[];for(let v=0;v<N.length;v++){const p=N[v];switch(p.mode){case s.NUMERIC:y.push([p,{data:p.data,mode:s.ALPHANUMERIC,length:p.length},{data:p.data,mode:s.BYTE,length:p.length}]);break;case s.ALPHANUMERIC:y.push([p,{data:p.data,mode:s.BYTE,length:p.length}]);break;case s.KANJI:y.push([p,{data:p.data,mode:s.BYTE,length:f(p.data)}]);break;case s.BYTE:y.push([{data:p.data,mode:s.BYTE,length:f(p.data)}])}}return y}function S(N,y){const v={},p={start:{}};let R=["start"];for(let u=0;u<N.length;u++){const d=N[u],w=[];for(let C=0;C<d.length;C++){const A=d[C],j=""+u+C;w.push(j),v[j]={node:A,lastCount:0},p[j]={};for(let E=0;E<R.length;E++){const b=R[E];v[b]&&v[b].node.mode===A.mode?(p[b][j]=g(v[b].lastCount+A.length,A.mode)-g(v[b].lastCount,A.mode),v[b].lastCount+=A.length):(v[b]&&(v[b].lastCount=A.length),p[b][j]=g(A.length,A.mode)+4+s.getCharCountIndicator(A.mode,y))}}R=w}for(let u=0;u<R.length;u++)p[R[u]].end=0;return{map:p,table:v}}function k(N,y){let v;const p=s.getBestModeForData(N);if(v=s.from(y,p),v!==s.BYTE&&v.bit<p.bit)throw new Error('"'+N+'" cannot be encoded with mode '+s.toString(v)+`.
5
- Suggested mode is: `+s.toString(p));switch(v===s.KANJI&&!c.isKanjiModeEnabled()&&(v=s.BYTE),v){case s.NUMERIC:return new o(N);case s.ALPHANUMERIC:return new r(N);case s.KANJI:return new i(N);case s.BYTE:return new n(N)}}e.fromArray=function(y){return y.reduce(function(v,p){return typeof p=="string"?v.push(k(p,null)):p.data&&v.push(k(p.data,p.mode)),v},[])},e.fromString=function(y,v){const p=x(y,c.isKanjiModeEnabled()),R=B(p),u=S(R,v),d=l.find_path(u.map,"start","end"),w=[];for(let C=1;C<d.length-1;C++)w.push(u.table[d[C]].node);return e.fromArray(h(w))},e.rawSplit=function(y){return e.fromArray(x(y,c.isKanjiModeEnabled()))}})(Re)),Re}var Ct;function Yn(){if(Ct)return we;Ct=1;const e=J(),s=Ke(),o=Pn(),r=In(),n=_n(),i=zn(),a=Dn(),c=Tt(),l=Fn(),f=On(),m=Vn(),x=Q(),g=Qn();function h(u,d){const w=u.size,C=i.getPositions(d);for(let A=0;A<C.length;A++){const j=C[A][0],E=C[A][1];for(let b=-1;b<=7;b++)if(!(j+b<=-1||w<=j+b))for(let M=-1;M<=7;M++)E+M<=-1||w<=E+M||(b>=0&&b<=6&&(M===0||M===6)||M>=0&&M<=6&&(b===0||b===6)||b>=2&&b<=4&&M>=2&&M<=4?u.set(j+b,E+M,!0,!0):u.set(j+b,E+M,!1,!0))}}function B(u){const d=u.size;for(let w=8;w<d-8;w++){const C=w%2===0;u.set(w,6,C,!0),u.set(6,w,C,!0)}}function S(u,d){const w=n.getPositions(d);for(let C=0;C<w.length;C++){const A=w[C][0],j=w[C][1];for(let E=-2;E<=2;E++)for(let b=-2;b<=2;b++)E===-2||E===2||b===-2||b===2||E===0&&b===0?u.set(A+E,j+b,!0,!0):u.set(A+E,j+b,!1,!0)}}function k(u,d){const w=u.size,C=f.getEncodedBits(d);let A,j,E;for(let b=0;b<18;b++)A=Math.floor(b/3),j=b%3+w-8-3,E=(C>>b&1)===1,u.set(A,j,E,!0),u.set(j,A,E,!0)}function N(u,d,w){const C=u.size,A=m.getEncodedBits(d,w);let j,E;for(j=0;j<15;j++)E=(A>>j&1)===1,j<6?u.set(j,8,E,!0):j<8?u.set(j+1,8,E,!0):u.set(C-15+j,8,E,!0),j<8?u.set(8,C-j-1,E,!0):j<9?u.set(8,15-j-1+1,E,!0):u.set(8,15-j-1,E,!0);u.set(C-8,8,1,!0)}function y(u,d){const w=u.size;let C=-1,A=w-1,j=7,E=0;for(let b=w-1;b>0;b-=2)for(b===6&&b--;;){for(let M=0;M<2;M++)if(!u.isReserved(A,b-M)){let D=!1;E<d.length&&(D=(d[E]>>>j&1)===1),u.set(A,b-M,D),j--,j===-1&&(E++,j=7)}if(A+=C,A<0||w<=A){A-=C,C=-C;break}}}function v(u,d,w){const C=new o;w.forEach(function(M){C.put(M.mode.bit,4),C.put(M.getLength(),x.getCharCountIndicator(M.mode,u)),M.write(C)});const A=e.getSymbolTotalCodewords(u),j=c.getTotalCodewordsCount(u,d),E=(A-j)*8;for(C.getLengthInBits()+4<=E&&C.put(0,4);C.getLengthInBits()%8!==0;)C.putBit(0);const b=(E-C.getLengthInBits())/8;for(let M=0;M<b;M++)C.put(M%2?17:236,8);return p(C,u,d)}function p(u,d,w){const C=e.getSymbolTotalCodewords(d),A=c.getTotalCodewordsCount(d,w),j=C-A,E=c.getBlocksCount(d,w),b=C%E,M=E-b,D=Math.floor(C/E),K=Math.floor(j/E),he=K+1,X=D-K,I=new l(X);let _=0;const U=new Array(E),We=new Array(E);let fe=0;const zt=new Uint8Array(u.buffer);for(let Y=0;Y<E;Y++){const me=Y<M?K:he;U[Y]=zt.slice(_,_+me),We[Y]=I.encode(U[Y]),_+=me,fe=Math.max(fe,me)}const ge=new Uint8Array(C);let Je=0,F,O;for(F=0;F<fe;F++)for(O=0;O<E;O++)F<U[O].length&&(ge[Je++]=U[O][F]);for(F=0;F<X;F++)for(O=0;O<E;O++)ge[Je++]=We[O][F];return ge}function R(u,d,w,C){let A;if(Array.isArray(u))A=g.fromArray(u);else if(typeof u=="string"){let D=d;if(!D){const K=g.rawSplit(u);D=f.getBestVersionForData(K,w)}A=g.fromString(u,D||40)}else throw new Error("Invalid data");const j=f.getBestVersionForData(A,w);if(!j)throw new Error("The amount of data is too big to be stored in a QR Code");if(!d)d=j;else if(d<j)throw new Error(`
6
- The chosen QR Code version cannot contain this amount of data.
7
- Minimum version required to store current data is: `+j+`.
8
- `);const E=v(d,w,A),b=e.getSymbolSize(d),M=new r(b);return h(M,d),B(M),S(M,d),N(M,w,0),d>=7&&k(M,d),y(M,E),isNaN(C)&&(C=a.getBestMask(M,N.bind(null,M,w))),a.applyMask(C,M),N(M,w,C),{modules:M,version:d,errorCorrectionLevel:w,maskPattern:C,segments:A}}return we.create=function(d,w){if(typeof d>"u"||d==="")throw new Error("No input text");let C=s.M,A,j;return typeof w<"u"&&(C=s.from(w.errorCorrectionLevel,s.M),A=f.from(w.version),j=a.from(w.maskPattern),w.toSJISFunc&&e.setToSJISFunction(w.toSJISFunc)),R(d,A,C,j)},we}var Ie={},_e={},vt;function _t(){return vt||(vt=1,(function(e){function s(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let r=o.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+o);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const n=parseInt(r.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const n=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:i,scale:i?4:a,margin:n,color:{dark:s(r.color.dark||"#000000ff"),light:s(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,n){return n.width&&n.width>=r+n.margin*2?n.width/(r+n.margin*2):n.scale},e.getImageWidth=function(r,n){const i=e.getScale(r,n);return Math.floor((r+n.margin*2)*i)},e.qrToImageData=function(r,n,i){const a=n.modules.size,c=n.modules.data,l=e.getScale(a,i),f=Math.floor((a+i.margin*2)*l),m=i.margin*l,x=[i.color.light,i.color.dark];for(let g=0;g<f;g++)for(let h=0;h<f;h++){let B=(g*f+h)*4,S=i.color.light;if(g>=m&&h>=m&&g<f-m&&h<f-m){const k=Math.floor((g-m)/l),N=Math.floor((h-m)/l);S=x[c[k*a+N]?1:0]}r[B++]=S.r,r[B++]=S.g,r[B++]=S.b,r[B]=S.a}}})(_e)),_e}var jt;function Gn(){return jt||(jt=1,(function(e){const s=_t();function o(n,i,a){n.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,a,c){let l=c,f=a;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),a||(f=r()),l=s.getOptions(l);const m=s.getImageWidth(i.modules.size,l),x=f.getContext("2d"),g=x.createImageData(m,m);return s.qrToImageData(g.data,i,l),o(x,f,m),x.putImageData(g,0,0),f},e.renderToDataURL=function(i,a,c){let l=c;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),l||(l={});const f=e.render(i,a,l),m=l.type||"image/png",x=l.rendererOpts||{};return f.toDataURL(m,x.quality)}})(Ie)),Ie}var ze={},bt;function Zn(){if(bt)return ze;bt=1;const e=_t();function s(n,i){const a=n.a/255,c=i+'="'+n.hex+'"';return a<1?c+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':c}function o(n,i,a){let c=n+i;return typeof a<"u"&&(c+=" "+a),c}function r(n,i,a){let c="",l=0,f=!1,m=0;for(let x=0;x<n.length;x++){const g=Math.floor(x%i),h=Math.floor(x/i);!g&&!f&&(f=!0),n[x]?(m++,x>0&&g>0&&n[x-1]||(c+=f?o("M",g+a,.5+h+a):o("m",l,0),l=0,f=!1),g+1<i&&n[x+1]||(c+=o("h",m),m=0)):l++}return c}return ze.render=function(i,a,c){const l=e.getOptions(a),f=i.modules.size,m=i.modules.data,x=f+l.margin*2,g=l.color.light.a?"<path "+s(l.color.light,"fill")+' d="M0 0h'+x+"v"+x+'H0z"/>':"",h="<path "+s(l.color.dark,"stroke")+' d="'+r(m,f,l.margin)+'"/>',B='viewBox="0 0 '+x+" "+x+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+B+' shape-rendering="crispEdges">'+g+h+`</svg>
9
- `;return typeof c=="function"&&c(null,k),k},ze}var Et;function Xn(){if(Et)return G;Et=1;const e=Tn(),s=Yn(),o=Gn(),r=Zn();function n(i,a,c,l,f){const m=[].slice.call(arguments,1),x=m.length,g=typeof m[x-1]=="function";if(!g&&!e())throw new Error("Callback required as last argument");if(g){if(x<2)throw new Error("Too few arguments provided");x===2?(f=c,c=a,a=l=void 0):x===3&&(a.getContext&&typeof f>"u"?(f=l,l=void 0):(f=l,l=c,c=a,a=void 0))}else{if(x<1)throw new Error("Too few arguments provided");return x===1?(c=a,a=l=void 0):x===2&&!a.getContext&&(l=c,c=a,a=void 0),new Promise(function(h,B){try{const S=s.create(c,l);h(i(S,a,l))}catch(S){B(S)}})}try{const h=s.create(c,l);f(null,i(h,a,l))}catch(h){f(h)}}return G.create=s.create,G.toCanvas=n.bind(null,o.render),G.toDataURL=n.bind(null,o.renderToDataURL),G.toString=n.bind(null,function(i,a,c){return r.render(i,c)}),G}var $n=Xn();const er=qt($n),tr="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.72532 0 0.578514 4.81465 0.0491943 10.9512H15.8916V13.0488H0.0491943C0.578514 19.1853 5.72532 24 12 24Z";function De(e,s,o,r,n){return`M${e+n},${s} h${o-2*n} a${n},${n} 0 0 1 ${n},${n} v${r-2*n} a${n},${n} 0 0 1 ${-n},${n} h${-(o-2*n)} a${n},${n} 0 0 1 ${-n},${-n} v${-(r-2*n)} a${n},${n} 0 0 1 ${n},${-n} z`}function nr(e,s){return[De(e,s,7,7,2.2)+" "+De(e+1,s+1,5,5,1.6),De(e+2,s+2,3,3,1.05)]}function rr({text:e,label:s}){const o=L.useMemo(()=>{try{const g=er.create(e,{errorCorrectionLevel:"Q"});return{size:g.modules.size,data:g.modules.data}}catch{return null}},[e]);if(!o)return t.jsx("div",{className:"gc-qr gc-qr--placeholder","aria-hidden":"true"});const{size:r,data:n}=o,i=r/2,a=r*.11,c=a+.6,l=a*.82,f=(g,h)=>g<7&&h<7||g<7&&h>=r-7||g>=r-7&&h<7,m=(g,h)=>Math.hypot(g+.5-i,h+.5-i)<c,x=[];for(let g=0;g<r;g++)for(let h=0;h<r;h++)n[g*r+h]&&(f(g,h)||m(g,h)||x.push(t.jsx("circle",{cx:h+.5,cy:g+.5,r:.34},`${g}-${h}`)));return t.jsxs("svg",{className:"gc-qr",viewBox:`0 0 ${r} ${r}`,role:"img","aria-label":s,children:[t.jsxs("g",{fill:"currentColor",children:[x,[[0,0],[r-7,0],[0,r-7]].map(([g,h])=>{const[B,S]=nr(g,h);return t.jsxs("g",{children:[t.jsx("path",{d:B,fillRule:"evenodd"}),t.jsx("path",{d:S})]},`${g}-${h}`)})]}),t.jsx("circle",{cx:i,cy:i,r:a,className:"gc-qr__badge"}),t.jsx("circle",{cx:i,cy:i,r:l,fill:"#fff"}),t.jsx("path",{d:tr,fill:"#0052FF",transform:`translate(${i-l}, ${i-l}) scale(${l*2/24})`})]})}const ir=L.lazy(()=>ce(()=>import("./WalletFunding-C5dOeiPL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),sr=["5","10","25"],Nt=200,or="https://antseed.mrdn.finance/";function ar(){const e=window.open("about:blank","_blank");return e&&(e.opener=null),e}function lr(e,s){if(e.mode==="off")return{tone:"error",text:e.status==="buyer-unreachable"?"The buyer is not reachable, so deposits are not watched right now.":"This wallet is not watched for deposits right now; USDC sent to it is credited once the buyer watches it again."};const o=e.event&&e.event.seq>s?e.event:null;if(!o||o.phase==="deferred")return{tone:"idle",text:"Waiting for USDC on Base…"};const r=o.amount?T(o.amount):"USDC";return o.phase==="received"?{tone:"busy",text:`Received ${r}, preparing the deposit…`}:o.phase==="sweeping"?{tone:"busy",text:`Depositing ${r} to the credits…`}:o.phase==="credited"?{tone:"done",text:`${r} added to the balance`}:{tone:"error",text:o.error??"The deposit failed. USDC stays in the workspace wallet and is retried."}}function At({line:e}){return t.jsxs("div",{className:`gc-depwatch gc-depwatch--${e.tone}`,role:"status",children:[e.tone==="done"?t.jsx(z.check,{size:15}):t.jsx("span",{className:"gc-depwatch__dot","aria-hidden":"true"}),e.text]})}function St({amount:e,setAmount:s,firstDeposit:o}){return t.jsxs("div",{className:"gc-fund-amount",children:[t.jsx("span",{className:"gc-fund-amount__label",children:"Amount to add"}),t.jsxs("div",{className:"gc-fund-amount__row",children:[sr.map(r=>t.jsxs("button",{type:"button",className:e===r?"gc-preset gc-preset--on":"gc-preset","aria-pressed":e===r,onClick:()=>s(r),children:["$",r]},r)),t.jsxs("label",{className:"gc-fund-amount__input",children:[t.jsx("span",{"aria-hidden":"true",children:"$"}),t.jsx("input",{type:"text",inputMode:"decimal",value:e,"aria-label":"Amount in USD",onChange:r=>s(r.target.value.replace(/[^0-9.]/g,""))})]})]}),t.jsxs("span",{className:"gc-fineprint",children:["1 credit = 1 USDC",o?" · The first deposit must be at least $1":""]})]})}function qe({icon:e,title:s,caption:o,badges:r,onClick:n,arrow:i}){return t.jsxs("button",{type:"button",className:"gc-method",onClick:n,children:[t.jsx("span",{className:"gc-method__icon",children:e}),t.jsxs("span",{className:"gc-method__text",children:[t.jsx("span",{className:"gc-method__title",children:s}),t.jsx("span",{className:"gc-method__caption",children:o})]}),t.jsx("span",{className:"gc-method__badges","aria-hidden":"true",children:r}),i?t.jsx(z.right,{size:16,className:"gc-method__arrow"}):t.jsx(z.external,{size:14,className:"gc-method__arrow"})]})}function cr({wallet:e,chain:s,workspaceId:o}){var X;const[r,n]=L.useState("choose"),[i,a]=L.useState("10"),[c,l]=L.useState(!1),[f,m]=L.useState(null),[x,g]=L.useState(null),h=oe(),B=ae(),S=Bt(o);Rn(o);const k=L.useRef(((X=e.deposit.event)==null?void 0:X.seq)??0),N=e.deposit.event!==null&&e.deposit.event.seq>k.current&&(e.deposit.event.phase==="received"||e.deposit.event.phase==="sweeping");kn(W.wallet(o),N?4e3:8e3,4e3);const[y,v]=L.useState(null),p=e.deposit.event,R=p&&p.seq>k.current&&p.phase==="credited"?p:null;L.useEffect(()=>{R&&(B(`${R.amount?T(R.amount):"Your deposit"} added to the balance`),v(null),h.invalidateQueries({queryKey:["channels",o]}))},[R==null?void 0:R.seq]);const u=Number(i),d=Number.isFinite(u)&&u>=1,w=ee(e.available)+ee(e.reserved),C=Math.max(0,w-(S.data?Mt(S.data):0))+ee(e.walletUsdc),A=w===0,j=Ut(s,"usdc"),E=lr(e.deposit,k.current),b=R!=null&&R.txHash?Ft(s,R.txHash):null;async function M(I){if(!d){m("Enter an amount of at least $1.");return}if(u>Nt){m(`Card deposits are limited to $${Nt}. Send more as USDC instead.`);return}g(I),m(null);try{const{url:_}=await te.wallet.cardLink(o,u,I),U=URL.canParse(_)?new URL(_).origin:null;if(!(U!=null&&U.startsWith("https://")))throw new Error("The gateway returned an invalid checkout link.");v({url:_,origin:U,provider:I})}catch(_){m(Fe(_))}finally{g(null)}}function D(){const I=ar(),_=`${or}?buyer=${encodeURIComponent(e.address)}`;I?I.location.replace(_):window.location.href=_}const K=t.jsxs("div",{className:"gc-fund-balance",children:[t.jsx("span",{className:"gc-fund-balance__label",children:"Workspace balance"}),t.jsx("span",{className:"gc-fund-balance__value",children:T(C)}),t.jsxs("span",{className:"gc-fineprint",children:[T(e.available)," available · ",T(e.reserved)," reserved",ee(e.walletUsdc)>0?` · ${T(e.walletUsdc)} in the wallet`:""]})]});if(r==="wallet")return t.jsxs("div",{className:"gc-fund",children:[t.jsx(P,{variant:"link",size:"sm",leadingIcon:t.jsx(z.left,{size:14}),onClick:()=>n("crypto"),children:"Back"}),t.jsx(de,{chain:s,children:I=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(ir,{action:"deposit",workspaceId:o,wallet:e,chain:I,onDone:()=>{B("Deposit confirmed"),h.invalidateQueries({queryKey:W.wallet(o)})}})})})]});if(r==="crypto")return t.jsxs("div",{className:"gc-fund",children:[t.jsx(P,{variant:"link",size:"sm",leadingIcon:t.jsx(z.left,{size:14}),onClick:()=>n("choose"),children:"All options"}),t.jsx(St,{amount:i,setAmount:a,firstDeposit:A}),t.jsxs("div",{className:"gc-fund-pay",children:[j&&s?t.jsx(rr,{text:un({usdcAddress:j,chainId:s.chainId,address:e.address},d?i:""),label:`Scan to send USDC on ${s.name} to this workspace's wallet`}):t.jsx("div",{className:"gc-qr gc-qr--placeholder","aria-hidden":"true"}),t.jsxs("div",{className:"gc-fund-pay__address",children:[t.jsx("code",{className:"gc-mono",title:e.address,children:H(e.address)}),t.jsx(Ue,{iconOnly:!0,value:e.address,label:"Copy address"})]}),t.jsx(At,{line:E}),t.jsx("span",{className:"gc-fineprint",children:"Credits update automatically · a small fixed relay fee is deducted"}),b&&t.jsx("a",{className:"gc-link gc-fineprint",href:b,target:"_blank",rel:"noopener noreferrer",children:"View transaction"}),t.jsxs("div",{className:"gc-fund-pay__warn",children:["Only send USDC on ",t.jsx("strong",{children:(s==null?void 0:s.name)??"Base"}),". Other tokens or networks are not deposited."]})]}),t.jsx(P,{variant:"link",size:"sm",trailingIcon:t.jsx(z.right,{size:14}),onClick:()=>n("wallet"),children:"No wallet on your phone? Pay from a connected wallet instead"})]});const he=t.jsx(Z,{isOpen:y!==null,onClose:()=>v(null),size:"md",title:"Secure checkout",bodyClassName:"gc-checkout",subtitle:y&&t.jsxs(t.Fragment,{children:[y.provider==="stripe"?"Card checkout by Outerfound, powered by Stripe (US only).":"Card checkout by Crossmint."," Closes by itself once the funds arrive."," ",t.jsx("a",{className:"gc-link",href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>v(null),children:"Open in a new tab"})]}),children:y&&t.jsx("iframe",{className:"gc-checkout__frame",src:y.url,title:"Antseed Pay checkout",allow:`payment ${y.origin}; clipboard-write`})});return t.jsxs("div",{className:"gc-fund",children:[he,K,t.jsx(St,{amount:i,setAmount:a,firstDeposit:A}),t.jsxs("button",{type:"button",className:"gc-method gc-method--primary",disabled:x!==null,onClick:()=>void M("crossmint"),children:[t.jsxs("span",{className:"gc-method__text",children:[t.jsx("span",{className:"gc-method__title",children:x==="crossmint"?"Opening checkout…":`Deposit${d?` ${T(u)}`:""} by card`}),t.jsx("span",{className:"gc-method__caption",children:"Powered by Crossmint"})]}),t.jsxs("span",{className:"gc-method__badges","aria-hidden":"true",children:[t.jsx(Ge,{}),t.jsx(xn,{}),t.jsx(Cn,{}),t.jsx(Ze,{})]})]}),t.jsxs("div",{className:"gc-fund-group",children:[t.jsx(qe,{icon:t.jsx(wn,{size:22}),title:"Quick deposit",caption:`USDC on ${(s==null?void 0:s.name)??"Base"}`,arrow:!0,onClick:()=>n("crypto"),badges:t.jsxs(t.Fragment,{children:[t.jsx(pn,{}),t.jsx("span",{className:"gc-fund-chip",children:t.jsx(z.qr,{size:12})})]})}),t.jsx("span",{className:"gc-fineprint",children:"* Deposited to the credits by the Antseed relayer network"})]}),f&&t.jsx(ne,{tone:"danger",children:f}),t.jsxs("button",{type:"button",className:"gc-fund-more","aria-expanded":c,onClick:()=>l(I=>!I),children:["More options ",t.jsx(z.down,{size:16,className:c?"gc-fund-more__chevron gc-fund-more__chevron--open":"gc-fund-more__chevron"})]}),c&&t.jsxs("div",{className:"gc-fund-options",children:[t.jsx(qe,{icon:t.jsx(bn,{}),title:"Deposit using Meridian",caption:"USDC from any chain",onClick:D,badges:t.jsxs(t.Fragment,{children:[t.jsx(Sn,{}),t.jsx(En,{}),t.jsx(Nn,{}),t.jsx(An,{})]})}),t.jsx(qe,{icon:t.jsx(jn,{size:20}),title:x==="stripe"?"Opening checkout…":"Deposit using Outerfound",caption:"Card · US only",onClick:()=>void M("stripe"),badges:t.jsxs(t.Fragment,{children:[t.jsx(Ze,{}),t.jsx(Ge,{}),t.jsx(vn,{})]})})]}),t.jsx(At,{line:E}),t.jsxs("div",{className:"gc-fund-trust",children:[t.jsxs("span",{children:[t.jsx(z.lock,{size:12})," Encrypted & secure · Non-custodial escrow on ",(s==null?void 0:s.name)??"Base"]}),t.jsxs("span",{children:[t.jsx(z.check,{size:12})," Pay per request · No subscriptions, no lock-in"]})]}),t.jsx("p",{className:"gc-fineprint gc-fund-fine",children:"Card checkout opens here and closes itself once the funds arrive. It is not available in every region."})]})}const ur=L.lazy(()=>ce(()=>import("./OperatorActions-BZHwECbE.js"),__vite__mapDeps([11,1,2,8,3,4,5,6,7,9]))),dr={info:"neutral",success:"success",warning:"warning",danger:"danger"},hr={authorize:"Authorize a wallet",manage:"Transfer or remove the authorized wallet"};function fr({workspaceId:e,action:s,onActionChange:o}){const r=Rt(e),n=ue(),i=ae(),{apply:a,refresh:c}=Ot(e),[l,f]=L.useState(null),m=s!==void 0?s:l,x=p=>o?o(p):f(p),[g,h]=L.useState(!1),[B,S]=L.useState(!1),[k,N]=L.useState(null);async function y(){S(!0),N(null);try{await c()}catch(p){N(p)}finally{S(!1)}}return t.jsxs(Oe,{title:"Authorized wallet",description:"Receives this workspace's withdrawals and ANTS rewards, and is the only wallet that can sign them.",children:[t.jsx(Ve,{query:r,rows:2,children:p=>{var R;return t.jsx(gr,{state:p,explorerUrl:((R=n.data)==null?void 0:R.explorerUrl)??null,refreshing:B,onReload:()=>void y(),onAction:x,onLink:()=>h(!0)})}}),k?t.jsx(ne,{tone:"danger",children:Fe(k)}):null,t.jsx(Z,{isOpen:m!==null&&r.data!==void 0,onClose:()=>x(null),size:"md",title:m?hr[m]:"",subtitle:m==="manage"&&r.data?`Signed by ${H(r.data.operator)} itself; the gateway cannot do it.`:"Withdrawals and ANTS rewards will go to the wallet you authorize, and only it can hand the role on.",children:m&&r.data&&t.jsx(de,{chain:n.data,error:n.error,children:p=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(ur,{mode:m,workspaceId:e,state:r.data,chain:p,onStale:()=>void y(),onChanged:R=>{a(R),x(null),i(He(R.operator)?`Authorized wallet is now ${H(R.operator)}`:"Authorized wallet removed")}})})})}),g&&r.data&&t.jsx(Vt,{isOpen:!0,startWith:"wallet",onClose:()=>h(!1),intro:t.jsxs("p",{className:"gc-muted",children:["Connect ",t.jsx("code",{className:"gc-mono",children:H(r.data.operator)})," and sign the message to add it as one of your sign-in methods. It then shows here as your wallet, and you can manage it."]}),onCredentialAdded:()=>{y(),i("Wallet linked to your account")}})]})}function gr({state:e,explorerUrl:s,refreshing:o,onReload:r,onAction:n,onLink:i}){const a=Ht(e,null),c=He(e.operator),l=s&&c?`${s.replace(/\/+$/,"")}/address/${e.operator}`:null,f=c&&e.relation!=="self";return t.jsxs("div",{className:"gc-operator",children:[t.jsxs("div",{className:"gc-operator__main",children:[t.jsxs("div",{className:"gc-operator__title",children:[t.jsx("span",{className:"gc-strong",children:a.title}),c&&t.jsx(Ue,{iconOnly:!0,value:e.operator,label:"Copy address"}),t.jsx(Lt,{tone:dr[a.tone],children:a.badge})]}),t.jsx("p",{className:"gc-operator__summary",children:a.summary}),t.jsxs("p",{className:"gc-fineprint gc-operator__meta",children:[l&&t.jsxs(t.Fragment,{children:[t.jsx("a",{className:"gc-link",href:l,target:"_blank",rel:"noopener noreferrer",children:"explorer"})," · "]}),"Checked ",Kt(e.checkedAt)," ·"," ",t.jsx(P,{variant:"link",size:"sm",disabled:o,onClick:r,children:o?"checking…":"check again"})]})]}),t.jsxs("div",{className:"gc-operator__actions",children:[a.canAuthorize&&t.jsx(P,{size:"sm",onClick:()=>n("authorize"),children:"Authorize a wallet"}),a.canLink&&t.jsx(P,{size:"sm",onClick:i,children:"Link to my account"}),f&&t.jsx(P,{size:"sm",variant:"outline",onClick:()=>n("manage"),children:"Transfer or remove"})]}),(a.body!==a.summary||e.relation==="none"&&!e.canAuthorize)&&t.jsxs(hn,{className:"gc-operator__details",title:"What does this mean?",children:[t.jsx("p",{className:"gc-muted",children:a.body}),e.relation==="none"&&!e.canAuthorize&&t.jsx("p",{className:"gc-fineprint",children:"Only the organization owner can authorize a wallet, with one of their own sign-in wallets added at least 24 hours ago."})]})]})}const mr=L.lazy(()=>ce(()=>import("./WalletFunding-C5dOeiPL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),pr=L.lazy(()=>ce(()=>import("./ChannelClose-DBF_JUwr.js"),__vite__mapDeps([12,1,2,8,3,4,5,6,7,9,10])));function wr(e,s=15e3){const[o,r]=L.useState(()=>Date.now());return L.useEffect(()=>{if(!e)return;r(Date.now());const n=setInterval(()=>r(Date.now()),s);return()=>clearInterval(n)},[e,s]),o}function yr({workspaceId:e,canCooperate:s,onAuthorize:o}){const[r,n]=L.useState(!1),[i,a]=L.useState(null),[c,l]=L.useState(()=>new Set),f=oe(),m=ae(),x=ue(),g=$t({queryKey:W.channels(e,r),queryFn:()=>te.wallet.channels(e,r)}),h=g.data??[],B=h.some(u=>u.status==="closing"),S=wr(B),k=async()=>{const u=await te.wallet.channels(e,r,!0);f.setQueryData(W.channels(e,r),u),f.invalidateQueries({queryKey:["channels",e]}),f.invalidateQueries({queryKey:W.wallet(e)})},N=h.map(en).filter(u=>u!==null&&u>S).sort((u,d)=>u-d)[0];L.useEffect(()=>{if(N===void 0)return;const u=setTimeout(()=>void k().catch(()=>{}),Math.max(1e3,N-Date.now()+5e3));return()=>clearTimeout(u)},[N]);const y=tn({mutationFn:u=>te.wallet.closeChannel(e,u.peerId),onSuccess:()=>{a(null),m("Channel closed by the seller")},onError:(u,d)=>l(w=>new Set(w).add(d.channelId)),invalidate:[["channels",e],W.wallet(e)]}),v=(u,d=c.has(u.channelId))=>{y.reset();const w=Ye(u,d||!s);w==="cooperative"?a({channel:u,mode:"cooperative"}):w==="on-chain"?a({channel:u,mode:"request"}):w==="withdraw"&&a({channel:u,mode:"withdraw"})},p=nn(h),R=u=>u.sellerName??H(u.peerId);return t.jsx("section",{id:"gc-channels",className:"gc-anchor",children:t.jsxs(Oe,{flush:!0,title:"Payment channels",description:"Funds reserved with sellers. Closing a channel returns what was not spent.",actions:t.jsx(gn,{checked:r,onChange:n,label:"Include closed"}),children:[p.count>0&&t.jsxs(ne,{tone:"warning",title:`${p.count} channel${p.count===1?"":"s"} ready to withdraw`,action:t.jsx(P,{size:"sm",onClick:()=>v(h.find(u=>u.status==="withdrawable")),children:"Withdraw"}),children:["About ",T(p.amount)," of unused reserve can return to the balance. The authorized wallet signs the withdrawal."]}),t.jsx(Ve,{query:g,children:u=>t.jsx(fn,{label:"Payment channels",rows:u,rowKey:d=>d.channelId,rowLabel:d=>`channel with ${R(d)}`,actions:d=>{const w=Ye(d,c.has(d.channelId)||!s);return[w==="cooperative"&&{label:"Close channel",onSelect:()=>v(d)},(w==="cooperative"||w==="on-chain")&&{label:"Close on chain",onSelect:()=>v(d,!0)},w==="withdraw"&&{label:"Withdraw reserve",onSelect:()=>v(d)}]},empty:t.jsx(ln,{icon:t.jsx(z.wallet,{size:18}),title:r?"No channels yet":"No open channels",body:"A channel opens the first time a seller serves this workspace."}),columns:[{key:"seller",header:"Seller",render:d=>d.sellerName??t.jsx(kt,{title:d.peerId,children:H(d.peerId)})},{key:"status",header:"Status",render:d=>t.jsx(Lt,{tone:sn(d),children:rn(d,S)})},{key:"reserved",header:"Reserved",align:"right",render:d=>T(d.reserved)},{key:"spent",header:"Spent",align:"right",render:d=>T(d.spent)},{key:"returns",header:"Returns on close",align:"right",secondary:!0,optional:!0,render:d=>on(d)?T(Qe(d)):"—"},{key:"opened",header:"Opened",secondary:!0,render:d=>an(d.openedAt)}]})}),!s&&h.some(u=>u.canCooperativeClose)&&t.jsx("p",{className:"gc-fineprint gc-panel-note",children:"Asking a seller to close needs an organization admin; you can still close on chain with the authorized wallet."}),t.jsx(Z,{isOpen:(i==null?void 0:i.mode)==="cooperative",onClose:()=>{a(null),y.reset()},size:"md",title:"Close this channel?",subtitle:i?`With ${R(i.channel)}. About ${T(Qe(i.channel))} returns to the balance.`:void 0,footer:i&&t.jsxs("div",{className:"gc-actions",children:[t.jsx(P,{variant:"ghost",onClick:()=>{a(null),y.reset()},children:"Cancel"}),y.error?t.jsxs(t.Fragment,{children:[t.jsx(P,{variant:"outline",disabled:y.isPending,onClick:()=>y.mutate(i.channel),children:"Try again"}),t.jsx(P,{onClick:()=>{y.reset(),a({channel:i.channel,mode:"request"})},children:"Close on chain instead"})]}):t.jsx(P,{disabled:y.isPending,onClick:()=>y.mutate(i.channel),children:y.isPending?"Asking the seller…":"Close channel"})]}),children:t.jsxs("div",{className:"gc-stack",children:[t.jsx("p",{className:"gc-muted",children:"The seller settles what was spent and the rest returns to your available balance at once. A new channel opens if this seller is used again."}),y.isPending&&t.jsx("p",{className:"gc-fineprint",children:"Waiting for the seller (up to a minute)…"}),y.error?t.jsx(ne,{tone:"danger",title:"The seller did not close it",children:cn(Fe(y.error))}):null]})}),t.jsx(Z,{isOpen:(i==null?void 0:i.mode)==="request"||(i==null?void 0:i.mode)==="withdraw",onClose:()=>a(null),size:"md",title:(i==null?void 0:i.mode)==="withdraw"?"Withdraw the unused reserve":"Close on chain",subtitle:i?`Channel with ${R(i.channel)}. Does not need the seller.`:void 0,children:i&&i.mode!=="cooperative"&&t.jsx(de,{chain:x.data,error:x.error,children:u=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(pr,{workspaceId:e,channel:i.channel,chain:u,step:i.mode,onAuthorize:()=>{a(null),o()},onDone:d=>{k().catch(()=>{}),d==="request"?m("Close requested. Withdraw in 15 minutes."):(m("Reserve returned to the balance"),a(null))}})})})})]})})}function xr({wallet:e,workspaceId:s,onWithdraw:o}){const r=Bt(s),n=r.data?Mt(r.data):null,i=()=>{var a;return(a=document.getElementById("gc-channels"))==null?void 0:a.scrollIntoView({behavior:"smooth",block:"start"})};return t.jsxs(Oe,{title:"Balance",actions:t.jsx(P,{size:"sm",variant:"outline",onClick:o,children:"Withdraw"}),children:[Zt(e)&&t.jsx(ne,{tone:"warning",title:"The whole balance is reserved in channels",action:t.jsx(P,{size:"sm",variant:"outline",onClick:i,children:"Manage channels"}),children:"Nothing is available for new sellers or withdrawals. Close channels you no longer use to return their unused reserve, or add funds."}),t.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[t.jsx(re,{label:"Available",value:T(e.available),strong:!0}),t.jsx(re,{label:"Reserved in channels",value:T(e.reserved)}),t.jsx(re,{label:"Authorized, not yet charged",value:n===null?"…":T(n)}),t.jsx(re,{label:"Credit limit",value:e.creditLimit===null?"None":T(e.creditLimit)})]}),ee(e.walletUsdc)>0&&t.jsxs("p",{className:"gc-fineprint gc-wallet-meta",children:[T(e.walletUsdc)," in the wallet, not deposited yet. ",Xt(e)]}),t.jsxs("p",{className:"gc-fineprint gc-wallet-meta",children:["Workspace wallet ",t.jsx(kt,{title:e.address,children:H(e.address)})," ",t.jsx(Ue,{iconOnly:!0,value:e.address,label:"Copy address"}),t.jsx("span",{"aria-hidden":"true",children:"·"})," Authorized spend is charged from channel reserves when sellers settle. Withdrawals go to the authorized wallet below."]})]})}function Cr({wallet:e,workspaceId:s,isOpen:o,onClose:r,onAuthorize:n}){const i=oe(),a=ae(),c=ue(),l=Rt(s),f=l.data&&He(l.data.operator)?l.data.operator:null;return t.jsx(Z,{isOpen:o,onClose:r,title:"Withdraw",subtitle:`${T(e.available)} available. ${f?`Sent to the authorized wallet ${H(f)}, which must sign it.`:"Withdrawals go to the authorized wallet, which must sign them."}`,children:t.jsx(de,{chain:c.data,error:c.error,children:m=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(mr,{action:"withdraw",workspaceId:s,wallet:e,chain:m,onAuthorize:()=>{r(),n()},onDone:()=>{a("Withdrawal confirmed"),i.invalidateQueries({queryKey:W.wallet(s)})}})})})})}function Mr(){const{workspace:e,viewer:s}=Wt(),o=Jt(e.id),r=ue(),[n,i]=L.useState(()=>new URLSearchParams(window.location.search).get("fund")==="1"?"fund":null),[a,c]=L.useState(null);return t.jsxs("div",{className:"gc-page",children:[t.jsx(Qt,{title:"Wallet & Funding",description:`Credits that pay for ${e.name}'s requests.`,actions:t.jsx(P,{variant:"brand",leadingIcon:t.jsx(z.plus,{size:14}),onClick:()=>i("fund"),children:"Add funds"})}),t.jsx(Ve,{query:o,rows:2,children:l=>t.jsxs(t.Fragment,{children:[t.jsx(Yt,{stale:l.stale}),t.jsx(xr,{wallet:l,workspaceId:e.id,onWithdraw:()=>i("withdraw")}),t.jsx(fr,{workspaceId:e.id,action:a,onActionChange:c}),t.jsx(Z,{isOpen:n==="fund",onClose:()=>i(null),size:"md",title:"Add funds",subtitle:`Credits that pay for ${e.name}'s requests.`,children:t.jsx(cr,{wallet:l,chain:r.data,workspaceId:e.id})}),t.jsx(Cr,{wallet:l,workspaceId:e.id,isOpen:n==="withdraw",onClose:()=>i(null),onAuthorize:()=>c("authorize")})]})}),t.jsx(yr,{workspaceId:e.id,canCooperate:Gt(s),onAuthorize:()=>c("authorize")})]})}export{Mr as default};
@@ -1 +0,0 @@
1
- import{j as s,r as c,B as o,v as f,ah as g,ag as w,ac as x}from"./index-jbhwAQ05.js";import{C as j}from"./ConnectWallet-Ba-nE-Ex.js";import{W as p,u as y,a as C,b as W,w as v}from"./en_US-Y4ZOVFV4-C1wt0O8b.js";import"./clsx-B-dksMZM.js";import"./index-9dOi2Cir.js";import"./index-BwpQbdIU.js";function k({onConfirmed:e}){const{address:t,isConnected:u}=y(),{disconnect:d}=C(),{signMessageAsync:h}=W(),[r,n]=c.useState(!1),[i,l]=c.useState(null);return!u||!t?s.jsx(j,{label:"Connect your wallet",size:"sm",variant:"outline",fullWidth:!1}):s.jsxs("div",{className:"gc-stack gc-stack--tight",children:[s.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[s.jsx(o,{size:"sm",disabled:r,onClick:async()=>{n(!0),l(null);try{e(await g(t,async a=>{try{return await h({message:a})}catch(m){throw new Error(v(m,"Signing was cancelled."))}}))}catch(a){l(w(a))}finally{n(!1)}},children:r?"Check your wallet…":`Confirm with ${f(t)}`}),s.jsx(o,{size:"sm",variant:"ghost",onClick:()=>d(),children:"Use a different wallet"})]}),i&&s.jsx(x,{tone:"danger",children:i})]})}function M(e){return s.jsx(p,{chain:null,children:s.jsx(k,{...e})})}export{M as default};