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

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 (179) 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-COI3ShsR.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-BEjGS0kI.js} +5 -5
  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/dist/scenario-child-process.js +20 -10
  135. package/langwatch/package.json +2 -2
  136. package/langwatch/pnpm-lock.yaml +329 -328
  137. package/langwatch/scripts/seed-dogfood-password.ts +163 -0
  138. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
  139. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +188 -0
  140. package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
  141. package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
  142. package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
  143. package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
  144. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
  145. package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
  146. package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
  147. package/langwatch/src/hooks/usePostHog.ts +11 -0
  148. package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
  149. package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
  150. package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
  151. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
  152. package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
  153. package/langwatch/src/optimization_studio/registry.ts +2 -4
  154. package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
  155. package/langwatch/src/server/api/routers/workflows.ts +18 -0
  156. package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
  157. package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
  158. package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
  159. package/langwatch/src/server/modelProviders/utils.ts +11 -1
  160. package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
  161. package/langwatch/src/server/nlpgo/nlpgoFetch.ts +155 -0
  162. package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
  163. package/langwatch/src/server/routes/playground.ts +11 -1
  164. package/langwatch/src/server/routes/workflows.ts +17 -0
  165. package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
  166. package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
  167. package/langwatch_nlp/langwatch_nlp/studio/execute/execute_component.py +25 -1
  168. package/langwatch_nlp/langwatch_nlp/studio/parser.py +121 -16
  169. package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
  170. package/langwatch_nlp/scripts/entrypoint.sh +67 -0
  171. package/langwatch_nlp/tests/studio/test_parse.py +198 -0
  172. package/mcp-server/pnpm-lock.yaml +15 -21
  173. package/package.json +1 -1
  174. package/packages/server/dist/cli.cjs +78 -94
  175. package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
  176. package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
  177. package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
  178. package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
  179. 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,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
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{An as n,Da as r,Dn as i,Fa as a,Fn as o,Gn as s,In as c,Ln as l,Mn as u,Nn as d,Pn as f,Xa as p,jn as m,kn as h,ln as g,lo as _,pn as v,qi as y,r as b,un as x,wa as S}from"./command-bar-CaJygoez.js";import{j as C,n as w}from"./stack-oJ9iWdbl.js";import{t as T}from"./box-BsM8YLGl.js";import{f as ee}from"./LoadingScreen--vgXk5-2.js";import{r as te}from"./dialog.anatomy-hrluUh9u.js";import{t as E}from"./tooltip-AEm0YeiF.js";import{n as D}from"./toaster-C_DYALhL.js";import{t as O}from"./heading-D90dlSnH.js";import{t as k}from"./text-CwTrMF8x.js";import{t as A}from"./h-stack-BKLDJ2vg.js";import{a as j,i as M,n as N,r as P}from"./alert-SnQmACl1.js";import{r as F,t as I}from"./card-CMtKVPVl.js";import{t as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as L}from"./v-stack-EOPQ57OZ.js";import{s as R}from"./auth-client-D3UhxhQi.js";import{t as z}from"./FilterDisplay-BB0xWrLn.js";import{r as B}from"./next-router-C6sliiV7.js";import{t as V}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as H}from"./index.esm-X7lxUoP1.js";import{t as U}from"./createLucideIcon-BJKFyRLS.js";import{t as W}from"./chart-no-axes-column-BMqNR285.js";import{t as G}from"./WithPermissionGuard-DD8uo3UK.js";import{t as K}from"./GraphsLayout-BJ68J9e-.js";var q=U(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),J=U(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Y=e=>{let t=[],n=new Set,r=(e,t)=>`${e},${t}`,i=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)if(o>=2||n.has(r(o,e)))return!1;return!0},a=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)n.add(r(o,e))};for(let n of e){let{colSpan:e,rowSpan:r}=n,o=!1,s=0;for(;!o;){for(let c=0;c<=2-e;c++)if(i(c,s,e,r)){a(c,s,e,r),t.push({graphId:n.id,gridColumn:c,gridRow:s,colSpan:e,rowSpan:r}),o=!0;break}o||s++}}return t},X=e(t()),Z=C(),Q=[{value:`1x1`,label:`Small (1x1)`,colSpan:1,rowSpan:1},{value:`2x1`,label:`Wide (2x1)`,colSpan:2,rowSpan:1},{value:`1x2`,label:`Tall (1x2)`,colSpan:1,rowSpan:2},{value:`2x2`,label:`Large (2x2)`,colSpan:2,rowSpan:2}],ie=(e,t)=>e===2&&t===2?`2x2`:e===2&&t===1?`2x1`:e===1&&t===2?`1x2`:`1x1`;function ae({graphId:e,projectSlug:t,dashboardId:n,colSpan:i,rowSpan:a,onSizeChange:o,onDelete:s,isDeleting:c}){let l=B(),u=ie(i,a),d=`/${t}/analytics/custom/${e}${n?`?dashboard=${n}`:``}`;return(0,Z.jsxs)(y.Root,{children:[(0,Z.jsx)(y.Trigger,{asChild:!0,children:(0,Z.jsx)(w,{variant:`ghost`,loading:c,children:(0,Z.jsx)(p,{})})}),(0,Z.jsxs)(y.Content,{children:[(0,Z.jsxs)(y.Item,{value:`edit`,onClick:()=>{l.push(d)},children:[(0,Z.jsx)(r,{}),` Edit Graph`]}),(0,Z.jsxs)(y.Root,{positioning:{placement:`right-start`,gutter:2},children:[(0,Z.jsxs)(y.TriggerItem,{value:`size`,children:[(0,Z.jsx)(J,{}),` Size (`,u,`)`]}),(0,Z.jsx)(y.Content,{children:Q.map(e=>(0,Z.jsxs)(y.Item,{value:e.value,onClick:()=>o(e.value),children:[e.label,e.value===u&&` ✓`]},e.value))})]}),(0,Z.jsxs)(y.Item,{value:`delete`,color:`red.600`,onClick:s,children:[(0,Z.jsx)(S,{}),` Delete Graph`]})]})]})}function oe({filters:e}){return(0,Z.jsx)(E,{content:(0,Z.jsx)(L,{align:`start`,backgroundColor:`black`,color:`white`,height:`100%`,textWrap:`wrap`,children:(0,Z.jsx)(z,{filters:e})}),positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,children:(0,Z.jsx)(q,{width:16,style:{minWidth:16}})})})}function se({graphId:e,name:t,graph:n,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,filters:s,trigger:c,isDragging:l,dragAttributes:u,dragListeners:d,onSizeChange:f,onDelete:p,isDeleting:m}){let{openDrawer:h}=b(),v=(0,X.useMemo)(()=>{if(t&&t.trim())return t;if(n&&typeof n==`object`&&`series`in n){let e=n;if(e.series&&e.series.length>0){let t=e.series.map(e=>e.name).filter(Boolean).join(`, `);if(t)return t.replace(/,([^,]*)$/,` and$1`)}}return`Untitled Graph`},[t,n]),y=H({defaultValues:n?{...g(n),title:v}:void 0});(0,X.useEffect)(()=>{n&&y.setValue(`title`,v)},[v,y,n]);let x=(0,X.useMemo)(()=>!!(s&&typeof s==`object`&&Object.keys(s).length>0),[s]),S=!!(e&&e!==`custom`&&n);return(0,Z.jsxs)(A,{...u,...d,align:`center`,marginBottom:4,cursor:l?`grabbing`:`grab`,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(O,{size:`sm`,marginLeft:2,children:v}),(0,Z.jsx)(re,{}),S&&(0,Z.jsx)(Z.Fragment,{children:c?.active?(0,Z.jsx)(E,{content:`Alert configured (${c.alertType??`INFO`})`,positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,cursor:`pointer`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:(0,Z.jsx)(_,{width:18,color:`black`})})}):(0,Z.jsxs)(w,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:[(0,Z.jsx)(_,{width:16}),`Add alert`]})}),x&&(0,Z.jsx)(oe,{filters:s}),(0,Z.jsx)(ae,{graphId:e,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,onSizeChange:f,onDelete:p,isDeleting:m})]})}function ce({graph:e,projectSlug:t,dashboardId:r,onDelete:i,onSizeChange:a,isDeleting:o}){let{attributes:c,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=n({id:e.id}),h={transform:l.Transform.toString(f),transition:p,opacity:m?.5:1,gridColumn:`span ${e.colSpan}`,gridRow:`span ${e.rowSpan}`},g=e.rowSpan===2?600:300;return(0,Z.jsx)(T,{ref:d,style:h,minWidth:0,children:(0,Z.jsx)(F,{height:`full`,minWidth:0,children:(0,Z.jsxs)(I,{height:`full`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,children:[(0,Z.jsx)(se,{graphId:e.id,name:e.name,graph:e.graph,projectSlug:t,dashboardId:r,colSpan:e.colSpan,rowSpan:e.rowSpan,filters:e.filters,trigger:e.trigger,isDragging:m,dragAttributes:c,dragListeners:u,onSizeChange:a,onDelete:i,isDeleting:o}),(0,Z.jsx)(T,{flex:1,minHeight:0,children:(0,Z.jsx)(s,{input:{...e.graph,height:g},filters:e.filters},e.id)})]})})})}function le({graphs:e,projectSlug:t,dashboardId:n,onGraphDelete:r,onGraphSizeChange:a,onGraphsReorder:s,deletingGraphId:l}){let[p,g]=(0,X.useState)(null),_=e.find(e=>e.id===p),v=c(o(d,{activationConstraint:{distance:8}}));return(0,Z.jsxs)(m,{sensors:v,collisionDetection:f,onDragStart:e=>{g(e.active.id)},onDragEnd:t=>{g(null);let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.findIndex(e=>e.id===n.id),a=e.findIndex(e=>e.id===r.id);if(i!==-1&&a!==-1){let t=[...e],[n]=t.splice(i,1);t.splice(a,0,n),s(Y(t))}},children:[(0,Z.jsx)(i,{items:e.map(e=>e.id),strategy:h,children:(0,Z.jsx)(te,{templateColumns:`repeat(2, 1fr)`,autoRows:`minmax(350px, auto)`,gap:5,width:`100%`,children:e.map(e=>(0,Z.jsx)(ce,{graph:e,projectSlug:t,dashboardId:n,onDelete:()=>r(e.id),onSizeChange:t=>a(e.id,t),isDeleting:l===e.id},e.id))})}),(0,Z.jsx)(u,{children:_?(0,Z.jsx)(F,{boxShadow:`xl`,opacity:.9,width:_.colSpan===2?`600px`:`300px`,height:_.rowSpan===2?`400px`:`200px`,children:(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(A,{align:`center`,marginBottom:4,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(k,{marginLeft:2,fontSize:`md`,fontWeight:`bold`,children:_.name})]}),(0,Z.jsx)(T,{flex:1,background:`gray.50`,borderRadius:`md`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`fg.subtle`,height:`calc(100% - 40px)`,children:`Chart preview`})]})}):null})]})}function $(){let{project:e}=V(),{showFilters:t}=v(),n=B(),r=e?.id??``,i=n.query.dashboard,o=R.dashboards.getOrCreateFirst.useQuery({projectId:r},{enabled:!!r&&!i}),s=i??o.data?.id,c=R.dashboards.getAll.useQuery({projectId:r},{enabled:!!r}),l=c.data?.find(e=>e.id===s)?.name??`Reports`,u=R.graphs.getAll.useQuery({projectId:r,dashboardId:s},{enabled:!!r&&!!s}),d=R.graphs.delete.useMutation(),f=R.graphs.updateLayout.useMutation(),p=R.graphs.batchUpdateLayouts.useMutation(),m=R.dashboards.rename.useMutation(),h=e=>{s&&m.mutate({projectId:r,dashboardId:s,name:e},{onSuccess:()=>{c.refetch()},onError:()=>{D.create({title:`Error renaming dashboard`,type:`error`,duration:3e3,meta:{closable:!0}})}})},g=e=>{d.mutate({projectId:r,id:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error deleting graph`,type:`error`,duration:3e3,meta:{closable:!0}})}})},_=(e,t)=>{let n=Q.find(e=>e.value===t);if(!n)return;let i=u.data?.find(t=>t.id===e);i&&f.mutate({projectId:r,graphId:e,gridColumn:i.gridColumn,gridRow:i.gridRow,colSpan:n.colSpan,rowSpan:n.rowSpan},{onSuccess:()=>{let t=u.data?.map(t=>t.id===e?{...t,colSpan:n.colSpan,rowSpan:n.rowSpan}:t);if(t){let e=Y(t);p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()}})}},onError:()=>{D.create({title:`Error updating graph size`,type:`error`,duration:3e3,meta:{closable:!0}})}})},y=e=>{p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error reordering graphs`,type:`error`,duration:3e3,meta:{closable:!0}})}})},b=u.data??[],S=b.length===0&&!u.isLoading,C=s?`/${e?.slug}/analytics/custom?dashboard=${s}`:`/${e?.slug}/analytics/custom`;return(0,Z.jsxs)(K,{title:l,analyticsHeaderProps:{isEditable:!0,onTitleSave:h},extraHeaderButtons:e?(0,Z.jsx)(ne,{href:C,asChild:!0,children:(0,Z.jsxs)(w,{colorPalette:`orange`,size:`sm`,children:[(0,Z.jsx)(a,{}),` Add chart`]})}):null,children:[S&&(0,Z.jsxs)(M,{status:`info`,borderStartWidth:`4px`,borderStartColor:`colorPalette.solid`,marginBottom:6,children:[(0,Z.jsx)(P,{alignSelf:`start`}),(0,Z.jsxs)(L,{align:`start`,children:[(0,Z.jsx)(j,{children:`Add your custom graphs here`}),(0,Z.jsx)(N,{children:(0,Z.jsxs)(k,{as:`span`,children:[`You haven`,`'`,`t set up any custom graphs yet. Click + Add chart to get started.`]})})]})]}),(0,Z.jsxs)(A,{align:`start`,gap:6,width:`full`,children:[(0,Z.jsx)(T,{flex:1,children:u.isLoading?(0,Z.jsx)(ee,{height:`300px`}):(0,Z.jsx)(le,{graphs:b,projectSlug:e?.slug??``,dashboardId:s??void 0,onGraphDelete:g,onGraphSizeChange:_,onGraphsReorder:y,deletingGraphId:d.isLoading?d.variables?.id??null:null})}),t?(0,Z.jsx)(x,{}):null]})]})}var ue=G(`analytics:view`)($);export{ue as default};
2
- //# sourceMappingURL=reports-D3QFKhNP.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{An as n,Da as r,Dn as i,Fa as a,Fn as o,Gn as s,In as c,Ln as l,Mn as u,Nn as d,Pn as f,Xa as p,jn as m,kn as h,ln as g,lo as _,pn as v,qi as y,r as b,un as x,wa as S}from"./command-bar-DUK45yin.js";import{j as C,n as w}from"./stack-oJ9iWdbl.js";import{t as T}from"./box-BsM8YLGl.js";import{f as ee}from"./LoadingScreen--vgXk5-2.js";import{r as te}from"./dialog.anatomy-hrluUh9u.js";import{t as E}from"./tooltip-AEm0YeiF.js";import{n as D}from"./toaster-C_DYALhL.js";import{t as O}from"./heading-D90dlSnH.js";import{t as k}from"./text-CwTrMF8x.js";import{t as A}from"./h-stack-BKLDJ2vg.js";import{a as j,i as M,n as N,r as P}from"./alert-SnQmACl1.js";import{r as F,t as I}from"./card-CMtKVPVl.js";import{t as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as L}from"./v-stack-EOPQ57OZ.js";import{s as R}from"./auth-client-D3UhxhQi.js";import{t as z}from"./FilterDisplay-0S3NqCkq.js";import{r as B}from"./next-router-C6sliiV7.js";import{t as V}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as H}from"./index.esm-X7lxUoP1.js";import{t as U}from"./createLucideIcon-BJKFyRLS.js";import{t as W}from"./chart-no-axes-column-BMqNR285.js";import{t as G}from"./WithPermissionGuard-B4Jo8E5-.js";import{t as K}from"./GraphsLayout-DJ-HI9N1.js";var q=U(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),J=U(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Y=e=>{let t=[],n=new Set,r=(e,t)=>`${e},${t}`,i=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)if(o>=2||n.has(r(o,e)))return!1;return!0},a=(e,t,i,a)=>{for(let o=e;o<e+i;o++)for(let e=t;e<t+a;e++)n.add(r(o,e))};for(let n of e){let{colSpan:e,rowSpan:r}=n,o=!1,s=0;for(;!o;){for(let c=0;c<=2-e;c++)if(i(c,s,e,r)){a(c,s,e,r),t.push({graphId:n.id,gridColumn:c,gridRow:s,colSpan:e,rowSpan:r}),o=!0;break}o||s++}}return t},X=e(t()),Z=C(),Q=[{value:`1x1`,label:`Small (1x1)`,colSpan:1,rowSpan:1},{value:`2x1`,label:`Wide (2x1)`,colSpan:2,rowSpan:1},{value:`1x2`,label:`Tall (1x2)`,colSpan:1,rowSpan:2},{value:`2x2`,label:`Large (2x2)`,colSpan:2,rowSpan:2}],ie=(e,t)=>e===2&&t===2?`2x2`:e===2&&t===1?`2x1`:e===1&&t===2?`1x2`:`1x1`;function ae({graphId:e,projectSlug:t,dashboardId:n,colSpan:i,rowSpan:a,onSizeChange:o,onDelete:s,isDeleting:c}){let l=B(),u=ie(i,a),d=`/${t}/analytics/custom/${e}${n?`?dashboard=${n}`:``}`;return(0,Z.jsxs)(y.Root,{children:[(0,Z.jsx)(y.Trigger,{asChild:!0,children:(0,Z.jsx)(w,{variant:`ghost`,loading:c,children:(0,Z.jsx)(p,{})})}),(0,Z.jsxs)(y.Content,{children:[(0,Z.jsxs)(y.Item,{value:`edit`,onClick:()=>{l.push(d)},children:[(0,Z.jsx)(r,{}),` Edit Graph`]}),(0,Z.jsxs)(y.Root,{positioning:{placement:`right-start`,gutter:2},children:[(0,Z.jsxs)(y.TriggerItem,{value:`size`,children:[(0,Z.jsx)(J,{}),` Size (`,u,`)`]}),(0,Z.jsx)(y.Content,{children:Q.map(e=>(0,Z.jsxs)(y.Item,{value:e.value,onClick:()=>o(e.value),children:[e.label,e.value===u&&` ✓`]},e.value))})]}),(0,Z.jsxs)(y.Item,{value:`delete`,color:`red.600`,onClick:s,children:[(0,Z.jsx)(S,{}),` Delete Graph`]})]})]})}function oe({filters:e}){return(0,Z.jsx)(E,{content:(0,Z.jsx)(L,{align:`start`,backgroundColor:`black`,color:`white`,height:`100%`,textWrap:`wrap`,children:(0,Z.jsx)(z,{filters:e})}),positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,children:(0,Z.jsx)(q,{width:16,style:{minWidth:16}})})})}function se({graphId:e,name:t,graph:n,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,filters:s,trigger:c,isDragging:l,dragAttributes:u,dragListeners:d,onSizeChange:f,onDelete:p,isDeleting:m}){let{openDrawer:h}=b(),v=(0,X.useMemo)(()=>{if(t&&t.trim())return t;if(n&&typeof n==`object`&&`series`in n){let e=n;if(e.series&&e.series.length>0){let t=e.series.map(e=>e.name).filter(Boolean).join(`, `);if(t)return t.replace(/,([^,]*)$/,` and$1`)}}return`Untitled Graph`},[t,n]),y=H({defaultValues:n?{...g(n),title:v}:void 0});(0,X.useEffect)(()=>{n&&y.setValue(`title`,v)},[v,y,n]);let x=(0,X.useMemo)(()=>!!(s&&typeof s==`object`&&Object.keys(s).length>0),[s]),S=!!(e&&e!==`custom`&&n);return(0,Z.jsxs)(A,{...u,...d,align:`center`,marginBottom:4,cursor:l?`grabbing`:`grab`,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(O,{size:`sm`,marginLeft:2,children:v}),(0,Z.jsx)(re,{}),S&&(0,Z.jsx)(Z.Fragment,{children:c?.active?(0,Z.jsx)(E,{content:`Alert configured (${c.alertType??`INFO`})`,positioning:{placement:`top`},showArrow:!0,children:(0,Z.jsx)(T,{padding:1,cursor:`pointer`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:(0,Z.jsx)(_,{width:18,color:`black`})})}):(0,Z.jsxs)(w,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t=>{t.stopPropagation(),h(`customGraphAlert`,{form:y,graphId:e})},children:[(0,Z.jsx)(_,{width:16}),`Add alert`]})}),x&&(0,Z.jsx)(oe,{filters:s}),(0,Z.jsx)(ae,{graphId:e,projectSlug:r,dashboardId:i,colSpan:a,rowSpan:o,onSizeChange:f,onDelete:p,isDeleting:m})]})}function ce({graph:e,projectSlug:t,dashboardId:r,onDelete:i,onSizeChange:a,isDeleting:o}){let{attributes:c,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=n({id:e.id}),h={transform:l.Transform.toString(f),transition:p,opacity:m?.5:1,gridColumn:`span ${e.colSpan}`,gridRow:`span ${e.rowSpan}`},g=e.rowSpan===2?600:300;return(0,Z.jsx)(T,{ref:d,style:h,minWidth:0,children:(0,Z.jsx)(F,{height:`full`,minWidth:0,children:(0,Z.jsxs)(I,{height:`full`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,children:[(0,Z.jsx)(se,{graphId:e.id,name:e.name,graph:e.graph,projectSlug:t,dashboardId:r,colSpan:e.colSpan,rowSpan:e.rowSpan,filters:e.filters,trigger:e.trigger,isDragging:m,dragAttributes:c,dragListeners:u,onSizeChange:a,onDelete:i,isDeleting:o}),(0,Z.jsx)(T,{flex:1,minHeight:0,children:(0,Z.jsx)(s,{input:{...e.graph,height:g},filters:e.filters},e.id)})]})})})}function le({graphs:e,projectSlug:t,dashboardId:n,onGraphDelete:r,onGraphSizeChange:a,onGraphsReorder:s,deletingGraphId:l}){let[p,g]=(0,X.useState)(null),_=e.find(e=>e.id===p),v=c(o(d,{activationConstraint:{distance:8}}));return(0,Z.jsxs)(m,{sensors:v,collisionDetection:f,onDragStart:e=>{g(e.active.id)},onDragEnd:t=>{g(null);let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.findIndex(e=>e.id===n.id),a=e.findIndex(e=>e.id===r.id);if(i!==-1&&a!==-1){let t=[...e],[n]=t.splice(i,1);t.splice(a,0,n),s(Y(t))}},children:[(0,Z.jsx)(i,{items:e.map(e=>e.id),strategy:h,children:(0,Z.jsx)(te,{templateColumns:`repeat(2, 1fr)`,autoRows:`minmax(350px, auto)`,gap:5,width:`100%`,children:e.map(e=>(0,Z.jsx)(ce,{graph:e,projectSlug:t,dashboardId:n,onDelete:()=>r(e.id),onSizeChange:t=>a(e.id,t),isDeleting:l===e.id},e.id))})}),(0,Z.jsx)(u,{children:_?(0,Z.jsx)(F,{boxShadow:`xl`,opacity:.9,width:_.colSpan===2?`600px`:`300px`,height:_.rowSpan===2?`400px`:`200px`,children:(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(A,{align:`center`,marginBottom:4,children:[(0,Z.jsx)(W,{color:`orange`}),(0,Z.jsx)(k,{marginLeft:2,fontSize:`md`,fontWeight:`bold`,children:_.name})]}),(0,Z.jsx)(T,{flex:1,background:`gray.50`,borderRadius:`md`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`fg.subtle`,height:`calc(100% - 40px)`,children:`Chart preview`})]})}):null})]})}function $(){let{project:e}=V(),{showFilters:t}=v(),n=B(),r=e?.id??``,i=n.query.dashboard,o=R.dashboards.getOrCreateFirst.useQuery({projectId:r},{enabled:!!r&&!i}),s=i??o.data?.id,c=R.dashboards.getAll.useQuery({projectId:r},{enabled:!!r}),l=c.data?.find(e=>e.id===s)?.name??`Reports`,u=R.graphs.getAll.useQuery({projectId:r,dashboardId:s},{enabled:!!r&&!!s}),d=R.graphs.delete.useMutation(),f=R.graphs.updateLayout.useMutation(),p=R.graphs.batchUpdateLayouts.useMutation(),m=R.dashboards.rename.useMutation(),h=e=>{s&&m.mutate({projectId:r,dashboardId:s,name:e},{onSuccess:()=>{c.refetch()},onError:()=>{D.create({title:`Error renaming dashboard`,type:`error`,duration:3e3,meta:{closable:!0}})}})},g=e=>{d.mutate({projectId:r,id:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error deleting graph`,type:`error`,duration:3e3,meta:{closable:!0}})}})},_=(e,t)=>{let n=Q.find(e=>e.value===t);if(!n)return;let i=u.data?.find(t=>t.id===e);i&&f.mutate({projectId:r,graphId:e,gridColumn:i.gridColumn,gridRow:i.gridRow,colSpan:n.colSpan,rowSpan:n.rowSpan},{onSuccess:()=>{let t=u.data?.map(t=>t.id===e?{...t,colSpan:n.colSpan,rowSpan:n.rowSpan}:t);if(t){let e=Y(t);p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()}})}},onError:()=>{D.create({title:`Error updating graph size`,type:`error`,duration:3e3,meta:{closable:!0}})}})},y=e=>{p.mutate({projectId:r,layouts:e},{onSuccess:()=>{u.refetch()},onError:()=>{D.create({title:`Error reordering graphs`,type:`error`,duration:3e3,meta:{closable:!0}})}})},b=u.data??[],S=b.length===0&&!u.isLoading,C=s?`/${e?.slug}/analytics/custom?dashboard=${s}`:`/${e?.slug}/analytics/custom`;return(0,Z.jsxs)(K,{title:l,analyticsHeaderProps:{isEditable:!0,onTitleSave:h},extraHeaderButtons:e?(0,Z.jsx)(ne,{href:C,asChild:!0,children:(0,Z.jsxs)(w,{colorPalette:`orange`,size:`sm`,children:[(0,Z.jsx)(a,{}),` Add chart`]})}):null,children:[S&&(0,Z.jsxs)(M,{status:`info`,borderStartWidth:`4px`,borderStartColor:`colorPalette.solid`,marginBottom:6,children:[(0,Z.jsx)(P,{alignSelf:`start`}),(0,Z.jsxs)(L,{align:`start`,children:[(0,Z.jsx)(j,{children:`Add your custom graphs here`}),(0,Z.jsx)(N,{children:(0,Z.jsxs)(k,{as:`span`,children:[`You haven`,`'`,`t set up any custom graphs yet. Click + Add chart to get started.`]})})]})]}),(0,Z.jsxs)(A,{align:`start`,gap:6,width:`full`,children:[(0,Z.jsx)(T,{flex:1,children:u.isLoading?(0,Z.jsx)(ee,{height:`300px`}):(0,Z.jsx)(le,{graphs:b,projectSlug:e?.slug??``,dashboardId:s??void 0,onGraphDelete:g,onGraphSizeChange:_,onGraphsReorder:y,deletingGraphId:d.isLoading?d.variables?.id??null:null})}),t?(0,Z.jsx)(x,{}):null]})]})}var ue=G(`analytics:view`)($);export{ue as default};
2
+ //# sourceMappingURL=reports-vlrcTrLs.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Bo as n,Da as r,Js as i,Ks as a,Xr as o,cc as s,gs as c,ls as l,qs as u,ts as d,wa as f,yo as p}from"./command-bar-CaJygoez.js";import{j as m,n as h,r as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{t as ee}from"./tooltip-AEm0YeiF.js";import{n as v,r as y}from"./toaster-C_DYALhL.js";import{Qt as te,Zt as ne,an as b,f as x}from"./dist-SwV3YZv3.js";import{c as S,h as C,n as w}from"./terminal-CfM0q99k.js";import{t as T}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{a as D,n as O,r as k,t as A}from"./field-CnUiixMS.js";import{t as j}from"./input-C7emsUCL.js";import{t as M}from"./h-stack-BKLDJ2vg.js";import{a as N,i as P,n as F,r as I,t as L}from"./alert-SnQmACl1.js";import{n as R,r as z,t as B}from"./card-CMtKVPVl.js";import{t as V}from"./v-stack-EOPQ57OZ.js";import{m as H,s as U}from"./auth-client-D3UhxhQi.js";import{c as W,i as re,n as G,r as K,t as ie}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as ae}from"./index.esm-X7lxUoP1.js";import{t as oe}from"./createLucideIcon-BJKFyRLS.js";import{n as se,t as q}from"./SettingsLayout-CLCGxMAe.js";import{t as ce}from"./ContactSalesBlock-CijLBwRC.js";import{t as le}from"./WithPermissionGuard-DD8uo3UK.js";var ue=oe(`shield-user`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]),J=e(t()),Y=W(),X=[K.TRACES,K.COST,K.SCENARIOS,K.ANNOTATIONS,K.ANALYTICS,K.EVALUATIONS,K.DATASETS,K.TRIGGERS,K.WORKFLOWS,K.PROMPTS,K.SECRETS,K.AUDIT_LOG,K.TEAM,K.PROJECT];function Z(e){return e===K.COST?[G.VIEW]:e===K.TRACES?[G.VIEW,G.SHARE]:e===K.SECRETS?[G.VIEW,G.MANAGE]:e===K.SCENARIOS||e===K.AUDIT_LOG?[G.VIEW]:[G.MANAGE,G.VIEW,G.CREATE,G.UPDATE,G.DELETE]}var Q=m();function de({permissions:e}){let t=(e,t)=>`${e}:${t}`,n={};return X.forEach(e=>{n[e]=Z(e).map(n=>t(e,n))}),(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(n).map(n=>{let r=Z(n);if(!r.some(t=>e.includes(`${n}:${t}`)))return null;let i=r.filter(t=>e.includes(`${n}:${t}`)),a=i.includes(`manage`)?i.filter(e=>e===`manage`||e===`share`):i;return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,textTransform:`capitalize`,fontSize:`md`,children:n}),(0,Q.jsx)(V,{align:`start`,gap:1.5,paddingLeft:4,width:`full`,children:a.map(e=>{let r=t(n,e),i=e===`manage`?`Manage (Create, Update, Delete)`:e.charAt(0).toUpperCase()+e.slice(1);return(0,Q.jsxs)(M,{gap:2,align:`center`,children:[(0,Q.jsx)(l,{size:14,color:`var(--chakra-colors-green-500)`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg`,children:i})]},r)})})]}),(0,Q.jsx)(C,{marginY:3})]},n)})})}function $({name:e,description:t,permissionCount:n,isDefault:i=!1,icon:a=w,onDelete:o,onEdit:s,onViewPermissions:c,hasPermission:l}){let u=l(`organization:manage`);return(0,Q.jsxs)(z,{width:`100%`,height:`100%`,borderWidth:`1px`,borderColor:`border`,_hover:c?{borderColor:`orange.400`,shadow:`md`}:{},transition:`all 0.2s`,display:`flex`,flexDirection:`column`,cursor:c&&u?`pointer`:`default`,onClick:c&&u?c:void 0,position:`relative`,children:[!i&&(0,Q.jsxs)(M,{gap:1,onClick:e=>e.stopPropagation(),position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,children:[c&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`blue`,onClick:e=>{e.stopPropagation(),c()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(S,{size:14})}),s&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`orange`,onClick:e=>{e.stopPropagation(),s()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(r,{size:14})}),o&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`red`,onClick:e=>{e.stopPropagation(),o()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(f,{size:14})})]}),(0,Q.jsx)(R,{children:(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsxs)(M,{children:[(0,Q.jsx)(a,{size:18}),(0,Q.jsx)(E,{fontWeight:`semibold`,children:e})]}),i&&(0,Q.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Built-in Role`})]})}),(0,Q.jsx)(B,{paddingTop:0,flex:1,display:`flex`,flexDirection:`column`,children:(0,Q.jsxs)(V,{align:`start`,gap:2,flex:1,width:`full`,justifyContent:`space-between`,children:[(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:t}),i?(0,Q.jsx)(b,{colorPalette:`orange`,size:`sm`,children:n}):(0,Q.jsx)(E,{fontSize:`xs`,color:`orange.fg`,fontWeight:`medium`,children:n})]})})]})}function fe({selectedPermissions:e,onChange:t}){let n=(e,t)=>`${e}:${t}`,r=(0,J.useMemo)(()=>{let e={};return X.forEach(t=>{e[t]=Z(t).map(e=>n(t,e))}),e},[]),o=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[n,i]=e.split(`:`);if(i===`view`){let n=r[t]||[],i=[`create`,`update`,`delete`];return[e,...n.filter(e=>i.some(t=>e.endsWith(`:${t}`)))]}return[e]},s=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[i,a]=e.split(`:`);return a===`create`||a===`update`||a===`delete`?[e,n(t,`view`)]:[e]},c=n=>{let[r]=n.split(`:`),i=o(n,r);t(e.filter(e=>!i.includes(e)))},l=n=>{let[r]=n.split(`:`),i=s(n,r);t([...e,...i.filter(t=>!e.includes(t))])},d=t=>{let[r,i]=t.split(`:`),a=n(r,`manage`),o=e.includes(a);e.includes(t)||o&&i!==`manage`?c(t):l(t)};return(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(r).map(t=>{let r=Z(t);return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(i,{children:[(0,Q.jsx)(u,{fontSize:`sm`,fontWeight:`semibold`,textTransform:`capitalize`,marginBottom:2,children:(0,Q.jsx)(E,{children:t})}),(0,Q.jsx)(a,{children:(0,Q.jsx)(M,{gap:4,flexWrap:`wrap`,paddingLeft:6,children:r.map(r=>{let i=n(t,r),a=e.includes(i),o=n(t,`manage`),s=e.includes(o),c=r!==`manage`&&s;return(0,Q.jsx)(p,{checked:a||c,onChange:()=>{d(c?o:i)},opacity:c?.6:1,cursor:c?`not-allowed`:`pointer`,children:r===`manage`?(0,Q.jsx)(ee,{content:`Manage includes all permissions (view, create, update, delete) for this resource`,positioning:{placement:`top`},showArrow:!0,children:(0,Q.jsxs)(M,{gap:1,children:[(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r}),(0,Q.jsx)(_,{color:`fg.muted`,children:(0,Q.jsx)(y,{size:14})})]})}):(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r})},i)})})})]}),(0,Q.jsx)(C,{marginY:3})]},t)})})}function pe({open:e,onClose:t,onSubmit:n,initialData:r,title:i,submitLabel:a=`Create Role`,isSubmitting:o=!1}){let{register:s,handleSubmit:l,reset:u,formState:{errors:d},setValue:f,watch:p}=ae({defaultValues:{name:r?.name??``,description:r?.description??``,permissions:r?.permissions??[]}}),m=p(`permissions`)||[];(0,J.useEffect)(()=>{r?(f(`name`,r.name),f(`description`,r.description),f(`permissions`,r.permissions)):u({name:``,description:``,permissions:[]})},[r,f,u]);let g=l(async e=>{await n(e),r||u()});return(0,Q.jsx)(x.Root,{open:e,onOpenChange:({open:e})=>!e&&t(),children:(0,Q.jsxs)(x.Content,{maxWidth:`900px`,maxHeight:`90vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsx)(x.Title,{children:i})}),(0,Q.jsx)(x.Body,{children:(0,Q.jsx)(`form`,{id:`role-form`,onSubmit:e=>void g(e),children:(0,Q.jsxs)(V,{gap:6,align:`start`,children:[(0,Q.jsxs)(D,{invalid:!!d.name,children:[(0,Q.jsxs)(k,{children:[`Role Name`,` `,(0,Q.jsx)(E,{as:`span`,color:`red.500`,children:`*`})]}),(0,Q.jsx)(j,{...s(`name`,{required:`Role name is required`}),placeholder:`e.g., Data Analyst`}),d.name&&(0,Q.jsx)(A,{children:d.name.message})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(k,{children:`Description`}),(0,Q.jsx)(O,{children:`Describe what this role is for`}),(0,Q.jsx)(c,{...s(`description`),placeholder:`e.g., Can view and analyze data but cannot modify settings`,rows:3})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsx)(T,{size:`sm`,children:`Permissions`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:`Select the permissions this role should have`}),(0,Q.jsx)(fe,{selectedPermissions:m,onChange:e=>f(`permissions`,e)})]})]})})}),(0,Q.jsxs)(x.Footer,{children:[(0,Q.jsx)(h,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(h,{type:`submit`,form:`role-form`,colorPalette:`orange`,loading:o,children:a})]}),(0,Q.jsx)(x.CloseTrigger,{})]})})}function me(){let{organization:e,hasPermission:t}=ie(),{isEnterprise:n,isLoading:r}=se();return!e||r?(0,Q.jsx)(q,{children:(0,Q.jsx)(V,{align:`center`,justify:`center`,width:`full`,height:`200px`,children:(0,Q.jsx)(g,{})})}):n?(0,Q.jsx)(q,{children:(0,Q.jsx)(ge,{organizationId:e.id,hasPermission:t})}):(0,Q.jsx)(q,{children:(0,Q.jsxs)(V,{gap:6,width:`full`,align:`start`,children:[(0,Q.jsxs)(P,{status:`info`,children:[(0,Q.jsx)(I,{}),(0,Q.jsxs)(L,{children:[(0,Q.jsx)(N,{children:`Enterprise Feature`}),(0,Q.jsx)(F,{children:`Custom roles are available on Enterprise plans. Contact sales to upgrade.`})]})]}),(0,Q.jsx)(_,{width:`full`,children:(0,Q.jsx)(ce,{})})]})})}var he=le(`organization:view`,{layoutComponent:q})(me);function ge({organizationId:e,hasPermission:t}){let{open:r,onOpen:i,onClose:a}=s(),{open:c,onOpen:l,onClose:u}=s(),{open:f,onOpen:p,onClose:m}=s(),{open:y,onOpen:b,onClose:S}=s(),[w,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(null),N=U.useContext(),P=U.role.getAll.useQuery({organizationId:e}),F=U.role.create.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role created successfully`,type:`success`}),a()},onError:e=>{H(e)||v.create({title:`Failed to create role`,description:e.message,type:`error`})}}),I=U.role.delete.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role deleted successfully`,type:`success`})},onError:e=>{H(e)||v.create({title:`Failed to delete role`,description:e.message,type:`error`})}}),L=U.role.update.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role updated successfully`,type:`success`}),u(),D(null)},onError:e=>{H(e)||v.create({title:`Failed to update role`,description:e.message,type:`error`})}}),R=async e=>{try{let t=await N.role.getById.fetch({roleId:e});D({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),l()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for editing`,type:`error`})}},W=async e=>{try{let t=await N.role.getById.fetch({roleId:e});k({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),p()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for viewing`,type:`error`})}},G=(e,t)=>{let n=re(t);j({name:e,description:K(e),permissions:n}),b()},K=e=>{switch(e){case`Admin`:return`Full access to all features and settings`;case`Member`:return`Can create and modify most resources, view costs and debug info`;case`Viewer`:return`Read-only access to analytics, messages, and guardrails`;default:return``}};return(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:6,children:[(0,Q.jsxs)(M,{justify:`space-between`,width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsx)(T,{as:`h2`,children:`Roles & Permissions`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Create custom roles and assign specific permissions to control access`})]}),(0,Q.jsx)(ee,{content:`You need organization:manage permissions to create roles.`,disabled:t(`organization:manage`),children:(0,Q.jsxs)(o.HeaderButton,{onClick:i,disabled:!t(`organization:manage`),children:[(0,Q.jsx)(te,{size:16}),` Create Role`]})})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Default Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`These are the built-in roles that cannot be modified or deleted.`})]}),(0,Q.jsxs)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:[(0,Q.jsx)($,{hasPermission:t,name:`Admin`,description:`Full access to all features and settings`,isDefault:!0,permissionCount:`All Permissions`,icon:ue,onViewPermissions:()=>G(`Admin`,Y.TeamUserRole.ADMIN)}),(0,Q.jsx)($,{hasPermission:t,name:`Member`,description:`Can create and modify most resources, view costs and debug info`,isDefault:!0,permissionCount:`Most Permissions`,icon:n,onViewPermissions:()=>G(`Member`,Y.TeamUserRole.MEMBER)}),(0,Q.jsx)($,{hasPermission:t,name:`Viewer`,description:`Read-only access to analytics, messages, and guardrails`,isDefault:!0,permissionCount:`View Only`,icon:d,onViewPermissions:()=>G(`Viewer`,Y.TeamUserRole.VIEWER)})]})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Custom Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Custom roles created for your organization with specific permission sets.`})]}),P.isLoading&&(0,Q.jsx)(V,{align:`center`,width:`full`,padding:8,children:(0,Q.jsx)(g,{})}),P.data&&P.data.length===0&&(0,Q.jsx)(z,{width:`full`,children:(0,Q.jsx)(B,{textAlign:`center`,padding:8,children:(0,Q.jsxs)(V,{gap:2,children:[(0,Q.jsx)(ne,{size:48,color:`gray`}),(0,Q.jsx)(E,{color:`fg.muted`,children:`No custom roles yet. Create your first custom role to get started.`})]})})}),(0,Q.jsx)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:P.data?.map(e=>(0,Q.jsx)($,{name:e.name,description:e.description??``,permissionCount:`${e.permissions.length} permissions`,hasPermission:t,onDelete:()=>{confirm(`Are you sure you want to delete the role "${e.name}"?`)&&I.mutate({roleId:e.id})},onEdit:()=>{R(e.id)},onViewPermissions:()=>{W(e.id)}},e.id))})]}),(0,Q.jsx)(pe,{open:r,onClose:a,onSubmit:async t=>{await F.mutateAsync({organizationId:e,name:t.name,description:t.description,permissions:t.permissions})},title:`Create Custom Role`,submitLabel:`Create Role`,isSubmitting:F.isLoading}),(0,Q.jsx)(pe,{open:c,onClose:()=>{u(),D(null)},onSubmit:async e=>{w&&await L.mutateAsync({roleId:w.id,name:e.name,description:e.description,permissions:e.permissions})},initialData:w?{name:w.name,description:w.description,permissions:w.permissions}:void 0,title:`Edit Role`,submitLabel:`Update Role`,isSubmitting:L.isLoading}),(0,Q.jsx)(x.Root,{open:f,onOpenChange:({open:e})=>!e&&m(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,O?.name]})}),(0,Q.jsx)(x.Body,{children:O&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:O.description||`No description provided`})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,O.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:O.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:m,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})}),(0,Q.jsx)(x.Root,{open:y,onOpenChange:({open:e})=>!e&&S(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,A?.name]})}),(0,Q.jsx)(x.Body,{children:A&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:A.description})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,A.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:A.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:S,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})})]})}export{he as default};
2
- //# sourceMappingURL=roles-B_0t5DWA.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Bo as n,Da as r,Js as i,Ks as a,Xr as o,cc as s,gs as c,ls as l,qs as u,ts as d,wa as f,yo as p}from"./command-bar-DUK45yin.js";import{j as m,n as h,r as g}from"./stack-oJ9iWdbl.js";import{t as _}from"./box-BsM8YLGl.js";import{t as ee}from"./tooltip-AEm0YeiF.js";import{n as v,r as y}from"./toaster-C_DYALhL.js";import{Qt as te,Zt as ne,an as b,f as x}from"./dist-Cds4Mqhj.js";import{c as S,h as C,n as w}from"./terminal-CfM0q99k.js";import{t as T}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{a as D,n as O,r as k,t as A}from"./field-CnUiixMS.js";import{t as j}from"./input-C7emsUCL.js";import{t as M}from"./h-stack-BKLDJ2vg.js";import{a as N,i as P,n as F,r as I,t as L}from"./alert-SnQmACl1.js";import{n as R,r as z,t as B}from"./card-CMtKVPVl.js";import{t as V}from"./v-stack-EOPQ57OZ.js";import{m as H,s as U}from"./auth-client-D3UhxhQi.js";import{c as W,i as re,n as G,r as K,t as ie}from"./useOrganizationTeamProject-DC0iozx2.js";import{s as ae}from"./index.esm-X7lxUoP1.js";import{t as oe}from"./createLucideIcon-BJKFyRLS.js";import{n as se,t as q}from"./SettingsLayout--1gdEuhv.js";import{t as ce}from"./ContactSalesBlock-CnnuZ8iI.js";import{t as le}from"./WithPermissionGuard-B4Jo8E5-.js";var ue=oe(`shield-user`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]),J=e(t()),Y=W(),X=[K.TRACES,K.COST,K.SCENARIOS,K.ANNOTATIONS,K.ANALYTICS,K.EVALUATIONS,K.DATASETS,K.TRIGGERS,K.WORKFLOWS,K.PROMPTS,K.SECRETS,K.AUDIT_LOG,K.TEAM,K.PROJECT];function Z(e){return e===K.COST?[G.VIEW]:e===K.TRACES?[G.VIEW,G.SHARE]:e===K.SECRETS?[G.VIEW,G.MANAGE]:e===K.SCENARIOS||e===K.AUDIT_LOG?[G.VIEW]:[G.MANAGE,G.VIEW,G.CREATE,G.UPDATE,G.DELETE]}var Q=m();function de({permissions:e}){let t=(e,t)=>`${e}:${t}`,n={};return X.forEach(e=>{n[e]=Z(e).map(n=>t(e,n))}),(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(n).map(n=>{let r=Z(n);if(!r.some(t=>e.includes(`${n}:${t}`)))return null;let i=r.filter(t=>e.includes(`${n}:${t}`)),a=i.includes(`manage`)?i.filter(e=>e===`manage`||e===`share`):i;return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,textTransform:`capitalize`,fontSize:`md`,children:n}),(0,Q.jsx)(V,{align:`start`,gap:1.5,paddingLeft:4,width:`full`,children:a.map(e=>{let r=t(n,e),i=e===`manage`?`Manage (Create, Update, Delete)`:e.charAt(0).toUpperCase()+e.slice(1);return(0,Q.jsxs)(M,{gap:2,align:`center`,children:[(0,Q.jsx)(l,{size:14,color:`var(--chakra-colors-green-500)`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg`,children:i})]},r)})})]}),(0,Q.jsx)(C,{marginY:3})]},n)})})}function $({name:e,description:t,permissionCount:n,isDefault:i=!1,icon:a=w,onDelete:o,onEdit:s,onViewPermissions:c,hasPermission:l}){let u=l(`organization:manage`);return(0,Q.jsxs)(z,{width:`100%`,height:`100%`,borderWidth:`1px`,borderColor:`border`,_hover:c?{borderColor:`orange.400`,shadow:`md`}:{},transition:`all 0.2s`,display:`flex`,flexDirection:`column`,cursor:c&&u?`pointer`:`default`,onClick:c&&u?c:void 0,position:`relative`,children:[!i&&(0,Q.jsxs)(M,{gap:1,onClick:e=>e.stopPropagation(),position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,children:[c&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`blue`,onClick:e=>{e.stopPropagation(),c()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(S,{size:14})}),s&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`orange`,onClick:e=>{e.stopPropagation(),s()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(r,{size:14})}),o&&(0,Q.jsx)(h,{size:`sm`,variant:`ghost`,colorPalette:`red`,onClick:e=>{e.stopPropagation(),o()},disabled:!l(`organization:manage`),children:(0,Q.jsx)(f,{size:14})})]}),(0,Q.jsx)(R,{children:(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsxs)(M,{children:[(0,Q.jsx)(a,{size:18}),(0,Q.jsx)(E,{fontWeight:`semibold`,children:e})]}),i&&(0,Q.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Built-in Role`})]})}),(0,Q.jsx)(B,{paddingTop:0,flex:1,display:`flex`,flexDirection:`column`,children:(0,Q.jsxs)(V,{align:`start`,gap:2,flex:1,width:`full`,justifyContent:`space-between`,children:[(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:t}),i?(0,Q.jsx)(b,{colorPalette:`orange`,size:`sm`,children:n}):(0,Q.jsx)(E,{fontSize:`xs`,color:`orange.fg`,fontWeight:`medium`,children:n})]})})]})}function fe({selectedPermissions:e,onChange:t}){let n=(e,t)=>`${e}:${t}`,r=(0,J.useMemo)(()=>{let e={};return X.forEach(t=>{e[t]=Z(t).map(e=>n(t,e))}),e},[]),o=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[n,i]=e.split(`:`);if(i===`view`){let n=r[t]||[],i=[`create`,`update`,`delete`];return[e,...n.filter(e=>i.some(t=>e.endsWith(`:${t}`)))]}return[e]},s=(e,t)=>{if(e.endsWith(`:manage`))return r[t]||[];let[i,a]=e.split(`:`);return a===`create`||a===`update`||a===`delete`?[e,n(t,`view`)]:[e]},c=n=>{let[r]=n.split(`:`),i=o(n,r);t(e.filter(e=>!i.includes(e)))},l=n=>{let[r]=n.split(`:`),i=s(n,r);t([...e,...i.filter(t=>!e.includes(t))])},d=t=>{let[r,i]=t.split(`:`),a=n(r,`manage`),o=e.includes(a);e.includes(t)||o&&i!==`manage`?c(t):l(t)};return(0,Q.jsx)(V,{align:`start`,width:`full`,gap:4,children:Object.keys(r).map(t=>{let r=Z(t);return(0,Q.jsxs)(_,{width:`full`,children:[(0,Q.jsxs)(i,{children:[(0,Q.jsx)(u,{fontSize:`sm`,fontWeight:`semibold`,textTransform:`capitalize`,marginBottom:2,children:(0,Q.jsx)(E,{children:t})}),(0,Q.jsx)(a,{children:(0,Q.jsx)(M,{gap:4,flexWrap:`wrap`,paddingLeft:6,children:r.map(r=>{let i=n(t,r),a=e.includes(i),o=n(t,`manage`),s=e.includes(o),c=r!==`manage`&&s;return(0,Q.jsx)(p,{checked:a||c,onChange:()=>{d(c?o:i)},opacity:c?.6:1,cursor:c?`not-allowed`:`pointer`,children:r===`manage`?(0,Q.jsx)(ee,{content:`Manage includes all permissions (view, create, update, delete) for this resource`,positioning:{placement:`top`},showArrow:!0,children:(0,Q.jsxs)(M,{gap:1,children:[(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r}),(0,Q.jsx)(_,{color:`fg.muted`,children:(0,Q.jsx)(y,{size:14})})]})}):(0,Q.jsx)(E,{fontSize:`sm`,textTransform:`capitalize`,children:r})},i)})})})]}),(0,Q.jsx)(C,{marginY:3})]},t)})})}function pe({open:e,onClose:t,onSubmit:n,initialData:r,title:i,submitLabel:a=`Create Role`,isSubmitting:o=!1}){let{register:s,handleSubmit:l,reset:u,formState:{errors:d},setValue:f,watch:p}=ae({defaultValues:{name:r?.name??``,description:r?.description??``,permissions:r?.permissions??[]}}),m=p(`permissions`)||[];(0,J.useEffect)(()=>{r?(f(`name`,r.name),f(`description`,r.description),f(`permissions`,r.permissions)):u({name:``,description:``,permissions:[]})},[r,f,u]);let g=l(async e=>{await n(e),r||u()});return(0,Q.jsx)(x.Root,{open:e,onOpenChange:({open:e})=>!e&&t(),children:(0,Q.jsxs)(x.Content,{maxWidth:`900px`,maxHeight:`90vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsx)(x.Title,{children:i})}),(0,Q.jsx)(x.Body,{children:(0,Q.jsx)(`form`,{id:`role-form`,onSubmit:e=>void g(e),children:(0,Q.jsxs)(V,{gap:6,align:`start`,children:[(0,Q.jsxs)(D,{invalid:!!d.name,children:[(0,Q.jsxs)(k,{children:[`Role Name`,` `,(0,Q.jsx)(E,{as:`span`,color:`red.500`,children:`*`})]}),(0,Q.jsx)(j,{...s(`name`,{required:`Role name is required`}),placeholder:`e.g., Data Analyst`}),d.name&&(0,Q.jsx)(A,{children:d.name.message})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(k,{children:`Description`}),(0,Q.jsx)(O,{children:`Describe what this role is for`}),(0,Q.jsx)(c,{...s(`description`),placeholder:`e.g., Can view and analyze data but cannot modify settings`,rows:3})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsx)(T,{size:`sm`,children:`Permissions`}),(0,Q.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:`Select the permissions this role should have`}),(0,Q.jsx)(fe,{selectedPermissions:m,onChange:e=>f(`permissions`,e)})]})]})})}),(0,Q.jsxs)(x.Footer,{children:[(0,Q.jsx)(h,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(h,{type:`submit`,form:`role-form`,colorPalette:`orange`,loading:o,children:a})]}),(0,Q.jsx)(x.CloseTrigger,{})]})})}function me(){let{organization:e,hasPermission:t}=ie(),{isEnterprise:n,isLoading:r}=se();return!e||r?(0,Q.jsx)(q,{children:(0,Q.jsx)(V,{align:`center`,justify:`center`,width:`full`,height:`200px`,children:(0,Q.jsx)(g,{})})}):n?(0,Q.jsx)(q,{children:(0,Q.jsx)(ge,{organizationId:e.id,hasPermission:t})}):(0,Q.jsx)(q,{children:(0,Q.jsxs)(V,{gap:6,width:`full`,align:`start`,children:[(0,Q.jsxs)(P,{status:`info`,children:[(0,Q.jsx)(I,{}),(0,Q.jsxs)(L,{children:[(0,Q.jsx)(N,{children:`Enterprise Feature`}),(0,Q.jsx)(F,{children:`Custom roles are available on Enterprise plans. Contact sales to upgrade.`})]})]}),(0,Q.jsx)(_,{width:`full`,children:(0,Q.jsx)(ce,{})})]})})}var he=le(`organization:view`,{layoutComponent:q})(me);function ge({organizationId:e,hasPermission:t}){let{open:r,onOpen:i,onClose:a}=s(),{open:c,onOpen:l,onClose:u}=s(),{open:f,onOpen:p,onClose:m}=s(),{open:y,onOpen:b,onClose:S}=s(),[w,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(null),N=U.useContext(),P=U.role.getAll.useQuery({organizationId:e}),F=U.role.create.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role created successfully`,type:`success`}),a()},onError:e=>{H(e)||v.create({title:`Failed to create role`,description:e.message,type:`error`})}}),I=U.role.delete.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role deleted successfully`,type:`success`})},onError:e=>{H(e)||v.create({title:`Failed to delete role`,description:e.message,type:`error`})}}),L=U.role.update.useMutation({onSuccess:()=>{N.role.getAll.invalidate(),v.create({title:`Role updated successfully`,type:`success`}),u(),D(null)},onError:e=>{H(e)||v.create({title:`Failed to update role`,description:e.message,type:`error`})}}),R=async e=>{try{let t=await N.role.getById.fetch({roleId:e});D({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),l()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for editing`,type:`error`})}},W=async e=>{try{let t=await N.role.getById.fetch({roleId:e});k({id:t.id,name:t.name,description:t.description??``,permissions:t.permissions}),p()}catch{v.create({title:`Failed to load role`,description:`Could not load role details for viewing`,type:`error`})}},G=(e,t)=>{let n=re(t);j({name:e,description:K(e),permissions:n}),b()},K=e=>{switch(e){case`Admin`:return`Full access to all features and settings`;case`Member`:return`Can create and modify most resources, view costs and debug info`;case`Viewer`:return`Read-only access to analytics, messages, and guardrails`;default:return``}};return(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:6,children:[(0,Q.jsxs)(M,{justify:`space-between`,width:`full`,children:[(0,Q.jsxs)(V,{align:`start`,gap:1,children:[(0,Q.jsx)(T,{as:`h2`,children:`Roles & Permissions`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Create custom roles and assign specific permissions to control access`})]}),(0,Q.jsx)(ee,{content:`You need organization:manage permissions to create roles.`,disabled:t(`organization:manage`),children:(0,Q.jsxs)(o.HeaderButton,{onClick:i,disabled:!t(`organization:manage`),children:[(0,Q.jsx)(te,{size:16}),` Create Role`]})})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Default Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`These are the built-in roles that cannot be modified or deleted.`})]}),(0,Q.jsxs)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:[(0,Q.jsx)($,{hasPermission:t,name:`Admin`,description:`Full access to all features and settings`,isDefault:!0,permissionCount:`All Permissions`,icon:ue,onViewPermissions:()=>G(`Admin`,Y.TeamUserRole.ADMIN)}),(0,Q.jsx)($,{hasPermission:t,name:`Member`,description:`Can create and modify most resources, view costs and debug info`,isDefault:!0,permissionCount:`Most Permissions`,icon:n,onViewPermissions:()=>G(`Member`,Y.TeamUserRole.MEMBER)}),(0,Q.jsx)($,{hasPermission:t,name:`Viewer`,description:`Read-only access to analytics, messages, and guardrails`,isDefault:!0,permissionCount:`View Only`,icon:d,onViewPermissions:()=>G(`Viewer`,Y.TeamUserRole.VIEWER)})]})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,width:`full`,gap:4,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(T,{as:`h3`,children:`Custom Roles`}),(0,Q.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Custom roles created for your organization with specific permission sets.`})]}),P.isLoading&&(0,Q.jsx)(V,{align:`center`,width:`full`,padding:8,children:(0,Q.jsx)(g,{})}),P.data&&P.data.length===0&&(0,Q.jsx)(z,{width:`full`,children:(0,Q.jsx)(B,{textAlign:`center`,padding:8,children:(0,Q.jsxs)(V,{gap:2,children:[(0,Q.jsx)(ne,{size:48,color:`gray`}),(0,Q.jsx)(E,{color:`fg.muted`,children:`No custom roles yet. Create your first custom role to get started.`})]})})}),(0,Q.jsx)(_,{width:`full`,display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(300px, 1fr))`,gap:4,children:P.data?.map(e=>(0,Q.jsx)($,{name:e.name,description:e.description??``,permissionCount:`${e.permissions.length} permissions`,hasPermission:t,onDelete:()=>{confirm(`Are you sure you want to delete the role "${e.name}"?`)&&I.mutate({roleId:e.id})},onEdit:()=>{R(e.id)},onViewPermissions:()=>{W(e.id)}},e.id))})]}),(0,Q.jsx)(pe,{open:r,onClose:a,onSubmit:async t=>{await F.mutateAsync({organizationId:e,name:t.name,description:t.description,permissions:t.permissions})},title:`Create Custom Role`,submitLabel:`Create Role`,isSubmitting:F.isLoading}),(0,Q.jsx)(pe,{open:c,onClose:()=>{u(),D(null)},onSubmit:async e=>{w&&await L.mutateAsync({roleId:w.id,name:e.name,description:e.description,permissions:e.permissions})},initialData:w?{name:w.name,description:w.description,permissions:w.permissions}:void 0,title:`Edit Role`,submitLabel:`Update Role`,isSubmitting:L.isLoading}),(0,Q.jsx)(x.Root,{open:f,onOpenChange:({open:e})=>!e&&m(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,O?.name]})}),(0,Q.jsx)(x.Body,{children:O&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:O.description||`No description provided`})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,O.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:O.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:m,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})}),(0,Q.jsx)(x.Root,{open:y,onOpenChange:({open:e})=>!e&&S(),children:(0,Q.jsxs)(x.Content,{maxWidth:`600px`,maxHeight:`80vh`,overflowY:`auto`,children:[(0,Q.jsx)(x.Header,{children:(0,Q.jsxs)(x.Title,{children:[`View Permissions - `,A?.name]})}),(0,Q.jsx)(x.Body,{children:A&&(0,Q.jsxs)(V,{gap:4,align:`start`,children:[(0,Q.jsxs)(V,{align:`start`,gap:2,width:`full`,children:[(0,Q.jsx)(E,{fontWeight:`semibold`,children:`Description:`}),(0,Q.jsx)(E,{color:`fg.muted`,children:A.description})]}),(0,Q.jsx)(C,{}),(0,Q.jsxs)(V,{align:`start`,gap:3,width:`full`,children:[(0,Q.jsxs)(E,{fontWeight:`semibold`,children:[`Permissions (`,A.permissions.length,`):`]}),(0,Q.jsx)(de,{permissions:A.permissions})]})]})}),(0,Q.jsx)(x.Footer,{children:(0,Q.jsx)(h,{variant:`outline`,onClick:S,children:`Close`})}),(0,Q.jsx)(x.CloseTrigger,{})]})})]})}export{he as default};
2
+ //# sourceMappingURL=roles-DNgi-NQ9.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,Ca as r,Co as i,Eo as a,Fa as o,Pa as s,Pr as c,Ss as l,To as u,Us as d,Ws as f,Xa as p,Xr as m,_s as h,ao as g,bs as _,do as v,et as y,fo as b,gs as x,ka as S,mn as C,nt as w,qi as T,r as E,ro as D,tt as O,vs as k,wo as A,xi as j,xs as M,yo as N,ys as P}from"./command-bar-CaJygoez.js";import{j as F,n as I,r as L}from"./stack-oJ9iWdbl.js";import{t as R}from"./box-BsM8YLGl.js";import{n as z}from"./toaster-C_DYALhL.js";import{f as B}from"./dist-SwV3YZv3.js";import{s as V}from"./terminal-CfM0q99k.js";import{t as ee}from"./heading-D90dlSnH.js";import{t as H}from"./text-CwTrMF8x.js";import{t as U}from"./icon-BwEPrfAc.js";import{t as W}from"./h-stack-BKLDJ2vg.js";import{Pt as te}from"./lu-Bf6j_N19.js";import{n as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as G}from"./v-stack-EOPQ57OZ.js";import{m as ie,s as K}from"./auth-client-D3UhxhQi.js";import{t as q}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as ae}from"./createLucideIcon-BJKFyRLS.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as se}from"./chevron-up-BvG6wkCS.js";import{t as ce}from"./WithPermissionGuard-DD8uo3UK.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as J}from"./lib-BYJUJC_x.js";var me=ae(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Y=e(t()),X=F();function he({allLabels:e,activeLabels:t,onToggle:n}){let r=t.length>0;return(0,X.jsxs)(u,{positioning:{placement:`bottom-start`},children:[(0,X.jsx)(a,{asChild:!0,children:(0,X.jsxs)(I,{size:`sm`,variant:r?`solid`:`outline`,colorPalette:r?`blue`:`gray`,children:[(0,X.jsx)(me,{size:14}),`Labels`,r&&(0,X.jsxs)(H,{as:`span`,fontSize:`xs`,ml:1,children:[`(`,t.length,`)`]})]})}),(0,X.jsx)(A,{width:`200px`,children:(0,X.jsx)(i,{children:e.length===0?(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`No labels available`}):(0,X.jsx)(G,{align:`stretch`,gap:2,children:e.map(e=>(0,X.jsxs)(W,{cursor:`pointer`,onClick:()=>n(e),children:[(0,X.jsx)(N,{checked:t.includes(e)}),(0,X.jsx)(H,{fontSize:`sm`,children:e})]},e))})})})]})}function ge({selectedCount:e,onArchive:t}){return e===0?null:(0,X.jsx)(R,{position:`fixed`,bottom:10,left:`50%`,transform:`translateX(-50%)`,backgroundColor:`#ffffff`,border:`1px solid #ccc`,boxShadow:`0 0 15px rgba(0, 0, 0, 0.2)`,borderRadius:`md`,padding:`8px`,paddingX:`16px`,zIndex:1e3,"data-testid":`batch-action-bar`,children:(0,X.jsxs)(W,{gap:3,children:[(0,X.jsxs)(H,{whiteSpace:`nowrap`,fontSize:`sm`,fontWeight:`medium`,children:[e,` selected`]}),(0,X.jsxs)(I,{size:`sm`,variant:`outline`,colorPalette:`orange`,onClick:t,children:[(0,X.jsx)(v,{size:14}),`Archive`]})]})})}function _e({open:e,onClose:t,onConfirm:n,scenarios:r,isLoading:i=!1}){let a=r.length>1,o=a?`Archive ${r.length} scenarios?`:`Archive scenario?`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:t,placement:`center`,children:(0,X.jsxs)(B.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{fontSize:`md`,fontWeight:`500`,children:o})}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[a?(0,X.jsx)(f,{paddingLeft:4,children:r.map(e=>(0,X.jsx)(d,{fontSize:`sm`,children:e.name},e.id))}):r[0]&&(0,X.jsx)(H,{children:(0,X.jsx)(H,{as:`span`,fontWeight:`semibold`,children:r[0].name})}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`Archived scenarios will no longer appear in the library.`})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(I,{variant:`outline`,mr:3,onClick:e=>{e.stopPropagation(),t()},disabled:i,children:`Cancel`}),(0,X.jsx)(I,{colorPalette:`orange`,onClick:e=>{e.stopPropagation(),n()},disabled:i,children:i?(0,X.jsx)(L,{size:`sm`}):`Archive`})]})]})})}var ve=`Describe your scenario. What does your agent do? What situation do you want to test?`,ye=`Generating...`,be=6e4;function xe({open:e,onClose:t,title:n,placeholder:r=ve,exampleTemplates:i,onGenerate:a,onSkip:o,generatingText:s=ye,hasModelProviders:c=!0}){let[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`idle`),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,Y.useEffect)(()=>{e&&(u(``),f(`idle`),m(``))},[e]);let g=(0,Y.useCallback)(e=>{u(e.target.value)},[]),_=(0,Y.useCallback)(e=>{u(e)},[]),v=(0,Y.useCallback)(async()=>{if(!l.trim())return;let e=a(l);if(!e)return;f(`generating`),m(``);let t=new Promise((e,t)=>{h.current=setTimeout(()=>{t(Error(`Generation timed out. Please try again.`))},be)});try{await Promise.race([e,t])}catch(e){f(`error`),m(e instanceof Error?e.message:`An unexpected error occurred`)}finally{h.current&&=(clearTimeout(h.current),null)}},[l,a]),y=(0,Y.useCallback)(()=>{v()},[v]),b=(0,Y.useCallback)(()=>{o()},[o]),x=(0,Y.useCallback)(e=>{!e.open&&d!==`generating`&&t()},[d,t]),S=d!==`generating`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:x,children:(0,X.jsxs)(B.Content,{children:[S&&(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{children:n})}),(0,X.jsxs)(B.Body,{children:[!c&&(0,X.jsx)(De,{}),c&&d===`idle`&&(0,X.jsx)(Se,{description:l,placeholder:r,exampleTemplates:i,onDescriptionChange:g,onExampleClick:_}),c&&d===`generating`&&(0,X.jsx)(Ce,{text:s}),c&&d===`error`&&(0,X.jsx)(we,{errorMessage:p})]}),(0,X.jsxs)(B.Footer,{children:[!c&&(0,X.jsx)(Oe,{}),c&&d===`idle`&&(0,X.jsx)(Te,{onSkip:b,onGenerate:v,isGenerateDisabled:!l.trim()}),c&&d===`error`&&(0,X.jsx)(Ee,{onSkip:b,onTryAgain:y})]})]})})}function Se({description:e,placeholder:t,exampleTemplates:n,onDescriptionChange:r,onExampleClick:i}){return(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[(0,X.jsx)(R,{children:(0,X.jsx)(x,{placeholder:t,value:e,onChange:r,rows:5,resize:`vertical`})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,mb:2,children:`Try an example:`}),(0,X.jsx)(W,{gap:2,flexWrap:`wrap`,children:n.map(e=>(0,X.jsx)(I,{size:`xs`,variant:`outline`,onClick:()=>i(e.text),children:e.label},e.label))})]})]})}function Ce({text:e}){return(0,X.jsxs)(G,{gap:4,py:8,children:[(0,X.jsx)(L,{size:`lg`,color:`blue.500`}),(0,X.jsx)(H,{color:`fg.muted`,children:e})]})}function we({errorMessage:e}){return(0,X.jsxs)(G,{gap:4,py:4,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`red.100`,color:`red.600`,children:(0,X.jsx)(U,{as:D,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`Something went wrong`}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:e})]})]})}function Te({onSkip:e,onGenerate:t,isGenerateDisabled:n}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:t,disabled:n,children:[(0,X.jsx)(S,{size:14}),`Generate with AI`]})]})}function Ee({onSkip:e,onTryAgain:t}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsx)(I,{colorPalette:`blue`,onClick:t,children:`Try again`})]})}function De(){return(0,X.jsxs)(G,{gap:4,py:8,align:`center`,justify:`center`,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`orange.100`,color:`orange.600`,children:(0,X.jsx)(U,{as:r,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`No model provider configured`}),(0,X.jsxs)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:[`Scenarios require a model provider to run. Please configure one to get started.`,` `,(0,X.jsx)(ne,{href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,color:`blue.500`,fontWeight:`medium`,children:`Configure model provider`})]})]})]})}function Oe(){return(0,X.jsx)(W,{gap:2,justify:`flex-end`,children:(0,X.jsx)(I,{colorPalette:`blue`,asChild:!0,children:(0,X.jsx)(`a`,{"data-testid":`ai-create-modal-configure-model-provider-button`,href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,children:`Configure model provider`})})})}var ke=`Create new scenario`,Ae=`Explain your agent, its goals and what behavior you want to test.`,je=`Generating scenario...`,Me=[{label:`Customer Support`,text:`A customer support agent that handles complaints. Test an angry customer who was charged twice and wants a refund.`},{label:`RAG Q&A`,text:`A knowledge bot that answers questions from documentation. Test a question that requires combining info from multiple sources.`},{label:`Tool-calling Agent`,text:`An agent that uses tools to complete tasks. Test a request that requires calling multiple tools in sequence.`}];function Ne({open:e,onClose:t}){let{project:n}=q(),{openDrawer:r}=E(),{checkAndProceed:i}=b(`scenarios`),{hasEnabledProviders:a,providers:o}=j({projectId:n?.id}),s=y({hasEnabledProviders:a,providers:o,defaultModel:n?.defaultModel}),c=(0,Y.useCallback)(e=>{r(`scenarioEditor`,{initialFormData:e},{resetStack:!0}),t()},[r,t]),l=(0,Y.useCallback)(async e=>{if(!n?.id)throw Error(`No project selected`);if(!s.ok){if(s.reason===`no-default`)throw Error(`No default model set. Configure one in Settings → Model Providers.`);if(s.reason===`stale-default`)throw Error(`Your default model's provider is disabled. Configure a new default in Settings → Model Providers.`);s.reason;return}try{c(await O(e,n.id))}catch(e){if(ie(e))return;throw e}},[n?.id,s,c]),u=(0,Y.useCallback)(()=>{c({name:``,situation:``,criteria:[]})},[c]);return(0,X.jsx)(xe,{open:e,onClose:t,title:ke,placeholder:Ae,exampleTemplates:Me,onGenerate:e=>i(()=>l(e)),onSkip:()=>i(u),generatingText:je,hasModelProviders:s.ok||s.reason!==`no-providers`})}function Pe({onCreateClick:e}){return(0,X.jsxs)(G,{gap:4,align:`center`,py:12,children:[(0,X.jsx)(H,{fontSize:`lg`,color:`fg.muted`,children:`No scenarios yet`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.subtle`,children:`Create your first scenario to get started`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:e,children:[(0,X.jsx)(o,{size:16}),` Create Scenario`]})]})}var Z=pe(),Fe=(e,t,n)=>{let r=e.getValue(t),i=n;return!i||i.length===0?!0:i.some(e=>r.includes(e))};function Ie({scenarios:e,columnFilters:t,onColumnFiltersChange:n,onRowClick:r,rowSelection:i,onRowSelectionChange:a,onArchive:o}){let[s,u]=(0,Y.useState)([]),d=de({data:e,columns:(0,Y.useMemo)(()=>[Z.display({id:`select`,header:({table:e})=>(0,X.jsx)(N,{"aria-label":`Select all`,checked:e.getIsAllPageRowsSelected(),onChange:()=>e.toggleAllPageRowsSelected(),onClick:e=>e.stopPropagation()}),cell:({row:e})=>(0,X.jsx)(N,{"aria-label":`Select ${e.original.name}`,checked:e.getIsSelected(),onChange:()=>e.toggleSelected(),onClick:e=>e.stopPropagation()}),enableSorting:!1}),Z.accessor(`name`,{header:`Name`,cell:e=>(0,X.jsx)(H,{fontWeight:`medium`,children:e.getValue()})}),Z.accessor(`labels`,{header:`Labels`,enableSorting:!1,filterFn:Fe,cell:e=>(0,X.jsx)(w,{labels:e.getValue()})}),Z.accessor(`updatedAt`,{header:`Updated`,cell:e=>(0,X.jsx)(H,{color:`fg.muted`,children:c(e.getValue().getTime())})}),Z.display({id:`actions`,header:``,cell:({row:e})=>(0,X.jsxs)(T.Root,{children:[(0,X.jsx)(T.Trigger,{asChild:!0,children:(0,X.jsx)(te,{"aria-label":`Actions for ${e.original.name}`,variant:`ghost`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,X.jsx)(p,{size:16})})}),(0,X.jsx)(T.Content,{portalled:!1,children:(0,X.jsxs)(T.Item,{value:`archive`,color:`orange.500`,onClick:t=>{t.stopPropagation(),o(e.original)},children:[(0,X.jsx)(v,{size:14}),`Archive`]})})]}),enableSorting:!1})],[o]),state:{sorting:s,columnFilters:t,rowSelection:i},enableRowSelection:!0,onRowSelectionChange:e=>{a(typeof e==`function`?e(i):e)},onSortingChange:u,onColumnFiltersChange:e=>{n(typeof e==`function`?e(t):e)},getCoreRowModel:ue(),getFilteredRowModel:le(),getSortedRowModel:fe(),getRowId:e=>e.id});return(0,X.jsxs)(M,{variant:`line`,width:`full`,size:`md`,children:[(0,X.jsx)(_,{children:d.getHeaderGroups().map(e=>(0,X.jsx)(l,{children:e.headers.map(e=>(0,X.jsx)(P,{cursor:e.column.getCanSort()?`pointer`:`default`,onClick:e.column.getToggleSortingHandler(),userSelect:`none`,width:e.id===`select`?`40px`:e.id===`actions`?`48px`:void 0,children:(0,X.jsxs)(W,{gap:1,children:[J(e.column.columnDef.header,e.getContext()),e.column.getIsSorted()===`asc`&&(0,X.jsx)(se,{size:14}),e.column.getIsSorted()===`desc`&&(0,X.jsx)(g,{size:14})]})},e.id))},e.id))}),(0,X.jsx)(h,{children:d.getRowModel().rows.map(e=>(0,X.jsx)(l,{cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>r(e.original.id),children:e.getVisibleCells().map(e=>(0,X.jsx)(k,{children:J(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}var Le=[{icon:V,title:`Automated Testing`,description:`Define test scenarios that run automatically against your AI agent to verify it handles real-world situations correctly.`},{icon:s,title:`Regression Detection`,description:`Catch regressions early by re-running scenarios after every change, ensuring your agent never breaks existing behavior.`}];function Q({onProceed:e}){return(0,X.jsxs)(G,{gap:8,align:`center`,children:[(0,X.jsxs)(G,{gap:3,textAlign:`center`,children:[(0,X.jsx)(ee,{as:`h2`,size:`xl`,children:`Welcome to Scenarios`}),(0,X.jsx)(H,{fontSize:`md`,color:`fg.muted`,children:`Scenarios let you test your agent behavior with repeatable, automated checks. Define situations, set expectations, and verify your agent responds correctly every time.`})]}),(0,X.jsx)(G,{gap:4,w:`full`,children:Le.map(({icon:e,title:t,description:n})=>(0,X.jsxs)(W,{gap:4,p:5,w:`full`,borderWidth:`1px`,borderColor:`border`,borderRadius:`lg`,align:`start`,children:[(0,X.jsx)(R,{p:2,borderRadius:`md`,bg:`blue.50`,color:`blue.600`,_dark:{bg:`blue.900`,color:`blue.200`},flexShrink:0,children:(0,X.jsx)(e,{size:20})}),(0,X.jsxs)(G,{gap:1,align:`start`,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:t}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:n})]})]},t))}),(0,X.jsxs)(I,{colorPalette:`blue`,size:`lg`,onClick:e,children:[`Create Your First Scenario `,(0,X.jsx)(oe,{size:16})]})]})}function Re({onProceed:e}){return(0,X.jsx)(G,{py:16,px:8,maxW:`640px`,mx:`auto`,children:(0,X.jsx)(Q,{onProceed:e})})}function ze({open:e,onOpenChange:t,onProceed:n}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>t(e.open),placement:`center`,size:`lg`,children:(0,X.jsxs)(B.Content,{maxWidth:`640px`,children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Body,{py:8,px:8,children:(0,X.jsx)(Q,{onProceed:n})})]})})}function Be(e){let[t,n]=(0,Y.useState)([]);return{columnFilters:t,setColumnFilters:n,allLabels:(0,Y.useMemo)(()=>{if(!e)return[];let t=new Set;return e.forEach(e=>e.labels.forEach(e=>t.add(e))),Array.from(t).sort()},[e]),activeLabels:(0,Y.useMemo)(()=>t.find(e=>e.id===`labels`)?.value??[],[t]),handleLabelToggle:(0,Y.useCallback)(e=>{n(t=>{let n=t.find(e=>e.id===`labels`)?.value??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i=t.filter(e=>e.id!==`labels`);return r.length===0?i:[...i,{id:`labels`,value:r}]})},[])}}var $=`langwatch:scenarios:welcomeSeen`;function Ve(){try{return localStorage.getItem($)===`true`}catch{return!1}}function He(){try{localStorage.setItem($,`true`)}catch{}}function Ue({scenarioCount:e,isLoading:t}){let[n,r]=(0,Y.useState)(Ve),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),c=!t&&e===0&&!n,l=(0,Y.useCallback)(()=>{He(),r(!0)},[]);return{showInlineWelcome:c,showWelcomeModal:i,showCreateModal:o,handleNewScenario:(0,Y.useCallback)(()=>{!n&&!t&&e===0?a(!0):s(!0)},[n,t,e]),handleWelcomeProceed:(0,Y.useCallback)(()=>{l(),a(!1),s(!0)},[l]),handleWelcomeModalOpenChange:(0,Y.useCallback)(e=>{e||(l(),a(!1))},[l]),handleCloseCreateModal:(0,Y.useCallback)(()=>{s(!1)},[])}}function We(){let[e,t]=(0,Y.useState)({}),n=(0,Y.useCallback)(e=>{t(t=>typeof e==`function`?e(t):e)},[]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})},[]),i=(0,Y.useCallback)(e=>{t(t=>{let n={...t};for(let t of e)n[t]=!0;return n})},[]),a=(0,Y.useCallback)(()=>{t({})},[]),o=(0,Y.useMemo)(()=>Object.keys(e).filter(t=>e[t]),[e]);return{toggle:r,selectAll:i,deselectAll:a,selectedIds:o,selectionCount:o.length,rowSelection:e,onRowSelectionChange:n}}function Ge(){let{project:e}=q(),{openDrawer:t,drawerOpen:r}=E(),{rowSelection:i,onRowSelectionChange:a,selectedIds:s,selectionCount:c,deselectAll:l}=We(),[u,d]=(0,Y.useState)(null),f=K.useContext(),{data:p,isLoading:h,error:g}=K.scenarios.getAll.useQuery({projectId:e?.id??``},{enabled:!!e}),_=(0,Y.useCallback)(()=>{f.scenarios.getAll.invalidate(),l(),d(null)},[f.scenarios.getAll,l]),v=K.scenarios.archive.useMutation({onSuccess:_,onError:e=>{z.create({title:`Failed to archive scenario`,description:e.message,type:`error`,meta:{closable:!0}})}}),y=K.scenarios.batchArchive.useMutation({onSuccess:e=>{e.failed.length>0&&z.create({title:`Some scenarios couldn't be archived`,description:`${e.failed.length} failed. Please retry.`,type:`error`,meta:{closable:!0}}),f.scenarios.getAll.invalidate(),l(),d(null)},onError:e=>{z.create({title:`Failed to archive scenarios`,description:e.message,type:`error`,meta:{closable:!0}})}}),{columnFilters:b,setColumnFilters:x,allLabels:S,activeLabels:w,handleLabelToggle:T}=Be(p),{showInlineWelcome:D,showWelcomeModal:O,showCreateModal:k,handleNewScenario:A,handleWelcomeProceed:j,handleWelcomeModalOpenChange:M,handleCloseCreateModal:N}=Ue({scenarioCount:p?.length??0,isLoading:h}),P=e=>{t(`scenarioEditor`,{urlParams:{scenarioId:e}})},F=(0,Y.useCallback)(e=>{d({type:`single`,scenario:e})},[]),I=(0,Y.useCallback)(()=>{d({type:`batch`})},[]),R=()=>{e?.id&&(u?.type===`single`?v.mutate({projectId:e.id,id:u.scenario.id}):u?.type===`batch`&&y.mutate({projectId:e.id,ids:s}))},B=()=>{d(null)},V=(0,Y.useMemo)(()=>!u||!p?[]:u.type===`single`?[{id:u.scenario.id,name:u.scenario.name}]:p.filter(e=>s.includes(e.id)).map(e=>({id:e.id,name:e.name})),[u,p,s]);return(0,X.jsxs)(C,{children:[(0,X.jsx)(m.Header,{children:(0,X.jsxs)(W,{justify:`space-between`,align:`center`,w:`full`,children:[(0,X.jsx)(m.Heading,{children:`Scenario Library`}),(0,X.jsx)(re,{}),(0,X.jsx)(he,{allLabels:S,activeLabels:w,onToggle:T}),(0,X.jsxs)(m.HeaderButton,{onClick:A,children:[(0,X.jsx)(o,{size:16}),` New Scenario`]})]})}),(0,X.jsxs)(m.Container,{padding:0,children:[h&&(0,X.jsx)(G,{gap:4,align:`center`,py:8,children:(0,X.jsx)(L,{borderWidth:`3px`,animationDuration:`0.8s`})}),g&&!p?.length&&(0,X.jsxs)(G,{gap:4,align:`center`,py:8,children:[(0,X.jsx)(H,{color:`red.500`,children:`Error loading scenarios`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:g.message})]}),!h&&!g&&p?.length===0&&D&&(0,X.jsx)(Re,{onProceed:j}),!h&&!g&&p?.length===0&&!D&&(0,X.jsx)(Pe,{onCreateClick:A}),p&&p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ge,{selectedCount:c,onArchive:I}),(0,X.jsx)(Ie,{scenarios:p,columnFilters:b,onColumnFiltersChange:x,onRowClick:P,rowSelection:i,onRowSelectionChange:a,onArchive:F})]})]}),(0,X.jsx)(n,{open:r(`scenarioEditor`)}),(0,X.jsx)(ze,{open:O,onOpenChange:M,onProceed:j}),(0,X.jsx)(Ne,{open:k,onClose:N}),(0,X.jsx)(_e,{open:u!==null,onClose:B,onConfirm:R,scenarios:V,isLoading:v.isPending||y.isPending})]})}var Ke=ce(`scenarios:view`,{layoutComponent:C})(Ge);export{Ke as default};
2
- //# sourceMappingURL=scenarios-BX3XslU0.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$ as n,Ca as r,Co as i,Eo as a,Fa as o,Pa as s,Pr as c,Ss as l,To as u,Us as d,Ws as f,Xa as p,Xr as m,_s as h,ao as g,bs as _,do as v,et as y,fo as b,gs as x,ka as S,mn as C,nt as w,qi as T,r as E,ro as D,tt as O,vs as k,wo as A,xi as j,xs as M,yo as N,ys as P}from"./command-bar-DUK45yin.js";import{j as F,n as I,r as L}from"./stack-oJ9iWdbl.js";import{t as R}from"./box-BsM8YLGl.js";import{n as z}from"./toaster-C_DYALhL.js";import{f as B}from"./dist-Cds4Mqhj.js";import{s as V}from"./terminal-CfM0q99k.js";import{t as ee}from"./heading-D90dlSnH.js";import{t as H}from"./text-CwTrMF8x.js";import{t as U}from"./icon-BwEPrfAc.js";import{t as W}from"./h-stack-BKLDJ2vg.js";import{Pt as te}from"./lu-Bf6j_N19.js";import{n as ne}from"./link-CwZhwOLq.js";import{t as re}from"./spacer-2LJJGbo8.js";import{t as G}from"./v-stack-EOPQ57OZ.js";import{m as ie,s as K}from"./auth-client-D3UhxhQi.js";import{t as q}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as ae}from"./createLucideIcon-BJKFyRLS.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as se}from"./chevron-up-BvG6wkCS.js";import{t as ce}from"./WithPermissionGuard-B4Jo8E5-.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as J}from"./lib-BYJUJC_x.js";var me=ae(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Y=e(t()),X=F();function he({allLabels:e,activeLabels:t,onToggle:n}){let r=t.length>0;return(0,X.jsxs)(u,{positioning:{placement:`bottom-start`},children:[(0,X.jsx)(a,{asChild:!0,children:(0,X.jsxs)(I,{size:`sm`,variant:r?`solid`:`outline`,colorPalette:r?`blue`:`gray`,children:[(0,X.jsx)(me,{size:14}),`Labels`,r&&(0,X.jsxs)(H,{as:`span`,fontSize:`xs`,ml:1,children:[`(`,t.length,`)`]})]})}),(0,X.jsx)(A,{width:`200px`,children:(0,X.jsx)(i,{children:e.length===0?(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:`No labels available`}):(0,X.jsx)(G,{align:`stretch`,gap:2,children:e.map(e=>(0,X.jsxs)(W,{cursor:`pointer`,onClick:()=>n(e),children:[(0,X.jsx)(N,{checked:t.includes(e)}),(0,X.jsx)(H,{fontSize:`sm`,children:e})]},e))})})})]})}function ge({selectedCount:e,onArchive:t}){return e===0?null:(0,X.jsx)(R,{position:`fixed`,bottom:10,left:`50%`,transform:`translateX(-50%)`,backgroundColor:`#ffffff`,border:`1px solid #ccc`,boxShadow:`0 0 15px rgba(0, 0, 0, 0.2)`,borderRadius:`md`,padding:`8px`,paddingX:`16px`,zIndex:1e3,"data-testid":`batch-action-bar`,children:(0,X.jsxs)(W,{gap:3,children:[(0,X.jsxs)(H,{whiteSpace:`nowrap`,fontSize:`sm`,fontWeight:`medium`,children:[e,` selected`]}),(0,X.jsxs)(I,{size:`sm`,variant:`outline`,colorPalette:`orange`,onClick:t,children:[(0,X.jsx)(v,{size:14}),`Archive`]})]})})}function _e({open:e,onClose:t,onConfirm:n,scenarios:r,isLoading:i=!1}){let a=r.length>1,o=a?`Archive ${r.length} scenarios?`:`Archive scenario?`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:t,placement:`center`,children:(0,X.jsxs)(B.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{fontSize:`md`,fontWeight:`500`,children:o})}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[a?(0,X.jsx)(f,{paddingLeft:4,children:r.map(e=>(0,X.jsx)(d,{fontSize:`sm`,children:e.name},e.id))}):r[0]&&(0,X.jsx)(H,{children:(0,X.jsx)(H,{as:`span`,fontWeight:`semibold`,children:r[0].name})}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,children:`Archived scenarios will no longer appear in the library.`})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(I,{variant:`outline`,mr:3,onClick:e=>{e.stopPropagation(),t()},disabled:i,children:`Cancel`}),(0,X.jsx)(I,{colorPalette:`orange`,onClick:e=>{e.stopPropagation(),n()},disabled:i,children:i?(0,X.jsx)(L,{size:`sm`}):`Archive`})]})]})})}var ve=`Describe your scenario. What does your agent do? What situation do you want to test?`,ye=`Generating...`,be=6e4;function xe({open:e,onClose:t,title:n,placeholder:r=ve,exampleTemplates:i,onGenerate:a,onSkip:o,generatingText:s=ye,hasModelProviders:c=!0}){let[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`idle`),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),(0,Y.useEffect)(()=>{e&&(u(``),f(`idle`),m(``))},[e]);let g=(0,Y.useCallback)(e=>{u(e.target.value)},[]),_=(0,Y.useCallback)(e=>{u(e)},[]),v=(0,Y.useCallback)(async()=>{if(!l.trim())return;let e=a(l);if(!e)return;f(`generating`),m(``);let t=new Promise((e,t)=>{h.current=setTimeout(()=>{t(Error(`Generation timed out. Please try again.`))},be)});try{await Promise.race([e,t])}catch(e){f(`error`),m(e instanceof Error?e.message:`An unexpected error occurred`)}finally{h.current&&=(clearTimeout(h.current),null)}},[l,a]),y=(0,Y.useCallback)(()=>{v()},[v]),b=(0,Y.useCallback)(()=>{o()},[o]),x=(0,Y.useCallback)(e=>{!e.open&&d!==`generating`&&t()},[d,t]),S=d!==`generating`;return(0,X.jsx)(B.Root,{open:e,onOpenChange:x,children:(0,X.jsxs)(B.Content,{children:[S&&(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Header,{children:(0,X.jsx)(B.Title,{children:n})}),(0,X.jsxs)(B.Body,{children:[!c&&(0,X.jsx)(De,{}),c&&d===`idle`&&(0,X.jsx)(Se,{description:l,placeholder:r,exampleTemplates:i,onDescriptionChange:g,onExampleClick:_}),c&&d===`generating`&&(0,X.jsx)(Ce,{text:s}),c&&d===`error`&&(0,X.jsx)(we,{errorMessage:p})]}),(0,X.jsxs)(B.Footer,{children:[!c&&(0,X.jsx)(Oe,{}),c&&d===`idle`&&(0,X.jsx)(Te,{onSkip:b,onGenerate:v,isGenerateDisabled:!l.trim()}),c&&d===`error`&&(0,X.jsx)(Ee,{onSkip:b,onTryAgain:y})]})]})})}function Se({description:e,placeholder:t,exampleTemplates:n,onDescriptionChange:r,onExampleClick:i}){return(0,X.jsxs)(G,{align:`stretch`,gap:4,children:[(0,X.jsx)(R,{children:(0,X.jsx)(x,{placeholder:t,value:e,onChange:r,rows:5,resize:`vertical`})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,mb:2,children:`Try an example:`}),(0,X.jsx)(W,{gap:2,flexWrap:`wrap`,children:n.map(e=>(0,X.jsx)(I,{size:`xs`,variant:`outline`,onClick:()=>i(e.text),children:e.label},e.label))})]})]})}function Ce({text:e}){return(0,X.jsxs)(G,{gap:4,py:8,children:[(0,X.jsx)(L,{size:`lg`,color:`blue.500`}),(0,X.jsx)(H,{color:`fg.muted`,children:e})]})}function we({errorMessage:e}){return(0,X.jsxs)(G,{gap:4,py:4,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`red.100`,color:`red.600`,children:(0,X.jsx)(U,{as:D,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`Something went wrong`}),(0,X.jsx)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:e})]})]})}function Te({onSkip:e,onGenerate:t,isGenerateDisabled:n}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:t,disabled:n,children:[(0,X.jsx)(S,{size:14}),`Generate with AI`]})]})}function Ee({onSkip:e,onTryAgain:t}){return(0,X.jsxs)(W,{gap:2,justify:`flex-end`,children:[(0,X.jsx)(I,{variant:`ghost`,onClick:e,children:`I'll write it myself`}),(0,X.jsx)(I,{colorPalette:`blue`,onClick:t,children:`Try again`})]})}function De(){return(0,X.jsxs)(G,{gap:4,py:8,align:`center`,justify:`center`,children:[(0,X.jsx)(R,{p:3,borderRadius:`full`,bg:`orange.100`,color:`orange.600`,children:(0,X.jsx)(U,{as:r,boxSize:6})}),(0,X.jsxs)(G,{gap:1,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:`No model provider configured`}),(0,X.jsxs)(H,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,children:[`Scenarios require a model provider to run. Please configure one to get started.`,` `,(0,X.jsx)(ne,{href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,color:`blue.500`,fontWeight:`medium`,children:`Configure model provider`})]})]})]})}function Oe(){return(0,X.jsx)(W,{gap:2,justify:`flex-end`,children:(0,X.jsx)(I,{colorPalette:`blue`,asChild:!0,children:(0,X.jsx)(`a`,{"data-testid":`ai-create-modal-configure-model-provider-button`,href:`/settings/model-providers`,target:`_blank`,rel:`noopener noreferrer`,children:`Configure model provider`})})})}var ke=`Create new scenario`,Ae=`Explain your agent, its goals and what behavior you want to test.`,je=`Generating scenario...`,Me=[{label:`Customer Support`,text:`A customer support agent that handles complaints. Test an angry customer who was charged twice and wants a refund.`},{label:`RAG Q&A`,text:`A knowledge bot that answers questions from documentation. Test a question that requires combining info from multiple sources.`},{label:`Tool-calling Agent`,text:`An agent that uses tools to complete tasks. Test a request that requires calling multiple tools in sequence.`}];function Ne({open:e,onClose:t}){let{project:n}=q(),{openDrawer:r}=E(),{checkAndProceed:i}=b(`scenarios`),{hasEnabledProviders:a,providers:o}=j({projectId:n?.id}),s=y({hasEnabledProviders:a,providers:o,defaultModel:n?.defaultModel}),c=(0,Y.useCallback)(e=>{r(`scenarioEditor`,{initialFormData:e},{resetStack:!0}),t()},[r,t]),l=(0,Y.useCallback)(async e=>{if(!n?.id)throw Error(`No project selected`);if(!s.ok){if(s.reason===`no-default`)throw Error(`No default model set. Configure one in Settings → Model Providers.`);if(s.reason===`stale-default`)throw Error(`Your default model's provider is disabled. Configure a new default in Settings → Model Providers.`);s.reason;return}try{c(await O(e,n.id))}catch(e){if(ie(e))return;throw e}},[n?.id,s,c]),u=(0,Y.useCallback)(()=>{c({name:``,situation:``,criteria:[]})},[c]);return(0,X.jsx)(xe,{open:e,onClose:t,title:ke,placeholder:Ae,exampleTemplates:Me,onGenerate:e=>i(()=>l(e)),onSkip:()=>i(u),generatingText:je,hasModelProviders:s.ok||s.reason!==`no-providers`})}function Pe({onCreateClick:e}){return(0,X.jsxs)(G,{gap:4,align:`center`,py:12,children:[(0,X.jsx)(H,{fontSize:`lg`,color:`fg.muted`,children:`No scenarios yet`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.subtle`,children:`Create your first scenario to get started`}),(0,X.jsxs)(I,{colorPalette:`blue`,onClick:e,children:[(0,X.jsx)(o,{size:16}),` Create Scenario`]})]})}var Z=pe(),Fe=(e,t,n)=>{let r=e.getValue(t),i=n;return!i||i.length===0?!0:i.some(e=>r.includes(e))};function Ie({scenarios:e,columnFilters:t,onColumnFiltersChange:n,onRowClick:r,rowSelection:i,onRowSelectionChange:a,onArchive:o}){let[s,u]=(0,Y.useState)([]),d=de({data:e,columns:(0,Y.useMemo)(()=>[Z.display({id:`select`,header:({table:e})=>(0,X.jsx)(N,{"aria-label":`Select all`,checked:e.getIsAllPageRowsSelected(),onChange:()=>e.toggleAllPageRowsSelected(),onClick:e=>e.stopPropagation()}),cell:({row:e})=>(0,X.jsx)(N,{"aria-label":`Select ${e.original.name}`,checked:e.getIsSelected(),onChange:()=>e.toggleSelected(),onClick:e=>e.stopPropagation()}),enableSorting:!1}),Z.accessor(`name`,{header:`Name`,cell:e=>(0,X.jsx)(H,{fontWeight:`medium`,children:e.getValue()})}),Z.accessor(`labels`,{header:`Labels`,enableSorting:!1,filterFn:Fe,cell:e=>(0,X.jsx)(w,{labels:e.getValue()})}),Z.accessor(`updatedAt`,{header:`Updated`,cell:e=>(0,X.jsx)(H,{color:`fg.muted`,children:c(e.getValue().getTime())})}),Z.display({id:`actions`,header:``,cell:({row:e})=>(0,X.jsxs)(T.Root,{children:[(0,X.jsx)(T.Trigger,{asChild:!0,children:(0,X.jsx)(te,{"aria-label":`Actions for ${e.original.name}`,variant:`ghost`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,X.jsx)(p,{size:16})})}),(0,X.jsx)(T.Content,{portalled:!1,children:(0,X.jsxs)(T.Item,{value:`archive`,color:`orange.500`,onClick:t=>{t.stopPropagation(),o(e.original)},children:[(0,X.jsx)(v,{size:14}),`Archive`]})})]}),enableSorting:!1})],[o]),state:{sorting:s,columnFilters:t,rowSelection:i},enableRowSelection:!0,onRowSelectionChange:e=>{a(typeof e==`function`?e(i):e)},onSortingChange:u,onColumnFiltersChange:e=>{n(typeof e==`function`?e(t):e)},getCoreRowModel:ue(),getFilteredRowModel:le(),getSortedRowModel:fe(),getRowId:e=>e.id});return(0,X.jsxs)(M,{variant:`line`,width:`full`,size:`md`,children:[(0,X.jsx)(_,{children:d.getHeaderGroups().map(e=>(0,X.jsx)(l,{children:e.headers.map(e=>(0,X.jsx)(P,{cursor:e.column.getCanSort()?`pointer`:`default`,onClick:e.column.getToggleSortingHandler(),userSelect:`none`,width:e.id===`select`?`40px`:e.id===`actions`?`48px`:void 0,children:(0,X.jsxs)(W,{gap:1,children:[J(e.column.columnDef.header,e.getContext()),e.column.getIsSorted()===`asc`&&(0,X.jsx)(se,{size:14}),e.column.getIsSorted()===`desc`&&(0,X.jsx)(g,{size:14})]})},e.id))},e.id))}),(0,X.jsx)(h,{children:d.getRowModel().rows.map(e=>(0,X.jsx)(l,{cursor:`pointer`,_hover:{bg:`bg.emphasized`},onClick:()=>r(e.original.id),children:e.getVisibleCells().map(e=>(0,X.jsx)(k,{children:J(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}var Le=[{icon:V,title:`Automated Testing`,description:`Define test scenarios that run automatically against your AI agent to verify it handles real-world situations correctly.`},{icon:s,title:`Regression Detection`,description:`Catch regressions early by re-running scenarios after every change, ensuring your agent never breaks existing behavior.`}];function Q({onProceed:e}){return(0,X.jsxs)(G,{gap:8,align:`center`,children:[(0,X.jsxs)(G,{gap:3,textAlign:`center`,children:[(0,X.jsx)(ee,{as:`h2`,size:`xl`,children:`Welcome to Scenarios`}),(0,X.jsx)(H,{fontSize:`md`,color:`fg.muted`,children:`Scenarios let you test your agent behavior with repeatable, automated checks. Define situations, set expectations, and verify your agent responds correctly every time.`})]}),(0,X.jsx)(G,{gap:4,w:`full`,children:Le.map(({icon:e,title:t,description:n})=>(0,X.jsxs)(W,{gap:4,p:5,w:`full`,borderWidth:`1px`,borderColor:`border`,borderRadius:`lg`,align:`start`,children:[(0,X.jsx)(R,{p:2,borderRadius:`md`,bg:`blue.50`,color:`blue.600`,_dark:{bg:`blue.900`,color:`blue.200`},flexShrink:0,children:(0,X.jsx)(e,{size:20})}),(0,X.jsxs)(G,{gap:1,align:`start`,children:[(0,X.jsx)(H,{fontWeight:`semibold`,children:t}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:n})]})]},t))}),(0,X.jsxs)(I,{colorPalette:`blue`,size:`lg`,onClick:e,children:[`Create Your First Scenario `,(0,X.jsx)(oe,{size:16})]})]})}function Re({onProceed:e}){return(0,X.jsx)(G,{py:16,px:8,maxW:`640px`,mx:`auto`,children:(0,X.jsx)(Q,{onProceed:e})})}function ze({open:e,onOpenChange:t,onProceed:n}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>t(e.open),placement:`center`,size:`lg`,children:(0,X.jsxs)(B.Content,{maxWidth:`640px`,children:[(0,X.jsx)(B.CloseTrigger,{}),(0,X.jsx)(B.Body,{py:8,px:8,children:(0,X.jsx)(Q,{onProceed:n})})]})})}function Be(e){let[t,n]=(0,Y.useState)([]);return{columnFilters:t,setColumnFilters:n,allLabels:(0,Y.useMemo)(()=>{if(!e)return[];let t=new Set;return e.forEach(e=>e.labels.forEach(e=>t.add(e))),Array.from(t).sort()},[e]),activeLabels:(0,Y.useMemo)(()=>t.find(e=>e.id===`labels`)?.value??[],[t]),handleLabelToggle:(0,Y.useCallback)(e=>{n(t=>{let n=t.find(e=>e.id===`labels`)?.value??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e],i=t.filter(e=>e.id!==`labels`);return r.length===0?i:[...i,{id:`labels`,value:r}]})},[])}}var $=`langwatch:scenarios:welcomeSeen`;function Ve(){try{return localStorage.getItem($)===`true`}catch{return!1}}function He(){try{localStorage.setItem($,`true`)}catch{}}function Ue({scenarioCount:e,isLoading:t}){let[n,r]=(0,Y.useState)(Ve),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),c=!t&&e===0&&!n,l=(0,Y.useCallback)(()=>{He(),r(!0)},[]);return{showInlineWelcome:c,showWelcomeModal:i,showCreateModal:o,handleNewScenario:(0,Y.useCallback)(()=>{!n&&!t&&e===0?a(!0):s(!0)},[n,t,e]),handleWelcomeProceed:(0,Y.useCallback)(()=>{l(),a(!1),s(!0)},[l]),handleWelcomeModalOpenChange:(0,Y.useCallback)(e=>{e||(l(),a(!1))},[l]),handleCloseCreateModal:(0,Y.useCallback)(()=>{s(!1)},[])}}function We(){let[e,t]=(0,Y.useState)({}),n=(0,Y.useCallback)(e=>{t(t=>typeof e==`function`?e(t):e)},[]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})},[]),i=(0,Y.useCallback)(e=>{t(t=>{let n={...t};for(let t of e)n[t]=!0;return n})},[]),a=(0,Y.useCallback)(()=>{t({})},[]),o=(0,Y.useMemo)(()=>Object.keys(e).filter(t=>e[t]),[e]);return{toggle:r,selectAll:i,deselectAll:a,selectedIds:o,selectionCount:o.length,rowSelection:e,onRowSelectionChange:n}}function Ge(){let{project:e}=q(),{openDrawer:t,drawerOpen:r}=E(),{rowSelection:i,onRowSelectionChange:a,selectedIds:s,selectionCount:c,deselectAll:l}=We(),[u,d]=(0,Y.useState)(null),f=K.useContext(),{data:p,isLoading:h,error:g}=K.scenarios.getAll.useQuery({projectId:e?.id??``},{enabled:!!e}),_=(0,Y.useCallback)(()=>{f.scenarios.getAll.invalidate(),l(),d(null)},[f.scenarios.getAll,l]),v=K.scenarios.archive.useMutation({onSuccess:_,onError:e=>{z.create({title:`Failed to archive scenario`,description:e.message,type:`error`,meta:{closable:!0}})}}),y=K.scenarios.batchArchive.useMutation({onSuccess:e=>{e.failed.length>0&&z.create({title:`Some scenarios couldn't be archived`,description:`${e.failed.length} failed. Please retry.`,type:`error`,meta:{closable:!0}}),f.scenarios.getAll.invalidate(),l(),d(null)},onError:e=>{z.create({title:`Failed to archive scenarios`,description:e.message,type:`error`,meta:{closable:!0}})}}),{columnFilters:b,setColumnFilters:x,allLabels:S,activeLabels:w,handleLabelToggle:T}=Be(p),{showInlineWelcome:D,showWelcomeModal:O,showCreateModal:k,handleNewScenario:A,handleWelcomeProceed:j,handleWelcomeModalOpenChange:M,handleCloseCreateModal:N}=Ue({scenarioCount:p?.length??0,isLoading:h}),P=e=>{t(`scenarioEditor`,{urlParams:{scenarioId:e}})},F=(0,Y.useCallback)(e=>{d({type:`single`,scenario:e})},[]),I=(0,Y.useCallback)(()=>{d({type:`batch`})},[]),R=()=>{e?.id&&(u?.type===`single`?v.mutate({projectId:e.id,id:u.scenario.id}):u?.type===`batch`&&y.mutate({projectId:e.id,ids:s}))},B=()=>{d(null)},V=(0,Y.useMemo)(()=>!u||!p?[]:u.type===`single`?[{id:u.scenario.id,name:u.scenario.name}]:p.filter(e=>s.includes(e.id)).map(e=>({id:e.id,name:e.name})),[u,p,s]);return(0,X.jsxs)(C,{children:[(0,X.jsx)(m.Header,{children:(0,X.jsxs)(W,{justify:`space-between`,align:`center`,w:`full`,children:[(0,X.jsx)(m.Heading,{children:`Scenario Library`}),(0,X.jsx)(re,{}),(0,X.jsx)(he,{allLabels:S,activeLabels:w,onToggle:T}),(0,X.jsxs)(m.HeaderButton,{onClick:A,children:[(0,X.jsx)(o,{size:16}),` New Scenario`]})]})}),(0,X.jsxs)(m.Container,{padding:0,children:[h&&(0,X.jsx)(G,{gap:4,align:`center`,py:8,children:(0,X.jsx)(L,{borderWidth:`3px`,animationDuration:`0.8s`})}),g&&!p?.length&&(0,X.jsxs)(G,{gap:4,align:`center`,py:8,children:[(0,X.jsx)(H,{color:`red.500`,children:`Error loading scenarios`}),(0,X.jsx)(H,{fontSize:`sm`,color:`fg.muted`,children:g.message})]}),!h&&!g&&p?.length===0&&D&&(0,X.jsx)(Re,{onProceed:j}),!h&&!g&&p?.length===0&&!D&&(0,X.jsx)(Pe,{onCreateClick:A}),p&&p.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ge,{selectedCount:c,onArchive:I}),(0,X.jsx)(Ie,{scenarios:p,columnFilters:b,onColumnFiltersChange:x,onRowClick:P,rowSelection:i,onRowSelectionChange:a,onArchive:F})]})]}),(0,X.jsx)(n,{open:r(`scenarioEditor`)}),(0,X.jsx)(ze,{open:O,onOpenChange:M,onProceed:j}),(0,X.jsx)(Ne,{open:k,onClose:N}),(0,X.jsx)(_e,{open:u!==null,onClose:B,onConfirm:R,scenarios:V,isLoading:v.isPending||y.isPending})]})}var Ke=ce(`scenarios:view`,{layoutComponent:C})(Ge);export{Ke as default};
2
+ //# sourceMappingURL=scenarios-BmG_wDkR.js.map
@@ -1,2 +1,2 @@
1
- import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ha as r,Ss as i,_s as a,bs as o,cc as s,m as c,vs as l,wa as u,xs as d,ys as f}from"./command-bar-CaJygoez.js";import{j as p,n as m}from"./stack-oJ9iWdbl.js";import{n as h}from"./toaster-C_DYALhL.js";import{an as g,f as _}from"./dist-SwV3YZv3.js";import{t as v}from"./heading-D90dlSnH.js";import{t as y}from"./text-CwTrMF8x.js";import{t as b}from"./input-C7emsUCL.js";import{t as x}from"./h-stack-BKLDJ2vg.js";import{r as S,t as C}from"./card-CMtKVPVl.js";import{t as w}from"./spacer-2LJJGbo8.js";import{t as T}from"./v-stack-EOPQ57OZ.js";import{s as E}from"./auth-client-D3UhxhQi.js";import{t as D}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as O}from"./SettingsLayout-CLCGxMAe.js";import{t as k}from"./WithPermissionGuard-DD8uo3UK.js";var A=e(t()),j=p();function M(){let{organization:e}=D();return e?(0,j.jsx)(P,{organizationId:e.id}):(0,j.jsx)(O,{})}var N=k(`organization:manage`,{layoutComponent:O})(M);function P({organizationId:e}){let t=E.scimToken.list.useQuery({organizationId:e}),p=E.scimToken.generate.useMutation(),D=E.scimToken.revoke.useMutation(),k=E.useContext(),{open:M,onOpen:N,onClose:P}=s(),[F,I]=(0,A.useState)(``),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(null),V=()=>{p.mutate({organizationId:e,description:F||void 0},{onSuccess:e=>{R(e.token),I(``),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to generate token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},H=t=>{D.mutate({organizationId:e,tokenId:t},{onSuccess:()=>{B(null),h.create({title:`Token revoked`,type:`success`,duration:3e3,meta:{closable:!0}}),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to revoke token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},U=typeof window<`u`?`${window.location.origin}/api/scim/v2`:``;return(0,j.jsxs)(O,{children:[(0,j.jsxs)(T,{gap:6,width:`full`,align:`start`,children:[(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{children:`SCIM Provisioning`}),(0,j.jsx)(w,{})]}),(0,j.jsx)(S,{width:`full`,children:(0,j.jsx)(C,{children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`SCIM (System for Cross-domain Identity Management) allows your identity provider (Okta, Azure AD, etc.) to automatically provision and deprovision users in LangWatch.`}),(0,j.jsxs)(T,{gap:2,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,children:`SCIM Base URL`}),(0,j.jsx)(c,{value:U,label:`SCIM Base URL`})]}),(0,j.jsx)(y,{fontSize:`sm`,color:`gray.500`,children:`Use this URL and a bearer token below to configure SCIM in your identity provider.`})]})})}),(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{size:`md`,children:`Bearer Tokens`}),(0,j.jsx)(w,{}),(0,j.jsxs)(m,{size:`sm`,onClick:N,children:[(0,j.jsx)(n,{size:16}),`Generate Token`]})]}),(0,j.jsx)(S,{width:`full`,overflow:`hidden`,children:(0,j.jsx)(C,{paddingY:0,paddingX:0,children:(0,j.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,j.jsx)(o,{children:(0,j.jsxs)(i,{children:[(0,j.jsx)(f,{children:`Description`}),(0,j.jsx)(f,{children:`Created`}),(0,j.jsx)(f,{children:`Last Used`}),(0,j.jsx)(f,{width:`80px`})]})}),(0,j.jsxs)(a,{children:[t.data?.length===0&&(0,j.jsx)(i,{children:(0,j.jsx)(l,{colSpan:4,children:(0,j.jsx)(y,{color:`gray.500`,textAlign:`center`,paddingY:4,children:`No SCIM tokens yet. Generate one to get started.`})})}),t.data?.map(e=>(0,j.jsxs)(i,{children:[(0,j.jsx)(l,{children:(0,j.jsxs)(x,{children:[(0,j.jsx)(r,{size:14}),(0,j.jsx)(y,{children:e.description??`No description`})]})}),(0,j.jsx)(l,{children:new Date(e.createdAt).toLocaleDateString()}),(0,j.jsx)(l,{children:e.lastUsedAt?new Date(e.lastUsedAt).toLocaleDateString():(0,j.jsx)(g,{size:`sm`,colorPalette:`gray`,children:`Never`})}),(0,j.jsx)(l,{children:(0,j.jsx)(m,{size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>B(e.id),children:(0,j.jsx)(u,{size:14})})})]},e.id))]})]})})})]}),(0,j.jsx)(_.Root,{open:M&&!L,onOpenChange:({open:e})=>{e||(P(),I(``))},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Generate SCIM Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`This token will be used by your identity provider to authenticate SCIM requests.`}),(0,j.jsxs)(T,{gap:1,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,fontSize:`sm`,children:`Description (optional)`}),(0,j.jsx)(b,{placeholder:`e.g., Okta SCIM integration`,value:F,onChange:e=>I(e.target.value)})]}),(0,j.jsx)(m,{width:`full`,onClick:V,disabled:p.isLoading,children:`Generate Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!L,onOpenChange:({open:e})=>{e||(R(null),P())},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Token Generated`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{color:`orange.500`,fontWeight:`600`,children:`Copy this token now. You won't be able to see it again.`}),L&&(0,j.jsx)(c,{value:L,label:`SCIM Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!z,onOpenChange:({open:e})=>{e||B(null)},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Revoke Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`Are you sure you want to revoke this token? Any identity provider using it will no longer be able to provision users.`}),(0,j.jsxs)(x,{width:`full`,justify:`end`,gap:2,children:[(0,j.jsx)(m,{variant:`outline`,onClick:()=>B(null),children:`Cancel`}),(0,j.jsx)(m,{colorPalette:`red`,onClick:()=>z&&H(z),disabled:D.isLoading,children:`Revoke`})]})]})})]})})]})}export{N as default};
2
- //# sourceMappingURL=scim-DDsLO39r.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Fa as n,Ha as r,Ss as i,_s as a,bs as o,cc as s,m as c,vs as l,wa as u,xs as d,ys as f}from"./command-bar-DUK45yin.js";import{j as p,n as m}from"./stack-oJ9iWdbl.js";import{n as h}from"./toaster-C_DYALhL.js";import{an as g,f as _}from"./dist-Cds4Mqhj.js";import{t as v}from"./heading-D90dlSnH.js";import{t as y}from"./text-CwTrMF8x.js";import{t as b}from"./input-C7emsUCL.js";import{t as x}from"./h-stack-BKLDJ2vg.js";import{r as S,t as C}from"./card-CMtKVPVl.js";import{t as w}from"./spacer-2LJJGbo8.js";import{t as T}from"./v-stack-EOPQ57OZ.js";import{s as E}from"./auth-client-D3UhxhQi.js";import{t as D}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as O}from"./SettingsLayout--1gdEuhv.js";import{t as k}from"./WithPermissionGuard-B4Jo8E5-.js";var A=e(t()),j=p();function M(){let{organization:e}=D();return e?(0,j.jsx)(P,{organizationId:e.id}):(0,j.jsx)(O,{})}var N=k(`organization:manage`,{layoutComponent:O})(M);function P({organizationId:e}){let t=E.scimToken.list.useQuery({organizationId:e}),p=E.scimToken.generate.useMutation(),D=E.scimToken.revoke.useMutation(),k=E.useContext(),{open:M,onOpen:N,onClose:P}=s(),[F,I]=(0,A.useState)(``),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(null),V=()=>{p.mutate({organizationId:e,description:F||void 0},{onSuccess:e=>{R(e.token),I(``),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to generate token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},H=t=>{D.mutate({organizationId:e,tokenId:t},{onSuccess:()=>{B(null),h.create({title:`Token revoked`,type:`success`,duration:3e3,meta:{closable:!0}}),k.scimToken.list.invalidate()},onError:()=>{h.create({title:`Failed to revoke token`,type:`error`,duration:5e3,meta:{closable:!0}})}})},U=typeof window<`u`?`${window.location.origin}/api/scim/v2`:``;return(0,j.jsxs)(O,{children:[(0,j.jsxs)(T,{gap:6,width:`full`,align:`start`,children:[(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{children:`SCIM Provisioning`}),(0,j.jsx)(w,{})]}),(0,j.jsx)(S,{width:`full`,children:(0,j.jsx)(C,{children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`SCIM (System for Cross-domain Identity Management) allows your identity provider (Okta, Azure AD, etc.) to automatically provision and deprovision users in LangWatch.`}),(0,j.jsxs)(T,{gap:2,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,children:`SCIM Base URL`}),(0,j.jsx)(c,{value:U,label:`SCIM Base URL`})]}),(0,j.jsx)(y,{fontSize:`sm`,color:`gray.500`,children:`Use this URL and a bearer token below to configure SCIM in your identity provider.`})]})})}),(0,j.jsxs)(x,{width:`full`,children:[(0,j.jsx)(v,{size:`md`,children:`Bearer Tokens`}),(0,j.jsx)(w,{}),(0,j.jsxs)(m,{size:`sm`,onClick:N,children:[(0,j.jsx)(n,{size:16}),`Generate Token`]})]}),(0,j.jsx)(S,{width:`full`,overflow:`hidden`,children:(0,j.jsx)(C,{paddingY:0,paddingX:0,children:(0,j.jsxs)(d,{variant:`line`,size:`md`,width:`full`,children:[(0,j.jsx)(o,{children:(0,j.jsxs)(i,{children:[(0,j.jsx)(f,{children:`Description`}),(0,j.jsx)(f,{children:`Created`}),(0,j.jsx)(f,{children:`Last Used`}),(0,j.jsx)(f,{width:`80px`})]})}),(0,j.jsxs)(a,{children:[t.data?.length===0&&(0,j.jsx)(i,{children:(0,j.jsx)(l,{colSpan:4,children:(0,j.jsx)(y,{color:`gray.500`,textAlign:`center`,paddingY:4,children:`No SCIM tokens yet. Generate one to get started.`})})}),t.data?.map(e=>(0,j.jsxs)(i,{children:[(0,j.jsx)(l,{children:(0,j.jsxs)(x,{children:[(0,j.jsx)(r,{size:14}),(0,j.jsx)(y,{children:e.description??`No description`})]})}),(0,j.jsx)(l,{children:new Date(e.createdAt).toLocaleDateString()}),(0,j.jsx)(l,{children:e.lastUsedAt?new Date(e.lastUsedAt).toLocaleDateString():(0,j.jsx)(g,{size:`sm`,colorPalette:`gray`,children:`Never`})}),(0,j.jsx)(l,{children:(0,j.jsx)(m,{size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>B(e.id),children:(0,j.jsx)(u,{size:14})})})]},e.id))]})]})})})]}),(0,j.jsx)(_.Root,{open:M&&!L,onOpenChange:({open:e})=>{e||(P(),I(``))},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Generate SCIM Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`This token will be used by your identity provider to authenticate SCIM requests.`}),(0,j.jsxs)(T,{gap:1,align:`start`,width:`full`,children:[(0,j.jsx)(y,{fontWeight:`600`,fontSize:`sm`,children:`Description (optional)`}),(0,j.jsx)(b,{placeholder:`e.g., Okta SCIM integration`,value:F,onChange:e=>I(e.target.value)})]}),(0,j.jsx)(m,{width:`full`,onClick:V,disabled:p.isLoading,children:`Generate Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!L,onOpenChange:({open:e})=>{e||(R(null),P())},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Token Generated`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{color:`orange.500`,fontWeight:`600`,children:`Copy this token now. You won't be able to see it again.`}),L&&(0,j.jsx)(c,{value:L,label:`SCIM Token`})]})})]})}),(0,j.jsx)(_.Root,{open:!!z,onOpenChange:({open:e})=>{e||B(null)},children:(0,j.jsxs)(_.Content,{children:[(0,j.jsx)(_.Header,{children:(0,j.jsx)(_.Title,{children:(0,j.jsx)(v,{size:`md`,children:`Revoke Token`})})}),(0,j.jsx)(_.CloseTrigger,{}),(0,j.jsx)(_.Body,{paddingBottom:6,children:(0,j.jsxs)(T,{gap:4,align:`start`,children:[(0,j.jsx)(y,{children:`Are you sure you want to revoke this token? Any identity provider using it will no longer be able to provision users.`}),(0,j.jsxs)(x,{width:`full`,justify:`end`,gap:2,children:[(0,j.jsx)(m,{variant:`outline`,onClick:()=>B(null),children:`Cancel`}),(0,j.jsx)(m,{colorPalette:`red`,onClick:()=>z&&H(z),disabled:D.isLoading,children:`Revoke`})]})]})})]})})]})}export{N as default};
2
+ //# sourceMappingURL=scim-BKr1_FHt.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 ee,Da as te,Fa as n,Ha as r,Qs as i,Ss as a,Xa as o,Xr as s,Xs as c,Ys as l,Zs as u,_s as d,bs as f,hn as p,qi as m,vs as h,wa as ne,xs as re,ys as g}from"./command-bar-CaJygoez.js";import{j as _,n as v,r as y}from"./stack-oJ9iWdbl.js";import{t as b}from"./box-BsM8YLGl.js";import{t as x}from"./tooltip-AEm0YeiF.js";import{n as S}from"./toaster-C_DYALhL.js";import{f as C}from"./dist-SwV3YZv3.js";import{t as w}from"./heading-D90dlSnH.js";import{t as T}from"./text-CwTrMF8x.js";import{t as E}from"./input-C7emsUCL.js";import{t as D}from"./h-stack-BKLDJ2vg.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout-CLCGxMAe.js";var N=e(t()),P=_();function F(){let{project:e,organizations:t,hasPermission:_}=j(),F=_(`secrets:manage`),I=A.secrets.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),L=I.data??[],R=A.secrets.create.useMutation(),z=A.secrets.update.useMutation(),B=A.secrets.delete.useMutation(),V=A.useContext(),[H,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(``),[K,q]=(0,N.useState)(``),[J,Y]=(0,N.useState)(null),[X,Z]=(0,N.useState)(null),[Q,$]=(0,N.useState)(``),ie=async()=>{if(!(!e?.id||!W||!K))try{await R.mutateAsync({projectId:e.id,name:W,value:K}),U(!1),G(``),q(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to create secret`,type:`error`})}},ae=async()=>{if(!(!e?.id||!J))try{await B.mutateAsync({projectId:e.id,secretId:J.id}),Y(null),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to delete secret`,type:`error`})}},oe=async()=>{if(!(!e?.id||!X||!Q))try{await z.mutateAsync({projectId:e.id,secretId:X.id,value:Q}),Z(null),$(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to update secret`,type:`error`})}};return(0,P.jsx)(M,{children:(0,P.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,P.jsxs)(D,{width:`full`,marginTop:2,children:[(0,P.jsx)(w,{as:`h2`,children:`Secrets`}),(0,P.jsx)(O,{}),t&&e&&(0,P.jsx)(p,{organizations:t,project:e}),F&&(0,P.jsx)(x,{content:`Add a new secret for use in code blocks`,disabled:!1,children:(0,P.jsxs)(s.HeaderButton,{onClick:()=>U(!0),children:[(0,P.jsx)(n,{}),` Add Secret`]})})]}),I.isLoading?(0,P.jsx)(y,{}):L.length===0?(0,P.jsx)(i,{width:`full`,children:(0,P.jsxs)(l,{children:[(0,P.jsx)(u,{children:(0,P.jsx)(r,{size:24})}),(0,P.jsxs)(k,{textAlign:`center`,children:[(0,P.jsx)(ee,{children:`No secrets configured`}),(0,P.jsx)(c,{children:`Add secrets to use in code blocks`})]})]})}):(0,P.jsxs)(re,{width:`full`,children:[(0,P.jsx)(f,{children:(0,P.jsxs)(a,{children:[(0,P.jsx)(g,{children:`Name`}),(0,P.jsx)(g,{children:`Created By`}),(0,P.jsx)(g,{children:`Last Updated`}),(0,P.jsx)(g,{})]})}),(0,P.jsx)(d,{children:L.map(e=>(0,P.jsxs)(a,{children:[(0,P.jsx)(h,{children:(0,P.jsx)(T,{fontFamily:`mono`,children:e.name})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:e.createdBy?.name??`-`})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:new Date(e.updatedAt).toLocaleDateString()})}),(0,P.jsx)(h,{textAlign:`right`,children:F&&(0,P.jsxs)(m.Root,{children:[(0,P.jsx)(m.Trigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,children:(0,P.jsx)(o,{})})}),(0,P.jsxs)(m.Content,{children:[(0,P.jsx)(m.Item,{value:`update`,onClick:()=>{Z({id:e.id,name:e.name}),$(``)},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(te,{size:14}),`Update Value`]})}),(0,P.jsx)(m.Item,{value:`delete`,color:`red`,onClick:()=>{Y({id:e.id,name:e.name})},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(ne,{size:14}),`Delete Secret`]})})]})]})})]},e.id))})]}),(0,P.jsx)(C.Root,{open:H,onOpenChange:e=>{e.open||(U(!1),G(``),q(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsx)(C.Title,{children:`Add Secret`})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:4,align:`start`,children:[(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Name`}),(0,P.jsx)(E,{placeholder:`e.g., OPENAI_API_KEY`,value:W,onChange:e=>G(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``))})]}),(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter secret value`,value:K,onChange:e=>q(e.target.value)})]})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:R.isPending,disabled:!W||!K,onClick:()=>void ie(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!J,onOpenChange:e=>{e.open||Y(null)},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Delete `,J?.name??``,`?`]})}),(0,P.jsx)(C.Body,{children:(0,P.jsx)(T,{children:`Code blocks referencing this secret will no longer have access.`})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`red`,loading:B.isPending,onClick:()=>void ae(),children:`Delete`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!X,onOpenChange:e=>{e.open||(Z(null),$(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Update Value for `,X?.name??``]})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`New Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter new secret value`,value:Q,onChange:e=>$(e.target.value)})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:z.isPending,disabled:!Q,onClick:()=>void oe(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})})]})})}export{F as default};
2
- //# sourceMappingURL=secrets-BvEGwDCy.js.map
1
+ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as ee,Da as te,Fa as n,Ha as r,Qs as i,Ss as a,Xa as o,Xr as s,Xs as c,Ys as l,Zs as u,_s as d,bs as f,hn as p,qi as m,vs as h,wa as ne,xs as re,ys as g}from"./command-bar-DUK45yin.js";import{j as _,n as v,r as y}from"./stack-oJ9iWdbl.js";import{t as b}from"./box-BsM8YLGl.js";import{t as x}from"./tooltip-AEm0YeiF.js";import{n as S}from"./toaster-C_DYALhL.js";import{f as C}from"./dist-Cds4Mqhj.js";import{t as w}from"./heading-D90dlSnH.js";import{t as T}from"./text-CwTrMF8x.js";import{t as E}from"./input-C7emsUCL.js";import{t as D}from"./h-stack-BKLDJ2vg.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{s as A}from"./auth-client-D3UhxhQi.js";import{t as j}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as M}from"./SettingsLayout--1gdEuhv.js";var N=e(t()),P=_();function F(){let{project:e,organizations:t,hasPermission:_}=j(),F=_(`secrets:manage`),I=A.secrets.list.useQuery({projectId:e?.id??``},{enabled:!!e?.id}),L=I.data??[],R=A.secrets.create.useMutation(),z=A.secrets.update.useMutation(),B=A.secrets.delete.useMutation(),V=A.useContext(),[H,U]=(0,N.useState)(!1),[W,G]=(0,N.useState)(``),[K,q]=(0,N.useState)(``),[J,Y]=(0,N.useState)(null),[X,Z]=(0,N.useState)(null),[Q,$]=(0,N.useState)(``),ie=async()=>{if(!(!e?.id||!W||!K))try{await R.mutateAsync({projectId:e.id,name:W,value:K}),U(!1),G(``),q(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to create secret`,type:`error`})}},ae=async()=>{if(!(!e?.id||!J))try{await B.mutateAsync({projectId:e.id,secretId:J.id}),Y(null),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to delete secret`,type:`error`})}},oe=async()=>{if(!(!e?.id||!X||!Q))try{await z.mutateAsync({projectId:e.id,secretId:X.id,value:Q}),Z(null),$(``),await V.secrets.list.invalidate()}catch(e){S.create({title:e instanceof Error?e.message:`Failed to update secret`,type:`error`})}};return(0,P.jsx)(M,{children:(0,P.jsxs)(k,{gap:6,width:`full`,align:`start`,children:[(0,P.jsxs)(D,{width:`full`,marginTop:2,children:[(0,P.jsx)(w,{as:`h2`,children:`Secrets`}),(0,P.jsx)(O,{}),t&&e&&(0,P.jsx)(p,{organizations:t,project:e}),F&&(0,P.jsx)(x,{content:`Add a new secret for use in code blocks`,disabled:!1,children:(0,P.jsxs)(s.HeaderButton,{onClick:()=>U(!0),children:[(0,P.jsx)(n,{}),` Add Secret`]})})]}),I.isLoading?(0,P.jsx)(y,{}):L.length===0?(0,P.jsx)(i,{width:`full`,children:(0,P.jsxs)(l,{children:[(0,P.jsx)(u,{children:(0,P.jsx)(r,{size:24})}),(0,P.jsxs)(k,{textAlign:`center`,children:[(0,P.jsx)(ee,{children:`No secrets configured`}),(0,P.jsx)(c,{children:`Add secrets to use in code blocks`})]})]})}):(0,P.jsxs)(re,{width:`full`,children:[(0,P.jsx)(f,{children:(0,P.jsxs)(a,{children:[(0,P.jsx)(g,{children:`Name`}),(0,P.jsx)(g,{children:`Created By`}),(0,P.jsx)(g,{children:`Last Updated`}),(0,P.jsx)(g,{})]})}),(0,P.jsx)(d,{children:L.map(e=>(0,P.jsxs)(a,{children:[(0,P.jsx)(h,{children:(0,P.jsx)(T,{fontFamily:`mono`,children:e.name})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:e.createdBy?.name??`-`})}),(0,P.jsx)(h,{children:(0,P.jsx)(T,{children:new Date(e.updatedAt).toLocaleDateString()})}),(0,P.jsx)(h,{textAlign:`right`,children:F&&(0,P.jsxs)(m.Root,{children:[(0,P.jsx)(m.Trigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,children:(0,P.jsx)(o,{})})}),(0,P.jsxs)(m.Content,{children:[(0,P.jsx)(m.Item,{value:`update`,onClick:()=>{Z({id:e.id,name:e.name}),$(``)},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(te,{size:14}),`Update Value`]})}),(0,P.jsx)(m.Item,{value:`delete`,color:`red`,onClick:()=>{Y({id:e.id,name:e.name})},children:(0,P.jsxs)(b,{display:`flex`,alignItems:`center`,gap:2,children:[(0,P.jsx)(ne,{size:14}),`Delete Secret`]})})]})]})})]},e.id))})]}),(0,P.jsx)(C.Root,{open:H,onOpenChange:e=>{e.open||(U(!1),G(``),q(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsx)(C.Title,{children:`Add Secret`})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:4,align:`start`,children:[(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Name`}),(0,P.jsx)(E,{placeholder:`e.g., OPENAI_API_KEY`,value:W,onChange:e=>G(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``))})]}),(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter secret value`,value:K,onChange:e=>q(e.target.value)})]})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:R.isPending,disabled:!W||!K,onClick:()=>void ie(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!J,onOpenChange:e=>{e.open||Y(null)},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Delete `,J?.name??``,`?`]})}),(0,P.jsx)(C.Body,{children:(0,P.jsx)(T,{children:`Code blocks referencing this secret will no longer have access.`})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`red`,loading:B.isPending,onClick:()=>void ae(),children:`Delete`})]}),(0,P.jsx)(C.CloseTrigger,{})]})}),(0,P.jsx)(C.Root,{open:!!X,onOpenChange:e=>{e.open||(Z(null),$(``))},children:(0,P.jsxs)(C.Content,{children:[(0,P.jsx)(C.Header,{children:(0,P.jsxs)(C.Title,{children:[`Update Value for `,X?.name??``]})}),(0,P.jsx)(C.Body,{children:(0,P.jsxs)(k,{gap:1,align:`start`,width:`full`,children:[(0,P.jsx)(T,{fontWeight:`medium`,children:`New Value`}),(0,P.jsx)(E,{type:`password`,placeholder:`Enter new secret value`,value:Q,onChange:e=>$(e.target.value)})]})}),(0,P.jsxs)(C.Footer,{children:[(0,P.jsx)(C.ActionTrigger,{asChild:!0,children:(0,P.jsx)(v,{variant:`outline`,children:`Cancel`})}),(0,P.jsx)(v,{colorPalette:`blue`,loading:z.isPending,disabled:!Q,onClick:()=>void oe(),children:`Save`})]}),(0,P.jsx)(C.CloseTrigger,{})]})})]})})}export{F as default};
2
+ //# sourceMappingURL=secrets-CU8ocTGv.js.map