@langwatch/server 3.1.0-beta.21 → 3.1.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/__init__.py +36 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/_logger.py +165 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/batch_clustering.py +153 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/build_response.py +77 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/constants.py +7 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/incremental_clustering.py +325 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/topic_naming.py +432 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/types.py +42 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/utils.py +191 -0
- package/langevals/evaluators/topic_clustering/pyproject.toml +52 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_clustering.py +239 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_clustering_integration.py +97 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_naming.py +72 -0
- package/langevals/langevals/pytest_plugins/pass_rate_plugin.py +7 -1
- package/langevals/langevals/server.py +28 -0
- package/langevals/pyproject.toml +3 -0
- package/langevals/uv.lock +119 -20
- package/langwatch/dist/client/assets/{AnnotationsTable-BDAkYaz6.js → AnnotationsTable-uS_9SQ-g.js} +2 -2
- package/langwatch/dist/client/assets/{BatchEvaluationSummary-DMaQM_VB.js → BatchEvaluationSummary-DtFd8yKJ.js} +2 -2
- package/langwatch/dist/client/assets/{BudgetEditDrawer-CHaqmdIl.js → BudgetEditDrawer-CHEPz0hH.js} +2 -2
- package/langwatch/dist/client/assets/{ChartCard-D14PUg_d.js → ChartCard-s5fMPo7b.js} +2 -2
- package/langwatch/dist/client/assets/{ChatWindow-CRDnlP-Q.js → ChatWindow-C0XSteVJ.js} +2 -2
- package/langwatch/dist/client/assets/ChatWindow-DFEmNXQL.js +1 -0
- package/langwatch/dist/client/assets/{ConfirmDialog-CXIhncvW.js → ConfirmDialog-M94yLNvP.js} +2 -2
- package/langwatch/dist/client/assets/{ContactSalesBlock-CijLBwRC.js → ContactSalesBlock-CnnuZ8iI.js} +2 -2
- package/langwatch/dist/client/assets/{DSPyExperiment-B1YOL2m8.js → DSPyExperiment-CMA6lrlx.js} +2 -2
- package/langwatch/dist/client/assets/{FilterDisplay-BB0xWrLn.js → FilterDisplay-0S3NqCkq.js} +2 -2
- package/langwatch/dist/client/assets/{FormatMoney-w9vr_h0X.js → FormatMoney-CCygtAHg.js} +2 -2
- package/langwatch/dist/client/assets/{FoundryDrawer-CdJDXtpz.js → FoundryDrawer-B35xZ26C.js} +2 -2
- package/langwatch/dist/client/assets/{GatewayErrorPanel-DvE9U2dS.js → GatewayErrorPanel-BsaYQEie.js} +2 -2
- package/langwatch/dist/client/assets/{GatewayLayout-lv1p_6B5.js → GatewayLayout-LvwwrwMf.js} +2 -2
- package/langwatch/dist/client/assets/{GraphsLayout-BJ68J9e-.js → GraphsLayout-DJ-HI9N1.js} +2 -2
- package/langwatch/dist/client/assets/{GroupBindingInputRow-DebZBCnD.js → GroupBindingInputRow-CV-fBkX9.js} +2 -2
- package/langwatch/dist/client/assets/{MessagesTable-B6lYde-x.js → MessagesTable-9taaKCOZ.js} +2 -2
- package/langwatch/dist/client/assets/{NavigationFooter-CiOVzDUh.js → NavigationFooter-Dzvauw3l.js} +2 -2
- package/langwatch/dist/client/assets/{NoDataInfoBlock-quSW_MRm.js → NoDataInfoBlock-CLKl_wlX.js} +2 -2
- package/langwatch/dist/client/assets/{OpsPageShell-DJ1WlI6-.js → OpsPageShell-C_mTziRS.js} +2 -2
- package/langwatch/dist/client/assets/{OptimizationStudio-BlozXjcN.js → OptimizationStudio-D2zpsmJj.js} +8 -12
- package/langwatch/dist/client/assets/{PreconditionsField-BOfcWvmZ.js → PreconditionsField-WXB8kcTK.js} +2 -2
- package/langwatch/dist/client/assets/{SettingsLayout-CLCGxMAe.js → SettingsLayout--1gdEuhv.js} +2 -2
- package/langwatch/dist/client/assets/{SubscriptionPage-J8b2Zaj6.js → SubscriptionPage-B0ox_4kM.js} +2 -2
- package/langwatch/dist/client/assets/{VirtualKeySecretReveal-DR1VDLy7.js → VirtualKeySecretReveal-CRbI1dKQ.js} +2 -2
- package/langwatch/dist/client/assets/{WithPermissionGuard-DD8uo3UK.js → WithPermissionGuard-B4Jo8E5-.js} +2 -2
- package/langwatch/dist/client/assets/{__...path__-BZVaIayJ.js → __...path__-BF2zkD84.js} +2 -2
- package/langwatch/dist/client/assets/{_experiment_-B1aT-wS3.js → _experiment_-D02aoVQk.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-oI_eq-I_.js → _id_-Ch8YmTiM.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-DAqPuO73.js → _id_-D6ZvwHpH.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-DUngklVb.js → _id_-DOC1ZkBm.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-jFDAfbob.js → _id_-DfWwW6_N.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-BKBrWGG0.js → _id_-DxUo4W7J.js} +2 -2
- package/langwatch/dist/client/assets/_not-found-DDh108-i.js +1 -0
- package/langwatch/dist/client/assets/{_project_-Bt1tayHB.js → _project_-_UUt5Ar9.js} +2 -2
- package/langwatch/dist/client/assets/{_runId_-CfvnDt5H.js → _runId_-Dimwzp48.js} +2 -2
- package/langwatch/dist/client/assets/_slug_-BMvKBwS_.js +2 -0
- package/langwatch/dist/client/assets/{_slug_-DZAdl0QS.js → _slug_-CE6VoDSC.js} +2 -2
- package/langwatch/dist/client/assets/{_slug_-DmoWXjKT.js → _slug_-OiOLG1Mv.js} +2 -2
- package/langwatch/dist/client/assets/{_team_-DL_wKSWK.js → _team_-DKvmwO_5.js} +2 -2
- package/langwatch/dist/client/assets/{_workflow_-DcMXLPUe.js → _workflow_-FkilKiB-.js} +3 -3
- package/langwatch/dist/client/assets/{_workflow_-NI9bac7d.js → _workflow_-gJZppg3h.js} +2 -2
- package/langwatch/dist/client/assets/{access-audit-CFwNwusI.js → access-audit-xcUVYMMT.js} +2 -2
- package/langwatch/dist/client/assets/{agents-Di4XRwcn.js → agents-D32g91cu.js} +2 -2
- package/langwatch/dist/client/assets/{all-C273mlDB.js → all-vnREzDZj.js} +2 -2
- package/langwatch/dist/client/assets/{analytics-CEAcSf6B.js → analytics-DP6Y4Feh.js} +2 -2
- package/langwatch/dist/client/assets/{annotation-scores-CHfn4LQp.js → annotation-scores-CjD4CEB6.js} +2 -2
- package/langwatch/dist/client/assets/{annotations-CHZQrha6.js → annotations-1rVXiDRQ.js} +2 -2
- package/langwatch/dist/client/assets/{api-keys-BT7HExHM.js → api-keys-BJpKyuaz.js} +2 -2
- package/langwatch/dist/client/assets/{audit-log-BGk-51Dt.js → audit-log-BdUdZjxp.js} +2 -2
- package/langwatch/dist/client/assets/{authentication-DvwXfkp-.js → authentication-8mQB00CC.js} +2 -2
- package/langwatch/dist/client/assets/{authorize-tXpHrWyw.js → authorize-BpUueMNW.js} +2 -2
- package/langwatch/dist/client/assets/{authorize-CRu9xlpU.js → authorize-CbNBtmxW.js} +2 -2
- package/langwatch/dist/client/assets/{automations-CjDvz9Ak.js → automations-34KMkRxd.js} +2 -2
- package/langwatch/dist/client/assets/{billing-plans-FUqEPN62.js → billing-plans-BUQp08MI.js} +2 -2
- package/langwatch/dist/client/assets/{budgets-BV6_RHrs.js → budgets-CdelE8Hv.js} +2 -2
- package/langwatch/dist/client/assets/{cache-rules-CtYA79E_.js → cache-rules-D2m1QlNJ.js} +2 -2
- package/langwatch/dist/client/assets/choose-C0LdeUiH.js +2 -0
- package/langwatch/dist/client/assets/{command-bar-CaJygoez.js → command-bar-DUK45yin.js} +7 -9
- package/langwatch/dist/client/assets/custom-hBq2K4FJ.js +1 -0
- package/langwatch/dist/client/assets/{datasets-vLWpH84_.js → datasets-ErNNhmjg.js} +2 -2
- package/langwatch/dist/client/assets/{dejaview-DwVR3RGg.js → dejaview-BaD4_v90.js} +2 -2
- package/langwatch/dist/client/assets/{dist-SwV3YZv3.js → dist-Cds4Mqhj.js} +4 -6
- package/langwatch/dist/client/assets/{edit-CyxsmQmW.js → edit-DpT8ejBV.js} +2 -2
- package/langwatch/dist/client/assets/{evaluations-BfgeZMph.js → evaluations-BdQ2Dm2r.js} +2 -2
- package/langwatch/dist/client/assets/{evaluations-HSQIMvbX.js → evaluations-C90I4VAr.js} +2 -2
- package/langwatch/dist/client/assets/{evaluators-DLHVvnrh.js → evaluators-ig_ugRLt.js} +2 -2
- package/langwatch/dist/client/assets/{foundry-Ckq0WjPU.js → foundry-B-X_80pD.js} +2 -2
- package/langwatch/dist/client/assets/{gateway-CDSYPZ6w.js → gateway-CS_mtJx-.js} +2 -2
- package/langwatch/dist/client/assets/{groups-CCCRUqPj.js → groups-Bp90ChP3.js} +2 -2
- package/langwatch/dist/client/assets/{index-Bm6z2fM9.js → index-TNQ6uyis.js} +4 -4
- package/langwatch/dist/client/assets/{license-CHOarGWr.js → license-CgnlvyuI.js} +2 -2
- package/langwatch/dist/client/assets/{me-CBya_vXs.js → me-DEqhm_KC.js} +2 -2
- package/langwatch/dist/client/assets/{members-lIFLh-rh.js → members-CUJANDtH.js} +2 -2
- package/langwatch/dist/client/assets/{messages-CG9j8Dz8.js → messages-fQBfCjvp.js} +2 -2
- package/langwatch/dist/client/assets/{metrics-C9pzeaI6.js → metrics-DeIxebpD.js} +2 -2
- package/langwatch/dist/client/assets/{model-costs-Bc5uqjkl.js → model-costs-C1RbgK--.js} +2 -2
- package/langwatch/dist/client/assets/{model-providers-B5UjRgS_.js → model-providers-Pv3ML_-t.js} +2 -2
- package/langwatch/dist/client/assets/{my-queue-BkEfiWyR.js → my-queue-BLre2NMr.js} +2 -2
- package/langwatch/dist/client/assets/{ops-Cc-g-CMn.js → ops-CCw-FJaT.js} +2 -2
- package/langwatch/dist/client/assets/{organization-features-CoIKKHkQ.js → organization-features-rqg-75mI.js} +2 -2
- package/langwatch/dist/client/assets/{organizations-DWcQUTzi.js → organizations-DjCzIHVx.js} +2 -2
- package/langwatch/dist/client/assets/{persistence-CTQ44vGL.js → persistence-BPvHS0F6.js} +2 -2
- package/langwatch/dist/client/assets/{plans-Dq3eFg5K.js → plans-Ch2Ol-Fd.js} +2 -2
- package/langwatch/dist/client/assets/{projections-CTNj1QBM.js → projections-it4FOVjm.js} +2 -2
- package/langwatch/dist/client/assets/{projects-BxM7C87h.js → projects-CjWZFLfn.js} +2 -2
- package/langwatch/dist/client/assets/{prompts-DhXnJT6e.js → prompts-DilmFH_s.js} +2 -2
- package/langwatch/dist/client/assets/{providers-DW7VWdqq.js → providers-tlLT_lTF.js} +2 -2
- package/langwatch/dist/client/assets/{reports-D3QFKhNP.js → reports-vlrcTrLs.js} +2 -2
- package/langwatch/dist/client/assets/{roles-B_0t5DWA.js → roles-DNgi-NQ9.js} +2 -2
- package/langwatch/dist/client/assets/{scenarios-BX3XslU0.js → scenarios-BmG_wDkR.js} +2 -2
- package/langwatch/dist/client/assets/{scim-DDsLO39r.js → scim-BKr1_FHt.js} +2 -2
- package/langwatch/dist/client/assets/{secrets-BvEGwDCy.js → secrets-CU8ocTGv.js} +2 -2
- package/langwatch/dist/client/assets/{settings-9giNiAQQ.js → settings-CDzdoYVK.js} +2 -2
- package/langwatch/dist/client/assets/{setup-HxXKoVKG.js → setup-nEvn2rjN.js} +2 -2
- package/langwatch/dist/client/assets/{subscription-DhyswDze.js → subscription-BPNl_6jF.js} +3 -3
- package/langwatch/dist/client/assets/{subscriptions-Dyyau22a.js → subscriptions-D0G-OE5C.js} +2 -2
- package/langwatch/dist/client/assets/{teams-DRmeAxzf.js → teams-DThgDQvB.js} +2 -2
- package/langwatch/dist/client/assets/{textOverflowHeuristic-JibhpzDV.js → textOverflowHeuristic-DTC8-Ffx.js} +2 -2
- package/langwatch/dist/client/assets/{topic-clustering-Bllfw5rZ.js → topic-clustering-BR2Mbpao.js} +2 -2
- package/langwatch/dist/client/assets/{topics-CpiGYxqb.js → topics-CI8GoNqp.js} +2 -2
- package/langwatch/dist/client/assets/{traceExecutor-CiHXJB0V.js → traceExecutor-CDUGyUaw.js} +2 -2
- package/langwatch/dist/client/assets/{usage-BnsstwBY.js → usage-B4mR7ut_.js} +2 -2
- package/langwatch/dist/client/assets/{usage-CoyGtJoI.js → usage-C8fbffYi.js} +2 -2
- package/langwatch/dist/client/assets/{useAdminResource-SPC5iBHM.js → useAdminResource-SmnnHro6.js} +2 -2
- package/langwatch/dist/client/assets/{useAnnotationQueues-2DKZTC7r.js → useAnnotationQueues-CA6Vk--V.js} +2 -2
- package/langwatch/dist/client/assets/{useAvailableEvaluators-HndTl2LV.js → useAvailableEvaluators-hmbmcRQr.js} +2 -2
- package/langwatch/dist/client/assets/{useDeleteDatasetConfirmation-BgWN6Qqb.js → useDeleteDatasetConfirmation-BCK_zUUe.js} +2 -2
- package/langwatch/dist/client/assets/{useWorkflowStore-e1wFCvo2.js → useWorkflowStore-QUJ3J8X9.js} +2 -2
- package/langwatch/dist/client/assets/{users-C6wjliCC.js → users-CfhanCfR.js} +2 -2
- package/langwatch/dist/client/assets/{users-tF6ZKeV1.js → users-HjuN3o6k.js} +2 -2
- package/langwatch/dist/client/assets/{virtual-keys-BL-65S0B.js → virtual-keys-Bj-MhW66.js} +2 -2
- package/langwatch/dist/client/assets/{wizard-faGkpZDT.js → wizard-dRWCVVx6.js} +2 -2
- package/langwatch/dist/client/assets/{workbench-Oj0s_YR-.js → workbench-CuixH3G1.js} +2 -2
- package/langwatch/dist/client/assets/{workflows-Cu9k-Twu.js → workflows-BT6m4Yu9.js} +2 -2
- package/langwatch/dist/client/index.html +3 -3
- package/langwatch/scripts/seed-dogfood-password.ts +163 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +180 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
- package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
- package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
- package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
- package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
- package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
- package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
- package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
- package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
- package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
- package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
- package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
- package/langwatch/src/optimization_studio/registry.ts +2 -4
- package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
- package/langwatch/src/server/api/routers/workflows.ts +18 -0
- package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
- package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
- package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
- package/langwatch/src/server/modelProviders/utils.ts +11 -1
- package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
- package/langwatch/src/server/nlpgo/nlpgoFetch.ts +142 -0
- package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
- package/langwatch/src/server/routes/playground.ts +11 -1
- package/langwatch/src/server/routes/workflows.ts +17 -0
- package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
- package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
- package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
- package/langwatch_nlp/scripts/entrypoint.sh +67 -0
- package/package.json +1 -1
- package/packages/server/dist/cli.cjs +67 -94
- package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
- package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
- package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
- package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
- package/langwatch/dist/client/assets/custom-CSiS1liN.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Dt as e,Gt as t,Ht as n,Kt as r,Nt as i,Qi as a,Ro as o,Ut as s,Wt as c,Yi as l,da as u,qt as d,yo as f}from"./command-bar-
|
|
1
|
+
import{Dt as e,Gt as t,Ht as n,Kt as r,Nt as i,Qi as a,Ro as o,Ut as s,Wt as c,Yi as l,da as u,qt as d,yo as f}from"./command-bar-DUK45yin.js";import{j as p,n as m}from"./stack-oJ9iWdbl.js";import{t as h}from"./box-BsM8YLGl.js";import{i as g,o as _,r as v,t as y}from"./tabs-DwV1cIZB.js";import{t as b}from"./tooltip-AEm0YeiF.js";import{r as x}from"./toaster-C_DYALhL.js";import{nn as S,r as C,rn as w}from"./dist-Cds4Mqhj.js";import{n as T,r as E,t as D}from"./native-select-B51i56CE.js";import{t as O}from"./heading-D90dlSnH.js";import{t as k}from"./text-CwTrMF8x.js";import{t as A}from"./input-C7emsUCL.js";import{t as j}from"./h-stack-BKLDJ2vg.js";import{t as M}from"./link-CwZhwOLq.js";import{t as N}from"./v-stack-EOPQ57OZ.js";import{s as P}from"./auth-client-D3UhxhQi.js";import{c as F,t as I}from"./useOrganizationTeamProject-DC0iozx2.js";import{c as L}from"./index.esm-X7lxUoP1.js";import{t as R}from"./HorizontalFormControl-BCD7-fcT.js";var z=p();function B(e){let{filterParams:t,queryOpts:n}=a(),r=P.traces.getSampleTracesDataset.useQuery(t,n);return e.traceMapping&&!e.traceMapping?.mapping?null:(0,z.jsx)(u,{...e,traces:r.data??[]})}var V=F();function H({slug:t,evaluatorDefinition:n,form:r,checkType:i,name:a,executionMode:o,settings:s,storeSettingsOnCode:c}){let u=o===V.EvaluationExecutionMode.AS_GUARDRAIL,d=c?i:t,{project:p}=I(),m=n.requiredFields.includes(`output`),C=P.project.getProjectAPIKey.useQuery({projectId:p?.id??``},{enabled:!!p}),T=({async:e})=>{let t=`\n name="${a}",`,r=[];n.requiredFields.includes(`input`)?r.push(`"input": user_input`):n.optionalFields.includes(`input`)&&r.push(`"input": user_input # optional`),n.requiredFields.includes(`output`)?r.push(`"output": generated_response`):n.optionalFields.includes(`output`)&&r.push(`"output": generated_response # optional`),n.requiredFields.includes(`contexts`)?r.push(`"contexts": ["retrieved snippet 1", "retrieved snippet 2"]`):n.optionalFields.includes(`contexts`)&&r.push(`"contexts": ["retrieved snippet 1", "retrieved snippet 2"] # optional`),n.requiredFields.includes(`expected_output`)?r.push(`"expected_output": gold_answer`):n.optionalFields.includes(`expected_output`)&&r.push(`"expected_output": gold_answer # optional`),n.requiredFields.includes(`conversation`)?r.push(`"conversation": conversation_history`):n.optionalFields.includes(`conversation`)&&r.push(`"conversation": conversation_history # optional`);let i=r.length>0?`\n data={\n ${r.join(`,
|
|
2
2
|
`)}\n },`:`
|
|
3
3
|
data={},`,o=c?`\n settings=${JSON.stringify(s??{},null,2).replace(/true/g,`True`).replace(/false/g,`False`).split(`
|
|
4
4
|
`).map((e,t)=>t===0?e:` `+e).join(`
|
|
@@ -59,4 +59,4 @@ curl -X POST "${e()}/api/evaluations/${d}/evaluate" \\
|
|
|
59
59
|
"as_guardrail": true`:``}${D}
|
|
60
60
|
}
|
|
61
61
|
EOF`,language:`bash`})}),(0,z.jsx)(k,{children:`Response:`}),(0,z.jsx)(h,{className:`markdown`,width:`full`,children:(0,z.jsx)(l,{code:JSON.stringify({status:`processed`,passed:!0,score:1,details:`possible explanation`},null,2),language:`json`})})]})})]})]})}var U=({runOn:e,append:a,remove:l,fields:u,label:f=`Preconditions`,helper:p=`Conditions that must be met for this check to run`})=>{let{control:g,watch:_,setValue:v,formState:y}=L(),b=_(`preconditions`),x=i(_(`checkType`)),S=t(),w=(e,t)=>{let n=t,i=b[e]?.rule;if(i&&!d(n,i)){let t=c(n);t.length>0&&v(`preconditions.${e}.rule`,t[0])}r(n)===`boolean`&&v(`preconditions.${e}.value`,`true`),v(`preconditions.${e}.key`,void 0),v(`preconditions.${e}.subkey`,void 0)};return(0,z.jsx)(R,{label:f,helper:p,children:(0,z.jsxs)(N,{align:`start`,gap:4,children:[x?.requiredFields.includes(`contexts`)&&(0,z.jsx)(h,{borderLeft:`4px solid`,borderLeftColor:`blue.400`,width:`full`,children:(0,z.jsxs)(N,{borderLeftColor:`reset`,padding:3,width:`full`,align:`start`,position:`relative`,children:[(0,z.jsx)(k,{children:`Requires RAG Contexts`}),(0,z.jsx)(k,{color:`fg.muted`,fontStyle:`italic`,children:`This evaluator will only run if the RAG contexts are provided`})]})}),x?.requiredFields.includes(`expected_output`)&&(0,z.jsx)(h,{borderLeft:`4px solid`,borderLeftColor:`blue.400`,width:`full`,children:(0,z.jsxs)(N,{borderLeftColor:`reset`,padding:3,width:`full`,align:`start`,position:`relative`,children:[(0,z.jsx)(k,{children:`Requires an Expected Output`}),(0,z.jsx)(k,{color:`fg.muted`,fontStyle:`italic`,children:`This evaluator will only run if the expected output is provided`})]})}),x?.requiredFields.includes(`expected_contexts`)&&(0,z.jsx)(h,{borderLeft:`4px solid`,borderLeftColor:`blue.400`,width:`full`,children:(0,z.jsxs)(N,{borderLeftColor:`reset`,padding:3,width:`full`,align:`start`,position:`relative`,children:[(0,z.jsx)(k,{children:`Requires Expected Contexts`}),(0,z.jsx)(k,{color:`fg.muted`,fontStyle:`italic`,children:`This evaluator will only run if the expected contexts are provided`})]})}),u.map((e,t)=>{let i=b[t]?.field,a=c(i),u=r(i),d=s(i);return(0,z.jsxs)(h,{borderLeft:`4px solid`,borderLeftColor:`blue.400`,width:`full`,children:[(0,z.jsxs)(N,{borderLeftColor:`reset`,padding:3,width:`full`,align:`start`,position:`relative`,children:[(0,z.jsx)(m,{position:`absolute`,right:0,top:0,padding:0,size:`sm`,variant:`ghost`,onClick:()=>l(t),color:`fg.subtle`,children:(0,z.jsx)(o,{})}),(0,z.jsx)(C,{children:t==0?`When`:`and`}),(0,z.jsxs)(j,{gap:2,flexWrap:`wrap`,children:[(0,z.jsxs)(E,{minWidth:`fit-content`,children:[(0,z.jsx)(D,{...g.register(`preconditions.${t}.field`,{onChange:e=>{w(t,e.target.value)}}),children:S.map(e=>(0,z.jsx)(`optgroup`,{label:e.category,children:e.fields.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.category))}),(0,z.jsx)(T,{})]}),d&&(0,z.jsx)(A,{...g.register(`preconditions.${t}.key`),placeholder:d.label,minWidth:`120px`,maxWidth:`200px`}),(0,z.jsxs)(E,{minWidth:`fit-content`,children:[(0,z.jsx)(D,{...g.register(`preconditions.${t}.rule`),children:a.map(e=>(0,z.jsx)(`option`,{value:e,children:n[e]},e))}),(0,z.jsx)(T,{})]})]}),(0,z.jsx)(j,{width:`full`,children:u===`boolean`?(0,z.jsxs)(E,{minWidth:`fit-content`,children:[(0,z.jsxs)(D,{...g.register(`preconditions.${t}.value`),children:[(0,z.jsx)(`option`,{value:`true`,children:`true`}),(0,z.jsx)(`option`,{value:`false`,children:`false`})]}),(0,z.jsx)(T,{})]}):(0,z.jsxs)(z.Fragment,{children:[b[t]?.rule.includes(`regex`)&&(0,z.jsx)(k,{fontSize:`16px`,children:`/`}),(0,z.jsx)(A,{...g.register(`preconditions.${t}.value`),placeholder:b[t]?.rule.includes(`regex`)?`regex`:`text`}),b[t]?.rule.includes(`regex`)&&(0,z.jsx)(k,{fontSize:`16px`,children:`/gi`})]})})]}),y.errors.preconditions?.[t]?.value&&(0,z.jsx)(k,{color:`red.500`,fontSize:`12px`,paddingLeft:4,children:y.errors.preconditions?.[t]?.value.message})]},e.id)}),e,(0,z.jsx)(m,{onClick:()=>a({field:`output`,rule:`contains`,value:``}),children:`Add Precondition`})]})})};export{H as n,B as r,U as t};
|
|
62
|
-
//# sourceMappingURL=PreconditionsField-
|
|
62
|
+
//# sourceMappingURL=PreconditionsField-WXB8kcTK.js.map
|
package/langwatch/dist/client/assets/{SettingsLayout-CLCGxMAe.js → SettingsLayout--1gdEuhv.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Cn as n,Un as r,Xr as i,ao as a,io as o,mn as s}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=SettingsLayout
|
|
1
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Cn as n,Un as r,Xr as i,ao as a,io as o,mn as s}from"./command-bar-DUK45yin.js";import{j as c}from"./stack-oJ9iWdbl.js";import{t as l}from"./box-BsM8YLGl.js";import{t as u}from"./text-CwTrMF8x.js";import{t as d}from"./h-stack-BKLDJ2vg.js";import{t as f}from"./container-Ccm3vB5X.js";import{t as p}from"./v-stack-EOPQ57OZ.js";import{s as m}from"./auth-client-D3UhxhQi.js";import{t as h}from"./usePublicEnv-1QvVAhAk.js";import{t as g}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as _}from"./next-navigation-CufL4Tjj.js";import{t as v}from"./MenuLink-b_JZtGfc.js";var y=e(t());function b(){let{organization:e}=g(),t=m.limits.getUsage.useQuery({organizationId:e?.id??``},{enabled:!!e?.id});return{isEnterprise:t.data?.activePlan.type===`ENTERPRISE`,isFree:t.data?.activePlan.free??!0,isLoading:t.isLoading,activePlan:t.data?.activePlan}}var x=c();function S({label:e,paths:t,children:n}){let r=_(),i=t.some(e=>r?.startsWith(e)),[s,c]=(0,y.useState)(i);return(0,y.useEffect)(()=>{i&&c(!0)},[i]),(0,x.jsxs)(p,{align:`start`,width:`full`,gap:0,children:[(0,x.jsxs)(d,{width:`full`,px:4,py:1,cursor:`pointer`,color:`fg.muted`,_hover:{color:`fg`},onClick:()=>c(e=>!e),children:[(0,x.jsx)(u,{fontSize:`xs`,fontWeight:`semibold`,textTransform:`uppercase`,letterSpacing:`wider`,children:e}),(0,x.jsx)(l,{ml:`auto`,children:s?(0,x.jsx)(a,{size:12}):(0,x.jsx)(o,{size:12})})]}),s&&(0,x.jsx)(p,{align:`start`,width:`full`,gap:1,pl:2,children:n})]})}function C({children:e,isSubscription:t}){let{project:a,hasPermission:o}=g({redirectToOnboarding:!1}),c=h().data?.IS_SAAS??!1,{isEnterprise:l}=b(),{isLiteMember:u}=r(),{hasAccess:_}=n(),y=m.user.isAdmin.useQuery({},{enabled:_,retry:!1,refetchOnWindowFocus:!1}).data?.isAdmin??!1;return(0,x.jsxs)(s,{compactMenu:!0,children:[(0,x.jsx)(i.Header,{children:(0,x.jsx)(i.Heading,{children:`Settings`})}),(0,x.jsxs)(d,{align:`start`,width:`full`,height:`calc(100vh - 56px - 48px)`,gap:0,children:[(0,x.jsxs)(p,{align:`start`,paddingX:2,paddingY:4,fontSize:`14px`,minWidth:`200px`,height:`full`,overflowY:`auto`,flexShrink:0,gap:2,display:t?`none`:`flex`,children:[(0,x.jsx)(v,{href:`/settings`,children:`General Settings`}),!u&&(0,x.jsx)(v,{href:`/settings/api-keys`,children:`API Keys`}),(0,x.jsxs)(S,{label:`Models`,paths:[`/settings/model-providers`,`/settings/model-costs`,`/settings/secrets`],children:[(0,x.jsx)(v,{href:`/settings/model-costs`,children:`Model Costs`}),(0,x.jsx)(v,{href:`/settings/model-providers`,children:`Model Providers`}),!u&&(0,x.jsx)(v,{href:`/settings/secrets`,children:`Secrets`})]}),(0,x.jsxs)(S,{label:`Teams & Access`,paths:[`/settings/teams`,`/settings/members`,`/settings/groups`,`/settings/roles`,`/settings/access-audit`,`/settings/authentication`,`/settings/scim`,`/settings/audit-log`],children:[(0,x.jsx)(v,{href:`/settings/members`,includePath:`members`,children:`Members`}),(0,x.jsx)(v,{href:`/settings/teams`,children:`Teams & Projects`}),l&&!u&&(0,x.jsx)(v,{href:`/settings/groups`,children:`Groups`}),l&&!u&&(0,x.jsx)(v,{href:`/settings/roles`,children:`Roles & Permissions`}),(0,x.jsx)(v,{href:`/settings/authentication`,children:`Authentication`}),l&&!u&&(0,x.jsx)(v,{href:`/settings/scim`,children:`SCIM Provisioning`}),l&&!u&&(0,x.jsx)(v,{href:`/settings/access-audit`,children:`Access Audit`}),l&&!u&&o(`auditLog:view`)&&(0,x.jsx)(v,{href:`/settings/audit-log`,children:`Audit Log`})]}),(0,x.jsxs)(S,{label:`Features`,paths:[`/settings/annotation-scores`,`/settings/topic-clustering`],children:[(0,x.jsx)(v,{href:`/settings/annotation-scores`,children:`Annotation Scores`}),!u&&a?.slug&&(0,x.jsx)(v,{href:`/${a.slug}/automations`,children:`Automations`}),!u&&(0,x.jsx)(v,{href:`/settings/topic-clustering`,children:`Topic Clustering`})]}),!u&&(0,x.jsxs)(S,{label:`Billing`,paths:[`/settings/usage`,`/settings/subscription`,`/settings/license`],children:[(0,x.jsx)(v,{href:`/settings/usage`,children:`Usage & Billing`}),c&&(0,x.jsx)(v,{href:`/settings/subscription`,children:`Subscription`}),!c&&(0,x.jsx)(v,{href:`/settings/license`,children:`License`})]}),_&&(0,x.jsxs)(S,{label:`Ops`,paths:[`/ops`],children:[(0,x.jsx)(v,{href:`/ops`,children:`Dashboard`}),(0,x.jsx)(v,{href:`/ops/projections`,includePath:`/ops/projections`,children:`Projection Replay`}),(0,x.jsx)(v,{href:`/ops/foundry`,includePath:`/ops/foundry`,children:`The Foundry`}),(0,x.jsx)(v,{href:`/ops/dejaview`,includePath:`/ops/dejaview`,children:`Deja View`})]}),y&&(0,x.jsxs)(S,{label:`Backoffice`,paths:[`/ops/backoffice`],children:[(0,x.jsx)(v,{href:`/ops/backoffice/users`,includePath:`/ops/backoffice/users`,children:`Users`}),(0,x.jsx)(v,{href:`/ops/backoffice/organizations`,includePath:`/ops/backoffice/organizations`,children:`Organizations`}),(0,x.jsx)(v,{href:`/ops/backoffice/projects`,includePath:`/ops/backoffice/projects`,children:`Projects`}),(0,x.jsx)(v,{href:`/ops/backoffice/subscriptions`,includePath:`/ops/backoffice/subscriptions`,children:`Subscriptions`}),(0,x.jsx)(v,{href:`/ops/backoffice/organization-features`,includePath:`/ops/backoffice/organization-features`,children:`Organization Features`})]})]}),(0,x.jsx)(f,{maxWidth:`1280px`,padding:4,paddingBottom:16,height:`full`,overflowY:`auto`,flex:1,children:e})]})]})}export{b as n,C as t};
|
|
2
|
+
//# sourceMappingURL=SettingsLayout--1gdEuhv.js.map
|
package/langwatch/dist/client/assets/{SubscriptionPage-J8b2Zaj6.js → SubscriptionPage-B0ox_4kM.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Fa as r,Ss as i,_s as a,ao as o,bs as s,ec as c,fa as l,na as u,nc as d,sc as f,tc as p,vs as m,wa as ee,xs as h,ys as g}from"./command-bar-CaJygoez.js";import{j as _,n as v,r as te}from"./stack-oJ9iWdbl.js";import{t as y}from"./box-BsM8YLGl.js";import{f as b}from"./LoadingScreen--vgXk5-2.js";import{n as x}from"./toaster-C_DYALhL.js";import{an as S,in as C}from"./dist-SwV3YZv3.js";import{h as w}from"./terminal-CfM0q99k.js";import{i as T}from"./tracking-DbhAKeey.js";import{t as ne}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{n as D}from"./code-FF_ibTVI.js";import{t as re}from"./input-C7emsUCL.js";import{t as O}from"./h-stack-BKLDJ2vg.js";import{r as k,t as A}from"./card-CMtKVPVl.js";import{t as j}from"./link-CwZhwOLq.js";import{t as M}from"./simple-grid-C3IW90zo.js";import{t as N}from"./v-stack-EOPQ57OZ.js";import{c as P,m as ie,s as F}from"./auth-client-D3UhxhQi.js";import{c as I,t as ae}from"./useOrganizationTeamProject-DC0iozx2.js";import{j as L}from"./types-B5pOLKPA.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as R}from"./download-X34ozaiD.js";import{t as z}from"./SettingsLayout-CLCGxMAe.js";import{n as se}from"./planTypes-Cig7WlCp.js";import{a as B,c as ce,d as le,f as V,l as H,n as ue,r as de,s as U,t as fe,u as W}from"./billing-plans-FUqEPN62.js";import{t as pe}from"./constants-BT2q4NNM.js";import{t as me}from"./ContactSalesBlock-CijLBwRC.js";var G=e(t()),K=_();function he({left:e,right:t,value:n,onChange:r,"data-testid":i}){let a=(0,G.useId)(),o=`${a}-left`,s=`${a}-right`;return(0,K.jsxs)(O,{gap:2,"data-testid":i,children:[(0,K.jsx)(E,{id:o,fontWeight:n===e.value?`bold`:`normal`,fontSize:`sm`,children:e.label}),(0,K.jsx)(l,{colorPalette:`blue`,checked:n===t.value,onCheckedChange:n=>r(n.checked?t.value:e.value),"aria-labelledby":`${o} ${s}`}),(0,K.jsx)(E,{id:s,fontWeight:n===t.value?`bold`:`normal`,fontSize:`sm`,children:t.label})]})}var q=I();function ge(e){return e.split(`:`)[1]===`view`}function _e(e){return e.every(ge)}function ve(e,t){return e===q.OrganizationUserRole.ADMIN||e===q.OrganizationUserRole.MEMBER||e===q.OrganizationUserRole.EXTERNAL&&t&&!_e(t)?`FullMember`:`LiteMember`}var ye=e=>L().email().safeParse(e).success,J=e=>e.filter(e=>e.memberType===`FullMember`).length;function be(e){return e?e.startsWith(`GROWTH_SEAT_`)?`Growth`:e.toLowerCase().split(`_`).map(e=>e[0]?.toUpperCase()+e.slice(1)).join(` `):`Current plan`}function xe({currency:e,billingPeriod:t,users:n,plannedUsers:r}){let i=H(),a=t===`annual`?i[e].annual:i[e].monthly;return{seatPricePerPeriodCents:a,periodSuffix:t===`annual`?`/yr`:`/mo`,totalFullMembers:J(n)+J(r),monthlyEquivalent:t===`annual`?`${U({cents:Math.round(a/12),currency:e})}/mo per seat`:`${U({cents:a,currency:e})}/mo per seat`}}function Se(e){return e===`FullMember`?`MEMBER`:`EXTERNAL`}function Ce({organizationId:e,currency:t,billingPeriod:n,totalFullMembers:r,currentMaxMembers:i,plannedUsers:a,onSeatsUpdated:o,organizationWithMembers:s,activePlanType:c}){let l=P(e=>e.openSeats),u=F.subscription.create.useMutation(),d=F.subscription.upgradeWithInvites.useMutation(),f=F.subscription.addTeamMemberOrEvents.useMutation(),p=F.subscription.manage.useMutation();return{handleUpgrade:async()=>{if(e)try{let i=a.filter(e=>e.email.trim()!==``).map(e=>({email:e.email.trim(),role:Se(e.memberType)}));if(i.length>0){let a=await d.mutateAsync({organizationId:e,baseUrl:window.location.origin,currency:t,billingInterval:n,totalSeats:r,invites:i});a.url&&(window.location.href=a.url);return}let o=await u.mutateAsync({organizationId:e,baseUrl:window.location.origin,plan:V({currency:t,interval:n}),membersToAdd:r,currency:t,billingInterval:n});o.url&&(window.location.href=o.url)}catch(e){x.create({title:`Error upgrading subscription`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}},handleUpdateSeats:()=>{if(!e)return;let a=r;l({organizationId:e,currentSeats:i??r,newSeats:a,onConfirm:async()=>{try{let r=c&&W(c)?c:V({currency:t,interval:n});await f.mutateAsync({organizationId:e,plan:r,upgradeMembers:!0,upgradeTraces:!1,totalMembers:a,totalTraces:0}),o(),x.create({title:`Seats updated successfully`,type:`success`}),s.refetch()}catch(e){x.create({title:`Error updating seats`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}}})},handleManageSubscription:async()=>{if(e)try{let t=await p.mutateAsync({organizationId:e,baseUrl:window.location.origin});t.url&&(window.location.href=t.url)}catch(e){x.create({title:`Error opening subscription portal`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}},isUpgradeLoading:u.isPending||d.isPending,isUpdateSeatsLoading:f.isPending,isManageLoading:p.isPending}}function Y({totalPrice:e,seatCount:t,perSeatPrice:n,totalTestId:r}){return(0,K.jsxs)(N,{align:`start`,gap:0,children:[(0,K.jsxs)(E,{"data-testid":r,fontSize:`sm`,color:`fg`,children:[e,` for `,t,` seat`,t===1?``:`s`]}),n&&t>1&&(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:n})]})}function we({planName:e,pricing:t,features:n,userCount:r,maxSeats:i,upgradeRequired:a,onUserCountClick:o,onManageSubscription:s,isManageLoading:c,deprecatedNotice:l,contactSalesUrl:u}){return(0,K.jsx)(k,{"data-testid":`current-plan-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:5,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(O,{gap:3,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:e}),(0,K.jsx)(S,{colorPalette:`blue`,variant:`outline`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:`Current`}),a&&(0,K.jsx)(S,{colorPalette:`orange`,variant:`subtle`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:`Upgrade required`})]}),t&&(0,K.jsx)(Y,{totalPrice:t.totalPrice,seatCount:t.seatCount,perSeatPrice:t.perSeatPrice})]}),(0,K.jsxs)(N,{align:`end`,gap:0,children:[(0,K.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Members / Seats`}),o?(0,K.jsx)(y,{as:`button`,onClick:o,textDecoration:`underline`,_hover:{color:`blue.fg`,cursor:`pointer`},color:`fg`,children:(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,"data-testid":`user-count-link`,children:i==null?r:`${r}/${i}`})}):(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,color:`fg`,"data-testid":`user-count-link`,children:i==null?r:`${r}/${i}`})]})]}),n&&(0,K.jsx)(M,{"data-testid":`current-plan-features-grid`,templateColumns:{base:`1fr`,md:`1fr 1.4fr 1fr`},gap:3,children:n.map((e,t)=>(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-blue-solid)`}),(0,K.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:e})]},t))}),l&&(0,K.jsx)(y,{"data-testid":`tiered-deprecated-notice`,paddingTop:1,children:(0,K.jsxs)(E,{fontSize:`sm`,color:`fg.muted`,children:[`You are on a legacy tiered pricing model.`,` `,(0,K.jsx)(j,{href:`/settings/plans`,fontWeight:`semibold`,color:`fg`,_hover:{color:`fg`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})}),s&&(0,K.jsx)(v,{"data-testid":`manage-subscription-button`,variant:`outline`,size:`sm`,onClick:s,loading:c,disabled:c,children:`Manage Subscription`}),u&&(0,K.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,colorPalette:`orange`,"data-testid":`contact-sales-button`,children:(0,K.jsx)(j,{href:u,isExternal:!0,fontWeight:`semibold`,children:`Contact us to Upgrade`})})]})})})}function Te({totalFullMembers:e,totalPrice:t,monthlyEquivalent:n,onUpdate:r,onDiscard:i,isLoading:a}){return(0,K.jsx)(k,{"data-testid":`update-seats-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:`Update seats`}),(0,K.jsx)(Y,{totalPrice:t,seatCount:e,perSeatPrice:n})]}),(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(v,{"data-testid":`discard-seat-changes-button`,variant:`ghost`,size:`md`,onClick:i,disabled:a,children:`Discard`}),(0,K.jsx)(v,{colorPalette:`blue`,size:`md`,onClick:r,loading:a,disabled:a,children:`Update subscription`})]})]})})})}function Ee({planName:e,totalPrice:t,coreMembers:n,features:r,monthlyEquivalent:i,onUpgrade:a,isLoading:o}){return(0,K.jsx)(k,{"data-testid":`upgrade-plan-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:5,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(E,{fontWeight:`semibold`,fontSize:`lg`,children:[`Upgrade to `,e]}),(0,K.jsx)(Y,{totalPrice:t,seatCount:n,perSeatPrice:i,totalTestId:`upgrade-total`})]}),(0,K.jsx)(v,{colorPalette:`blue`,size:`md`,onClick:a,loading:o,disabled:o,children:`Upgrade now`})]}),(0,K.jsx)(M,{"data-testid":`upgrade-plan-features-grid`,templateColumns:{base:`1fr`,md:`1fr 1.4fr 1fr`},gap:2,children:r.map((e,t)=>(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-blue-solid)`}),(0,K.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:e})]},t))})]})})})}function X(e){switch(e){case`paid`:return`green`;case`open`:return`yellow`;case`void`:case`uncollectible`:return`red`;default:return`gray`}}function Z(e){return new Date(e*1e3).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function Q({amountCents:e,currency:t}){let n=e/100;return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t.toUpperCase(),minimumFractionDigits:2}).format(n)}function De({organizationId:e,onViewAllInStripe:t}){let n=F.subscription.listInvoices.useQuery({organizationId:e});return(0,K.jsx)(k,{"data-testid":`invoices-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:4,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:`Recent Invoices`}),!n.isLoading&&!n.isError&&n.data&&n.data.length>0&&t&&(0,K.jsx)(E,{"data-testid":`view-all-invoices-link`,as:`button`,fontSize:`sm`,color:`fg.muted`,cursor:`pointer`,_hover:{color:`blue.fg`},onClick:t,children:(0,K.jsxs)(O,{gap:1,children:[(0,K.jsx)(`span`,{children:`View all in Stripe`}),(0,K.jsx)(T,{size:14})]})})]}),n.isLoading&&(0,K.jsxs)(N,{"data-testid":`invoices-loading`,gap:2,children:[(0,K.jsx)(b,{height:`20px`,width:`100%`}),(0,K.jsx)(b,{height:`20px`,width:`100%`}),(0,K.jsx)(b,{height:`20px`,width:`100%`})]}),n.isError&&(0,K.jsx)(E,{color:`red.fg`,fontSize:`sm`,children:`Failed to load invoices. Please try again later.`}),!n.isLoading&&!n.isError&&n.data?.length===0&&(0,K.jsx)(E,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,paddingY:4,children:`No invoices yet`}),!n.isLoading&&!n.isError&&n.data&&n.data.length>0&&(0,K.jsxs)(h,{size:`sm`,variant:`outline`,children:[(0,K.jsx)(s,{children:(0,K.jsxs)(i,{children:[(0,K.jsx)(g,{children:`Invoice #`}),(0,K.jsx)(g,{children:`Date`}),(0,K.jsx)(g,{children:`Amount`}),(0,K.jsx)(g,{children:`Status`}),(0,K.jsx)(g,{children:`Actions`})]})}),(0,K.jsx)(a,{children:n.data.map(e=>(0,K.jsxs)(i,{children:[(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:e.number??`--`})}),(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:Z(e.date)})}),(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:Q({amountCents:e.amountDue,currency:e.currency})})}),(0,K.jsx)(m,{children:(0,K.jsx)(S,{colorPalette:X(e.status),variant:`subtle`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:e.status})}),(0,K.jsx)(m,{children:e.pdfUrl&&(0,K.jsx)(j,{"data-testid":`invoice-pdf-${e.id}`,href:e.pdfUrl,isExternal:!0,"aria-label":`Download PDF for invoice ${e.number??e.id}`,children:(0,K.jsxs)(O,{gap:1,color:`blue.fg`,fontSize:`sm`,children:[(0,K.jsx)(R,{size:14}),(0,K.jsx)(E,{children:`PDF`})]})})})]},e.id))})]})]})})})}function Oe({open:e,onClose:t,users:i,plannedUsers:a,pendingInvitesWithMemberType:s,seatPricePerPeriodCents:l,billingPeriod:u,currency:f,isLoading:m,onSave:h,maxSeats:g}){let[_,b]=(0,G.useState)([]),[x,T]=(0,G.useState)([]),[D,k]=(0,G.useState)({}),[A,j]=(0,G.useState)(0),M=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let t=e&&!M.current;if(M.current=e,!t)return;b([...i]);let n=J(i)+J(s)+J(a),r=g==null?0:Math.max(0,g-n);j(r);let o=Array.from({length:r},(e,t)=>({id:`auto-${Date.now()}-${t}`,email:``,memberType:`FullMember`}));T([...a,...o])},[e,i,a,s,g]);let P=(0,G.useCallback)(()=>{b([]),T([]),k({}),t()},[t]),ie=()=>{let e={id:`planned-${crypto.randomUUID()}`,email:``,memberType:`FullMember`};T(t=>[...t,e])},F=e=>{T(t=>t.filter(t=>t.id!==e))},I=(e,t)=>{T(n=>n.map(n=>n.id===e?{...n,email:t}:n)),k(t=>{let n={...t};return delete n[e],n})},ae=()=>{let e={};for(let t of x){let n=t.email.trim();n!==``&&!ye(n)&&(e[t.id]=`Please enter a valid email address`)}if(Object.keys(e).length>0){k(e);return}let n=x.filter(e=>e.id.startsWith(`auto-`)),r=x.filter(e=>e.id.startsWith(`planned-`)),i=n.filter(e=>e.email.trim()!==``),a=A-n.length;h({inviteEmails:i.map(e=>e.email),newSeats:r,deletedSeatCount:Math.max(0,a)}),t()},L=J(_)+J(s)+J(x),oe=L*l,R=u===`annual`?`/yr`:`/mo`,z=u===`annual`?`Annual Price:`:`Monthly Price:`;return(0,K.jsx)(n.Root,{open:e,placement:`end`,size:`lg`,onOpenChange:({open:e})=>{e||P()},children:(0,K.jsxs)(n.Content,{children:[(0,K.jsxs)(n.Header,{children:[(0,K.jsx)(ne,{size:`md`,children:`Manage Seats`}),(0,K.jsx)(n.CloseTrigger,{})]}),(0,K.jsx)(n.Body,{children:m?(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(te,{})}):(0,K.jsxs)(N,{align:`start`,gap:6,width:`full`,children:[(0,K.jsxs)(p,{width:`full`,children:[(0,K.jsx)(O,{justify:`flex-start`,width:`full`,children:(0,K.jsx)(d,{asChild:!0,children:(0,K.jsxs)(v,{variant:`ghost`,size:`xs`,color:`fg.muted`,fontSize:`xs`,children:[`Show members (`,_.length+s.length,`)`,(0,K.jsx)(o,{size:12})]})})}),(0,K.jsx)(c,{children:(0,K.jsx)(y,{as:`table`,width:`full`,style:{borderCollapse:`collapse`},children:(0,K.jsxs)(y,{as:`tbody`,children:[_.map(e=>(0,K.jsxs)(y,{as:`tr`,children:[(0,K.jsxs)(y,{as:`td`,paddingY:2,verticalAlign:`top`,children:[(0,K.jsx)(E,{fontSize:`sm`,fontWeight:`medium`,color:`fg`,children:e.email}),(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Active`})]}),(0,K.jsx)(y,{as:`td`,paddingY:2,textAlign:`right`,verticalAlign:`middle`,children:(0,K.jsx)(S,{colorPalette:e.memberType===`FullMember`?`blue`:`yellow`,variant:`outline`,children:e.memberType===`FullMember`?`Full Member`:`Lite Member`})})]},e.id)),s.map(e=>(0,K.jsxs)(y,{as:`tr`,opacity:.8,"data-testid":`pending-invite-${e.email}`,children:[(0,K.jsxs)(y,{as:`td`,paddingY:2,verticalAlign:`top`,children:[(0,K.jsx)(E,{fontSize:`sm`,fontWeight:`medium`,color:`fg`,children:e.email}),(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Invited - Waiting for acceptance`})]}),(0,K.jsx)(y,{as:`td`,paddingY:2,textAlign:`right`,verticalAlign:`middle`,children:(0,K.jsx)(S,{colorPalette:e.memberType===`FullMember`?`blue`:`yellow`,variant:`outline`,children:e.memberType===`FullMember`?`Full Member`:`Lite Member`})})]},e.id))]})})})]}),(0,K.jsxs)(N,{align:`start`,gap:3,width:`full`,children:[(0,K.jsxs)(O,{justify:`space-between`,width:`full`,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`sm`,color:`fg.muted`,children:`Seats available`}),(0,K.jsxs)(v,{variant:`outline`,size:`sm`,onClick:ie,children:[(0,K.jsx)(r,{size:16}),`Add Seat`]})]}),x.map((e,t)=>(0,K.jsxs)(N,{width:`full`,gap:1,align:`stretch`,children:[(0,K.jsxs)(O,{"data-testid":`pending-seat-${t}`,width:`full`,gap:2,padding:3,borderWidth:1,borderRadius:`md`,borderColor:D[e.id]?`red.emphasized`:`border`,children:[(0,K.jsx)(re,{"data-testid":`seat-email-${t}`,placeholder:`Enter email address`,size:`sm`,flex:1,value:e.email,onChange:t=>I(e.id,t.target.value)}),(0,K.jsx)(S,{"data-testid":`seat-member-type-${t}`,colorPalette:`blue`,variant:`outline`,children:`Full Member`}),(0,K.jsx)(v,{"data-testid":`remove-seat-${t}`,size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>F(e.id),children:(0,K.jsx)(ee,{size:14})})]}),D[e.id]&&(0,K.jsx)(E,{fontSize:`xs`,color:`red.fg`,paddingLeft:3,children:D[e.id]})]},e.id))]})]})}),(0,K.jsx)(n.Footer,{children:(0,K.jsxs)(N,{width:`full`,gap:4,children:[(0,K.jsxs)(N,{"data-testid":`drawer-footer-breakdown`,align:`stretch`,gap:2,fontSize:`sm`,padding:4,bg:`bg.subtle`,borderRadius:`md`,width:`full`,children:[(0,K.jsxs)(O,{justify:`space-between`,children:[(0,K.jsx)(E,{fontWeight:`bold`,children:`Total Seats:`}),(0,K.jsx)(E,{fontWeight:`bold`,"data-testid":`total-seats-footer-count`,children:L})]}),(0,K.jsx)(w,{}),(0,K.jsxs)(O,{justify:`space-between`,children:[(0,K.jsx)(E,{fontWeight:`bold`,children:z}),(0,K.jsxs)(E,{fontWeight:`bold`,color:`blue.fg`,"data-testid":`monthly-price-footer`,children:[U({cents:oe,currency:f}),R]})]})]}),(0,K.jsxs)(O,{width:`full`,justifyContent:`flex-end`,children:[(0,K.jsx)(v,{variant:`ghost`,onClick:P,children:`Cancel`}),(0,K.jsx)(v,{colorPalette:`blue`,onClick:ae,children:`Done`})]})]})})]})})}var ke=[{label:`€ EUR`,value:q.Currency.EUR},{label:`$ USD`,value:q.Currency.USD}],Ae=f({items:ke});function $(){let{organization:e,team:t}=ae(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(0),[c,l]=(0,G.useState)(null),[d,f]=(0,G.useState)(`monthly`),[p,m]=(0,G.useState)(!1),[ee,h]=(0,G.useState)(!1),g=F.currency.detectCurrency.useQuery({},{enabled:!!e}),_=c??g.data?.currency??q.Currency.EUR;(0,G.useEffect)(()=>{l(null)},[e?.id]),(0,G.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search);e.has(`success`)&&m(!0),e.has(`upgraded_from`)&&h(!0)}},[]);let b=F.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e}),w=F.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:e?.id??``},{enabled:!!e}),T=F.organization.getOrganizationPendingInvites.useQuery({organizationId:e?.id??``},{enabled:!!e}),re=F.organization.createInvites.useMutation(),k=(0,G.useMemo)(()=>w.data?w.data.members.map(e=>({id:e.userId,userId:e.userId,name:e.user.name??``,email:e.user.email??``,role:e.role,memberType:ve(e.role,void 0)})):[],[w.data]),A=b.data,M=A?.free??!0,P=A?.planSource===`license`,I=e?.pricingModel===q.PricingModel.TIERED,L=A?.type===`ENTERPRISE`&&!P,R=I&&!M&&!L&&!P;(0,G.useEffect)(()=>{R&&A&&se(A.type)&&f(`annual`)},[R,A?.type]);let V=A?le(A.type):null,H=V?V.billingInterval:d,W=V?V.currency:_,ge=(0,G.useMemo)(()=>T.data?T.data.filter(e=>e.status===`PENDING`).map(e=>({id:e.id,email:e.email,memberType:ve(e.role,void 0)})):[],[T.data]),_e=[...i,...ge],ye=J(k),Se=ye+J(_e),Y=A?.maxMembers,{seatPricePerPeriodCents:X,periodSuffix:Z,totalFullMembers:Q,monthlyEquivalent:$}=xe({currency:W,billingPeriod:H,users:k,plannedUsers:_e}),je=M||P?1:Y,Me=J(i),Ne=M||P?Math.max(Q,(je??0)+Me-o):Math.max(ye,(je??Q)+Me-o),Pe=R?Math.max(1,Q):Ne,Fe=`${U({cents:Ne*X,currency:W})}${Z}`,Ie=`${U({cents:Pe*X,currency:W})}${Z}`,Le=n=>{if(a(n.newSeats),s(n.deletedSeatCount),!M&&!P&&n.inviteEmails.length>0&&e?.id&&re.mutate({organizationId:e.id,invites:n.inviteEmails.map(e=>({email:e.toLowerCase(),role:q.OrganizationUserRole.MEMBER,...t?.id?{teams:[{teamId:t.id,role:q.TeamUserRole.MEMBER}]}:{}}))},{onSuccess:()=>{x.create({title:`Invites sent successfully`,type:`success`}),T.refetch(),w.refetch()},onError:e=>{ie(e)||x.create({title:`Failed to send invites`,description:e.message,type:`error`})}}),(M||P)&&n.inviteEmails.length>0){let e=n.inviteEmails.map((e,t)=>({id:`invite-${Date.now()}-${t}`,email:e,memberType:`FullMember`}));a(t=>[...t,...e])}},{handleUpgrade:Re,handleUpdateSeats:ze,handleManageSubscription:Be,isUpgradeLoading:Ve,isUpdateSeatsLoading:He,isManageLoading:Ue}=Ce({organizationId:e?.id,currency:W,billingPeriod:H,totalFullMembers:Pe,currentMaxMembers:Y??void 0,plannedUsers:i,onSeatsUpdated:()=>{a([]),s(0),b.refetch(),T.refetch()},organizationWithMembers:w,activePlanType:A?.type});if(!e||b.isLoading||g.isLoading)return(0,K.jsx)(z,{children:(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(te,{})})});if(b.isError||!A)return(0,K.jsx)(z,{children:(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(E,{color:`red.fg`,children:`Failed to load subscription information. Please try again later.`})})});let We=P?`License: ${A.name??`Growth`}`:I?A.name??be(A.type):M?`Free plan`:`Growth plan`,Ge=I||M||P?void 0:{totalPrice:`${U({cents:X*(A?.maxMembers??1),currency:W})}${Z}`,seatCount:A?.maxMembers??1,perSeatPrice:$},Ke=P?B(W):R?de({maxMembers:A?.maxMembers??0,maxMessagesPerMonth:A?.maxMessagesPerMonth??0,maxProjects:A?.maxProjects??0,maxMembersLite:A?.maxMembersLite??0}):L?fe:M?ue:B(W),qe=!M&&!R&&!L&&!P&&(i.length>0||o>0),Je=(M&&(i.length>0||o>0)||R||M||P)&&!L,Ye=(M&&(i.length>0||o>0)||R)&&!L,Xe=qe||(M?Ye:Je);return(0,K.jsxs)(z,{children:[(0,K.jsxs)(N,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsx)(ne,{size:`xl`,children:`Billing`}),(0,K.jsxs)(E,{color:`fg.muted`,children:[`For questions about billing,`,` `,(0,K.jsx)(j,{href:`mailto:sales@langwatch.ai`,fontWeight:`semibold`,color:`fg`,_hover:{color:`fg`},children:`contact us`})]})]}),(0,K.jsxs)(O,{gap:4,alignItems:`center`,children:[(M||R||P)&&!L&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(he,{"data-testid":`billing-period-toggle`,left:{label:`Monthly`,value:`monthly`},right:{label:`Annually`,value:`annual`},value:d,onChange:f}),(0,K.jsxs)(u.Root,{"data-testid":`currency-selector`,collection:Ae,size:`xs`,width:`100px`,value:[_],onValueChange:e=>{let t=e.value[0];t&&l(t)},children:[(0,K.jsx)(u.Trigger,{children:(0,K.jsx)(u.ValueText,{})}),(0,K.jsx)(u.Content,{paddingY:2,children:ke.map(e=>(0,K.jsx)(u.Item,{item:e,children:e.label},e.value))})]})]}),(0,K.jsx)(j,{href:`/settings/plans`,children:(0,K.jsxs)(v,{variant:`ghost`,size:`sm`,color:`fg.muted`,children:[`All plans `,(0,K.jsx)(oe,{size:14})]})})]})]}),p&&(0,K.jsx)(y,{"data-testid":`subscription-success`,backgroundColor:`green.subtle`,borderWidth:1,borderColor:`green.muted`,borderRadius:`md`,padding:4,children:(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-green-solid)`}),(0,K.jsx)(E,{fontWeight:`semibold`,color:`green.fg`,children:`Subscription activated successfully!`})]}),ee&&(0,K.jsx)(E,{fontSize:`sm`,color:`green.fg`,"data-testid":`credit-notice`,children:`Your previous plan has been prorated. Any unused credit has been applied to your account and will offset future invoices.`})]})}),(0,K.jsx)(we,{planName:We,pricing:Ge,features:Ke,userCount:Se,maxSeats:I?void 0:Y,upgradeRequired:Xe,onUserCountClick:()=>r(!0),onManageSubscription:!M&&!L&&!P?Be:void 0,isManageLoading:Ue,deprecatedNotice:R,contactSalesUrl:L?pe:void 0}),(0,K.jsx)(De,{organizationId:e.id,onViewAllInStripe:Be}),Je&&(0,K.jsx)(Ee,{planName:(0,K.jsxs)(K.Fragment,{children:[`Growth Plan`,` `,H===`annual`&&(0,K.jsxs)(S,{colorPalette:`green`,variant:`subtle`,fontSize:`xs`,children:[`Save `,ce(W),`%`]})]}),totalPrice:Ie,coreMembers:Pe,features:B(W),monthlyEquivalent:$,onUpgrade:Re,isLoading:Ve}),qe&&(0,K.jsx)(Te,{totalFullMembers:Ne,totalPrice:Fe,monthlyEquivalent:$,onUpdate:ze,onDiscard:()=>{a([]),s(0)},isLoading:He}),!L&&(0,K.jsx)(me,{})]}),(0,K.jsx)(Oe,{open:n,onClose:()=>r(!1),users:k,plannedUsers:i,pendingInvitesWithMemberType:ge,seatPricePerPeriodCents:X,billingPeriod:H,currency:W,isLoading:w.isLoading,onSave:Le,maxSeats:I?void 0:je})]})}export{$ as SubscriptionPage};
|
|
2
|
-
//# sourceMappingURL=SubscriptionPage-
|
|
1
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{Do as n,Fa as r,Ss as i,_s as a,ao as o,bs as s,ec as c,fa as l,na as u,nc as d,sc as f,tc as p,vs as m,wa as ee,xs as h,ys as g}from"./command-bar-DUK45yin.js";import{j as _,n as v,r as te}from"./stack-oJ9iWdbl.js";import{t as y}from"./box-BsM8YLGl.js";import{f as b}from"./LoadingScreen--vgXk5-2.js";import{n as x}from"./toaster-C_DYALhL.js";import{an as S,in as C}from"./dist-Cds4Mqhj.js";import{h as w}from"./terminal-CfM0q99k.js";import{i as T}from"./tracking-DbhAKeey.js";import{t as ne}from"./heading-D90dlSnH.js";import{t as E}from"./text-CwTrMF8x.js";import{n as D}from"./code-FF_ibTVI.js";import{t as re}from"./input-C7emsUCL.js";import{t as O}from"./h-stack-BKLDJ2vg.js";import{r as k,t as A}from"./card-CMtKVPVl.js";import{t as j}from"./link-CwZhwOLq.js";import{t as M}from"./simple-grid-C3IW90zo.js";import{t as N}from"./v-stack-EOPQ57OZ.js";import{c as P,m as ie,s as F}from"./auth-client-D3UhxhQi.js";import{c as I,t as ae}from"./useOrganizationTeamProject-DC0iozx2.js";import{j as L}from"./types-B5pOLKPA.js";import{t as oe}from"./arrow-right-B3ZN8yal.js";import{t as R}from"./download-X34ozaiD.js";import{t as z}from"./SettingsLayout--1gdEuhv.js";import{n as se}from"./planTypes-Cig7WlCp.js";import{a as B,c as ce,d as le,f as V,l as H,n as ue,r as de,s as U,t as fe,u as W}from"./billing-plans-BUQp08MI.js";import{t as pe}from"./constants-BT2q4NNM.js";import{t as me}from"./ContactSalesBlock-CnnuZ8iI.js";var G=e(t()),K=_();function he({left:e,right:t,value:n,onChange:r,"data-testid":i}){let a=(0,G.useId)(),o=`${a}-left`,s=`${a}-right`;return(0,K.jsxs)(O,{gap:2,"data-testid":i,children:[(0,K.jsx)(E,{id:o,fontWeight:n===e.value?`bold`:`normal`,fontSize:`sm`,children:e.label}),(0,K.jsx)(l,{colorPalette:`blue`,checked:n===t.value,onCheckedChange:n=>r(n.checked?t.value:e.value),"aria-labelledby":`${o} ${s}`}),(0,K.jsx)(E,{id:s,fontWeight:n===t.value?`bold`:`normal`,fontSize:`sm`,children:t.label})]})}var q=I();function ge(e){return e.split(`:`)[1]===`view`}function _e(e){return e.every(ge)}function ve(e,t){return e===q.OrganizationUserRole.ADMIN||e===q.OrganizationUserRole.MEMBER||e===q.OrganizationUserRole.EXTERNAL&&t&&!_e(t)?`FullMember`:`LiteMember`}var ye=e=>L().email().safeParse(e).success,J=e=>e.filter(e=>e.memberType===`FullMember`).length;function be(e){return e?e.startsWith(`GROWTH_SEAT_`)?`Growth`:e.toLowerCase().split(`_`).map(e=>e[0]?.toUpperCase()+e.slice(1)).join(` `):`Current plan`}function xe({currency:e,billingPeriod:t,users:n,plannedUsers:r}){let i=H(),a=t===`annual`?i[e].annual:i[e].monthly;return{seatPricePerPeriodCents:a,periodSuffix:t===`annual`?`/yr`:`/mo`,totalFullMembers:J(n)+J(r),monthlyEquivalent:t===`annual`?`${U({cents:Math.round(a/12),currency:e})}/mo per seat`:`${U({cents:a,currency:e})}/mo per seat`}}function Se(e){return e===`FullMember`?`MEMBER`:`EXTERNAL`}function Ce({organizationId:e,currency:t,billingPeriod:n,totalFullMembers:r,currentMaxMembers:i,plannedUsers:a,onSeatsUpdated:o,organizationWithMembers:s,activePlanType:c}){let l=P(e=>e.openSeats),u=F.subscription.create.useMutation(),d=F.subscription.upgradeWithInvites.useMutation(),f=F.subscription.addTeamMemberOrEvents.useMutation(),p=F.subscription.manage.useMutation();return{handleUpgrade:async()=>{if(e)try{let i=a.filter(e=>e.email.trim()!==``).map(e=>({email:e.email.trim(),role:Se(e.memberType)}));if(i.length>0){let a=await d.mutateAsync({organizationId:e,baseUrl:window.location.origin,currency:t,billingInterval:n,totalSeats:r,invites:i});a.url&&(window.location.href=a.url);return}let o=await u.mutateAsync({organizationId:e,baseUrl:window.location.origin,plan:V({currency:t,interval:n}),membersToAdd:r,currency:t,billingInterval:n});o.url&&(window.location.href=o.url)}catch(e){x.create({title:`Error upgrading subscription`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}},handleUpdateSeats:()=>{if(!e)return;let a=r;l({organizationId:e,currentSeats:i??r,newSeats:a,onConfirm:async()=>{try{let r=c&&W(c)?c:V({currency:t,interval:n});await f.mutateAsync({organizationId:e,plan:r,upgradeMembers:!0,upgradeTraces:!1,totalMembers:a,totalTraces:0}),o(),x.create({title:`Seats updated successfully`,type:`success`}),s.refetch()}catch(e){x.create({title:`Error updating seats`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}}})},handleManageSubscription:async()=>{if(e)try{let t=await p.mutateAsync({organizationId:e,baseUrl:window.location.origin});t.url&&(window.location.href=t.url)}catch(e){x.create({title:`Error opening subscription portal`,description:e instanceof Error?e.message:`An unexpected error occurred`,type:`error`,meta:{closable:!0}})}},isUpgradeLoading:u.isPending||d.isPending,isUpdateSeatsLoading:f.isPending,isManageLoading:p.isPending}}function Y({totalPrice:e,seatCount:t,perSeatPrice:n,totalTestId:r}){return(0,K.jsxs)(N,{align:`start`,gap:0,children:[(0,K.jsxs)(E,{"data-testid":r,fontSize:`sm`,color:`fg`,children:[e,` for `,t,` seat`,t===1?``:`s`]}),n&&t>1&&(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:n})]})}function we({planName:e,pricing:t,features:n,userCount:r,maxSeats:i,upgradeRequired:a,onUserCountClick:o,onManageSubscription:s,isManageLoading:c,deprecatedNotice:l,contactSalesUrl:u}){return(0,K.jsx)(k,{"data-testid":`current-plan-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:5,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(O,{gap:3,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:e}),(0,K.jsx)(S,{colorPalette:`blue`,variant:`outline`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:`Current`}),a&&(0,K.jsx)(S,{colorPalette:`orange`,variant:`subtle`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:`Upgrade required`})]}),t&&(0,K.jsx)(Y,{totalPrice:t.totalPrice,seatCount:t.seatCount,perSeatPrice:t.perSeatPrice})]}),(0,K.jsxs)(N,{align:`end`,gap:0,children:[(0,K.jsx)(E,{color:`fg.muted`,fontSize:`sm`,children:`Members / Seats`}),o?(0,K.jsx)(y,{as:`button`,onClick:o,textDecoration:`underline`,_hover:{color:`blue.fg`,cursor:`pointer`},color:`fg`,children:(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,"data-testid":`user-count-link`,children:i==null?r:`${r}/${i}`})}):(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,color:`fg`,"data-testid":`user-count-link`,children:i==null?r:`${r}/${i}`})]})]}),n&&(0,K.jsx)(M,{"data-testid":`current-plan-features-grid`,templateColumns:{base:`1fr`,md:`1fr 1.4fr 1fr`},gap:3,children:n.map((e,t)=>(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-blue-solid)`}),(0,K.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:e})]},t))}),l&&(0,K.jsx)(y,{"data-testid":`tiered-deprecated-notice`,paddingTop:1,children:(0,K.jsxs)(E,{fontSize:`sm`,color:`fg.muted`,children:[`You are on a legacy tiered pricing model.`,` `,(0,K.jsx)(j,{href:`/settings/plans`,fontWeight:`semibold`,color:`fg`,_hover:{color:`fg`},children:`Update your plan`}),` `,`to move to seat and usage billing.`]})}),s&&(0,K.jsx)(v,{"data-testid":`manage-subscription-button`,variant:`outline`,size:`sm`,onClick:s,loading:c,disabled:c,children:`Manage Subscription`}),u&&(0,K.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,colorPalette:`orange`,"data-testid":`contact-sales-button`,children:(0,K.jsx)(j,{href:u,isExternal:!0,fontWeight:`semibold`,children:`Contact us to Upgrade`})})]})})})}function Te({totalFullMembers:e,totalPrice:t,monthlyEquivalent:n,onUpdate:r,onDiscard:i,isLoading:a}){return(0,K.jsx)(k,{"data-testid":`update-seats-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:`Update seats`}),(0,K.jsx)(Y,{totalPrice:t,seatCount:e,perSeatPrice:n})]}),(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(v,{"data-testid":`discard-seat-changes-button`,variant:`ghost`,size:`md`,onClick:i,disabled:a,children:`Discard`}),(0,K.jsx)(v,{colorPalette:`blue`,size:`md`,onClick:r,loading:a,disabled:a,children:`Update subscription`})]})]})})})}function Ee({planName:e,totalPrice:t,coreMembers:n,features:r,monthlyEquivalent:i,onUpgrade:a,isLoading:o}){return(0,K.jsx)(k,{"data-testid":`upgrade-plan-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:5,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(E,{fontWeight:`semibold`,fontSize:`lg`,children:[`Upgrade to `,e]}),(0,K.jsx)(Y,{totalPrice:t,seatCount:n,perSeatPrice:i,totalTestId:`upgrade-total`})]}),(0,K.jsx)(v,{colorPalette:`blue`,size:`md`,onClick:a,loading:o,disabled:o,children:`Upgrade now`})]}),(0,K.jsx)(M,{"data-testid":`upgrade-plan-features-grid`,templateColumns:{base:`1fr`,md:`1fr 1.4fr 1fr`},gap:2,children:r.map((e,t)=>(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-blue-solid)`}),(0,K.jsx)(E,{fontSize:`sm`,color:`fg.muted`,children:e})]},t))})]})})})}function X(e){switch(e){case`paid`:return`green`;case`open`:return`yellow`;case`void`:case`uncollectible`:return`red`;default:return`gray`}}function Z(e){return new Date(e*1e3).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function Q({amountCents:e,currency:t}){let n=e/100;return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t.toUpperCase(),minimumFractionDigits:2}).format(n)}function De({organizationId:e,onViewAllInStripe:t}){let n=F.subscription.listInvoices.useQuery({organizationId:e});return(0,K.jsx)(k,{"data-testid":`invoices-block`,borderWidth:1,borderColor:`border`,children:(0,K.jsx)(A,{paddingY:5,paddingX:6,children:(0,K.jsxs)(N,{align:`stretch`,gap:4,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`center`,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`lg`,children:`Recent Invoices`}),!n.isLoading&&!n.isError&&n.data&&n.data.length>0&&t&&(0,K.jsx)(E,{"data-testid":`view-all-invoices-link`,as:`button`,fontSize:`sm`,color:`fg.muted`,cursor:`pointer`,_hover:{color:`blue.fg`},onClick:t,children:(0,K.jsxs)(O,{gap:1,children:[(0,K.jsx)(`span`,{children:`View all in Stripe`}),(0,K.jsx)(T,{size:14})]})})]}),n.isLoading&&(0,K.jsxs)(N,{"data-testid":`invoices-loading`,gap:2,children:[(0,K.jsx)(b,{height:`20px`,width:`100%`}),(0,K.jsx)(b,{height:`20px`,width:`100%`}),(0,K.jsx)(b,{height:`20px`,width:`100%`})]}),n.isError&&(0,K.jsx)(E,{color:`red.fg`,fontSize:`sm`,children:`Failed to load invoices. Please try again later.`}),!n.isLoading&&!n.isError&&n.data?.length===0&&(0,K.jsx)(E,{color:`fg.muted`,fontSize:`sm`,textAlign:`center`,paddingY:4,children:`No invoices yet`}),!n.isLoading&&!n.isError&&n.data&&n.data.length>0&&(0,K.jsxs)(h,{size:`sm`,variant:`outline`,children:[(0,K.jsx)(s,{children:(0,K.jsxs)(i,{children:[(0,K.jsx)(g,{children:`Invoice #`}),(0,K.jsx)(g,{children:`Date`}),(0,K.jsx)(g,{children:`Amount`}),(0,K.jsx)(g,{children:`Status`}),(0,K.jsx)(g,{children:`Actions`})]})}),(0,K.jsx)(a,{children:n.data.map(e=>(0,K.jsxs)(i,{children:[(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:e.number??`--`})}),(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:Z(e.date)})}),(0,K.jsx)(m,{children:(0,K.jsx)(E,{fontSize:`sm`,children:Q({amountCents:e.amountDue,currency:e.currency})})}),(0,K.jsx)(m,{children:(0,K.jsx)(S,{colorPalette:X(e.status),variant:`subtle`,borderRadius:`md`,paddingX:2,paddingY:.5,fontSize:`xs`,children:e.status})}),(0,K.jsx)(m,{children:e.pdfUrl&&(0,K.jsx)(j,{"data-testid":`invoice-pdf-${e.id}`,href:e.pdfUrl,isExternal:!0,"aria-label":`Download PDF for invoice ${e.number??e.id}`,children:(0,K.jsxs)(O,{gap:1,color:`blue.fg`,fontSize:`sm`,children:[(0,K.jsx)(R,{size:14}),(0,K.jsx)(E,{children:`PDF`})]})})})]},e.id))})]})]})})})}function Oe({open:e,onClose:t,users:i,plannedUsers:a,pendingInvitesWithMemberType:s,seatPricePerPeriodCents:l,billingPeriod:u,currency:f,isLoading:m,onSave:h,maxSeats:g}){let[_,b]=(0,G.useState)([]),[x,T]=(0,G.useState)([]),[D,k]=(0,G.useState)({}),[A,j]=(0,G.useState)(0),M=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let t=e&&!M.current;if(M.current=e,!t)return;b([...i]);let n=J(i)+J(s)+J(a),r=g==null?0:Math.max(0,g-n);j(r);let o=Array.from({length:r},(e,t)=>({id:`auto-${Date.now()}-${t}`,email:``,memberType:`FullMember`}));T([...a,...o])},[e,i,a,s,g]);let P=(0,G.useCallback)(()=>{b([]),T([]),k({}),t()},[t]),ie=()=>{let e={id:`planned-${crypto.randomUUID()}`,email:``,memberType:`FullMember`};T(t=>[...t,e])},F=e=>{T(t=>t.filter(t=>t.id!==e))},I=(e,t)=>{T(n=>n.map(n=>n.id===e?{...n,email:t}:n)),k(t=>{let n={...t};return delete n[e],n})},ae=()=>{let e={};for(let t of x){let n=t.email.trim();n!==``&&!ye(n)&&(e[t.id]=`Please enter a valid email address`)}if(Object.keys(e).length>0){k(e);return}let n=x.filter(e=>e.id.startsWith(`auto-`)),r=x.filter(e=>e.id.startsWith(`planned-`)),i=n.filter(e=>e.email.trim()!==``),a=A-n.length;h({inviteEmails:i.map(e=>e.email),newSeats:r,deletedSeatCount:Math.max(0,a)}),t()},L=J(_)+J(s)+J(x),oe=L*l,R=u===`annual`?`/yr`:`/mo`,z=u===`annual`?`Annual Price:`:`Monthly Price:`;return(0,K.jsx)(n.Root,{open:e,placement:`end`,size:`lg`,onOpenChange:({open:e})=>{e||P()},children:(0,K.jsxs)(n.Content,{children:[(0,K.jsxs)(n.Header,{children:[(0,K.jsx)(ne,{size:`md`,children:`Manage Seats`}),(0,K.jsx)(n.CloseTrigger,{})]}),(0,K.jsx)(n.Body,{children:m?(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(te,{})}):(0,K.jsxs)(N,{align:`start`,gap:6,width:`full`,children:[(0,K.jsxs)(p,{width:`full`,children:[(0,K.jsx)(O,{justify:`flex-start`,width:`full`,children:(0,K.jsx)(d,{asChild:!0,children:(0,K.jsxs)(v,{variant:`ghost`,size:`xs`,color:`fg.muted`,fontSize:`xs`,children:[`Show members (`,_.length+s.length,`)`,(0,K.jsx)(o,{size:12})]})})}),(0,K.jsx)(c,{children:(0,K.jsx)(y,{as:`table`,width:`full`,style:{borderCollapse:`collapse`},children:(0,K.jsxs)(y,{as:`tbody`,children:[_.map(e=>(0,K.jsxs)(y,{as:`tr`,children:[(0,K.jsxs)(y,{as:`td`,paddingY:2,verticalAlign:`top`,children:[(0,K.jsx)(E,{fontSize:`sm`,fontWeight:`medium`,color:`fg`,children:e.email}),(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Active`})]}),(0,K.jsx)(y,{as:`td`,paddingY:2,textAlign:`right`,verticalAlign:`middle`,children:(0,K.jsx)(S,{colorPalette:e.memberType===`FullMember`?`blue`:`yellow`,variant:`outline`,children:e.memberType===`FullMember`?`Full Member`:`Lite Member`})})]},e.id)),s.map(e=>(0,K.jsxs)(y,{as:`tr`,opacity:.8,"data-testid":`pending-invite-${e.email}`,children:[(0,K.jsxs)(y,{as:`td`,paddingY:2,verticalAlign:`top`,children:[(0,K.jsx)(E,{fontSize:`sm`,fontWeight:`medium`,color:`fg`,children:e.email}),(0,K.jsx)(E,{fontSize:`xs`,color:`fg.muted`,children:`Invited - Waiting for acceptance`})]}),(0,K.jsx)(y,{as:`td`,paddingY:2,textAlign:`right`,verticalAlign:`middle`,children:(0,K.jsx)(S,{colorPalette:e.memberType===`FullMember`?`blue`:`yellow`,variant:`outline`,children:e.memberType===`FullMember`?`Full Member`:`Lite Member`})})]},e.id))]})})})]}),(0,K.jsxs)(N,{align:`start`,gap:3,width:`full`,children:[(0,K.jsxs)(O,{justify:`space-between`,width:`full`,children:[(0,K.jsx)(E,{fontWeight:`semibold`,fontSize:`sm`,color:`fg.muted`,children:`Seats available`}),(0,K.jsxs)(v,{variant:`outline`,size:`sm`,onClick:ie,children:[(0,K.jsx)(r,{size:16}),`Add Seat`]})]}),x.map((e,t)=>(0,K.jsxs)(N,{width:`full`,gap:1,align:`stretch`,children:[(0,K.jsxs)(O,{"data-testid":`pending-seat-${t}`,width:`full`,gap:2,padding:3,borderWidth:1,borderRadius:`md`,borderColor:D[e.id]?`red.emphasized`:`border`,children:[(0,K.jsx)(re,{"data-testid":`seat-email-${t}`,placeholder:`Enter email address`,size:`sm`,flex:1,value:e.email,onChange:t=>I(e.id,t.target.value)}),(0,K.jsx)(S,{"data-testid":`seat-member-type-${t}`,colorPalette:`blue`,variant:`outline`,children:`Full Member`}),(0,K.jsx)(v,{"data-testid":`remove-seat-${t}`,size:`xs`,variant:`ghost`,colorPalette:`red`,onClick:()=>F(e.id),children:(0,K.jsx)(ee,{size:14})})]}),D[e.id]&&(0,K.jsx)(E,{fontSize:`xs`,color:`red.fg`,paddingLeft:3,children:D[e.id]})]},e.id))]})]})}),(0,K.jsx)(n.Footer,{children:(0,K.jsxs)(N,{width:`full`,gap:4,children:[(0,K.jsxs)(N,{"data-testid":`drawer-footer-breakdown`,align:`stretch`,gap:2,fontSize:`sm`,padding:4,bg:`bg.subtle`,borderRadius:`md`,width:`full`,children:[(0,K.jsxs)(O,{justify:`space-between`,children:[(0,K.jsx)(E,{fontWeight:`bold`,children:`Total Seats:`}),(0,K.jsx)(E,{fontWeight:`bold`,"data-testid":`total-seats-footer-count`,children:L})]}),(0,K.jsx)(w,{}),(0,K.jsxs)(O,{justify:`space-between`,children:[(0,K.jsx)(E,{fontWeight:`bold`,children:z}),(0,K.jsxs)(E,{fontWeight:`bold`,color:`blue.fg`,"data-testid":`monthly-price-footer`,children:[U({cents:oe,currency:f}),R]})]})]}),(0,K.jsxs)(O,{width:`full`,justifyContent:`flex-end`,children:[(0,K.jsx)(v,{variant:`ghost`,onClick:P,children:`Cancel`}),(0,K.jsx)(v,{colorPalette:`blue`,onClick:ae,children:`Done`})]})]})})]})})}var ke=[{label:`€ EUR`,value:q.Currency.EUR},{label:`$ USD`,value:q.Currency.USD}],Ae=f({items:ke});function $(){let{organization:e,team:t}=ae(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(0),[c,l]=(0,G.useState)(null),[d,f]=(0,G.useState)(`monthly`),[p,m]=(0,G.useState)(!1),[ee,h]=(0,G.useState)(!1),g=F.currency.detectCurrency.useQuery({},{enabled:!!e}),_=c??g.data?.currency??q.Currency.EUR;(0,G.useEffect)(()=>{l(null)},[e?.id]),(0,G.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search);e.has(`success`)&&m(!0),e.has(`upgraded_from`)&&h(!0)}},[]);let b=F.plan.getActivePlan.useQuery({organizationId:e?.id??``},{enabled:!!e}),w=F.organization.getOrganizationWithMembersAndTheirTeams.useQuery({organizationId:e?.id??``},{enabled:!!e}),T=F.organization.getOrganizationPendingInvites.useQuery({organizationId:e?.id??``},{enabled:!!e}),re=F.organization.createInvites.useMutation(),k=(0,G.useMemo)(()=>w.data?w.data.members.map(e=>({id:e.userId,userId:e.userId,name:e.user.name??``,email:e.user.email??``,role:e.role,memberType:ve(e.role,void 0)})):[],[w.data]),A=b.data,M=A?.free??!0,P=A?.planSource===`license`,I=e?.pricingModel===q.PricingModel.TIERED,L=A?.type===`ENTERPRISE`&&!P,R=I&&!M&&!L&&!P;(0,G.useEffect)(()=>{R&&A&&se(A.type)&&f(`annual`)},[R,A?.type]);let V=A?le(A.type):null,H=V?V.billingInterval:d,W=V?V.currency:_,ge=(0,G.useMemo)(()=>T.data?T.data.filter(e=>e.status===`PENDING`).map(e=>({id:e.id,email:e.email,memberType:ve(e.role,void 0)})):[],[T.data]),_e=[...i,...ge],ye=J(k),Se=ye+J(_e),Y=A?.maxMembers,{seatPricePerPeriodCents:X,periodSuffix:Z,totalFullMembers:Q,monthlyEquivalent:$}=xe({currency:W,billingPeriod:H,users:k,plannedUsers:_e}),je=M||P?1:Y,Me=J(i),Ne=M||P?Math.max(Q,(je??0)+Me-o):Math.max(ye,(je??Q)+Me-o),Pe=R?Math.max(1,Q):Ne,Fe=`${U({cents:Ne*X,currency:W})}${Z}`,Ie=`${U({cents:Pe*X,currency:W})}${Z}`,Le=n=>{if(a(n.newSeats),s(n.deletedSeatCount),!M&&!P&&n.inviteEmails.length>0&&e?.id&&re.mutate({organizationId:e.id,invites:n.inviteEmails.map(e=>({email:e.toLowerCase(),role:q.OrganizationUserRole.MEMBER,...t?.id?{teams:[{teamId:t.id,role:q.TeamUserRole.MEMBER}]}:{}}))},{onSuccess:()=>{x.create({title:`Invites sent successfully`,type:`success`}),T.refetch(),w.refetch()},onError:e=>{ie(e)||x.create({title:`Failed to send invites`,description:e.message,type:`error`})}}),(M||P)&&n.inviteEmails.length>0){let e=n.inviteEmails.map((e,t)=>({id:`invite-${Date.now()}-${t}`,email:e,memberType:`FullMember`}));a(t=>[...t,...e])}},{handleUpgrade:Re,handleUpdateSeats:ze,handleManageSubscription:Be,isUpgradeLoading:Ve,isUpdateSeatsLoading:He,isManageLoading:Ue}=Ce({organizationId:e?.id,currency:W,billingPeriod:H,totalFullMembers:Pe,currentMaxMembers:Y??void 0,plannedUsers:i,onSeatsUpdated:()=>{a([]),s(0),b.refetch(),T.refetch()},organizationWithMembers:w,activePlanType:A?.type});if(!e||b.isLoading||g.isLoading)return(0,K.jsx)(z,{children:(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(te,{})})});if(b.isError||!A)return(0,K.jsx)(z,{children:(0,K.jsx)(C,{justifyContent:`center`,padding:8,children:(0,K.jsx)(E,{color:`red.fg`,children:`Failed to load subscription information. Please try again later.`})})});let We=P?`License: ${A.name??`Growth`}`:I?A.name??be(A.type):M?`Free plan`:`Growth plan`,Ge=I||M||P?void 0:{totalPrice:`${U({cents:X*(A?.maxMembers??1),currency:W})}${Z}`,seatCount:A?.maxMembers??1,perSeatPrice:$},Ke=P?B(W):R?de({maxMembers:A?.maxMembers??0,maxMessagesPerMonth:A?.maxMessagesPerMonth??0,maxProjects:A?.maxProjects??0,maxMembersLite:A?.maxMembersLite??0}):L?fe:M?ue:B(W),qe=!M&&!R&&!L&&!P&&(i.length>0||o>0),Je=(M&&(i.length>0||o>0)||R||M||P)&&!L,Ye=(M&&(i.length>0||o>0)||R)&&!L,Xe=qe||(M?Ye:Je);return(0,K.jsxs)(z,{children:[(0,K.jsxs)(N,{gap:6,width:`full`,align:`stretch`,maxWidth:`900px`,marginX:`auto`,children:[(0,K.jsxs)(C,{justifyContent:`space-between`,alignItems:`flex-start`,children:[(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsx)(ne,{size:`xl`,children:`Billing`}),(0,K.jsxs)(E,{color:`fg.muted`,children:[`For questions about billing,`,` `,(0,K.jsx)(j,{href:`mailto:sales@langwatch.ai`,fontWeight:`semibold`,color:`fg`,_hover:{color:`fg`},children:`contact us`})]})]}),(0,K.jsxs)(O,{gap:4,alignItems:`center`,children:[(M||R||P)&&!L&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(he,{"data-testid":`billing-period-toggle`,left:{label:`Monthly`,value:`monthly`},right:{label:`Annually`,value:`annual`},value:d,onChange:f}),(0,K.jsxs)(u.Root,{"data-testid":`currency-selector`,collection:Ae,size:`xs`,width:`100px`,value:[_],onValueChange:e=>{let t=e.value[0];t&&l(t)},children:[(0,K.jsx)(u.Trigger,{children:(0,K.jsx)(u.ValueText,{})}),(0,K.jsx)(u.Content,{paddingY:2,children:ke.map(e=>(0,K.jsx)(u.Item,{item:e,children:e.label},e.value))})]})]}),(0,K.jsx)(j,{href:`/settings/plans`,children:(0,K.jsxs)(v,{variant:`ghost`,size:`sm`,color:`fg.muted`,children:[`All plans `,(0,K.jsx)(oe,{size:14})]})})]})]}),p&&(0,K.jsx)(y,{"data-testid":`subscription-success`,backgroundColor:`green.subtle`,borderWidth:1,borderColor:`green.muted`,borderRadius:`md`,padding:4,children:(0,K.jsxs)(N,{align:`start`,gap:1,children:[(0,K.jsxs)(O,{gap:2,children:[(0,K.jsx)(D,{size:16,color:`var(--chakra-colors-green-solid)`}),(0,K.jsx)(E,{fontWeight:`semibold`,color:`green.fg`,children:`Subscription activated successfully!`})]}),ee&&(0,K.jsx)(E,{fontSize:`sm`,color:`green.fg`,"data-testid":`credit-notice`,children:`Your previous plan has been prorated. Any unused credit has been applied to your account and will offset future invoices.`})]})}),(0,K.jsx)(we,{planName:We,pricing:Ge,features:Ke,userCount:Se,maxSeats:I?void 0:Y,upgradeRequired:Xe,onUserCountClick:()=>r(!0),onManageSubscription:!M&&!L&&!P?Be:void 0,isManageLoading:Ue,deprecatedNotice:R,contactSalesUrl:L?pe:void 0}),(0,K.jsx)(De,{organizationId:e.id,onViewAllInStripe:Be}),Je&&(0,K.jsx)(Ee,{planName:(0,K.jsxs)(K.Fragment,{children:[`Growth Plan`,` `,H===`annual`&&(0,K.jsxs)(S,{colorPalette:`green`,variant:`subtle`,fontSize:`xs`,children:[`Save `,ce(W),`%`]})]}),totalPrice:Ie,coreMembers:Pe,features:B(W),monthlyEquivalent:$,onUpgrade:Re,isLoading:Ve}),qe&&(0,K.jsx)(Te,{totalFullMembers:Ne,totalPrice:Fe,monthlyEquivalent:$,onUpdate:ze,onDiscard:()=>{a([]),s(0)},isLoading:He}),!L&&(0,K.jsx)(me,{})]}),(0,K.jsx)(Oe,{open:n,onClose:()=>r(!1),users:k,plannedUsers:i,pendingInvitesWithMemberType:ge,seatPricePerPeriodCents:X,billingPeriod:H,currency:W,isLoading:w.isLoading,onSave:Le,maxSeats:I?void 0:je})]})}export{$ as SubscriptionPage};
|
|
2
|
+
//# sourceMappingURL=SubscriptionPage-B0ox_4kM.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-BaAzBaqq.js","assets/preload-helper-rov5CBGT.js","assets/html-void-elements-BETCRsX6.js","assets/chunk-Bj-mKKzh.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{t as n}from"./preload-helper-rov5CBGT.js";import{$a as r,Do as i,Fa as a,gs as o,rc as s,uo as c,wa as l}from"./command-bar-
|
|
2
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{t as n}from"./preload-helper-rov5CBGT.js";import{$a as r,Do as i,Fa as a,gs as o,rc as s,uo as c,wa as l}from"./command-bar-DUK45yin.js";import{j as u,n as d}from"./stack-oJ9iWdbl.js";import{t as f}from"./box-BsM8YLGl.js";import{c as p,m}from"./LoadingScreen--vgXk5-2.js";import{a as h,c as g,o as _,r as v,t as y}from"./tabs-DwV1cIZB.js";import{n as b}from"./toaster-C_DYALhL.js";import{an as ee,f as x}from"./dist-Cds4Mqhj.js";import{S,T as C,_ as w,b as T,c as te,g as E,h as D,l as O,v as k,w as A,x as j,y as M}from"./terminal-CfM0q99k.js";import{r as ne,t as re}from"./native-select-B51i56CE.js";import{t as N}from"./text-CwTrMF8x.js";import{n as ie}from"./code-FF_ibTVI.js";import{a as P,n as F,r as I}from"./field-CnUiixMS.js";import{t as L}from"./input-C7emsUCL.js";import{t as R}from"./h-stack-BKLDJ2vg.js";import{a as z,i as B,n as V,r as H,t as U}from"./alert-SnQmACl1.js";import{Pt as W}from"./lu-Bf6j_N19.js";import{n as G}from"./link-CwZhwOLq.js";import{t as ae}from"./spacer-2LJJGbo8.js";import{t as K}from"./v-stack-EOPQ57OZ.js";import{s as q}from"./auth-client-D3UhxhQi.js";import{t as oe}from"./arrow-down-DRWC2hGk.js";import{n as J}from"./ConfirmDialog-M94yLNvP.js";var Y=e(t());function se({aliases:e,boundProviderTypes:t}){let n=[];for(let[r,i]of Object.entries(e)){if(!i.includes(`/`))continue;let e=i.split(`/`,1)[0];e&&!t.has(e)&&n.push(`Alias "${r}" → "${i}" references provider "${e}", which is not bound on this VK (bound: ${[...t].join(`, `)||`none`}).`)}return{errors:n}}var X=u(),ce={pre:{label:`Request (pre)`,description:`Runs on inbound request body. Block → 403 guardrail_blocked before any provider call. Fail-closed by default (503 guardrail_upstream_unavailable); toggle fail-open below to allow on evaluator timeout.`},post:{label:`Response (post)`,description:`Runs on assistant text before the client sees it. Block → 403 + zero-cost debit. Modify → in-place redaction. Fail-closed by default.`},streamChunk:{label:`Stream chunk`,description:`Runs per visible delta on SSE responses (role-only/tool-call/usage frames skip). Block → terminal SSE event:error with code=stream_chunk_blocked. Timeout/error always fail-open per contract (50ms budget).`}},le={tools:{label:`Tools`,placeholderDeny:`e.g. ^shell_.*
|
|
3
3
|
delete_user`,helper:`RE2 regexes matched against OpenAI tools[].function.name + Anthropic tools[].name. Deny wins.`},mcp:{label:`MCP servers`,placeholderDeny:`e.g. unapproved\\.example\\.com`,helper:`Matched against mcp_servers[].name and .url. Deny wins; applies before dispatch.`},urls:{label:`URLs`,placeholderDeny:`e.g. internal\\.corp\\..*`,helper:`Extracted from the raw request body (user messages, tool args, system prompts). First deny match → 403 url_not_allowed.`},models:{label:`Models (policy)`,placeholderDeny:`e.g. gpt-4o-search.*`,helper:"RE2 regex policy distinct from the glob `modelsAllowed` allowlist above. Use this to enforce company policy (e.g. no non-deterministic models)."}};function ue({projectId:e,vk:t,onOpenChange:n,onSaved:r}){let[u,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)([]),[v,y]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(`respect`),[C,w]=(0,Y.useState)(3600),[T,te]=(0,Y.useState)(``),[E,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)({tools:{deny:``,allow:``},mcp:{deny:``,allow:``},urls:{deny:``,allow:``},models:{deny:``,allow:``}}),[ie,z]=(0,Y.useState)(``),[B,V]=(0,Y.useState)({pre:[],post:[],streamChunk:[]}),[H,U]=(0,Y.useState)(!1),[G,ue]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!t)return;p(t.name),h(t.description??``),_(t.providerCredentialIds),y(Object.entries(t.config.modelAliases??{}).map(([e,t])=>({from:e,to:t}))),S(t.config.cache?.mode??`respect`),w(t.config.cache?.ttlS??3600),z((t.config.metadata?.tags??[]).join(`, `)),te(t.config.rateLimits?.rpm?.toString()??``),O(t.config.rateLimits?.tpm?.toString()??``),A(t.config.rateLimits?.rpd?.toString()??``);let e=t.config.policyRules??{};M({tools:{deny:(e.tools?.deny??[]).join(`
|
|
4
4
|
`),allow:(e.tools?.allow??[]).join(`
|
|
5
5
|
`)},mcp:{deny:(e.mcp?.deny??[]).join(`
|
|
@@ -60,4 +60,4 @@ func main() {
|
|
|
60
60
|
"model": "gpt-5-mini",
|
|
61
61
|
"messages": [{"role": "user", "content": "Hello"}]
|
|
62
62
|
}'`;return[{key:`python`,title:`Python`,code:e,language:`python`,highlightLines:[4,5]},{key:`typescript`,title:`TypeScript`,code:t,language:`typescript`,highlightLines:[4,5]},{key:`go`,title:`Go`,code:n,language:`go`,highlightLines:[13,14]},{key:`bash`,title:`cURL`,code:r,language:`bash`,highlightLines:[1,2]}]},[o,a]),c=g({defaultValue:`python`}),l=s.find(e=>e.key===c.value)??s[0],u=s.filter(e=>e.key!==c.value),d=(0,Y.useMemo)(()=>C({async load(){let{createHighlighter:e}=await n(async()=>{let{createHighlighter:e}=await import(`./dist-BaAzBaqq.js`);return{createHighlighter:e}},__vite__mapDeps([0,1,2,3]));return e({langs:[`typescript`,`python`,`go`,`bash`],themes:[`github-dark`,`github-light`]})},theme:i===`dark`?`github-dark`:`github-light`}),[i]);return(0,X.jsxs)(K,{align:`stretch`,gap:2,children:[(0,X.jsx)(N,{fontWeight:`medium`,children:r}),(0,X.jsxs)(N,{textStyle:`xs`,color:`fg.muted`,children:[`Works with any OpenAI-compatible SDK or coding assistant (Claude Code, Codex, Cursor, Aider).`,` `,(0,X.jsx)(G,{href:`https://langwatch.ai/docs/ai-gateway/quickstart`,color:`orange.600`,target:`_blank`,rel:`noreferrer`,children:`Read more →`})]}),(0,X.jsx)(h,{value:c,size:`sm`,variant:`line`,children:(0,X.jsx)(A,{value:d,children:(0,X.jsx)(m,{children:()=>(0,X.jsxs)(S,{code:l.code,language:l.language,size:`sm`,meta:{highlightLines:l.highlightLines,colorScheme:i},transition:`all 0.3s ease`,bg:`bg.panel/60`,borderRadius:`xl`,border:`1px solid`,borderColor:`border`,backdropFilter:`blur(20px) saturate(1.3)`,boxShadow:`0 2px 16px rgba(0,0,0,0.04)`,overflow:`hidden`,children:[(0,X.jsxs)(j,{borderBottomWidth:`1px`,borderColor:`border`,children:[(0,X.jsx)(v,{w:`full`,border:`0`,ms:`-1`,children:s.map(e=>(0,X.jsx)(_,{colorPalette:`teal`,value:e.key,textStyle:`xs`,"data-testid":`vk-usage-tab-${e.key}`,children:e.title},e.key))}),(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(W,{variant:`ghost`,size:`2xs`,mr:`-4px`,children:(0,X.jsx)(M,{})})})]}),(0,X.jsxs)(k,{transition:`background-color 0.3s ease, color 0.3s ease`,css:{"& pre, & code":{transition:`background-color 0.3s ease, color 0.3s ease`}},overflow:`scroll`,children:[u.map(e=>(0,X.jsx)(y,{value:e.key},e.key)),(0,X.jsx)(y,{pt:`1`,value:l.key,children:(0,X.jsx)(E,{children:(0,X.jsx)(w,{})})})]})]})})})}),!e&&(0,X.jsxs)(N,{textStyle:`xs`,color:`fg.muted`,children:[`Set `,(0,X.jsx)(`code`,{children:`LANGWATCH_VK_SECRET`}),` to the VK secret from the create-or-rotate flow. The raw secret is shown once and not retrievable afterwards.`]})]})}function pe({open:e,onClose:t,keyName:n,secret:i,kind:a=`create`}){let[o,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1);return(0,X.jsx)(x.Root,{open:e,onOpenChange:()=>{},role:`alertdialog`,closeOnInteractOutside:!1,closeOnEscape:!1,children:(0,X.jsxs)(x.Content,{maxWidth:`560px`,children:[(0,X.jsx)(x.Header,{children:(0,X.jsx)(x.Title,{children:a===`rotate`?`Save your rotated secret`:`Save your virtual key secret`})}),(0,X.jsx)(x.Body,{children:(0,X.jsxs)(K,{align:`stretch`,gap:4,children:[(0,X.jsxs)(B,{status:`warning`,children:[(0,X.jsx)(H,{}),(0,X.jsxs)(U,{children:[(0,X.jsx)(z,{children:`You will only see this secret once.`}),(0,X.jsx)(V,{children:`LangWatch stores only a hash. Copy and save the raw secret in your password manager or secret store before closing.`})]})]}),a===`rotate`&&(0,X.jsxs)(B,{status:`info`,children:[(0,X.jsx)(H,{}),(0,X.jsxs)(U,{children:[(0,X.jsx)(z,{children:`24-hour grace window active.`}),(0,X.jsx)(V,{children:`The previous secret keeps working for 24 hours so clients can roll over gradually. After that it hard- fails with a 401 even though this key stays active.`})]})]}),(0,X.jsxs)(K,{align:`start`,gap:1,children:[(0,X.jsx)(N,{fontSize:`sm`,color:`fg.muted`,children:`Virtual key name`}),(0,X.jsx)(N,{fontWeight:`medium`,children:n})]}),(0,X.jsxs)(K,{align:`stretch`,gap:2,children:[(0,X.jsx)(N,{fontSize:`sm`,color:`fg.muted`,children:`Secret`}),(0,X.jsxs)(R,{border:`1px solid`,borderColor:`border.subtle`,borderRadius:`md`,padding:2,gap:2,children:[(0,X.jsx)(f,{flex:1,overflowX:`auto`,children:(0,X.jsx)(s,{fontSize:`sm`,bg:`transparent`,paddingX:0,whiteSpace:`nowrap`,children:o?i:me(i)})}),(0,X.jsx)(W,{"aria-label":o?`Hide secret`:`Reveal secret`,variant:`ghost`,size:`sm`,onClick:()=>c(e=>!e),children:o?(0,X.jsx)(O,{size:14}):(0,X.jsx)(te,{size:14})}),(0,X.jsx)(W,{"aria-label":`Copy secret`,variant:`ghost`,size:`sm`,onClick:async()=>{await navigator.clipboard.writeText(i),u(!0),window.setTimeout(()=>u(!1),1500)},children:l?(0,X.jsx)(ie,{size:14}):(0,X.jsx)(r,{size:14})})]})]}),(0,X.jsx)(D,{}),(0,X.jsx)(Q,{secret:i})]})}),(0,X.jsx)(x.Footer,{children:(0,X.jsxs)(R,{width:`full`,gap:4,children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`vk-secret-confirm`,checked:p,onChange:e=>m(e.target.checked)}),(0,X.jsx)(`label`,{htmlFor:`vk-secret-confirm`,children:(0,X.jsx)(N,{fontSize:`sm`,children:`I've saved the secret in a safe place.`})})]}),(0,X.jsx)(f,{flex:1}),(0,X.jsx)(d,{colorPalette:`orange`,onClick:()=>{c(!1),u(!1),m(!1),t()},disabled:!p,children:`Close`})]})})]})})}function me(e){return e.length<=14?`••••`:`${e.slice(0,14)}${`•`.repeat(Math.max(0,e.length-14))}`}export{Q as n,ue as r,pe as t};
|
|
63
|
-
//# sourceMappingURL=VirtualKeySecretReveal-
|
|
63
|
+
//# sourceMappingURL=VirtualKeySecretReveal-CRbI1dKQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$o as e}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=WithPermissionGuard-
|
|
1
|
+
import{$o as e}from"./command-bar-DUK45yin.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./box-BsM8YLGl.js";import{t as r}from"./text-CwTrMF8x.js";import{a as i,i as a,n as o,r as s,t as c}from"./alert-SnQmACl1.js";import{t as l}from"./useOrganizationTeamProject-DC0iozx2.js";var u=t();function d({message:t,alertProps:l={},permission:d}){let f=`You don't have permission to view this content. Required permission: ${d}. Ask your team administrator to request access.`,p=t??f;return(0,u.jsx)(n,{padding:4,children:(0,u.jsxs)(a,{status:`warning`,...l,children:[(0,u.jsx)(s,{children:(0,u.jsx)(e,{size:16})}),(0,u.jsxs)(c,{children:[(0,u.jsx)(i,{children:`Access Restricted`}),(0,u.jsx)(o,{children:(0,u.jsx)(r,{children:p})})]})]})})}function f(e,t){return function(n){let{fallbackComponent:r=d,layoutComponent:i,customMessage:a}=t??{},o=t=>{let{hasAnyPermission:o,isLoading:s}=l();if(s)return(0,u.jsx)(n,{...t});if(!o(e)){let t=(0,u.jsx)(r,{permission:e,message:a});return i?(0,u.jsx)(i,{children:t}):t}return(0,u.jsx)(n,{...t})};return o.displayName=`withPermissionGuard(${n.displayName??n.name??`Component`})`,o}}export{d as n,f as t};
|
|
2
|
+
//# sourceMappingURL=WithPermissionGuard-B4Jo8E5-.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$i as n,$s as r,A as i,B as a,Ba as o,Ca as s,D as c,E as l,Ea as u,F as d,Fa as f,Fr as p,G as m,H as h,I as g,Io as _,Ja as v,L as y,La as b,M as ee,N as x,Na as S,O as C,P as w,Qs as T,R as te,Ra as E,V as ne,Va as D,W as O,Xa as re,Xr as ie,Xs as ae,Ya as oe,Ys as se,Zs as ce,a as k,ao as A,at as le,ea as ue,ei as j,eo as M,i as de,io as fe,it as N,j as pe,k as P,mn as F,no as me,o as I,q as he,qo as L,r as ge,rt as R,s as _e,ya as ve,z as ye}from"./command-bar-
|
|
1
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$i as n,$s as r,A as i,B as a,Ba as o,Ca as s,D as c,E as l,Ea as u,F as d,Fa as f,Fr as p,G as m,H as h,I as g,Io as _,Ja as v,L as y,La as b,M as ee,N as x,Na as S,O as C,P as w,Qs as T,R as te,Ra as E,V as ne,Va as D,W as O,Xa as re,Xr as ie,Xs as ae,Ya as oe,Ys as se,Zs as ce,a as k,ao as A,at as le,ea as ue,ei as j,eo as M,i as de,io as fe,it as N,j as pe,k as P,mn as F,no as me,o as I,q as he,qo as L,r as ge,rt as R,s as _e,ya as ve,z as ye}from"./command-bar-DUK45yin.js";import{j as be,n as z,r as B}from"./stack-oJ9iWdbl.js";import{t as V}from"./box-BsM8YLGl.js";import{f as xe,l as Se}from"./LoadingScreen--vgXk5-2.js";import{r as Ce}from"./dialog.anatomy-hrluUh9u.js";import{t as H}from"./tooltip-AEm0YeiF.js";import{n as U}from"./toaster-C_DYALhL.js";import{f as W,rt as we}from"./dist-Cds4Mqhj.js";import{h as Te}from"./terminal-CfM0q99k.js";import{n as Ee,r as De,t as Oe}from"./native-select-B51i56CE.js";import{t as G}from"./text-CwTrMF8x.js";import{i as ke,n as Ae}from"./code-FF_ibTVI.js";import{t as je}from"./icon-BwEPrfAc.js";import{t as K}from"./h-stack-BKLDJ2vg.js";import{r as Me,t as Ne}from"./card-CMtKVPVl.js";import{Mt as Pe,O as Fe,Pt as Ie,b as Le}from"./lu-Bf6j_N19.js";import{t as Re}from"./spacer-2LJJGbo8.js";import{t as q}from"./v-stack-EOPQ57OZ.js";import{l as ze,s as J}from"./auth-client-D3UhxhQi.js";import{r as Be}from"./next-router-C6sliiV7.js";import{t as Ve}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as He}from"./createLucideIcon-BJKFyRLS.js";import{t as Ue}from"./ban-90mrVpKK.js";import{t as We}from"./chart-column-AuWZxhn9.js";import{t as Ge}from"./square-9W0gaHHd.js";import{t as Ke}from"./WithPermissionGuard-B4Jo8E5-.js";import{n as qe,r as Je,t as Ye}from"./PassRateIndicator-BvWYud47.js";var Xe=He(`crosshair`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]),Ze=He(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Qe=He(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),$e=He(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),et=He(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),tt=He(`repeat-2`,[[`path`,{d:`m2 9 3-3 3 3`,key:`1ltn5i`}],[`path`,{d:`M13 18H7a2 2 0 0 1-2-2V6`,key:`1r6tfw`}],[`path`,{d:`m22 15-3 3-3-3`,key:`4rnwn2`}],[`path`,{d:`M11 6h6a2 2 0 0 1 2 2v10`,key:`2f72bc`}]]),Y=e(t()),X=be(),nt={none:`None`,scenario:`Scenario`,target:`Target`};function rt({scenarioOptions:e,filters:t,onFiltersChange:n,groupBy:r,onGroupByChange:i,groupByOptions:a=[...C],viewMode:s,onViewModeChange:c}){return(0,X.jsxs)(K,{gap:3,flexWrap:`wrap`,justifyContent:`space-between`,children:[(0,X.jsxs)(K,{gap:3,flexWrap:`wrap`,children:[(0,X.jsxs)(De,{size:`sm`,width:`auto`,minWidth:`150px`,children:[(0,X.jsxs)(Oe,{value:t.scenarioId,onChange:e=>n({...t,scenarioId:e.target.value}),"aria-label":`Filter by scenario`,children:[(0,X.jsx)(`option`,{value:``,children:`All Scenarios`}),e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,X.jsx)(Ee,{})]}),(0,X.jsxs)(De,{size:`sm`,width:`auto`,minWidth:`120px`,children:[(0,X.jsxs)(Oe,{value:t.passFailStatus,onChange:e=>n({...t,passFailStatus:e.target.value}),"aria-label":`Filter by pass/fail status`,children:[(0,X.jsx)(`option`,{value:``,children:`All Statuses`}),(0,X.jsx)(`option`,{value:`pass`,children:`Pass`}),(0,X.jsx)(`option`,{value:`fail`,children:`Fail`}),(0,X.jsx)(`option`,{value:`stalled`,children:`Stalled`})]}),(0,X.jsx)(Ee,{})]})]}),(0,X.jsxs)(K,{gap:3,children:[c&&(0,X.jsxs)(K,{gap:1,role:`group`,"aria-label":`View mode`,children:[(0,X.jsx)(Ie,{"aria-label":`List view`,"aria-pressed":s===`list`,size:`xs`,variant:s===`list`?`solid`:`ghost`,onClick:()=>c(`list`),children:(0,X.jsx)(o,{size:14})}),(0,X.jsx)(Ie,{"aria-label":`Grid view`,"aria-pressed":s===`grid`,size:`xs`,variant:s===`grid`?`solid`:`ghost`,onClick:()=>c(`grid`),children:(0,X.jsx)(Ze,{size:14})})]}),i&&(0,X.jsxs)(K,{gap:2,children:[(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,whiteSpace:`nowrap`,children:`Group by:`}),(0,X.jsxs)(De,{size:`sm`,width:`auto`,minWidth:`120px`,children:[(0,X.jsx)(Oe,{value:r??`none`,onChange:e=>i(e.target.value),"aria-label":`Group by`,children:a.map(e=>(0,X.jsx)(`option`,{value:e,children:nt[e]},e))}),(0,X.jsx)(Ee,{})]})]})]})]})}var it=(0,Y.createContext)(Date.now());function at(){return(0,Y.useContext)(it)}var ot={pass:`
|
|
2
2
|
radial-gradient(ellipse at 0% 100%, rgba(134, 239, 172, 0.55) 0%, transparent 50%),
|
|
3
3
|
radial-gradient(ellipse at 100% 50%, rgba(72, 187, 120, 0.5) 0%, transparent 45%),
|
|
4
4
|
radial-gradient(ellipse at 70% 0%, rgba(56, 161, 105, 0.55) 0%, transparent 50%),
|
|
@@ -35,4 +35,4 @@ import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";impor
|
|
|
35
35
|
radial-gradient(ellipse at 100% 50%, rgba(245, 158, 11, 0.42) 0%, transparent 50%),
|
|
36
36
|
linear-gradient(160deg, rgba(217, 119, 6, 0.48) 0%, rgba(251, 191, 36, 0.32) 100%)
|
|
37
37
|
`},ct={[R.SUCCESS]:`pass`,[R.FAILED]:`fail`,[R.ERROR]:`fail`,[R.CANCELLED]:`cancelled`,[R.STALLED]:`stalled`,[R.IN_PROGRESS]:`cancelled`,[R.PENDING]:`cancelled`,[R.QUEUED]:`cancelled`,[R.RUNNING]:`cancelled`};function lt({status:e}){let t=I[e].isComplete,n=ct[e],r=Se(ot[n],st[n]);return t?(0,X.jsx)(V,{position:`absolute`,top:0,left:0,right:0,bottom:0,background:r,zIndex:1,pointerEvents:`none`}):null}function ut({title:e,status:t}){return(0,X.jsx)(V,{py:2,px:3,w:`100%`,position:`relative`,zIndex:2,children:(0,X.jsx)(G,{fontSize:`xs`,fontWeight:`semibold`,color:t&&I[t].isComplete?`white`:`fg`,lineClamp:2,children:e})})}function dt(){return(0,X.jsxs)(q,{p:4,gap:4,align:`stretch`,height:`100%`,css:{"@keyframes shimmer":{"0%":{opacity:.4},"50%":{opacity:.7},"100%":{opacity:.4}}},children:[(0,X.jsx)(K,{justify:`flex-end`,children:(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`32px`,w:`65%`,css:{animation:`shimmer 1.5s ease-in-out infinite`}})}),(0,X.jsxs)(q,{align:`flex-start`,gap:2,children:[(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`14px`,w:`90%`,css:{animation:`shimmer 1.5s ease-in-out 0.15s infinite`}}),(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`14px`,w:`75%`,css:{animation:`shimmer 1.5s ease-in-out 0.3s infinite`}}),(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`14px`,w:`60%`,css:{animation:`shimmer 1.5s ease-in-out 0.45s infinite`}})]}),(0,X.jsx)(K,{justify:`flex-end`,children:(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`28px`,w:`50%`,css:{animation:`shimmer 1.5s ease-in-out 0.6s infinite`}})}),(0,X.jsxs)(q,{align:`flex-start`,gap:2,children:[(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`14px`,w:`85%`,css:{animation:`shimmer 1.5s ease-in-out 0.75s infinite`}}),(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`14px`,w:`70%`,css:{animation:`shimmer 1.5s ease-in-out 0.9s infinite`}})]})]})}function ft({description:e}){return(0,X.jsxs)(q,{height:`100%`,justify:`center`,align:`center`,gap:4,p:4,css:{"@keyframes ripple":{"0%":{transform:`scale(0.8)`,opacity:.4},"50%":{transform:`scale(1)`,opacity:.15},"100%":{transform:`scale(0.8)`,opacity:.4}}},children:[(0,X.jsx)(V,{position:`relative`,w:`64px`,h:`64px`,children:[0,1,2].map(e=>(0,X.jsx)(V,{position:`absolute`,inset:`${e*8}px`,borderRadius:`full`,border:`1px solid`,borderColor:`fg.muted`,css:{animation:`ripple 2.4s ease-in-out ${e*.4}s infinite`}},e))}),e&&(0,X.jsx)(G,{fontSize:`xs`,color:`fg.muted`,textAlign:`center`,lineClamp:2,maxW:`90%`,children:e})]})}function pt({children:e}){return(0,X.jsx)(Ne,{p:0,height:`100%`,overflow:`hidden`,position:`relative`,w:`100%`,children:(0,X.jsx)(V,{height:`100%`,width:`100%`,position:`relative`,children:e})})}function mt({status:e}){let t=I[e],n=_e[e],r=e===R.RUNNING||e===R.IN_PROGRESS,i=e===R.PENDING||e===R.QUEUED;return(0,X.jsx)(V,{position:`absolute`,bottom:3,left:`50%`,transform:`translateX(-50%)`,zIndex:10,pointerEvents:`none`,children:(0,X.jsxs)(K,{gap:1.5,px:3,py:1,borderRadius:`full`,bg:`color-mix(in srgb, var(--chakra-colors-${t.colorPalette}-subtle) 80%, transparent)`,boxShadow:`0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04)`,border:`1px solid`,borderColor:`color-mix(in srgb, var(--chakra-colors-${t.colorPalette}-muted) 50%, transparent)`,color:t.fgColor,children:[r||i?(0,X.jsx)(B,{size:`xs`,color:t.fgColor}):(0,X.jsx)(n,{size:12,color:`currentColor`}),(0,X.jsx)(G,{fontSize:`xs`,fontWeight:`semibold`,textTransform:`capitalize`,lineHeight:`1`,children:t.label})]})})}function ht({title:e,description:t,status:n,isActive:r,isLoading:i,isAwaitingMessages:a,children:o}){let s=n?I[n].isComplete:!1,c=s&&!r;return(0,X.jsxs)(Me,{height:`100%`,border:`1px solid rgba(255,255,255,0.12)`,borderRadius:`xl`,position:`relative`,bg:`bg.panel`,css:{overflow:`hidden !important`,contain:`content`,boxShadow:`sm`,"&:hover .simulation-card-content":{opacity:1},"& .simulation-chat-scroll":{scrollbarWidth:`none`},"&:hover .simulation-chat-scroll":{scrollbarWidth:`thin`},"& .simulation-chat-scroll::-webkit-scrollbar":{display:`none`},"&:hover .simulation-chat-scroll::-webkit-scrollbar":{display:`block`,width:`6px`}},children:[(0,X.jsxs)(q,{height:`100%`,gap:0,children:[!i&&(0,X.jsx)(ut,{title:e,status:n}),(0,X.jsx)(V,{className:`simulation-card-content`,opacity:c?.45:1,transition:`opacity 0.3s ease`,height:`100%`,width:`100%`,overflow:`hidden`,children:i?(0,X.jsx)(dt,{}):a?(0,X.jsx)(ft,{description:t}):(0,X.jsx)(pt,{children:o})})]}),s&&n&&(0,X.jsx)(lt,{status:n}),n&&(0,X.jsx)(mt,{status:n})]})}function gt(e){if(typeof e==`string`){try{let t=JSON.parse(e);if(Array.isArray(t))return _t(t)}catch{}return e}return Array.isArray(e)?_t(e):``}function _t(e){return e.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `)}function vt(){return(0,X.jsx)(V,{display:`flex`,gap:`3px`,alignItems:`center`,height:`14px`,css:{"@keyframes pulse-dot":{"0%, 80%, 100%":{opacity:.3},"40%":{opacity:1}}},children:[0,1,2].map(e=>(0,X.jsx)(V,{width:`5px`,height:`5px`,borderRadius:`full`,bg:`fg.muted`,animation:`pulse-dot 1.4s infinite`,style:{animationDelay:`${e*.2}s`}},e))})}function yt({messages:e,streamingMessages:t}){let n=new Set((e??[]).map(e=>e.id).filter(Boolean)),r=(t??[]).filter(e=>!n.has(e.messageId));return(!e||e.length===0)&&r.length===0?(0,X.jsxs)(q,{align:`stretch`,gap:1.5,padding:3,height:`100%`,justifyContent:`flex-end`,css:{"@keyframes shimmer":{"0%":{opacity:.3},"50%":{opacity:.55},"100%":{opacity:.3}}},children:[(0,X.jsx)(V,{alignSelf:`flex-end`,maxWidth:`65%`,children:(0,X.jsx)(V,{bg:`bg.muted`,borderRadius:`lg`,h:`28px`,w:`100%`,css:{animation:`shimmer 2s ease-in-out infinite`}})}),(0,X.jsxs)(q,{align:`flex-start`,gap:1,maxWidth:`80%`,children:[(0,X.jsx)(V,{bg:`bg.subtle`,borderRadius:`lg`,h:`12px`,w:`100%`,css:{animation:`shimmer 2s ease-in-out 0.2s infinite`}}),(0,X.jsx)(V,{bg:`bg.subtle`,borderRadius:`lg`,h:`12px`,w:`70%`,css:{animation:`shimmer 2s ease-in-out 0.4s infinite`}})]})]}):(0,X.jsxs)(q,{align:`stretch`,gap:1.5,padding:3,height:`100%`,overflow:`hidden`,justifyContent:`flex-end`,children:[(e??[]).map((e,t)=>{let n=`tool_calls`in e&&e.tool_calls?e.tool_calls:`toolCalls`in e&&e.toolCalls?e.toolCalls:null;if(n)return n.map((n,r)=>(0,X.jsxs)(K,{alignSelf:`flex-start`,gap:1,children:[(0,X.jsx)(V,{color:`orange.fg`,children:(0,X.jsx)(L,{size:10})}),(0,X.jsx)(G,{fontSize:`2xs`,color:`orange.fg`,fontWeight:`medium`,lineClamp:1,children:n.function?.name??`tool`})]},`${e.id??t}-tc-${r}`));if(e.role===`tool`){let n=gt(e.content);return n?(0,X.jsx)(V,{alignSelf:`flex-start`,maxWidth:`85%`,children:(0,X.jsx)(V,{bg:`bg.subtle`,borderRadius:`lg`,paddingX:2.5,paddingY:1.5,fontSize:`xs`,color:`fg.muted`,lineClamp:2,children:n})},e.id??t):null}let r=gt(e.content);if(!r||r===`None`)return null;let i=e.role===`user`;return(0,X.jsx)(V,{alignSelf:i?`flex-end`:`flex-start`,maxWidth:`85%`,children:(0,X.jsx)(V,{bg:i?`gray.600`:`bg.subtle`,color:i?`white`:`fg`,borderRadius:`lg`,paddingX:2.5,paddingY:1.5,fontSize:`xs`,lineClamp:3,children:r})},e.id??t)}),r.map(e=>{let t=e.role===`user`;return(0,X.jsx)(V,{alignSelf:t?`flex-end`:`flex-start`,maxWidth:`85%`,children:(0,X.jsx)(V,{bg:t?`gray.600`:`bg.subtle`,color:t?`white`:`fg`,borderRadius:`lg`,paddingX:2.5,paddingY:1.5,fontSize:`xs`,lineClamp:3,children:e.content||(0,X.jsx)(vt,{})})},e.messageId)})]})}function bt({onCancelJobSuccess:e,onCancelJobError:t,onCancelBatchSuccess:n,onCancelBatchError:r}={}){let i=J.scenarios.cancelJob.useMutation({onSuccess:n=>{n.cancelled?e?.():t?.({message:`Job could not be cancelled — it may have already completed`})},onError:e=>{t?.(e)}}),a=J.scenarios.cancelBatchRun.useMutation({onSuccess:()=>{n?.()},onError:e=>{r?.(e)}});return{cancelJob:(0,Y.useCallback)(e=>{i.mutate(e)},[i]),cancelBatchRun:(0,Y.useCallback)(e=>{a.mutate(e)},[a]),isCancellingJob:i.isPending,isCancellingBatch:a.isPending}}function xt({scenarioRun:e,targetName:t,onClick:n,iteration:r,onCancel:a,isCancelling:o=!1}){let s=i({scenarioName:e.name??e.scenarioId,targetName:t,iteration:r});return(0,X.jsxs)(V,{position:`relative`,children:[(0,X.jsx)(V,{as:`button`,onClick:n,cursor:`pointer`,height:`200px`,textAlign:`left`,width:`full`,"aria-label":`View details for ${s}`,children:(0,X.jsx)(ht,{title:s,status:e.status,children:(0,X.jsx)(yt,{messages:e.messages})})}),a&&N(e.status)&&(0,X.jsxs)(K,{as:`button`,tabIndex:o?-1:0,gap:1,paddingX:2,paddingY:.5,borderRadius:`md`,border:`1px solid`,borderColor:`gray.300`,fontSize:`xs`,color:`fg.default`,bg:`white`,cursor:o?`default`:`pointer`,opacity:o?.6:1,_hover:o?void 0:{bg:`gray.100`,borderColor:`gray.400`},position:`absolute`,top:2,right:2,zIndex:1,onClick:e=>{e.stopPropagation(),o||a()},onKeyDown:e=>{!o&&(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),a())},"aria-label":`Stop run`,"aria-disabled":o,"data-testid":`cancel-run-button`,children:[o?(0,X.jsx)(B,{size:`xs`}):(0,X.jsx)(Ge,{size:10}),(0,X.jsx)(G,{fontSize:`xs`,children:`Stop`})]})]})}var St={[R.SUCCESS]:`Passed`,[R.FAILED]:`Failed`,[R.ERROR]:`Failed`,[R.CANCELLED]:`Cancelled`,[R.STALLED]:`Stalled`,[R.IN_PROGRESS]:`Running`,[R.PENDING]:`Pending`,[R.QUEUED]:`Queued`,[R.RUNNING]:`Running`},Ct=new Set([R.SUCCESS,R.FAILED,R.ERROR]);function wt({status:e,results:t}){let n=St[e];if(!Ct.has(e)||!t)return n;let r=t.metCriteria.length,i=r+t.unmetCriteria.length;return i===0?n:`${n} (${r}/${i})`}var Tt={[R.SUCCESS]:`green.500`,[R.FAILED]:`red.500`,[R.ERROR]:`red.500`,[R.STALLED]:`yellow.500`,[R.CANCELLED]:`gray.400`,[R.IN_PROGRESS]:`orange.400`,[R.PENDING]:`gray.400`,[R.QUEUED]:`blue.400`,[R.RUNNING]:`orange.400`};function Et({scenarioRun:e}){let t=e.roleCosts??{},n=e.roleLatencies??{},r=Object.keys(n).filter(e=>n[e]&&n[e].length>0),i=Object.keys(t).filter(e=>t[e]&&t[e].length>0);return(0,X.jsx)(q,{align:`stretch`,gap:0,fontSize:`12px`,minWidth:`180px`,color:`fg`,children:(0,X.jsxs)(q,{align:`stretch`,gap:2,padding:2,children:[e.durationInMs>0&&(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Duration`}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(e.durationInMs)})]}),e.totalCost!=null&&(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Total Cost`}),(0,X.jsx)(G,{fontWeight:`medium`,children:O(e.totalCost)})]}),r.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{borderTopWidth:`1px`,borderColor:`border.emphasized`,marginX:-2}),(0,X.jsx)(G,{color:`fg`,fontWeight:`semibold`,children:`Latency`}),r.map(e=>{let t=n[e],r=t.reduce((e,t)=>e+t,0)/t.length;return(0,X.jsxs)(K,{justify:`space-between`,paddingLeft:2,children:[(0,X.jsx)(G,{color:`fg.muted`,children:e}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(r)})]},`lat-${e}`)})]}),i.length>0&&(0,X.jsxs)(X.Fragment,{children:[r.length===0&&(0,X.jsx)(V,{borderTopWidth:`1px`,borderColor:`border.emphasized`,marginX:-2}),(0,X.jsx)(G,{color:`fg`,fontWeight:`semibold`,children:`Cost`}),i.map(e=>{let n=t[e].reduce((e,t)=>e+t,0);return(0,X.jsxs)(K,{justify:`space-between`,paddingLeft:2,children:[(0,X.jsx)(G,{color:`fg.muted`,children:e}),(0,X.jsx)(G,{fontWeight:`medium`,children:O(n)})]},`cost-${e}`)})]})]})})}function Dt({status:e}){return e===R.QUEUED||e===R.RUNNING?(0,X.jsx)(B,{size:`xs`,"data-testid":`queued-spinner`}):(0,X.jsx)(V,{width:`10px`,height:`10px`,borderRadius:`full`,bg:Tt[e]??`gray.400`,flexShrink:0})}function Ot({scenarioRun:e,targetName:t,onClick:n,iteration:r,onCancel:a,isCancelling:o=!1}){let s=i({scenarioName:e.name??e.scenarioId,targetName:t,iteration:r}),c=I[e.status],l=a&&N(e.status),u=e.durationInMs>0||e.totalCost!=null;return(0,X.jsx)(V,{position:`relative`,className:`group`,borderBottom:`1px solid`,_last:{border:`none`},borderColor:`border.subtle`,_hover:{borderColor:`transparent`},children:(0,X.jsxs)(K,{as:`button`,width:`full`,paddingX:4,paddingY:2,gap:4,_hover:{bg:`bg.muted/80`},borderRadius:`lg`,cursor:`pointer`,onClick:n,tabIndex:0,"aria-label":`View details for ${s}`,children:[(0,X.jsxs)(K,{children:[(0,X.jsx)(Dt,{status:e.status}),(0,X.jsx)(G,{fontSize:`xs`,fontWeight:`semibold`,color:c.fgColor,minWidth:`43px`,textAlign:`left`,whiteSpace:`nowrap`,children:wt({status:e.status,results:e.results??void 0})})]}),(0,X.jsx)(G,{fontSize:`sm`,textAlign:`left`,truncate:!0,children:s}),l&&(0,X.jsxs)(K,{as:`span`,role:`button`,tabIndex:o?-1:0,gap:1,paddingX:2,paddingY:.5,borderRadius:`md`,border:`1px solid`,borderColor:`gray.300`,fontSize:`xs`,color:`fg.default`,cursor:o?`default`:`pointer`,opacity:o?.6:1,flexShrink:0,_hover:o?void 0:{bg:`gray.100`,borderColor:`gray.400`},onClick:e=>{e.stopPropagation(),o||a?.()},onKeyDown:e=>{!o&&(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),a?.())},"aria-label":`Stop run`,"aria-disabled":o,"data-testid":`cancel-run-button`,children:[o?(0,X.jsx)(B,{size:`xs`}):(0,X.jsx)(Ge,{size:10}),(0,X.jsx)(G,{fontSize:`xs`,children:`Stop`})]}),(0,X.jsx)(V,{flex:1}),u&&(0,X.jsx)(H,{content:(0,X.jsx)(Et,{scenarioRun:e}),contentProps:{padding:0},positioning:{placement:`bottom`},interactive:!0,children:(0,X.jsxs)(K,{gap:2,flexShrink:0,color:`fg.subtle`,children:[e.durationInMs>0&&(0,X.jsx)(G,{fontSize:`11px`,children:m(e.durationInMs)}),e.totalCost!=null&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{color:`gray.300`,children:`⋅`}),(0,X.jsx)(G,{fontSize:`xs`,children:O(e.totalCost)})]})]})})]})})}var kt=30,At=200,jt=16,Mt=16,Nt=At+jt,Pt=37,Ft=250,It=(0,Y.memo)(function({scenarioRun:e,targetName:t,onScenarioRunClick:n,iteration:r,onCancelRun:i,isCancelling:a}){let o=(0,Y.useCallback)(()=>n(e),[n,e]),s=(0,Y.useCallback)(()=>i?.(e),[i,e]);return(0,X.jsx)(xt,{scenarioRun:e,targetName:t,onClick:o,iteration:r,onCancel:i?s:void 0,isCancelling:a})});function Lt(e){return e.scenarioRuns.length>kt?(0,X.jsx)(Bt,{...e}):(0,X.jsx)(Rt,{...e})}function Rt({scenarioRuns:e,viewMode:t,resolveTargetName:n,onScenarioRunClick:r,iterationMap:i,onCancelRun:a,cancellingJobId:o}){return t===`grid`?(0,X.jsx)(Ce,{templateColumns:`repeat(auto-fill, minmax(250px, 1fr))`,gap:4,padding:4,position:`relative`,zIndex:0,"data-testid":`scenario-grid`,children:e.map(e=>(0,X.jsx)(It,{scenarioRun:e,targetName:n(e),onScenarioRunClick:r,iteration:i.get(e.scenarioRunId),onCancelRun:a,isCancelling:o===e.scenarioRunId},e.scenarioRunId))}):(0,X.jsx)(q,{align:`stretch`,gap:0,"data-testid":`scenario-list`,children:e.map(e=>(0,X.jsx)(Ot,{scenarioRun:e,targetName:n(e),onClick:()=>r(e),iteration:i.get(e.scenarioRunId),onCancel:a?()=>a(e):void 0,isCancelling:o===e.scenarioRunId},e.scenarioRunId))})}function zt(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);if(/(auto|scroll)/.test(e.overflow+e.overflowY))return t;t=t.parentElement}return document.documentElement}function Bt({scenarioRuns:e,viewMode:t,resolveTargetName:n,onScenarioRunClick:r,iterationMap:i,onCancelRun:a,cancellingJobId:o}){let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(1),f=t===`grid`;(0,Y.useLayoutEffect)(()=>{s.current&&l(zt(s.current))},[]),(0,Y.useLayoutEffect)(()=>{if(!s.current||!f)return;let e=s.current.clientWidth-Mt*2;d(Math.max(1,Math.floor((e+jt)/(Ft+jt))))},[f]),(0,Y.useEffect)(()=>{if(!s.current||!f)return;let e=s.current,t=new ResizeObserver(()=>{let t=e.clientWidth-Mt*2;d(Math.max(1,Math.floor((t+jt)/(Ft+jt))))});return t.observe(e),()=>t.disconnect()},[f]);let p=0;if(s.current&&c){let e=s.current.getBoundingClientRect(),t=c.getBoundingClientRect();p=Math.round(e.top-t.top+c.scrollTop)}let m=f?Math.ceil(e.length/u):e.length,h=f?Nt:Pt,g=j({count:m,getScrollElement:(0,Y.useCallback)(()=>c,[c]),estimateSize:(0,Y.useCallback)(()=>h,[h]),overscan:5,scrollMargin:p,enabled:!!c}),_=g.getVirtualItems(),v=g.getTotalSize();return f?(0,X.jsx)(`div`,{ref:s,style:{height:v+Mt*2,width:`100%`,position:`relative`,flexShrink:0},"data-testid":`scenario-grid`,children:_.map(t=>{let s=t.index*u,c=e.slice(s,s+u);return(0,X.jsx)(`div`,{style:{position:`absolute`,top:Mt,left:Mt,right:Mt,height:At,transform:`translateY(${t.start-g.options.scrollMargin}px)`,display:`grid`,gridTemplateColumns:`repeat(${u}, 1fr)`,gap:jt},children:c.map(e=>(0,X.jsx)(It,{scenarioRun:e,targetName:n(e),onScenarioRunClick:r,iteration:i.get(e.scenarioRunId),onCancelRun:a,isCancelling:o===e.scenarioRunId},e.scenarioRunId))},t.index)})}):(0,X.jsx)(`div`,{ref:s,style:{height:v,width:`100%`,position:`relative`,flexShrink:0},"data-testid":`scenario-list`,children:_.map(t=>{let s=e[t.index];return s?(0,X.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:t.size,transform:`translateY(${t.start-g.options.scrollMargin}px)`},children:(0,X.jsx)(Ot,{scenarioRun:s,targetName:n(s),onClick:()=>r(s),iteration:i.get(s.scenarioRunId),onCancel:a?()=>a(s):void 0,isCancelling:o===s.scenarioRunId})},s.scenarioRunId):null})})}function Vt(e){let t=[];return e.failedCount>0&&t.push(`${e.failedCount} failed`),e.stalledCount>0&&t.push(`${e.stalledCount} stalled`),e.cancelledCount>0&&t.push(`${e.cancelledCount} cancelled`),t.length>0?`(${t.join(`, `)})`:null}function Ht({summary:e}){let t=Vt(e);return(0,X.jsx)(q,{align:`stretch`,gap:0,fontSize:`12px`,minWidth:`220px`,color:`fg`,children:(0,X.jsxs)(q,{align:`stretch`,gap:2,padding:2,children:[(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Pass`}),(0,X.jsxs)(K,{gap:1.5,children:[(0,X.jsx)(Ye,{passRate:e.passRate}),(0,X.jsx)(G,{fontWeight:`medium`,color:qe(e.passRate),children:e.passRate===null?`-`:`${Math.round(e.passRate)}%`})]})]}),(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Completed`}),(0,X.jsxs)(G,{fontWeight:`medium`,children:[e.completedCount,`/`,e.totalCount,t&&(0,X.jsx)(G,{as:`span`,color:`red.300`,marginLeft:1,children:t})]})]}),e.agentLatencyStats?(0,X.jsx)(H,{content:(0,X.jsx)(h,{stats:e.agentLatencyStats}),positioning:{placement:`right`},openDelay:100,interactive:!0,children:(0,X.jsxs)(K,{justify:`space-between`,cursor:`pointer`,_hover:{bg:`bg.muted`},marginX:-2,paddingX:2,paddingY:.5,borderRadius:`md`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Avg Agent Latency`}),(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(je,{as:Fe,color:`fg.muted`,boxSize:3}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(e.averageAgentLatencyMs)}),(0,X.jsx)(je,{as:Le,boxSize:3,color:`fg.subtle`})]})]})}):e.averageAgentLatencyMs===null?null:(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Avg Agent Latency`}),(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(je,{as:Fe,color:`fg.muted`,boxSize:3}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(e.averageAgentLatencyMs)})]})]}),e.agentCostStats?(0,X.jsx)(H,{content:(0,X.jsx)(ne,{stats:e.agentCostStats}),positioning:{placement:`right`},openDelay:100,interactive:!0,children:(0,X.jsxs)(K,{justify:`space-between`,cursor:`pointer`,_hover:{bg:`bg.muted`},marginX:-2,paddingX:2,paddingY:.5,borderRadius:`md`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Avg Agent Cost`}),(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(G,{fontWeight:`medium`,children:O(e.averageAgentCost)}),(0,X.jsx)(je,{as:Le,boxSize:3,color:`fg.subtle`})]})]})}):null,e.totalDurationMs!==null&&(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Total Duration`}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(e.totalDurationMs)})]}),e.totalCost!==null&&(0,X.jsxs)(K,{justify:`space-between`,children:[(0,X.jsx)(G,{color:`fg.muted`,children:`Total Cost`}),(0,X.jsx)(G,{fontWeight:`medium`,children:O(e.totalCost)})]})]})})}function Ut({summary:e}){let{isOpen:t,handleMouseEnter:n,handleMouseLeave:r}=Je(150),i=e.inProgressCount>0||e.queuedCount>0;return(0,X.jsx)(H,{content:(0,X.jsx)(Ht,{summary:e}),contentProps:{padding:0,onMouseEnter:n,onMouseLeave:r},positioning:{placement:`bottom`},open:t,interactive:!0,children:(0,X.jsxs)(K,{gap:2,fontSize:`12px`,color:`fg.muted`,paddingX:2,paddingY:1,borderRadius:`lg`,border:`1px solid`,borderColor:`border`,cursor:`default`,_hover:{borderColor:`border.emphasized`,bg:`bg.muted`},"data-testid":`run-metrics-summary`,onMouseEnter:n,onMouseLeave:r,overflow:`hidden`,children:[i&&(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(je,{as:Pe,boxSize:3,color:`blue.fg`}),(0,X.jsxs)(G,{color:`blue.fg`,fontWeight:`medium`,children:[e.completedCount,`/`,e.totalCount]})]}),!i&&e.totalCount>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{fontWeight:`600`,children:`Pass`}),(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(Ye,{passRate:e.passRate}),(0,X.jsx)(G,{color:qe(e.passRate),fontWeight:`medium`,children:e.passRate===null?`-`:`${Math.round(e.passRate)}%`})]})]}),i&&e.completedCount>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{fontWeight:`600`,children:`Pass`}),(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(Ye,{passRate:e.passRate}),(0,X.jsx)(G,{color:qe(e.passRate),fontWeight:`medium`,children:e.passRate===null?`-`:`${Math.round(e.passRate)}%`})]})]}),e.totalDurationMs!==null&&(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(je,{as:Fe,boxSize:3}),(0,X.jsx)(G,{fontWeight:`medium`,children:m(e.totalDurationMs)})]}),e.totalCost!==null&&(0,X.jsx)(G,{fontWeight:`medium`,children:O(e.totalCost)})]})})}function Wt(e){return e.loading?(0,X.jsx)(Gt,{suiteName:e.suiteName}):(0,X.jsx)(Kt,{...e})}function Gt({suiteName:e}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(V,{padding:2,paddingBottom:0,width:`full`,position:`sticky`,top:0,zIndex:20,children:(0,X.jsxs)(K,{width:`full`,paddingX:4,paddingY:3,gap:3,flexWrap:`nowrap`,bg:`bg.subtle/50`,backdropFilter:`blur(4px)`,"data-testid":`run-row-header`,borderRadius:`lg`,boxShadow:`xs`,children:[(0,X.jsx)(B,{size:`xs`,color:`fg.muted`,css:{flexShrink:0,height:`14px`,width:`14px`}}),e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{fontSize:`sm`,fontWeight:`medium`,color:`fg.default`,flexShrink:0,children:e}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,flexShrink:0,children:`·`})]}),(0,X.jsx)(G,{fontSize:`xs`,color:`fg.subtle`,flexShrink:0,children:`Starting...`}),(0,X.jsx)(V,{flex:1}),(0,X.jsx)(V,{paddingY:1,paddingX:2,borderRadius:`lg`,border:`1px solid transparent`,children:(0,X.jsx)(G,{fontSize:`12px`,visibility:`hidden`,children:`\xA0`})})]})}),(0,X.jsx)(V,{padding:2})]})}function Kt({batchRun:e,summary:t,isExpanded:n,onToggle:r,resolveTargetName:i,onScenarioRunClick:a,expectedJobCount:o,suiteName:s,viewMode:c=`grid`,onCancelRun:l,onCancelAll:u,isCancellingBatch:d=!1,cancellingJobId:f,isHighlighted:m=!1}){let[h,g]=(0,Y.useState)(!1),_=at(),v=p(e.timestamp,_),y=(0,Y.useMemo)(()=>x({scenarioRuns:e.scenarioRuns}),[e.scenarioRuns]),b=(0,Y.useMemo)(()=>e.scenarioRuns.filter(e=>N(e.status)).length,[e.scenarioRuns]),ee=b>0;return(0,X.jsxs)(V,{"data-batch-id":e.batchRunId,css:m?{"@keyframes yellowFlash":{"0%":{backgroundColor:`rgba(234, 179, 8, 0.3)`},"100%":{backgroundColor:`transparent`}},animation:`yellowFlash 2s ease-out`}:void 0,children:[(0,X.jsx)(V,{padding:2,paddingBottom:0,width:`full`,position:`sticky`,top:0,zIndex:20,children:(0,X.jsxs)(K,{as:`button`,width:`full`,paddingX:4,paddingY:3,gap:3,flexWrap:`nowrap`,cursor:`pointer`,onClick:r,className:`group`,"aria-expanded":n,"aria-label":`Run from ${v??`unknown time`}`,bg:`bg.subtle/50`,backdropFilter:`blur(4px)`,"data-testid":`run-row-header`,borderRadius:`lg`,boxShadow:`xs`,children:[n?(0,X.jsx)(A,{size:14,style:{flexShrink:0}}):(0,X.jsx)(fe,{size:14,style:{flexShrink:0}}),s&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{fontSize:`sm`,fontWeight:`medium`,color:`fg.default`,flexShrink:0,children:s}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,flexShrink:0,children:`·`})]}),(0,X.jsx)(G,{fontSize:`xs`,color:`fg.subtle`,flexShrink:0,children:v}),o!=null&&t.totalCount<o&&(0,X.jsxs)(G,{fontSize:`xs`,color:`fg.muted`,flexShrink:0,children:[t.totalCount,` of `,o]}),u&&ee&&(0,X.jsxs)(K,{as:`span`,role:`button`,tabIndex:d?-1:0,gap:1,paddingX:2,paddingY:.5,borderRadius:`md`,border:`1px solid`,borderColor:`gray.300`,fontSize:`xs`,color:`fg.default`,cursor:d?`default`:`pointer`,flexShrink:0,opacity:d?.6:1,_hover:d?void 0:{bg:`gray.100`,borderColor:`gray.400`},onClick:e=>{e.stopPropagation(),d||g(!0)},onKeyDown:e=>{!d&&(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),g(!0))},"aria-label":`Stop all remaining runs`,"aria-disabled":d,"data-testid":`cancel-all-button`,children:[d?(0,X.jsx)(B,{size:`xs`}):(0,X.jsx)(Ge,{size:10}),(0,X.jsx)(G,{fontSize:`xs`,children:`Stop`})]}),(0,X.jsx)(V,{flex:1}),(0,X.jsx)(Ut,{summary:t})]})}),(0,X.jsx)(V,{padding:2,children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Lt,{scenarioRuns:e.scenarioRuns,viewMode:c,resolveTargetName:i,onScenarioRunClick:a,iterationMap:y,onCancelRun:l,cancellingJobId:f}),e.scenarioRuns.length===0&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,paddingX:4,paddingY:3,children:`No scenario runs in this batch.`})]})}),u&&(0,X.jsx)(W.Root,{open:h,onOpenChange:({open:e})=>g(e),children:(0,X.jsxs)(W.Content,{maxWidth:`sm`,children:[(0,X.jsx)(W.Header,{children:(0,X.jsx)(W.Title,{children:`Cancel remaining jobs?`})}),(0,X.jsx)(W.Body,{children:(0,X.jsxs)(G,{fontSize:`sm`,color:`fg.muted`,children:[`This will cancel `,b,` remaining`,` `,b===1?`job`:`jobs`,` in this batch run. This action cannot be undone.`]})}),(0,X.jsxs)(W.Footer,{children:[(0,X.jsx)(z,{variant:`outline`,onClick:()=>g(!1),children:`Keep running`}),(0,X.jsxs)(z,{colorPalette:`red`,onClick:()=>{g(!1),u()},"data-testid":`confirm-cancel-all-button`,children:[`Cancel `,b,` `,b===1?`job`:`jobs`]})]})]})})]})}function qt({batch:e,resolveTargetName:t,onScenarioRunClick:n,viewMode:r,onCancelRun:i,cancellingJobId:a}){let o=(0,Y.useMemo)(()=>pe({batchRun:e}),[e]),s=(0,Y.useMemo)(()=>x({scenarioRuns:e.scenarioRuns}),[e.scenarioRuns]),c=at();return(0,X.jsxs)(q,{align:`stretch`,gap:0,children:[(0,X.jsxs)(K,{paddingX:4,paddingY:2,gap:2,"data-testid":`batch-sub-header`,children:[(0,X.jsx)(G,{fontSize:`xs`,color:`fg.subtle`,children:p(e.timestamp,c)}),(0,X.jsx)(V,{flex:1}),(0,X.jsx)(Jt,{summary:o})]}),(0,X.jsx)(Lt,{scenarioRuns:e.scenarioRuns,viewMode:r,resolveTargetName:t,onScenarioRunClick:n,iterationMap:s,onCancelRun:i,cancellingJobId:a})]})}function Jt({summary:e}){let t=[];return e.passedCount>0&&t.push({count:e.passedCount,color:`green.500`,label:`passed`}),e.failedCount>0&&t.push({count:e.failedCount,color:`red.500`,label:`failed`}),e.stalledCount>0&&t.push({count:e.stalledCount,color:`yellow.500`,label:`stalled`}),e.cancelledCount>0&&t.push({count:e.cancelledCount,color:`fg.muted`,label:`cancelled`}),e.inProgressCount>0&&t.push({count:e.inProgressCount,color:`orange.500`,label:`running`}),e.queuedCount>0&&t.push({count:e.queuedCount,color:`blue.500`,label:`queued`}),t.length===0?null:(0,X.jsx)(K,{gap:2,children:t.map(e=>(0,X.jsxs)(K,{gap:1,children:[(0,X.jsx)(V,{width:`6px`,height:`6px`,borderRadius:`full`,bg:e.color,flexShrink:0}),(0,X.jsxs)(G,{fontSize:`xs`,color:`fg.subtle`,children:[e.count,` `,e.label]})]},e.label))})}function Yt({group:e,summary:t,isExpanded:n,onToggle:r,onScenarioRunClick:i,resolveTargetName:a,viewMode:o=`grid`,onCancelRun:s,cancellingJobId:c}){let l=e.scenarioRuns.length,u=(0,Y.useMemo)(()=>d({runs:e.scenarioRuns}),[e.scenarioRuns]);return(0,X.jsxs)(V,{children:[(0,X.jsx)(V,{padding:2,paddingBottom:0,width:`full`,position:`sticky`,top:0,zIndex:20,children:(0,X.jsxs)(K,{as:`button`,width:`full`,paddingX:4,paddingY:3,gap:3,flexWrap:`nowrap`,cursor:`pointer`,onClick:r,className:`group`,"aria-expanded":n,"aria-label":`${e.groupLabel} group`,bg:`bg.subtle/50`,backdropFilter:`blur(4px)`,"data-testid":`group-row-header`,borderRadius:`lg`,boxShadow:`xs`,children:[n?(0,X.jsx)(A,{size:14,style:{flexShrink:0}}):(0,X.jsx)(fe,{size:14,style:{flexShrink:0}}),(0,X.jsx)(G,{fontSize:`sm`,fontWeight:`medium`,color:`fg.default`,truncate:!0,minWidth:0,flexShrink:1,children:e.groupLabel}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,flexShrink:0,children:`·`}),(0,X.jsxs)(G,{fontSize:`xs`,color:`fg.muted`,flexShrink:0,children:[l,` `,l===1?`run`:`runs`]}),(0,X.jsx)(V,{flex:1}),(0,X.jsx)(V,{flexShrink:0,children:(0,X.jsx)(Ut,{summary:t})})]})}),(0,X.jsx)(V,{padding:2,children:n&&(0,X.jsxs)(X.Fragment,{children:[u.map(e=>(0,X.jsx)(qt,{batch:e,resolveTargetName:a,onScenarioRunClick:i,viewMode:o,onCancelRun:s,cancellingJobId:c},e.batchRunId)),e.scenarioRuns.length===0&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,paddingX:4,paddingY:3,children:`No scenario runs in this group.`})]})})]})}function Xt({scrollRef:e,fadeAfterPx:t=100}={}){let[n,r]=(0,Y.useState)(+!e),i=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!e)return;let n,a=!1,o=()=>{let s=e.current;if(!s){n=requestAnimationFrame(o);return}a=!0;let c=()=>{r(Math.min(s.scrollTop/t,1))};c(),s.addEventListener(`scroll`,c,{passive:!0}),i.current=()=>s.removeEventListener(`scroll`,c)};return n=requestAnimationFrame(o),()=>{a||cancelAnimationFrame(n),i.current?.(),i.current=null}},[e,t]),(0,X.jsxs)(V,{width:`full`,flexShrink:0,position:`relative`,opacity:n,transition:`opacity 0.15s ease-out`,children:[(0,X.jsx)(V,{width:`full`,height:`1px`,bg:`border.muted`}),(0,X.jsx)(V,{width:`full`,height:`4px`,background:`linear-gradient(to bottom, var(--chakra-colors-border-muted), transparent)`,opacity:.4,position:`absolute`,zIndex:1})]})}function Zt({count:e,label:t,tooltip:n,icon:r,color:i,bg:a}){return(0,X.jsx)(H,{content:n,children:(0,X.jsxs)(K,{gap:`4px`,paddingX:`8px`,paddingY:`2px`,borderRadius:`md`,bg:a,children:[(0,X.jsx)(r,{size:12,style:{color:`var(--chakra-colors-${i})`}}),(0,X.jsxs)(G,{fontSize:`xs`,fontWeight:`semibold`,color:i,whiteSpace:`nowrap`,children:[e,` `,t]})]})})}function Qt({summary:e}){return(0,X.jsxs)(K,{gap:1,"data-testid":`run-summary-counts`,children:[e.passedCount>0&&(0,X.jsx)(Zt,{count:e.passedCount,label:`passed`,tooltip:`${e.passedCount} scenario${e.passedCount===1?``:`s`} passed all criteria`,icon:Ae,color:`green.fg`,bg:`green.subtle`}),e.failedCount>0&&(0,X.jsx)(Zt,{count:e.failedCount,label:`failed`,tooltip:`${e.failedCount} scenario${e.failedCount===1?``:`s`} failed one or more criteria`,icon:ve,color:`red.fg`,bg:`red.subtle`}),e.stalledCount>0&&(0,X.jsx)(Zt,{count:e.stalledCount,label:`stalled`,tooltip:`${e.stalledCount} scenario${e.stalledCount===1?``:`s`} stalled (no response received)`,icon:s,color:`yellow.fg`,bg:`yellow.subtle`}),e.cancelledCount>0&&(0,X.jsx)(Zt,{count:e.cancelledCount,label:`cancelled`,tooltip:`${e.cancelledCount} scenario${e.cancelledCount===1?``:`s`} were cancelled`,icon:Ue,color:`fg.muted`,bg:`bg.emphasized`}),e.inProgressCount>0&&(0,X.jsx)(Zt,{count:e.inProgressCount,label:`running`,tooltip:`${e.inProgressCount} scenario${e.inProgressCount===1?``:`s`} currently executing`,icon:Qe,color:`orange.fg`,bg:`orange.subtle`}),e.queuedCount>0&&(0,X.jsx)(Zt,{count:e.queuedCount,label:`queued`,tooltip:`${e.queuedCount} scenario${e.queuedCount===1?``:`s`} waiting to execute`,icon:M,color:`blue.fg`,bg:`blue.subtle`})]})}function $t(e){return typeof e==`string`&&C.includes(e)}function en(e,t){let n=e[t];return Array.isArray(n)?n[0]??``:typeof n==`string`?n:``}function tn(){return ze((e,t)=>({groupBy:`none`,viewMode:`grid`,filters:{scenarioId:``,passFailStatus:``},setGroupBy:t=>{e({groupBy:t})},setViewMode:t=>{e({viewMode:t})},setFilter:(t,n)=>{e(e=>({filters:{...e.filters,[t]:n}}))},setFilters:t=>{e({filters:t})},syncToUrl:e=>{let{groupBy:n,filters:r}=t(),i={};for(let[t,n]of Object.entries(e.query))(typeof n==`string`||Array.isArray(n))&&(i[t]=n);n===`none`?delete i.groupBy:i.groupBy=n,r.scenarioId?i.scenarioId=r.scenarioId:delete i.scenarioId,r.passFailStatus?i.passFailStatus=r.passFailStatus:delete i.passFailStatus,e.push({query:i},void 0,{shallow:!0})},hydrateFromUrl:t=>{let n=en(t,`groupBy`);e({groupBy:$t(n)?n:`none`,filters:{scenarioId:en(t,`scenarioId`),passFailStatus:en(t,`passFailStatus`)}})}}))}var Z=tn();function nn(e){if(e.startsWith(`{`)&&e.endsWith(`}`))throw Error(`Queue name "${e}" is already wrapped in hash tags. Do not call makeQueueName twice.`);return`{${e}}`}nn(`simulations/scenarios/executions`);var rn={TIMEOUT_MS:900*1e3}.TIMEOUT_MS*2;function an({scenarioSetId:e,startDateMs:t}){let{project:n}=Ve(),[r,i]=(0,Y.useState)(void 0),[a,o]=(0,Y.useState)([]),s=(0,Y.useRef)(void 0);(0,Y.useEffect)(()=>{i(void 0),o([])},[t]);let{data:c,isLoading:l,error:u,refetch:d}=J.scenarios.getSuiteRunData.useQuery({projectId:n?.id??``,scenarioSetId:e,limit:20,cursor:r,startDate:t},{enabled:!!n,refetchInterval:a.length<=1?3e4:void 0,trpc:{context:{skipBatch:!0}}});return(0,Y.useEffect)(()=>{!c||!c.changed||(r===void 0?o([c]):r!==s.current&&o(e=>[...e,c]),s.current=r)},[c,r]),{allRuns:(0,Y.useMemo)(()=>{let e=Date.now();return a.flatMap(e=>e.runs).map(t=>t.status===R.IN_PROGRESS&&e-t.timestamp>=rn?{...t,status:R.STALLED}:t)},[a]),allScenarioSetIds:(0,Y.useMemo)(()=>{let e={};for(let t of a)Object.assign(e,t.scenarioSetIds);return e},[a]),hasMore:a.length>0?a[a.length-1]?.hasMore??!1:!1,loadMore:(0,Y.useCallback)(()=>{let e=a[a.length-1];e?.nextCursor&&i(e.nextCursor)},[a]),isLoading:l&&a.length===0,error:u,refetch:d}}var on=`langwatch:run-history-expanded`,sn=new Set,Q=new Map;try{let e=typeof window<`u`?localStorage.getItem(on):null;if(e){let t=JSON.parse(e);for(let[e,n]of Object.entries(t))Q.set(e,new Set(n)),sn.add(e)}}catch{}function cn(){try{let e={};for(let[t,n]of Q)e[t]=[...n];localStorage.setItem(on,JSON.stringify(e))}catch{}}function ln(e,t){return`${e}::${t}`}function un({panelKey:e,groupBy:t,batchRuns:n,groups:r}){let i=ln(e,t),[a,o]=(0,Y.useState)(()=>Q.get(i)??new Set),s=(0,Y.useRef)(t),c=(0,Y.useRef)(e);return(0,Y.useEffect)(()=>{if(s.current!==t||c.current!==e){let n=ln(e,t),r=Q.get(n);r?o(r):(o(new Set),sn.delete(n)),s.current=t,c.current=e}},[t,e]),(0,Y.useEffect)(()=>{let e=t===`none`?n:r;if(e.length===0)return;let a=new Set(e.map(e=>`batchRunId`in e?e.batchRunId:e.groupKey));sn.has(i)?o(e=>{let t=[...a].filter(t=>!e.has(t));if(t.length===0)return e;let n=new Set(e);for(let e of t)n.add(e);return Q.set(i,n),cn(),n}):(o(a),Q.set(i,a),sn.add(i),cn())},[t,n,r,i]),{expandedIds:a,toggleExpanded:(0,Y.useCallback)(e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Q.set(i,n),cn(),n})},[i])}}var dn=2e3,fn=100,pn=50;function mn({highlightBatchId:e}){let[t,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{if(!e){n(null);return}let t=0,r=!1,i=null,a=()=>{if(r)return;let o=document.querySelector(`[data-batch-id="${e}"]`);if(!o){t++,t<pn&&requestAnimationFrame(a);return}document.querySelectorAll(`[data-batch-id]`)[0]!==o&&o.scrollIntoView({behavior:`smooth`,block:`center`}),n(e),i=setTimeout(()=>{r||n(null)},dn)},o=setTimeout(a,fn);return()=>{r=!0,clearTimeout(o),i&&clearTimeout(i)}},[e]),{highlightedBatchId:t}}function hn({scenarioSetId:e,period:t,onStatsReady:n,expectedJobCount:r,suiteNameMap:i,pendingBatchRunId:o,highlightBatchId:s}){let{project:u}=Ve(),f=Be(),p=Z(e=>e.groupBy),m=Z(e=>e.viewMode),h=Z(e=>e.filters),_=Z(e=>e.setGroupBy),v=Z(e=>e.setViewMode),b=Z(e=>e.setFilters),x=Z(e=>e.syncToUrl),S=Z(e=>e.hydrateFromUrl),C=(0,Y.useRef)(null),T=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{!T.current&&f.isReady&&(S(f.query),T.current=!0)},[f.isReady,f.query,S]);let E=(0,Y.useRef)(p),ne=(0,Y.useRef)(h);(0,Y.useEffect)(()=>{T.current&&(E.current!==p||ne.current!==h)&&(E.current=p,ne.current=h,x(f))},[p,h,x,f]);let{allRuns:D,allScenarioSetIds:O,hasMore:re,loadMore:ie,isLoading:ae,error:oe,refetch:se}=an({scenarioSetId:e,startDateMs:t.startDate.getTime()});c({projectId:u?.id??``,refetch:se,enabled:!!u?.id,debounceMs:500,filter:e?{scenarioSetId:e}:void 0});let{data:ce}=J.scenarios.getAll.useQuery({projectId:u?.id??``},{enabled:!!u}),k=l(),A=(0,Y.useCallback)(e=>{let t=e.metadata?.langwatch?.targetReferenceId;return t?k.get(t)??t:null},[k]),le=(0,Y.useMemo)(()=>ce?ce.map(e=>({id:e.id,name:e.name})):[],[ce]),[ue,j]=(0,Y.useState)(null),{cancelJob:M,cancelBatchRun:de,isCancellingBatch:fe}=bt({onCancelJobSuccess:()=>{j(null),se(),U.create({title:`Cancellation requested`,type:`info`})},onCancelJobError:e=>{j(null),se(),U.create({title:`Failed to cancel job`,description:e.message,type:`error`})},onCancelBatchSuccess:()=>{se(),U.create({title:`Jobs cancelled`,type:`success`})},onCancelBatchError:e=>{U.create({title:`Failed to cancel jobs`,description:e.message,type:`error`})}}),N=(0,Y.useMemo)(()=>{if(D.length===0)return[];let e=D;return h.scenarioId&&(e=e.filter(e=>e.scenarioId===h.scenarioId)),h.passFailStatus===`pass`?e=e.filter(e=>e.status===R.SUCCESS):h.passFailStatus===`fail`?e=e.filter(e=>e.status===R.ERROR||e.status===R.FAILED):h.passFailStatus===`stalled`&&(e=e.filter(e=>e.status===R.STALLED)),e},[D,h]),P=(0,Y.useMemo)(()=>d({runs:N,scenarioSetIds:O}),[N,O]),F=(0,Y.useMemo)(()=>p===`none`?[]:p===`scenario`?g({runs:N}):y({runs:N,targetNameMap:k}),[p,N,k]),{expandedIds:me,toggleExpanded:I}=un({panelKey:e??`all-runs`,groupBy:p,batchRuns:P,groups:F}),L=(0,Y.useMemo)(()=>w({runs:N}),[N]),_e=p===`none`?P[0]?.timestamp??null:F[0]?.timestamp??null;(0,Y.useEffect)(()=>{if(!n)return;let e=L.passedCount+L.failedCount,t=e>0?L.passedCount/e*100:0;n({runCount:L.runCount,passRate:t,lastActivityTimestamp:_e})},[L,_e,n]);let{highlightedBatchId:ve}=mn({highlightBatchId:s}),ye=e=>!!e&&(he(e)||a(e)),be=(0,Y.useCallback)(e=>t=>{u?.id&&(j(t.scenarioRunId),M({projectId:u.id,scenarioSetId:e,batchRunId:t.batchRunId,scenarioRunId:t.scenarioRunId,scenarioId:t.scenarioId}))},[u?.id,M]),xe=(0,Y.useCallback)((e,t)=>{u?.id&&de({projectId:u.id,scenarioSetId:t,batchRunId:e})},[u?.id,de]),{openDrawer:Se}=ge(),Ce=(0,Y.useCallback)(e=>{Se(`scenarioRunDetail`,{urlParams:{scenarioRunId:e.scenarioRunId}})},[Se]),H=(0,Y.useCallback)(e=>{b(e)},[b]),W=(0,Y.useMemo)(()=>o?!P.some(e=>e.batchRunId===o):!1,[o,P]);if(oe)return(0,X.jsx)(V,{padding:6,children:(0,X.jsxs)(G,{color:`red.fg`,children:[`Error loading runs: `,oe.message]})});if(ae)return(0,X.jsx)(V,{padding:6,display:`flex`,justifyContent:`center`,children:(0,X.jsx)(B,{size:`lg`,"data-testid":`loading-spinner`})});let we=!!e,Te=p===`none`?P.length:F.length,Ee=!!(h.scenarioId||h.passFailStatus);return(0,X.jsxs)(q,{align:`stretch`,gap:0,height:`100%`,children:[!we&&(0,X.jsxs)(V,{paddingX:6,paddingY:4,children:[(0,X.jsx)(G,{fontSize:`xl`,fontWeight:`semibold`,children:`All Runs`}),(0,X.jsxs)(K,{gap:2,"data-testid":`all-runs-header-totals`,children:[(0,X.jsxs)(G,{fontSize:`sm`,color:`fg.muted`,children:[p===`none`?`${P.length} ${P.length===1?`execution`:`executions`} · `:`${F.length} ${F.length===1?`group`:`groups`} · `,L.runCount,` `,L.runCount===1?`run`:`runs`]}),(0,X.jsx)(Qt,{summary:{passedCount:L.passedCount,failedCount:L.failedCount,stalledCount:0,cancelledCount:0,completedCount:L.passedCount+L.failedCount,inProgressCount:L.pendingCount,queuedCount:0,passRate:0,totalCount:L.runCount,totalCost:null,averageAgentLatencyMs:null,totalDurationMs:null,agentLatencyStats:null,agentCostStats:null,averageAgentCost:null}})]})]}),(0,X.jsx)(V,{paddingX:6,paddingY:4,bg:`bg`,_after:{content:`""`,position:`absolute`,bottom:`-5px`,left:0,right:0,height:`5px`,borderTop:`1px solid var(--chakra-colors-border-muted)`,background:`linear-gradient(to bottom, color-mix(in srgb, var(--chakra-colors-border-muted) 40%, transparent), transparent)`,pointerEvents:`none`},children:(0,X.jsx)(rt,{scenarioOptions:le,filters:h,onFiltersChange:H,groupBy:p,onGroupByChange:_,viewMode:m,onViewModeChange:v})}),(0,X.jsx)(Xt,{scrollRef:C}),Te===0&&!W?(0,X.jsx)(V,{paddingX:6,paddingY:8,textAlign:`center`,children:(0,X.jsx)(G,{color:`fg.muted`,children:Ee?`No runs match the selected filters.`:we?`Run this suite to see results here.`:`No runs yet. Execute a suite to see results here.`})}):(0,X.jsxs)(q,{ref:C,align:`stretch`,gap:0,flex:1,minH:0,overflow:`auto`,children:[W&&(0,X.jsx)(Wt,{loading:!0}),p===`none`?P.map(t=>(0,X.jsx)(Wt,{batchRun:t,summary:pe({batchRun:t}),isExpanded:me.has(t.batchRunId),onToggle:()=>I(t.batchRunId),resolveTargetName:A,onScenarioRunClick:Ce,expectedJobCount:r,suiteName:i?te({scenarioSetId:t.scenarioSetId,suiteNameMap:i})??void 0:void 0,viewMode:m,onCancelRun:ye(t.scenarioSetId??e)?be(t.scenarioSetId??e??``):void 0,onCancelAll:ye(t.scenarioSetId??e)?()=>xe(t.batchRunId,t.scenarioSetId??e??``):void 0,isCancellingBatch:fe,cancellingJobId:ue,isHighlighted:ve===t.batchRunId},t.batchRunId)):F.map(t=>(0,X.jsx)(Yt,{group:t,summary:ee({group:t}),isExpanded:me.has(t.groupKey),onToggle:()=>I(t.groupKey),onScenarioRunClick:Ce,resolveTargetName:A,viewMode:m,onCancelRun:ye(e)?be(e??``):void 0,cancellingJobId:ue},t.groupKey)),re&&(0,X.jsx)(V,{paddingX:6,paddingY:6,display:`flex`,justifyContent:`center`,children:(0,X.jsx)(z,{variant:`outline`,onClick:ie,children:`Load More...`})})]})]})}function gn({open:e,onClose:t,onConfirm:n,suiteName:r,isLoading:i=!1}){return(0,X.jsx)(W.Root,{open:e,onOpenChange:t,placement:`center`,children:(0,X.jsxs)(W.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(W.CloseTrigger,{}),(0,X.jsx)(W.Header,{children:(0,X.jsx)(W.Title,{fontSize:`md`,fontWeight:`500`,children:`Archive run plan?`})}),(0,X.jsx)(W.Body,{children:(0,X.jsxs)(q,{align:`stretch`,gap:4,children:[(0,X.jsx)(G,{children:(0,X.jsx)(G,{as:`span`,fontWeight:`semibold`,children:r})}),(0,X.jsx)(G,{color:`fg.muted`,fontSize:`sm`,children:`Archived run plans will no longer appear in the sidebar. Test runs are preserved.`})]})}),(0,X.jsxs)(W.Footer,{children:[(0,X.jsx)(z,{variant:`outline`,mr:3,onClick:e=>{e.stopPropagation(),t()},disabled:i,children:`Cancel`}),(0,X.jsx)(z,{colorPalette:`orange`,onClick:e=>{e.stopPropagation(),n()},disabled:i,children:i?(0,X.jsx)(B,{size:`sm`}):`Archive`})]})]})})}function _n({x:e,y:t,onEdit:n,onDuplicate:r,onArchive:i,onClose:a}){let o=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,X.jsx)(V,{ref:o,position:`fixed`,left:`${e}px`,top:`${t}px`,bg:`bg.surface`,border:`1px solid`,borderColor:`border`,borderRadius:`md`,shadow:`lg`,zIndex:1e3,py:1,minWidth:`140px`,children:(0,X.jsxs)(q,{align:`stretch`,gap:0,children:[(0,X.jsx)(vn,{label:`Edit`,onClick:()=>{n(),a()}}),(0,X.jsx)(vn,{label:`Duplicate`,onClick:()=>{r(),a()}}),(0,X.jsx)(vn,{label:`Archive`,onClick:()=>{i(),a()},color:`orange.fg`})]})})}function vn({label:e,onClick:t,color:n}){return(0,X.jsx)(V,{as:`button`,width:`full`,textAlign:`left`,paddingX:3,paddingY:1.5,cursor:`pointer`,_hover:{bg:`bg.subtle`},onClick:t,children:(0,X.jsx)(G,{fontSize:`sm`,color:n,children:e})})}function yn({suite:e,onEdit:t,onRun:n,isRunning:r=!1,pendingBatchRunId:i,period:a,highlightBatchId:o}){let s=at(),c=(()=>{try{return k(e.targets)}catch{return[]}})(),l=e.scenarioIds.length*c.length*e.repeatCount,[d,f]=(0,Y.useState)(null);return(0,X.jsxs)(q,{align:`stretch`,gap:0,height:`100%`,children:[(0,X.jsx)(V,{paddingX:6,paddingY:4,children:(0,X.jsxs)(K,{justify:`space-between`,align:`start`,children:[(0,X.jsxs)(q,{align:`start`,gap:1,children:[(0,X.jsx)(G,{fontSize:`xl`,fontWeight:`bold`,children:e.name}),e.description&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:e.description})]}),(0,X.jsxs)(K,{gap:2,children:[(0,X.jsxs)(z,{size:`sm`,variant:`outline`,onClick:t,children:[(0,X.jsx)(E,{size:14}),`Edit`]}),(0,X.jsxs)(z,{size:`sm`,colorPalette:`blue`,onClick:n,disabled:r,loading:r,children:[(0,X.jsx)(b,{size:14}),`Run`]})]})]})}),(0,X.jsx)(V,{paddingX:6,paddingBottom:2,children:(0,X.jsxs)(K,{gap:2,flexWrap:`wrap`,alignItems:`center`,children:[(0,X.jsx)($,{icon:(0,X.jsx)(oe,{size:14}),value:e.scenarioIds.length,label:`scenarios`,colorScheme:`gray`}),(0,X.jsx)($,{icon:(0,X.jsx)(u,{size:14}),value:c.length,label:`targets`,colorScheme:`purple`}),(0,X.jsx)($,{icon:(0,X.jsx)(tt,{size:14}),value:`${e.repeatCount}x`,label:`trials`,colorScheme:`gray`}),d&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Te,{orientation:`vertical`,height:`24px`,borderColor:`border`}),(0,X.jsx)($,{icon:(0,X.jsx)(D,{size:14}),value:l,label:`executions`,colorScheme:`gray`}),(0,X.jsx)($,{icon:(0,X.jsx)(We,{size:14}),value:d.runCount,label:`runs`,colorScheme:`gray`}),(0,X.jsx)(xn,{passRate:d.passRate}),d.lastActivityTimestamp&&(0,X.jsx)($,{icon:(0,X.jsx)(M,{size:14}),value:p(d.lastActivityTimestamp,s),label:``,colorScheme:`gray`})]}),!d&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Te,{orientation:`vertical`,height:`24px`,borderColor:`border`}),(0,X.jsx)($,{icon:(0,X.jsx)(D,{size:14}),value:l,label:`executions`,colorScheme:`gray`})]})]})}),(0,X.jsx)(hn,{scenarioSetId:ye(e.id),onStatsReady:f,period:a,pendingBatchRunId:i,highlightBatchId:o})]})}var bn={gray:{bg:`bg.muted`,color:`fg.muted`},purple:{bg:`bg.muted`,color:`purple.fg`},blue:{bg:`bg.muted`,color:`blue.fg`},orange:{bg:`bg.muted`,color:`orange.fg`}};function $({icon:e,value:t,label:n,colorScheme:r=`gray`}){let i=bn[r]??bn.gray;return(0,X.jsxs)(K,{gap:1.5,paddingX:3,paddingY:1.5,borderRadius:`full`,bg:i.bg,children:[(0,X.jsx)(V,{color:i.color,children:e}),(0,X.jsx)(G,{fontSize:`sm`,fontWeight:`semibold`,children:t}),n&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:n})]})}function xn({passRate:e}){return(0,X.jsxs)(K,{gap:1.5,paddingX:3,paddingY:1.5,borderRadius:`full`,border:`1px solid`,borderColor:`border`,bg:`bg`,children:[(0,X.jsx)(me,{size:14}),(0,X.jsxs)(G,{fontSize:`sm`,fontWeight:`semibold`,children:[Math.round(e),`%`]}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:`pass`})]})}function Sn({onNewSuite:e}){return(0,X.jsx)(ke,{flex:1,height:`100%`,children:(0,X.jsx)(T,{children:(0,X.jsxs)(se,{children:[(0,X.jsx)(ce,{children:(0,X.jsx)(v,{size:32})}),(0,X.jsx)(r,{children:`No run plan selected`}),(0,X.jsx)(ae,{children:`Select a run plan from the sidebar or create a new one`}),(0,X.jsxs)(z,{colorPalette:`blue`,onClick:e,children:[(0,X.jsx)(f,{size:16}),` New Run Plan`]})]})})})}var Cn=P({viewContext:`external`});function wn({scenarioSetId:e,period:t,highlightBatchId:n}){let{project:r}=Ve(),{openDrawer:i}=ge(),{highlightedBatchId:a}=mn({highlightBatchId:n}),o=(0,Y.useRef)(null),s=Z(e=>e.groupBy),c=Z(e=>e.viewMode),l=Z(e=>e.filters),u=Z(e=>e.setGroupBy),f=Z(e=>e.setViewMode),p=Z(e=>e.setFilters),m=Cn.includes(s)?s:`none`,{data:h,isLoading:_,error:v}=J.scenarios.getSuiteRunData.useQuery({projectId:r?.id??``,scenarioSetId:e,limit:100,startDate:t.startDate.getTime(),endDate:t.endDate.getTime()},{enabled:!!r,refetchInterval:5e3,trpc:{context:{skipBatch:!0}}}),y=h&&`runs`in h?h.runs:void 0,{data:b}=J.scenarios.getAll.useQuery({projectId:r?.id??``},{enabled:!!r}),x=(0,Y.useMemo)(()=>{if(!b||!y)return[];let e=new Set(y.map(e=>e.scenarioId));return b.filter(t=>e.has(t.id)).map(e=>({id:e.id,name:e.name}))},[b,y]);(0,Y.useEffect)(()=>{!l.scenarioId||x.length===0||new Set(x.map(e=>e.id)).has(l.scenarioId)||p({...l,scenarioId:``})},[l,x,p]);let S=(0,Y.useMemo)(()=>{if(!y)return[];let e=y;return l.scenarioId&&(e=e.filter(e=>e.scenarioId===l.scenarioId)),l.passFailStatus===`pass`?e=e.filter(e=>e.status===R.SUCCESS):l.passFailStatus===`fail`?e=e.filter(e=>e.status===R.ERROR||e.status===R.FAILED):l.passFailStatus===`stalled`&&(e=e.filter(e=>e.status===R.STALLED)),e},[y,l.scenarioId,l.passFailStatus]),C=(0,Y.useMemo)(()=>d({runs:S}),[S]),w=(0,Y.useMemo)(()=>m===`none`?[]:g({runs:S}),[m,S]),{expandedIds:T,toggleExpanded:te}=un({panelKey:`external:${e}`,groupBy:m,batchRuns:C,groups:w}),E=(0,Y.useCallback)(e=>{i(`scenarioRunDetail`,{urlParams:{scenarioRunId:e.scenarioRunId}})},[i]),ne=(0,Y.useCallback)(()=>null,[]),D=(0,Y.useCallback)(e=>{p(e)},[p]),O=m===`none`?C.length>0:w.length>0,re=!!(l.scenarioId||l.passFailStatus);return(0,X.jsxs)(q,{align:`stretch`,gap:0,height:`100%`,children:[(0,X.jsx)(K,{paddingX:6,paddingY:4,justify:`space-between`,children:(0,X.jsxs)(q,{align:`start`,gap:0,children:[(0,X.jsx)(G,{fontSize:`xs`,fontWeight:`bold`,color:`fg.muted`,letterSpacing:`wider`,children:`EXTERNAL SET`}),(0,X.jsx)(G,{fontSize:`lg`,fontWeight:`semibold`,children:e})]})}),!_&&!v&&y&&y.length>0&&(0,X.jsx)(V,{paddingX:6,paddingY:4,bg:`bg`,flexShrink:0,_after:{content:`""`,position:`absolute`,bottom:`-5px`,left:0,right:0,height:`5px`,borderTop:`1px solid var(--chakra-colors-border-muted)`,background:`linear-gradient(to bottom, color-mix(in srgb, var(--chakra-colors-border-muted) 40%, transparent), transparent)`,pointerEvents:`none`},children:(0,X.jsx)(rt,{scenarioOptions:x,filters:l,onFiltersChange:D,groupBy:m,onGroupByChange:u,groupByOptions:Cn,viewMode:c,onViewModeChange:f})}),(0,X.jsx)(Xt,{scrollRef:o}),(0,X.jsxs)(q,{ref:o,align:`stretch`,gap:0,flex:1,overflow:`auto`,children:[_&&(0,X.jsxs)(q,{paddingY:8,children:[(0,X.jsx)(B,{}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:`Loading run data...`})]}),v&&(0,X.jsxs)(q,{paddingY:8,children:[(0,X.jsx)(G,{color:`red.500`,children:`Error loading run data`}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:v.message})]}),!_&&!v&&y&&y.length>0&&(0,X.jsx)(X.Fragment,{children:!O&&re?(0,X.jsx)(V,{paddingX:6,paddingY:8,textAlign:`center`,children:(0,X.jsx)(G,{color:`fg.muted`,children:`No runs match the selected filters.`})}):(0,X.jsx)(X.Fragment,{children:m===`none`?C.map(e=>(0,X.jsx)(Wt,{batchRun:e,summary:pe({batchRun:e}),isExpanded:T.has(e.batchRunId),onToggle:()=>te(e.batchRunId),resolveTargetName:ne,onScenarioRunClick:E,viewMode:c,isHighlighted:a===e.batchRunId},e.batchRunId)):w.map(e=>(0,X.jsx)(Yt,{group:e,summary:ee({group:e}),isExpanded:T.has(e.groupKey),onToggle:()=>te(e.groupKey),onScenarioRunClick:E,resolveTargetName:ne,viewMode:c},e.groupKey))})}),!_&&!v&&(!y||y.length===0)&&(0,X.jsx)(q,{paddingY:8,children:(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:`No run data found for this set.`})})]})]})}var Tn=`all-runs`,En=`external:`;function Dn(e){return e.startsWith(En)}function On(e){return e.slice(9)}function kn(e){return`${En}${e}`}function An(){let e=Be(),{selectedSuiteSlug:t,highlightBatchId:n}=jn({isReady:e.isReady,path:e.query.path??Mn(e.asPath)}),r=e.query.project;return{selectedSuiteSlug:t,navigateToSuite:(0,Y.useCallback)(t=>{if(!r)return;let n={};typeof e.query.startDate==`string`&&(n.startDate=e.query.startDate),typeof e.query.endDate==`string`&&(n.endDate=e.query.endDate);let i;i=t===`all-runs`?[]:Dn(t)?[On(t)]:[`run-plans`,t];let a=i.length>0?`/${r}/simulations/${i.join(`/`)}`:`/${r}/simulations`,o=Object.entries(n).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join(`&`),s=o?`${a}?${o}`:a;e.push({pathname:`/[project]/simulations/[[...path]]`,query:{project:r,...i.length>0?{path:i}:{},...n}},s,{shallow:!0})},[e,r]),highlightBatchId:n}}function jn({isReady:e,path:t}){if(!e)return{selectedSuiteSlug:null,highlightBatchId:null};let n=(Array.isArray(t)?t:t?[t]:[]).filter(e=>e&&!e.startsWith(`?`)&&!e.includes(`=`));return n.length===0?{selectedSuiteSlug:Tn,highlightBatchId:null}:n[0]===`run-plans`&&n.length>=2?{selectedSuiteSlug:n[1],highlightBatchId:n[2]??null}:{selectedSuiteSlug:kn(n[0]),highlightBatchId:n[1]??null}}function Mn(e){let t=(e.split(`?`)[0]?.split(`#`)[0]??``).match(/\/simulations\/(.+?)\/?$/);if(t?.[1])return t[1].split(`/`).filter(Boolean)}var Nn=`suite-sidebar-collapsed`,Pn=6;function Fn({projectSlug:e,suites:t,selectedSuiteSlug:n,runSummaries:r,externalSets:i=[],onSelectSuite:a,onRunSuite:s,onContextMenu:c,isLoading:l=!1}){let[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(()=>{try{return localStorage.getItem(Nn)===`true`}catch{return!1}}),m=()=>{let e=!f;p(e);try{localStorage.setItem(Nn,String(e))}catch{}},h=(0,Y.useMemo)(()=>{if(!u.trim())return t;let e=u.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e))},[t,u]),g=(0,Y.useMemo)(()=>[...u.trim()?i.filter(e=>e.scenarioSetId.toLowerCase().includes(u.toLowerCase())):i].sort((e,t)=>t.lastRunTimestamp-e.lastRunTimestamp),[i,u]),_=h.length===0&&g.length===0;return(0,X.jsxs)(q,{width:f?`auto`:`280px`,minWidth:f?`auto`:`280px`,height:`100%`,align:`stretch`,gap:0,children:[!f&&(0,X.jsx)(V,{paddingX:3,paddingBottom:2,children:(0,X.jsx)(de,{size:`sm`,borderRadius:`full`,placeholder:`Search...`,value:u,onChange:e=>d(e.target.value)})}),(0,X.jsx)(V,{paddingX:f?6:2,paddingBottom:2,children:f?(0,X.jsx)(H,{content:`All Runs`,positioning:{placement:`right`},children:(0,X.jsx)(Ie,{"aria-label":`All Runs`,size:`sm`,width:`full`,variant:n===`all-runs`?`solid`:`ghost`,onClick:()=>a(Tn),children:(0,X.jsx)(o,{size:16})})}):(0,X.jsx)(In,{icon:(0,X.jsx)(o,{size:14}),label:`All Runs`,href:`/${e}/simulations`,isSelected:n===Tn,onClick:()=>a(Tn)})}),(0,X.jsx)(Xt,{}),(0,X.jsxs)(q,{flex:1,overflow:`auto`,paddingX:f?6:2,paddingTop:2,paddingBottom:2,gap:+!f,align:`stretch`,children:[l&&!f&&Array.from({length:Pn}).map((e,t)=>(0,X.jsx)(xe,{"data-testid":`suite-sidebar-skeleton`,height:`60px`,width:`100%`,borderRadius:`md`,marginBottom:1},t)),!l&&!f&&_&&t.length===0&&i.length===0&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,paddingX:2,paddingY:4,textAlign:`center`,children:`No run plans yet`}),!l&&!f&&_&&(t.length>0||i.length>0)&&(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,paddingX:2,paddingY:4,textAlign:`center`,children:`No matching run plans`}),!l&&h.map(t=>f?(0,X.jsx)(H,{content:t.name,positioning:{placement:`right`},children:(0,X.jsx)(Ie,{"aria-label":t.name,size:`sm`,width:`full`,variant:t.slug===n?`solid`:`ghost`,onClick:()=>a(t.slug),children:(0,X.jsx)(ke,{width:`22px`,height:`22px`,borderRadius:`full`,bg:t.slug===n?`transparent`:`bg.emphasized`,fontSize:`xs`,fontWeight:`bold`,children:t.name.charAt(0).toUpperCase()})})},t.id):(0,X.jsx)(zn,{suite:t,projectSlug:e,isSelected:t.slug===n,runSummary:r?.get(t.id),onSelect:()=>a(t.slug),onRun:()=>s(t.id),onContextMenu:e=>c(e,t.id)},t.id)),!l&&g.length>0&&(0,X.jsxs)(X.Fragment,{children:[!f&&(0,X.jsx)(G,{"data-testid":`external-sets-header`,fontSize:`xs`,fontWeight:`bold`,color:`fg.muted`,letterSpacing:`wider`,paddingX:2,paddingTop:3,paddingBottom:1,children:`EXTERNAL SETS`}),f&&(0,X.jsx)(V,{paddingY:.5,children:(0,X.jsx)(Xt,{})}),g.map(t=>f?(0,X.jsx)(H,{content:t.scenarioSetId,positioning:{placement:`right`},children:(0,X.jsx)(Ie,{"aria-label":t.scenarioSetId,size:`sm`,width:`full`,variant:n===kn(t.scenarioSetId)?`solid`:`ghost`,onClick:()=>a(kn(t.scenarioSetId)),children:(0,X.jsx)(ke,{width:`22px`,height:`22px`,borderRadius:`full`,bg:n===kn(t.scenarioSetId)?`transparent`:`bg.emphasized`,fontSize:`xs`,fontWeight:`bold`,children:t.scenarioSetId.charAt(0).toUpperCase()})})},t.scenarioSetId):(0,X.jsx)(Bn,{externalSet:t,projectSlug:e,isSelected:n===kn(t.scenarioSetId),onSelect:()=>a(kn(t.scenarioSetId))},t.scenarioSetId))]})]}),(0,X.jsx)(Xt,{}),(0,X.jsx)(K,{paddingX:f?6:3,paddingY:1.5,justify:`flex-start`,children:(0,X.jsx)(Ie,{"aria-label":f?`Expand sidebar`:`Collapse sidebar`,size:`sm`,variant:`outline`,width:f?`full`:void 0,onClick:m,children:f?(0,X.jsx)($e,{size:16}):(0,X.jsx)(et,{size:16})})})]})}function In({icon:e,label:t,href:n,isSelected:r=!1,onClick:i}){return(0,X.jsx)(K,{asChild:!0,width:`full`,paddingX:2,paddingY:1.5,borderRadius:`md`,cursor:`pointer`,bg:r?`bg.emphasized`:`transparent`,_hover:{bg:r?`bg.emphasized`:`bg.subtle`},onClick:e=>{e.metaKey||e.ctrlKey||e.button===1||(e.preventDefault(),i())},gap:2,textDecoration:`none`,color:`inherit`,children:(0,X.jsxs)(`a`,{href:n??`#`,children:[e,(0,X.jsx)(G,{fontSize:`sm`,children:t})]})})}function Ln({passedCount:e,failedCount:t,totalCount:n}){let r=n>0?e/n*100:null;return(0,X.jsxs)(K,{gap:1,color:`fg.muted`,children:[(0,X.jsx)(Ye,{passRate:r,size:`8px`}),(0,X.jsx)(G,{fontSize:`xs`,color:qe(r),fontWeight:`medium`,children:r===null?`-`:`${Math.round(r)}%`}),(0,X.jsx)(G,{fontSize:`xs`,color:`gray.350`,children:`·`}),(0,X.jsxs)(G,{fontSize:`xs`,color:`fg.subtle`,children:[e,` passed`]})]})}function Rn({isSelected:e,href:t,onClick:n,onContextMenu:r,className:i,"data-testid":a,children:o}){return(0,X.jsx)(K,{asChild:!0,className:i,"data-testid":a,"data-selected":e||void 0,paddingX:3,position:`relative`,paddingY:3,borderRadius:`md`,cursor:`pointer`,bg:e?`bg.subtle`:`transparent`,border:e?`1px solid border.emphasized`:`none`,_hover:{bg:e?`bg.emphasized`:`bg.subtle`},onContextMenu:r,onClick:e=>{e.metaKey||e.ctrlKey||e.button===1||(e.preventDefault(),n())},justify:`space-between`,width:`full`,textDecoration:`none`,color:`inherit`,children:(0,X.jsx)(`a`,{href:t??`#`,children:o})})}function zn({suite:e,projectSlug:t,isSelected:n,runSummary:r,onSelect:i,onRun:a,onContextMenu:o}){let s=at();return(0,X.jsx)(Rn,{className:`group`,"data-testid":`suite-list-item`,href:`/${t}/simulations/run-plans/${e.slug}`,isSelected:n,onClick:i,onContextMenu:o,children:(0,X.jsxs)(q,{align:`start`,gap:0,flex:1,overflow:`hidden`,textAlign:`left`,children:[(0,X.jsxs)(K,{gap:1.5,width:`full`,children:[(0,X.jsx)(G,{fontSize:`13px`,fontWeight:`medium`,lineClamp:1,children:e.name||`<empty>`}),(0,X.jsx)(Re,{}),r?.lastRunTimestamp&&(0,X.jsx)(G,{fontSize:`11px`,color:`fg.subtle`,flexShrink:0,whiteSpace:`nowrap`,children:p(r.lastRunTimestamp,s)}),(0,X.jsxs)(K,{gap:0,flexShrink:0,children:[(0,X.jsxs)(V,{as:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a()},paddingX:1,paddingY:.5,borderRadius:`sm`,_hover:{bg:`bg.muted`},cursor:`pointer`,display:`flex`,alignItems:`center`,gap:1,flexShrink:0,children:[(0,X.jsx)(b,{size:12}),(0,X.jsx)(G,{fontSize:`xs`,children:`Run`})]}),(0,X.jsx)(V,{as:`button`,"aria-label":`Run plan options`,"data-testid":`suite-menu-button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),o(e)},paddingX:1,paddingY:.5,borderRadius:`sm`,_hover:{bg:`bg.muted`},display:`flex`,alignItems:`center`,opacity:0,_groupHover:{opacity:1},transition:`opacity 150ms`,cursor:`pointer`,children:(0,X.jsx)(re,{size:14})})]})]}),r&&(0,X.jsx)(Ln,{passedCount:r.passedCount,failedCount:r.failedCount,totalCount:r.totalCount})]})})}function Bn({externalSet:e,projectSlug:t,isSelected:n,onSelect:r}){let i=at();return(0,X.jsx)(Rn,{"data-testid":`external-set-list-item`,href:`/${t}/simulations/${e.scenarioSetId}`,isSelected:n,onClick:r,children:(0,X.jsxs)(q,{align:`start`,gap:0,flex:1,overflow:`hidden`,textAlign:`left`,children:[(0,X.jsxs)(K,{gap:1.5,width:`full`,children:[(0,X.jsx)(G,{fontSize:`13px`,fontWeight:`medium`,lineClamp:1,children:e.scenarioSetId||`<empty>`}),(0,X.jsx)(Re,{}),e.lastRunTimestamp&&(0,X.jsx)(G,{fontSize:`11px`,color:`fg.subtle`,flexShrink:0,whiteSpace:`nowrap`,children:p(e.lastRunTimestamp,i)})]}),(0,X.jsx)(Ln,{passedCount:e.passedCount,failedCount:e.failedCount,totalCount:e.totalCount})]})})}function Vn(e={}){let{project:t}=Ve(),{openDrawer:n}=ge(),r=J.useContext(),i=(0,Y.useRef)(e);i.current=e;let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=J.suites.run.useMutation({onSuccess:(e,t)=>{if(r.scenarios.getSuiteRunData.invalidate(),o(null),(e.skippedArchived?.scenarios?.length??0)+(e.skippedArchived?.targets?.length??0)>0){let r=[];e.skippedArchived.scenarios.length>0&&r.push(`${e.skippedArchived.scenarios.length} archived scenario${e.skippedArchived.scenarios.length>1?`s`:``}`),e.skippedArchived.targets.length>0&&r.push(`${e.skippedArchived.targets.length} archived target${e.skippedArchived.targets.length>1?`s`:``}`),U.create({title:`Run plan scheduled (${e.jobCount} jobs)`,description:`${r.join(` and `)} skipped.`,type:`warning`,meta:{closable:!0},action:{label:`Edit Run Plan`,onClick:()=>{n(`suiteEditor`,{urlParams:{suiteId:t.id}})}}})}else U.create({title:`Run plan scheduled (${e.jobCount} jobs)`,type:`success`,meta:{closable:!0}});i.current.onRunScheduled?.(t.id,t.batchRunId??e.batchRunId)},onError:(e,t)=>{o(null),c(null);let r=e.data?.code===`BAD_REQUEST`&&(e.message.includes(`All scenarios`)||e.message.includes(`All targets`));U.create({title:r?`Cannot start run plan`:`Run plan failed to start`,description:e.message,type:`error`,meta:{closable:!0},...r?{action:{label:`Edit Run Plan`,onClick:()=>{n(`suiteEditor`,{urlParams:{suiteId:t.id}})}}}:{}})}}),u=(0,Y.useCallback)(e=>{!t||l.isPending||o(e)},[t,l.isPending]),d=(0,Y.useCallback)(()=>{if(!t||!a||l.isPending)return;let e=le(we.SCENARIO_BATCH).toString();c(e),l.mutate({projectId:t.id,id:a.id,idempotencyKey:crypto.randomUUID(),batchRunId:e})},[t,a,l]),f=(0,Y.useCallback)(()=>{l.isPending||o(null)},[l.isPending]),{data:p}=J.scenarios.getAll.useQuery({projectId:t?.id??``},{enabled:!!t&&!!a}),m=(0,Y.useMemo)(()=>{if(!a||!p)return a?.scenarioIds.length??0;let e=new Set(p.map(e=>e.id));return a.scenarioIds.filter(t=>e.has(t)).length},[a,p]),h=(0,Y.useMemo)(()=>a?k(a.targets).length:0,[a]);return{requestRun:u,confirmRun:d,cancelRun:f,isPending:l.isPending,pendingBatchRunId:s,dialogProps:{open:!!a,onClose:f,onConfirm:d,suiteName:a?.name??``,scenarioCount:m,targetCount:h,repeatCount:a?.repeatCount??1,isLoading:l.isPending}}}function Hn({open:e,onClose:t,onConfirm:n,suiteName:r,scenarioCount:i,targetCount:a,repeatCount:o=1,isLoading:s=!1}){let c=i*a*o;return(0,X.jsx)(W.Root,{open:e,onOpenChange:()=>{s||t()},placement:`center`,children:(0,X.jsxs)(W.Content,{maxWidth:`500px`,onClick:e=>e.stopPropagation(),children:[!s&&(0,X.jsx)(W.CloseTrigger,{}),(0,X.jsx)(W.Header,{children:(0,X.jsx)(W.Title,{children:r})}),(0,X.jsx)(W.Body,{children:(0,X.jsxs)(q,{align:`stretch`,gap:4,children:[(0,X.jsxs)(G,{fontWeight:`semibold`,children:[` `,`Run `,c,` `,c===1?`simulation`:`simulations`,`?`]}),(0,X.jsxs)(K,{gap:6,children:[(0,X.jsxs)(q,{gap:0,align:`start`,children:[(0,X.jsxs)(K,{gap:1.5,align:`center`,children:[(0,X.jsx)(oe,{size:14,color:`var(--chakra-colors-fg-muted)`}),(0,X.jsx)(G,{fontSize:`lg`,fontWeight:`semibold`,children:i})]}),(0,X.jsx)(G,{color:`fg.muted`,fontSize:`sm`,children:i===1?`scenario`:`scenarios`})]}),(0,X.jsxs)(q,{gap:0,align:`start`,children:[(0,X.jsxs)(K,{gap:1.5,align:`center`,children:[(0,X.jsx)(Xe,{size:14,color:`var(--chakra-colors-fg-muted)`}),(0,X.jsx)(G,{fontSize:`lg`,fontWeight:`semibold`,children:a})]}),(0,X.jsx)(G,{color:`fg.muted`,fontSize:`sm`,children:a===1?`target`:`targets`})]}),o>1&&(0,X.jsxs)(q,{gap:0,align:`start`,children:[(0,X.jsxs)(K,{gap:1.5,align:`center`,children:[(0,X.jsx)(S,{size:14,color:`var(--chakra-colors-fg-muted)`}),(0,X.jsxs)(G,{fontSize:`lg`,fontWeight:`semibold`,children:[o,`x`]})]}),(0,X.jsx)(G,{color:`fg.muted`,fontSize:`sm`,children:`repeats`})]})]})]})}),(0,X.jsxs)(W.Footer,{children:[(0,X.jsx)(z,{variant:`outline`,onClick:e=>{e.stopPropagation(),t()},disabled:s,children:`Cancel`}),(0,X.jsx)(z,{colorPalette:`blue`,onClick:e=>{e.stopPropagation(),n()},disabled:s,children:s?(0,X.jsx)(B,{size:`sm`}):`Run ${c} ${c===1?`Job`:`Jobs`}`})]})]})})}var Un=6e4;function Wn({intervalMs:e=Un,children:t}){let[n,r]=(0,Y.useState)(()=>Date.now());return(0,Y.useEffect)(()=>{let t=setInterval(()=>r(Date.now()),e);return()=>clearInterval(t)},[e]),(0,X.jsx)(it,{value:n,children:t})}function Gn(){let{project:e}=Ve(),{openDrawer:t,setFlowCallbacks:r}=ge(),i=J.useContext(),{selectedSuiteSlug:a,navigateToSuite:o,highlightBatchId:s}=An(),l=Be();(0,Y.useEffect)(()=>{if(!l.isReady)return;let e=l.query.openRun;if(typeof e==`string`&&e){t(`scenarioRunDetail`,{urlParams:{scenarioRunId:e}});let{openRun:n,...r}=l.query;l.replace({pathname:l.pathname,query:r},void 0,{shallow:!0})}},[l.isReady]);let[u,d]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!l.isReady)return;let e=l.query.pendingBatch;if(typeof e==`string`&&e){d(e);let{pendingBatch:t,...n}=l.query;l.replace({pathname:l.pathname,query:n},void 0,{shallow:!0})}},[l.isReady]);let{period:p,setPeriod:m}=ue(30),[h,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),{data:b,isLoading:ee,error:x}=J.suites.getAll.useQuery({projectId:e?.id??``},{enabled:!!e}),{data:S,isLoading:C}=J.scenarios.getExternalSetSummaries.useQuery({projectId:e?.id??``,startDate:p.startDate.getTime(),endDate:p.endDate.getTime()},{enabled:!!e,refetchInterval:15e3}),{data:w}=J.suites.getSummaries.useQuery({projectId:e?.id??``,startDate:p.startDate.getTime(),endDate:p.endDate.getTime()},{enabled:!!e,refetchInterval:3e4});c({projectId:e?.id??``,refetch:()=>{i.suites.getSummaries.invalidate(),i.scenarios.getExternalSetSummaries.invalidate()},enabled:!!e?.id,debounceMs:500});let T=(0,Y.useMemo)(()=>{if(w)return new Map(Object.entries(w))},[w]),te=(0,Y.useMemo)(()=>{let e=new Map;if(b)for(let t of b)e.set(t.id,t.name);return e},[b]),E=(0,Y.useMemo)(()=>!a||a===`all-runs`||Dn(a)?null:b?.find(e=>e.slug===a)??null,[a,b]),ne=(0,Y.useMemo)(()=>!a||!Dn(a)?null:On(a),[a]);(0,Y.useEffect)(()=>{if(!a||a===`all-runs`)return;let e=null;if(Dn(a)&&S){let t=On(a);e=S.find(e=>e.scenarioSetId===t)?.lastRunTimestamp??null}else E&&T&&(e=T.get(E.id)?.lastRunTimestamp??null);if(e&&e<p.startDate.getTime()){let t=Math.ceil((Date.now()-e)/864e5);m(_(new Date,t<=30?30:t<=90?90:365),new Date)}},[a]);let D=v?b?.find(e=>e.id===v):null,O=J.suites.archive.useMutation({onSuccess:()=>{i.suites.getAll.invalidate();let e=b?.find(e=>e.id===v);e&&e.slug===a&&o(Tn),y(null),U.create({title:`Run plan archived`,type:`success`,meta:{closable:!0}})},onError:e=>{U.create({title:`Failed to archive run plan`,description:e.message,type:`error`,meta:{closable:!0}})}}),re=J.suites.duplicate.useMutation({onSuccess:e=>{i.suites.getAll.invalidate(),o(e.slug),U.create({title:`Run plan duplicated`,type:`success`,meta:{closable:!0}})},onError:e=>{U.create({title:`Failed to duplicate run plan`,description:e.message,type:`error`,meta:{closable:!0}})}}),{requestRun:ae,isPending:oe,pendingBatchRunId:se,dialogProps:ce}=Vn({onRunScheduled:e=>{i.suites.getSummaries.invalidate();let t=b?.find(t=>t.id===e);t&&a!==t.slug&&o(t.slug)}}),k=(0,Y.useCallback)(e=>{o(e.slug)},[o]),A=(0,Y.useCallback)(e=>{o(e.slug),ae(e)},[o,ae]),le=(0,Y.useCallback)(()=>{r(`suiteEditor`,{onSaved:k,onRunRequested:A}),t(`suiteEditor`)},[t,r,k,A]),j=(0,Y.useCallback)(e=>{r(`suiteEditor`,{onSaved:k,onRunRequested:A}),t(`suiteEditor`,{urlParams:{suiteId:e}})},[t,r,k,A]),M=(0,Y.useCallback)(e=>{let t=b?.find(t=>t.id===e);t&&ae(t)},[b,ae]),de=(0,Y.useCallback)(t=>{e&&re.mutate({projectId:e.id,id:t})},[e,re]),fe=(0,Y.useCallback)(t=>{e&&y(t)},[e]),N=(0,Y.useCallback)(()=>{!e||!v||O.mutate({projectId:e.id,id:v})},[e,v,O]),pe=(0,Y.useCallback)((e,t)=>{e.preventDefault(),g({x:e.clientX,y:e.clientY,suiteId:t})},[]);return(0,X.jsx)(Wn,{children:(0,X.jsxs)(F,{children:[(0,X.jsxs)(q,{width:`full`,height:`full`,gap:0,children:[(0,X.jsx)(ie.Header,{withBorder:!1,children:(0,X.jsxs)(K,{justify:`space-between`,align:`center`,w:`full`,children:[(0,X.jsx)(ie.Heading,{children:`Simulations`}),(0,X.jsxs)(K,{children:[(0,X.jsx)(n,{period:p,setPeriod:m}),(0,X.jsxs)(ie.HeaderButton,{onClick:le,children:[(0,X.jsx)(f,{size:16}),` New Run Plan`]})]})]})}),(0,X.jsxs)(K,{flex:1,width:`full`,gap:0,overflow:`hidden`,minHeight:0,children:[(0,X.jsx)(Fn,{projectSlug:e?.slug??``,suites:b??[],selectedSuiteSlug:a,runSummaries:T,externalSets:S??[],onSelectSuite:o,onRunSuite:M,onContextMenu:pe,isLoading:ee||C}),(0,X.jsx)(V,{flex:1,height:`full`,minWidth:0,paddingBottom:3,paddingRight:4,children:(0,X.jsx)(V,{height:`full`,width:`full`,borderRadius:`lg`,boxShadow:`0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1), 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)`,border:`1px solid`,borderColor:`border.muted`,background:`bg.panel`,overflow:`auto`,children:(0,X.jsx)(Kn,{error:x??null,selectedSuiteSlug:a,selectedSuite:E,selectedExternalSetId:ne,isLoading:ee,onNewSuite:le,onEditSuite:j,onRunSuite:M,isRunning:oe,pendingBatchRunId:se??u,period:p,suiteNameMap:te,highlightBatchId:s})})})]})]}),h&&(0,X.jsx)(_n,{x:h.x,y:h.y,onEdit:()=>j(h.suiteId),onDuplicate:()=>de(h.suiteId),onArchive:()=>fe(h.suiteId),onClose:()=>g(null)}),(0,X.jsx)(gn,{open:!!v,onClose:()=>y(null),onConfirm:N,suiteName:D?.name??``,isLoading:O.isPending}),(0,X.jsx)(Hn,{...ce})]})})}function Kn({error:e,selectedSuiteSlug:t,selectedSuite:n,selectedExternalSetId:r,isLoading:i,onNewSuite:a,onEditSuite:o,onRunSuite:s,isRunning:c,pendingBatchRunId:l,period:u,suiteNameMap:d,highlightBatchId:f}){return e?(0,X.jsxs)(q,{gap:4,align:`center`,py:8,children:[(0,X.jsx)(G,{color:`red.500`,children:`Error loading simulations`}),(0,X.jsx)(G,{fontSize:`sm`,color:`fg.muted`,children:e.message})]}):t===null?null:r?(0,X.jsx)(wn,{scenarioSetId:r,period:u,highlightBatchId:f}):t===`all-runs`?(0,X.jsx)(hn,{period:u,suiteNameMap:d,pendingBatchRunId:l,highlightBatchId:f}):n?(0,X.jsx)(yn,{suite:n,onEdit:()=>o(n.id),onRun:()=>s(n.id),isRunning:c,pendingBatchRunId:l,period:u,highlightBatchId:f}):i?null:(0,X.jsx)(Sn,{onNewSuite:a})}function qn(){let e=Be(),t=Array.isArray(e.query.path)?e.query.path:[],n=e.query.project;return(0,Y.useEffect)(()=>{if(!(!e.isReady||!n)){if(t[0]===`suites`){let t=e.query.suite,r=e.query.externalSet;typeof t==`string`&&t?e.replace(`/${n}/simulations/run-plans/${t}`):typeof r==`string`&&r?e.replace(`/${n}/simulations/${r}`):e.replace(`/${n}/simulations`);return}if(t.length===3&&t[0]!==`run-plans`){let[r,i,a]=t;e.replace(`/${n}/simulations/${r}/${i}?openRun=${a}`)}}},[e.isReady]),t[0]===`suites`||t.length===3&&t[0]!==`run-plans`?null:(0,X.jsx)(Gn,{})}var Jn=Ke(`scenarios:view`,{layoutComponent:F})(qn);export{Jn as default};
|
|
38
|
-
//# sourceMappingURL=__...path__-
|
|
38
|
+
//# sourceMappingURL=__...path__-BF2zkD84.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as e}from"./chunk-Bj-mKKzh.js";import{Dr as t,Ss as n,Yn as r,Zr as i,_s as a,bs as o,is as s,mn as c,vs as l,xs as u,ys as d}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=_experiment_-
|
|
1
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{Dr as t,Ss as n,Yn as r,Zr as i,_s as a,bs as o,is as s,mn as c,vs as l,xs as u,ys as d}from"./command-bar-DUK45yin.js";import{j as f,n as p}from"./stack-oJ9iWdbl.js";import{t as m}from"./box-BsM8YLGl.js";import{f as h}from"./LoadingScreen--vgXk5-2.js";import{t as g}from"./tooltip-AEm0YeiF.js";import{t as _}from"./heading-D90dlSnH.js";import{t as v}from"./text-CwTrMF8x.js";import{t as y}from"./icon-BwEPrfAc.js";import{t as b}from"./h-stack-BKLDJ2vg.js";import{a as x,i as S,n as C,r as w}from"./alert-SnQmACl1.js";import{r as T,t as E}from"./card-CMtKVPVl.js";import{t as D}from"./container-Ccm3vB5X.js";import{t as O}from"./spacer-2LJJGbo8.js";import{t as k}from"./v-stack-EOPQ57OZ.js";import{h as A,s as j}from"./auth-client-D3UhxhQi.js";import{r as M}from"./next-router-C6sliiV7.js";import{c as N,t as P}from"./useOrganizationTeamProject-DC0iozx2.js";import{c as F,t as I}from"./DSPyExperiment-CMA6lrlx.js";var L=N(),R=e(t()),z=e(i()),B=f();function V({project:e,experiment:t}){let i=j.batchRecord.getAllByexperimentSlug.useQuery({projectId:e.id??``,experimentSlug:t.slug??``}),c=()=>{let e=[`Dataset`,`Evaluation`,`Input`,`Output`,`Expected Output`,`Passed`,`Status`,`Details`,`Score`,`Label`,`Cost`,`Created at`],n=[];i.data?.forEach(e=>{let t=e?.data?.input,r=e?.data?.output,i=e?.data?.expected_output;n.push([e.datasetSlug,e.evaluation,t,r,i,e.passed?`True`:`False`,e.status,e.details,e.score,e.label??``,e.cost,new Date(e.createdAt).toLocaleString()])});let r=z.default.unparse({fields:e,data:n}),a=window.URL.createObjectURL(new Blob([r])),o=document.createElement(`a`);o.href=a;let s=`${t?.slug}.csv`;o.setAttribute(`download`,s),document.body.appendChild(o),o.click(),o.remove()},f=i.data?.reduce((e,t)=>e+t.cost,0),x=i.data?.reduce((e,t)=>!e||new Date(t.createdAt)<new Date(e.createdAt)?t:e,void 0),S=i.data?.reduce((e,t)=>!e||new Date(t.createdAt)>new Date(e.createdAt)?t:e,void 0),C=S&&x?new Date(S.createdAt).getTime()-new Date(x.createdAt).getTime():0,w=i.data?.reduce((e,t)=>(e[t.evaluation]||(e[t.evaluation]={all:[],processed:[],error:[],skipped:[],unknown:[]}),e[t.evaluation].all.push(t),e[t.evaluation][t.status===`processed`?`processed`:t.status===`error`?`error`:t.status===`skipped`?`skipped`:`unknown`].push(t),e),{}),A=Object.fromEntries(Object.entries(w??{}).map(([e,t])=>[e,t.processed.some(e=>e.score)?`score`:`passed`])),M=Object.fromEntries(Object.entries(w??{}).map(([e,t])=>A[e]===`score`?[e,t.processed.reduce((e,t)=>e+t.score,0)/t.processed.length]:[e,t.processed.filter(e=>e.passed).length/t.processed.length]));return(0,B.jsxs)(m,{background:`bg.surface`,width:`full`,height:`full`,paddingTop:14,children:[(0,B.jsx)(D,{maxW:`calc(100vw - 200px)`,children:(0,B.jsxs)(b,{width:`full`,verticalAlign:`middle`,paddingBottom:6,children:[(0,B.jsxs)(k,{align:`start`,children:[(0,B.jsx)(_,{as:`h1`,size:`lg`,children:t.name??t.slug}),(0,B.jsxs)(v,{children:[`Dataset: `,i.data?.[0]?.dataset.name??``]})]}),(0,B.jsx)(O,{}),(0,B.jsxs)(p,{colorPalette:`black`,minWidth:`fit-content`,variant:`ghost`,onClick:()=>i.data&&c(),children:[`Download Results CSV`,` `,(0,B.jsx)(y,{marginLeft:2,children:(0,B.jsx)(s,{})})]})]})}),(0,B.jsxs)(b,{align:`center`,alignItems:`stretch`,justify:`center`,background:`gray.50`,padding:6,gap:6,children:[Object.entries(M).map(([e,t])=>(0,B.jsx)(T,{children:(0,B.jsx)(E,{children:(0,B.jsxs)(k,{align:`start`,justify:`center`,height:`full`,gap:2,children:[(0,B.jsx)(v,{color:`fg`,fontSize:`15px`,fontWeight:`500`,children:e}),(0,B.jsxs)(b,{align:`end`,color:t<.5?`red.500`:`green.500`,children:[(0,B.jsx)(v,{fontSize:`26px`,fontWeight:`300`,children:typeof t==`number`?(0,R.default)(t).format(A[e]===`score`?`0.00`:`0%`):t}),(0,B.jsx)(v,{fontSize:`13px`,fontWeight:`500`,marginBottom:`4px`,opacity:.8,children:A[e]===`score`?`avg score`:`pass rate`})]}),(0,B.jsxs)(b,{fontSize:`11px`,textTransform:`uppercase`,fontWeight:`600`,color:`fg.muted`,children:[w?.[e]?.skipped.length&&(0,B.jsxs)(v,{children:[(0,B.jsx)(m,{display:`inline-block`,background:`yellow.400`,borderRadius:`100%`,width:2,height:2,marginRight:1}),w?.[e]?.skipped.length,` `,`skipped`]}),w?.[e]?.error.length&&(0,B.jsxs)(v,{children:[(0,B.jsx)(m,{display:`inline-block`,background:`red.400`,borderRadius:`100%`,width:2,height:2,marginRight:1}),w?.[e]?.error.length,` error`]})]})]})})},e)),(0,B.jsx)(T,{children:(0,B.jsx)(E,{children:(0,B.jsxs)(k,{align:`start`,justify:`center`,height:`full`,gap:2,children:[(0,B.jsx)(v,{color:`fg`,fontSize:`15px`,fontWeight:`500`,children:`Evaluations Cost`}),(0,B.jsx)(v,{fontSize:`26px`,fontWeight:`300`,children:f?r({amount:f,currency:`USD`}):`-`})]})})}),(0,B.jsx)(T,{children:(0,B.jsx)(E,{children:(0,B.jsxs)(k,{align:`start`,justify:`center`,height:`full`,gap:2,children:[(0,B.jsx)(v,{color:`fg`,fontSize:`15px`,fontWeight:`500`,children:`Runtime`}),(0,B.jsx)(v,{fontSize:`26px`,fontWeight:`300`,children:C?(0,R.default)(C/1e3).format(`00:00:00`):`-`})]})})})]}),(0,B.jsx)(m,{width:`full`,paddingBottom:12,display:`flex`,justifyContent:`center`,overflowX:`auto`,paddingX:6,children:(0,B.jsx)(k,{align:`start`,minWidth:`0`,children:i.isLoading?(0,B.jsx)(m,{children:(0,B.jsx)(u,{variant:`line`,borderWidth:`1px`,borderColor:`border`,children:(0,B.jsx)(a,{children:Array.from({length:3}).map((e,t)=>(0,B.jsx)(n,{children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(l,{children:(0,B.jsx)(h,{height:`20px`})},t))},t))})})}):i.data&&i.data.length==0?(0,B.jsx)(v,{children:`No data found`}):Object.entries(w??{}).map(([e,t])=>{let i=t.all.some(e=>e.data?.expected_output),s=t.all.some(e=>e.details);return(0,B.jsxs)(k,{align:`start`,gap:8,paddingTop:12,children:[(0,B.jsx)(_,{as:`h2`,size:`md`,children:e}),(0,B.jsx)(m,{children:(0,B.jsxs)(u,{variant:`line`,borderWidth:`1px`,borderColor:`border`,children:[(0,B.jsx)(o,{children:(0,B.jsxs)(n,{children:[(0,B.jsx)(d,{children:`Input`}),(0,B.jsx)(d,{children:`Output`}),i&&(0,B.jsx)(d,{children:`Expected Output`}),(0,B.jsx)(d,{children:`Status`}),(0,B.jsx)(d,{minWidth:120,textAlign:`center`,children:A[e]===`score`?`Score`:`Passed`}),s&&(0,B.jsx)(d,{children:`Details`}),(0,B.jsx)(d,{children:`Cost`}),(0,B.jsx)(d,{children:`Created`})]})}),(0,B.jsx)(a,{children:t.all.map((t,a)=>{let o=t?.data?.input??``,c=t?.data?.output??``,u=t?.data?.expected_output??``;return(0,B.jsxs)(n,{children:[(0,B.jsx)(l,{children:(0,B.jsx)(g,{content:o,children:(0,B.jsx)(v,{lineClamp:2,display:`block`,maxWidth:230,children:o})})}),(0,B.jsx)(l,{children:(0,B.jsx)(g,{content:c,children:(0,B.jsx)(v,{lineClamp:2,display:`block`,maxWidth:230,children:c})})}),i&&(0,B.jsx)(l,{children:(0,B.jsx)(g,{content:u,children:(0,B.jsx)(v,{lineClamp:2,display:`block`,maxWidth:230,children:u})})}),(0,B.jsx)(l,{color:t.status===`skipped`?`yellow.700`:t.status===`error`?`red.700`:void 0,children:t.status}),t.status===`processed`?(0,B.jsx)(l,{textAlign:`center`,fontWeight:`500`,color:A[e]===`score`?t.score<.5?`red.500`:`green.500`:t.passed?`green.500`:`red.500`,children:A[e]===`score`?(0,R.default)(t.score).format(`0.00`):t.passed?`True`:`False`}):(0,B.jsx)(l,{textAlign:`center`,children:`-`}),s&&(0,B.jsx)(l,{maxWidth:300,color:t.status===`skipped`?`yellow.700`:t.status===`error`?`red.700`:void 0,children:(0,B.jsx)(g,{content:t.details,children:(0,B.jsx)(v,{lineClamp:1,wordBreak:`break-all`,display:`block`,children:t.details})})}),(0,B.jsx)(l,{children:t.cost?r({amount:t.cost,currency:`USD`}):`-`}),(0,B.jsx)(l,{children:new Date(t.createdAt).toLocaleString()})]},a)})})]})})]},e)})})})]})}function H(){let e=M(),{project:t}=P(),{experiment:n}=e.query,r=j.experiments.getExperimentBySlugOrId.useQuery({projectId:t?.id??``,experimentSlug:n},{enabled:!!t&&typeof n==`string`}),i=A(r.error),a=r.isError&&!i;return i?(0,B.jsx)(c,{children:(0,B.jsx)(m,{padding:6,children:(0,B.jsxs)(S,{status:`warning`,children:[(0,B.jsx)(w,{}),(0,B.jsx)(x,{children:`Experiment not found`}),(0,B.jsx)(C,{children:`The experiment you're looking for doesn't exist or you don't have access to it.`})]})})}):a?(0,B.jsx)(c,{children:(0,B.jsx)(m,{padding:6,children:(0,B.jsxs)(S,{status:`error`,children:[(0,B.jsx)(w,{}),(0,B.jsx)(x,{children:`Failed to load experiment`}),(0,B.jsx)(C,{children:r.error?.message??`An unexpected error occurred while loading the experiment.`})]})})}):(0,B.jsx)(c,{children:t&&r.data?.type===L.ExperimentType.DSPY?(0,B.jsx)(I,{project:t,experiment:r.data}):t&&r.data?.type===L.ExperimentType.BATCH_EVALUATION?(0,B.jsx)(V,{project:t,experiment:r.data}):!t||r.data===void 0||r.data.type===L.ExperimentType.BATCH_EVALUATION_V2||r.data.type===L.ExperimentType.EVALUATIONS_V3?(0,B.jsx)(F,{project:t,experiment:r.data}):(0,B.jsx)(m,{padding:6,children:(0,B.jsxs)(S,{status:`warning`,children:[(0,B.jsx)(w,{}),(0,B.jsx)(x,{children:`Unknown experiment type`}),(0,B.jsxs)(C,{children:[`This experiment has an unrecognized type: `,r.data.type]})]})})})}export{H as default};
|
|
2
|
+
//# sourceMappingURL=_experiment_-D02aoVQk.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Gr as e,mn as t}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=_id_-
|
|
1
|
+
import{Gr as e,mn as t}from"./command-bar-DUK45yin.js";import{j as n}from"./stack-oJ9iWdbl.js";import{r}from"./next-router-C6sliiV7.js";var i=n();function a(){let n=r().query.id;return(0,i.jsx)(t,{children:(0,i.jsx)(e,{datasetId:n})})}export{a as default};
|
|
2
|
+
//# sourceMappingURL=_id_-Ch8YmTiM.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,Bs as r,Pr as i,Qs as a,Ra as ee,Ss as o,Vs as s,Xr as c,Xs as l,Ys as u,Zs as te,_s as d,bs as f,do as ne,mn as p,rc as m,vs as h,xs as re,ys as g,zs as _}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=_id_-
|
|
1
|
+
import{s as e}from"./chunk-Bj-mKKzh.js";import{t}from"./react-C7JcuhbW.js";import{$s as n,Bs as r,Pr as i,Qs as a,Ra as ee,Ss as o,Vs as s,Xr as c,Xs as l,Ys as u,Zs as te,_s as d,bs as f,do as ne,mn as p,rc as m,vs as h,xs as re,ys as g,zs as _}from"./command-bar-DUK45yin.js";import{j as v,n as y,r as ie}from"./stack-oJ9iWdbl.js";import{t as b}from"./box-BsM8YLGl.js";import{t as x}from"./tooltip-AEm0YeiF.js";import{n as ae}from"./toaster-C_DYALhL.js";import{an as S}from"./dist-Cds4Mqhj.js";import{h as C}from"./terminal-CfM0q99k.js";import{t as w}from"./heading-D90dlSnH.js";import{t as T}from"./text-CwTrMF8x.js";import{r as E}from"./code-FF_ibTVI.js";import{t as D}from"./h-stack-BKLDJ2vg.js";import{t as O}from"./link-CwZhwOLq.js";import{t as k}from"./spacer-2LJJGbo8.js";import{t as A}from"./v-stack-EOPQ57OZ.js";import{s as j}from"./auth-client-D3UhxhQi.js";import{r as oe}from"./next-router-C6sliiV7.js";import{t as M}from"./useOrganizationTeamProject-DC0iozx2.js";import{t as N}from"./createLucideIcon-BJKFyRLS.js";import{t as P}from"./file-clock-CnKkOnAG.js";import{t as F}from"./WithPermissionGuard-B4Jo8E5-.js";import{t as I}from"./ConfirmDialog-M94yLNvP.js";import{t as L}from"./BudgetEditDrawer-CHEPz0hH.js";import{t as R}from"./GatewayLayout-LvwwrwMf.js";var z=N(`receipt`,[[`path`,{d:`M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z`,key:`q3az6g`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 17.5v-11`,key:`1jc1ny`}]]),B=e(t()),V=v();function H(){let{organization:e,project:t,hasPermission:p}=M(),v=oe(),C=typeof v.query.id==`string`?v.query.id:``,w=j.gatewayBudgets.get.useQuery({organizationId:e?.id??``,id:C},{enabled:!!e?.id&&!!C}),N=j.useContext(),F=j.gatewayBudgets.archive.useMutation({onSuccess:async()=>{e?.id&&(await N.gatewayBudgets.list.invalidate({organizationId:e.id}),await N.gatewayBudgets.get.invalidate({organizationId:e.id,id:C}))}}),[H,q]=(0,B.useState)(!1),[ce,J]=(0,B.useState)(!1),le=p(`gatewayBudgets:update`),ue=p(`gatewayBudgets:delete`),Y=w.data,de=async()=>{if(!(!Y||!e))try{await F.mutateAsync({organizationId:e.id,id:Y.id}),J(!1)}catch(e){ae.create({title:e instanceof Error?e.message:`Failed to archive`,type:`error`})}},X=Y?Number.parseFloat(Y.spentUsd):0,Z=Y?Number.parseFloat(Y.limitUsd):0,Q=Z>0?Math.min(100,X/Z*100):0,$=!!Y?.archivedAt;return(0,V.jsxs)(R,{children:[(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(c.Header,{children:[(0,V.jsx)(D,{children:(0,V.jsx)(O,{href:`/${t?.slug}/gateway/budgets`,color:`fg.muted`,fontSize:`sm`,children:(0,V.jsxs)(D,{gap:1,children:[(0,V.jsx)(E,{size:14}),` Budgets`]})})}),(0,V.jsxs)(c.Heading,{children:[Y?.name??`Budget`,$&&(0,V.jsx)(S,{colorPalette:`gray`,ml:2,children:`archived`})]}),(0,V.jsx)(k,{}),Y&&(0,V.jsxs)(D,{children:[(0,V.jsx)(O,{href:`/settings/audit-log?targetKind=budget&targetId=${Y.id}`,children:(0,V.jsxs)(y,{variant:`outline`,size:`sm`,children:[(0,V.jsx)(P,{size:14}),` Audit history`]})}),!$&&le&&(0,V.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>q(!0),children:[(0,V.jsx)(ee,{size:14}),` Edit`]}),!$&&ue&&(0,V.jsxs)(y,{colorPalette:`red`,variant:`outline`,size:`sm`,onClick:()=>J(!0),children:[(0,V.jsx)(ne,{size:14}),` Archive`]})]})]}),(0,V.jsx)(b,{padding:6,width:`full`,maxWidth:`1600px`,marginX:`auto`,children:w.isLoading?(0,V.jsx)(ie,{}):Y?(0,V.jsxs)(A,{align:`stretch`,gap:6,maxWidth:`960px`,children:[(0,V.jsx)(U,{title:`Utilization`,children:(0,V.jsxs)(A,{align:`stretch`,gap:2,children:[(0,V.jsxs)(D,{children:[(0,V.jsxs)(T,{fontWeight:`medium`,fontSize:`2xl`,children:[`$`,X.toFixed(2)]}),(0,V.jsxs)(T,{color:`fg.muted`,children:[`/ $`,Z.toFixed(2)]}),(0,V.jsx)(k,{}),(0,V.jsxs)(S,{colorPalette:Q>=100?`red`:Q>=80?`orange`:`green`,children:[Q.toFixed(1),`% used`]})]}),(0,V.jsx)(r,{value:Q,size:`sm`,colorPalette:Q>=100?`red`:Q>=80?`orange`:`green`,children:(0,V.jsx)(s,{children:(0,V.jsx)(_,{})})}),(0,V.jsxs)(D,{fontSize:`xs`,color:`fg.muted`,children:[(0,V.jsxs)(T,{children:[`Window: `,(0,V.jsx)(`strong`,{children:Y.window.toLowerCase()})]}),(0,V.jsx)(T,{children:`·`}),(0,V.jsxs)(T,{children:[`Resets:`,` `,(0,V.jsx)(`strong`,{children:Y.window===`TOTAL`?`never`:(0,V.jsx)(x,{content:new Date(Y.resetsAt).toLocaleString(),children:(0,V.jsx)(`span`,{children:i(new Date(Y.resetsAt).getTime())})})})]}),(0,V.jsx)(T,{children:`·`}),(0,V.jsxs)(T,{children:[`On breach:`,` `,(0,V.jsx)(`strong`,{children:Y.onBreach.toLowerCase()})]})]})]})}),(0,V.jsxs)(U,{title:`Identity`,children:[(0,V.jsx)(W,{label:`ID`,children:(0,V.jsx)(m,{fontSize:`xs`,children:Y.id})}),Y.description&&(0,V.jsx)(W,{label:`Description`,children:(0,V.jsx)(T,{fontSize:`sm`,children:Y.description})}),(0,V.jsx)(W,{label:`Scope`,children:(0,V.jsx)(G,{target:Y.scopeTarget,projectSlug:t?.slug??null})}),(0,V.jsx)(W,{label:`Created`,children:(0,V.jsx)(x,{content:new Date(Y.createdAt).toLocaleString(),children:(0,V.jsx)(T,{fontSize:`sm`,color:`fg.muted`,children:i(new Date(Y.createdAt).getTime())})})}),Y.lastResetAt&&(0,V.jsx)(W,{label:`Last reset`,children:(0,V.jsx)(x,{content:new Date(Y.lastResetAt).toLocaleString(),children:(0,V.jsx)(T,{fontSize:`sm`,color:`fg.muted`,children:i(new Date(Y.lastResetAt).getTime())})})}),Y.timezone&&(0,V.jsx)(W,{label:`Timezone`,children:(0,V.jsx)(m,{fontSize:`xs`,children:Y.timezone})})]}),(0,V.jsxs)(U,{title:`Recent debits`,children:[Y.recentLedger.length===0?(0,V.jsx)(a,{size:`sm`,children:(0,V.jsxs)(u,{children:[(0,V.jsx)(te,{children:(0,V.jsx)(z,{size:24})}),(0,V.jsx)(n,{children:`No debits yet`}),(0,V.jsx)(l,{children:`Debits land here once the gateway writes the outbox ledger after a completed request against a VK in this scope.`})]})}):(0,V.jsxs)(re,{size:`sm`,children:[(0,V.jsx)(f,{children:(0,V.jsxs)(o,{children:[(0,V.jsx)(g,{children:`When`}),(0,V.jsx)(g,{children:`Virtual key`}),(0,V.jsx)(g,{children:`Model`}),(0,V.jsx)(g,{children:`Amount`}),(0,V.jsx)(g,{children:`Status`})]})}),(0,V.jsx)(d,{children:Y.recentLedger.map(e=>(0,V.jsxs)(o,{children:[(0,V.jsx)(h,{children:(0,V.jsx)(x,{content:new Date(e.occurredAt).toLocaleString(),children:(0,V.jsx)(T,{fontSize:`xs`,color:`fg.muted`,children:i(new Date(e.occurredAt).getTime())})})}),(0,V.jsx)(h,{children:(0,V.jsx)(O,{href:`/${t?.slug}/gateway/virtual-keys/${e.virtualKeyId}`,color:`orange.600`,children:(0,V.jsx)(T,{fontSize:`sm`,children:e.virtualKeyName})})}),(0,V.jsx)(h,{children:(0,V.jsx)(m,{fontSize:`xs`,children:e.model})}),(0,V.jsx)(h,{children:se(e.amountUsd)}),(0,V.jsx)(h,{children:(0,V.jsx)(K,{status:e.status})})]},e.id))})]}),(0,V.jsx)(T,{fontSize:`xs`,color:`fg.muted`,mt:1,children:`Most recent 20 debits. Full history lives on the outbox ledger — query via Usage for aggregates.`})]})]}):(0,V.jsx)(T,{color:`fg.muted`,children:`Budget not found.`})})]}),(0,V.jsx)(L,{budget:H&&Y?Y:null,onOpenChange:e=>{e||q(!1)},onSaved:()=>{q(!1),w.refetch()}}),(0,V.jsx)(I,{open:ce,onOpenChange:J,title:`Archive ${Y?.name??`budget`}?`,message:`Debits against this budget stop counting. The historical ledger is preserved but new requests route as if the budget didn't exist.`,confirmLabel:`Archive`,tone:`warning`,loading:F.isPending,onConfirm:de})]})}function U({title:e,children:t}){return(0,V.jsxs)(b,{children:[(0,V.jsx)(w,{size:`sm`,mb:2,children:e}),(0,V.jsx)(C,{mb:3}),(0,V.jsx)(A,{align:`stretch`,gap:2,children:t})]})}function W({label:e,children:t}){return(0,V.jsxs)(D,{gap:4,align:`flex-start`,children:[(0,V.jsx)(T,{fontSize:`sm`,color:`fg.muted`,minWidth:`140px`,children:e}),t]})}function G({target:e,projectSlug:t}){let n=e.kind.toLowerCase().replace(`_`,` `),r=e.kind===`VIRTUAL_KEY`?`/${e.projectSlug??t??``}/gateway/virtual-keys/${e.id}`:null;return(0,V.jsxs)(D,{gap:2,align:`baseline`,children:[(0,V.jsx)(S,{colorPalette:`gray`,children:n}),r?(0,V.jsx)(O,{href:r,color:`orange.600`,children:(0,V.jsx)(T,{fontSize:`sm`,fontWeight:`medium`,children:e.name})}):(0,V.jsx)(T,{fontSize:`sm`,fontWeight:`medium`,children:e.name}),e.secondary&&(0,V.jsx)(m,{fontSize:`xs`,color:`fg.muted`,children:e.secondary})]})}function K({status:e}){return(0,V.jsx)(S,{colorPalette:e===`SUCCESS`?`green`:e===`BLOCKED_BY_GUARDRAIL`?`red`:e===`PROVIDER_ERROR`?`orange`:`gray`,children:e.toLowerCase()})}function se(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t>=1?`$${t.toFixed(4)}`:t>=.01?`$${t.toFixed(5)}`:`$${t.toFixed(6)}`:`—`}var q=F(`gatewayBudgets:view`,{layoutComponent:p})(H);export{q as default};
|
|
2
|
+
//# sourceMappingURL=_id_-D6ZvwHpH.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,mn as t}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=_id_-
|
|
1
|
+
import{c as e,mn as t}from"./command-bar-DUK45yin.js";import{j as n}from"./stack-oJ9iWdbl.js";import{t as r}from"./text-CwTrMF8x.js";import{s as i}from"./auth-client-D3UhxhQi.js";import{r as a}from"./next-router-C6sliiV7.js";import{t as o}from"./next-error-XienPTyn.js";var s=n();function c(){let n=a(),c=typeof n.query.id==`string`?n.query.id:``,l=i.share.getShared.useQuery({id:c},{enabled:!!c});return l.error?(0,s.jsx)(r,{children:`Error loading shared item`}):l.isSuccess?!l.data||l.data.resourceType!==`TRACE`?(0,s.jsx)(o,{statusCode:404}):(0,s.jsx)(t,{publicPage:!0,children:(0,s.jsx)(e,{traceId:l.data.resourceId})}):null}export{c as default};
|
|
2
|
+
//# sourceMappingURL=_id_-DOC1ZkBm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{sn as e}from"./command-bar-
|
|
2
|
-
//# sourceMappingURL=_id_-
|
|
1
|
+
import{sn as e}from"./command-bar-DUK45yin.js";import{j as t}from"./stack-oJ9iWdbl.js";import{t as n}from"./box-BsM8YLGl.js";import{t as r}from"./text-CwTrMF8x.js";import{t as i}from"./v-stack-EOPQ57OZ.js";import{s as a}from"./auth-client-D3UhxhQi.js";import{r as o}from"./next-router-C6sliiV7.js";import{t as s}from"./useOrganizationTeamProject-DC0iozx2.js";var c=t();function l(){let t=o().query.id,{project:l}=s(),u=a.graphs.getById.useQuery({projectId:l?.id??``,id:t??``},{enabled:!!l?.id&&!!t,retry:!1}),d=u.data?.graph,f=u.data?.name,p=u.data?.alert,m=p!=null&&p.type!=null&&(p.action===`SEND_EMAIL`||p.action===`SEND_SLACK_MESSAGE`)?p:void 0;return u.error?(0,c.jsxs)(i,{align:`start`,p:8,gap:2,children:[(0,c.jsx)(r,{fontSize:`xl`,fontWeight:`bold`,children:`Graph not found`}),(0,c.jsx)(r,{color:`gray.600`,children:`The graph you are looking for does not exist or you do not have access to it.`})]}):u.isLoading?(0,c.jsx)(n,{p:8,children:`Loading…`}):d?(0,c.jsx)(e,{customId:t,graph:d,name:f??``,filters:u.data?.filters,alert:m}):null}export{l as default};
|
|
2
|
+
//# sourceMappingURL=_id_-DfWwW6_N.js.map
|