@langwatch/server 3.1.0-beta.21 → 3.1.0-beta.22

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 (171) hide show
  1. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/__init__.py +36 -0
  2. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/_logger.py +165 -0
  3. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/batch_clustering.py +153 -0
  4. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/build_response.py +77 -0
  5. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/constants.py +7 -0
  6. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/incremental_clustering.py +325 -0
  7. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/topic_naming.py +432 -0
  8. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/types.py +42 -0
  9. package/langevals/evaluators/topic_clustering/langevals_topic_clustering/utils.py +191 -0
  10. package/langevals/evaluators/topic_clustering/pyproject.toml +52 -0
  11. package/langevals/evaluators/topic_clustering/tests/test_topic_clustering.py +239 -0
  12. package/langevals/evaluators/topic_clustering/tests/test_topic_clustering_integration.py +97 -0
  13. package/langevals/evaluators/topic_clustering/tests/test_topic_naming.py +72 -0
  14. package/langevals/langevals/pytest_plugins/pass_rate_plugin.py +7 -1
  15. package/langevals/langevals/server.py +28 -0
  16. package/langevals/pyproject.toml +3 -0
  17. package/langevals/uv.lock +119 -20
  18. package/langwatch/dist/client/assets/{AnnotationsTable-BDAkYaz6.js → AnnotationsTable-uS_9SQ-g.js} +2 -2
  19. package/langwatch/dist/client/assets/{BatchEvaluationSummary-DMaQM_VB.js → BatchEvaluationSummary-DtFd8yKJ.js} +2 -2
  20. package/langwatch/dist/client/assets/{BudgetEditDrawer-CHaqmdIl.js → BudgetEditDrawer-CHEPz0hH.js} +2 -2
  21. package/langwatch/dist/client/assets/{ChartCard-D14PUg_d.js → ChartCard-s5fMPo7b.js} +2 -2
  22. package/langwatch/dist/client/assets/{ChatWindow-CRDnlP-Q.js → ChatWindow-C0XSteVJ.js} +2 -2
  23. package/langwatch/dist/client/assets/ChatWindow-DFEmNXQL.js +1 -0
  24. package/langwatch/dist/client/assets/{ConfirmDialog-CXIhncvW.js → ConfirmDialog-M94yLNvP.js} +2 -2
  25. package/langwatch/dist/client/assets/{ContactSalesBlock-CijLBwRC.js → ContactSalesBlock-CnnuZ8iI.js} +2 -2
  26. package/langwatch/dist/client/assets/{DSPyExperiment-B1YOL2m8.js → DSPyExperiment-CMA6lrlx.js} +2 -2
  27. package/langwatch/dist/client/assets/{FilterDisplay-BB0xWrLn.js → FilterDisplay-0S3NqCkq.js} +2 -2
  28. package/langwatch/dist/client/assets/{FormatMoney-w9vr_h0X.js → FormatMoney-CCygtAHg.js} +2 -2
  29. package/langwatch/dist/client/assets/{FoundryDrawer-CdJDXtpz.js → FoundryDrawer-B35xZ26C.js} +2 -2
  30. package/langwatch/dist/client/assets/{GatewayErrorPanel-DvE9U2dS.js → GatewayErrorPanel-BsaYQEie.js} +2 -2
  31. package/langwatch/dist/client/assets/{GatewayLayout-lv1p_6B5.js → GatewayLayout-LvwwrwMf.js} +2 -2
  32. package/langwatch/dist/client/assets/{GraphsLayout-BJ68J9e-.js → GraphsLayout-DJ-HI9N1.js} +2 -2
  33. package/langwatch/dist/client/assets/{GroupBindingInputRow-DebZBCnD.js → GroupBindingInputRow-CV-fBkX9.js} +2 -2
  34. package/langwatch/dist/client/assets/{MessagesTable-B6lYde-x.js → MessagesTable-9taaKCOZ.js} +2 -2
  35. package/langwatch/dist/client/assets/{NavigationFooter-CiOVzDUh.js → NavigationFooter-Dzvauw3l.js} +2 -2
  36. package/langwatch/dist/client/assets/{NoDataInfoBlock-quSW_MRm.js → NoDataInfoBlock-CLKl_wlX.js} +2 -2
  37. package/langwatch/dist/client/assets/{OpsPageShell-DJ1WlI6-.js → OpsPageShell-C_mTziRS.js} +2 -2
  38. package/langwatch/dist/client/assets/{OptimizationStudio-BlozXjcN.js → OptimizationStudio-D2zpsmJj.js} +8 -12
  39. package/langwatch/dist/client/assets/{PreconditionsField-BOfcWvmZ.js → PreconditionsField-WXB8kcTK.js} +2 -2
  40. package/langwatch/dist/client/assets/{SettingsLayout-CLCGxMAe.js → SettingsLayout--1gdEuhv.js} +2 -2
  41. package/langwatch/dist/client/assets/{SubscriptionPage-J8b2Zaj6.js → SubscriptionPage-B0ox_4kM.js} +2 -2
  42. package/langwatch/dist/client/assets/{VirtualKeySecretReveal-DR1VDLy7.js → VirtualKeySecretReveal-CRbI1dKQ.js} +2 -2
  43. package/langwatch/dist/client/assets/{WithPermissionGuard-DD8uo3UK.js → WithPermissionGuard-B4Jo8E5-.js} +2 -2
  44. package/langwatch/dist/client/assets/{__...path__-BZVaIayJ.js → __...path__-BF2zkD84.js} +2 -2
  45. package/langwatch/dist/client/assets/{_experiment_-B1aT-wS3.js → _experiment_-D02aoVQk.js} +2 -2
  46. package/langwatch/dist/client/assets/{_id_-oI_eq-I_.js → _id_-Ch8YmTiM.js} +2 -2
  47. package/langwatch/dist/client/assets/{_id_-DAqPuO73.js → _id_-D6ZvwHpH.js} +2 -2
  48. package/langwatch/dist/client/assets/{_id_-DUngklVb.js → _id_-DOC1ZkBm.js} +2 -2
  49. package/langwatch/dist/client/assets/{_id_-jFDAfbob.js → _id_-DfWwW6_N.js} +2 -2
  50. package/langwatch/dist/client/assets/{_id_-BKBrWGG0.js → _id_-DxUo4W7J.js} +2 -2
  51. package/langwatch/dist/client/assets/_not-found-DDh108-i.js +1 -0
  52. package/langwatch/dist/client/assets/{_project_-Bt1tayHB.js → _project_-_UUt5Ar9.js} +2 -2
  53. package/langwatch/dist/client/assets/{_runId_-CfvnDt5H.js → _runId_-Dimwzp48.js} +2 -2
  54. package/langwatch/dist/client/assets/_slug_-BMvKBwS_.js +2 -0
  55. package/langwatch/dist/client/assets/{_slug_-DZAdl0QS.js → _slug_-CE6VoDSC.js} +2 -2
  56. package/langwatch/dist/client/assets/{_slug_-DmoWXjKT.js → _slug_-OiOLG1Mv.js} +2 -2
  57. package/langwatch/dist/client/assets/{_team_-DL_wKSWK.js → _team_-DKvmwO_5.js} +2 -2
  58. package/langwatch/dist/client/assets/{_workflow_-DcMXLPUe.js → _workflow_-FkilKiB-.js} +3 -3
  59. package/langwatch/dist/client/assets/{_workflow_-NI9bac7d.js → _workflow_-gJZppg3h.js} +2 -2
  60. package/langwatch/dist/client/assets/{access-audit-CFwNwusI.js → access-audit-xcUVYMMT.js} +2 -2
  61. package/langwatch/dist/client/assets/{agents-Di4XRwcn.js → agents-D32g91cu.js} +2 -2
  62. package/langwatch/dist/client/assets/{all-C273mlDB.js → all-vnREzDZj.js} +2 -2
  63. package/langwatch/dist/client/assets/{analytics-CEAcSf6B.js → analytics-DP6Y4Feh.js} +2 -2
  64. package/langwatch/dist/client/assets/{annotation-scores-CHfn4LQp.js → annotation-scores-CjD4CEB6.js} +2 -2
  65. package/langwatch/dist/client/assets/{annotations-CHZQrha6.js → annotations-1rVXiDRQ.js} +2 -2
  66. package/langwatch/dist/client/assets/{api-keys-BT7HExHM.js → api-keys-BJpKyuaz.js} +2 -2
  67. package/langwatch/dist/client/assets/{audit-log-BGk-51Dt.js → audit-log-BdUdZjxp.js} +2 -2
  68. package/langwatch/dist/client/assets/{authentication-DvwXfkp-.js → authentication-8mQB00CC.js} +2 -2
  69. package/langwatch/dist/client/assets/{authorize-tXpHrWyw.js → authorize-BpUueMNW.js} +2 -2
  70. package/langwatch/dist/client/assets/{authorize-CRu9xlpU.js → authorize-CbNBtmxW.js} +2 -2
  71. package/langwatch/dist/client/assets/{automations-CjDvz9Ak.js → automations-34KMkRxd.js} +2 -2
  72. package/langwatch/dist/client/assets/{billing-plans-FUqEPN62.js → billing-plans-BUQp08MI.js} +2 -2
  73. package/langwatch/dist/client/assets/{budgets-BV6_RHrs.js → budgets-CdelE8Hv.js} +2 -2
  74. package/langwatch/dist/client/assets/{cache-rules-CtYA79E_.js → cache-rules-D2m1QlNJ.js} +2 -2
  75. package/langwatch/dist/client/assets/choose-C0LdeUiH.js +2 -0
  76. package/langwatch/dist/client/assets/{command-bar-CaJygoez.js → command-bar-DUK45yin.js} +7 -9
  77. package/langwatch/dist/client/assets/custom-hBq2K4FJ.js +1 -0
  78. package/langwatch/dist/client/assets/{datasets-vLWpH84_.js → datasets-ErNNhmjg.js} +2 -2
  79. package/langwatch/dist/client/assets/{dejaview-DwVR3RGg.js → dejaview-BaD4_v90.js} +2 -2
  80. package/langwatch/dist/client/assets/{dist-SwV3YZv3.js → dist-Cds4Mqhj.js} +4 -6
  81. package/langwatch/dist/client/assets/{edit-CyxsmQmW.js → edit-DpT8ejBV.js} +2 -2
  82. package/langwatch/dist/client/assets/{evaluations-BfgeZMph.js → evaluations-BdQ2Dm2r.js} +2 -2
  83. package/langwatch/dist/client/assets/{evaluations-HSQIMvbX.js → evaluations-C90I4VAr.js} +2 -2
  84. package/langwatch/dist/client/assets/{evaluators-DLHVvnrh.js → evaluators-ig_ugRLt.js} +2 -2
  85. package/langwatch/dist/client/assets/{foundry-Ckq0WjPU.js → foundry-B-X_80pD.js} +2 -2
  86. package/langwatch/dist/client/assets/{gateway-CDSYPZ6w.js → gateway-CS_mtJx-.js} +2 -2
  87. package/langwatch/dist/client/assets/{groups-CCCRUqPj.js → groups-Bp90ChP3.js} +2 -2
  88. package/langwatch/dist/client/assets/{index-Bm6z2fM9.js → index-TNQ6uyis.js} +4 -4
  89. package/langwatch/dist/client/assets/{license-CHOarGWr.js → license-CgnlvyuI.js} +2 -2
  90. package/langwatch/dist/client/assets/{me-CBya_vXs.js → me-DEqhm_KC.js} +2 -2
  91. package/langwatch/dist/client/assets/{members-lIFLh-rh.js → members-CUJANDtH.js} +2 -2
  92. package/langwatch/dist/client/assets/{messages-CG9j8Dz8.js → messages-fQBfCjvp.js} +2 -2
  93. package/langwatch/dist/client/assets/{metrics-C9pzeaI6.js → metrics-DeIxebpD.js} +2 -2
  94. package/langwatch/dist/client/assets/{model-costs-Bc5uqjkl.js → model-costs-C1RbgK--.js} +2 -2
  95. package/langwatch/dist/client/assets/{model-providers-B5UjRgS_.js → model-providers-Pv3ML_-t.js} +2 -2
  96. package/langwatch/dist/client/assets/{my-queue-BkEfiWyR.js → my-queue-BLre2NMr.js} +2 -2
  97. package/langwatch/dist/client/assets/{ops-Cc-g-CMn.js → ops-CCw-FJaT.js} +2 -2
  98. package/langwatch/dist/client/assets/{organization-features-CoIKKHkQ.js → organization-features-rqg-75mI.js} +2 -2
  99. package/langwatch/dist/client/assets/{organizations-DWcQUTzi.js → organizations-DjCzIHVx.js} +2 -2
  100. package/langwatch/dist/client/assets/{persistence-CTQ44vGL.js → persistence-BPvHS0F6.js} +2 -2
  101. package/langwatch/dist/client/assets/{plans-Dq3eFg5K.js → plans-Ch2Ol-Fd.js} +2 -2
  102. package/langwatch/dist/client/assets/{projections-CTNj1QBM.js → projections-it4FOVjm.js} +2 -2
  103. package/langwatch/dist/client/assets/{projects-BxM7C87h.js → projects-CjWZFLfn.js} +2 -2
  104. package/langwatch/dist/client/assets/{prompts-DhXnJT6e.js → prompts-DilmFH_s.js} +2 -2
  105. package/langwatch/dist/client/assets/{providers-DW7VWdqq.js → providers-tlLT_lTF.js} +2 -2
  106. package/langwatch/dist/client/assets/{reports-D3QFKhNP.js → reports-vlrcTrLs.js} +2 -2
  107. package/langwatch/dist/client/assets/{roles-B_0t5DWA.js → roles-DNgi-NQ9.js} +2 -2
  108. package/langwatch/dist/client/assets/{scenarios-BX3XslU0.js → scenarios-BmG_wDkR.js} +2 -2
  109. package/langwatch/dist/client/assets/{scim-DDsLO39r.js → scim-BKr1_FHt.js} +2 -2
  110. package/langwatch/dist/client/assets/{secrets-BvEGwDCy.js → secrets-CU8ocTGv.js} +2 -2
  111. package/langwatch/dist/client/assets/{settings-9giNiAQQ.js → settings-CDzdoYVK.js} +2 -2
  112. package/langwatch/dist/client/assets/{setup-HxXKoVKG.js → setup-nEvn2rjN.js} +2 -2
  113. package/langwatch/dist/client/assets/{subscription-DhyswDze.js → subscription-BPNl_6jF.js} +3 -3
  114. package/langwatch/dist/client/assets/{subscriptions-Dyyau22a.js → subscriptions-D0G-OE5C.js} +2 -2
  115. package/langwatch/dist/client/assets/{teams-DRmeAxzf.js → teams-DThgDQvB.js} +2 -2
  116. package/langwatch/dist/client/assets/{textOverflowHeuristic-JibhpzDV.js → textOverflowHeuristic-DTC8-Ffx.js} +2 -2
  117. package/langwatch/dist/client/assets/{topic-clustering-Bllfw5rZ.js → topic-clustering-BR2Mbpao.js} +2 -2
  118. package/langwatch/dist/client/assets/{topics-CpiGYxqb.js → topics-CI8GoNqp.js} +2 -2
  119. package/langwatch/dist/client/assets/{traceExecutor-CiHXJB0V.js → traceExecutor-CDUGyUaw.js} +2 -2
  120. package/langwatch/dist/client/assets/{usage-BnsstwBY.js → usage-B4mR7ut_.js} +2 -2
  121. package/langwatch/dist/client/assets/{usage-CoyGtJoI.js → usage-C8fbffYi.js} +2 -2
  122. package/langwatch/dist/client/assets/{useAdminResource-SPC5iBHM.js → useAdminResource-SmnnHro6.js} +2 -2
  123. package/langwatch/dist/client/assets/{useAnnotationQueues-2DKZTC7r.js → useAnnotationQueues-CA6Vk--V.js} +2 -2
  124. package/langwatch/dist/client/assets/{useAvailableEvaluators-HndTl2LV.js → useAvailableEvaluators-hmbmcRQr.js} +2 -2
  125. package/langwatch/dist/client/assets/{useDeleteDatasetConfirmation-BgWN6Qqb.js → useDeleteDatasetConfirmation-BCK_zUUe.js} +2 -2
  126. package/langwatch/dist/client/assets/{useWorkflowStore-e1wFCvo2.js → useWorkflowStore-QUJ3J8X9.js} +2 -2
  127. package/langwatch/dist/client/assets/{users-C6wjliCC.js → users-CfhanCfR.js} +2 -2
  128. package/langwatch/dist/client/assets/{users-tF6ZKeV1.js → users-HjuN3o6k.js} +2 -2
  129. package/langwatch/dist/client/assets/{virtual-keys-BL-65S0B.js → virtual-keys-Bj-MhW66.js} +2 -2
  130. package/langwatch/dist/client/assets/{wizard-faGkpZDT.js → wizard-dRWCVVx6.js} +2 -2
  131. package/langwatch/dist/client/assets/{workbench-Oj0s_YR-.js → workbench-CuixH3G1.js} +2 -2
  132. package/langwatch/dist/client/assets/{workflows-Cu9k-Twu.js → workflows-BT6m4Yu9.js} +2 -2
  133. package/langwatch/dist/client/index.html +3 -3
  134. package/langwatch/scripts/seed-dogfood-password.ts +163 -0
  135. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
  136. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +180 -0
  137. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
  138. package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
  139. package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
  140. package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
  141. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
  142. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
  143. package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
  144. package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
  145. package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
  146. package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
  147. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
  148. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
  149. package/langwatch/src/optimization_studio/registry.ts +2 -4
  150. package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
  151. package/langwatch/src/server/api/routers/workflows.ts +18 -0
  152. package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
  153. package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
  154. package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
  155. package/langwatch/src/server/modelProviders/utils.ts +11 -1
  156. package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
  157. package/langwatch/src/server/nlpgo/nlpgoFetch.ts +142 -0
  158. package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
  159. package/langwatch/src/server/routes/playground.ts +11 -1
  160. package/langwatch/src/server/routes/workflows.ts +17 -0
  161. package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
  162. package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
  163. package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
  164. package/langwatch_nlp/scripts/entrypoint.sh +67 -0
  165. package/package.json +1 -1
  166. package/packages/server/dist/cli.cjs +67 -94
  167. package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
  168. package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
  169. package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
  170. package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
  171. package/langwatch/dist/client/assets/custom-CSiS1liN.js +0 -1
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,gs as u,qi as d,vs as f,xs as p,ys as m}from"./command-bar-CaJygoez.js";import{j as h,n as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{n as v}from"./toaster-C_DYALhL.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,s as z,u as B}from"./useAdminResource-SPC5iBHM.js";var V=N(),H=e(t()),U=h(),W=25;function G(){let e=M(),t=(0,H.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,H.useState)(1),[u,h]=(0,H.useState)(t.current),[g]=l(u,300),[v,y]=(0,H.useState)(null),b=I(`organization`,{pagination:{page:n,perPage:W},sort:{field:`createdAt`,order:`DESC`},filter:g?{query:g}:{}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(P,{title:`Organizations`,searchValue:u,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:b.isLoading,isFetching:b.isFetching,error:b.error,pagination:{page:n,perPage:W,total:b.data?.total??0,onPageChange:c},children:(0,U.jsxs)(p,{variant:`line`,size:`md`,width:`full`,children:[(0,U.jsx)(s,{children:(0,U.jsxs)(i,{children:[(0,U.jsx)(m,{children:`ID`}),(0,U.jsx)(m,{children:`Name`}),(0,U.jsx)(m,{children:`Slug`}),(0,U.jsx)(m,{children:`Plan model`}),(0,U.jsx)(m,{children:`Currency`}),(0,U.jsx)(m,{children:`SSO domain`}),(0,U.jsx)(m,{children:`Created`}),(0,U.jsx)(m,{width:`60px`,textAlign:`right`})]})}),(0,U.jsxs)(o,{children:[b.data?.data.length===0&&(0,U.jsx)(i,{children:(0,U.jsx)(f,{colSpan:8,children:(0,U.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organizations match your search.`})})}),b.data?.data.map(e=>(0,U.jsxs)(i,{children:[(0,U.jsx)(f,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,U.jsx)(f,{children:e.name}),(0,U.jsx)(f,{children:e.slug}),(0,U.jsx)(f,{children:e.pricingModel}),(0,U.jsx)(f,{children:e.currency}),(0,U.jsx)(f,{children:e.ssoDomain??(0,U.jsx)(L,{})}),(0,U.jsx)(f,{children:F(e.createdAt)}),(0,U.jsx)(f,{textAlign:`right`,children:(0,U.jsx)(_,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,U.jsxs)(d.Root,{children:[(0,U.jsx)(d.Trigger,{children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(d.Content,{children:(0,U.jsxs)(d.Item,{value:`edit`,onClick:()=>y(e),children:[(0,U.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,U.jsx)(Y,{organization:v,onClose:()=>y(null)})]})}function K(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function q(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function J(e){return e.trim()===``?null:e}function Y({organization:e,onClose:t}){let r=R(`organization`),[i,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{e&&a({name:e.name??``,slug:e.slug??``,phoneNumber:e.phoneNumber??``,ssoDomain:e.ssoDomain??``,ssoProvider:e.ssoProvider??``,usageSpendingMaxLimit:e.usageSpendingMaxLimit?.toString()??``,signedDPA:!!e.signedDPA,promoCode:e.promoCode??``,stripeCustomerId:e.stripeCustomerId??``,currency:e.currency,pricingModel:e.pricingModel,license:e.license??``,licenseExpiresAt:K(e.licenseExpiresAt),useCustomElasticsearch:!!e.useCustomElasticsearch,useCustomS3:!!e.useCustomS3,elasticsearchNodeUrl:``,elasticsearchApiKey:``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,U.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,U.jsxs)(n.Content,{children:[(0,U.jsx)(n.Header,{children:(0,U.jsx)(n.Title,{children:`Edit Organization`})}),(0,U.jsx)(n.CloseTrigger,{}),(0,U.jsx)(n.Body,{children:e&&i&&(0,U.jsxs)(j,{gap:4,align:`stretch`,children:[(0,U.jsx)(X,{children:`Identity`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Name`}),(0,U.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Slug`}),(0,U.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,U.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Phone number`}),(0,U.jsx)(O,{type:`tel`,value:i.phoneNumber,onChange:e=>o(`phoneNumber`,e.target.value)})]}),(0,U.jsx)(X,{children:`Billing`}),(0,U.jsxs)(k,{gap:3,align:`start`,children:[(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Currency`}),(0,U.jsx)(Z,{value:i.currency,options:Object.values(V.Currency),onChange:e=>o(`currency`,e)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Pricing model`}),(0,U.jsx)(Z,{value:i.pricingModel,options:Object.values(V.PricingModel),onChange:e=>o(`pricingModel`,e)})]})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Stripe customer ID`}),(0,U.jsx)(O,{value:i.stripeCustomerId,onChange:e=>o(`stripeCustomerId`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Promo code`}),(0,U.jsx)(O,{value:i.promoCode,onChange:e=>o(`promoCode`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Usage spending max limit`}),(0,U.jsx)(O,{type:`number`,value:i.usageSpendingMaxLimit,onChange:e=>o(`usageSpendingMaxLimit`,e.target.value),placeholder:`Leave empty for no cap`})]}),(0,U.jsx)(Q,{label:`Signed DPA`,hint:`Enterprise data processing agreement on file.`,checked:i.signedDPA,onChange:e=>o(`signedDPA`,e)}),(0,U.jsx)(X,{children:`Authentication`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO domain`}),(0,U.jsx)(O,{value:i.ssoDomain,onChange:e=>o(`ssoDomain`,e.target.value),placeholder:`e.g. acme.com`}),(0,U.jsx)(E,{children:`Lowercased server-side. Users with this email domain can sign in via SSO.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO provider`}),(0,U.jsx)(O,{value:i.ssoProvider,onChange:e=>o(`ssoProvider`,e.target.value)})]}),(0,U.jsx)(X,{children:`License`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License key`}),(0,U.jsx)(u,{rows:4,value:i.license,onChange:e=>o(`license`,e.target.value),fontFamily:`mono`,fontSize:`xs`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License expires at`}),(0,U.jsx)(O,{type:`date`,value:i.licenseExpiresAt,onChange:e=>o(`licenseExpiresAt`,e.target.value)})]}),(0,U.jsx)(X,{children:`Custom Elasticsearch`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom Elasticsearch`,hint:`Override the platform-managed ClickHouse/ES cluster for this tenant.`,checked:i.useCustomElasticsearch,onChange:e=>o(`useCustomElasticsearch`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Node URL`}),(0,U.jsx)(O,{type:`url`,value:i.elasticsearchNodeUrl,onChange:e=>o(`elasticsearchNodeUrl`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`API key`}),(0,U.jsx)(O,{type:`password`,value:i.elasticsearchApiKey,onChange:e=>o(`elasticsearchApiKey`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch,autoComplete:`new-password`})]}),(0,U.jsx)(X,{children:`Custom S3`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom S3`,hint:`Store large blobs (datasets, uploads) in the tenant's own bucket.`,checked:i.useCustomS3,onChange:e=>o(`useCustomS3`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Endpoint`}),(0,U.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Bucket`}),(0,U.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Access key ID`}),(0,U.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3,autoComplete:`new-password`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Secret access key`}),(0,U.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`,disabled:!i.useCustomS3})]}),(0,U.jsx)(y,{my:2}),(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Organization ID: `,e.id]}),(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Created: `,F(e.createdAt)]})]})]})}),(0,U.jsx)(n.Footer,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsx)(A,{}),(0,U.jsx)(g,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,U.jsx)(g,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.phoneNumber!==(e.phoneNumber??``)&&(n.phoneNumber=J(i.phoneNumber)),i.ssoDomain!==(e.ssoDomain??``)&&(n.ssoDomain=J(i.ssoDomain)),i.ssoProvider!==(e.ssoProvider??``)&&(n.ssoProvider=J(i.ssoProvider));let a=q(i.usageSpendingMaxLimit);a!==e.usageSpendingMaxLimit&&(n.usageSpendingMaxLimit=a),i.signedDPA!==!!e.signedDPA&&(n.signedDPA=i.signedDPA),i.promoCode!==(e.promoCode??``)&&(n.promoCode=J(i.promoCode)),i.stripeCustomerId!==(e.stripeCustomerId??``)&&(n.stripeCustomerId=J(i.stripeCustomerId)),i.currency!==e.currency&&(n.currency=i.currency),i.pricingModel!==e.pricingModel&&(n.pricingModel=i.pricingModel),i.license!==(e.license??``)&&(n.license=J(i.license));let o=z(i.licenseExpiresAt);if(o!==e.licenseExpiresAt&&(n.licenseExpiresAt=o),i.useCustomElasticsearch!==!!e.useCustomElasticsearch&&(n.useCustomElasticsearch=i.useCustomElasticsearch),i.useCustomS3!==!!e.useCustomS3&&(n.useCustomS3=i.useCustomS3),i.elasticsearchNodeUrl.trim()!==``&&(n.elasticsearchNodeUrl=i.elasticsearchNodeUrl),i.elasticsearchApiKey.trim()!==``&&(n.elasticsearchApiKey=i.elasticsearchApiKey),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{v.create({title:`Organization updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>v.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function X({children:e}){return(0,U.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function Z({value:e,options:t,onChange:n}){return(0,U.jsxs)(x,{size:`sm`,width:`full`,children:[(0,U.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(b,{})]})}function Q({label:e,hint:t,checked:n,onChange:r}){return(0,U.jsx)(T,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsx)(D,{children:e}),t&&(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,U.jsx)(A,{}),(0,U.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function $(){return(0,U.jsx)(B,{children:(0,U.jsx)(G,{})})}export{$ as default};
2
- //# sourceMappingURL=organizations-DWcQUTzi.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,gs as u,qi as d,vs as f,xs as p,ys as m}from"./command-bar-DUK45yin.js";import{j as h,n as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{n as v}from"./toaster-C_DYALhL.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,s as z,u as B}from"./useAdminResource-SmnnHro6.js";var V=N(),H=e(t()),U=h(),W=25;function G(){let e=M(),t=(0,H.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,H.useState)(1),[u,h]=(0,H.useState)(t.current),[g]=l(u,300),[v,y]=(0,H.useState)(null),b=I(`organization`,{pagination:{page:n,perPage:W},sort:{field:`createdAt`,order:`DESC`},filter:g?{query:g}:{}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(P,{title:`Organizations`,searchValue:u,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:b.isLoading,isFetching:b.isFetching,error:b.error,pagination:{page:n,perPage:W,total:b.data?.total??0,onPageChange:c},children:(0,U.jsxs)(p,{variant:`line`,size:`md`,width:`full`,children:[(0,U.jsx)(s,{children:(0,U.jsxs)(i,{children:[(0,U.jsx)(m,{children:`ID`}),(0,U.jsx)(m,{children:`Name`}),(0,U.jsx)(m,{children:`Slug`}),(0,U.jsx)(m,{children:`Plan model`}),(0,U.jsx)(m,{children:`Currency`}),(0,U.jsx)(m,{children:`SSO domain`}),(0,U.jsx)(m,{children:`Created`}),(0,U.jsx)(m,{width:`60px`,textAlign:`right`})]})}),(0,U.jsxs)(o,{children:[b.data?.data.length===0&&(0,U.jsx)(i,{children:(0,U.jsx)(f,{colSpan:8,children:(0,U.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No organizations match your search.`})})}),b.data?.data.map(e=>(0,U.jsxs)(i,{children:[(0,U.jsx)(f,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,U.jsx)(f,{children:e.name}),(0,U.jsx)(f,{children:e.slug}),(0,U.jsx)(f,{children:e.pricingModel}),(0,U.jsx)(f,{children:e.currency}),(0,U.jsx)(f,{children:e.ssoDomain??(0,U.jsx)(L,{})}),(0,U.jsx)(f,{children:F(e.createdAt)}),(0,U.jsx)(f,{textAlign:`right`,children:(0,U.jsx)(_,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,U.jsxs)(d.Root,{children:[(0,U.jsx)(d.Trigger,{children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(d.Content,{children:(0,U.jsxs)(d.Item,{value:`edit`,onClick:()=>y(e),children:[(0,U.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,U.jsx)(Y,{organization:v,onClose:()=>y(null)})]})}function K(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function q(e){if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function J(e){return e.trim()===``?null:e}function Y({organization:e,onClose:t}){let r=R(`organization`),[i,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{e&&a({name:e.name??``,slug:e.slug??``,phoneNumber:e.phoneNumber??``,ssoDomain:e.ssoDomain??``,ssoProvider:e.ssoProvider??``,usageSpendingMaxLimit:e.usageSpendingMaxLimit?.toString()??``,signedDPA:!!e.signedDPA,promoCode:e.promoCode??``,stripeCustomerId:e.stripeCustomerId??``,currency:e.currency,pricingModel:e.pricingModel,license:e.license??``,licenseExpiresAt:K(e.licenseExpiresAt),useCustomElasticsearch:!!e.useCustomElasticsearch,useCustomS3:!!e.useCustomS3,elasticsearchNodeUrl:``,elasticsearchApiKey:``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,U.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,U.jsxs)(n.Content,{children:[(0,U.jsx)(n.Header,{children:(0,U.jsx)(n.Title,{children:`Edit Organization`})}),(0,U.jsx)(n.CloseTrigger,{}),(0,U.jsx)(n.Body,{children:e&&i&&(0,U.jsxs)(j,{gap:4,align:`stretch`,children:[(0,U.jsx)(X,{children:`Identity`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Name`}),(0,U.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Slug`}),(0,U.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,U.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Phone number`}),(0,U.jsx)(O,{type:`tel`,value:i.phoneNumber,onChange:e=>o(`phoneNumber`,e.target.value)})]}),(0,U.jsx)(X,{children:`Billing`}),(0,U.jsxs)(k,{gap:3,align:`start`,children:[(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Currency`}),(0,U.jsx)(Z,{value:i.currency,options:Object.values(V.Currency),onChange:e=>o(`currency`,e)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Pricing model`}),(0,U.jsx)(Z,{value:i.pricingModel,options:Object.values(V.PricingModel),onChange:e=>o(`pricingModel`,e)})]})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Stripe customer ID`}),(0,U.jsx)(O,{value:i.stripeCustomerId,onChange:e=>o(`stripeCustomerId`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Promo code`}),(0,U.jsx)(O,{value:i.promoCode,onChange:e=>o(`promoCode`,e.target.value)})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Usage spending max limit`}),(0,U.jsx)(O,{type:`number`,value:i.usageSpendingMaxLimit,onChange:e=>o(`usageSpendingMaxLimit`,e.target.value),placeholder:`Leave empty for no cap`})]}),(0,U.jsx)(Q,{label:`Signed DPA`,hint:`Enterprise data processing agreement on file.`,checked:i.signedDPA,onChange:e=>o(`signedDPA`,e)}),(0,U.jsx)(X,{children:`Authentication`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO domain`}),(0,U.jsx)(O,{value:i.ssoDomain,onChange:e=>o(`ssoDomain`,e.target.value),placeholder:`e.g. acme.com`}),(0,U.jsx)(E,{children:`Lowercased server-side. Users with this email domain can sign in via SSO.`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`SSO provider`}),(0,U.jsx)(O,{value:i.ssoProvider,onChange:e=>o(`ssoProvider`,e.target.value)})]}),(0,U.jsx)(X,{children:`License`}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License key`}),(0,U.jsx)(u,{rows:4,value:i.license,onChange:e=>o(`license`,e.target.value),fontFamily:`mono`,fontSize:`xs`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`License expires at`}),(0,U.jsx)(O,{type:`date`,value:i.licenseExpiresAt,onChange:e=>o(`licenseExpiresAt`,e.target.value)})]}),(0,U.jsx)(X,{children:`Custom Elasticsearch`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom Elasticsearch`,hint:`Override the platform-managed ClickHouse/ES cluster for this tenant.`,checked:i.useCustomElasticsearch,onChange:e=>o(`useCustomElasticsearch`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Node URL`}),(0,U.jsx)(O,{type:`url`,value:i.elasticsearchNodeUrl,onChange:e=>o(`elasticsearchNodeUrl`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`API key`}),(0,U.jsx)(O,{type:`password`,value:i.elasticsearchApiKey,onChange:e=>o(`elasticsearchApiKey`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomElasticsearch,autoComplete:`new-password`})]}),(0,U.jsx)(X,{children:`Custom S3`}),(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,U.jsx)(Q,{label:`Use custom S3`,hint:`Store large blobs (datasets, uploads) in the tenant's own bucket.`,checked:i.useCustomS3,onChange:e=>o(`useCustomS3`,e)}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Endpoint`}),(0,U.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Bucket`}),(0,U.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Access key ID`}),(0,U.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,disabled:!i.useCustomS3,autoComplete:`new-password`})]}),(0,U.jsxs)(T,{children:[(0,U.jsx)(D,{children:`Secret access key`}),(0,U.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`,disabled:!i.useCustomS3})]}),(0,U.jsx)(y,{my:2}),(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Organization ID: `,e.id]}),(0,U.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Created: `,F(e.createdAt)]})]})]})}),(0,U.jsx)(n.Footer,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsx)(A,{}),(0,U.jsx)(g,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,U.jsx)(g,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.phoneNumber!==(e.phoneNumber??``)&&(n.phoneNumber=J(i.phoneNumber)),i.ssoDomain!==(e.ssoDomain??``)&&(n.ssoDomain=J(i.ssoDomain)),i.ssoProvider!==(e.ssoProvider??``)&&(n.ssoProvider=J(i.ssoProvider));let a=q(i.usageSpendingMaxLimit);a!==e.usageSpendingMaxLimit&&(n.usageSpendingMaxLimit=a),i.signedDPA!==!!e.signedDPA&&(n.signedDPA=i.signedDPA),i.promoCode!==(e.promoCode??``)&&(n.promoCode=J(i.promoCode)),i.stripeCustomerId!==(e.stripeCustomerId??``)&&(n.stripeCustomerId=J(i.stripeCustomerId)),i.currency!==e.currency&&(n.currency=i.currency),i.pricingModel!==e.pricingModel&&(n.pricingModel=i.pricingModel),i.license!==(e.license??``)&&(n.license=J(i.license));let o=z(i.licenseExpiresAt);if(o!==e.licenseExpiresAt&&(n.licenseExpiresAt=o),i.useCustomElasticsearch!==!!e.useCustomElasticsearch&&(n.useCustomElasticsearch=i.useCustomElasticsearch),i.useCustomS3!==!!e.useCustomS3&&(n.useCustomS3=i.useCustomS3),i.elasticsearchNodeUrl.trim()!==``&&(n.elasticsearchNodeUrl=i.elasticsearchNodeUrl),i.elasticsearchApiKey.trim()!==``&&(n.elasticsearchApiKey=i.elasticsearchApiKey),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{v.create({title:`Organization updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>v.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function X({children:e}){return(0,U.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function Z({value:e,options:t,onChange:n}){return(0,U.jsxs)(x,{size:`sm`,width:`full`,children:[(0,U.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(b,{})]})}function Q({label:e,hint:t,checked:n,onChange:r}){return(0,U.jsx)(T,{children:(0,U.jsxs)(k,{width:`full`,children:[(0,U.jsxs)(j,{align:`start`,gap:0,children:[(0,U.jsx)(D,{children:e}),t&&(0,U.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,U.jsx)(A,{}),(0,U.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function $(){return(0,U.jsx)(B,{children:(0,U.jsx)(G,{})})}export{$ as default};
2
+ //# sourceMappingURL=organizations-DjCzIHVx.js.map
@@ -1,2 +1,2 @@
1
- import{_t as e,gt as t,ht as n,vt as r}from"./command-bar-CaJygoez.js";import{A as i,D as a,E as o,P as s,j as c,m as l}from"./types-B5pOLKPA.js";var u=a({runId:c().optional(),versionId:c().optional(),targetOutputs:i(l(s())),targetMetadata:i(l(r.nullish())),evaluatorResults:i(i(l(s()))),errors:i(l(c().nullish()))});a({experimentId:c().optional(),experimentSlug:c().optional(),name:c(),datasets:l(n),activeDatasetId:c(),evaluators:l(t),targets:l(e),results:u.optional(),hiddenColumns:l(c()).optional(),concurrency:o().min(1).max(24).optional()});var d=e=>{if(Object.keys(e.targetOutputs).length>0||Object.keys(e.targetMetadata).length>0||Object.keys(e.evaluatorResults).length>0||Object.keys(e.errors).length>0)return{runId:e.runId,versionId:e.versionId,targetOutputs:e.targetOutputs,targetMetadata:e.targetMetadata,evaluatorResults:e.evaluatorResults,errors:e.errors}},f=e=>{let{ui:t,results:n,datasets:r,...i}=e,a=d(n),o=r.map(e=>{if(e.type===`saved`){let{savedRecords:t,...n}=e;return n}return e});return{...i,datasets:o,results:a,hiddenColumns:Array.from(t.hiddenColumns),concurrency:t.concurrency}};export{f as t};
2
- //# sourceMappingURL=persistence-CTQ44vGL.js.map
1
+ import{_t as e,gt as t,ht as n,vt as r}from"./command-bar-DUK45yin.js";import{A as i,D as a,E as o,P as s,j as c,m as l}from"./types-B5pOLKPA.js";var u=a({runId:c().optional(),versionId:c().optional(),targetOutputs:i(l(s())),targetMetadata:i(l(r.nullish())),evaluatorResults:i(i(l(s()))),errors:i(l(c().nullish()))});a({experimentId:c().optional(),experimentSlug:c().optional(),name:c(),datasets:l(n),activeDatasetId:c(),evaluators:l(t),targets:l(e),results:u.optional(),hiddenColumns:l(c()).optional(),concurrency:o().min(1).max(24).optional()});var d=e=>{if(Object.keys(e.targetOutputs).length>0||Object.keys(e.targetMetadata).length>0||Object.keys(e.evaluatorResults).length>0||Object.keys(e.errors).length>0)return{runId:e.runId,versionId:e.versionId,targetOutputs:e.targetOutputs,targetMetadata:e.targetMetadata,evaluatorResults:e.evaluatorResults,errors:e.errors}},f=e=>{let{ui:t,results:n,datasets:r,...i}=e,a=d(n),o=r.map(e=>{if(e.type===`saved`){let{savedRecords:t,...n}=e;return n}return e});return{...i,datasets:o,results:a,hiddenColumns:Array.from(t.hiddenColumns),concurrency:t.concurrency}};export{f as t};
2
+ //# sourceMappingURL=persistence-BPvHS0F6.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Za as n}from"./command-bar-CaJygoez.js";import{j as r,n as i,r as a}from"./stack-oJ9iWdbl.js";import{t as o}from"./box-BsM8YLGl.js";import{an as s,in as c}from"./dist-SwV3YZv3.js";import{o as l}from"./terminal-CfM0q99k.js";import{t as u}from"./heading-D90dlSnH.js";import{t as d}from"./text-CwTrMF8x.js";import{n as f,r as p}from"./code-FF_ibTVI.js";import{t as m}from"./h-stack-BKLDJ2vg.js";import{r as h,t as g}from"./card-CMtKVPVl.js";import{t as _}from"./link-CwZhwOLq.js";import{t as v}from"./simple-grid-C3IW90zo.js";import{t as y}from"./v-stack-EOPQ57OZ.js";import{s as b}from"./auth-client-D3UhxhQi.js";import{c as x,t as S}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as C}from"./createLucideIcon-BJKFyRLS.js";import{t as w}from"./SettingsLayout-CLCGxMAe.js";import{i as T,l as E,n as D,o as O,s as k,t as A,u as j}from"./billing-plans-FUqEPN62.js";import{t as M}from"./constants-BT2q4NNM.js";import{t as N}from"./WithPermissionGuard-DD8uo3UK.js";var P=C(`euro`,[[`path`,{d:`M4 10h12`,key:`1y6xl8`}],[`path`,{d:`M4 14h9`,key:`1loblj`}],[`path`,{d:`M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2`,key:`1j6lzo`}]]),F=e(t()),I=x();function L(e){if(!e)return null;let t=e.type?.toUpperCase();return e.free||t===`FREE`?`free`:t===`GROWTH`||t&&j(t)?`growth`:t===`ENTERPRISE`?`enterprise`:null}var R=r(),z=e=>[{id:`free`,name:`Free`,subtitle:`For teams getting started`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`blue`,features:D},{id:`growth`,name:`Growth`,subtitle:`Seat and usage pricing for growing teams`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`orange`,features:O(e)},{id:`enterprise`,name:`Enterprise`,subtitle:`Regulated and high-volume deployments`,actionLabel:`Contact Sales`,actionHref:M,actionColor:`blue`,features:A}];function B(e,t,n){if(e===`free`)return`${T[t]}0 per user/month`;if(e===`growth`){let e=E();return`${k({cents:n===`annual`?Math.round(e[t].annual/12):e[t].monthly,currency:t})} per seat/month`}return`Custom pricing`}function V({plan:e,currentPlan:t}){return e.id===`free`?null:e.id===`growth`?t===`growth`?(0,R.jsx)(y,{width:`full`,gap:2,children:(0,R.jsx)(i,{asChild:!0,width:`full`,color:`bg.emphasized`,backgroundColor:`orange.600`,variant:`solid`,children:(0,R.jsx)(_,{href:`/settings/members`,children:`Add Members`})})}):(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`orange`,variant:`solid`,children:(0,R.jsx)(_,{color:`white`,href:`/settings/subscription`,children:`Upgrade Now`})}):e.id===`enterprise`&&t!==`enterprise`?(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`muted`,variant:`outline`,children:(0,R.jsx)(_,{href:M,isExternal:!0,children:`Contact Sales`})}):null}function H({plan:e,isCurrent:t,currentPlan:n,currency:r,billingPeriod:i}){return(0,R.jsx)(h,{"data-testid":`plan-column-${e.id}`,borderWidth:1,borderColor:`border.emphasized`,bg:`bg.panel`,borderRadius:`2xl`,height:`full`,transition:`all 0.2s ease-in-out`,_hover:{transform:`scale(1.02)`,boxShadow:`lg`},children:(0,R.jsx)(g,{paddingY:6,paddingX:6,children:(0,R.jsxs)(y,{align:`stretch`,gap:5,height:`full`,children:[(0,R.jsxs)(y,{align:`start`,gap:1,children:[(0,R.jsxs)(m,{gap:2,children:[(0,R.jsx)(u,{as:`h2`,size:`xl`,children:e.name}),t&&(0,R.jsx)(s,{colorPalette:`green`,variant:`surface`,size:`lg`,children:`Current`})]}),(0,R.jsx)(d,{color:`fg`,fontSize:`md`,fontWeight:`medium`,children:B(e.id,r,i)}),(0,R.jsx)(d,{color:`fg.muted`,fontSize:`sm`,children:e.subtitle})]}),(0,R.jsx)(y,{align:`start`,gap:2,flex:1,children:e.features.map(e=>(0,R.jsxs)(m,{align:`start`,gap:2,children:[(0,R.jsx)(f,{size:14,style:{marginTop:`4px`,flexShrink:0},color:`var(--chakra-colors-blue-500)`}),(0,R.jsx)(d,{fontSize:`sm`,color:`fg.muted`,children:e})]},e))}),(0,R.jsx)(y,{width:`full`,marginTop:`auto`,paddingTop:4,children:(0,R.jsx)(V,{plan:e,currentPlan:n})})]})})})}function U({activePlan:e,pricingModel:t}){let r=L(e),s=t===`TIERED`&&!e?.free,f=b.currency.detectCurrency.useQuery({}),[h,g]=(0,F.useState)(null),x=h??f.data?.currency??I.Currency.EUR,[S,C]=(0,F.useState)(`monthly`);return f.isLoading?(0,R.jsx)(a,{}):(0,R.jsxs)(y,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,R.jsxs)(c,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,R.jsx)(o,{flex:1,children:(0,R.jsx)(_,{href:`/settings/subscription`,children:(0,R.jsxs)(i,{variant:`ghost`,size:`sm`,color:`gray.600`,children:[(0,R.jsx)(p,{size:14}),` Subscription`]})})}),(0,R.jsxs)(y,{align:`center`,gap:1,flex:2,children:[(0,R.jsx)(u,{size:`xl`,as:`h2`,children:`Plans`}),(0,R.jsx)(d,{color:`fg.muted`,children:`Compare plans and choose the right tier for your organization.`})]}),(0,R.jsx)(o,{flex:1})]}),(0,R.jsxs)(m,{width:`full`,justifyContent:{base:`center`,md:`center`},flexWrap:`wrap`,gap:3,children:[(0,R.jsx)(o,{flex:{md:1}}),(0,R.jsx)(m,{gap:0,bg:`bg.muted`,borderRadius:`full`,padding:`1`,"data-testid":`billing-period-toggle`,children:[{label:`Monthly`,value:`monthly`},{label:`Annually`,value:`annual`}].map(e=>(0,R.jsx)(o,{as:`button`,"aria-pressed":S===e.value,onClick:()=>C(e.value),paddingX:4,paddingY:1.5,borderRadius:`full`,fontSize:`sm`,fontWeight:S===e.value?`semibold`:`normal`,color:S===e.value?`orange.500`:`fg.muted`,bg:S===e.value?`bg.panel`:`transparent`,boxShadow:S===e.value?`xs`:`none`,transition:`all 0.15s ease-in-out`,cursor:`pointer`,_hover:{color:S===e.value?`orange.500`:`fg`},children:e.label},e.value))}),(0,R.jsx)(o,{flex:{md:1},display:`flex`,justifyContent:`flex-end`,children:(0,R.jsxs)(i,{"data-testid":`currency-toggle`,variant:`subtle`,size:`sm`,_hover:{bgColor:`orange.400`,color:`bg.muted`},onClick:()=>g(x===I.Currency.EUR?I.Currency.USD:I.Currency.EUR),children:[x===I.Currency.EUR?(0,R.jsx)(P,{size:14}):(0,R.jsx)(n,{size:14}),x]})})]}),s&&(0,R.jsx)(o,{"data-testid":`tiered-discontinued-notice`,backgroundColor:`orange.50`,borderWidth:1,borderColor:`orange.200`,borderRadius:`md`,padding:4,children:(0,R.jsxs)(m,{gap:2,alignItems:`start`,children:[(0,R.jsx)(l,{size:16,color:`var(--chakra-colors-orange-500)`}),(0,R.jsxs)(d,{fontSize:`sm`,color:`orange.900`,children:[`Your current pricing model has been discontinued.`,` `,(0,R.jsx)(_,{href:`/settings/subscription`,fontWeight:`semibold`,color:`orange.700`,_hover:{color:`orange.900`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})]})}),(0,R.jsx)(v,{columns:{base:1,md:3},gap:4,children:z(x).map(e=>(0,R.jsx)(H,{plan:e,isCurrent:r===e.id,currentPlan:r,currency:x,billingPeriod:S},e.id))})]})}function W(){let{organization:e}=S(),t=b.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e?.id,refetchOnWindowFocus:!1,refetchOnMount:!1});return t.isLoading&&!t.data?(0,R.jsx)(w,{children:(0,R.jsx)(a,{})}):(0,R.jsx)(w,{children:(0,R.jsx)(U,{activePlan:t.data,pricingModel:e?.pricingModel})})}var G=N(`organization:view`,{layoutComponent:w})(W);export{G as default};
2
- //# sourceMappingURL=plans-Dq3eFg5K.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Za as n}from"./command-bar-DUK45yin.js";import{j as r,n as i,r as a}from"./stack-oJ9iWdbl.js";import{t as o}from"./box-BsM8YLGl.js";import{an as s,in as c}from"./dist-Cds4Mqhj.js";import{o as l}from"./terminal-CfM0q99k.js";import{t as u}from"./heading-D90dlSnH.js";import{t as d}from"./text-CwTrMF8x.js";import{n as f,r as p}from"./code-FF_ibTVI.js";import{t as m}from"./h-stack-BKLDJ2vg.js";import{r as h,t as g}from"./card-CMtKVPVl.js";import{t as _}from"./link-CwZhwOLq.js";import{t as v}from"./simple-grid-C3IW90zo.js";import{t as y}from"./v-stack-EOPQ57OZ.js";import{s as b}from"./auth-client-D3UhxhQi.js";import{c as x,t as S}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as C}from"./createLucideIcon-BJKFyRLS.js";import{t as w}from"./SettingsLayout--1gdEuhv.js";import{i as T,l as E,n as D,o as O,s as k,t as A,u as j}from"./billing-plans-BUQp08MI.js";import{t as M}from"./constants-BT2q4NNM.js";import{t as N}from"./WithPermissionGuard-B4Jo8E5-.js";var P=C(`euro`,[[`path`,{d:`M4 10h12`,key:`1y6xl8`}],[`path`,{d:`M4 14h9`,key:`1loblj`}],[`path`,{d:`M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2`,key:`1j6lzo`}]]),F=e(t()),I=x();function L(e){if(!e)return null;let t=e.type?.toUpperCase();return e.free||t===`FREE`?`free`:t===`GROWTH`||t&&j(t)?`growth`:t===`ENTERPRISE`?`enterprise`:null}var R=r(),z=e=>[{id:`free`,name:`Free`,subtitle:`For teams getting started`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`blue`,features:D},{id:`growth`,name:`Growth`,subtitle:`Seat and usage pricing for growing teams`,actionLabel:`Get Started`,actionHref:`/settings/subscription`,actionColor:`orange`,features:O(e)},{id:`enterprise`,name:`Enterprise`,subtitle:`Regulated and high-volume deployments`,actionLabel:`Contact Sales`,actionHref:M,actionColor:`blue`,features:A}];function B(e,t,n){if(e===`free`)return`${T[t]}0 per user/month`;if(e===`growth`){let e=E();return`${k({cents:n===`annual`?Math.round(e[t].annual/12):e[t].monthly,currency:t})} per seat/month`}return`Custom pricing`}function V({plan:e,currentPlan:t}){return e.id===`free`?null:e.id===`growth`?t===`growth`?(0,R.jsx)(y,{width:`full`,gap:2,children:(0,R.jsx)(i,{asChild:!0,width:`full`,color:`bg.emphasized`,backgroundColor:`orange.600`,variant:`solid`,children:(0,R.jsx)(_,{href:`/settings/members`,children:`Add Members`})})}):(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`orange`,variant:`solid`,children:(0,R.jsx)(_,{color:`white`,href:`/settings/subscription`,children:`Upgrade Now`})}):e.id===`enterprise`&&t!==`enterprise`?(0,R.jsx)(i,{asChild:!0,width:`full`,colorPalette:`muted`,variant:`outline`,children:(0,R.jsx)(_,{href:M,isExternal:!0,children:`Contact Sales`})}):null}function H({plan:e,isCurrent:t,currentPlan:n,currency:r,billingPeriod:i}){return(0,R.jsx)(h,{"data-testid":`plan-column-${e.id}`,borderWidth:1,borderColor:`border.emphasized`,bg:`bg.panel`,borderRadius:`2xl`,height:`full`,transition:`all 0.2s ease-in-out`,_hover:{transform:`scale(1.02)`,boxShadow:`lg`},children:(0,R.jsx)(g,{paddingY:6,paddingX:6,children:(0,R.jsxs)(y,{align:`stretch`,gap:5,height:`full`,children:[(0,R.jsxs)(y,{align:`start`,gap:1,children:[(0,R.jsxs)(m,{gap:2,children:[(0,R.jsx)(u,{as:`h2`,size:`xl`,children:e.name}),t&&(0,R.jsx)(s,{colorPalette:`green`,variant:`surface`,size:`lg`,children:`Current`})]}),(0,R.jsx)(d,{color:`fg`,fontSize:`md`,fontWeight:`medium`,children:B(e.id,r,i)}),(0,R.jsx)(d,{color:`fg.muted`,fontSize:`sm`,children:e.subtitle})]}),(0,R.jsx)(y,{align:`start`,gap:2,flex:1,children:e.features.map(e=>(0,R.jsxs)(m,{align:`start`,gap:2,children:[(0,R.jsx)(f,{size:14,style:{marginTop:`4px`,flexShrink:0},color:`var(--chakra-colors-blue-500)`}),(0,R.jsx)(d,{fontSize:`sm`,color:`fg.muted`,children:e})]},e))}),(0,R.jsx)(y,{width:`full`,marginTop:`auto`,paddingTop:4,children:(0,R.jsx)(V,{plan:e,currentPlan:n})})]})})})}function U({activePlan:e,pricingModel:t}){let r=L(e),s=t===`TIERED`&&!e?.free,f=b.currency.detectCurrency.useQuery({}),[h,g]=(0,F.useState)(null),x=h??f.data?.currency??I.Currency.EUR,[S,C]=(0,F.useState)(`monthly`);return f.isLoading?(0,R.jsx)(a,{}):(0,R.jsxs)(y,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,R.jsxs)(c,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,R.jsx)(o,{flex:1,children:(0,R.jsx)(_,{href:`/settings/subscription`,children:(0,R.jsxs)(i,{variant:`ghost`,size:`sm`,color:`gray.600`,children:[(0,R.jsx)(p,{size:14}),` Subscription`]})})}),(0,R.jsxs)(y,{align:`center`,gap:1,flex:2,children:[(0,R.jsx)(u,{size:`xl`,as:`h2`,children:`Plans`}),(0,R.jsx)(d,{color:`fg.muted`,children:`Compare plans and choose the right tier for your organization.`})]}),(0,R.jsx)(o,{flex:1})]}),(0,R.jsxs)(m,{width:`full`,justifyContent:{base:`center`,md:`center`},flexWrap:`wrap`,gap:3,children:[(0,R.jsx)(o,{flex:{md:1}}),(0,R.jsx)(m,{gap:0,bg:`bg.muted`,borderRadius:`full`,padding:`1`,"data-testid":`billing-period-toggle`,children:[{label:`Monthly`,value:`monthly`},{label:`Annually`,value:`annual`}].map(e=>(0,R.jsx)(o,{as:`button`,"aria-pressed":S===e.value,onClick:()=>C(e.value),paddingX:4,paddingY:1.5,borderRadius:`full`,fontSize:`sm`,fontWeight:S===e.value?`semibold`:`normal`,color:S===e.value?`orange.500`:`fg.muted`,bg:S===e.value?`bg.panel`:`transparent`,boxShadow:S===e.value?`xs`:`none`,transition:`all 0.15s ease-in-out`,cursor:`pointer`,_hover:{color:S===e.value?`orange.500`:`fg`},children:e.label},e.value))}),(0,R.jsx)(o,{flex:{md:1},display:`flex`,justifyContent:`flex-end`,children:(0,R.jsxs)(i,{"data-testid":`currency-toggle`,variant:`subtle`,size:`sm`,_hover:{bgColor:`orange.400`,color:`bg.muted`},onClick:()=>g(x===I.Currency.EUR?I.Currency.USD:I.Currency.EUR),children:[x===I.Currency.EUR?(0,R.jsx)(P,{size:14}):(0,R.jsx)(n,{size:14}),x]})})]}),s&&(0,R.jsx)(o,{"data-testid":`tiered-discontinued-notice`,backgroundColor:`orange.50`,borderWidth:1,borderColor:`orange.200`,borderRadius:`md`,padding:4,children:(0,R.jsxs)(m,{gap:2,alignItems:`start`,children:[(0,R.jsx)(l,{size:16,color:`var(--chakra-colors-orange-500)`}),(0,R.jsxs)(d,{fontSize:`sm`,color:`orange.900`,children:[`Your current pricing model has been discontinued.`,` `,(0,R.jsx)(_,{href:`/settings/subscription`,fontWeight:`semibold`,color:`orange.700`,_hover:{color:`orange.900`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})]})}),(0,R.jsx)(v,{columns:{base:1,md:3},gap:4,children:z(x).map(e=>(0,R.jsx)(H,{plan:e,isCurrent:r===e.id,currentPlan:r,currency:x,billingPeriod:S},e.id))})]})}function W(){let{organization:e}=S(),t=b.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e?.id,refetchOnWindowFocus:!1,refetchOnMount:!1});return t.isLoading&&!t.data?(0,R.jsx)(w,{children:(0,R.jsx)(a,{})}):(0,R.jsx)(w,{children:(0,R.jsx)(U,{activePlan:t.data,pricingModel:e?.pricingModel})})}var G=N(`organization:view`,{layoutComponent:w})(W);export{G as default};
2
+ //# sourceMappingURL=plans-Ch2Ol-Fd.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,D as r,M as i,Q as a,Tt as o,U as s,W as c,X as l,Y as u,_ as d,a as f,et as p,i as m,k as h,l as ee,m as g,o as _,p as te,r as v,rt as y,wt as b}from"./prop-types-DifpXm68.js";import{$s as x,Aa as ne,Ao as re,Bs as ie,Cn as S,Cs as ae,Gs as C,Mo as oe,No as se,Oo as ce,Po as le,Qs as ue,Ss as de,Vs as fe,Xr as pe,Xs as me,Ys as he,_s as ge,ao as _e,bs as ve,ec as ye,gs as be,jo as xe,ko as Se,mn as Ce,nc as we,tc as Te,vs as w,xs as Ee,yo as De,ys as T,zs as Oe}from"./command-bar-CaJygoez.js";import{j as ke,n as E,r as Ae}from"./stack-oJ9iWdbl.js";import{t as D}from"./box-BsM8YLGl.js";import{m as je}from"./tabs-DwV1cIZB.js";import{m as Me}from"./tooltip-AEm0YeiF.js";import{m as O,n as k,o as Ne}from"./toaster-C_DYALhL.js";import{c as Pe,i as Fe,l as Ie}from"./radio-group.anatomy-1s_fCJ3y.js";import{an as A}from"./dist-SwV3YZv3.js";import{h as Le}from"./terminal-CfM0q99k.js";import{a as Re,d as ze,l as Be,s as Ve,u as He}from"./dist-frWhjLir.js";import{t as j}from"./text-CwTrMF8x.js";import{i as Ue}from"./code-FF_ibTVI.js";import{r as We,t as Ge}from"./input-C7emsUCL.js";import{n as M}from"./tags-input.anatomy-BFbwdDIO.js";import{t as Ke}from"./create-slot-recipe-context-B6DU0msX.js";import{c as qe,t as N}from"./h-stack-BKLDJ2vg.js";import{r as P,t as F}from"./card-CMtKVPVl.js";import{n as I,r as L,t as R}from"./stat-CHoKZ9Rr.js";import{c as Je,i as Ye,l as Xe,n as z,t as Ze}from"./ReplayStateBadge-ChyX1KUG.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{s as V}from"./auth-client-D3UhxhQi.js";import{r as Qe}from"./next-router-C6sliiV7.js";import{t as $e}from"./arrow-right-B3ZN8yal.js";import{t as et}from"./OpsPageShell-DJ1WlI6-.js";import{n as tt,r as nt,t as rt}from"./PhaseTimeline-DXfTjBZX.js";function it(e){if(!e)return!1;try{return e.selectionStart===0&&e.selectionEnd===0}catch{return e.value===``}}var H=`__live-region__`;function at(e={}){let{level:t=`polite`,document:n=document,root:r,delay:i=0}=e,a=n.defaultView??window,o=r??n.body;function s(e,r){n.getElementById(H)?.remove(),r??=i;let s=n.createElement(`span`);s.id=H,s.dataset.liveAnnouncer=`true`;let c=t===`assertive`?`alert`:`status`;s.setAttribute(`aria-live`,t),s.setAttribute(`role`,c),Object.assign(s.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}),o.appendChild(s),a.setTimeout(()=>{s.textContent=e},r)}function c(){n.getElementById(H)?.remove()}return{announce:s,destroy:c,toJSON(){return H}}}function ot(e){if(!e)return;let t=Me(e);return`box-sizing:`+t.boxSizing+`;border-left:`+t.borderLeftWidth+` solid red;border-right:`+t.borderRightWidth+` solid red;font-family:`+t.fontFamily+`;font-feature-settings:`+t.fontFeatureSettings+`;font-kerning:`+t.fontKerning+`;font-size:`+t.fontSize+`;font-stretch:`+t.fontStretch+`;font-style:`+t.fontStyle+`;font-variant:`+t.fontVariant+`;font-variant-caps:`+t.fontVariantCaps+`;font-variant-ligatures:`+t.fontVariantLigatures+`;font-variant-numeric:`+t.fontVariantNumeric+`;font-weight:`+t.fontWeight+`;letter-spacing:`+t.letterSpacing+`;margin-left:`+t.marginLeft+`;margin-right:`+t.marginRight+`;padding-left:`+t.paddingLeft+`;padding-right:`+t.paddingRight+`;text-indent:`+t.textIndent+`;text-transform:`+t.textTransform}function st(e){let t=e.createElement(`div`);return t.id=`ghost`,t.style.cssText=`display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;`,e.body.appendChild(t),t}function ct(e){if(!e)return;let t=h(e),n=i(e),r=st(t),a=ot(e);a&&(r.style.cssText+=a);function o(){n.requestAnimationFrame(()=>{r.innerHTML=e.value;let t=n.getComputedStyle(r);e?.style.setProperty(`width`,t.width)})}return o(),e?.addEventListener(`input`,o),e?.addEventListener(`change`,o),()=>{t.body.removeChild(r),e?.removeEventListener(`input`,o),e?.removeEventListener(`change`,o)}}var[lt,U]=p({name:`TagsInputContext`,hookName:`useTagsInputContext`,providerName:`<TagsInputProvider />`}),W=ke(),G=e(t(),1),ut=(0,G.forwardRef)((e,t)=>{let n=a(U().getClearTriggerProps(),e);return(0,W.jsx)(_.button,{...n,ref:t})});ut.displayName=`TagsInputClearTrigger`;var dt=(0,G.forwardRef)((e,t)=>{let n=a(U().getControlProps(),e);return(0,W.jsx)(_.div,{...n,ref:t})});dt.displayName=`TagsInputControl`;var ft=(0,G.forwardRef)((e,t)=>{let n=a(U().getHiddenInputProps(),e),r=We();return(0,W.jsx)(_.input,{"aria-describedby":r?.ariaDescribedby,...n,ref:t})});ft.displayName=`TagsInputHiddenInput`;var pt=(0,G.forwardRef)((e,t)=>{let n=a(U().getInputProps(),e);return(0,W.jsx)(_.input,{...n,ref:t})});pt.displayName=`TagsInputInput`;var[mt,ht]=p({name:`TagsInputItemContext`,hookName:`useTagsInputItemContext`,providerName:`<TagsInputItemProvider />`}),[gt,K]=p({name:`TagsInputItemPropsContext`,hookName:`useTagsInputItemPropsContext`,providerName:`<TagsInputItemPropsProvider />`}),_t=Re(),vt=(0,G.forwardRef)((e,t)=>{let[n,r]=_t(e,[`index`,`disabled`,`value`]),i=U(),o=a(i.getItemProps(n),r);return(0,W.jsx)(gt,{value:n,children:(0,W.jsx)(mt,{value:i.getItemState(n),children:(0,W.jsx)(_.div,{...o,ref:t})})})});vt.displayName=`TagsInputItem`;var yt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemDeleteTriggerProps(r),e);return(0,W.jsx)(_.button,{...i,ref:t})});yt.displayName=`TagsInputItemDeleteTrigger`;var bt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemInputProps(r),e);return(0,W.jsx)(_.input,{...i,ref:t})});bt.displayName=`TagsInputItemInput`;var xt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemPreviewProps(r),e);return(0,W.jsx)(_.div,{...i,ref:t})});xt.displayName=`TagsInputItemPreview`;var St=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemTextProps(r),e);return(0,W.jsx)(_.span,{...i,ref:t})});St.displayName=`TagsInputItemText`;var Ct=(0,G.forwardRef)((e,t)=>{let n=a(U().getLabelProps(),e);return(0,W.jsx)(_.label,{...n,ref:t})});Ct.displayName=`TagsInputLabel`;var wt=e=>e.ids?.root??`tags-input:${e.id}`,Tt=e=>e.ids?.input??`tags-input:${e.id}:input`,Et=e=>e.ids?.clearBtn??`tags-input:${e.id}:clear-btn`,Dt=e=>e.ids?.hiddenInput??`tags-input:${e.id}:hidden-input`,Ot=e=>e.ids?.label??`tags-input:${e.id}:label`,kt=e=>e.ids?.control??`tags-input:${e.id}:control`,q=(e,t)=>e.ids?.item?.(t)??`tags-input:${e.id}:tag:${t.value}:${t.index}`,At=(e,t)=>e.ids?.itemDeleteTrigger?.(t)??`${q(e,t)}:delete-btn`,jt=(e,t)=>e.ids?.itemInput?.(t)??`${q(e,t)}:input`,Mt=e=>`${e}:input`,Nt=(e,t)=>e.getById(Mt(t)),Pt=e=>ze(It(e),`[data-part=item]`),Ft=(e,t)=>e.getById(jt(e,t)),It=e=>e.getById(wt(e)),J=e=>e.getById(Tt(e)),Lt=e=>e.getById(Dt(e)),Y=e=>ze(It(e),`[data-part=item-preview]:not([data-disabled])`),Rt=e=>Y(e)[0],zt=e=>Y(e)[Y(e).length-1],Bt=(e,t)=>He(Y(e),t,!1),Vt=(e,t)=>Be(Y(e),t,!1),Ht=(e,t)=>Y(e)[t],X=(e,t)=>Ve(Y(e),t),Ut=e=>{let t=e.closest(`[data-part=item-preview]`);t&&(t.dataset.deleteIntent=``)},Wt=e=>{let t=e.closest(`[data-part=item-preview]`);t&&delete t.dataset.deleteIntent},Gt=(e,t)=>{let n=Lt(e);n&&Fe(n,{value:t})};function Kt(e,t){let{state:n,send:r,computed:i,prop:a,scope:o,context:l}=e,u=i(`isInteractive`),f=!!a(`disabled`),p=!!a(`readOnly`),m=!!a(`required`),h=a(`invalid`)||i(`isOverflowing`),_=a(`translations`),v=n.hasTag(`focused`),y=n.matches(`editing:tag`),b=i(`count`)===0;function x(e){let t=q(o,e),n=l.get(`editedTagId`),r=l.get(`highlightedTagId`);return{id:t,editing:y&&n===t,highlighted:t===r,disabled:!!(e.disabled||f)}}return{empty:b,inputValue:l.get(`inputValue`),value:l.get(`value`),valueAsString:i(`valueAsString`),count:i(`count`),atMax:i(`isAtMax`),setValue(e){r({type:`SET_VALUE`,value:e})},clearValue(e){r(e?{type:`CLEAR_TAG`,id:e}:{type:`CLEAR_VALUE`})},addValue(e){r({type:`ADD_TAG`,value:e})},setValueAtIndex(e,t){r({type:`SET_VALUE_AT_INDEX`,index:e,value:t})},setInputValue(e){r({type:`SET_INPUT_VALUE`,value:e})},clearInputValue(){r({type:`SET_INPUT_VALUE`,value:``})},focus(){J(o)?.focus()},getItemState:x,getRootProps(){return t.element({dir:a(`dir`),...M.root.attrs,"data-invalid":c(h),"data-readonly":c(p),"data-disabled":c(f),"data-focus":c(v),"data-empty":c(b),id:wt(o),onPointerDown(){u&&r({type:`POINTER_DOWN`})}})},getLabelProps(){return t.label({...M.label.attrs,"data-disabled":c(f),"data-invalid":c(h),"data-readonly":c(p),"data-required":c(m),id:Ot(o),dir:a(`dir`),htmlFor:Tt(o)})},getControlProps(){return t.element({id:kt(o),...M.control.attrs,dir:a(`dir`),tabIndex:p?0:void 0,"data-disabled":c(f),"data-readonly":c(p),"data-invalid":c(h),"data-focus":c(v)})},getInputProps(){return t.input({...M.input.attrs,dir:a(`dir`),"data-invalid":c(h),"aria-invalid":s(h),"data-readonly":c(p),"data-empty":c(b),maxLength:a(`maxLength`),id:Tt(o),defaultValue:l.get(`inputValue`),autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,enterKeyHint:`done`,disabled:f||p,placeholder:b?a(`placeholder`):void 0,onInput(e){let t=te(e),n=e.currentTarget.value;if(t.inputType===`insertFromPaste`){r({type:`PASTE`,value:n});return}if(qt(n,a(`delimiter`))){r({type:`DELIMITER_KEY`});return}r({type:`TYPE`,value:n,key:t.inputType})},onFocus(){queueMicrotask(()=>{r({type:`FOCUS`})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t=e.currentTarget,n=t.getAttribute(`role`)===`combobox`,i=t.ariaExpanded===`true`,o={ArrowDown(){r({type:`ARROW_DOWN`})},ArrowLeft(){n&&i||r({type:`ARROW_LEFT`})},ArrowRight(e){l.get(`highlightedTagId`)&&e.preventDefault(),!(n&&i)&&r({type:`ARROW_RIGHT`})},Escape(e){e.preventDefault(),r({type:`ESCAPE`})},Backspace(){r({type:`BACKSPACE`})},Delete(){r({type:`DELETE`})},Enter(e){let a=t.getAttribute(`aria-activedescendant`);n&&i&&a||(r({type:`ENTER`}),e.preventDefault())}}[ee(e,{dir:a(`dir`)})];if(o){o(e);return}}})},getHiddenInputProps(){return t.input({type:`text`,hidden:!0,name:a(`name`),form:a(`form`),disabled:f,readOnly:p,required:a(`required`),id:Dt(o),defaultValue:i(`valueAsString`)})},getItemProps(e){return t.element({...M.item.attrs,dir:a(`dir`),"data-value":e.value,"data-disabled":c(f)})},getItemPreviewProps(e){let n=x(e);return t.element({...M.itemPreview.attrs,id:n.id,dir:a(`dir`),hidden:n.editing,"data-value":e.value,"data-disabled":c(f),"data-highlighted":c(n.highlighted),onPointerDown(e){!u||n.disabled||d(e)&&(e.preventDefault(),r({type:`POINTER_DOWN_TAG`,id:n.id}))},onDoubleClick(){!u||n.disabled||r({type:`DOUBLE_CLICK_TAG`,id:n.id})}})},getItemTextProps(e){let n=x(e);return t.element({...M.itemText.attrs,dir:a(`dir`),"data-disabled":c(f),"data-highlighted":c(n.highlighted)})},getItemInputProps(e){let n=x(e);return t.input({...M.itemInput.attrs,dir:a(`dir`),"aria-label":_?.tagEdited?.(e.value),disabled:f,id:jt(o,e),tabIndex:-1,hidden:!n.editing,maxLength:a(`maxLength`),defaultValue:n.editing?l.get(`editedTagValue`):``,onInput(e){r({type:`TAG_INPUT_TYPE`,value:e.currentTarget.value})},onBlur(e){queueMicrotask(()=>{r({type:`TAG_INPUT_BLUR`,target:e.relatedTarget,id:n.id})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t={Enter(){r({type:`TAG_INPUT_ENTER`})},Escape(){r({type:`TAG_INPUT_ESCAPE`})}}[e.key];t&&(e.preventDefault(),t(e))}})},getItemDeleteTriggerProps(e){let n=x(e);return t.button({...M.itemDeleteTrigger.attrs,dir:a(`dir`),"data-disabled":c(n.disabled),"aria-disabled":n.disabled,"data-highlighted":c(n.highlighted),id:At(o,e),type:`button`,disabled:n.disabled,"aria-label":_?.deleteTagTriggerLabel?.(e.value),tabIndex:-1,onPointerDown(e){d(e)&&(u||e.preventDefault())},onPointerMove(e){u&&Ut(e.currentTarget)},onPointerLeave(e){u&&Wt(e.currentTarget)},onClick(e){e.defaultPrevented||u&&r({type:`CLICK_DELETE_TAG`,id:n.id})}})},getClearTriggerProps(){return t.button({...M.clearTrigger.attrs,dir:a(`dir`),id:Et(o),type:`button`,"data-readonly":c(p),disabled:f,"aria-label":_?.clearTriggerLabel,hidden:b,onClick(){u&&r({type:`CLEAR_VALUE`})}})}}}function qt(e,t){return t?typeof t==`string`?e.endsWith(t):RegExp(`${t.source}$`).test(e):!1}var{and:Z,not:Q,or:Jt}=u(),Yt=l({props({props:e}){return{dir:`ltr`,addOnPaste:!1,editable:!0,validate:()=>!0,allowDuplicates:!1,delimiter:`,`,defaultValue:[],defaultInputValue:``,max:1/0,sanitizeValue:e=>e.trim(),...e,translations:{clearTriggerLabel:`Clear all tags`,deleteTagTriggerLabel:e=>`Delete tag ${e}`,tagAdded:e=>`Added tag ${e}`,tagsPasted:e=>`Pasted ${e.length} tags`,tagEdited:e=>`Editing tag ${e}. Press enter to save or escape to cancel.`,tagUpdated:e=>`Tag update to ${e}`,tagDeleted:e=>`Tag ${e} deleted`,tagSelected:e=>`Tag ${e} selected. Press enter to edit, delete or backspace to remove.`,...e.translations}}},initialState({prop:e}){return e(`autoFocus`)?`focused:input`:`idle`},refs(){return{liveRegion:null,log:{current:null,prev:null}}},context({bindable:e,prop:t}){return{value:e(()=>({defaultValue:t(`defaultValue`),value:t(`value`),isEqual:je,hash(e){return e.join(`, `)},onChange(e){t(`onValueChange`)?.({value:e})}})),inputValue:e(()=>({sync:!0,defaultValue:t(`defaultInputValue`),value:t(`inputValue`),onChange(e){t(`onInputValueChange`)?.({inputValue:e})}})),fieldsetDisabled:e(()=>({defaultValue:!1})),editedTagValue:e(()=>({defaultValue:``})),editedTagId:e(()=>({defaultValue:null})),editedTagIndex:e(()=>({defaultValue:null,sync:!0})),highlightedTagId:e(()=>({defaultValue:null,sync:!0,onChange(e){t(`onHighlightChange`)?.({highlightedValue:e})}}))}},computed:{count:({context:e})=>e.get(`value`).length,valueAsString:({context:e})=>e.hash(`value`),sanitizedInputValue:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)),isDisabled:({prop:e})=>!!e(`disabled`),isInteractive:({prop:e})=>!(e(`readOnly`)||e(`disabled`)),isAtMax:({context:e,prop:t})=>e.get(`value`).length===t(`max`),isOverflowing:({context:e,prop:t})=>e.get(`value`).length>t(`max`)},watch({track:e,context:t,action:n,computed:r,refs:i}){e([()=>t.get(`editedTagValue`)],()=>{n([`syncEditedTagInputValue`])}),e([()=>t.get(`inputValue`)],()=>{n([`syncInputValue`])}),e([()=>t.get(`highlightedTagId`)],()=>{n([`logHighlightedTag`])}),e([()=>r(`isOverflowing`)],()=>{n([`invokeOnInvalid`])}),e([()=>JSON.stringify(i.get(`log`))],()=>{n([`announceLog`])})},effects:[`trackLiveRegion`,`trackFormControlState`],exit:[`clearLog`],on:{DOUBLE_CLICK_TAG:{guard:`isTagEditable`,target:`editing:tag`,actions:[`setEditedId`]},POINTER_DOWN_TAG:{target:`navigating:tag`,actions:[`highlightTag`,`focusInput`]},CLICK_DELETE_TAG:{target:`focused:input`,actions:[`deleteTag`]},SET_INPUT_VALUE:{actions:[`setInputValue`]},SET_VALUE:{actions:[`setValue`]},CLEAR_TAG:{actions:[`deleteTag`]},SET_VALUE_AT_INDEX:{actions:[`setValueAtIndex`]},CLEAR_VALUE:{actions:[`clearTags`,`clearInputValue`,`focusInput`]},ADD_TAG:{actions:[`addTag`]},INSERT_TAG:{guard:Z(Jt(Q(`isAtMax`),`allowOverflow`),Q(`isInputValueEmpty`)),actions:[`addTag`,`clearInputValue`]},EXTERNAL_BLUR:[{guard:`addOnBlur`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,actions:[`clearInputValue`]}]},states:{idle:{on:{FOCUS:{target:`focused:input`},POINTER_DOWN:{guard:Q(`hasHighlightedTag`),target:`focused:input`}}},"focused:input":{tags:[`focused`],entry:[`focusInput`,`clearHighlightedId`],effects:[`trackInteractOutside`],on:{TYPE:{actions:[`setInputValue`]},BLUR:[{guard:`addOnBlur`,target:`idle`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,target:`idle`,actions:[`clearInputValue`]},{target:`idle`}],ENTER:{actions:[`raiseInsertTagEvent`]},DELIMITER_KEY:{actions:[`raiseInsertTagEvent`]},ARROW_LEFT:{guard:Z(`hasTags`,`isCaretAtStart`),target:`navigating:tag`,actions:[`highlightLastTag`]},BACKSPACE:{target:`navigating:tag`,guard:Z(`hasTags`,`isCaretAtStart`),actions:[`highlightLastTag`]},DELETE:{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]},PASTE:[{guard:`addOnPaste`,actions:[`setInputValue`,`addTagFromPaste`]},{actions:[`setInputValue`]}]}},"navigating:tag":{tags:[`focused`],effects:[`trackInteractOutside`],on:{ARROW_RIGHT:[{guard:Z(`hasTags`,`isCaretAtStart`,Q(`isLastTagHighlighted`)),actions:[`highlightNextTag`]},{target:`focused:input`}],ARROW_LEFT:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{actions:[`highlightPrevTag`]}],BLUR:{target:`idle`,actions:[`clearHighlightedId`]},ENTER:{guard:Z(`isTagEditable`,`hasHighlightedTag`),target:`editing:tag`,actions:[`setEditedId`,`focusEditedTagInput`]},ARROW_DOWN:{target:`focused:input`},ESCAPE:{target:`focused:input`},TYPE:{target:`focused:input`,actions:[`setInputValue`]},BACKSPACE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{guard:`isFirstTagHighlighted`,actions:[`deleteHighlightedTag`,`highlightFirstTag`]},{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightPrevTag`]},{actions:[`highlightLastTag`]}],DELETE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{target:`focused:input`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]}],PASTE:[{guard:`addOnPaste`,target:`focused:input`,actions:[`setInputValue`,`addTagFromPaste`]},{target:`focused:input`,actions:[`setInputValue`]}]}},"editing:tag":{tags:[`editing`,`focused`],entry:[`focusEditedTagInput`],effects:[`autoResize`],on:{TAG_INPUT_TYPE:{actions:[`setEditedTagValue`]},TAG_INPUT_ESCAPE:{target:`navigating:tag`,actions:[`clearEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},TAG_INPUT_BLUR:[{guard:`isInputRelatedTarget`,target:`navigating:tag`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`]},{target:`idle`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`,`raiseExternalBlurEvent`]}],TAG_INPUT_ENTER:[{guard:`isEditedTagEmpty`,target:`navigating:tag`,actions:[`deleteHighlightedTag`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},{target:`navigating:tag`,actions:[`submitEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]}]}}},implementations:{guards:{isInputRelatedTarget:({scope:e,event:t})=>t.relatedTarget===J(e),isAtMax:({computed:e})=>e(`isAtMax`),hasHighlightedTag:({context:e})=>e.get(`highlightedTagId`)!=null,isFirstTagHighlighted:({context:e,scope:t})=>q(t,{value:e.get(`value`)[0],index:0})===e.get(`highlightedTagId`),isEditedTagEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`editedTagValue`))===``,isLastTagHighlighted:({context:e,scope:t})=>{let n=e.get(`value`),r=n.length-1;return q(t,{value:n[r],index:r})===e.get(`highlightedTagId`)},isInputValueEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)).length===0,hasTags:({context:e})=>e.get(`value`).length>0,allowOverflow:({prop:e})=>!!e(`allowOverflow`),autoFocus:({prop:e})=>!!e(`autoFocus`),addOnBlur:({prop:e})=>e(`blurBehavior`)===`add`,clearOnBlur:({prop:e})=>e(`blurBehavior`)===`clear`,addOnPaste:({prop:e})=>!!e(`addOnPaste`),isTagEditable:({prop:e})=>!!e(`editable`),isCaretAtStart:({scope:e})=>it(J(e))},effects:{trackInteractOutside({scope:e,prop:t,send:n}){return Ne(J(e),{exclude(t){return Pt(e).some(e=>r(e,t))},onFocusOutside:t(`onFocusOutside`),onPointerDownOutside:t(`onPointerDownOutside`),onInteractOutside(e){t(`onInteractOutside`)?.(e),!e.defaultPrevented&&n({type:`BLUR`,src:`interact-outside`})}})},trackFormControlState({context:e,send:t,scope:n}){return Ie(Lt(n),{onFieldsetDisabledChange(t){e.set(`fieldsetDisabled`,t)},onFormReset(){t({type:`SET_VALUE`,value:e.initial(`value`),src:`form-reset`})}})},autoResize({context:e,prop:t,scope:n}){let r;return queueMicrotask(()=>{let i=e.get(`editedTagValue`),a=e.get(`editedTagIndex`);!i||a==null||!t(`editable`)||(r=ct(Ft(n,{value:i,index:a})))}),()=>{r?.()}},trackLiveRegion({scope:e,refs:t}){let n=at({level:`assertive`,document:e.getDoc()});return t.set(`liveRegion`,n),()=>n.destroy()}},actions:{raiseInsertTagEvent({send:e}){e({type:`INSERT_TAG`})},raiseExternalBlurEvent({send:e,event:t}){e({type:`EXTERNAL_BLUR`,id:t.id})},dispatchChangeEvent({scope:e,computed:t}){Gt(e,t(`valueAsString`))},highlightNextTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Vt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightFirstTag({context:e,scope:t}){O(()=>{let n=Rt(t);e.set(`highlightedTagId`,n?.id??null)})},highlightLastTag({context:e,scope:t}){let n=zt(t);e.set(`highlightedTagId`,n?.id??null)},highlightPrevTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Bt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightTag({context:e,event:t}){e.set(`highlightedTagId`,t.id)},highlightTagAtIndex({context:e,scope:t}){O(()=>{let n=e.get(`editedTagIndex`);if(n==null)return;let r=Ht(t,n);r!=null&&(e.set(`highlightedTagId`,r.id),e.set(`editedTagIndex`,null))})},deleteTag({context:e,scope:t,event:n,refs:r}){let i=X(t,n.id),a=e.get(`value`)[i],o=r.get(`log`);r.set(`log`,{prev:o.current,current:{type:`delete`,value:a}}),e.set(`value`,e=>b(e,i))},deleteHighlightedTag({context:e,scope:t,refs:n}){let r=e.get(`highlightedTagId`);if(r==null)return;let i=X(t,r);e.set(`editedTagIndex`,i);let a=e.get(`value`),o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`delete`,value:a[i]}}),e.set(`value`,e=>b(e,i))},setEditedId({context:e,event:t,scope:n}){let r=e.get(`highlightedTagId`),i=t.id??r;e.set(`editedTagId`,i);let a=X(n,i),o=e.get(`value`)[a];e.set(`editedTagIndex`,a),e.set(`editedTagValue`,o)},clearEditedId({context:e}){e.set(`editedTagId`,null)},clearEditedTagValue({context:e}){e.set(`editedTagValue`,``)},setEditedTagValue({context:e,event:t}){e.set(`editedTagValue`,t.value)},submitEditedTagValue({context:e,scope:t,refs:n,prop:r}){let i=e.get(`editedTagId`);if(!i)return;let a=X(t,i),o=e.get(`editedTagValue`),s=e.get(`value`),c=s.some((e,t)=>t!==a&&e===o);if(!r(`allowDuplicates`)&&c||s[a]===o)return;e.set(`value`,e=>{let t=e.slice();return t[a]=o,t});let l=n.get(`log`);n.set(`log`,{prev:l.current,current:{type:`update`,value:o}})},setValueAtIndex({context:e,event:t,refs:n,prop:r}){if(t.value){let i=e.get(`value`),a=i.some((e,n)=>n!==t.index&&e===t.value);if(!r(`allowDuplicates`)&&a||i[t.index]===t.value)return;e.set(`value`,e=>{let n=e.slice();return n[t.index]=t.value,n});let o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`update`,value:t.value}})}else y(`You need to provide a value for the tag`)},focusEditedTagInput({context:e,scope:t}){O(()=>{let n=e.get(`editedTagId`);n&&Nt(t,n)?.select()})},setInputValue({context:e,event:t}){e.set(`inputValue`,t.value)},clearHighlightedId({context:e}){e.set(`highlightedTagId`,null)},focusInput({scope:e}){O(()=>{J(e)?.focus()})},clearInputValue({context:e}){O(()=>{e.set(`inputValue`,``)})},syncInputValue({context:e,scope:t}){let n=J(t);n&&Pe(n,e.get(`inputValue`))},syncEditedTagInputValue({context:e,event:t,scope:n}){let r=e.get(`editedTagId`)||e.get(`highlightedTagId`)||t.id;if(r==null)return;let i=Nt(n,r);i&&Pe(i,e.get(`editedTagValue`))},addTag({context:e,event:t,computed:n,prop:r,refs:i}){let a=t.value??n(`sanitizedInputValue`),s=e.get(`value`);if(r(`validate`)?.({inputValue:a,value:Array.from(s)})){let t=r(`allowDuplicates`)?s.concat(a):o(s.concat(a));e.set(`value`,t);let n=i.get(`log`);i.set(`log`,{prev:n.current,current:{type:`add`,value:a}})}else r(`onValueInvalid`)?.({reason:`invalidTag`})},addTagFromPaste({context:e,computed:t,prop:n,refs:r}){O(()=>{let i=t(`sanitizedInputValue`),a=e.get(`value`),s=n(`sanitizeValue`);if(n(`validate`)?.({inputValue:i,value:Array.from(a)})){let t=n(`delimiter`),c=t?i.split(t).map(s):[i],l=n(`allowDuplicates`)?a.concat(...c):o(a.concat(...c));e.set(`value`,l);let u=r.get(`log`);r.set(`log`,{prev:u.current,current:{type:`paste`,values:c}})}else n(`onValueInvalid`)?.({reason:`invalidTag`});e.set(`inputValue`,``)})},clearTags({context:e,refs:t}){e.set(`value`,[]);let n=t.get(`log`);t.set(`log`,{prev:n.current,current:{type:`clear`}})},setValue({context:e,event:t}){e.set(`value`,t.value)},invokeOnInvalid({prop:e,computed:t}){t(`isOverflowing`)&&e(`onValueInvalid`)?.({reason:`rangeOverflow`})},clearLog({refs:e}){let t=e.get(`log`);t.prev=t.current=null},logHighlightedTag({refs:e,context:t,scope:n}){let r=t.get(`highlightedTagId`),i=e.get(`log`);if(r==null||!i.current)return;let a=X(n,r),o=t.get(`value`)[a],s=e.get(`log`);e.set(`log`,{prev:s.current,current:{type:`select`,value:o}})},announceLog({refs:e,prop:t}){let n=e.get(`liveRegion`),r=t(`translations`),i=e.get(`log`);if(!i.current||n==null)return;let a=n,{current:o,prev:s}=i,c;switch(o.type){case`add`:c=r.tagAdded(o.value);break;case`delete`:c=r.tagDeleted(o.value);break;case`update`:c=r.tagUpdated(o.value);break;case`paste`:c=r.tagsPasted(o.values);break;case`select`:c=r.tagSelected(o.value),s?.type===`delete`?c=`${r.tagDeleted(s.value)}. ${c}`:s?.type===`update`&&(c=`${r.tagUpdated(s.value)}. ${c}`);break;default:break}c&&a.announce(c)}}}}),Xt=e=>{let t=(0,G.useId)(),{getRootNode:r}=n(),{dir:i}=f(),a=We();return Kt(m(Yt,{id:t,ids:{label:a?.ids.label,hiddenInput:a?.ids.control},dir:i,disabled:a?.disabled,invalid:a?.invalid,readOnly:a?.readOnly,required:a?.required,getRootNode:r,...e}),v)},Zt=Re(),Qt=(0,G.forwardRef)((e,t)=>{let[n,r]=Zt(e,`addOnPaste.allowDuplicates.allowOverflow.autoFocus.blurBehavior.defaultInputValue.defaultValue.delimiter.disabled.editable.form.id.ids.inputValue.invalid.max.maxLength.name.onFocusOutside.onHighlightChange.onInputValueChange.onInteractOutside.onPointerDownOutside.onValueChange.onValueInvalid.placeholder.readOnly.required.sanitizeValue.translations.validate.value`.split(`.`)),i=Xt(n),o=a(i.getRootProps(),r);return(0,W.jsx)(lt,{value:i,children:(0,W.jsx)(_.div,{...o,ref:t})})});Qt.displayName=`TagsInputRoot`;var $t=Re(),en=(0,G.forwardRef)((e,t)=>{let[{value:n},r]=$t(e,[`value`]),i=a(n.getRootProps(),r);return(0,W.jsx)(lt,{value:n,children:(0,W.jsx)(_.div,{...i,ref:t})})});en.displayName=`TagsInputRootProvider`;var{withProvider:tn,withContext:$,useStyles:nn,PropsProvider:rn}=Ke({key:`tagsInput`});tn(en,`root`,{forwardAsChild:!0});var an=tn(Qt,`root`,{forwardAsChild:!0,defaultProps:{editable:!1}}),on=$(Ct,`label`,{forwardAsChild:!0}),sn=$(dt,`control`,{forwardAsChild:!0}),cn=$(pt,`input`,{forwardAsChild:!0}),ln=$(vt,`item`,{forwardAsChild:!0}),un=$(St,`itemText`,{forwardAsChild:!0}),dn=$(yt,`itemDeleteTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),fn=$(xt,`itemPreview`,{forwardAsChild:!0}),pn=$(bt,`itemInput`,{forwardAsChild:!0}),mn=$(ut,`clearTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),hn=e=>(0,W.jsx)(C,{each:U().value,children:(t,n)=>(0,W.jsxs)(ln,{index:n,value:t,...e,children:[(0,W.jsxs)(fn,{children:[(0,W.jsx)(un,{children:t}),(0,W.jsx)(dn,{})]}),(0,W.jsx)(pn,{})]},n)});function gn({open:e,onClose:t}){let n=Qe(),{hasAccess:r}=S(),i=z({refetchInterval:e?1e3:!1}),a=V.ops.cancelReplay.useMutation({onSuccess:()=>void i.refetch()}),o=i.data,s=o?.state===`running`,c=o?.state===`completed`?`green`:o?.state===`failed`?`red`:o?.state===`cancelled`?`orange`:`blue`,l=o&&o.aggregatesTotal>0?Math.round(o.aggregatesProcessed/o.aggregatesTotal*100):0,u=(0,G.useMemo)(()=>{if(!o?.startedAt||!o.eventsProcessed)return null;let e=(Date.now()-new Date(o.startedAt).getTime())/1e3;return e<1?null:Math.round(o.eventsProcessed/e)},[o?.startedAt,o?.eventsProcessed]);return(0,W.jsx)(se,{open:e,onOpenChange:e=>{e.open||t()},placement:`end`,size:`sm`,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(oe,{children:[(0,W.jsx)(le,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:c,size:`sm`,children:(0,W.jsx)(Je,{})}),`Replay `,o?.state??`idle`]})}),(0,W.jsx)(Se,{})]}),(0,W.jsx)(ce,{children:!o||o.state===`idle`?(0,W.jsx)(j,{textStyle:`sm`,color:`fg.muted`,children:`No replay is currently running.`}):(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(nt,{currentPhase:o.currentPhase,completedState:o.state===`running`?null:o.state}),o.currentPhase&&(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`lg`,children:rt[o.currentPhase]??`·`}),(0,W.jsxs)(B,{align:`start`,gap:0,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:tt[o.currentPhase]??o.currentPhase}),o.currentProjection&&(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:o.currentProjection})]})]}),o.aggregatesTotal>0&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Aggregates`}),(0,W.jsxs)(j,{textStyle:`xs`,fontWeight:`medium`,children:[o.aggregatesProcessed.toLocaleString(),` / `,o.aggregatesTotal.toLocaleString(),` (`,l,`%)`]})]}),(0,W.jsx)(ie,{value:l,size:`sm`,colorPalette:c,children:(0,W.jsx)(fe,{children:(0,W.jsx)(Oe,{})})})]}),(0,W.jsx)(Le,{}),(0,W.jsxs)(N,{gap:4,flexWrap:`wrap`,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.eventsProcessed.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.projectionNames.length})]}),u!==null&&(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events/s`}),(0,W.jsx)(L,{textStyle:`lg`,children:u.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Elapsed`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.startedAt?Ye(o.startedAt):`—`})]})]}),(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:o.projectionNames.map(e=>(0,W.jsx)(A,{size:`sm`,variant:e===o.currentProjection?`solid`:`subtle`,colorPalette:e===o.currentProjection?`orange`:`gray`,children:e},e))})]}),o.description&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Description`}),(0,W.jsx)(j,{textStyle:`sm`,children:o.description})]}),o.error&&(0,W.jsxs)(D,{padding:3,borderRadius:`md`,bg:`red.subtle`,borderWidth:`1px`,borderColor:`red.200`,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`red.fg`,marginBottom:1,children:`Error`}),(0,W.jsx)(j,{textStyle:`xs`,color:`red.fg`,children:o.error})]})]})}),(0,W.jsx)(xe,{children:(0,W.jsxs)(N,{gap:2,width:`full`,children:[o?.runId&&(0,W.jsx)(E,{size:`sm`,variant:`outline`,flex:1,onClick:()=>{n.push(`/ops/projections/${o.runId}`),t()},children:`Full Page View`}),s&&r&&(0,W.jsx)(E,{size:`sm`,colorPalette:`red`,variant:`outline`,loading:a.isPending,onClick:()=>a.mutate(),children:`Cancel`})]})})]})})}function _n(){let e=Qe(),t=z(),n=V.ops.cancelReplay.useMutation({onSuccess:()=>void t.refetch()}),{hasAccess:r}=S(),i=t.data;return!i||i.state!==`running`?null:(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:`blue`,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`semibold`,children:`Replay running`}),i.currentProjection&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,children:i.currentProjection})]}),(0,W.jsxs)(N,{gap:2,children:[i.runId&&(0,W.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>void e.push(`/ops/projections/${i.runId}`),children:`View Progress`}),r&&(0,W.jsx)(E,{size:`xs`,colorPalette:`red`,variant:`outline`,loading:n.isPending,onClick:()=>n.mutate(),children:`Cancel`})]})]})})})}function vn(){let e=Qe(),t=V.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data;return!t||t.length===0?null:(0,W.jsx)(P,{overflow:`hidden`,children:(0,W.jsxs)(F,{padding:0,children:[(0,W.jsx)(N,{paddingX:4,paddingY:3,children:(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`Replay History`})}),(0,W.jsx)(ae,{children:(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{children:`Status`}),(0,W.jsx)(T,{children:`Description`}),(0,W.jsx)(T,{children:`Projections`}),(0,W.jsx)(T,{textAlign:`end`,children:`Duration`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{textAlign:`end`,children:`Events`}),(0,W.jsx)(T,{children:`When`}),(0,W.jsx)(T,{width:`40px`})]})}),(0,W.jsx)(ge,{children:t.map(t=>{let n=Ze(t.state);return(0,W.jsxs)(de,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>void e.push(`/ops/projections/${t.runId}`),children:[(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:n,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:n,children:t.state})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,truncate:!0,maxW:`300px`,children:t.description??`—`})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[t.projectionNames?.length??0,` projection`,(t.projectionNames?.length??0)===1?``:`s`]})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:Ye(t.startedAt,t.completedAt)})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.aggregatesProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.eventsProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:t.startedAt?new Date(t.startedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})}),(0,W.jsx)(w,{children:(0,W.jsx)($e,{size:12,style:{opacity:.5}})})]},t.runId)})})]})})]})})}function yn({tenantIds:e,onTenantIdsChange:t}){let[n,r]=(0,G.useState)(``),i=V.ops.searchTenants.useQuery({query:n},{enabled:n.length>=2});return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(an,{size:`sm`,value:e,onValueChange:e=>t(e.value),addOnPaste:!0,delimiter:`,`,blurBehavior:`add`,validate:e=>e.inputValue.trim().length>0,children:[(0,W.jsx)(on,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Tenants`})}),(0,W.jsxs)(sn,{children:[(0,W.jsx)(hn,{}),(0,W.jsx)(cn,{placeholder:`Type tenant ID and press Enter...`}),(0,W.jsx)(mn,{})]})]}),(0,W.jsxs)(D,{position:`relative`,children:[(0,W.jsxs)(N,{gap:2,borderWidth:`1px`,borderRadius:`md`,paddingX:3,paddingY:1.5,children:[(0,W.jsx)(ne,{size:12,color:`var(--chakra-colors-fg-muted)`}),(0,W.jsx)(`input`,{style:{flex:1,background:`transparent`,border:`none`,outline:`none`,fontSize:`12px`,color:`inherit`},placeholder:`Search tenants by name or ID...`,value:n,onChange:e=>r(e.target.value)})]}),i.data&&i.data.length>0&&(0,W.jsx)(D,{position:`absolute`,zIndex:10,width:`full`,borderWidth:`1px`,borderRadius:`md`,bg:`bg.panel`,shadow:`md`,maxHeight:`200px`,overflowY:`auto`,marginTop:1,children:i.data.map(n=>(0,W.jsx)(D,{paddingX:3,paddingY:2,cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>{e.includes(n.id)||t([...e,n.id]),r(``)},children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,children:n.name}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,fontFamily:`mono`,children:n.id}),e.includes(n.id)&&(0,W.jsx)(A,{size:`sm`,colorPalette:`green`,children:`added`})]})},n.id))})]})]})}function bn({onReplayStarted:e}){let{hasAccess:t}=S(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(``),f=V.ops.listProjections.useQuery(),p=z(),m=i||n.length>0,h=o.length>0,ee=m&&h,g=V.ops.discoverAggregates.useQuery({projectionNames:f.data?.projections.map(e=>e.projectionName)??[],since:o,tenantIds:i?[]:n},{enabled:!1}),_=(0,G.useRef)(``);(0,G.useEffect)(()=>{if(!ee)return;let e=JSON.stringify({tenantIds:i?[]:n,since:o});e!==_.current&&(_.current=e,g.refetch().then(e=>{e.data&&l(new Set(e.data.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)))}))},[ee,i,n,o]);let te=!!g.data,v=new Set(g.data?.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)??[]),y=V.ops.startReplay.useMutation({onSuccess:()=>{p.refetch(),k.create({title:`Projection replay started`,description:`Replaying ${c.size} projection${c.size===1?``:`s`}...`,type:`success`}),e()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}}),[b,ne]=(0,G.useState)(null),re=V.ops.dryRunReplay.useMutation({onSuccess:e=>{ne(e),k.create({title:`Dry run complete`,description:e.message,type:`info`})},onError:e=>{k.create({title:`Dry run failed`,description:e.message,type:`error`})}});function ie(e){v.has(e)&&l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){l(new Set(v))}let C=g.data?.projections.filter(e=>c.has(e.projectionName)).reduce((e,t)=>e+t.aggregateCount,0)??0,oe=p.data?.state===`running`;function se(){y.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n,description:u||`Manual replay`})}function ce(){re.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n})}return f.isLoading?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(Ae,{size:`lg`})}):f.data&&f.data.projections.length===0?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(ue,{children:(0,W.jsxs)(he,{children:[(0,W.jsx)(x,{children:`No projections registered`}),(0,W.jsx)(me,{children:`No fold projections were found in the pipeline registry.`})]})})}):f.data?(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{marginBottom:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`1. Select tenants`}),(0,W.jsx)(De,{size:`sm`,checked:i,onCheckedChange:e=>{a(!!e.checked),e.checked&&r([])},children:(0,W.jsx)(j,{textStyle:`xs`,children:`All tenants`})})]}),(0,W.jsx)(D,{opacity:i?.4:1,pointerEvents:i?`none`:`auto`,children:(0,W.jsx)(yn,{tenantIds:n,onTenantIdsChange:r})}),!m&&!i&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,marginTop:2,children:`At least 1 tenant is required to proceed`})]})}),(0,W.jsx)(P,{opacity:m?1:.5,pointerEvents:m?`auto`:`none`,children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,marginBottom:3,children:`2. Choose date range`}),(0,W.jsxs)(N,{gap:3,alignItems:`end`,flexWrap:`wrap`,children:[(0,W.jsxs)(D,{maxWidth:`220px`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Replay events since`}),(0,W.jsx)(Ge,{type:`date`,size:`sm`,value:o,onChange:e=>s(e.target.value)})]}),(0,W.jsx)(N,{gap:1,children:[{label:`This month`,months:0},{label:`2 months`,months:2},{label:`3 months`,months:3},{label:`6 months`,months:6}].map(({label:e,months:t})=>{let n=new Date;t===0?n.setDate(1):n.setMonth(n.getMonth()-t);let r=n.toISOString().slice(0,10);return(0,W.jsx)(E,{size:`sm`,height:`36px`,variant:o===r?`solid`:`outline`,onClick:()=>s(r),children:e},e)})})]}),ee&&g.isFetching&&(0,W.jsxs)(N,{gap:2,marginTop:3,children:[(0,W.jsx)(Ae,{size:`xs`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Discovering aggregates...`})]})]})}),te&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:0,overflowX:`auto`,children:[(0,W.jsxs)(N,{paddingX:4,paddingY:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`3. Select projections to replay`}),(0,W.jsx)(E,{variant:`ghost`,size:`xs`,onClick:ae,children:`Select all with data`})]}),(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{width:`40px`}),(0,W.jsx)(T,{children:`Projection`}),(0,W.jsx)(T,{children:`Pipeline`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{children:`Tenants`})]})}),(0,W.jsx)(ge,{children:g.data.projections.map(e=>{let t=e.aggregateCount>0,n=c.has(e.projectionName);return(0,W.jsxs)(de,{cursor:t?`pointer`:`default`,opacity:t?1:.4,onClick:()=>ie(e.projectionName),_hover:t?{bg:`bg.subtle`}:void 0,bg:n?`bg.subtle`:void 0,children:[(0,W.jsx)(w,{children:(0,W.jsx)(De,{checked:n,disabled:!t,onCheckedChange:()=>ie(e.projectionName)})}),(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`sm`,children:e.projectionName}),!t&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:`gray`,children:`no data`})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:f.data?.projections.find(t=>t.projectionName===e.projectionName)?.pipelineName??`—`})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{fontWeight:`medium`,children:e.aggregateCount})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[e.tenantBreakdown.length,` tenant`,e.tenantBreakdown.length===1?``:`s`]})})]},e.projectionName)})})]})]})}),c.size>0&&(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{gap:6,marginBottom:4,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Selected Aggregates`}),(0,W.jsx)(L,{children:C})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{children:c.size})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Tenants`}),(0,W.jsx)(L,{children:i?`All`:n.length})]})]}),t&&(0,W.jsxs)(B,{align:`stretch`,gap:3,children:[(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Description (for audit log)`}),(0,W.jsx)(be,{size:`sm`,placeholder:`Describe the reason for this replay...`,value:u,onChange:e=>d(e.target.value),rows:2})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,colorPalette:`orange`,disabled:oe||C===0,loading:y.isPending,onClick:se,children:`Start Full Replay`}),(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:oe||C===0,loading:re.isPending,onClick:ce,children:`Dry Run (5 aggregates)`}),oe&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,children:`A replay is already running`})]}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Full replay pauses projections, drains active jobs, replays events from ClickHouse, then unpauses. Dry run processes 5 sample aggregates in memory without writing.`}),b&&(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsxs)(F,{padding:3,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`blue.500`,marginBottom:1,children:`Dry Run Result`}),(0,W.jsx)(j,{textStyle:`sm`,children:b.message}),(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,marginTop:1,children:[`Projections:`,` `,b.projectionNames.join(`, `),` | Sample size: `,b.sampleSize]})]})})]})]})})]})]}):null}function xn({projections:e,onReplayStarted:t}){let n=z(),r=n.data?.state===`running`,[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u]=(0,G.useState)(()=>{let e=new Date;return e.setMonth(e.getMonth()-3),e.toISOString().slice(0,10)}),d=V.ops.startReplay.useMutation({onSuccess:()=>{n.refetch(),k.create({title:`Single aggregate replay started`,type:`success`}),t()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}});function f(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Aggregate ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. trace_abc123`,value:i,onChange:e=>a(e.target.value),fontFamily:`mono`})]}),(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Tenant ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. project_xyz`,value:o,onChange:e=>s(e.target.value),fontFamily:`mono`})]})]}),(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:e.map(e=>(0,W.jsx)(A,{size:`sm`,variant:c.has(e.projectionName)?`solid`:`outline`,colorPalette:c.has(e.projectionName)?`orange`:`gray`,cursor:`pointer`,onClick:()=>f(e.projectionName),children:e.projectionName},e.projectionName))})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:!i.trim()||!o.trim()||c.size===0||r,loading:d.isPending,onClick:()=>{d.mutate({projectionNames:[...c],since:u,tenantIds:[o.trim()],aggregateIds:[i.trim()],description:`Single aggregate replay: ${i.trim()}`})},children:`Replay Single`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Replays selected projections for a single tenant (events from last 3 months)`})]})]})}function Sn(){let{hasAccess:e}=S(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=V.ops.listProjections.useQuery().data?.projections??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(_n,{}),(0,W.jsx)(bn,{onReplayStarted:()=>n(!0)}),e&&a.length>0&&(0,W.jsxs)(Te,{open:r,onOpenChange:e=>i(e.open),children:[(0,W.jsx)(we,{asChild:!0,children:(0,W.jsx)(D,{cursor:`pointer`,userSelect:`none`,children:(0,W.jsxs)(N,{gap:2,paddingY:1,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Advanced: Single Aggregate Replay`}),(0,W.jsx)(_e,{size:12,style:{transform:r?`rotate(180deg)`:`none`,transition:`transform 0.15s`}})]})})}),(0,W.jsx)(ye,{children:(0,W.jsx)(P,{marginTop:2,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsx)(xn,{projections:a,onReplayStarted:()=>n(!0)})})})})]}),(0,W.jsx)(vn,{})]}),(0,W.jsx)(gn,{open:t,onClose:()=>n(!1)})]})}function Cn(){return(0,W.jsx)(et,{children:(0,W.jsxs)(Ce,{children:[(0,W.jsx)(pe.Header,{children:(0,W.jsx)(pe.Heading,{children:`Projection Replay`})}),(0,W.jsx)(pe.Container,{children:(0,W.jsx)(Sn,{})})]})})}export{Cn as default};
2
- //# sourceMappingURL=projections-CTNj1QBM.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,D as r,M as i,Q as a,Tt as o,U as s,W as c,X as l,Y as u,_ as d,a as f,et as p,i as m,k as h,l as ee,m as g,o as _,p as te,r as v,rt as y,wt as b}from"./prop-types-DifpXm68.js";import{$s as x,Aa as ne,Ao as re,Bs as ie,Cn as S,Cs as ae,Gs as C,Mo as oe,No as se,Oo as ce,Po as le,Qs as ue,Ss as de,Vs as fe,Xr as pe,Xs as me,Ys as he,_s as ge,ao as _e,bs as ve,ec as ye,gs as be,jo as xe,ko as Se,mn as Ce,nc as we,tc as Te,vs as w,xs as Ee,yo as De,ys as T,zs as Oe}from"./command-bar-DUK45yin.js";import{j as ke,n as E,r as Ae}from"./stack-oJ9iWdbl.js";import{t as D}from"./box-BsM8YLGl.js";import{m as je}from"./tabs-DwV1cIZB.js";import{m as Me}from"./tooltip-AEm0YeiF.js";import{m as O,n as k,o as Ne}from"./toaster-C_DYALhL.js";import{c as Pe,i as Fe,l as Ie}from"./radio-group.anatomy-1s_fCJ3y.js";import{an as A}from"./dist-Cds4Mqhj.js";import{h as Le}from"./terminal-CfM0q99k.js";import{a as Re,d as ze,l as Be,s as Ve,u as He}from"./dist-frWhjLir.js";import{t as j}from"./text-CwTrMF8x.js";import{i as Ue}from"./code-FF_ibTVI.js";import{r as We,t as Ge}from"./input-C7emsUCL.js";import{n as M}from"./tags-input.anatomy-BFbwdDIO.js";import{t as Ke}from"./create-slot-recipe-context-B6DU0msX.js";import{c as qe,t as N}from"./h-stack-BKLDJ2vg.js";import{r as P,t as F}from"./card-CMtKVPVl.js";import{n as I,r as L,t as R}from"./stat-CHoKZ9Rr.js";import{c as Je,i as Ye,l as Xe,n as z,t as Ze}from"./ReplayStateBadge-ChyX1KUG.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{s as V}from"./auth-client-D3UhxhQi.js";import{r as Qe}from"./next-router-C6sliiV7.js";import{t as $e}from"./arrow-right-B3ZN8yal.js";import{t as et}from"./OpsPageShell-C_mTziRS.js";import{n as tt,r as nt,t as rt}from"./PhaseTimeline-DXfTjBZX.js";function it(e){if(!e)return!1;try{return e.selectionStart===0&&e.selectionEnd===0}catch{return e.value===``}}var H=`__live-region__`;function at(e={}){let{level:t=`polite`,document:n=document,root:r,delay:i=0}=e,a=n.defaultView??window,o=r??n.body;function s(e,r){n.getElementById(H)?.remove(),r??=i;let s=n.createElement(`span`);s.id=H,s.dataset.liveAnnouncer=`true`;let c=t===`assertive`?`alert`:`status`;s.setAttribute(`aria-live`,t),s.setAttribute(`role`,c),Object.assign(s.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}),o.appendChild(s),a.setTimeout(()=>{s.textContent=e},r)}function c(){n.getElementById(H)?.remove()}return{announce:s,destroy:c,toJSON(){return H}}}function ot(e){if(!e)return;let t=Me(e);return`box-sizing:`+t.boxSizing+`;border-left:`+t.borderLeftWidth+` solid red;border-right:`+t.borderRightWidth+` solid red;font-family:`+t.fontFamily+`;font-feature-settings:`+t.fontFeatureSettings+`;font-kerning:`+t.fontKerning+`;font-size:`+t.fontSize+`;font-stretch:`+t.fontStretch+`;font-style:`+t.fontStyle+`;font-variant:`+t.fontVariant+`;font-variant-caps:`+t.fontVariantCaps+`;font-variant-ligatures:`+t.fontVariantLigatures+`;font-variant-numeric:`+t.fontVariantNumeric+`;font-weight:`+t.fontWeight+`;letter-spacing:`+t.letterSpacing+`;margin-left:`+t.marginLeft+`;margin-right:`+t.marginRight+`;padding-left:`+t.paddingLeft+`;padding-right:`+t.paddingRight+`;text-indent:`+t.textIndent+`;text-transform:`+t.textTransform}function st(e){let t=e.createElement(`div`);return t.id=`ghost`,t.style.cssText=`display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;`,e.body.appendChild(t),t}function ct(e){if(!e)return;let t=h(e),n=i(e),r=st(t),a=ot(e);a&&(r.style.cssText+=a);function o(){n.requestAnimationFrame(()=>{r.innerHTML=e.value;let t=n.getComputedStyle(r);e?.style.setProperty(`width`,t.width)})}return o(),e?.addEventListener(`input`,o),e?.addEventListener(`change`,o),()=>{t.body.removeChild(r),e?.removeEventListener(`input`,o),e?.removeEventListener(`change`,o)}}var[lt,U]=p({name:`TagsInputContext`,hookName:`useTagsInputContext`,providerName:`<TagsInputProvider />`}),W=ke(),G=e(t(),1),ut=(0,G.forwardRef)((e,t)=>{let n=a(U().getClearTriggerProps(),e);return(0,W.jsx)(_.button,{...n,ref:t})});ut.displayName=`TagsInputClearTrigger`;var dt=(0,G.forwardRef)((e,t)=>{let n=a(U().getControlProps(),e);return(0,W.jsx)(_.div,{...n,ref:t})});dt.displayName=`TagsInputControl`;var ft=(0,G.forwardRef)((e,t)=>{let n=a(U().getHiddenInputProps(),e),r=We();return(0,W.jsx)(_.input,{"aria-describedby":r?.ariaDescribedby,...n,ref:t})});ft.displayName=`TagsInputHiddenInput`;var pt=(0,G.forwardRef)((e,t)=>{let n=a(U().getInputProps(),e);return(0,W.jsx)(_.input,{...n,ref:t})});pt.displayName=`TagsInputInput`;var[mt,ht]=p({name:`TagsInputItemContext`,hookName:`useTagsInputItemContext`,providerName:`<TagsInputItemProvider />`}),[gt,K]=p({name:`TagsInputItemPropsContext`,hookName:`useTagsInputItemPropsContext`,providerName:`<TagsInputItemPropsProvider />`}),_t=Re(),vt=(0,G.forwardRef)((e,t)=>{let[n,r]=_t(e,[`index`,`disabled`,`value`]),i=U(),o=a(i.getItemProps(n),r);return(0,W.jsx)(gt,{value:n,children:(0,W.jsx)(mt,{value:i.getItemState(n),children:(0,W.jsx)(_.div,{...o,ref:t})})})});vt.displayName=`TagsInputItem`;var yt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemDeleteTriggerProps(r),e);return(0,W.jsx)(_.button,{...i,ref:t})});yt.displayName=`TagsInputItemDeleteTrigger`;var bt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemInputProps(r),e);return(0,W.jsx)(_.input,{...i,ref:t})});bt.displayName=`TagsInputItemInput`;var xt=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemPreviewProps(r),e);return(0,W.jsx)(_.div,{...i,ref:t})});xt.displayName=`TagsInputItemPreview`;var St=(0,G.forwardRef)((e,t)=>{let n=U(),r=K(),i=a(n.getItemTextProps(r),e);return(0,W.jsx)(_.span,{...i,ref:t})});St.displayName=`TagsInputItemText`;var Ct=(0,G.forwardRef)((e,t)=>{let n=a(U().getLabelProps(),e);return(0,W.jsx)(_.label,{...n,ref:t})});Ct.displayName=`TagsInputLabel`;var wt=e=>e.ids?.root??`tags-input:${e.id}`,Tt=e=>e.ids?.input??`tags-input:${e.id}:input`,Et=e=>e.ids?.clearBtn??`tags-input:${e.id}:clear-btn`,Dt=e=>e.ids?.hiddenInput??`tags-input:${e.id}:hidden-input`,Ot=e=>e.ids?.label??`tags-input:${e.id}:label`,kt=e=>e.ids?.control??`tags-input:${e.id}:control`,q=(e,t)=>e.ids?.item?.(t)??`tags-input:${e.id}:tag:${t.value}:${t.index}`,At=(e,t)=>e.ids?.itemDeleteTrigger?.(t)??`${q(e,t)}:delete-btn`,jt=(e,t)=>e.ids?.itemInput?.(t)??`${q(e,t)}:input`,Mt=e=>`${e}:input`,Nt=(e,t)=>e.getById(Mt(t)),Pt=e=>ze(It(e),`[data-part=item]`),Ft=(e,t)=>e.getById(jt(e,t)),It=e=>e.getById(wt(e)),J=e=>e.getById(Tt(e)),Lt=e=>e.getById(Dt(e)),Y=e=>ze(It(e),`[data-part=item-preview]:not([data-disabled])`),Rt=e=>Y(e)[0],zt=e=>Y(e)[Y(e).length-1],Bt=(e,t)=>He(Y(e),t,!1),Vt=(e,t)=>Be(Y(e),t,!1),Ht=(e,t)=>Y(e)[t],X=(e,t)=>Ve(Y(e),t),Ut=e=>{let t=e.closest(`[data-part=item-preview]`);t&&(t.dataset.deleteIntent=``)},Wt=e=>{let t=e.closest(`[data-part=item-preview]`);t&&delete t.dataset.deleteIntent},Gt=(e,t)=>{let n=Lt(e);n&&Fe(n,{value:t})};function Kt(e,t){let{state:n,send:r,computed:i,prop:a,scope:o,context:l}=e,u=i(`isInteractive`),f=!!a(`disabled`),p=!!a(`readOnly`),m=!!a(`required`),h=a(`invalid`)||i(`isOverflowing`),_=a(`translations`),v=n.hasTag(`focused`),y=n.matches(`editing:tag`),b=i(`count`)===0;function x(e){let t=q(o,e),n=l.get(`editedTagId`),r=l.get(`highlightedTagId`);return{id:t,editing:y&&n===t,highlighted:t===r,disabled:!!(e.disabled||f)}}return{empty:b,inputValue:l.get(`inputValue`),value:l.get(`value`),valueAsString:i(`valueAsString`),count:i(`count`),atMax:i(`isAtMax`),setValue(e){r({type:`SET_VALUE`,value:e})},clearValue(e){r(e?{type:`CLEAR_TAG`,id:e}:{type:`CLEAR_VALUE`})},addValue(e){r({type:`ADD_TAG`,value:e})},setValueAtIndex(e,t){r({type:`SET_VALUE_AT_INDEX`,index:e,value:t})},setInputValue(e){r({type:`SET_INPUT_VALUE`,value:e})},clearInputValue(){r({type:`SET_INPUT_VALUE`,value:``})},focus(){J(o)?.focus()},getItemState:x,getRootProps(){return t.element({dir:a(`dir`),...M.root.attrs,"data-invalid":c(h),"data-readonly":c(p),"data-disabled":c(f),"data-focus":c(v),"data-empty":c(b),id:wt(o),onPointerDown(){u&&r({type:`POINTER_DOWN`})}})},getLabelProps(){return t.label({...M.label.attrs,"data-disabled":c(f),"data-invalid":c(h),"data-readonly":c(p),"data-required":c(m),id:Ot(o),dir:a(`dir`),htmlFor:Tt(o)})},getControlProps(){return t.element({id:kt(o),...M.control.attrs,dir:a(`dir`),tabIndex:p?0:void 0,"data-disabled":c(f),"data-readonly":c(p),"data-invalid":c(h),"data-focus":c(v)})},getInputProps(){return t.input({...M.input.attrs,dir:a(`dir`),"data-invalid":c(h),"aria-invalid":s(h),"data-readonly":c(p),"data-empty":c(b),maxLength:a(`maxLength`),id:Tt(o),defaultValue:l.get(`inputValue`),autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,enterKeyHint:`done`,disabled:f||p,placeholder:b?a(`placeholder`):void 0,onInput(e){let t=te(e),n=e.currentTarget.value;if(t.inputType===`insertFromPaste`){r({type:`PASTE`,value:n});return}if(qt(n,a(`delimiter`))){r({type:`DELIMITER_KEY`});return}r({type:`TYPE`,value:n,key:t.inputType})},onFocus(){queueMicrotask(()=>{r({type:`FOCUS`})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t=e.currentTarget,n=t.getAttribute(`role`)===`combobox`,i=t.ariaExpanded===`true`,o={ArrowDown(){r({type:`ARROW_DOWN`})},ArrowLeft(){n&&i||r({type:`ARROW_LEFT`})},ArrowRight(e){l.get(`highlightedTagId`)&&e.preventDefault(),!(n&&i)&&r({type:`ARROW_RIGHT`})},Escape(e){e.preventDefault(),r({type:`ESCAPE`})},Backspace(){r({type:`BACKSPACE`})},Delete(){r({type:`DELETE`})},Enter(e){let a=t.getAttribute(`aria-activedescendant`);n&&i&&a||(r({type:`ENTER`}),e.preventDefault())}}[ee(e,{dir:a(`dir`)})];if(o){o(e);return}}})},getHiddenInputProps(){return t.input({type:`text`,hidden:!0,name:a(`name`),form:a(`form`),disabled:f,readOnly:p,required:a(`required`),id:Dt(o),defaultValue:i(`valueAsString`)})},getItemProps(e){return t.element({...M.item.attrs,dir:a(`dir`),"data-value":e.value,"data-disabled":c(f)})},getItemPreviewProps(e){let n=x(e);return t.element({...M.itemPreview.attrs,id:n.id,dir:a(`dir`),hidden:n.editing,"data-value":e.value,"data-disabled":c(f),"data-highlighted":c(n.highlighted),onPointerDown(e){!u||n.disabled||d(e)&&(e.preventDefault(),r({type:`POINTER_DOWN_TAG`,id:n.id}))},onDoubleClick(){!u||n.disabled||r({type:`DOUBLE_CLICK_TAG`,id:n.id})}})},getItemTextProps(e){let n=x(e);return t.element({...M.itemText.attrs,dir:a(`dir`),"data-disabled":c(f),"data-highlighted":c(n.highlighted)})},getItemInputProps(e){let n=x(e);return t.input({...M.itemInput.attrs,dir:a(`dir`),"aria-label":_?.tagEdited?.(e.value),disabled:f,id:jt(o,e),tabIndex:-1,hidden:!n.editing,maxLength:a(`maxLength`),defaultValue:n.editing?l.get(`editedTagValue`):``,onInput(e){r({type:`TAG_INPUT_TYPE`,value:e.currentTarget.value})},onBlur(e){queueMicrotask(()=>{r({type:`TAG_INPUT_BLUR`,target:e.relatedTarget,id:n.id})})},onKeyDown(e){if(e.defaultPrevented||g(e))return;let t={Enter(){r({type:`TAG_INPUT_ENTER`})},Escape(){r({type:`TAG_INPUT_ESCAPE`})}}[e.key];t&&(e.preventDefault(),t(e))}})},getItemDeleteTriggerProps(e){let n=x(e);return t.button({...M.itemDeleteTrigger.attrs,dir:a(`dir`),"data-disabled":c(n.disabled),"aria-disabled":n.disabled,"data-highlighted":c(n.highlighted),id:At(o,e),type:`button`,disabled:n.disabled,"aria-label":_?.deleteTagTriggerLabel?.(e.value),tabIndex:-1,onPointerDown(e){d(e)&&(u||e.preventDefault())},onPointerMove(e){u&&Ut(e.currentTarget)},onPointerLeave(e){u&&Wt(e.currentTarget)},onClick(e){e.defaultPrevented||u&&r({type:`CLICK_DELETE_TAG`,id:n.id})}})},getClearTriggerProps(){return t.button({...M.clearTrigger.attrs,dir:a(`dir`),id:Et(o),type:`button`,"data-readonly":c(p),disabled:f,"aria-label":_?.clearTriggerLabel,hidden:b,onClick(){u&&r({type:`CLEAR_VALUE`})}})}}}function qt(e,t){return t?typeof t==`string`?e.endsWith(t):RegExp(`${t.source}$`).test(e):!1}var{and:Z,not:Q,or:Jt}=u(),Yt=l({props({props:e}){return{dir:`ltr`,addOnPaste:!1,editable:!0,validate:()=>!0,allowDuplicates:!1,delimiter:`,`,defaultValue:[],defaultInputValue:``,max:1/0,sanitizeValue:e=>e.trim(),...e,translations:{clearTriggerLabel:`Clear all tags`,deleteTagTriggerLabel:e=>`Delete tag ${e}`,tagAdded:e=>`Added tag ${e}`,tagsPasted:e=>`Pasted ${e.length} tags`,tagEdited:e=>`Editing tag ${e}. Press enter to save or escape to cancel.`,tagUpdated:e=>`Tag update to ${e}`,tagDeleted:e=>`Tag ${e} deleted`,tagSelected:e=>`Tag ${e} selected. Press enter to edit, delete or backspace to remove.`,...e.translations}}},initialState({prop:e}){return e(`autoFocus`)?`focused:input`:`idle`},refs(){return{liveRegion:null,log:{current:null,prev:null}}},context({bindable:e,prop:t}){return{value:e(()=>({defaultValue:t(`defaultValue`),value:t(`value`),isEqual:je,hash(e){return e.join(`, `)},onChange(e){t(`onValueChange`)?.({value:e})}})),inputValue:e(()=>({sync:!0,defaultValue:t(`defaultInputValue`),value:t(`inputValue`),onChange(e){t(`onInputValueChange`)?.({inputValue:e})}})),fieldsetDisabled:e(()=>({defaultValue:!1})),editedTagValue:e(()=>({defaultValue:``})),editedTagId:e(()=>({defaultValue:null})),editedTagIndex:e(()=>({defaultValue:null,sync:!0})),highlightedTagId:e(()=>({defaultValue:null,sync:!0,onChange(e){t(`onHighlightChange`)?.({highlightedValue:e})}}))}},computed:{count:({context:e})=>e.get(`value`).length,valueAsString:({context:e})=>e.hash(`value`),sanitizedInputValue:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)),isDisabled:({prop:e})=>!!e(`disabled`),isInteractive:({prop:e})=>!(e(`readOnly`)||e(`disabled`)),isAtMax:({context:e,prop:t})=>e.get(`value`).length===t(`max`),isOverflowing:({context:e,prop:t})=>e.get(`value`).length>t(`max`)},watch({track:e,context:t,action:n,computed:r,refs:i}){e([()=>t.get(`editedTagValue`)],()=>{n([`syncEditedTagInputValue`])}),e([()=>t.get(`inputValue`)],()=>{n([`syncInputValue`])}),e([()=>t.get(`highlightedTagId`)],()=>{n([`logHighlightedTag`])}),e([()=>r(`isOverflowing`)],()=>{n([`invokeOnInvalid`])}),e([()=>JSON.stringify(i.get(`log`))],()=>{n([`announceLog`])})},effects:[`trackLiveRegion`,`trackFormControlState`],exit:[`clearLog`],on:{DOUBLE_CLICK_TAG:{guard:`isTagEditable`,target:`editing:tag`,actions:[`setEditedId`]},POINTER_DOWN_TAG:{target:`navigating:tag`,actions:[`highlightTag`,`focusInput`]},CLICK_DELETE_TAG:{target:`focused:input`,actions:[`deleteTag`]},SET_INPUT_VALUE:{actions:[`setInputValue`]},SET_VALUE:{actions:[`setValue`]},CLEAR_TAG:{actions:[`deleteTag`]},SET_VALUE_AT_INDEX:{actions:[`setValueAtIndex`]},CLEAR_VALUE:{actions:[`clearTags`,`clearInputValue`,`focusInput`]},ADD_TAG:{actions:[`addTag`]},INSERT_TAG:{guard:Z(Jt(Q(`isAtMax`),`allowOverflow`),Q(`isInputValueEmpty`)),actions:[`addTag`,`clearInputValue`]},EXTERNAL_BLUR:[{guard:`addOnBlur`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,actions:[`clearInputValue`]}]},states:{idle:{on:{FOCUS:{target:`focused:input`},POINTER_DOWN:{guard:Q(`hasHighlightedTag`),target:`focused:input`}}},"focused:input":{tags:[`focused`],entry:[`focusInput`,`clearHighlightedId`],effects:[`trackInteractOutside`],on:{TYPE:{actions:[`setInputValue`]},BLUR:[{guard:`addOnBlur`,target:`idle`,actions:[`raiseInsertTagEvent`]},{guard:`clearOnBlur`,target:`idle`,actions:[`clearInputValue`]},{target:`idle`}],ENTER:{actions:[`raiseInsertTagEvent`]},DELIMITER_KEY:{actions:[`raiseInsertTagEvent`]},ARROW_LEFT:{guard:Z(`hasTags`,`isCaretAtStart`),target:`navigating:tag`,actions:[`highlightLastTag`]},BACKSPACE:{target:`navigating:tag`,guard:Z(`hasTags`,`isCaretAtStart`),actions:[`highlightLastTag`]},DELETE:{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]},PASTE:[{guard:`addOnPaste`,actions:[`setInputValue`,`addTagFromPaste`]},{actions:[`setInputValue`]}]}},"navigating:tag":{tags:[`focused`],effects:[`trackInteractOutside`],on:{ARROW_RIGHT:[{guard:Z(`hasTags`,`isCaretAtStart`,Q(`isLastTagHighlighted`)),actions:[`highlightNextTag`]},{target:`focused:input`}],ARROW_LEFT:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{actions:[`highlightPrevTag`]}],BLUR:{target:`idle`,actions:[`clearHighlightedId`]},ENTER:{guard:Z(`isTagEditable`,`hasHighlightedTag`),target:`editing:tag`,actions:[`setEditedId`,`focusEditedTagInput`]},ARROW_DOWN:{target:`focused:input`},ESCAPE:{target:`focused:input`},TYPE:{target:`focused:input`,actions:[`setInputValue`]},BACKSPACE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{guard:`isFirstTagHighlighted`,actions:[`deleteHighlightedTag`,`highlightFirstTag`]},{guard:`hasHighlightedTag`,actions:[`deleteHighlightedTag`,`highlightPrevTag`]},{actions:[`highlightLastTag`]}],DELETE:[{guard:Q(`isCaretAtStart`),target:`focused:input`},{target:`focused:input`,actions:[`deleteHighlightedTag`,`highlightTagAtIndex`]}],PASTE:[{guard:`addOnPaste`,target:`focused:input`,actions:[`setInputValue`,`addTagFromPaste`]},{target:`focused:input`,actions:[`setInputValue`]}]}},"editing:tag":{tags:[`editing`,`focused`],entry:[`focusEditedTagInput`],effects:[`autoResize`],on:{TAG_INPUT_TYPE:{actions:[`setEditedTagValue`]},TAG_INPUT_ESCAPE:{target:`navigating:tag`,actions:[`clearEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},TAG_INPUT_BLUR:[{guard:`isInputRelatedTarget`,target:`navigating:tag`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`]},{target:`idle`,actions:[`clearEditedTagValue`,`clearHighlightedId`,`clearEditedId`,`raiseExternalBlurEvent`]}],TAG_INPUT_ENTER:[{guard:`isEditedTagEmpty`,target:`navigating:tag`,actions:[`deleteHighlightedTag`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]},{target:`navigating:tag`,actions:[`submitEditedTagValue`,`focusInput`,`clearEditedId`,`highlightTagAtIndex`]}]}}},implementations:{guards:{isInputRelatedTarget:({scope:e,event:t})=>t.relatedTarget===J(e),isAtMax:({computed:e})=>e(`isAtMax`),hasHighlightedTag:({context:e})=>e.get(`highlightedTagId`)!=null,isFirstTagHighlighted:({context:e,scope:t})=>q(t,{value:e.get(`value`)[0],index:0})===e.get(`highlightedTagId`),isEditedTagEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`editedTagValue`))===``,isLastTagHighlighted:({context:e,scope:t})=>{let n=e.get(`value`),r=n.length-1;return q(t,{value:n[r],index:r})===e.get(`highlightedTagId`)},isInputValueEmpty:({context:e,prop:t})=>t(`sanitizeValue`)(e.get(`inputValue`)).length===0,hasTags:({context:e})=>e.get(`value`).length>0,allowOverflow:({prop:e})=>!!e(`allowOverflow`),autoFocus:({prop:e})=>!!e(`autoFocus`),addOnBlur:({prop:e})=>e(`blurBehavior`)===`add`,clearOnBlur:({prop:e})=>e(`blurBehavior`)===`clear`,addOnPaste:({prop:e})=>!!e(`addOnPaste`),isTagEditable:({prop:e})=>!!e(`editable`),isCaretAtStart:({scope:e})=>it(J(e))},effects:{trackInteractOutside({scope:e,prop:t,send:n}){return Ne(J(e),{exclude(t){return Pt(e).some(e=>r(e,t))},onFocusOutside:t(`onFocusOutside`),onPointerDownOutside:t(`onPointerDownOutside`),onInteractOutside(e){t(`onInteractOutside`)?.(e),!e.defaultPrevented&&n({type:`BLUR`,src:`interact-outside`})}})},trackFormControlState({context:e,send:t,scope:n}){return Ie(Lt(n),{onFieldsetDisabledChange(t){e.set(`fieldsetDisabled`,t)},onFormReset(){t({type:`SET_VALUE`,value:e.initial(`value`),src:`form-reset`})}})},autoResize({context:e,prop:t,scope:n}){let r;return queueMicrotask(()=>{let i=e.get(`editedTagValue`),a=e.get(`editedTagIndex`);!i||a==null||!t(`editable`)||(r=ct(Ft(n,{value:i,index:a})))}),()=>{r?.()}},trackLiveRegion({scope:e,refs:t}){let n=at({level:`assertive`,document:e.getDoc()});return t.set(`liveRegion`,n),()=>n.destroy()}},actions:{raiseInsertTagEvent({send:e}){e({type:`INSERT_TAG`})},raiseExternalBlurEvent({send:e,event:t}){e({type:`EXTERNAL_BLUR`,id:t.id})},dispatchChangeEvent({scope:e,computed:t}){Gt(e,t(`valueAsString`))},highlightNextTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Vt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightFirstTag({context:e,scope:t}){O(()=>{let n=Rt(t);e.set(`highlightedTagId`,n?.id??null)})},highlightLastTag({context:e,scope:t}){let n=zt(t);e.set(`highlightedTagId`,n?.id??null)},highlightPrevTag({context:e,scope:t}){let n=e.get(`highlightedTagId`);if(n==null)return;let r=Bt(t,n);e.set(`highlightedTagId`,r?.id??null)},highlightTag({context:e,event:t}){e.set(`highlightedTagId`,t.id)},highlightTagAtIndex({context:e,scope:t}){O(()=>{let n=e.get(`editedTagIndex`);if(n==null)return;let r=Ht(t,n);r!=null&&(e.set(`highlightedTagId`,r.id),e.set(`editedTagIndex`,null))})},deleteTag({context:e,scope:t,event:n,refs:r}){let i=X(t,n.id),a=e.get(`value`)[i],o=r.get(`log`);r.set(`log`,{prev:o.current,current:{type:`delete`,value:a}}),e.set(`value`,e=>b(e,i))},deleteHighlightedTag({context:e,scope:t,refs:n}){let r=e.get(`highlightedTagId`);if(r==null)return;let i=X(t,r);e.set(`editedTagIndex`,i);let a=e.get(`value`),o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`delete`,value:a[i]}}),e.set(`value`,e=>b(e,i))},setEditedId({context:e,event:t,scope:n}){let r=e.get(`highlightedTagId`),i=t.id??r;e.set(`editedTagId`,i);let a=X(n,i),o=e.get(`value`)[a];e.set(`editedTagIndex`,a),e.set(`editedTagValue`,o)},clearEditedId({context:e}){e.set(`editedTagId`,null)},clearEditedTagValue({context:e}){e.set(`editedTagValue`,``)},setEditedTagValue({context:e,event:t}){e.set(`editedTagValue`,t.value)},submitEditedTagValue({context:e,scope:t,refs:n,prop:r}){let i=e.get(`editedTagId`);if(!i)return;let a=X(t,i),o=e.get(`editedTagValue`),s=e.get(`value`),c=s.some((e,t)=>t!==a&&e===o);if(!r(`allowDuplicates`)&&c||s[a]===o)return;e.set(`value`,e=>{let t=e.slice();return t[a]=o,t});let l=n.get(`log`);n.set(`log`,{prev:l.current,current:{type:`update`,value:o}})},setValueAtIndex({context:e,event:t,refs:n,prop:r}){if(t.value){let i=e.get(`value`),a=i.some((e,n)=>n!==t.index&&e===t.value);if(!r(`allowDuplicates`)&&a||i[t.index]===t.value)return;e.set(`value`,e=>{let n=e.slice();return n[t.index]=t.value,n});let o=n.get(`log`);n.set(`log`,{prev:o.current,current:{type:`update`,value:t.value}})}else y(`You need to provide a value for the tag`)},focusEditedTagInput({context:e,scope:t}){O(()=>{let n=e.get(`editedTagId`);n&&Nt(t,n)?.select()})},setInputValue({context:e,event:t}){e.set(`inputValue`,t.value)},clearHighlightedId({context:e}){e.set(`highlightedTagId`,null)},focusInput({scope:e}){O(()=>{J(e)?.focus()})},clearInputValue({context:e}){O(()=>{e.set(`inputValue`,``)})},syncInputValue({context:e,scope:t}){let n=J(t);n&&Pe(n,e.get(`inputValue`))},syncEditedTagInputValue({context:e,event:t,scope:n}){let r=e.get(`editedTagId`)||e.get(`highlightedTagId`)||t.id;if(r==null)return;let i=Nt(n,r);i&&Pe(i,e.get(`editedTagValue`))},addTag({context:e,event:t,computed:n,prop:r,refs:i}){let a=t.value??n(`sanitizedInputValue`),s=e.get(`value`);if(r(`validate`)?.({inputValue:a,value:Array.from(s)})){let t=r(`allowDuplicates`)?s.concat(a):o(s.concat(a));e.set(`value`,t);let n=i.get(`log`);i.set(`log`,{prev:n.current,current:{type:`add`,value:a}})}else r(`onValueInvalid`)?.({reason:`invalidTag`})},addTagFromPaste({context:e,computed:t,prop:n,refs:r}){O(()=>{let i=t(`sanitizedInputValue`),a=e.get(`value`),s=n(`sanitizeValue`);if(n(`validate`)?.({inputValue:i,value:Array.from(a)})){let t=n(`delimiter`),c=t?i.split(t).map(s):[i],l=n(`allowDuplicates`)?a.concat(...c):o(a.concat(...c));e.set(`value`,l);let u=r.get(`log`);r.set(`log`,{prev:u.current,current:{type:`paste`,values:c}})}else n(`onValueInvalid`)?.({reason:`invalidTag`});e.set(`inputValue`,``)})},clearTags({context:e,refs:t}){e.set(`value`,[]);let n=t.get(`log`);t.set(`log`,{prev:n.current,current:{type:`clear`}})},setValue({context:e,event:t}){e.set(`value`,t.value)},invokeOnInvalid({prop:e,computed:t}){t(`isOverflowing`)&&e(`onValueInvalid`)?.({reason:`rangeOverflow`})},clearLog({refs:e}){let t=e.get(`log`);t.prev=t.current=null},logHighlightedTag({refs:e,context:t,scope:n}){let r=t.get(`highlightedTagId`),i=e.get(`log`);if(r==null||!i.current)return;let a=X(n,r),o=t.get(`value`)[a],s=e.get(`log`);e.set(`log`,{prev:s.current,current:{type:`select`,value:o}})},announceLog({refs:e,prop:t}){let n=e.get(`liveRegion`),r=t(`translations`),i=e.get(`log`);if(!i.current||n==null)return;let a=n,{current:o,prev:s}=i,c;switch(o.type){case`add`:c=r.tagAdded(o.value);break;case`delete`:c=r.tagDeleted(o.value);break;case`update`:c=r.tagUpdated(o.value);break;case`paste`:c=r.tagsPasted(o.values);break;case`select`:c=r.tagSelected(o.value),s?.type===`delete`?c=`${r.tagDeleted(s.value)}. ${c}`:s?.type===`update`&&(c=`${r.tagUpdated(s.value)}. ${c}`);break;default:break}c&&a.announce(c)}}}}),Xt=e=>{let t=(0,G.useId)(),{getRootNode:r}=n(),{dir:i}=f(),a=We();return Kt(m(Yt,{id:t,ids:{label:a?.ids.label,hiddenInput:a?.ids.control},dir:i,disabled:a?.disabled,invalid:a?.invalid,readOnly:a?.readOnly,required:a?.required,getRootNode:r,...e}),v)},Zt=Re(),Qt=(0,G.forwardRef)((e,t)=>{let[n,r]=Zt(e,`addOnPaste.allowDuplicates.allowOverflow.autoFocus.blurBehavior.defaultInputValue.defaultValue.delimiter.disabled.editable.form.id.ids.inputValue.invalid.max.maxLength.name.onFocusOutside.onHighlightChange.onInputValueChange.onInteractOutside.onPointerDownOutside.onValueChange.onValueInvalid.placeholder.readOnly.required.sanitizeValue.translations.validate.value`.split(`.`)),i=Xt(n),o=a(i.getRootProps(),r);return(0,W.jsx)(lt,{value:i,children:(0,W.jsx)(_.div,{...o,ref:t})})});Qt.displayName=`TagsInputRoot`;var $t=Re(),en=(0,G.forwardRef)((e,t)=>{let[{value:n},r]=$t(e,[`value`]),i=a(n.getRootProps(),r);return(0,W.jsx)(lt,{value:n,children:(0,W.jsx)(_.div,{...i,ref:t})})});en.displayName=`TagsInputRootProvider`;var{withProvider:tn,withContext:$,useStyles:nn,PropsProvider:rn}=Ke({key:`tagsInput`});tn(en,`root`,{forwardAsChild:!0});var an=tn(Qt,`root`,{forwardAsChild:!0,defaultProps:{editable:!1}}),on=$(Ct,`label`,{forwardAsChild:!0}),sn=$(dt,`control`,{forwardAsChild:!0}),cn=$(pt,`input`,{forwardAsChild:!0}),ln=$(vt,`item`,{forwardAsChild:!0}),un=$(St,`itemText`,{forwardAsChild:!0}),dn=$(yt,`itemDeleteTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),fn=$(xt,`itemPreview`,{forwardAsChild:!0}),pn=$(bt,`itemInput`,{forwardAsChild:!0}),mn=$(ut,`clearTrigger`,{forwardAsChild:!0,defaultProps:{children:(0,W.jsx)(qe,{})}}),hn=e=>(0,W.jsx)(C,{each:U().value,children:(t,n)=>(0,W.jsxs)(ln,{index:n,value:t,...e,children:[(0,W.jsxs)(fn,{children:[(0,W.jsx)(un,{children:t}),(0,W.jsx)(dn,{})]}),(0,W.jsx)(pn,{})]},n)});function gn({open:e,onClose:t}){let n=Qe(),{hasAccess:r}=S(),i=z({refetchInterval:e?1e3:!1}),a=V.ops.cancelReplay.useMutation({onSuccess:()=>void i.refetch()}),o=i.data,s=o?.state===`running`,c=o?.state===`completed`?`green`:o?.state===`failed`?`red`:o?.state===`cancelled`?`orange`:`blue`,l=o&&o.aggregatesTotal>0?Math.round(o.aggregatesProcessed/o.aggregatesTotal*100):0,u=(0,G.useMemo)(()=>{if(!o?.startedAt||!o.eventsProcessed)return null;let e=(Date.now()-new Date(o.startedAt).getTime())/1e3;return e<1?null:Math.round(o.eventsProcessed/e)},[o?.startedAt,o?.eventsProcessed]);return(0,W.jsx)(se,{open:e,onOpenChange:e=>{e.open||t()},placement:`end`,size:`sm`,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(oe,{children:[(0,W.jsx)(le,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:c,size:`sm`,children:(0,W.jsx)(Je,{})}),`Replay `,o?.state??`idle`]})}),(0,W.jsx)(Se,{})]}),(0,W.jsx)(ce,{children:!o||o.state===`idle`?(0,W.jsx)(j,{textStyle:`sm`,color:`fg.muted`,children:`No replay is currently running.`}):(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(nt,{currentPhase:o.currentPhase,completedState:o.state===`running`?null:o.state}),o.currentPhase&&(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`lg`,children:rt[o.currentPhase]??`·`}),(0,W.jsxs)(B,{align:`start`,gap:0,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:tt[o.currentPhase]??o.currentPhase}),o.currentProjection&&(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:o.currentProjection})]})]}),o.aggregatesTotal>0&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Aggregates`}),(0,W.jsxs)(j,{textStyle:`xs`,fontWeight:`medium`,children:[o.aggregatesProcessed.toLocaleString(),` / `,o.aggregatesTotal.toLocaleString(),` (`,l,`%)`]})]}),(0,W.jsx)(ie,{value:l,size:`sm`,colorPalette:c,children:(0,W.jsx)(fe,{children:(0,W.jsx)(Oe,{})})})]}),(0,W.jsx)(Le,{}),(0,W.jsxs)(N,{gap:4,flexWrap:`wrap`,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.eventsProcessed.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.projectionNames.length})]}),u!==null&&(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Events/s`}),(0,W.jsx)(L,{textStyle:`lg`,children:u.toLocaleString()})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Elapsed`}),(0,W.jsx)(L,{textStyle:`lg`,children:o.startedAt?Ye(o.startedAt):`—`})]})]}),(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:o.projectionNames.map(e=>(0,W.jsx)(A,{size:`sm`,variant:e===o.currentProjection?`solid`:`subtle`,colorPalette:e===o.currentProjection?`orange`:`gray`,children:e},e))})]}),o.description&&(0,W.jsxs)(B,{align:`stretch`,gap:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Description`}),(0,W.jsx)(j,{textStyle:`sm`,children:o.description})]}),o.error&&(0,W.jsxs)(D,{padding:3,borderRadius:`md`,bg:`red.subtle`,borderWidth:`1px`,borderColor:`red.200`,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`red.fg`,marginBottom:1,children:`Error`}),(0,W.jsx)(j,{textStyle:`xs`,color:`red.fg`,children:o.error})]})]})}),(0,W.jsx)(xe,{children:(0,W.jsxs)(N,{gap:2,width:`full`,children:[o?.runId&&(0,W.jsx)(E,{size:`sm`,variant:`outline`,flex:1,onClick:()=>{n.push(`/ops/projections/${o.runId}`),t()},children:`Full Page View`}),s&&r&&(0,W.jsx)(E,{size:`sm`,colorPalette:`red`,variant:`outline`,loading:a.isPending,onClick:()=>a.mutate(),children:`Cancel`})]})})]})})}function _n(){let e=Qe(),t=z(),n=V.ops.cancelReplay.useMutation({onSuccess:()=>void t.refetch()}),{hasAccess:r}=S(),i=t.data;return!i||i.state!==`running`?null:(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsxs)(N,{justify:`space-between`,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:`blue`,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`semibold`,children:`Replay running`}),i.currentProjection&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,children:i.currentProjection})]}),(0,W.jsxs)(N,{gap:2,children:[i.runId&&(0,W.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>void e.push(`/ops/projections/${i.runId}`),children:`View Progress`}),r&&(0,W.jsx)(E,{size:`xs`,colorPalette:`red`,variant:`outline`,loading:n.isPending,onClick:()=>n.mutate(),children:`Cancel`})]})]})})})}function vn(){let e=Qe(),t=V.ops.getReplayHistory.useQuery(void 0,{refetchInterval:1e4}).data;return!t||t.length===0?null:(0,W.jsx)(P,{overflow:`hidden`,children:(0,W.jsxs)(F,{padding:0,children:[(0,W.jsx)(N,{paddingX:4,paddingY:3,children:(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`Replay History`})}),(0,W.jsx)(ae,{children:(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,css:{"& tr:last-child td":{borderBottom:`none`}},children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{children:`Status`}),(0,W.jsx)(T,{children:`Description`}),(0,W.jsx)(T,{children:`Projections`}),(0,W.jsx)(T,{textAlign:`end`,children:`Duration`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{textAlign:`end`,children:`Events`}),(0,W.jsx)(T,{children:`When`}),(0,W.jsx)(T,{width:`40px`})]})}),(0,W.jsx)(ge,{children:t.map(t=>{let n=Ze(t.state);return(0,W.jsxs)(de,{cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>void e.push(`/ops/projections/${t.runId}`),children:[(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(Xe,{colorPalette:n,children:(0,W.jsx)(Je,{})}),(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:n,children:t.state})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,truncate:!0,maxW:`300px`,children:t.description??`—`})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[t.projectionNames?.length??0,` projection`,(t.projectionNames?.length??0)===1?``:`s`]})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:Ye(t.startedAt,t.completedAt)})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.aggregatesProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{textStyle:`xs`,children:(t.eventsProcessed??0).toLocaleString()})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,whiteSpace:`nowrap`,children:t.startedAt?new Date(t.startedAt).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`})}),(0,W.jsx)(w,{children:(0,W.jsx)($e,{size:12,style:{opacity:.5}})})]},t.runId)})})]})})]})})}function yn({tenantIds:e,onTenantIdsChange:t}){let[n,r]=(0,G.useState)(``),i=V.ops.searchTenants.useQuery({query:n},{enabled:n.length>=2});return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(an,{size:`sm`,value:e,onValueChange:e=>t(e.value),addOnPaste:!0,delimiter:`,`,blurBehavior:`add`,validate:e=>e.inputValue.trim().length>0,children:[(0,W.jsx)(on,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Tenants`})}),(0,W.jsxs)(sn,{children:[(0,W.jsx)(hn,{}),(0,W.jsx)(cn,{placeholder:`Type tenant ID and press Enter...`}),(0,W.jsx)(mn,{})]})]}),(0,W.jsxs)(D,{position:`relative`,children:[(0,W.jsxs)(N,{gap:2,borderWidth:`1px`,borderRadius:`md`,paddingX:3,paddingY:1.5,children:[(0,W.jsx)(ne,{size:12,color:`var(--chakra-colors-fg-muted)`}),(0,W.jsx)(`input`,{style:{flex:1,background:`transparent`,border:`none`,outline:`none`,fontSize:`12px`,color:`inherit`},placeholder:`Search tenants by name or ID...`,value:n,onChange:e=>r(e.target.value)})]}),i.data&&i.data.length>0&&(0,W.jsx)(D,{position:`absolute`,zIndex:10,width:`full`,borderWidth:`1px`,borderRadius:`md`,bg:`bg.panel`,shadow:`md`,maxHeight:`200px`,overflowY:`auto`,marginTop:1,children:i.data.map(n=>(0,W.jsx)(D,{paddingX:3,paddingY:2,cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:()=>{e.includes(n.id)||t([...e,n.id]),r(``)},children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,children:n.name}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,fontFamily:`mono`,children:n.id}),e.includes(n.id)&&(0,W.jsx)(A,{size:`sm`,colorPalette:`green`,children:`added`})]})},n.id))})]})]})}function bn({onReplayStarted:e}){let{hasAccess:t}=S(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(``),f=V.ops.listProjections.useQuery(),p=z(),m=i||n.length>0,h=o.length>0,ee=m&&h,g=V.ops.discoverAggregates.useQuery({projectionNames:f.data?.projections.map(e=>e.projectionName)??[],since:o,tenantIds:i?[]:n},{enabled:!1}),_=(0,G.useRef)(``);(0,G.useEffect)(()=>{if(!ee)return;let e=JSON.stringify({tenantIds:i?[]:n,since:o});e!==_.current&&(_.current=e,g.refetch().then(e=>{e.data&&l(new Set(e.data.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)))}))},[ee,i,n,o]);let te=!!g.data,v=new Set(g.data?.projections.filter(e=>e.aggregateCount>0).map(e=>e.projectionName)??[]),y=V.ops.startReplay.useMutation({onSuccess:()=>{p.refetch(),k.create({title:`Projection replay started`,description:`Replaying ${c.size} projection${c.size===1?``:`s`}...`,type:`success`}),e()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}}),[b,ne]=(0,G.useState)(null),re=V.ops.dryRunReplay.useMutation({onSuccess:e=>{ne(e),k.create({title:`Dry run complete`,description:e.message,type:`info`})},onError:e=>{k.create({title:`Dry run failed`,description:e.message,type:`error`})}});function ie(e){v.has(e)&&l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){l(new Set(v))}let C=g.data?.projections.filter(e=>c.has(e.projectionName)).reduce((e,t)=>e+t.aggregateCount,0)??0,oe=p.data?.state===`running`;function se(){y.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n,description:u||`Manual replay`})}function ce(){re.mutate({projectionNames:[...c],since:o,tenantIds:i?[]:n})}return f.isLoading?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(Ae,{size:`lg`})}):f.data&&f.data.projections.length===0?(0,W.jsx)(Ue,{paddingY:20,children:(0,W.jsx)(ue,{children:(0,W.jsxs)(he,{children:[(0,W.jsx)(x,{children:`No projections registered`}),(0,W.jsx)(me,{children:`No fold projections were found in the pipeline registry.`})]})})}):f.data?(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{marginBottom:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`1. Select tenants`}),(0,W.jsx)(De,{size:`sm`,checked:i,onCheckedChange:e=>{a(!!e.checked),e.checked&&r([])},children:(0,W.jsx)(j,{textStyle:`xs`,children:`All tenants`})})]}),(0,W.jsx)(D,{opacity:i?.4:1,pointerEvents:i?`none`:`auto`,children:(0,W.jsx)(yn,{tenantIds:n,onTenantIdsChange:r})}),!m&&!i&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,marginTop:2,children:`At least 1 tenant is required to proceed`})]})}),(0,W.jsx)(P,{opacity:m?1:.5,pointerEvents:m?`auto`:`none`,children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,marginBottom:3,children:`2. Choose date range`}),(0,W.jsxs)(N,{gap:3,alignItems:`end`,flexWrap:`wrap`,children:[(0,W.jsxs)(D,{maxWidth:`220px`,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Replay events since`}),(0,W.jsx)(Ge,{type:`date`,size:`sm`,value:o,onChange:e=>s(e.target.value)})]}),(0,W.jsx)(N,{gap:1,children:[{label:`This month`,months:0},{label:`2 months`,months:2},{label:`3 months`,months:3},{label:`6 months`,months:6}].map(({label:e,months:t})=>{let n=new Date;t===0?n.setDate(1):n.setMonth(n.getMonth()-t);let r=n.toISOString().slice(0,10);return(0,W.jsx)(E,{size:`sm`,height:`36px`,variant:o===r?`solid`:`outline`,onClick:()=>s(r),children:e},e)})})]}),ee&&g.isFetching&&(0,W.jsxs)(N,{gap:2,marginTop:3,children:[(0,W.jsx)(Ae,{size:`xs`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Discovering aggregates...`})]})]})}),te&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:0,overflowX:`auto`,children:[(0,W.jsxs)(N,{paddingX:4,paddingY:3,justify:`space-between`,children:[(0,W.jsx)(j,{textStyle:`sm`,fontWeight:`medium`,children:`3. Select projections to replay`}),(0,W.jsx)(E,{variant:`ghost`,size:`xs`,onClick:ae,children:`Select all with data`})]}),(0,W.jsxs)(Ee,{size:`sm`,variant:`line`,children:[(0,W.jsx)(ve,{children:(0,W.jsxs)(de,{children:[(0,W.jsx)(T,{width:`40px`}),(0,W.jsx)(T,{children:`Projection`}),(0,W.jsx)(T,{children:`Pipeline`}),(0,W.jsx)(T,{textAlign:`end`,children:`Aggregates`}),(0,W.jsx)(T,{children:`Tenants`})]})}),(0,W.jsx)(ge,{children:g.data.projections.map(e=>{let t=e.aggregateCount>0,n=c.has(e.projectionName);return(0,W.jsxs)(de,{cursor:t?`pointer`:`default`,opacity:t?1:.4,onClick:()=>ie(e.projectionName),_hover:t?{bg:`bg.subtle`}:void 0,bg:n?`bg.subtle`:void 0,children:[(0,W.jsx)(w,{children:(0,W.jsx)(De,{checked:n,disabled:!t,onCheckedChange:()=>ie(e.projectionName)})}),(0,W.jsx)(w,{children:(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(j,{textStyle:`sm`,children:e.projectionName}),!t&&(0,W.jsx)(A,{size:`sm`,variant:`subtle`,colorPalette:`gray`,children:`no data`})]})}),(0,W.jsx)(w,{children:(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:f.data?.projections.find(t=>t.projectionName===e.projectionName)?.pipelineName??`—`})}),(0,W.jsx)(w,{textAlign:`end`,children:(0,W.jsx)(j,{fontWeight:`medium`,children:e.aggregateCount})}),(0,W.jsx)(w,{children:(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,children:[e.tenantBreakdown.length,` tenant`,e.tenantBreakdown.length===1?``:`s`]})})]},e.projectionName)})})]})]})}),c.size>0&&(0,W.jsx)(P,{children:(0,W.jsxs)(F,{padding:4,children:[(0,W.jsxs)(N,{gap:6,marginBottom:4,children:[(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Selected Aggregates`}),(0,W.jsx)(L,{children:C})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Projections`}),(0,W.jsx)(L,{children:c.size})]}),(0,W.jsxs)(I,{children:[(0,W.jsx)(R,{children:`Tenants`}),(0,W.jsx)(L,{children:i?`All`:n.length})]})]}),t&&(0,W.jsxs)(B,{align:`stretch`,gap:3,children:[(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Description (for audit log)`}),(0,W.jsx)(be,{size:`sm`,placeholder:`Describe the reason for this replay...`,value:u,onChange:e=>d(e.target.value),rows:2})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,colorPalette:`orange`,disabled:oe||C===0,loading:y.isPending,onClick:se,children:`Start Full Replay`}),(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:oe||C===0,loading:re.isPending,onClick:ce,children:`Dry Run (5 aggregates)`}),oe&&(0,W.jsx)(j,{textStyle:`xs`,color:`orange.500`,children:`A replay is already running`})]}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Full replay pauses projections, drains active jobs, replays events from ClickHouse, then unpauses. Dry run processes 5 sample aggregates in memory without writing.`}),b&&(0,W.jsx)(P,{borderColor:`blue.200`,borderWidth:`1px`,children:(0,W.jsxs)(F,{padding:3,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`blue.500`,marginBottom:1,children:`Dry Run Result`}),(0,W.jsx)(j,{textStyle:`sm`,children:b.message}),(0,W.jsxs)(j,{textStyle:`xs`,color:`fg.muted`,marginTop:1,children:[`Projections:`,` `,b.projectionNames.join(`, `),` | Sample size: `,b.sampleSize]})]})})]})]})})]})]}):null}function xn({projections:e,onReplayStarted:t}){let n=z(),r=n.data?.state===`running`,[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(new Set),[u]=(0,G.useState)(()=>{let e=new Date;return e.setMonth(e.getMonth()-3),e.toISOString().slice(0,10)}),d=V.ops.startReplay.useMutation({onSuccess:()=>{n.refetch(),k.create({title:`Single aggregate replay started`,type:`success`}),t()},onError:e=>{k.create({title:`Failed to start replay`,description:e.message,type:`error`})}});function f(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,W.jsxs)(B,{align:`stretch`,gap:2,children:[(0,W.jsxs)(N,{gap:2,children:[(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Aggregate ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. trace_abc123`,value:i,onChange:e=>a(e.target.value),fontFamily:`mono`})]}),(0,W.jsxs)(D,{flex:1,children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Tenant ID`}),(0,W.jsx)(Ge,{size:`sm`,placeholder:`e.g. project_xyz`,value:o,onChange:e=>s(e.target.value),fontFamily:`mono`})]})]}),(0,W.jsxs)(D,{children:[(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,marginBottom:1,children:`Projections`}),(0,W.jsx)(N,{gap:1,flexWrap:`wrap`,children:e.map(e=>(0,W.jsx)(A,{size:`sm`,variant:c.has(e.projectionName)?`solid`:`outline`,colorPalette:c.has(e.projectionName)?`orange`:`gray`,cursor:`pointer`,onClick:()=>f(e.projectionName),children:e.projectionName},e.projectionName))})]}),(0,W.jsxs)(N,{gap:2,children:[(0,W.jsx)(E,{size:`sm`,variant:`outline`,disabled:!i.trim()||!o.trim()||c.size===0||r,loading:d.isPending,onClick:()=>{d.mutate({projectionNames:[...c],since:u,tenantIds:[o.trim()],aggregateIds:[i.trim()],description:`Single aggregate replay: ${i.trim()}`})},children:`Replay Single`}),(0,W.jsx)(j,{textStyle:`xs`,color:`fg.muted`,children:`Replays selected projections for a single tenant (events from last 3 months)`})]})]})}function Sn(){let{hasAccess:e}=S(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=V.ops.listProjections.useQuery().data?.projections??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(B,{align:`stretch`,gap:4,children:[(0,W.jsx)(_n,{}),(0,W.jsx)(bn,{onReplayStarted:()=>n(!0)}),e&&a.length>0&&(0,W.jsxs)(Te,{open:r,onOpenChange:e=>i(e.open),children:[(0,W.jsx)(we,{asChild:!0,children:(0,W.jsx)(D,{cursor:`pointer`,userSelect:`none`,children:(0,W.jsxs)(N,{gap:2,paddingY:1,children:[(0,W.jsx)(j,{textStyle:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`Advanced: Single Aggregate Replay`}),(0,W.jsx)(_e,{size:12,style:{transform:r?`rotate(180deg)`:`none`,transition:`transform 0.15s`}})]})})}),(0,W.jsx)(ye,{children:(0,W.jsx)(P,{marginTop:2,children:(0,W.jsx)(F,{padding:4,children:(0,W.jsx)(xn,{projections:a,onReplayStarted:()=>n(!0)})})})})]}),(0,W.jsx)(vn,{})]}),(0,W.jsx)(gn,{open:t,onClose:()=>n(!1)})]})}function Cn(){return(0,W.jsx)(et,{children:(0,W.jsxs)(Ce,{children:[(0,W.jsx)(pe.Header,{children:(0,W.jsx)(pe.Heading,{children:`Projection Replay`})}),(0,W.jsx)(pe.Container,{children:(0,W.jsx)(Sn,{})})]})})}export{Cn as default};
2
+ //# sourceMappingURL=projections-it4FOVjm.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,qi as u,vs as d,xs as f,ys as p}from"./command-bar-CaJygoez.js";import{j as m,n as h}from"./stack-oJ9iWdbl.js";import{t as g}from"./box-BsM8YLGl.js";import{n as _}from"./toaster-C_DYALhL.js";import{an as v}from"./dist-SwV3YZv3.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,u as z}from"./useAdminResource-SPC5iBHM.js";var B=N(),V=e(t()),H=m(),U=25;function W(){let e=M(),t=(0,V.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,V.useState)(1),[m,h]=(0,V.useState)(t.current),[_]=l(m,300),[y,b]=(0,V.useState)(null),x=I(`project`,{pagination:{page:n,perPage:U},sort:{field:`createdAt`,order:`DESC`},filter:_?{query:_}:{}});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(P,{title:`Projects`,searchValue:m,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:n,perPage:U,total:x.data?.total??0,onPageChange:c},children:(0,H.jsxs)(f,{variant:`line`,size:`md`,width:`full`,children:[(0,H.jsx)(s,{children:(0,H.jsxs)(i,{children:[(0,H.jsx)(p,{children:`ID`}),(0,H.jsx)(p,{children:`Name`}),(0,H.jsx)(p,{children:`Slug`}),(0,H.jsx)(p,{children:`Language`}),(0,H.jsx)(p,{children:`Framework`}),(0,H.jsx)(p,{children:`PII`}),(0,H.jsx)(p,{children:`Status`}),(0,H.jsx)(p,{children:`Created`}),(0,H.jsx)(p,{width:`60px`,textAlign:`right`})]})}),(0,H.jsxs)(o,{children:[x.data?.data.length===0&&(0,H.jsx)(i,{children:(0,H.jsx)(d,{colSpan:9,children:(0,H.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No projects match your search.`})})}),x.data?.data.map(e=>(0,H.jsxs)(i,{children:[(0,H.jsx)(d,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,H.jsx)(d,{children:e.name}),(0,H.jsx)(d,{children:e.slug}),(0,H.jsx)(d,{children:e.language??(0,H.jsx)(L,{})}),(0,H.jsx)(d,{children:e.framework??(0,H.jsx)(L,{})}),(0,H.jsx)(d,{children:(0,H.jsx)(v,{size:`sm`,variant:`subtle`,children:e.piiRedactionLevel})}),(0,H.jsx)(d,{children:e.archivedAt?(0,H.jsx)(v,{size:`sm`,colorPalette:`gray`,children:`Archived`}):e.integrated?(0,H.jsx)(v,{size:`sm`,colorPalette:`green`,children:`Integrated`}):(0,H.jsx)(v,{size:`sm`,colorPalette:`yellow`,children:`Pending`})}),(0,H.jsx)(d,{children:F(e.createdAt)}),(0,H.jsx)(d,{textAlign:`right`,children:(0,H.jsx)(g,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,H.jsxs)(u.Root,{children:[(0,H.jsx)(u.Trigger,{children:(0,H.jsx)(a,{size:16})}),(0,H.jsx)(u.Content,{children:(0,H.jsxs)(u.Item,{value:`edit`,onClick:()=>b(e),children:[(0,H.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,H.jsx)(K,{project:y,onClose:()=>b(null)})]})}function G(e){return e.trim()===``?null:e}function K({project:e,onClose:t}){let r=R(`project`),[i,a]=(0,V.useState)(null);(0,V.useEffect)(()=>{e&&a({name:e.name,slug:e.slug,language:e.language??``,framework:e.framework??``,firstMessage:!!e.firstMessage,integrated:!!e.integrated,userLinkTemplate:e.userLinkTemplate??``,piiRedactionLevel:e.piiRedactionLevel,capturedInputVisibility:e.capturedInputVisibility,capturedOutputVisibility:e.capturedOutputVisibility,traceSharingEnabled:!!e.traceSharingEnabled,defaultModel:e.defaultModel??``,topicClusteringModel:e.topicClusteringModel??``,embeddingsModel:e.embeddingsModel??``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``,archive:!!e.archivedAt})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,H.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,H.jsxs)(n.Content,{children:[(0,H.jsx)(n.Header,{children:(0,H.jsx)(n.Title,{children:`Edit Project`})}),(0,H.jsx)(n.CloseTrigger,{}),(0,H.jsx)(n.Body,{children:e&&i&&(0,H.jsxs)(j,{gap:4,align:`stretch`,children:[(0,H.jsx)(q,{children:`Identity`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Name`}),(0,H.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Slug`}),(0,H.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,H.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,H.jsxs)(k,{gap:3,children:[(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Language`}),(0,H.jsx)(O,{value:i.language,onChange:e=>o(`language`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Framework`}),(0,H.jsx)(O,{value:i.framework,onChange:e=>o(`framework`,e.target.value)})]})]}),(0,H.jsx)(q,{children:`Onboarding flags`}),(0,H.jsx)(Y,{label:`First message received`,hint:`Flipped by the collector on the first ingested trace.`,checked:i.firstMessage,onChange:e=>o(`firstMessage`,e)}),(0,H.jsx)(Y,{label:`Integrated`,hint:`Tenant-visible ‘setup complete’ state.`,checked:i.integrated,onChange:e=>o(`integrated`,e)}),(0,H.jsx)(q,{children:`Privacy`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`PII redaction level`}),(0,H.jsx)(J,{value:i.piiRedactionLevel,options:Object.values(B.PIIRedactionLevel),onChange:e=>o(`piiRedactionLevel`,e)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Captured input visibility`}),(0,H.jsx)(J,{value:i.capturedInputVisibility,options:Object.values(B.ProjectSensitiveDataVisibilityLevel),onChange:e=>o(`capturedInputVisibility`,e)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Captured output visibility`}),(0,H.jsx)(J,{value:i.capturedOutputVisibility,options:Object.values(B.ProjectSensitiveDataVisibilityLevel),onChange:e=>o(`capturedOutputVisibility`,e)})]}),(0,H.jsx)(Y,{label:`Trace sharing enabled`,hint:`Allow operators to generate public share links for traces.`,checked:i.traceSharingEnabled,onChange:e=>o(`traceSharingEnabled`,e)}),(0,H.jsx)(q,{children:`Integrations`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`User link template`}),(0,H.jsx)(O,{value:i.userLinkTemplate,onChange:e=>o(`userLinkTemplate`,e.target.value),placeholder:`e.g. https://app.acme.com/users/{{userId}}`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Default model`}),(0,H.jsx)(O,{value:i.defaultModel,onChange:e=>o(`defaultModel`,e.target.value),placeholder:`e.g. openai/gpt-5-mini`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Topic clustering model`}),(0,H.jsx)(O,{value:i.topicClusteringModel,onChange:e=>o(`topicClusteringModel`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Embeddings model`}),(0,H.jsx)(O,{value:i.embeddingsModel,onChange:e=>o(`embeddingsModel`,e.target.value)})]}),(0,H.jsx)(q,{children:`Project S3`}),(0,H.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Endpoint`}),(0,H.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Bucket`}),(0,H.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Access key ID`}),(0,H.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Secret access key`}),(0,H.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,H.jsx)(q,{children:`Lifecycle`}),(0,H.jsx)(Y,{label:`Archived`,hint:`Hides the project from the UI and stops it from accruing limits.`,checked:i.archive,onChange:e=>o(`archive`,e)}),(0,H.jsx)(y,{my:2}),(0,H.jsxs)(j,{align:`start`,gap:0,children:[(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Project ID: `,e.id]}),(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Team: `,e.teamId]}),(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`API key: `,e.apiKey]}),e.archivedAt&&(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Archived at: `,F(e.archivedAt)]})]})]})}),(0,H.jsx)(n.Footer,{children:(0,H.jsxs)(k,{width:`full`,children:[(0,H.jsx)(A,{}),(0,H.jsx)(h,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,H.jsx)(h,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.language!==(e.language??``)&&(n.language=i.language),i.framework!==(e.framework??``)&&(n.framework=i.framework),i.firstMessage!==!!e.firstMessage&&(n.firstMessage=i.firstMessage),i.integrated!==!!e.integrated&&(n.integrated=i.integrated),i.userLinkTemplate!==(e.userLinkTemplate??``)&&(n.userLinkTemplate=G(i.userLinkTemplate)),i.piiRedactionLevel!==e.piiRedactionLevel&&(n.piiRedactionLevel=i.piiRedactionLevel),i.capturedInputVisibility!==e.capturedInputVisibility&&(n.capturedInputVisibility=i.capturedInputVisibility),i.capturedOutputVisibility!==e.capturedOutputVisibility&&(n.capturedOutputVisibility=i.capturedOutputVisibility),i.traceSharingEnabled!==!!e.traceSharingEnabled&&(n.traceSharingEnabled=i.traceSharingEnabled),i.defaultModel!==(e.defaultModel??``)&&(n.defaultModel=G(i.defaultModel)),i.topicClusteringModel!==(e.topicClusteringModel??``)&&(n.topicClusteringModel=G(i.topicClusteringModel)),i.embeddingsModel!==(e.embeddingsModel??``)&&(n.embeddingsModel=G(i.embeddingsModel)),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket);let a=!!e.archivedAt;if(i.archive!==a&&(n.archivedAt=i.archive?new Date().toISOString():null),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{_.create({title:`Project updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>_.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function q({children:e}){return(0,H.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function J({value:e,options:t,onChange:n}){return(0,H.jsxs)(x,{size:`sm`,width:`full`,children:[(0,H.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))}),(0,H.jsx)(b,{})]})}function Y({label:e,hint:t,checked:n,onChange:r}){return(0,H.jsx)(T,{children:(0,H.jsxs)(k,{width:`full`,children:[(0,H.jsxs)(j,{align:`start`,gap:0,children:[(0,H.jsx)(D,{children:e}),t&&(0,H.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,H.jsx)(A,{}),(0,H.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function X(){return(0,H.jsx)(z,{children:(0,H.jsx)(W,{})})}export{X as default};
2
- //# sourceMappingURL=projects-BxM7C87h.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Ra as r,Ss as i,Xa as a,_s as o,bs as s,fa as c,ga as l,qi as u,vs as d,xs as f,ys as p}from"./command-bar-DUK45yin.js";import{j as m,n as h}from"./stack-oJ9iWdbl.js";import{t as g}from"./box-BsM8YLGl.js";import{n as _}from"./toaster-C_DYALhL.js";import{an as v}from"./dist-Cds4Mqhj.js";import{h as y}from"./terminal-CfM0q99k.js";import{n as b,r as x,t as S}from"./native-select-B51i56CE.js";import{t as C}from"./heading-D90dlSnH.js";import{t as w}from"./text-CwTrMF8x.js";import{a as T,n as E,r as D}from"./field-CnUiixMS.js";import{t as O}from"./input-C7emsUCL.js";import{t as k}from"./h-stack-BKLDJ2vg.js";import{t as A}from"./spacer-2LJJGbo8.js";import{t as j}from"./v-stack-EOPQ57OZ.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N}from"./useOrganizationTeamProject-DC0iozx2.js";import{a as P,c as F,n as I,o as L,r as R,u as z}from"./useAdminResource-SmnnHro6.js";var B=N(),V=e(t()),H=m(),U=25;function W(){let e=M(),t=(0,V.useRef)(typeof e.query.q==`string`?e.query.q:``),[n,c]=(0,V.useState)(1),[m,h]=(0,V.useState)(t.current),[_]=l(m,300),[y,b]=(0,V.useState)(null),x=I(`project`,{pagination:{page:n,perPage:U},sort:{field:`createdAt`,order:`DESC`},filter:_?{query:_}:{}});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(P,{title:`Projects`,searchValue:m,onSearchChange:e=>{h(e),c(1)},searchPlaceholder:`Search by ID, name, or slug`,isLoading:x.isLoading,isFetching:x.isFetching,error:x.error,pagination:{page:n,perPage:U,total:x.data?.total??0,onPageChange:c},children:(0,H.jsxs)(f,{variant:`line`,size:`md`,width:`full`,children:[(0,H.jsx)(s,{children:(0,H.jsxs)(i,{children:[(0,H.jsx)(p,{children:`ID`}),(0,H.jsx)(p,{children:`Name`}),(0,H.jsx)(p,{children:`Slug`}),(0,H.jsx)(p,{children:`Language`}),(0,H.jsx)(p,{children:`Framework`}),(0,H.jsx)(p,{children:`PII`}),(0,H.jsx)(p,{children:`Status`}),(0,H.jsx)(p,{children:`Created`}),(0,H.jsx)(p,{width:`60px`,textAlign:`right`})]})}),(0,H.jsxs)(o,{children:[x.data?.data.length===0&&(0,H.jsx)(i,{children:(0,H.jsx)(d,{colSpan:9,children:(0,H.jsx)(w,{color:`fg.muted`,textAlign:`center`,paddingY:6,children:`No projects match your search.`})})}),x.data?.data.map(e=>(0,H.jsxs)(i,{children:[(0,H.jsx)(d,{fontSize:`xs`,color:`fg.muted`,children:e.id}),(0,H.jsx)(d,{children:e.name}),(0,H.jsx)(d,{children:e.slug}),(0,H.jsx)(d,{children:e.language??(0,H.jsx)(L,{})}),(0,H.jsx)(d,{children:e.framework??(0,H.jsx)(L,{})}),(0,H.jsx)(d,{children:(0,H.jsx)(v,{size:`sm`,variant:`subtle`,children:e.piiRedactionLevel})}),(0,H.jsx)(d,{children:e.archivedAt?(0,H.jsx)(v,{size:`sm`,colorPalette:`gray`,children:`Archived`}):e.integrated?(0,H.jsx)(v,{size:`sm`,colorPalette:`green`,children:`Integrated`}):(0,H.jsx)(v,{size:`sm`,colorPalette:`yellow`,children:`Pending`})}),(0,H.jsx)(d,{children:F(e.createdAt)}),(0,H.jsx)(d,{textAlign:`right`,children:(0,H.jsx)(g,{width:`full`,height:`full`,display:`flex`,justifyContent:`end`,children:(0,H.jsxs)(u.Root,{children:[(0,H.jsx)(u.Trigger,{children:(0,H.jsx)(a,{size:16})}),(0,H.jsx)(u.Content,{children:(0,H.jsxs)(u.Item,{value:`edit`,onClick:()=>b(e),children:[(0,H.jsx)(r,{size:16}),`Edit`]})})]})})})]},e.id))]})]})}),(0,H.jsx)(K,{project:y,onClose:()=>b(null)})]})}function G(e){return e.trim()===``?null:e}function K({project:e,onClose:t}){let r=R(`project`),[i,a]=(0,V.useState)(null);(0,V.useEffect)(()=>{e&&a({name:e.name,slug:e.slug,language:e.language??``,framework:e.framework??``,firstMessage:!!e.firstMessage,integrated:!!e.integrated,userLinkTemplate:e.userLinkTemplate??``,piiRedactionLevel:e.piiRedactionLevel,capturedInputVisibility:e.capturedInputVisibility,capturedOutputVisibility:e.capturedOutputVisibility,traceSharingEnabled:!!e.traceSharingEnabled,defaultModel:e.defaultModel??``,topicClusteringModel:e.topicClusteringModel??``,embeddingsModel:e.embeddingsModel??``,s3Endpoint:``,s3AccessKeyId:``,s3SecretAccessKey:``,s3Bucket:``,archive:!!e.archivedAt})},[e]);let o=(e,t)=>a(n=>n&&{...n,[e]:t});return(0,H.jsx)(n.Root,{open:!!e,onOpenChange:({open:e})=>{e||t()},size:`md`,children:(0,H.jsxs)(n.Content,{children:[(0,H.jsx)(n.Header,{children:(0,H.jsx)(n.Title,{children:`Edit Project`})}),(0,H.jsx)(n.CloseTrigger,{}),(0,H.jsx)(n.Body,{children:e&&i&&(0,H.jsxs)(j,{gap:4,align:`stretch`,children:[(0,H.jsx)(q,{children:`Identity`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Name`}),(0,H.jsx)(O,{value:i.name,onChange:e=>o(`name`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Slug`}),(0,H.jsx)(O,{value:i.slug,onChange:e=>o(`slug`,e.target.value)}),(0,H.jsx)(E,{children:`URL-safe identifier. Changing this can break existing links.`})]}),(0,H.jsxs)(k,{gap:3,children:[(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Language`}),(0,H.jsx)(O,{value:i.language,onChange:e=>o(`language`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Framework`}),(0,H.jsx)(O,{value:i.framework,onChange:e=>o(`framework`,e.target.value)})]})]}),(0,H.jsx)(q,{children:`Onboarding flags`}),(0,H.jsx)(Y,{label:`First message received`,hint:`Flipped by the collector on the first ingested trace.`,checked:i.firstMessage,onChange:e=>o(`firstMessage`,e)}),(0,H.jsx)(Y,{label:`Integrated`,hint:`Tenant-visible ‘setup complete’ state.`,checked:i.integrated,onChange:e=>o(`integrated`,e)}),(0,H.jsx)(q,{children:`Privacy`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`PII redaction level`}),(0,H.jsx)(J,{value:i.piiRedactionLevel,options:Object.values(B.PIIRedactionLevel),onChange:e=>o(`piiRedactionLevel`,e)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Captured input visibility`}),(0,H.jsx)(J,{value:i.capturedInputVisibility,options:Object.values(B.ProjectSensitiveDataVisibilityLevel),onChange:e=>o(`capturedInputVisibility`,e)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Captured output visibility`}),(0,H.jsx)(J,{value:i.capturedOutputVisibility,options:Object.values(B.ProjectSensitiveDataVisibilityLevel),onChange:e=>o(`capturedOutputVisibility`,e)})]}),(0,H.jsx)(Y,{label:`Trace sharing enabled`,hint:`Allow operators to generate public share links for traces.`,checked:i.traceSharingEnabled,onChange:e=>o(`traceSharingEnabled`,e)}),(0,H.jsx)(q,{children:`Integrations`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`User link template`}),(0,H.jsx)(O,{value:i.userLinkTemplate,onChange:e=>o(`userLinkTemplate`,e.target.value),placeholder:`e.g. https://app.acme.com/users/{{userId}}`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Default model`}),(0,H.jsx)(O,{value:i.defaultModel,onChange:e=>o(`defaultModel`,e.target.value),placeholder:`e.g. openai/gpt-5-mini`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Topic clustering model`}),(0,H.jsx)(O,{value:i.topicClusteringModel,onChange:e=>o(`topicClusteringModel`,e.target.value)})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Embeddings model`}),(0,H.jsx)(O,{value:i.embeddingsModel,onChange:e=>o(`embeddingsModel`,e.target.value)})]}),(0,H.jsx)(q,{children:`Project S3`}),(0,H.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:`Credentials below are write-only — the server never reads them back. Leave blank to keep the stored value; type to replace.`}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Endpoint`}),(0,H.jsx)(O,{type:`url`,value:i.s3Endpoint,onChange:e=>o(`s3Endpoint`,e.target.value),placeholder:`Leave blank to keep current`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Bucket`}),(0,H.jsx)(O,{value:i.s3Bucket,onChange:e=>o(`s3Bucket`,e.target.value),placeholder:`Leave blank to keep current`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Access key ID`}),(0,H.jsx)(O,{type:`password`,value:i.s3AccessKeyId,onChange:e=>o(`s3AccessKeyId`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(D,{children:`Secret access key`}),(0,H.jsx)(O,{type:`password`,value:i.s3SecretAccessKey,onChange:e=>o(`s3SecretAccessKey`,e.target.value),placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,H.jsx)(q,{children:`Lifecycle`}),(0,H.jsx)(Y,{label:`Archived`,hint:`Hides the project from the UI and stops it from accruing limits.`,checked:i.archive,onChange:e=>o(`archive`,e)}),(0,H.jsx)(y,{my:2}),(0,H.jsxs)(j,{align:`start`,gap:0,children:[(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Project ID: `,e.id]}),(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Team: `,e.teamId]}),(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`API key: `,e.apiKey]}),e.archivedAt&&(0,H.jsxs)(w,{fontSize:`xs`,color:`fg.muted`,children:[`Archived at: `,F(e.archivedAt)]})]})]})}),(0,H.jsx)(n.Footer,{children:(0,H.jsxs)(k,{width:`full`,children:[(0,H.jsx)(A,{}),(0,H.jsx)(h,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,H.jsx)(h,{loading:r.isPending,onClick:()=>{if(!e||!i)return;let n={};i.name!==e.name&&(n.name=i.name),i.slug!==e.slug&&(n.slug=i.slug),i.language!==(e.language??``)&&(n.language=i.language),i.framework!==(e.framework??``)&&(n.framework=i.framework),i.firstMessage!==!!e.firstMessage&&(n.firstMessage=i.firstMessage),i.integrated!==!!e.integrated&&(n.integrated=i.integrated),i.userLinkTemplate!==(e.userLinkTemplate??``)&&(n.userLinkTemplate=G(i.userLinkTemplate)),i.piiRedactionLevel!==e.piiRedactionLevel&&(n.piiRedactionLevel=i.piiRedactionLevel),i.capturedInputVisibility!==e.capturedInputVisibility&&(n.capturedInputVisibility=i.capturedInputVisibility),i.capturedOutputVisibility!==e.capturedOutputVisibility&&(n.capturedOutputVisibility=i.capturedOutputVisibility),i.traceSharingEnabled!==!!e.traceSharingEnabled&&(n.traceSharingEnabled=i.traceSharingEnabled),i.defaultModel!==(e.defaultModel??``)&&(n.defaultModel=G(i.defaultModel)),i.topicClusteringModel!==(e.topicClusteringModel??``)&&(n.topicClusteringModel=G(i.topicClusteringModel)),i.embeddingsModel!==(e.embeddingsModel??``)&&(n.embeddingsModel=G(i.embeddingsModel)),i.s3Endpoint.trim()!==``&&(n.s3Endpoint=i.s3Endpoint),i.s3AccessKeyId.trim()!==``&&(n.s3AccessKeyId=i.s3AccessKeyId),i.s3SecretAccessKey.trim()!==``&&(n.s3SecretAccessKey=i.s3SecretAccessKey),i.s3Bucket.trim()!==``&&(n.s3Bucket=i.s3Bucket);let a=!!e.archivedAt;if(i.archive!==a&&(n.archivedAt=i.archive?new Date().toISOString():null),Object.keys(n).length===0){t();return}r.mutate({id:e.id,data:n},{onSuccess:()=>{_.create({title:`Project updated`,type:`success`,duration:3e3,meta:{closable:!0}}),t()},onError:e=>_.create({title:`Update failed`,description:e.message,type:`error`,duration:5e3,meta:{closable:!0}})})},children:`Save`})]})})]})})}function q({children:e}){return(0,H.jsx)(C,{as:`h3`,size:`xs`,color:`fg.muted`,textTransform:`uppercase`,letterSpacing:`wider`,pt:2,children:e})}function J({value:e,options:t,onChange:n}){return(0,H.jsxs)(x,{size:`sm`,width:`full`,children:[(0,H.jsx)(S,{value:e,onChange:e=>n(e.target.value),children:t.map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))}),(0,H.jsx)(b,{})]})}function Y({label:e,hint:t,checked:n,onChange:r}){return(0,H.jsx)(T,{children:(0,H.jsxs)(k,{width:`full`,children:[(0,H.jsxs)(j,{align:`start`,gap:0,children:[(0,H.jsx)(D,{children:e}),t&&(0,H.jsx)(w,{fontSize:`xs`,color:`fg.muted`,children:t})]}),(0,H.jsx)(A,{}),(0,H.jsx)(c,{checked:n,onCheckedChange:e=>r(e.checked)})]})})}function X(){return(0,H.jsx)(z,{children:(0,H.jsx)(W,{})})}export{X as default};
2
+ //# sourceMappingURL=projects-CjWZFLfn.js.map
@@ -1,8 +1,8 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$r as n,$s as r,An as i,Bi as a,Di as o,Dn as s,Ei as c,Fn as l,Hr as u,In as d,Li as f,Ln as p,Lt as m,Mn as h,Nn as g,Oi as _,On as v,Pn as y,Qs as b,Rt as x,Si as S,Vi as C,Xr as w,Xs as T,Yo as ee,Ys as te,Zs as E,ai as D,bi as ne,ci as re,d as ie,fo as ae,ii as oe,jn as se,ki as O,lt as ce,mi as le,mn as k,ms as ue,mt as de,oi as fe,os as pe,pt as me,qi as A,si as he,st as j,wi as ge,xi as _e,zt as ve}from"./command-bar-CaJygoez.js";import{j as ye,n as M,r as be}from"./stack-oJ9iWdbl.js";import{t as N}from"./box-BsM8YLGl.js";import{f as xe,h as Se}from"./LoadingScreen--vgXk5-2.js";import{i as Ce,o as we,r as Te,t as Ee}from"./tabs-DwV1cIZB.js";import{t as P}from"./tooltip-AEm0YeiF.js";import{n as F}from"./toaster-C_DYALhL.js";import{f as I}from"./dist-SwV3YZv3.js";import{s as De}from"./terminal-CfM0q99k.js";import{t as L}from"./text-CwTrMF8x.js";import{i as R}from"./code-FF_ibTVI.js";import{t as Oe}from"./icon-BwEPrfAc.js";import{t as z}from"./h-stack-BKLDJ2vg.js";import{A as ke,Et as Ae,O as je,P as Me,R as Ne,ft as Pe,jt as Fe,p as Ie,ut as Le,v as Re,yt as ze}from"./lu-Bf6j_N19.js";import{t as Be}from"./spacer-2LJJGbo8.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{c as Ve,m as V,s as H}from"./auth-client-D3UhxhQi.js";import{r as He}from"./next-router-C6sliiV7.js";import{t as U}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as Ue}from"./WithPermissionGuard-DD8uo3UK.js";import{t as We}from"./persistence-CTQ44vGL.js";import{t as Ge}from"./humanReadableId-BiX-kWLL.js";var W=e(t()),Ke=`Welcome to the LangWatch Prompt Playground
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$r as n,$s as r,An as i,Bi as a,Di as o,Dn as s,Ei as c,Fn as l,Hr as u,In as d,Li as f,Ln as p,Lt as m,Mn as h,Nn as g,Oi as _,On as v,Pn as y,Qs as b,Rt as x,Si as S,Vi as C,Xr as w,Xs as T,Yo as ee,Ys as te,Zs as E,ai as D,bi as ne,ci as re,d as ie,fo as ae,ii as oe,jn as se,ki as O,lt as ce,mi as le,mn as k,ms as ue,mt as de,oi as fe,os as pe,pt as me,qi as A,si as he,st as j,wi as ge,xi as _e,zt as ve}from"./command-bar-DUK45yin.js";import{j as ye,n as M,r as be}from"./stack-oJ9iWdbl.js";import{t as N}from"./box-BsM8YLGl.js";import{f as xe,h as Se}from"./LoadingScreen--vgXk5-2.js";import{i as Ce,o as we,r as Te,t as Ee}from"./tabs-DwV1cIZB.js";import{t as P}from"./tooltip-AEm0YeiF.js";import{n as F}from"./toaster-C_DYALhL.js";import{f as I}from"./dist-Cds4Mqhj.js";import{s as De}from"./terminal-CfM0q99k.js";import{t as L}from"./text-CwTrMF8x.js";import{i as R}from"./code-FF_ibTVI.js";import{t as Oe}from"./icon-BwEPrfAc.js";import{t as z}from"./h-stack-BKLDJ2vg.js";import{A as ke,Et as Ae,O as je,P as Me,R as Ne,ft as Pe,jt as Fe,p as Ie,ut as Le,v as Re,yt as ze}from"./lu-Bf6j_N19.js";import{t as Be}from"./spacer-2LJJGbo8.js";import{t as B}from"./v-stack-EOPQ57OZ.js";import{c as Ve,m as V,s as H}from"./auth-client-D3UhxhQi.js";import{r as He}from"./next-router-C6sliiV7.js";import{t as U}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as Ue}from"./WithPermissionGuard-B4Jo8E5-.js";import{t as We}from"./persistence-BPvHS0F6.js";import{t as Ge}from"./humanReadableId-BiX-kWLL.js";var W=e(t()),Ke=`Welcome to the LangWatch Prompt Playground
2
2
 
3
3
  Edit this template to get started
4
4
 
5
5
  Add variables via double brackets like this: {{input}}
6
6
 
7
7
  `;function G(){let{project:e}=U(),{modelMetadata:t}=_e({projectId:e?.id}),{addTab:n}=_(({addTab:e})=>({addTab:e}));return{createDraftPrompt:(0,W.useCallback)(async()=>{let r=e?.defaultModel??`openai/gpt-5.2`,i=t?.[r],o=a({version:{configData:{llm:{model:r,maxTokens:le(i)},messages:[{content:Ke}]}}});return n({data:{chat:{initialMessagesFromSpanData:[]},form:{currentValues:o},meta:{title:o.handle},variableValues:{}}}),setTimeout(()=>{document.querySelector(`textarea[data-role="system"]`)?.focus()},100),{defaultValues:o}},[n,t,e?.defaultModel])}}var K=ye();function q({iconOnly:e}){let{createDraftPrompt:t}=G(),{checkAndProceed:n}=ae(`prompts`),{hasPermission:r}=U(),i=Ve(e=>e.openLiteMemberRestriction);return(0,K.jsx)(P,{content:`New Prompt`,disabled:!e,children:(0,K.jsxs)(w.HeaderButton,{onClick:()=>{if(!r(`prompts:create`)){i({resource:`prompts`});return}n(()=>{t()})},children:[(0,K.jsx)(Pe,{size:14}),!e&&`New Prompt`]})})}var qe=e=>{let t=e.form.currentValues.version?.configData;if(!t)return;let n=t.llm,r=t.messages??[],i=t.inputs??[],a=t.outputs??[],o=n?.litellmParams?Object.fromEntries(Object.entries(n.litellmParams).filter(e=>e[1]!==void 0)):void 0;return{llm:{model:n?.model??`openai/gpt-4o`,temperature:n?.temperature??void 0,maxTokens:n?.maxTokens??void 0,litellmParams:o},messages:r.filter(e=>e!==void 0).map(e=>({role:e.role,content:e.content??``})),inputs:i.filter(e=>e!==void 0).map(e=>({identifier:e.identifier??`input`,type:e.type??`str`})),outputs:a.filter(e=>e!==void 0).map(e=>({identifier:e.identifier??`output`,type:e.type??`str`,json_schema:e.json_schema??void 0}))}},Je=(e,t)=>{let n=e.form.currentValues.configId,r=e.form.currentValues;return!n||!r.handle||!t?!0:r?!fe(D({prompt:t,useSystemMessage:!0}),r):!1},Ye=(e,t,n,r)=>{let i=e.form.currentValues.configId,a=e.form.currentValues.versionMetadata?.versionId,o=e.form.currentValues.version?.configData,s=(o?.inputs??[]).filter(e=>e!==void 0).map(e=>({identifier:e.identifier??`input`,type:e.type??`str`})),c=(o?.outputs??[]).filter(e=>e!==void 0).map(e=>({identifier:e.identifier??`output`,type:e.type??`str`})),l=Je(e,r),u={id:`target_${Date.now()}_${t}`,type:`prompt`,promptId:i??void 0,promptVersionId:a??void 0,promptVersionNumber:i?e.meta.versionNumber:void 0,localPromptConfig:l?qe(e):void 0,inputs:s,outputs:c,mappings:{}},d=me(u,n);return{...u,mappings:d}};function Xe({iconOnly:e}){let{project:t,hasPermission:n}=U(),r=He(),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1),c=H.useContext(),{isComparing:l,allTabs:u,activeTab:d}=_(e=>{let t=e.windows.find(t=>t.id===e.activeWindowId);return{isComparing:e.windows.length>1,allTabs:e.windows.flatMap(e=>e.tabs),activeTab:t?.tabs.find(e=>e.id===t?.activeTabId)}}),f=u.length,p=f===0||!n(`evaluations:manage`),m=(0,W.useMemo)(()=>u.map(e=>e.data.form.currentValues.configId).filter(e=>!!e),[u]),h=H.useQueries(e=>m.map(n=>{let r=u.find(e=>e.data.form.currentValues.configId===n)?.data.form.currentValues.versionMetadata?.versionId;return e.prompts.getByIdOrHandle({idOrHandle:n,projectId:t?.id??``,versionId:r},{enabled:!!t?.id&&i,staleTime:6e4})})),g=h.some(e=>e.isLoading),v=(0,W.useMemo)(()=>{let e=new Map;return m.forEach((t,n)=>{let r=h[n];r?.isLoading||e.set(t,r?.data??null)}),e},[m,h]),y=H.experiments.saveEvaluationsV3.useMutation({onSuccess:e=>{c.experiments.getAllForEvaluationsList.invalidate(),r.push(`/${t?.slug}/experiments/workbench/${e.slug}`),s(!1),a(!1)},onError:()=>{s(!1)}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{content:`Experiment`,disabled:!e,children:(0,K.jsxs)(w.HeaderButton,{onClick:()=>a(!0),disabled:p,title:p?`Open a prompt to create an experiment`:void 0,children:[(0,K.jsx)(De,{size:`18px`}),!e&&`Experiment`]})}),(0,K.jsx)(I.Root,{open:i,onOpenChange:({open:e})=>a(e),children:(0,K.jsxs)(I.Content,{children:[(0,K.jsx)(I.Header,{children:(0,K.jsx)(I.Title,{children:`Create Experiment`})}),(0,K.jsx)(I.Body,{children:(0,K.jsx)(L,{children:!l||f===1?`Create new experiment with this prompt?`:`Create new experiment with these prompts? (${f} prompts)`})}),(0,K.jsxs)(I.Footer,{children:[(0,K.jsx)(M,{variant:`ghost`,onClick:()=>a(!1),disabled:o,children:`Cancel`}),(0,K.jsxs)(M,{colorPalette:`blue`,onClick:()=>{if(!t?.id||o||g)return;s(!0);let e=Ge(),n=de();n.name=e,n.targets=(l||!d?u:[d]).map((e,t)=>{let r=e.data.form.currentValues.configId,i=r?v.get(r):null;return Ye(e.data,t,n.datasets,i)});let r=We(n);y.mutate({projectId:t.id,experimentId:void 0,state:{...r,experimentSlug:e}})},disabled:o||g,children:[(o||g)&&(0,K.jsx)(be,{size:`sm`,marginRight:2}),g?`Loading...`:`Create`]})]}),(0,K.jsx)(I.CloseTrigger,{})]})})]})}function Ze(e,t){let n=n=>{let r=t(n);return(0,K.jsx)(e,{...n,...r})};return n.displayName=`withController(${e.displayName??e.name??`Component`})`,n}function Qe(){let e=o(),t=oe(e),n=_(t=>t.windows.flatMap(e=>e.tabs).find(t=>t.id===e)),r=_(e=>e.removeTab),i=_(e=>e.updateTabData),a=!n?.data.form.currentValues?.configId,s=n?.data.form.currentValues?.configId,c=n?.data.meta.versionNumber,{latestVersion:l,isOutdated:u}=S({configId:s,currentVersion:c}),d=_(e=>{if(!s)return!1;let t=e.windows.flatMap(e=>e.tabs).filter(e=>e.data.form.currentValues?.configId===s);return t.length<=1?!1:new Set(t.map(e=>e.data.meta.versionNumber)).size>1}),p=u||d,{getPromptById:m}=O();return{tab:n,hasUnsavedChanges:t,handleClose:n=>{n.stopPropagation(),!((t||a)&&!confirm(`Your unsaved changes will be lost. Proceed anyway?`))&&r({tabId:e})},latestVersion:l,isOutdated:u,handleUpgrade:(0,W.useCallback)(async()=>{if(s)try{let t=await m({id:s});if(!t)throw Error(`Prompt not found`);let n=f(t);i({tabId:e,updater:e=>({...e,form:{currentValues:n},meta:{...e.meta,versionNumber:t.version}})})}catch(e){console.error(`Failed to load latest prompt version:`,e)}},[s,m,e,i]),showVersionBadge:p}}function $e({tab:e,hasUnsavedChanges:t,dimmed:n,handleClose:r,latestVersion:i,isOutdated:a,handleUpgrade:o,showVersionBadge:s,...c}){if(!e)return null;let l=e.data.meta;return(0,K.jsxs)(z,{gap:2,height:`full`,...c,children:[(0,K.jsxs)(z,{children:[(0,K.jsx)(L,{textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:l.title??`New Prompt`}),t&&(0,K.jsx)(N,{children:(0,K.jsx)(Se,{size:`10px`,bg:`orange.solid`})}),s&&l.versionNumber!=null&&(0,K.jsx)(ce,{version:l.versionNumber,latestVersion:i,onUpgrade:a?o:void 0})]}),(0,K.jsx)(N,{role:`button`,borderRadius:`3px`,transition:`all 0.1s ease-in-out`,opacity:n?.25:1,_hover:{opacity:1},onPointerDown:e=>{e.stopPropagation()},onClick:r,marginRight:-1,children:(0,K.jsx)(Fe,{width:`18px`})})]})}var J=Ze($e,Qe),et=W.createContext(null),Y=W.createContext(null);function tt(){let e=W.useContext(Y);if(!e)throw Error(`Tab components must be used within DraggableTabsBrowser.Group`);return e}function nt({children:e,onTabMove:t}){let[n,r]=W.useState(null),i=d(l(g,{activationConstraint:{distance:8}}));function a(e){let{groupId:t,tabId:n,label:i}=e.active.data.current;r({groupId:t,tabId:n,label:i})}function o(e){r(null);let{active:n,over:i}=e;if(!i)return;let a=n.data.current,o=i.data.current;if(!a||!o)return;let s=a.sortable?.index,c=o.sortable?.index;t({tabId:a.tabId,from:{groupId:a.groupId,index:s},to:{groupId:o.groupId,index:c}})}let s={onTabMove:t,activeDrag:n,setActiveDrag:r};return(0,K.jsx)(et.Provider,{value:s,children:(0,K.jsx)(se,{sensors:i,onDragStart:a,onDragEnd:o,collisionDetection:y,children:(0,K.jsxs)(z,{width:`full`,gap:2,padding:2,height:`full`,children:[e,(0,K.jsx)(h,{children:n?(0,K.jsx)(rt,{activeDrag:n}):null})]})})})}function rt({activeDrag:e}){return(0,K.jsx)(`div`,{style:{background:`var(--chakra-colors-bg-panel)`,padding:8,border:`1px solid var(--chakra-colors-border)`,borderRadius:6,boxShadow:`0 2px 8px rgba(0,0,0,0.15)`,pointerEvents:`none`},children:e.label??`Dragging tab...`})}function it({children:e,groupId:t,activeTabId:n,onTabChange:r,onClick:i,...a}){let o={groupId:t,activeTabId:n,onTabChange:r};return(0,K.jsx)(Y.Provider,{value:o,children:(0,K.jsx)(B,{height:`full`,gap:0,align:`stretch`,width:`full`,children:(0,K.jsx)(Ce,{value:n,onValueChange:e=>r?.(t,e.value),onClick:()=>i?.(t,n??``),width:`full`,height:`full`,display:`flex`,flexDirection:`column`,variant:`enclosed`,...a,children:e})})})}function at({children:e,tabIds:t,...n}){return(0,K.jsx)(z,{gap:0,width:`full`,...n,children:(0,K.jsx)(s,{items:t??[],strategy:v,children:(0,K.jsx)(Te,{width:`full`,gap:0,height:`full`,paddingY:0,background:`none`,children:e})})})}function ot({value:e,children:t}){return(0,K.jsx)(we,{value:e,minWidth:`fit-content`,cursor:`pointer`,transition:`all 0.15s ease-in-out`,children:t})}function st({id:e,children:t,...n}){let{groupId:r}=tt(),{attributes:a,listeners:o,setNodeRef:s,transform:l,transition:u,isDragging:d,isOver:f}=i({id:e,data:{groupId:r,tabId:e,label:(0,K.jsx)(c,{tabId:e,children:(0,K.jsx)(J,{dimmed:!1})})}});return(0,K.jsx)(N,{...n,ref:s,flex:1,alignItems:`stretch`,cursor:d?`grabbing`:`grab`,transform:p.Transform.toString(l),transition:u,opacity:d||f?.5:1,...a,...o,children:t})}var X={Root:nt,Group:it,TabBar:at,Trigger:ot,Tab:st,Content:Ee};function ct(){let{windows:e,splitTab:t,moveTab:n,setActiveTab:r,activeWindowId:i,setActiveWindow:a}=_(({windows:e,splitTab:t,moveTab:n,setActiveTab:r,activeWindowId:i,setActiveWindow:a})=>({windows:e,splitTab:t,moveTab:n,setActiveTab:r,activeWindowId:i,setActiveWindow:a}));function o(e){n({tabId:e.tabId,windowId:e.to.groupId,index:e.to.index})}function s(e,t){r({windowId:e,tabId:t})}function l(e){t({tabId:e})}return(0,K.jsx)(X.Root,{onTabMove:o,children:e.map(t=>(0,K.jsxs)(X.Group,{groupId:t.id,activeTabId:t.activeTabId??void 0,onTabChange:s,onClick:()=>a({windowId:t.id}),maxWidth:e.length>1?`calc((100vw - 340px) / ${e.length})`:`auto`,paddingTop:0,children:[(0,K.jsxs)(X.TabBar,{tabIds:t.tabs.map(e=>e.id),children:[(0,K.jsx)(z,{gap:0,overflow:`auto`,height:`full`,paddingY:2,paddingX:2,children:t.tabs.map(e=>(0,K.jsx)(c,{tabId:e.id,children:(0,K.jsx)(X.Tab,{id:e.id,height:`full`,children:(0,K.jsx)(X.Trigger,{value:e.id,children:(0,K.jsx)(J,{dimmed:t.id!==i})})})},e.id))}),(0,K.jsx)(Be,{}),t.id===i&&(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(z,{flexShrink:0,paddingLeft:1,position:`relative`,_before:{content:`""`,position:`absolute`,left:`-10px`,top:0,bottom:0,width:`10px`,height:`50px`,background:`linear-gradient(to right, transparent, var(--chakra-colors-bg-panel))`,zIndex:10,pointerEvents:`none`},children:[(0,K.jsx)(Xe,{iconOnly:e.length>1}),(0,K.jsx)(P,{content:`Compare`,disabled:e.length<=1,children:(0,K.jsxs)(w.HeaderButton,{onClick:()=>t.activeTabId&&l(t.activeTabId),disabled:!t.activeTabId,title:`Split tab to compare prompts side by side`,children:[(0,K.jsx)(ke,{size:`18px`}),e.length<=1&&`Compare`]})}),(0,K.jsx)(q,{iconOnly:e.length>1})]})})]}),t.tabs.map(e=>(0,K.jsx)(c,{tabId:e.id,children:(0,K.jsx)(X.Content,{value:e.id,height:`full`,borderRadius:`lg`,boxShadow:`md`,background:`bg.panel`,padding:0,minHeight:`0`,children:(0,K.jsx)(u,{})})},e.id))]},t.id))})}function lt(){let{createDraftPrompt:e}=G();return(0,K.jsx)(R,{width:`full`,height:`full`,bg:`bg.panel`,children:(0,K.jsx)(b,{children:(0,K.jsxs)(te,{children:[(0,K.jsx)(E,{children:(0,K.jsx)(ze,{})}),(0,K.jsx)(r,{children:`Create Your First Prompt`}),(0,K.jsx)(T,{children:`Get started on the prompt playground to design, test, and optimize your AI prompts in one place.`}),(0,K.jsx)(M,{colorPalette:`orange`,variant:`solid`,onClick:()=>void e(),children:`Create First Prompt`})]})})})}function ut(){return(0,K.jsxs)(B,{width:`full`,height:`full`,children:[(0,K.jsxs)(z,{width:`full`,paddingTop:`18px`,paddingRight:`12px`,children:[(0,K.jsx)(Be,{}),(0,K.jsx)(q,{})]}),(0,K.jsx)(R,{width:`full`,height:`full`,bg:`bg.panel`,children:(0,K.jsx)(b,{children:(0,K.jsxs)(te,{children:[(0,K.jsx)(E,{children:(0,K.jsx)(Ne,{})}),(0,K.jsx)(r,{children:`No prompts open`}),(0,K.jsx)(T,{children:`Create a new prompt or select an existing prompt to get started.`})]})})})]})}function dt(){let{data:e}=j();return e?.filter(e=>e.version>0)?.length===0?(0,K.jsx)(lt,{}):(0,K.jsx)(ut,{})}function ft(){return ie(),_(({windows:e})=>e.length===0||e.every(e=>e.tabs.length===0))?(0,K.jsx)(dt,{}):(0,K.jsx)(z,{width:`full`,height:`full`,gap:0,overflowX:`scroll`,children:(0,K.jsx)(ct,{})})}function pt(){return(0,K.jsx)(P,{content:`This prompt is available to all projects in the organization`,children:(0,K.jsx)(Oe,{color:`purple`,children:(0,K.jsx)(Ie,{})})})}var mt=({open:e,onClose:t,onSuccess:n,promptId:r,promptName:i})=>{let{project:a}=U(),o=H.prompts.copy.useMutation(),s=x(`prompts:create`);return a?(0,K.jsx)(ve,{open:e,onClose:t,onSuccess:n,title:`Replicate Prompt`,entityLabel:`Prompt`,sourceName:i,sourceId:r,sourceProjectId:a.id,projects:s,onCopy:async({projectId:e,sourceProjectId:t})=>{await o.mutateAsync({idOrHandle:r,projectId:e,sourceProjectId:t})},isLoading:o.isLoading}):null},ht=({open:e,onClose:t,promptId:n,promptName:r})=>{let{project:i}=U(),a=H.prompts.pushToCopies.useMutation(),o=H.useContext(),[s,c]=(0,W.useState)(new Set),{data:l,isLoading:u,error:d}=H.prompts.getCopies.useQuery({projectId:i?.id??``,idOrHandle:n},{enabled:e&&!!i?.id&&!!n}),[f,p]=(0,W.useState)([]);return(0,W.useEffect)(()=>{l&&(p(l),c(new Set(l.map(e=>e.id))))},[l]),(0,K.jsx)(m,{open:e,onClose:t,entityLabel:`Prompt`,sourceName:r,copies:f,isLoading:u,error:d?{message:d.message}:null,selectedCopyIds:s,onToggleCopy:e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),c(t)},onPush:async()=>{let e=await a.mutateAsync({idOrHandle:n,projectId:i.id,copyIds:Array.from(s)});return await o.prompts.getAllPromptsForProject.invalidate(),e},pushLoading:a.isLoading,bodyIntro:`Select which replicas to push the latest version to:`,onSuccess:()=>c(new Set)})},gt=({promptId:e,onSuccess:t})=>{let{triggerChangeHandle:n}=re(),{project:r}=U(),i=H.useContext(),{data:a}=H.prompts.checkModifyPermission.useQuery({idOrHandle:e,projectId:r?.id??``},{enabled:!!e&&!!r?.id}),o=a?.hasPermission??!1;return{renameHandle:(0,W.useCallback)(()=>{if(!e){F.create({title:`Error changing prompt handle`,description:`Prompt ID is required`,type:`error`});return}n({id:e,onSuccess:e=>{i.prompts.getAllPromptsForProject.invalidate(),F.create({title:`Prompt handle changed`,description:`Prompt handle has been changed to ${e.handle}`,type:`success`}),t?.(e)},onError:e=>{console.error(e),F.create({title:`Error changing prompt handle`,description:e.message,type:`error`})}})},[e,n,i,t]),canRename:o,permissionReason:a?.reason}};function _t({promptId:e,promptHandle:t,prompt:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),{deletePrompt:l}=O(),{project:u,hasPermission:d}=U(),{addTab:f}=_(({addTab:e})=>({addTab:e})),{renameHandle:p,canRename:m,permissionReason:h}=gt({promptId:e}),g=H.prompts.syncFromSource.useMutation(),v=H.useContext(),y=!!n?.copiedFromPromptId,b=(n?._count?.copiedPrompts??0)>0,x=(0,W.useCallback)(async()=>{if(u)try{await g.mutateAsync({idOrHandle:e,projectId:u.id}),await v.prompts.getAllPromptsForProject.invalidate(),F.create({title:`Prompt updated`,description:`Prompt "${$(t)}" has been updated from source.`,type:`success`,meta:{closable:!0}})}catch(e){if(V(e))return;F.create({title:`Error updating prompt`,description:e instanceof Error?e.message:`Please try again later.`,type:`error`,meta:{closable:!0}})}},[g,u,v,e,t]),{data:S}=H.prompts.checkModifyPermission.useQuery({idOrHandle:e,projectId:u?.id??``},{enabled:!!u?.id}),C=S?.hasPermission??!0,w=(0,W.useCallback)(async()=>{if(u?.id)try{await l({projectId:u.id,idOrHandle:e}),F.create({title:`Prompt deleted`,description:`"${$(t)}" has been deleted`,type:`success`})}catch(e){if(V(e))return;F.create({title:`Failed to delete prompt`,description:e instanceof Error?e.message:`An unknown error occurred`,type:`error`})}finally{i(!1)}},[e,t,u?.id,l]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{onClick:e=>e.stopPropagation(),opacity:0,_groupHover:{opacity:1},transition:`opacity 0.2s`,children:(0,K.jsxs)(A.Root,{children:[(0,K.jsx)(A.Trigger,{asChild:!0,children:(0,K.jsx)(M,{variant:`ghost`,size:`xs`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(Me,{size:14})})}),(0,K.jsxs)(A.Content,{onClick:e=>e.stopPropagation(),children:[y&&(0,K.jsxs)(A.Item,{value:`sync`,onClick:()=>void x(),children:[(0,K.jsx)(ee,{size:16}),` Update from source`]}),b&&(0,K.jsxs)(A.Item,{value:`push`,onClick:()=>c(!0),children:[(0,K.jsx)(ue,{size:16}),` Push to replicas`]}),(0,K.jsxs)(A.Item,{value:`copy`,onClick:()=>o(!0),children:[(0,K.jsx)(pe,{size:16}),` Replicate to another project`]}),(0,K.jsxs)(A.Item,{value:`view-history`,onClick:()=>{if(!n)return;let e=u?.defaultModel,t=D({prompt:n,defaultModel:typeof e==`string`?e:void 0,useSystemMessage:!0});f({data:{chat:{initialMessagesFromSpanData:[]},form:{currentValues:t},meta:{title:t.handle??null,versionNumber:t.versionMetadata?.versionNumber,openHistoryOnLoad:!0},variableValues:{}}})},children:[(0,K.jsx)(je,{size:16}),` View history`]}),(0,K.jsx)(P,{content:h,disabled:m,positioning:{placement:`right`},showArrow:!0,children:(0,K.jsxs)(A.Item,{value:`rename`,onClick:m?p:void 0,disabled:!m,opacity:m?1:.5,cursor:m?`pointer`:`not-allowed`,children:[(0,K.jsx)(Le,{size:16}),(0,K.jsx)(L,{as:`span`,children:`Rename handle`})]})}),(0,K.jsx)(P,{content:S?.reason,disabled:C,positioning:{placement:`right`},showArrow:!0,children:(0,K.jsxs)(A.Item,{value:`delete`,onClick:()=>C&&i(!0),disabled:!C,opacity:C?1:.5,cursor:C?`pointer`:`not-allowed`,children:[(0,K.jsx)(Ae,{size:16}),(0,K.jsx)(L,{as:`span`,children:`Delete prompt`})]})})]})]})}),(0,K.jsx)(ge,{title:`Are you really sure?`,description:`There is no going back, and you will lose all versions of this prompt. If you're sure you want to delete this prompt, type 'delete' below:`,open:r,onClose:()=>i(!1),onConfirm:()=>void w()}),(0,K.jsx)(mt,{open:a,onClose:()=>o(!1),onSuccess:()=>void v.prompts.getAllPromptsForProject.invalidate(),promptId:e,promptName:$(t)}),(0,K.jsx)(ht,{open:s,onClose:()=>c(!1),promptId:e,promptName:$(t)})]})}function vt({promptId:e,promptHandle:t,prompt:n}){return(0,K.jsxs)(z,{justify:`space-between`,width:`full`,className:`group`,children:[n?.scope===`ORGANIZATION`&&(0,K.jsx)(N,{marginLeft:`-12px`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(L,{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`sm`,fontWeight:`normal`,flex:1,children:$(t)}),(0,K.jsx)(_t,{promptId:e,promptHandle:t,prompt:n})]})}function yt({children:e,...t}){return(0,K.jsx)(N,{as:`nav`,width:`full`,height:`100%`,overflowY:`auto`,paddingBottom:`2`,...t,children:(0,K.jsx)(B,{gap:0,align:`stretch`,children:e})})}function bt({children:e}){return(0,K.jsx)(N,{padding:`4`,fontSize:`lg`,fontWeight:`semibold`,children:e})}function Z({children:e,...t}){return(0,K.jsx)(N,{paddingX:`3`,paddingY:`2`,fontSize:`sm`,fontWeight:`medium`,color:`fg`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,...t,children:e})}function xt({children:e}){return(0,K.jsx)(N,{children:e})}function St({children:e,title:t,collapsible:n=!1,defaultOpen:r=!1,action:i}){let[a,o]=(0,W.useState)(r);return t?(0,K.jsxs)(B,{gap:0,align:`stretch`,children:[(0,K.jsxs)(Z,{onClick:()=>o(!a),cursor:`pointer`,children:[(0,K.jsxs)(z,{gap:2,children:[n&&(0,K.jsx)(N,{transform:a?`rotate(0deg)`:`rotate(-90deg)`,transition:`transform 0.2s`,children:(0,K.jsx)(Re,{size:14})}),(0,K.jsx)(L,{children:t})]}),i&&(0,K.jsx)(N,{onClick:e=>e.stopPropagation(),children:i})]}),(!n||a)&&(0,K.jsx)(B,{gap:0,align:`stretch`,paddingX:4,children:e})]}):(0,K.jsx)(B,{gap:.5,align:`stretch`,paddingX:2,children:e})}function Ct({children:e,onClick:t,active:n=!1,icon:r,meta:i,variant:a=`default`,...o}){return a===`empty`?(0,K.jsx)(N,{padding:`3`,fontSize:`sm`,color:`fg.muted`,textAlign:`center`,children:e}):(0,K.jsxs)(N,{fontSize:`sm`,color:n?`blue.fg`:`fg`,bg:n?`blue.subtle`:`transparent`,borderRadius:`md`,cursor:`pointer`,_hover:{bg:n?`blue.muted`:`bg.muted`},onClick:t,display:`flex`,alignItems:`center`,gap:2,width:`full`,...o,children:[r&&(0,K.jsx)(N,{width:`16px`,borderRadius:`full`,bg:`bg.muted`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,children:r}),(0,K.jsxs)(N,{flex:1,minWidth:0,children:[e,i&&(0,K.jsx)(L,{fontSize:`xs`,color:`fg.muted`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,children:i})]})]})}var Q={Root:yt,Header:bt,SectionHeader:Z,List:St,Item:Ct,Section:xt};function wt(){return(0,K.jsx)(L,{fontSize:`sm`,color:`fg.muted`,textAlign:`center`,paddingY:6,paddingX:4,children:`No prompts yet`})}function $(e){return e?e?.includes(`/`)?e.split(`/`)[1]:e:`New Prompt`}function Tt(){let{data:e,isLoading:t}=j(),{addTab:n}=_(({addTab:e})=>({addTab:e})),{project:r}=U(),i=(0,W.useMemo)(()=>{let t=e?.filter(e=>e.version>0),n=C(t,e=>e.handle?.includes(`/`)?e.handle?.split(`/`)[0]:`default`);return Object.entries(n).sort((e,t)=>e[0]===`default`?1:t[0]===`default`?-1:0)},[e]),a=e?.filter(e=>e.version>0);return t?(0,K.jsx)(Q.List,{children:[1,2,3,4].map(e=>(0,K.jsx)(Q.Item,{paddingY:1,paddingLeft:2,children:(0,K.jsx)(xe,{width:`full`,height:`20px`,borderRadius:`sm`})},e))}):a?.length===0?(0,K.jsx)(wt,{}):(0,K.jsx)(K.Fragment,{children:i.map(([e,t])=>(0,K.jsx)(Q.List,{title:e===`default`?void 0:e,collapsible:e!==`default`,defaultOpen:!1,children:t.map(e=>(0,K.jsx)(Q.Item,{icon:ne[e.model?.split(`/`)[0]],onClick:()=>{let t=r?.defaultModel,i=D({prompt:e,defaultModel:typeof t==`string`?t:void 0,useSystemMessage:!0});n({data:{chat:{initialMessagesFromSpanData:[]},form:{currentValues:i},meta:{title:i.handle??null,versionNumber:i.versionMetadata?.versionNumber},variableValues:{}}})},paddingY:1,paddingLeft:2,children:(0,K.jsx)(vt,{promptId:e.id,promptHandle:e.handle,prompt:e})},e.id))},e))})}function Et(){return(0,K.jsx)(Q.Root,{children:(0,K.jsx)(Q.Section,{children:(0,K.jsx)(Tt,{})})})}function Dt(){return(0,K.jsx)(k,{position:`relative`,compactMenu:!0,children:(0,K.jsx)(he,{children:(0,K.jsx)(n,{children:(0,K.jsxs)(z,{width:`full`,height:`full`,gap:0,position:`relative`,children:[(0,K.jsxs)(B,{position:`relative`,top:0,left:0,width:`250px`,height:`full`,children:[(0,K.jsx)(w.Header,{withBorder:!1,children:(0,K.jsx)(w.Heading,{children:`Prompts`})}),(0,K.jsx)(Et,{})]}),(0,K.jsx)(ft,{})]})})})})}function Ot(){return(0,K.jsx)(Dt,{})}var kt=Ue(`prompts:view`,{layoutComponent:k})(Ot);export{kt as default};
8
- //# sourceMappingURL=prompts-DhXnJT6e.js.map
8
+ //# sourceMappingURL=prompts-DilmFH_s.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as n,Do as r,Fa as i,Ia as a,Qs as o,Ra as s,Ss as c,Xa as l,Xr as u,Xs as d,Ys as f,Zs as p,_s as m,bi as h,bs as g,mn as _,na as v,qi as y,rn as b,sc as x,vs as S,xs as C,ys as w}from"./command-bar-CaJygoez.js";import{j as T,n as E,r as D}from"./stack-oJ9iWdbl.js";import{t as O}from"./box-BsM8YLGl.js";import{t as k}from"./tooltip-AEm0YeiF.js";import{n as A}from"./toaster-C_DYALhL.js";import{an as j}from"./dist-SwV3YZv3.js";import{t as M}from"./text-CwTrMF8x.js";import{a as N,n as P,r as F}from"./field-CnUiixMS.js";import{t as I}from"./input-C7emsUCL.js";import{t as L}from"./h-stack-BKLDJ2vg.js";import{r as R,t as z}from"./card-CMtKVPVl.js";import{t as B}from"./link-CwZhwOLq.js";import{t as V}from"./spacer-2LJJGbo8.js";import{t as H}from"./v-stack-EOPQ57OZ.js";import{s as U}from"./auth-client-D3UhxhQi.js";import{t as W}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as G}from"./createLucideIcon-BJKFyRLS.js";import{t as K}from"./WithPermissionGuard-DD8uo3UK.js";import{n as q,t as J}from"./ConfirmDialog-CXIhncvW.js";import{t as Y}from"./GatewayErrorPanel-DvE9U2dS.js";import{t as X}from"./GatewayLayout-lv1p_6B5.js";var ee=G(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Z=e(t()),Q=T();function te({projectId:e,open:t,onOpenChange:n,onCreated:i}){let{project:a}=W(),o=`/settings/model-providers`,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`primary`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),h=U.useContext(),g=U.modelProvider.getAllForProject.useQuery({projectId:e},{enabled:t&&!!e}),_=U.gatewayProviders.list.useQuery({projectId:e},{enabled:t&&!!e}),y=U.gatewayProviders.create.useMutation({onSuccess:async()=>{await h.gatewayProviders.list.invalidate({projectId:e})}}),S=()=>{c(``),u(`primary`),f(``),m(``)},C=()=>{y.isPending||(S(),n(!1))},w=async()=>{if(!s){A.create({title:`Select a model provider`,type:`error`});return}try{await y.mutateAsync({projectId:e,modelProviderId:s,slot:l||void 0,rateLimitRpm:d?Number.parseInt(d,10):null,rateLimitTpm:p?Number.parseInt(p,10):null}),i(),S(),n(!1)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to bind provider`,type:`error`})}},T=g.data??{},O=Object.values(T).filter(e=>e?.enabled&&e?.id),k=new Set((_.data??[]).map(e=>e.modelProviderId)),j=O.filter(e=>!k.has(e.id)),R=(0,Z.useMemo)(()=>x({items:j.map(e=>({value:e.id,label:e.provider}))}),[j]),z=j.find(e=>e.id===s),G=z?.scopes?.some(e=>e.scopeType===`ORGANIZATION`||e.scopeType===`TEAM`)||z?.scopeType===`ORGANIZATION`||z?.scopeType===`TEAM`;return(0,Q.jsx)(r.Root,{open:t,onOpenChange:()=>C(),placement:`end`,size:`md`,children:(0,Q.jsxs)(r.Content,{children:[(0,Q.jsxs)(r.Header,{children:[(0,Q.jsx)(r.Title,{children:`Bind provider to gateway`}),(0,Q.jsx)(r.CloseTrigger,{})]}),(0,Q.jsx)(r.Body,{children:(0,Q.jsxs)(H,{align:`stretch`,gap:4,children:[(0,Q.jsxs)(N,{required:!0,children:[(0,Q.jsxs)(F,{children:[`Model provider`,(0,Q.jsx)(q,{description:`The LLM provider whose API key the gateway routes traffic to. Providers are configured once in Settings → Model Providers and reused here.`,docHref:`/ai-gateway/provider-bindings#model-provider`})]}),g.isLoading?(0,Q.jsx)(D,{size:`sm`}):j.length===0?(0,Q.jsxs)(H,{align:`stretch`,gap:2,children:[(0,Q.jsx)(M,{fontSize:`sm`,color:`fg.muted`,children:`All enabled model providers are already bound, or none are configured yet.`}),(0,Q.jsx)(B,{href:o,color:`orange.600`,fontSize:`sm`,fontWeight:`medium`,children:`Configure providers in Settings →`})]}):(0,Q.jsxs)(v.Root,{collection:R,value:s?[s]:[],onValueChange:e=>c(e.value[0]??``),width:`full`,size:`sm`,children:[(0,Q.jsx)(v.Trigger,{children:(0,Q.jsx)(v.ValueText,{placeholder:`Select a provider`,children:e=>{let t=e[0];if(!t)return`Select a provider`;let n=typeof t==`object`&&`label`in t?t.label:``,r=j.find(e=>e.id===s);return(0,Q.jsxs)(L,{gap:2,children:[(0,Q.jsx)($,{provider:n}),(0,Q.jsx)(M,{children:n}),r&&(0,Q.jsx)(b,{scopes:r.scopes,fallbackScopeType:r.scopeType})]})}})}),(0,Q.jsx)(v.Content,{children:j.map(e=>(0,Q.jsx)(v.Item,{item:{value:e.id,label:e.provider},children:(0,Q.jsxs)(L,{gap:2,width:`full`,children:[(0,Q.jsx)($,{provider:e.provider}),(0,Q.jsx)(M,{children:e.provider}),(0,Q.jsx)(V,{}),(0,Q.jsx)(b,{scopes:e.scopes,fallbackScopeType:e.scopeType})]})},e.id))})]}),(0,Q.jsx)(P,{children:G?(0,Q.jsxs)(Q.Fragment,{children:[`This credential is scoped to the`,` `,z?.scopes?.some(e=>e.scopeType===`ORGANIZATION`)||z?.scopeType===`ORGANIZATION`?`organization`:`team`,`, so any project with access can bind it to the gateway. Binding here only stores this project's gateway-specific settings (rate limits, fallback priority); the API key stays managed in`,` `,(0,Q.jsx)(B,{href:o,color:`orange.600`,children:`Settings → Model Providers`}),`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Gateway reuses the ModelProvider API key from`,` `,(0,Q.jsx)(B,{href:o,color:`orange.600`,children:`Settings → Model Providers`}),`. Binding only adds gateway-specific settings (rate limits, fallback priority).`]})})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Slot`,(0,Q.jsx)(q,{description:`Free-text tag used by virtual keys to reference this binding in their fallback chain. Typical names: primary, fallback-1, eu-region, canary. Defaults to 'primary'.`,docHref:`/ai-gateway/provider-bindings#slot`})]}),(0,Q.jsx)(I,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. primary, fallback-1`}),(0,Q.jsx)(P,{children:`Logical name used in the fallback chain. Defaults to "primary". Must be unique per provider — binding the same provider with the same slot twice is rejected by the server.`})]}),(0,Q.jsxs)(L,{gap:4,align:`flex-start`,children:[(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpm)`,(0,Q.jsx)(q,{description:`Requests Per Minute ceiling on this binding. Sliding window; 429 + Retry-After emitted at breach. Blank = unlimited (upstream provider limits still apply).`,docHref:`/ai-gateway/rate-limits#rpm`})]}),(0,Q.jsx)(I,{value:d,onChange:e=>f(e.target.value),placeholder:`blank = unlimited`,inputMode:`numeric`})]}),(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (tpm)`,(0,Q.jsx)(q,{description:`Tokens Per Minute ceiling on this binding. Deferred to v1.1 — configurable here now for forward compat, but the gateway does not enforce TPM until the streaming-usage accumulator lands.`,docHref:`/ai-gateway/rate-limits#tpm`})]}),(0,Q.jsx)(I,{value:p,onChange:e=>m(e.target.value),placeholder:`blank = unlimited`,inputMode:`numeric`})]})]})]})}),(0,Q.jsx)(r.Footer,{children:(0,Q.jsxs)(L,{width:`full`,children:[(0,Q.jsx)(V,{}),(0,Q.jsx)(E,{variant:`ghost`,onClick:C,disabled:y.isPending,children:`Cancel`}),(0,Q.jsx)(E,{colorPalette:`orange`,onClick:w,loading:y.isPending,disabled:!s,children:`Bind provider`})]})})]})})}function $({provider:e}){return(0,Q.jsx)(O,{width:`18px`,height:`18px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,css:{"& > svg":{width:`100%`,height:`100%`}},children:e in h?h[e]:null})}function ne({projectId:e,binding:t,onOpenChange:n,onSaved:i}){let[a,o]=(0,Z.useState)(`primary`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{t&&(o(t.slot),c(t.rateLimitRpm?.toString()??``),u(t.rateLimitRpd?.toString()??``),f(t.fallbackPriorityGlobal?.toString()??``))},[t]);let p=U.useContext(),m=U.gatewayProviders.update.useMutation({onSuccess:async()=>{await p.gatewayProviders.list.invalidate({projectId:e})}}),h=()=>{m.isPending||n(!1)};return(0,Q.jsx)(r.Root,{open:!!t,onOpenChange:()=>h(),placement:`end`,size:`md`,children:(0,Q.jsxs)(r.Content,{children:[(0,Q.jsxs)(r.Header,{children:[(0,Q.jsx)(r.Title,{children:`Edit provider binding`}),(0,Q.jsx)(r.CloseTrigger,{})]}),(0,Q.jsx)(r.Body,{children:(0,Q.jsxs)(H,{align:`stretch`,gap:4,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsx)(F,{children:`Provider`}),(0,Q.jsxs)(M,{fontSize:`sm`,color:`fg.muted`,children:[t?.modelProviderName,` (immutable — rebind to change)`]})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Slot`,(0,Q.jsx)(q,{description:`Free-text tag used by virtual keys to reference this binding in their fallback chain. Typical names: primary, fallback-1, eu-region, canary.`,docHref:`/ai-gateway/provider-bindings#slot`})]}),(0,Q.jsx)(I,{value:a,onChange:e=>o(e.target.value),placeholder:`e.g. primary, fallback-1`}),(0,Q.jsx)(P,{children:`Logical name used in the VK fallback chain.`})]}),(0,Q.jsxs)(L,{gap:4,align:`flex-start`,children:[(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpm)`,` `,(0,Q.jsx)(j,{colorPalette:`gray`,fontSize:`2xs`,ml:1,children:`per-binding`}),(0,Q.jsx)(q,{description:`Requests Per Minute ceiling on this binding. Sliding window; 429 + Retry-After emitted at breach. Blank = unlimited (upstream provider limits still apply).`,docHref:`/ai-gateway/rate-limits#rpm`})]}),(0,Q.jsx)(I,{value:s,onChange:e=>c(e.target.value),placeholder:`unlimited`,inputMode:`numeric`})]}),(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpd)`,(0,Q.jsx)(q,{description:`Rolling-24h request cap. Works jointly with rpm — whichever trips first blocks. Useful for 'daily quota' budgets independent of instantaneous burst.`,docHref:`/ai-gateway/rate-limits#rpd`})]}),(0,Q.jsx)(I,{value:l,onChange:e=>u(e.target.value),placeholder:`unlimited`,inputMode:`numeric`})]})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Fallback priority (global)`,(0,Q.jsx)(q,{description:`Tiebreaker when multiple bindings are eligible for the same VK slot; lower = higher priority. Leave blank to rely only on per-VK fallback chain ordering.`,docHref:`/ai-gateway/provider-bindings#fallback-priority-global`})]}),(0,Q.jsx)(I,{value:d,onChange:e=>f(e.target.value),placeholder:`none — ordered only via VK fallback chain`,inputMode:`numeric`}),(0,Q.jsx)(P,{children:`Lower numbers tried first when a VK leaves the slot unset. Leave blank to rely only on per-VK fallback ordering.`})]})]})}),(0,Q.jsx)(r.Footer,{children:(0,Q.jsxs)(L,{width:`full`,children:[(0,Q.jsx)(V,{}),(0,Q.jsx)(E,{variant:`ghost`,onClick:h,disabled:m.isPending,children:`Cancel`}),(0,Q.jsx)(E,{colorPalette:`orange`,onClick:async()=>{if(t)try{await m.mutateAsync({projectId:e,id:t.id,slot:a||void 0,rateLimitRpm:s?Number.parseInt(s,10):null,rateLimitRpd:l?Number.parseInt(l,10):null,fallbackPriorityGlobal:d?Number.parseInt(d,10):null}),i(),n(!1)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to update binding`,type:`error`})}},loading:m.isPending,children:`Save changes`})]})})]})})}function re(){let{project:e,hasPermission:t}=W(),r=t(`gatewayProviders:manage`),_=U.gatewayProviders.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),v=U.useContext(),b=U.gatewayProviders.disable.useMutation({onSuccess:()=>v.gatewayProviders.list.invalidate({projectId:e?.id})}),[x,T]=(0,Z.useState)(!1),[k,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null);return(0,Q.jsxs)(X,{children:[(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(u.Header,{children:[(0,Q.jsx)(u.Heading,{children:`Providers`}),(0,Q.jsx)(V,{}),r&&(0,Q.jsxs)(E,{colorPalette:`orange`,size:`sm`,onClick:()=>T(!0),children:[(0,Q.jsx)(i,{size:14}),` Bind provider`]})]}),(0,Q.jsx)(O,{padding:6,width:`full`,maxWidth:`1600px`,marginX:`auto`,children:_.isLoading?(0,Q.jsx)(D,{}):_.isError?(0,Q.jsx)(Y,{title:`Failed to load providers`,error:_.error,onRetry:()=>_.refetch()}):(_.data??[]).length===0?(0,Q.jsx)(o,{children:(0,Q.jsxs)(f,{children:[(0,Q.jsx)(p,{children:(0,Q.jsx)(a,{size:32})}),(0,Q.jsx)(n,{children:`No providers bound to the gateway yet`}),(0,Q.jsxs)(d,{children:[`Configure an LLM provider in`,` `,(0,Q.jsx)(B,{href:`/settings/model-providers`,color:`orange.600`,children:`Settings → Model Providers`}),`, then bind it to the AI Gateway here. The gateway reuses the existing ModelProvider credentials; binding only adds gateway-specific settings like rate limits and rotation.`]}),r&&(0,Q.jsxs)(E,{colorPalette:`orange`,onClick:()=>T(!0),mt:2,children:[(0,Q.jsx)(a,{size:14}),` Bind your first provider`]})]})}):(0,Q.jsx)(R,{width:`full`,overflow:`hidden`,children:(0,Q.jsx)(z,{paddingY:0,paddingX:0,children:(0,Q.jsxs)(C,{variant:`line`,size:`md`,width:`full`,children:[(0,Q.jsx)(g,{children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(w,{children:`Provider`}),(0,Q.jsx)(w,{children:`Slot`}),(0,Q.jsx)(w,{children:`Health`}),(0,Q.jsx)(w,{children:`Rate limits`}),(0,Q.jsx)(w,{children:`Priority`}),(0,Q.jsx)(w,{})]})}),(0,Q.jsx)(m,{children:(_.data??[]).map(e=>{let t=h[e.modelProviderName];return(0,Q.jsxs)(c,{children:[(0,Q.jsx)(S,{children:(0,Q.jsxs)(L,{gap:2,children:[(0,Q.jsx)(O,{width:`20px`,height:`20px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,css:{"& > svg":{width:`100%`,height:`100%`}},children:t}),(0,Q.jsxs)(H,{align:`start`,gap:0,children:[(0,Q.jsx)(M,{fontWeight:`medium`,children:e.modelProviderName}),e.disabledAt&&(0,Q.jsxs)(M,{fontSize:`2xs`,color:`fg.muted`,children:[`disabled`,` `,new Date(e.disabledAt).toLocaleDateString()]})]})]})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(j,{variant:`subtle`,colorPalette:`gray`,children:e.slot})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(ie,{status:e.healthStatus})}),(0,Q.jsx)(S,{children:(0,Q.jsxs)(L,{gap:1,flexWrap:`wrap`,children:[(0,Q.jsxs)(j,{variant:`outline`,fontSize:`2xs`,children:[`rpm `,e.rateLimitRpm??`∞`]}),(0,Q.jsxs)(j,{variant:`outline`,fontSize:`2xs`,children:[`rpd `,e.rateLimitRpd??`∞`]})]})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(M,{fontSize:`sm`,color:`fg.muted`,children:e.fallbackPriorityGlobal??`—`})}),(0,Q.jsxs)(S,{children:[r&&!e.disabledAt&&(0,Q.jsxs)(y.Root,{children:[(0,Q.jsx)(y.Trigger,{asChild:!0,children:(0,Q.jsx)(E,{variant:`ghost`,size:`xs`,"aria-label":`Actions`,children:(0,Q.jsx)(l,{size:14})})}),(0,Q.jsxs)(y.Content,{children:[(0,Q.jsxs)(y.Item,{value:`edit`,onClick:()=>N(e),children:[(0,Q.jsx)(s,{size:14}),` Edit`]}),(0,Q.jsxs)(y.Item,{value:`disable`,onClick:()=>F(e),children:[(0,Q.jsx)(ee,{size:14}),` Disable`]})]})]}),e.disabledAt&&(0,Q.jsx)(j,{colorPalette:`gray`,variant:`subtle`,children:`disabled`})]})]},e.id)})})]})})})})]}),e?.id&&(0,Q.jsx)(te,{projectId:e.id,open:x,onOpenChange:T,onCreated:()=>{_.refetch()}}),e?.id&&(0,Q.jsx)(ne,{projectId:e.id,binding:k,onOpenChange:e=>{e||N(null)},onSaved:()=>{N(null),_.refetch()}}),(0,Q.jsx)(J,{open:!!P,onOpenChange:e=>{e||F(null)},title:`Disable ${P?.modelProviderName??`provider`} binding?`,message:`VKs routing to this slot will fail over to the next provider in their fallback chain. The underlying ModelProvider credentials are not touched.`,confirmLabel:`Disable binding`,tone:`warning`,loading:b.isPending,onConfirm:async()=>{if(!(!P||!e?.id))try{await b.mutateAsync({projectId:e.id,id:P.id}),F(null)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to disable`,type:`error`})}}})]})}function ie({status:e}){return(0,Q.jsx)(k,{content:e===`HEALTHY`?`Last probe + recent dispatches succeeded.`:e===`DEGRADED`?`Recent dispatches have been partially failing — fallbacks likely kicking in.`:e===`CIRCUIT_OPEN`?`Too many consecutive failures; the gateway is short-circuiting this binding and all traffic moves to fallbacks.`:`No probe has run against this binding yet. Status will update after the first dispatch or the next periodic health check.`,children:(0,Q.jsx)(j,{colorPalette:e===`HEALTHY`?`green`:e===`DEGRADED`?`yellow`:e===`CIRCUIT_OPEN`?`red`:`gray`,children:e.toLowerCase()})})}var ae=K(`gatewayProviders:view`,{layoutComponent:_})(re);export{ae as default};
2
- //# sourceMappingURL=providers-DW7VWdqq.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as n,Do as r,Fa as i,Ia as a,Qs as o,Ra as s,Ss as c,Xa as l,Xr as u,Xs as d,Ys as f,Zs as p,_s as m,bi as h,bs as g,mn as _,na as v,qi as y,rn as b,sc as x,vs as S,xs as C,ys as w}from"./command-bar-DUK45yin.js";import{j as T,n as E,r as D}from"./stack-oJ9iWdbl.js";import{t as O}from"./box-BsM8YLGl.js";import{t as k}from"./tooltip-AEm0YeiF.js";import{n as A}from"./toaster-C_DYALhL.js";import{an as j}from"./dist-Cds4Mqhj.js";import{t as M}from"./text-CwTrMF8x.js";import{a as N,n as P,r as F}from"./field-CnUiixMS.js";import{t as I}from"./input-C7emsUCL.js";import{t as L}from"./h-stack-BKLDJ2vg.js";import{r as R,t as z}from"./card-CMtKVPVl.js";import{t as B}from"./link-CwZhwOLq.js";import{t as V}from"./spacer-2LJJGbo8.js";import{t as H}from"./v-stack-EOPQ57OZ.js";import{s as U}from"./auth-client-D3UhxhQi.js";import{t as W}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as G}from"./createLucideIcon-BJKFyRLS.js";import{t as K}from"./WithPermissionGuard-B4Jo8E5-.js";import{n as q,t as J}from"./ConfirmDialog-M94yLNvP.js";import{t as Y}from"./GatewayErrorPanel-BsaYQEie.js";import{t as X}from"./GatewayLayout-LvwwrwMf.js";var ee=G(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Z=e(t()),Q=T();function te({projectId:e,open:t,onOpenChange:n,onCreated:i}){let{project:a}=W(),o=`/settings/model-providers`,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`primary`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),h=U.useContext(),g=U.modelProvider.getAllForProject.useQuery({projectId:e},{enabled:t&&!!e}),_=U.gatewayProviders.list.useQuery({projectId:e},{enabled:t&&!!e}),y=U.gatewayProviders.create.useMutation({onSuccess:async()=>{await h.gatewayProviders.list.invalidate({projectId:e})}}),S=()=>{c(``),u(`primary`),f(``),m(``)},C=()=>{y.isPending||(S(),n(!1))},w=async()=>{if(!s){A.create({title:`Select a model provider`,type:`error`});return}try{await y.mutateAsync({projectId:e,modelProviderId:s,slot:l||void 0,rateLimitRpm:d?Number.parseInt(d,10):null,rateLimitTpm:p?Number.parseInt(p,10):null}),i(),S(),n(!1)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to bind provider`,type:`error`})}},T=g.data??{},O=Object.values(T).filter(e=>e?.enabled&&e?.id),k=new Set((_.data??[]).map(e=>e.modelProviderId)),j=O.filter(e=>!k.has(e.id)),R=(0,Z.useMemo)(()=>x({items:j.map(e=>({value:e.id,label:e.provider}))}),[j]),z=j.find(e=>e.id===s),G=z?.scopes?.some(e=>e.scopeType===`ORGANIZATION`||e.scopeType===`TEAM`)||z?.scopeType===`ORGANIZATION`||z?.scopeType===`TEAM`;return(0,Q.jsx)(r.Root,{open:t,onOpenChange:()=>C(),placement:`end`,size:`md`,children:(0,Q.jsxs)(r.Content,{children:[(0,Q.jsxs)(r.Header,{children:[(0,Q.jsx)(r.Title,{children:`Bind provider to gateway`}),(0,Q.jsx)(r.CloseTrigger,{})]}),(0,Q.jsx)(r.Body,{children:(0,Q.jsxs)(H,{align:`stretch`,gap:4,children:[(0,Q.jsxs)(N,{required:!0,children:[(0,Q.jsxs)(F,{children:[`Model provider`,(0,Q.jsx)(q,{description:`The LLM provider whose API key the gateway routes traffic to. Providers are configured once in Settings → Model Providers and reused here.`,docHref:`/ai-gateway/provider-bindings#model-provider`})]}),g.isLoading?(0,Q.jsx)(D,{size:`sm`}):j.length===0?(0,Q.jsxs)(H,{align:`stretch`,gap:2,children:[(0,Q.jsx)(M,{fontSize:`sm`,color:`fg.muted`,children:`All enabled model providers are already bound, or none are configured yet.`}),(0,Q.jsx)(B,{href:o,color:`orange.600`,fontSize:`sm`,fontWeight:`medium`,children:`Configure providers in Settings →`})]}):(0,Q.jsxs)(v.Root,{collection:R,value:s?[s]:[],onValueChange:e=>c(e.value[0]??``),width:`full`,size:`sm`,children:[(0,Q.jsx)(v.Trigger,{children:(0,Q.jsx)(v.ValueText,{placeholder:`Select a provider`,children:e=>{let t=e[0];if(!t)return`Select a provider`;let n=typeof t==`object`&&`label`in t?t.label:``,r=j.find(e=>e.id===s);return(0,Q.jsxs)(L,{gap:2,children:[(0,Q.jsx)($,{provider:n}),(0,Q.jsx)(M,{children:n}),r&&(0,Q.jsx)(b,{scopes:r.scopes,fallbackScopeType:r.scopeType})]})}})}),(0,Q.jsx)(v.Content,{children:j.map(e=>(0,Q.jsx)(v.Item,{item:{value:e.id,label:e.provider},children:(0,Q.jsxs)(L,{gap:2,width:`full`,children:[(0,Q.jsx)($,{provider:e.provider}),(0,Q.jsx)(M,{children:e.provider}),(0,Q.jsx)(V,{}),(0,Q.jsx)(b,{scopes:e.scopes,fallbackScopeType:e.scopeType})]})},e.id))})]}),(0,Q.jsx)(P,{children:G?(0,Q.jsxs)(Q.Fragment,{children:[`This credential is scoped to the`,` `,z?.scopes?.some(e=>e.scopeType===`ORGANIZATION`)||z?.scopeType===`ORGANIZATION`?`organization`:`team`,`, so any project with access can bind it to the gateway. Binding here only stores this project's gateway-specific settings (rate limits, fallback priority); the API key stays managed in`,` `,(0,Q.jsx)(B,{href:o,color:`orange.600`,children:`Settings → Model Providers`}),`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Gateway reuses the ModelProvider API key from`,` `,(0,Q.jsx)(B,{href:o,color:`orange.600`,children:`Settings → Model Providers`}),`. Binding only adds gateway-specific settings (rate limits, fallback priority).`]})})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Slot`,(0,Q.jsx)(q,{description:`Free-text tag used by virtual keys to reference this binding in their fallback chain. Typical names: primary, fallback-1, eu-region, canary. Defaults to 'primary'.`,docHref:`/ai-gateway/provider-bindings#slot`})]}),(0,Q.jsx)(I,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. primary, fallback-1`}),(0,Q.jsx)(P,{children:`Logical name used in the fallback chain. Defaults to "primary". Must be unique per provider — binding the same provider with the same slot twice is rejected by the server.`})]}),(0,Q.jsxs)(L,{gap:4,align:`flex-start`,children:[(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpm)`,(0,Q.jsx)(q,{description:`Requests Per Minute ceiling on this binding. Sliding window; 429 + Retry-After emitted at breach. Blank = unlimited (upstream provider limits still apply).`,docHref:`/ai-gateway/rate-limits#rpm`})]}),(0,Q.jsx)(I,{value:d,onChange:e=>f(e.target.value),placeholder:`blank = unlimited`,inputMode:`numeric`})]}),(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (tpm)`,(0,Q.jsx)(q,{description:`Tokens Per Minute ceiling on this binding. Deferred to v1.1 — configurable here now for forward compat, but the gateway does not enforce TPM until the streaming-usage accumulator lands.`,docHref:`/ai-gateway/rate-limits#tpm`})]}),(0,Q.jsx)(I,{value:p,onChange:e=>m(e.target.value),placeholder:`blank = unlimited`,inputMode:`numeric`})]})]})]})}),(0,Q.jsx)(r.Footer,{children:(0,Q.jsxs)(L,{width:`full`,children:[(0,Q.jsx)(V,{}),(0,Q.jsx)(E,{variant:`ghost`,onClick:C,disabled:y.isPending,children:`Cancel`}),(0,Q.jsx)(E,{colorPalette:`orange`,onClick:w,loading:y.isPending,disabled:!s,children:`Bind provider`})]})})]})})}function $({provider:e}){return(0,Q.jsx)(O,{width:`18px`,height:`18px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,css:{"& > svg":{width:`100%`,height:`100%`}},children:e in h?h[e]:null})}function ne({projectId:e,binding:t,onOpenChange:n,onSaved:i}){let[a,o]=(0,Z.useState)(`primary`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{t&&(o(t.slot),c(t.rateLimitRpm?.toString()??``),u(t.rateLimitRpd?.toString()??``),f(t.fallbackPriorityGlobal?.toString()??``))},[t]);let p=U.useContext(),m=U.gatewayProviders.update.useMutation({onSuccess:async()=>{await p.gatewayProviders.list.invalidate({projectId:e})}}),h=()=>{m.isPending||n(!1)};return(0,Q.jsx)(r.Root,{open:!!t,onOpenChange:()=>h(),placement:`end`,size:`md`,children:(0,Q.jsxs)(r.Content,{children:[(0,Q.jsxs)(r.Header,{children:[(0,Q.jsx)(r.Title,{children:`Edit provider binding`}),(0,Q.jsx)(r.CloseTrigger,{})]}),(0,Q.jsx)(r.Body,{children:(0,Q.jsxs)(H,{align:`stretch`,gap:4,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsx)(F,{children:`Provider`}),(0,Q.jsxs)(M,{fontSize:`sm`,color:`fg.muted`,children:[t?.modelProviderName,` (immutable — rebind to change)`]})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Slot`,(0,Q.jsx)(q,{description:`Free-text tag used by virtual keys to reference this binding in their fallback chain. Typical names: primary, fallback-1, eu-region, canary.`,docHref:`/ai-gateway/provider-bindings#slot`})]}),(0,Q.jsx)(I,{value:a,onChange:e=>o(e.target.value),placeholder:`e.g. primary, fallback-1`}),(0,Q.jsx)(P,{children:`Logical name used in the VK fallback chain.`})]}),(0,Q.jsxs)(L,{gap:4,align:`flex-start`,children:[(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpm)`,` `,(0,Q.jsx)(j,{colorPalette:`gray`,fontSize:`2xs`,ml:1,children:`per-binding`}),(0,Q.jsx)(q,{description:`Requests Per Minute ceiling on this binding. Sliding window; 429 + Retry-After emitted at breach. Blank = unlimited (upstream provider limits still apply).`,docHref:`/ai-gateway/rate-limits#rpm`})]}),(0,Q.jsx)(I,{value:s,onChange:e=>c(e.target.value),placeholder:`unlimited`,inputMode:`numeric`})]}),(0,Q.jsxs)(N,{flex:1,children:[(0,Q.jsxs)(F,{children:[`Rate limit (rpd)`,(0,Q.jsx)(q,{description:`Rolling-24h request cap. Works jointly with rpm — whichever trips first blocks. Useful for 'daily quota' budgets independent of instantaneous burst.`,docHref:`/ai-gateway/rate-limits#rpd`})]}),(0,Q.jsx)(I,{value:l,onChange:e=>u(e.target.value),placeholder:`unlimited`,inputMode:`numeric`})]})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(F,{children:[`Fallback priority (global)`,(0,Q.jsx)(q,{description:`Tiebreaker when multiple bindings are eligible for the same VK slot; lower = higher priority. Leave blank to rely only on per-VK fallback chain ordering.`,docHref:`/ai-gateway/provider-bindings#fallback-priority-global`})]}),(0,Q.jsx)(I,{value:d,onChange:e=>f(e.target.value),placeholder:`none — ordered only via VK fallback chain`,inputMode:`numeric`}),(0,Q.jsx)(P,{children:`Lower numbers tried first when a VK leaves the slot unset. Leave blank to rely only on per-VK fallback ordering.`})]})]})}),(0,Q.jsx)(r.Footer,{children:(0,Q.jsxs)(L,{width:`full`,children:[(0,Q.jsx)(V,{}),(0,Q.jsx)(E,{variant:`ghost`,onClick:h,disabled:m.isPending,children:`Cancel`}),(0,Q.jsx)(E,{colorPalette:`orange`,onClick:async()=>{if(t)try{await m.mutateAsync({projectId:e,id:t.id,slot:a||void 0,rateLimitRpm:s?Number.parseInt(s,10):null,rateLimitRpd:l?Number.parseInt(l,10):null,fallbackPriorityGlobal:d?Number.parseInt(d,10):null}),i(),n(!1)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to update binding`,type:`error`})}},loading:m.isPending,children:`Save changes`})]})})]})})}function re(){let{project:e,hasPermission:t}=W(),r=t(`gatewayProviders:manage`),_=U.gatewayProviders.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),v=U.useContext(),b=U.gatewayProviders.disable.useMutation({onSuccess:()=>v.gatewayProviders.list.invalidate({projectId:e?.id})}),[x,T]=(0,Z.useState)(!1),[k,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null);return(0,Q.jsxs)(X,{children:[(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(u.Header,{children:[(0,Q.jsx)(u.Heading,{children:`Providers`}),(0,Q.jsx)(V,{}),r&&(0,Q.jsxs)(E,{colorPalette:`orange`,size:`sm`,onClick:()=>T(!0),children:[(0,Q.jsx)(i,{size:14}),` Bind provider`]})]}),(0,Q.jsx)(O,{padding:6,width:`full`,maxWidth:`1600px`,marginX:`auto`,children:_.isLoading?(0,Q.jsx)(D,{}):_.isError?(0,Q.jsx)(Y,{title:`Failed to load providers`,error:_.error,onRetry:()=>_.refetch()}):(_.data??[]).length===0?(0,Q.jsx)(o,{children:(0,Q.jsxs)(f,{children:[(0,Q.jsx)(p,{children:(0,Q.jsx)(a,{size:32})}),(0,Q.jsx)(n,{children:`No providers bound to the gateway yet`}),(0,Q.jsxs)(d,{children:[`Configure an LLM provider in`,` `,(0,Q.jsx)(B,{href:`/settings/model-providers`,color:`orange.600`,children:`Settings → Model Providers`}),`, then bind it to the AI Gateway here. The gateway reuses the existing ModelProvider credentials; binding only adds gateway-specific settings like rate limits and rotation.`]}),r&&(0,Q.jsxs)(E,{colorPalette:`orange`,onClick:()=>T(!0),mt:2,children:[(0,Q.jsx)(a,{size:14}),` Bind your first provider`]})]})}):(0,Q.jsx)(R,{width:`full`,overflow:`hidden`,children:(0,Q.jsx)(z,{paddingY:0,paddingX:0,children:(0,Q.jsxs)(C,{variant:`line`,size:`md`,width:`full`,children:[(0,Q.jsx)(g,{children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(w,{children:`Provider`}),(0,Q.jsx)(w,{children:`Slot`}),(0,Q.jsx)(w,{children:`Health`}),(0,Q.jsx)(w,{children:`Rate limits`}),(0,Q.jsx)(w,{children:`Priority`}),(0,Q.jsx)(w,{})]})}),(0,Q.jsx)(m,{children:(_.data??[]).map(e=>{let t=h[e.modelProviderName];return(0,Q.jsxs)(c,{children:[(0,Q.jsx)(S,{children:(0,Q.jsxs)(L,{gap:2,children:[(0,Q.jsx)(O,{width:`20px`,height:`20px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,css:{"& > svg":{width:`100%`,height:`100%`}},children:t}),(0,Q.jsxs)(H,{align:`start`,gap:0,children:[(0,Q.jsx)(M,{fontWeight:`medium`,children:e.modelProviderName}),e.disabledAt&&(0,Q.jsxs)(M,{fontSize:`2xs`,color:`fg.muted`,children:[`disabled`,` `,new Date(e.disabledAt).toLocaleDateString()]})]})]})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(j,{variant:`subtle`,colorPalette:`gray`,children:e.slot})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(ie,{status:e.healthStatus})}),(0,Q.jsx)(S,{children:(0,Q.jsxs)(L,{gap:1,flexWrap:`wrap`,children:[(0,Q.jsxs)(j,{variant:`outline`,fontSize:`2xs`,children:[`rpm `,e.rateLimitRpm??`∞`]}),(0,Q.jsxs)(j,{variant:`outline`,fontSize:`2xs`,children:[`rpd `,e.rateLimitRpd??`∞`]})]})}),(0,Q.jsx)(S,{children:(0,Q.jsx)(M,{fontSize:`sm`,color:`fg.muted`,children:e.fallbackPriorityGlobal??`—`})}),(0,Q.jsxs)(S,{children:[r&&!e.disabledAt&&(0,Q.jsxs)(y.Root,{children:[(0,Q.jsx)(y.Trigger,{asChild:!0,children:(0,Q.jsx)(E,{variant:`ghost`,size:`xs`,"aria-label":`Actions`,children:(0,Q.jsx)(l,{size:14})})}),(0,Q.jsxs)(y.Content,{children:[(0,Q.jsxs)(y.Item,{value:`edit`,onClick:()=>N(e),children:[(0,Q.jsx)(s,{size:14}),` Edit`]}),(0,Q.jsxs)(y.Item,{value:`disable`,onClick:()=>F(e),children:[(0,Q.jsx)(ee,{size:14}),` Disable`]})]})]}),e.disabledAt&&(0,Q.jsx)(j,{colorPalette:`gray`,variant:`subtle`,children:`disabled`})]})]},e.id)})})]})})})})]}),e?.id&&(0,Q.jsx)(te,{projectId:e.id,open:x,onOpenChange:T,onCreated:()=>{_.refetch()}}),e?.id&&(0,Q.jsx)(ne,{projectId:e.id,binding:k,onOpenChange:e=>{e||N(null)},onSaved:()=>{N(null),_.refetch()}}),(0,Q.jsx)(J,{open:!!P,onOpenChange:e=>{e||F(null)},title:`Disable ${P?.modelProviderName??`provider`} binding?`,message:`VKs routing to this slot will fail over to the next provider in their fallback chain. The underlying ModelProvider credentials are not touched.`,confirmLabel:`Disable binding`,tone:`warning`,loading:b.isPending,onConfirm:async()=>{if(!(!P||!e?.id))try{await b.mutateAsync({projectId:e.id,id:P.id}),F(null)}catch(e){A.create({title:e instanceof Error?e.message:`Failed to disable`,type:`error`})}}})]})}function ie({status:e}){return(0,Q.jsx)(k,{content:e===`HEALTHY`?`Last probe + recent dispatches succeeded.`:e===`DEGRADED`?`Recent dispatches have been partially failing — fallbacks likely kicking in.`:e===`CIRCUIT_OPEN`?`Too many consecutive failures; the gateway is short-circuiting this binding and all traffic moves to fallbacks.`:`No probe has run against this binding yet. Status will update after the first dispatch or the next periodic health check.`,children:(0,Q.jsx)(j,{colorPalette:e===`HEALTHY`?`green`:e===`DEGRADED`?`yellow`:e===`CIRCUIT_OPEN`?`red`:`gray`,children:e.toLowerCase()})})}var ae=K(`gatewayProviders:view`,{layoutComponent:_})(re);export{ae as default};
2
+ //# sourceMappingURL=providers-tlLT_lTF.js.map