@microvac/ui 0.1.0-rc.14 → 0.1.0-rc.15
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/dist/assets/{ActiveAgentsPanel-C9AP9hJu.js → ActiveAgentsPanel-BEx06tMt.js} +1 -1
- package/dist/assets/{AdapterManager-CmxTUKJH.js → AdapterManager-3kEEQWFJ.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-CXsQnTei.js → AdvancedToolsRoute-CgS6B-oh.js} +1 -1
- package/dist/assets/{AgentActionButtons-DWq2OuVK.js → AgentActionButtons-Cz3jCEd7.js} +1 -1
- package/dist/assets/{AgentAdvancedTab-dhBDxF-H.js → AgentAdvancedTab-BG6ZIAuN.js} +1 -1
- package/dist/assets/{AgentBulkSettingsSheet-DYT4ovDg.js → AgentBulkSettingsSheet-BrrbvspS.js} +1 -1
- package/dist/assets/{AgentChat-r0TPOfPK.js → AgentChat-Dw9iXD6H.js} +1 -1
- package/dist/assets/{AgentDetailPage-Bc_okBuS.js → AgentDetailPage-CuVIHv_q.js} +3 -3
- package/dist/assets/{AgentIdentityChip-CB2NBXkZ.js → AgentIdentityChip-BrVCcuHQ.js} +1 -1
- package/dist/assets/{AgentRosterFilters-b7qMLv8-.js → AgentRosterFilters-GQ2bdXfW.js} +2 -2
- package/dist/assets/{Agents-BsvXy3pZ.js → Agents-clrVQnvc.js} +2 -2
- package/dist/assets/{Agents.production-BeOZmzaF.js → Agents.production-DTopo7XB.js} +2 -2
- package/dist/assets/{AnimatedDialogContent-CWshmxP2.js → AnimatedDialogContent-CDLfw-dJ.js} +1 -1
- package/dist/assets/{AppDetail-DbqENTF_.js → AppDetail-BcWBg5yW.js} +1 -1
- package/dist/assets/{AppNotConnected-BhnCqL0F.js → AppNotConnected-NgfyHZ4L.js} +1 -1
- package/dist/assets/{ApprovalDetail-B2KiYLTj.js → ApprovalDetail-Dm_1V4tC.js} +1 -1
- package/dist/assets/{Approvals-j-wRmqKj.js → Approvals-i5AB3JPj.js} +1 -1
- package/dist/assets/{AppsConnect-CcPVEZ0C.js → AppsConnect-D660Tpuo.js} +1 -1
- package/dist/assets/{AppsReview-B8eWvKkS.js → AppsReview-DdTqOisY.js} +1 -1
- package/dist/assets/{ArtifactEmptyGraphic-5mdkS5jj.js → ArtifactEmptyGraphic-DzxCruYA.js} +1 -1
- package/dist/assets/{Artifacts-Bz7Oo6VX.js → Artifacts-CkXBz6nh.js} +1 -1
- package/dist/assets/{AssigneePickerInner-DdpF7hck.js → AssigneePickerInner-BNjyABBe.js} +1 -1
- package/dist/assets/{AssistantConnection-BpaaJDc_.js → AssistantConnection-CNF6mDmO.js} +1 -1
- package/dist/assets/{AttentionInlineVerbs-DlPQVCO-.js → AttentionInlineVerbs-BiyZ1ekZ.js} +1 -1
- package/dist/assets/{AttentionQueueRow-BC6ezctS.js → AttentionQueueRow-Bh0dKHpF.js} +1 -1
- package/dist/assets/{AuditHub-BVP7LKL9.js → AuditHub-BK848cb4.js} +1 -1
- package/dist/assets/{AuditRuns-DqizHgX1.js → AuditRuns-CUdlbP7S.js} +1 -1
- package/dist/assets/{Auth-DOF0snjp.js → Auth-DDqxm5gD.js} +1 -1
- package/dist/assets/{BoardChat-BYAbDtfd.js → BoardChat-fvKqk0R7.js} +1 -1
- package/dist/assets/{BoardClaim-7y41Pr8e.js → BoardClaim-BEC5BZfz.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-BftH1vOv.js → BootstrapSetupUxLab-CXzErrin.js} +1 -1
- package/dist/assets/{Browse-Ck01W1Yl.js → Browse-DoovSMuF.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-CKhrzfgy.js → BudgetPolicyCard-BYMlczCq.js} +1 -1
- package/dist/assets/{CaseDetail-qlXKJ66D.js → CaseDetail-UMAcSH_x.js} +1 -1
- package/dist/assets/{CaseStatus-B3RiZVDH.js → CaseStatus-BI0aMl9l.js} +1 -1
- package/dist/assets/{Cases-CFV3V-5X.js → Cases-CMTkGghU.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-7Hi5TJNt.js → ChatEndpointDetail-CocNEInH.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-CtwgH6sg.js → ChatEndpointSetup-Cyi2tI9K.js} +1 -1
- package/dist/assets/{ChatIdentityConfirm-CXjksBwX.js → ChatIdentityConfirm-Ba3JuTX1.js} +1 -1
- package/dist/assets/{CliAuth-KVjrGMfZ.js → CliAuth-D2jnueGH.js} +1 -1
- package/dist/assets/{Companies-oeJem3De.js → Companies-K75I9dJs.js} +1 -1
- package/dist/assets/{CompanyAccess-vWT6G-n_.js → CompanyAccess-Cw6nLUhE.js} +1 -1
- package/dist/assets/{CompanyActivity-zOzzeN1B.js → CompanyActivity-BsgmVpWS.js} +1 -1
- package/dist/assets/CompanyActivity.production-w-KGxvo6.js +1 -0
- package/dist/assets/{CompanyConnections-llSEaVa2.js → CompanyConnections-yRPYSdm7.js} +1 -1
- package/dist/assets/{CompanyEnvironments-DNyyGC_S.js → CompanyEnvironments-BA7kWdOJ.js} +1 -1
- package/dist/assets/{CompanyExport-CFa-F8Es.js → CompanyExport-DfsK4b9c.js} +1 -1
- package/dist/assets/{CompanyImport-DG6qwQ8F.js → CompanyImport-DJHAsmSF.js} +1 -1
- package/dist/assets/{CompanySettings-Dv5Z3ZQi.js → CompanySettings-DwzHGXec.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-CZk1d_0d.js → CompanySettingsPluginPage-Bpa81PF3.js} +1 -1
- package/dist/assets/{CompanySkills-CdzWhJfQ.js → CompanySkills-eTqgbqQN.js} +1 -1
- package/dist/assets/{CompanySkills.production-IoCRW5FQ.js → CompanySkills.production-CQSWfH0r.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-BwW7XQ1O.js → ConfigureBuiltInAgentModal-DgeD7t_i.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-PTn061ft.js → CopyableGatewayUrl-B6K3rOal.js} +1 -1
- package/dist/assets/{CordisPluginSettings-C_BeeGEc.js → CordisPluginSettings-DD3AnD2G.js} +1 -1
- package/dist/assets/{Costs-DhuNxwSj.js → Costs-orBM8T-a.js} +1 -1
- package/dist/assets/{CrossIssueCollaborationUxLab-ZaAXq46r.js → CrossIssueCollaborationUxLab-Bv9y9-NE.js} +1 -1
- package/dist/assets/{Dashboard-BaDnqiKo.js → Dashboard-CrSBNKX1.js} +1 -1
- package/dist/assets/{DashboardLive-D-Ed7osd.js → DashboardLive-Cg8C9RiS.js} +1 -1
- package/dist/assets/{DecisionDateChips-D3pl_mLn.js → DecisionDateChips-BLZKZH71.js} +1 -1
- package/dist/assets/{DecisionHistoryPanel-D5MzyrOh.js → DecisionHistoryPanel-yK-CP7Qg.js} +1 -1
- package/dist/assets/{DecisionQueuePage-D3UZ9oRk.js → DecisionQueuePage-BKXbERai.js} +1 -1
- package/dist/assets/{DesignGuide-COTo7ICj.js → DesignGuide-2FswNsXz.js} +1 -1
- package/dist/assets/{DesignSandboxTaskThread-CMeCSQid.js → DesignSandboxTaskThread-CGU--FXR.js} +1 -1
- package/dist/assets/{EmailConnectionAccess-kCL7obSr.js → EmailConnectionAccess-CZ5QRKyg.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-BGrksR_u.js → EmailEndpointSetup-BI2vsd8Y.js} +1 -1
- package/dist/assets/{EnforcementBanner-_Eb_nK3M.js → EnforcementBanner-B-iX466h.js} +1 -1
- package/dist/assets/{EntityRow-gpsOgEtu.js → EntityRow-BsICt6pd.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-DwGkH6d3.js → ExecutionWorkspaceDetail-CMqR9puh.js} +1 -1
- package/dist/assets/{ExternalAgentInviteDialog-CGid6pM9.js → ExternalAgentInviteDialog-De30ZrLP.js} +1 -1
- package/dist/assets/{FilterBar-1D-VhrvG.js → FilterBar-rCmsTtG4.js} +1 -1
- package/dist/assets/{FolderControls-CQ6kef3c.js → FolderControls-CmnB7Ap-.js} +1 -1
- package/dist/assets/{GatewayDetail-CCqekM1J.js → GatewayDetail-Duw9pJ10.js} +1 -1
- package/dist/assets/{GatewaysList-nFsRcszh.js → GatewaysList-BBhVGhRq.js} +1 -1
- package/dist/assets/{GitHubConnectionRecovery-B9sFWJup.js → GitHubConnectionRecovery-6VshLoNV.js} +1 -1
- package/dist/assets/{GoalDetail-BQ8y55P-.js → GoalDetail-CahntjlI.js} +1 -1
- package/dist/assets/{GoalTree-laRjXp0P.js → GoalTree-CU4GBFCh.js} +1 -1
- package/dist/assets/{Goals-Cm14EaeP.js → Goals-CzM2NDFR.js} +1 -1
- package/dist/assets/{InstanceAccess-DxQ-Akt_.js → InstanceAccess-CZzkE65W.js} +1 -1
- package/dist/assets/{InstanceExperimentalSettings-BxwqbXNw.js → InstanceExperimentalSettings-DWumKtOK.js} +1 -1
- package/dist/assets/{InviteLanding-Cf0L_u6s.js → InviteLanding-BIy2z50u.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-BfsF6FdF.js → IssueChatLongThreadPerf-D4DJvdOG.js} +1 -1
- package/dist/assets/{JoinRequestQueue-BXCdTFG_.js → JoinRequestQueue-C5rauGYm.js} +1 -1
- package/dist/assets/{Layout.production-CqzU0qMi.js → Layout.production-BSDWnupa.js} +1 -1
- package/dist/assets/{McpConnect-COWnZ9Eb.js → McpConnect-BN8ST0RS.js} +1 -1
- package/dist/assets/{MembershipAction-C9i9Sdmi.js → MembershipAction-DTjhGn-L.js} +1 -1
- package/dist/assets/{MetricCard-Bwnt3_p3.js → MetricCard-CeL9Pdn5.js} +1 -1
- package/dist/assets/{MissingPluginTabPlaceholder-B0Zxv1Kx.js → MissingPluginTabPlaceholder-CbQiSVnZ.js} +1 -1
- package/dist/assets/{NewAgent-BIlJ5Dyt.js → NewAgent-BszrNpQk.js} +1 -1
- package/dist/assets/{NewAgentDialog-CJdMxxYL.js → NewAgentDialog-U9qAcTzc.js} +1 -1
- package/dist/assets/{NewGoalDialog-B8izfKLm.js → NewGoalDialog-DqKbk4-i.js} +1 -1
- package/dist/assets/{NewProjectDialog-DXqjTYFK.js → NewProjectDialog-DrlUAF-N.js} +1 -1
- package/dist/assets/{OnboardingPrimitives-DHYBqn_0.js → OnboardingPrimitives-BkgPF4Mu.js} +1 -1
- package/dist/assets/{OnboardingWizard-DqSfZ13V.js → OnboardingWizard-CMBMcuXv.js} +1 -1
- package/dist/assets/{OrgChart.production-DrSFUf7i.js → OrgChart.production-BLczTjRj.js} +1 -1
- package/dist/assets/{PaperclipCloudOAuthHandoff-jPUvjJ8q.js → PaperclipCloudOAuthHandoff-BTtF8UPD.js} +1 -1
- package/dist/assets/{PluginManager-h3LFPaUq.js → PluginManager-CCcqlfgK.js} +1 -1
- package/dist/assets/{PluginPage-E5Im4454.js → PluginPage-B1empV69.js} +1 -1
- package/dist/assets/{PluginSettings-BBO0jAgo.js → PluginSettings-DtopaRqR.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-CQBD7fms.js → ProfileDetailRoute-BqvVpBZi.js} +1 -1
- package/dist/assets/{ProfileSettings-BwnVEHLp.js → ProfileSettings-5__tVfGi.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-By_SC6Gn.js → ProfileWizardRoute-vt-MRLuD.js} +1 -1
- package/dist/assets/{ProjectDetail-CbiwFBAE.js → ProjectDetail-DJ4zjube.js} +1 -1
- package/dist/assets/{ProjectRepositoryInput-DZF9bX4E.js → ProjectRepositoryInput-BJcnj3At.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-DPsl_4bD.js → ProjectWorkspaceDetail-DEAO3q6v.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-COH4dOWK.js → ProjectWorkspacesContent-CZvO7p0i.js} +1 -1
- package/dist/assets/{Projects-Ch9Qu7sn.js → Projects-Dm7-zXUH.js} +1 -1
- package/dist/assets/{QuotaBar-DIFOT9Uh.js → QuotaBar-Drp3CaxX.js} +1 -1
- package/dist/assets/{RepositoryEditor-DHB1bqId.js → RepositoryEditor-BT_VAkJu.js} +1 -1
- package/dist/assets/{Responsibilities-C5O0JXXG.js → Responsibilities-DbUEtGZu.js} +1 -1
- package/dist/assets/{ResponsibilityDetail-D6NpZpkm.js → ResponsibilityDetail--S8_GOkb.js} +1 -1
- package/dist/assets/{ResponsibleUserDenialUxLab-CFrIWYwe.js → ResponsibleUserDenialUxLab-1PB3JNG0.js} +1 -1
- package/dist/assets/{ReviewQueueCard-BPC4Lm67.js → ReviewQueueCard-B8w9aXKU.js} +1 -1
- package/dist/assets/{RoutineAuditActivity-sKyzMajz.js → RoutineAuditActivity-BCo7pYe5.js} +1 -1
- package/dist/assets/{RoutineDetail-CG8HF5fp.js → RoutineDetail-C9Dwn5G9.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-CKh3CmLD.js → RoutineRunVariablesDialog-Baomcbe3.js} +1 -1
- package/dist/assets/{Routines-tF2qfUKo.js → Routines-Dkv4gJno.js} +1 -1
- package/dist/assets/{Routines.production-BTyj1Ljr.js → Routines.production-Cs2Y-lpt.js} +1 -1
- package/dist/assets/{RoutinesToolbar-CvUFVCGN.js → RoutinesToolbar-BNKfCrTo.js} +1 -1
- package/dist/assets/{Search-Z9D0NuS1.js → Search-CVx4cl2o.js} +1 -1
- package/dist/assets/{Secrets-DgmbLOJK.js → Secrets-C2qv2HKZ.js} +1 -1
- package/dist/assets/{SkillBinaryFile-F3_9qcaM.js → SkillBinaryFile-DDkhLlfC.js} +1 -1
- package/dist/assets/{SkillCardIcon-CXHUCMej.js → SkillCardIcon-Cp_hws0N.js} +1 -1
- package/dist/assets/{SkillFolderTree-CB3lrTIE.js → SkillFolderTree-Cv0CmfYx.js} +1 -1
- package/dist/assets/{SkillSourceTree-BbuciCo6.js → SkillSourceTree-DmjlUswf.js} +1 -1
- package/dist/assets/{SkillSources-Dlo6Cew3.js → SkillSources-nmlYypUU.js} +1 -1
- package/dist/assets/{SkillStudio-ZO-Nf7eI.js → SkillStudio-BK3y_3zr.js} +1 -1
- package/dist/assets/{SkillsNavigationTabs-B9Iqnlqt.js → SkillsNavigationTabs-DRwMP1eu.js} +1 -1
- package/dist/assets/{SpekoPhoneCallback-C4VnMiZh.js → SpekoPhoneCallback-Cqi7AIyH.js} +1 -1
- package/dist/assets/{SpekoProviderSetup-I4evPZb3.js → SpekoProviderSetup-CJI4oXk5.js} +1 -1
- package/dist/assets/{StatusCards-D0MVzbsw.js → StatusCards-DKyyY81S.js} +1 -1
- package/dist/assets/{SummarySlotCard-DUXgZPxG.js → SummarySlotCard-f3RomdZS.js} +1 -1
- package/dist/assets/{TailscaleConnector-CMhT73gj.js → TailscaleConnector-yQWLR1Ra.js} +1 -1
- package/dist/assets/{TaskChatLab-D9-KAE-7.js → TaskChatLab-Dsr7eyj4.js} +1 -1
- package/dist/assets/{TaskSummaryList-CUxieFNe.js → TaskSummaryList-eFDfK_QH.js} +1 -1
- package/dist/assets/{Timeline-BNMoRbtK.js → Timeline-BWA9dyk6.js} +1 -1
- package/dist/assets/{ToolsAdminGate-CEr0zy2T.js → ToolsAdminGate-DpBg30hQ.js} +1 -1
- package/dist/assets/{TrustPresetSection-B9YXZtkh.js → TrustPresetSection-DtWjK9Kp.js} +1 -1
- package/dist/assets/{UserProfile-D-tnW96X.js → UserProfile-C66UI5xx.js} +1 -1
- package/dist/assets/{WebhookUrlWarning-Ba_DixKh.js → WebhookUrlWarning-CDygVnDH.js} +1 -1
- package/dist/assets/{WhatNeedsMe-B-Jzj8_M.js → WhatNeedsMe-BQ82RHus.js} +1 -1
- package/dist/assets/{Workspaces-BqhDI_Bl.js → Workspaces-DrjJes30.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-Bn9P-nUW.js → abnfDiagram-YUKMZFIV-Crkksu2D.js} +1 -1
- package/dist/assets/{architecture-WOLXFQ4H-V1ldsZlt.js → architecture-WOLXFQ4H-bHU8FW0c.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-BkYxt-Gc.js → architectureDiagram-47P4ROYG-Bj5Styf9.js} +1 -1
- package/dist/assets/{arrow-down-left-o81ENfeW.js → arrow-down-left-Ck9VQyqQ.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BO7pPYbp.js → blockDiagram-E7TT5TSB-OeHpNCQ-.js} +1 -1
- package/dist/assets/{budgets-0Dw6TH1A.js → budgets-CAWPqcn4.js} +1 -1
- package/dist/assets/{building-complex-DciZTnys.js → building-complex-Dxiyk_pH.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-D4EpmmzV.js → c4Diagram-CRA5TL53-QbK5p76P.js} +1 -1
- package/dist/assets/channel-BSmZkKA8.js +1 -0
- package/dist/assets/{chat-channels-DWyry-9M.js → chat-channels-CzTZV2fr.js} +1 -1
- package/dist/assets/{chunk-2BW5OAIV-DFXIyCJy.js → chunk-2BW5OAIV-Ckr4HfBO.js} +1 -1
- package/dist/assets/{chunk-3YJQHVM4-Dj5wEKIw.js → chunk-3YJQHVM4-C_uoPpLR.js} +1 -1
- package/dist/assets/{chunk-4EA7E6EY-5XiUVgzK.js → chunk-4EA7E6EY-BeMEfIRS.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-D0opKcsy.js → chunk-7TKQ45FW-DiwqWHvN.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-DnjsTe04.js → chunk-AW2ZBBNX-Cf57K3PO.js} +1 -1
- package/dist/assets/{chunk-DBDB3WZW-DNqSQPZ0.js → chunk-DBDB3WZW-B2qouVQO.js} +1 -1
- package/dist/assets/{chunk-E2ZNV5FY-cjSf_BTz.js → chunk-E2ZNV5FY-DG8wQ_NS.js} +1 -1
- package/dist/assets/{chunk-EU5HNXII-CZYBiaSw.js → chunk-EU5HNXII-cxRrXRGV.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DSc0-wJA.js → chunk-FVRAUYC3-Dizswk0V.js} +1 -1
- package/dist/assets/{chunk-HJ2JQQFS-MXK0gYSP.js → chunk-HJ2JQQFS-DL4lnpSv.js} +1 -1
- package/dist/assets/{chunk-HTAEGDNF-BjDZm_5k.js → chunk-HTAEGDNF-Zxjdb6kj.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-Bfj0tDmO.js → chunk-KQW6MTUR-BsVaJdnu.js} +1 -1
- package/dist/assets/{chunk-NTY3LDVX-Bpz5TkVb.js → chunk-NTY3LDVX-DyT9N5sM.js} +1 -1
- package/dist/assets/{chunk-VPRB5NB3-CfeHjtbb.js → chunk-VPRB5NB3-BNz5CtBn.js} +1 -1
- package/dist/assets/{chunk-XC4XBNZT-FBCWmi6K.js → chunk-XC4XBNZT-CCgIhjYS.js} +1 -1
- package/dist/assets/{circle-slash-DqKFFqfb.js → circle-slash-uNv_ha0X.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-DbC_J0kK.js → classDiagram-v2-K4WV4PDN-Cdh3CEl4.js} +1 -1
- package/dist/assets/{coins-BztUbqyl.js → coins-BDAh8hDQ.js} +1 -1
- package/dist/assets/{collections-BxrcELwt.js → collections-B58p51lw.js} +1 -1
- package/dist/assets/{connection-owner-D-ikSHyR.js → connection-owner-D8fNrFqC.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-COwSJ4qP.js → cynefin-EF2NZ3EQ-BkwhfqJ0.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-diaEJq9Y.js → cynefinDiagram-3GCD6N5R-DuGb_wq2.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-BPAMRuIj.js → dagre-W4DXFKR2-Bxq_Mhia.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-BvRnO1Id.js → diagram-2UJZ2QOL-B-P_hrXV.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-CDgBeD0m.js → diagram-OVF4WLC6-Ds0BqQWH.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-DAw9lREG.js → diagram-PFPMY2P6-Dpqb2-Cb.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-ZQqQn22t.js → diagram-UMYRVEAY-BJSoxjiu.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CoJtGgWs.js → diagram-YEKJPTXX-BxaG_9tT.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-qW_Zn_bO.js → diagram-ZIFT7M5P-6acvVOtc.js} +1 -1
- package/dist/assets/{dist-B2E6oBK1.js → dist-0EWXio4m.js} +1 -1
- package/dist/assets/{dist-IcdxEhjC.js → dist-BGvZP_Cl.js} +1 -1
- package/dist/assets/{dist-DXjkgaZX.js → dist-BZ7AbEhN.js} +1 -1
- package/dist/assets/{dist-_EtfntKJ.js → dist-BlosHr86.js} +1 -1
- package/dist/assets/{dist-DylHAy-6.js → dist-Bmr4uhSk.js} +1 -1
- package/dist/assets/{dist-DML0cJH3.js → dist-C6yMfMNS.js} +1 -1
- package/dist/assets/{dist-Dl94YqeS.js → dist-CMZQedYl.js} +1 -1
- package/dist/assets/{dist-DKyBHaH2.js → dist-C_N_-eaT.js} +1 -1
- package/dist/assets/{dist-CvRpZH53.js → dist-CaUbG4Hl.js} +1 -1
- package/dist/assets/{dist-ptDa9fKh.js → dist-Cn7-nxjU.js} +1 -1
- package/dist/assets/{dist-CG-phytt.js → dist-Cnj95_pX.js} +1 -1
- package/dist/assets/{dist-DbXGl-wj.js → dist-D9DR7k9k.js} +1 -1
- package/dist/assets/{dist-CjRqeLFz.js → dist-DIwsVdS2.js} +1 -1
- package/dist/assets/{dist-BCJybC91.js → dist-DVE0lLId.js} +1 -1
- package/dist/assets/{dist-CPgRB-NQ.js → dist-DkAPL4CQ.js} +1 -1
- package/dist/assets/{dist-CeSzCyeG.js → dist-Dl6N3kpQ.js} +1 -1
- package/dist/assets/{dist-DZruZxAk.js → dist-DmBvXBzK.js} +1 -1
- package/dist/assets/{dist-CdmdXwCZ.js → dist-DpgXK0aZ.js} +1 -1
- package/dist/assets/{dist-CYRzGbSY.js → dist-gMRyU9GJ.js} +1 -1
- package/dist/assets/{dist-CG6fC1Db.js → dist-jQQX2kOU.js} +1 -1
- package/dist/assets/{dist-DZIxMHOT.js → dist-lUaUoFTq.js} +1 -1
- package/dist/assets/{dist-CuwPDbnL.js → dist-qw1ZF2vD.js} +1 -1
- package/dist/assets/{dist-B6Qde8KJ.js → dist-rH4qrNAn.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-DA4UvKXV.js → ebnfDiagram-VR2GEFS7-Ytj3Z5qC.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-CM74d3mJ.js → elk-IJKZMXRS-CJurNqqK.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-d869V0qL.js → erDiagram-O2IAPWRE-hyXckW2d.js} +1 -1
- package/dist/assets/{eventmodeling-K75KTNOO-C-oz_eyI.js → eventmodeling-K75KTNOO-D3xQujrh.js} +1 -1
- package/dist/assets/flowDiagram-OXPTDLAJ-D4ojBTuY.js +1 -0
- package/dist/assets/{folder-plus-CxWXoYCi.js → folder-plus-BJZSMzuj.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-BBul4Kpm.js → ganttDiagram-R7TSEDQI-C8U_ITl4.js} +1 -1
- package/dist/assets/{gitGraph-VSP46ZUC-BriEZgAq.js → gitGraph-VSP46ZUC-CDeq3yKT.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-I12rg8s1.js → gitGraphDiagram-XJZIOB7I-CST3EWE9.js} +1 -1
- package/dist/assets/{goals-CvMWzjH4.js → goals-BNJZ4nzg.js} +1 -1
- package/dist/assets/{index-Bt31d8ga.js → index-BJtnP7H1.js} +8 -8
- package/dist/assets/{info-OHQRW6UA-CxrcGiem.js → info-OHQRW6UA-CPvTWk7J.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-4Sm0LiOu.js → infoDiagram-5W2HQ5XZ-BPUiNdxI.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-CKXvKV-s.js → ishikawaDiagram-K3B6WC7H-D5Z3rmaA.js} +1 -1
- package/dist/assets/{issue-detail-4PCbYpdv.js → issue-detail-CZfjXs0M.js} +3 -3
- package/dist/assets/{journeyDiagram-COXZFDF6-BHsrZLvQ.js → journeyDiagram-COXZFDF6-CEkwEYdR.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-8HhnIs_l.js → kanban-definition-P3RFRI5V-8h_R6Qjq.js} +1 -1
- package/dist/assets/{line-rrKrpB-b.js → line-Ljt_vfsb.js} +1 -1
- package/dist/assets/{link-BecLzmfo.js → link-DvgFK0mz.js} +1 -1
- package/dist/assets/{list-filter-BC3D4IoX.js → list-filter-BR4_dvwm.js} +1 -1
- package/dist/assets/{log-in-BJCGwGGT.js → log-in-Dvx9-FMC.js} +1 -1
- package/dist/assets/{mcpSkills-DRs3pGKn.js → mcpSkills-76szK_k1.js} +1 -1
- package/dist/assets/{mermaid-parser.core-DmG0b4S0.js → mermaid-parser.core-BjFu937m.js} +3 -3
- package/dist/assets/{mermaid.core-D1vILTuF.js → mermaid.core-B0t95EIS.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-DIMpL0de.js → mindmap-definition-LZFPQGKD-TVnHYUR4.js} +1 -1
- package/dist/assets/{packet-JDAUHWVQ-BnbYht3G.js → packet-JDAUHWVQ-aNGiRWLy.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-BUjtJVjT.js → pegDiagram-BGZESJAR-DDadxqWQ.js} +1 -1
- package/dist/assets/{pie-XZMESJXO-CM4VXUb-.js → pie-XZMESJXO-CydFP1hd.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-B3v8ryvG.js → pieDiagram-CAPJLFHJ-KhdUDwDS.js} +1 -1
- package/dist/assets/{power-0mw59G-l.js → power-sYV-WuqQ.js} +1 -1
- package/dist/assets/{profile-summary-B5rPf8v-.js → profile-summary-D4LPX-Dv.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-Cv-dS2Rn.js → quadrantDiagram-GDMTTRAM-B1X8K2Fs.js} +1 -1
- package/dist/assets/{radar-ABXABTNO-v6yZj4Fk.js → radar-ABXABTNO-BqodkLpx.js} +1 -1
- package/dist/assets/{railroad-I3PHUGI6-D-U8Cs0m.js → railroad-I3PHUGI6-HmRKXDJj.js} +1 -1
- package/dist/assets/{railroad-abnf-LNEFI6M7-Dw3fkrVy.js → railroad-abnf-LNEFI6M7-CkBttaHp.js} +1 -1
- package/dist/assets/{railroad-ebnf-DWYD2UWJ-_ln-e3Tx.js → railroad-ebnf-DWYD2UWJ-C6DBawFA.js} +1 -1
- package/dist/assets/{railroad-peg-JR7BVNR7-Bf8u1-RZ.js → railroad-peg-JR7BVNR7-Z9df3u5o.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-Drr5UhQI.js → railroadDiagram-SM67HX2B-2vDUUppL.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-D5ef6_ac.js → requirementDiagram-X7JNWC4A-DAuP39Hc.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-DncJWIz_.js → sankeyDiagram-UM26HJRW-ByS54QZK.js} +1 -1
- package/dist/assets/{saved-permissions-CizWg8-P.js → saved-permissions-CPiYtxkZ.js} +1 -1
- package/dist/assets/{scroll-text-Ck6HB7eM.js → scroll-text-CVSt6aO2.js} +1 -1
- package/dist/assets/{sdk-CWyUlmcn.js → sdk-vrG4HtB4.js} +1 -1
- package/dist/assets/{search-DkTqg7ab.js → search-CG-QtPVH.js} +1 -1
- package/dist/assets/{send-CYVi50sh.js → send-CH-0xdLm.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Cs0nGCCg.js → sequenceDiagram-ZO4K6R2Y-DvWxKTLK.js} +1 -1
- package/dist/assets/{shared-CIwISWMj.js → shared-D37zfckm.js} +1 -1
- package/dist/assets/{smoke-lab-matrix-A7ubFpfk.js → smoke-lab-matrix-C5gR81E3.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-Dpp3m5Wq.js → stateDiagram-v2-TBUQTH76-DtiiZIXq.js} +1 -1
- package/dist/assets/{swimlanes-N4OXWK64-NXVbx1w8.js → swimlanes-N4OXWK64-BWSEtCbX.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Bl_9DvHU.js +8 -0
- package/dist/assets/{timeline-definition-YOQAKGHF-DqI-Mv2e.js → timeline-definition-YOQAKGHF-U4QcniMh.js} +1 -1
- package/dist/assets/{treeView-D4JQ5SDB-CZBlE7ya.js → treeView-D4JQ5SDB-B2tdrtsj.js} +1 -1
- package/dist/assets/{treemap-SAJKECNS-BlueznID.js → treemap-SAJKECNS-DodN8j4n.js} +1 -1
- package/dist/assets/{useAgentlessOnboardingAutoOpen-CnFwEQ-H.js → useAgentlessOnboardingAutoOpen-DSWW7Juw.js} +1 -1
- package/dist/assets/{useAuthorizationWindow-DnFQsiFj.js → useAuthorizationWindow-tg3aKEU7.js} +1 -1
- package/dist/assets/{useDateRange-9EbqkWXy.js → useDateRange-CnZQr2KO.js} +1 -1
- package/dist/assets/{useFastResponsesEnabled-D8dunm4j.js → useFastResponsesEnabled-B8tHSJ1y.js} +1 -1
- package/dist/assets/{usePageView-BiX5i8ck.js → usePageView-CtFMs34g.js} +1 -1
- package/dist/assets/{useProfilesData-0VYQ4lAT.js → useProfilesData-CWHdMSuL.js} +1 -1
- package/dist/assets/{useReviewCount-WBWxwKI3.js → useReviewCount-W_bCZ2Hz.js} +1 -1
- package/dist/assets/{useRoutineFormOptions-DnX5DBn1.js → useRoutineFormOptions-CCLMmVSF.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-DPQRvaXT.js → useSummaryDraftStream-NVNYNt72.js} +1 -1
- package/dist/assets/{useTailscaleConnections-BDff6dWx.js → useTailscaleConnections-Dy52nCY3.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-BSDn8OaJ.js → usecaseDiagram-VIAY4XPW-kEHhqgOj.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-BBSA9KNN.js → vennDiagram-BLWOH2XV-NPJU0aCU.js} +1 -1
- package/dist/assets/{wardley-7MLQ67FV-CsT-rTZ9.js → wardley-7MLQ67FV-bUGKvIPT.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-BLClsIjw.js → wardleyDiagram-YMQ3BMBF-qtUDHfhb.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-2x4wB0gq.js → xychartDiagram-TAQBALBS-C-z57aZj.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/CompanyActivity.production-DbaFBsM0.js +0 -1
- package/dist/assets/channel-BQh2vFIU.js +0 -1
- package/dist/assets/flowDiagram-OXPTDLAJ-Be1xLbJu.js +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Ct3LnXZt.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
var xt=Object.defineProperty;var i=(t,n)=>xt(t,"name",{value:n,configurable:!0});import{a as Us,n as pt}from"./rolldown-runtime-DhZMWcEn.js";import{a as ht,i as gt,n as bt,r as vt,t as ft}from"./BudgetPolicyCard-CKhrzfgy.js";import{b as jt}from"./collections-BxrcELwt.js";import{t as yt}from"./arrow-down-left-o81ENfeW.js";import{t as ns}from"./coins-BztUbqyl.js";import{$A as Nt,$S as Ls,Ai as re,BA as M,BE as Ct,CA as Ps,Di as As,EA as Ne,E_ as W,FA as Oe,GA as kt,GE as St,GS as F,Gb as Qe,HE as j,H_ as We,IA as me,Kr as Tt,LS as It,ME as qs,M_ as ie,Mb as Pt,Mi as je,NE as ee,OA as Ks,O_ as X,RE as cs,UT as as,VA as At,VE as zs,WC as rs,WE as Ce,XE as I,__ as ws,bE as Ae,cv as wt,fy as Mt,iT as Xe,ib as Et,jT as Os,j_ as oe,jb as $t,ji as Dt,kT as Qs,k_ as be,ki as es,ly as Ft,mb as ye,my as Bt,nD as se,nj as Rt,oE as _t,on as Ut,op as Pe,pb as ss,rD as ds,rb as Lt,sy as qt,uE as qe,uy as Kt,wA as zt,xE as q,zE as $e}from"./index-Bt31d8ga.js";import{t as ts}from"./budgets-0Dw6TH1A.js";import{a as Ot,i as we,n as Qt,o as _,r as Wt,s as Ms,t as Gt}from"./useDateRange-9EbqkWXy.js";import{n as Vt,r as Yt,t as Ht}from"./useFastResponsesEnabled-D8dunm4j.js";import{t as Ge}from"./QuotaBar-DIFOT9Uh.js";var ge=At([M().max(160),Oe().finite()]).transform((t,n)=>{try{if((typeof t=="number"?t<0:t.startsWith("-"))||bt(t)<0n)throw new Error("Money cannot be negative");return gt(t)}catch(a){return n.addIssue({code:"custom",message:a instanceof Error?a.message:"Invalid money"}),kt}}),Ws=me({source:Ne(["provider_reported","provider_invoice","operator","rate_card","unknown"]).default("unknown"),version:M().max(100).optional(),evidence:M().max(1e3).optional(),inputCentsPerMillion:ge.optional(),cachedInputCentsPerMillion:ge.optional(),outputCentsPerMillion:ge.optional(),cacheWriteCentsPerMillion:ge.optional(),serviceTier:M().max(50).optional(),contextTier:Ne(["short","long"]).optional()}),Bn=me({biller:M().trim().min(1).max(150),externalId:M().trim().min(1).max(200),currency:M().regex(/^[A-Za-z]{3}$/).transform(t=>t.toUpperCase()),lines:Ks(me({externalId:M().trim().min(1).max(200),kind:Ne(["inference","fee","credit"]).default("inference"),amountCents:ge,occurredAt:zt({offset:!0}),costEventId:M().uuid().optional(),runId:M().uuid().optional(),providerRequestId:M().min(1).max(250).optional(),model:M().min(1).max(250).optional(),pricing:Ws.optional()})).min(1).max(2e3)}).superRefine((t,n)=>{new Set(t.lines.map(a=>a.externalId)).size!==t.lines.length&&n.addIssue({code:"custom",path:["lines"],message:"Invoice line identifiers must be unique"})}),Rn=me({idempotencyKey:M().trim().min(1).max(200),expectedCents:ge,correctedCents:ge,invoiceLineId:M().uuid().optional(),reason:M().trim().min(1).max(1e3),pricing:Ws}),_n=me({fingerprint:M().regex(/^[a-f0-9]{64}$/),reason:M().trim().min(1).max(1e3)}),Un=me({runId:M().uuid()}),Ln=me({provider:Ne(["openai","anthropic"]),secretId:M().uuid(),accountId:M().trim().min(1).max(150).regex(/^[a-zA-Z0-9_-]+$/),scopeIds:Ks(M().trim().min(1).max(150)).min(1).max(25),from:Ps(),to:Ps()}).superRefine((t,n)=>{const a=Date.parse(t.to)-Date.parse(t.from);(a<=0||a>26784e5||Date.parse(t.to)>Math.floor(Date.now()/864e5)*864e5)&&n.addIssue({code:"custom",message:"Choose up to 31 completed UTC days; the end date is exclusive."}),new Set(t.scopeIds).size!==t.scopeIds.length&&n.addIssue({code:"custom",message:"Project/workspace identifiers must be unique."})}),Gs=["USD","EUR","GBP","CAD","AUD","CHF"],qn=me({expectedRevision:Oe().int().nonnegative(),plan:M().trim().min(1).max(100),amountCents:ge.nullable(),currency:Ne(Gs),cadence:Ne(["month","year"]),status:Ne(["active","ended","excluded"])}).strict(),Kn=me({targetId:M().uuid(),expectedRevision:Oe().int().nonnegative(),targetRevision:Oe().int().nonnegative()}).strict(),zn=[["openai","free","ChatGPT Free","0","https://learn.chatgpt.com/docs/pricing"],["openai","go","ChatGPT Go","800","https://learn.chatgpt.com/docs/pricing"],["openai","plus","ChatGPT Plus","2000","https://learn.chatgpt.com/docs/pricing"],["anthropic","pro","Claude Pro","2000","https://claude.com/pricing"],["anthropic","max_5x","Claude Max 5x","10000","https://claude.com/pricing"],["anthropic","max_20x","Claude Max 20x","20000","https://claude.com/pricing"],["xai","supergrok","SuperGrok","3000","https://x.ai/pricing"],["xai","supergrok_plus","SuperGrok Plus","10000","https://x.ai/pricing"]].map(([t,n,a,r,l])=>({provider:t,id:n,name:a,monthlyCents:r,sourceUrl:l,currency:"USD",checkedAt:"2026-10-08"})),e=Us(Nt(),1);function Vs({entries:t,fastResponse:n=!1,fastResponsesEnabled:a=!0}){return t.length?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recent requests. Inputs are not retained."}),(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm","aria-label":n?"Fast responses":"Decision requests",children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{className:"border-b border-border text-muted-foreground",children:["When / feature","Responsible","Task",...n?["Connection"]:[],"Model","Status","Duration","Tokens in / out","Cost"].map(r=>(0,e.jsx)("th",{className:"px-3 py-2 text-left font-medium",children:r},r))})}),(0,e.jsx)("tbody",{children:t.map(r=>(0,e.jsxs)("tr",{className:"border-b border-border last:border-0",children:[(0,e.jsxs)("td",{className:"px-3 py-3",children:[(0,e.jsx)("div",{className:"whitespace-nowrap",children:Ce(r.startedAt)}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.feature==="settings.test"?"Setup test":r.feature})]}),(0,e.jsx)("td",{className:"px-3 py-3",children:r.actorType==="system"?"Microvac services":r.userName??(r.responsibleUserId==="local-board"?"Board":"Former user")}),(0,e.jsx)("td",{className:"px-3 py-3",children:r.issueId?(0,e.jsx)(Qe,{className:"underline underline-offset-4",to:`/issues/${r.issueIdentifier??r.issueId}`,children:r.issueIdentifier??"View task"}):"—"}),n&&(0,e.jsx)("td",{className:"px-3 py-3 ph-mask ph-sensitive",children:r.connectionName??(r.connectionId?"Removed connection":"—")}),(0,e.jsx)("td",{className:"px-3 py-3 font-mono text-xs",children:r.model}),(0,e.jsxs)("td",{className:"px-3 py-3",children:[(0,e.jsx)("div",{children:r.status==="succeeded"?"Succeeded":r.status==="running"?"Running":r.status==="unknown"?"Unresolved":r.status==="skipped"?"Skipped":r.status==="pending"?"Pending":"Failed"}),r.publicationStatus&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.publicationStatus}),r.errorCode&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.errorCode.replaceAll("_"," ")})]}),(0,e.jsx)("td",{className:"px-3 py-3 font-mono",children:r.durationMs===null?"—":`${(r.durationMs/1e3).toFixed(1)}s`}),(0,e.jsxs)("td",{className:"whitespace-nowrap px-3 py-3 font-mono",children:[r.inputTokens===null?"—":I(r.inputTokens)," / ",r.outputTokens===null?"—":I(r.outputTokens)]}),(0,e.jsxs)("td",{className:"px-3 py-3 font-mono",children:[(0,e.jsx)("div",{children:r.costCents===null?"Unknown":St(r.costCents)}),r.costStatus!=="unpriced"&&r.costStatus&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:r.costStatus==="estimated"?"Estimated":"Reported"})]})]},r.id))})]})})]}):(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:[n?"No fast responses in this period.":"No decision requests in this period."," ",(0,e.jsx)(Qe,{to:n&&!a?"/company/settings/instance/experimental":"/company/settings/connections",className:"underline underline-offset-4",children:n?a?"Configure fast response":"Enable experimental fast responses":"Configure a decision model"})," to run a test."]})}i(Vs,"DecisionHistoryTable");function Zt({companyId:t,from:n,to:a}){const r=q({queryKey:["decision-history",t,n,a],queryFn:i(()=>Yt.history(t,n,a),"queryFn"),refetchInterval:i(l=>l.state.data?.some(g=>g.status==="running")?5e3:!1,"refetchInterval")});return r.isPending?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading decision requests…"}):r.error?(0,e.jsxs)("div",{role:"alert",className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Could not load decision requests."}),(0,e.jsx)(ee,{variant:"outline",onClick:i(()=>{r.refetch()},"onClick"),children:"Try again"})]}):(0,e.jsx)(Vs,{entries:r.data??[]})}i(Zt,"DecisionHistory");function Jt({companyId:t,from:n,to:a}){const{enabled:r}=Ht(),l=q({queryKey:["fast-response-history",t,n,a],queryFn:i(()=>Vt.history(t,n??void 0,a??void 0),"queryFn"),refetchInterval:i(g=>g.state.data?.some(u=>["pending","running"].includes(u.status)||["pending","streaming","retry"].includes(u.publicationStatus))?3e3:!1,"refetchInterval")});return l.isPending?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading fast responses…"}):l.error?(0,e.jsxs)("div",{role:"alert",children:[(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Could not load fast responses."}),(0,e.jsx)(ee,{variant:"outline",onClick:i(()=>{l.refetch()},"onClick"),children:"Try again"})]}):(0,e.jsx)(Vs,{entries:l.data??[],fastResponse:!0,fastResponsesEnabled:r})}i(Jt,"FastResponseHistory");var p=Us(Rt(),1),Ve={report(t,n,a){const r=new URLSearchParams;return n&&r.set("from",n),a&&r.set("to",a),!n&&!a&&r.set("period","all"),qe.get(`/companies/${t}/costs/subscriptions?${r}`)},refresh:i(t=>qe.post(`/companies/${t}/costs/subscriptions/refresh`,{}),"refresh"),update:i((t,n,a)=>qe.patch(`/companies/${t}/costs/subscriptions/${n}`,a),"update"),link:i((t,n,a,r,l)=>qe.post(`/companies/${t}/costs/subscriptions/${n}/link`,{targetId:a,expectedRevision:r,targetRevision:l}),"link")};function Es(t,n){return n==="USD"?j(Number(t)):new Intl.NumberFormat(void 0,{style:"currency",currency:n,currencyDisplay:"code"}).format(Number(t)/100)}i(Es,"subscriptionMoney");function is({usage:t}){return(0,e.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:[I(t.inputTokens+t.cachedInputTokens)," in · ",I(t.outputTokens)," out",t.cachedInputTokens>0&&(0,e.jsxs)("span",{className:"block",children:[I(t.cachedInputTokens)," input cached"]})]})}i(is,"SubscriptionTokenUsage");function Xt({account:t,accounts:n,companyId:a,onDone:r}){const[l,g]=(0,p.useState)(t.price.plan),[u,E]=(0,p.useState)(t.price.amountCents==null?"":vt(t.price.amountCents).replace(/\.?0+$/,"")),[U,B]=(0,p.useState)(t.price.currency),[v,c]=(0,p.useState)(t.price.cadence),[T,R]=(0,p.useState)(t.price.status),[L,$]=(0,p.useState)(""),G=Ae({mutationFn:i(()=>Ve.update(a,t.id,{expectedRevision:t.price.revision,plan:l,amountCents:u.trim()?ht(u.trim()):null,currency:U,cadence:v,status:T}),"mutationFn"),onSuccess:r}),K=Ae({mutationFn:i(()=>Ve.link(a,t.id,L,t.price.revision,n.find(C=>C.id===L).price.revision),"mutationFn"),onSuccess:r}),z=n.filter(C=>C.id!==t.id&&C.provider===t.provider&&C.canEdit),w=G.isPending||K.isPending,k="h-9 rounded-md border border-input bg-background px-3 text-sm";return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("form",{className:"space-y-4",onSubmit:i(C=>{C.preventDefault(),G.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-plan",children:"Plan"}),(0,e.jsx)(ws,{id:"subscription-plan",value:l,onChange:i(C=>g(C.target.value),"onChange"),required:!0,maxLength:100})]}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-price",children:"Price per billing period"}),(0,e.jsx)(ws,{id:"subscription-price",type:"number",min:"0",step:"any",value:u,placeholder:"Unknown",onChange:i(C=>E(C.target.value),"onChange")})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-currency",children:"Currency"}),(0,e.jsx)("select",{id:"subscription-currency",className:k,value:U,onChange:i(C=>B(C.target.value),"onChange"),children:Gs.map(C=>(0,e.jsx)("option",{children:C},C))})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-cadence",children:"Billed"}),(0,e.jsxs)("select",{id:"subscription-cadence",className:k,value:v,onChange:i(C=>c(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"month",children:"Monthly"}),(0,e.jsx)("option",{value:"year",children:"Annually"})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-status",children:"Tracking"}),(0,e.jsxs)("select",{id:"subscription-status",className:k,value:T,onChange:i(C=>R(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"active",children:"Active"}),(0,e.jsx)("option",{value:"ended",children:"Subscription ended"}),(0,e.jsx)("option",{value:"excluded",children:"Exclude from this organization"})]})]})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter the full amount for one account or seat. Annual prices are divided by 12. Changes apply from now. Ending tracking here does not cancel your provider subscription."}),G.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not save this price. Check the amount, or reopen the account if another person updated it."}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ee,{type:"button",variant:"ghost",disabled:w,onClick:r,children:"Cancel"}),(0,e.jsx)(ee,{type:"submit",disabled:w,children:G.isPending?"Saving…":"Save price"})]})]}),z.length>0&&(0,e.jsxs)("div",{className:"space-y-2 border-t border-border pt-4",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-link",children:"Same subscription as another account?"}),(0,e.jsxs)("select",{id:"subscription-link",className:$e(k,"ph-mask ph-sensitive"),value:L,onChange:i(C=>$(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Choose an account"}),z.map(C=>(0,e.jsxs)("option",{value:C.id,children:[C.name," · ",C.price.plan]},C.id))]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Linking counts these accounts once, combines their Microvac usage, and keeps the selected account’s price. Only link the same subscription or paid seat."}),K.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not link these accounts. Reopen their details and try again."}),(0,e.jsx)(ee,{type:"button",variant:"outline",disabled:!L||w,onClick:i(()=>K.mutate(),"onClick"),children:"Link accounts"})]})]})}i(Xt,"SubscriptionEditor");function en({companyId:t,report:n,error:a,onChanged:r}){const[l,g]=(0,p.useState)(!1),[u,E]=(0,p.useState)(null),U=i(()=>{E(null),r()},"closeEditor"),B=n?.monthlyTotals.length,v=n?.monthlyTotals.reduce((c,T)=>c+T.estimatedCount,0)??0;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(W,{className:"block p-4",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"Subscriptions"}),(0,e.jsx)("div",{className:"mt-2 font-mono text-2xl font-semibold tabular-nums",children:B?n.monthlyTotals.map(c=>(0,e.jsxs)("div",{children:[Es(c.amountCents,c.currency),(0,e.jsx)("span",{className:"text-sm font-normal",children:"/month"})]},c.currency)):n&&n.activeCount===0&&n.accounts.length>0?"$0.00/month":"—"}),(0,e.jsxs)("div",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:[n?(0,e.jsxs)(e.Fragment,{children:[v>0&&(0,e.jsx)("div",{children:(0,e.jsx)(We,{variant:"outline",className:"font-normal text-muted-foreground",children:v<n.activeCount-n.unknownPriceCount?"Partially estimated":"Estimated"})}),n.unknownPriceCount>0&&!!B&&(0,e.jsx)("div",{children:"Known monthly subtotal"}),(0,e.jsx)("div",{children:n.accounts.length===0?"No visible subscriptions":(0,e.jsxs)(e.Fragment,{children:[n.activeCount," active ",n.activeCount===1?"subscription":"subscriptions",n.unknownPriceCount>0&&` · ${n.unknownPriceCount} ${n.unknownPriceCount===1?"price":"prices"} unknown`]})}),n.accounts.length>0&&(0,e.jsx)("div",{children:"Monthly fees for accounts visible to you"}),n.unidentifiedAccountCount>0&&(0,e.jsxs)("div",{children:[n.unidentifiedAccountCount," unconfirmed ",n.unidentifiedAccountCount===1?"account identity":"account identities"]}),(0,e.jsx)(is,{usage:n.subscription})]}):a?(0,e.jsx)("div",{children:"Subscription data is unavailable."}):(0,e.jsx)("div",{children:"Loading subscriptions…"}),n&&a?(0,e.jsx)("div",{children:"Showing last loaded subscription data."}):null]}),(0,e.jsx)(ee,{variant:"link",size:"sm",className:"h-auto p-0",onClick:i(()=>g(!0),"onClick"),disabled:!n,children:"View details"})]}),(0,e.jsx)(qt,{open:l,onOpenChange:i(c=>{g(c),c||E(null)},"onOpenChange"),children:(0,e.jsxs)(Ft,{className:"max-h-(--sz-80vh) overflow-y-auto sm:max-w-3xl",children:[(0,e.jsxs)(Mt,{children:[(0,e.jsx)(Bt,{children:u?"Subscription price":"Subscriptions"}),(0,e.jsx)(Kt,{children:"Current monthly costs for accounts visible to you. Token totals cover company work in the selected period."})]}),u?(0,e.jsx)(Xt,{companyId:t,account:u,accounts:n?.accounts??[],onDone:U},u.id):(0,e.jsxs)("div",{className:"space-y-4",children:[n?.accounts.length===0&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No subscriptions are visible to you yet. Connect an AI account or run an agent with a connected subscription."}),n?.accounts.map(c=>(0,e.jsxs)("div",{className:"space-y-2 border-b border-border pb-4 last:border-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:Ls,children:[(0,e.jsx)("div",{className:"font-medium",children:c.name}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[c.shared?"Shared":c.ownerName??(c.ownerUserId?"Account owner":"Personal accounts")," · ",se(c.provider)," · ",c.price.plan]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)("div",{className:"font-mono",children:c.price.status!=="active"?c.price.status==="ended"?"Ended":"Excluded":c.price.monthlyCents==null?"Price unknown":`${Es(c.price.monthlyCents,c.price.currency)}/month`}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[c.price.source==="catalog"?"Estimated · before tax":c.price.source==="user"?"User supplied":"",c.price.cadence==="year"?" · annual payment ÷ 12":""]})]})]}),(0,e.jsx)(is,{usage:c.usage}),Number(c.usage.costCents)>0&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j(Number(c.usage.costCents))," recorded usage charges in selected period, separate from the subscription fee."]}),c.agents.length>0&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Used by ",c.agents.map(T=>T.name).join(", ")]}),!c.identityVerified&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Account identity is unconfirmed. Link duplicates if these connections use the same subscription."}),c.observedAt&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Plan checked ",Ce(c.observedAt),c.refreshStatus==="unavailable"?" · latest check unavailable":""]}),c.refreshStatus==="unavailable"&&!c.observedAt&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"The provider did not make plan details available. You can enter the price yourself."}),c.canEdit&&(0,e.jsx)("div",{children:(0,e.jsx)(ee,{variant:"outline",size:"sm",onClick:i(()=>E(c),"onClick"),children:"Edit price"})})]},c.id)),!!n?.unattributedSubscription.eventCount&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Some subscription usage has no recorded account. It is included in the subscription token total."}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Monthly fees cover the whole account, including use outside Microvac. They are separate from recorded charges and agent budgets. Currencies are totaled separately."})]})]})})]})}i(en,"SubscriptionCostCard");function sn({report:t}){return(0,e.jsxs)(W,{className:"min-w-0 max-w-full gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By user"})}),(0,e.jsxs)(X,{className:"min-w-0 px-5",children:[(0,e.jsx)("div",{className:"max-w-full overflow-x-auto",children:(0,e.jsxs)("table",{"aria-label":"Costs by user",className:"w-full text-sm",children:[(0,e.jsx)("thead",{className:"text-muted-foreground",children:(0,e.jsxs)("tr",{className:"border-b border-border",children:[(0,e.jsx)("th",{scope:"col",className:"py-2 pr-4 text-left font-medium",children:"User"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Runs"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Input"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Output"}),(0,e.jsx)("th",{scope:"col",className:"py-2 pl-4 text-right font-medium",children:"Cost"})]})}),(0,e.jsxs)("tbody",{children:[t.rows.length===0&&(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"py-3 text-muted-foreground",children:"No user-attributed costs yet."})}),t.rows.map(n=>(0,e.jsxs)("tr",{className:"border-b border-border last:border-0",children:[(0,e.jsx)("th",{scope:"row",className:"py-3 pr-4 text-left font-normal",children:n.userId?(0,e.jsx)(Pt,{name:n.userName??"Unknown user",avatarUrl:n.userImage}):"Unattributed"}),(0,e.jsx)("td",{className:"px-4 py-3 text-right tabular-nums",children:n.runCount.toLocaleString()}),(0,e.jsxs)("td",{className:"px-4 py-3 text-right tabular-nums",children:[I(n.inputTokens+n.cachedInputTokens),n.cachedInputTokens>0&&(0,e.jsxs)("div",{className:"whitespace-nowrap text-xs text-muted-foreground",children:[I(n.cachedInputTokens)," cached"]})]}),(0,e.jsx)("td",{className:"px-4 py-3 text-right tabular-nums",children:I(n.outputTokens)}),(0,e.jsxs)("td",{className:"py-3 pl-4 text-right tabular-nums",children:[(0,e.jsx)(we,{costCents:n.costCents,eventCount:n.eventCount,estimatedEventCount:n.estimatedEventCount,unpricedEventCount:n.unpricedEventCount}),n.unpricedEventCount>0&&(0,e.jsxs)("div",{className:"whitespace-nowrap text-xs text-muted-foreground",children:[n.unpricedEventCount," unpriced ",n.unpricedEventCount===1?"charge":"charges"]})]})]},n.userId??"unattributed"))]})]})}),t.rows.some(n=>n.userId===null)&&(0,e.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"Unattributed costs have no recorded user in this organization."})]})]})}i(sn,"CostByUserTable");var tn={unknown_billing:{label:"Billing category unknown",description:"This run did not identify API or subscription billing. Any recorded charges are included in the inference ledger. For future runs, select an AI connection in the agent’s configuration so Microvac can identify its billing."},missing_model:{label:"Model not reported",description:"Token usage was recorded without a model, so Microvac cannot estimate its cost. Select an explicit model in the agent’s configuration for future runs. Changing settings will not reprice this past run."},missing_price:{label:"Cost unavailable",description:"The provider did not supply a reliable price for this usage. There is no action required for this past entry. New API runs with complete usage and a supported model are estimated automatically."},waiting_for_receipt:{label:"Receiving usage",description:"This run has stopped. Microvac is waiting for its final usage data and will record it automatically. You do not need to rerun the agent."},receipt_unavailable:{label:"Final usage unavailable",description:"This run stopped without final usage data. Its cost remains unresolved for budget checks. Microvac will record a late receipt if one arrives; rerunning the agent will not recover this usage."},retryable:{label:"Ready to record",description:"Saved usage data is ready to be recorded. Microvac retries automatically, or you can retry now. This records costs only; it does not rerun the agent."}};function nn({companyId:t,from:n,to:a,reportKey:r,unpricedCount:l,pendingCount:g,unknownBillingCount:u}){const[E,U]=(0,p.useState)(!1),B=l+g,v=B>0||u>0,c=(0,p.useId)(),T=qs(),{pushToast:R}=wt(),L=[...r,"data-quality"],{data:$,error:G,isPending:K,refetch:z}=q({queryKey:L,queryFn:i(()=>_.dataQuality(t,n,a),"queryFn"),enabled:E&&v,refetchInterval:E&&v?3e4:!1}),w=Ae({mutationFn:i(h=>_.retryAccounting(t,h),"mutationFn"),onSuccess:i(h=>{R({title:h.accounted?"Costs recorded.":"No new cost data is available.",body:"The agent was not rerun.",tone:h.accounted?"success":"info"}),T.invalidateQueries({queryKey:["costs",t]}),T.invalidateQueries({queryKey:L}),T.invalidateQueries({queryKey:["cost-subscriptions",t]})},"onSuccess")}),k=B>0?`${B} run ${B===1?"cost":"costs"} unavailable`:`${u} billing ${u===1?"type":"types"} unknown`,C=new Map;for(const[h,D]of[["event",$?.events??[]],["run",$?.runs??[]]])for(const y of D){let A=C.get(y.agentId);A||(A={agent:{id:y.agentId??void 0,name:y.agentName??(y.agentId?"Unknown agent":"Microvac services"),appearance:y.agentAppearance},items:[]},C.set(y.agentId,A)),A.items.push({item:y,source:h})}const ve=[...C.values()].sort((h,D)=>h.agent.name.localeCompare(D.agent.name,"en",{sensitivity:"base",numeric:!0})||(h.agent.id??"").localeCompare(D.agent.id??""));for(const h of ve)h.items.sort((D,y)=>Date.parse(y.item.occurredAt)-Date.parse(D.item.occurredAt)||`${D.source}:${D.item.id}`.localeCompare(`${y.source}:${y.item.id}`));function ke(h,D){const y=tn[h.reason];return(0,e.jsxs)("li",{className:"space-y-2 border-b border-border py-3 last:border-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(We,{variant:"outline",className:"font-normal text-muted-foreground",children:y.label}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,e.jsx)("time",{dateTime:h.occurredAt,children:Ce(h.occurredAt)}),h.runId&&h.agentId&&(0,e.jsx)(Qe,{className:"text-primary underline underline-offset-4 hover:text-primary/80",to:`/agents/${h.agentId}/runs/${h.runId}`,children:"View run"}),h.reason==="retryable"&&h.runId&&$?.canRetry&&(0,e.jsx)(ee,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs font-normal underline hover:text-primary/80",disabled:w.isPending,onClick:i(()=>{w.reset(),w.mutate(h.runId)},"onClick"),children:"Retry cost recording"})]})]}),(0,e.jsx)("p",{children:y.description}),w.variables===h.runId&&w.isPending&&(0,e.jsx)("p",{role:"status",children:"Recording saved costs…"}),w.variables===h.runId&&w.error&&(0,e.jsx)("p",{role:"status",children:"Cost recording failed. Try again shortly."})]},`${D}:${h.id}`)}return i(ke,"itemRow"),(0,e.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,e.jsxs)(ee,{type:"button",variant:"ghost",size:"sm",className:"h-auto justify-start gap-1 px-0 py-1 font-normal has-[>svg]:px-0","aria-expanded":E,"aria-controls":c,onClick:i(()=>U(h=>!h),"onClick"),children:[E?(0,e.jsx)(Os,{className:"size-3","aria-hidden":"true"}):(0,e.jsx)(Qs,{className:"size-3","aria-hidden":"true"}),k]}),E&&(0,e.jsxs)("div",{id:c,className:"space-y-2",children:[v&&K&&(0,e.jsx)("p",{role:"status",children:"Loading affected runs…"}),v&&G&&!$&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{role:"status",children:"Cost details could not be loaded."}),(0,e.jsx)(ee,{variant:"outline",size:"sm",onClick:i(()=>z(),"onClick"),children:"Retry loading"})]}),v&&$&&(0,e.jsxs)(e.Fragment,{children:[G&&(0,e.jsx)("p",{role:"status",children:"Showing the last loaded cost details. Updates will resume automatically."}),$.events.length===0&&$.runs.length===0&&(0,e.jsx)("p",{role:"status",children:"No cost gaps remain in this period."}),(0,e.jsx)("ul",{"aria-label":"Cost details by agent",className:"space-y-4",children:ve.map(h=>(0,e.jsxs)("li",{children:[(0,e.jsxs)("h3",{className:"flex items-center gap-2 font-medium text-foreground",children:[(0,e.jsx)($t,{agent:h.agent,size:20}),h.agent.id?(0,e.jsx)(Qe,{className:"text-primary underline underline-offset-4 hover:text-primary/80",to:`/agents/${h.agent.id}/configuration`,children:h.agent.name}):h.agent.name]}),(0,e.jsx)("ul",{"aria-label":`${h.agent.name} cost details`,children:h.items.map(({item:D,source:y})=>ke(D,y))})]},h.agent.id??"services"))}),($.hasMoreEvents||$.hasMoreRuns)&&(0,e.jsx)("p",{className:"text-xs",children:"Showing the 25 most recent entries in each category. Select a shorter date range to inspect more."})]})]})]})}i(nn,"CostDataQualityNotice");function $s({row:t,weekSpendCents:n,budgetMonthlyCents:a,showBudgetUtilization:r=!0,totalCompanySpendCents:l,providerRows:g}){const u=(0,p.useMemo)(()=>{const v=new Map;for(const c of g){const T=v.get(c.provider)??{provider:c.provider,costCents:0,inputTokens:0,outputTokens:0};T.costCents+=c.costCents,T.inputTokens+=c.inputTokens+c.cachedInputTokens,T.outputTokens+=c.outputTokens,v.set(c.provider,T)}return Array.from(v.values()).sort((c,T)=>T.costCents-c.costCents)},[g]),E=(0,p.useMemo)(()=>{const v=new Map;for(const c of g)v.set(c.billingType,(v.get(c.billingType)??0)+c.costCents);return Array.from(v.entries()).sort((c,T)=>T[1]-c[1])},[g]),U=a,B=U>0?Math.min(100,t.costCents/U*100):0;return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-0 gap-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(ie,{className:"text-sm font-semibold",children:se(t.biller)}),(0,e.jsxs)(be,{className:"text-xs mt-0.5",children:[(0,e.jsx)("span",{className:"font-mono",children:I(t.inputTokens+t.cachedInputTokens)})," in"," · ",(0,e.jsx)("span",{className:"font-mono",children:I(t.outputTokens)})," out"," · ",t.providerCount," provider",t.providerCount===1?"":"s"," · ",t.modelCount," model",t.modelCount===1?"":"s"]})]}),(0,e.jsx)("div",{className:"text-xl shrink-0",children:(0,e.jsx)(we,{costCents:t.costCents,eventCount:t.eventCount,estimatedEventCount:t.estimatedEventCount,unpricedEventCount:t.unpricedEventCount,showUnavailableCount:!0})})]})}),(0,e.jsxs)(X,{className:"px-4 pb-4 pt-3 space-y-4",children:[r&&a>0&&(0,e.jsx)(Ge,{label:"Period spend",percentUsed:B,leftLabel:j(t.costCents),rightLabel:`${Math.round(B)}% of company budget`}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[t.apiRunCount>0?`${t.apiRunCount} metered run${t.apiRunCount===1?"":"s"}`:"0 metered runs"," · ",t.subscriptionRunCount>0?`${t.subscriptionRunCount} subscription run${t.subscriptionRunCount===1?"":"s"}`:"0 subscription runs"," · ",j(n)," this week"]}),E.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Billing types"}),(0,e.jsx)("div",{className:"space-y-1.5",children:E.map(([v,c])=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:cs(v)}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:j(c)})]},v))})]})]}),u.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Upstream providers"}),(0,e.jsx)("div",{className:"space-y-1.5",children:u.map(v=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:se(v.provider)}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"font-medium",children:j(v.costCents)}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[I(v.inputTokens+v.outputTokens)," tok"]})]})]},v.provider))})]})]})]})]})}i($s,"BillerSpendCard");function an({row:t}){return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(ie,{className:"text-base",children:se(t.biller)}),(0,e.jsxs)(be,{className:"mt-1 text-xs",children:[t.eventCount," event",t.eventCount===1?"":"s"," across ",t.kindCount," kind",t.kindCount===1?"":"s"]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)("div",{className:"text-lg font-semibold tabular-nums",children:j(t.netCents,t.currency)}),(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"net"})]})]})}),(0,e.jsx)(X,{className:"space-y-3 px-4 pb-4 pt-3",children:(0,e.jsxs)("div",{className:"grid gap-2 text-sm sm:grid-cols-3",children:[(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"debits"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.debitCents,t.currency)})]}),(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"credits"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.creditCents,t.currency)})]}),(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"estimated"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.estimatedDebitCents,t.currency)})]})]})})]})}i(an,"FinanceBillerCard");function rn({rows:t}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-4 pt-4 pb-1",children:[(0,e.jsx)(ie,{className:"text-base",children:"Financial event mix"}),(0,e.jsx)(be,{children:"Account-level charges grouped by event kind."})]}),(0,e.jsx)(X,{className:"space-y-2 px-4 pb-4 pt-3",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events in this period."}):t.map(n=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium",children:zs(n.eventKind)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[n.eventCount," event",n.eventCount===1?"":"s"," · ",n.billerCount," biller",n.billerCount===1?"":"s"]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:j(n.netCents,n.currency)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j(n.debitCents,n.currency)," debits"]})]})]},`${n.eventKind}:${n.currency}`))})]})}i(rn,"FinanceKindCard");function on({rows:t,emptyMessage:n="No financial events recorded in this period. Events appear when reported through the API, CLI, or a supported integration."}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-4 pt-4 pb-1",children:[(0,e.jsx)(ie,{className:"text-base",children:"Recent financial events"}),(0,e.jsx)(be,{children:"Provider charges, subscriptions, fees, and credits. Reported separately from run-cost estimates."})]}),(0,e.jsx)(X,{className:"space-y-3 px-4 pb-4 pt-3",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:n}):t.map(a=>(0,e.jsx)("div",{className:"border border-border p-3",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(We,{variant:"secondary",children:a.metadataJson?.source==="provider_cost_report"?"Provider cost report":zs(a.eventKind)}),(0,e.jsx)(We,{variant:a.direction==="credit"?"outline":"secondary",children:Ct(a.direction)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:Ce(a.occurredAt)})]}),(0,e.jsxs)("div",{className:"text-sm font-medium",children:[se(a.biller),a.provider?` -> ${se(a.provider)}`:"",a.model?(0,e.jsx)("span",{className:"ml-1 font-mono text-xs text-muted-foreground",children:a.model}):null]}),(a.description||a.externalInvoiceId||a.region||a.pricingTier)&&(0,e.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground",children:[a.description?(0,e.jsx)("div",{children:a.description}):null,a.externalInvoiceId?(0,e.jsxs)("div",{children:["invoice ",a.externalInvoiceId]}):null,a.region?(0,e.jsxs)("div",{children:["region ",a.region]}):null,a.pricingTier?(0,e.jsxs)("div",{children:["tier ",a.pricingTier]}):null]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"text-sm font-semibold",children:j(a.amountCents,a.currency)}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:a.currency}),a.estimated?(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-amber-600",children:"estimated"}):null]})]})},a.id))})]})}i(on,"FinanceTimelineCard");var ln=new Set(["credentials_unavailable","authentication_required","refresh_token_reused","refresh_token_expired","refresh_token_invalidated"]);function cn(t,n){return n.map(a=>{if(a.ok||a.errorFamily&&ln.has(a.errorFamily))return a;const r=t?.find(l=>l.provider===a.provider&&l.accountKey===a.accountKey);return r?.windows.length?{...a,windows:r.windows,source:r.source,capturedAt:r.capturedAt}:a})}i(cn,"retainQuotaWindows");function Ye(t){return t?"Showing the last available quota. Updates will resume automatically.":"Subscription quota is currently unavailable. Check usage with your provider."}i(Ye,"quotaUnavailableMessage");function dn({accounts:t,failed:n}){return(0,e.jsx)("div",{className:"space-y-4",children:t.map(a=>(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("p",{className:$e("text-sm font-medium",Ls),children:a.accountLabel??"Subscription account"}),(n||!a.ok)&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a.errorFamily==="credentials_unavailable"?"Connect or reconnect a subscription in AI connections to view its quota.":Ye(a.windows.length>0)}),a.windows.map((r,l)=>r.usedPercent==null?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:r.label}),(0,e.jsx)("span",{className:"font-mono text-muted-foreground",children:r.valueLabel??"Usage not reported"})]}),r.resetsAt&&(0,e.jsxs)("p",{className:"text-xs font-mono text-muted-foreground",children:["Resets ",Ce(r.resetsAt)]})]},`${r.label}:${l}`):(0,e.jsx)(Ge,{className:"font-mono",label:r.label,percentUsed:r.usedPercent,leftLabel:r.valueLabel??(r.usedPercent===null?"Usage not reported":`${r.usedPercent}% used`),rightLabel:r.resetsAt?`Resets ${Ce(r.resetsAt)}`:void 0},`${r.label}:${l}`)),a.capturedAt&&(0,e.jsxs)("p",{className:"text-xs font-mono text-muted-foreground",children:["Last checked ",Ce(a.capturedAt)]})]},a.accountKey??a.provider))})}i(dn,"AccountQuotaPanels");var Ke=["currentsession","currentweekallmodels","currentweeksonnetonly","currentweeksonnet","currentweekopusonly","currentweekopus","extrausage"];function os(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(os,"normalizeLabel$1");function un(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}i(un,"detailText$1");function mn(t){return[...t].sort((n,a)=>{const r=Ke.indexOf(os(n.label)),l=Ke.indexOf(os(a.label));return(r===-1?Ke.length:r)-(l===-1?Ke.length:l)})}i(mn,"orderedWindows$1");function xn(t){return t==null?"bg-zinc-700":t>=90?"bg-(--status-task-blocked)":t>=70?"bg-(--status-task-todo)":"bg-primary/70"}i(xn,"fillClass$1");function pn({windows:t,source:n=null,error:a=null}){const r=mn(t);return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Anthropic subscription"}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:"Quota from the Claude subscription connected to this server."})]}),n?(0,e.jsx)("span",{className:"shrink-0 border border-border px-2.5 py-1 text-(length:--text-nano) font-semibold uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(n)}):null]}),a?(0,e.jsx)("div",{role:"status",className:"mt-4 text-sm text-muted-foreground",children:Ye(t.length>0)}):null,(0,e.jsx)("div",{className:"mt-4 space-y-4",children:r.map(l=>{const g=os(l.label),u=un(l);if(g==="extrausage")return(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.label}),l.valueLabel?(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.valueLabel}):null]}),u?(0,e.jsx)("div",{className:"mt-2 text-sm text-muted-foreground",children:u}):null]},l.label);const E=Math.min(100,Math.max(0,l.usedPercent??0));return(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.label}),u?(0,e.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:u}):null]}),l.usedPercent!=null?(0,e.jsxs)("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[l.usedPercent,"% used"]}):null]}),(0,e.jsx)("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:$e("h-full transition-(--tp-width) duration-200",xn(l.usedPercent)),style:{width:`${E}%`}})})]},l.label)})})]})}i(pn,"ClaudeSubscriptionPanel");var ze=["5hlimit","weeklylimit","credits"];function ls(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(ls,"normalizeLabel");function hn(t){return[...t].sort((n,a)=>{const r=ls(n.label).replace(/^gpt53codexspark/,""),l=ls(a.label).replace(/^gpt53codexspark/,""),g=ze.indexOf(r),u=ze.indexOf(l);return(g===-1?ze.length:g)-(u===-1?ze.length:u)})}i(hn,"orderedWindows");function gn(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}i(gn,"detailText");function bn(t){return t==null?"bg-zinc-700":t>=90?"bg-(--status-task-blocked)":t>=70?"bg-(--status-task-todo)":"bg-primary/70"}i(bn,"fillClass");function Ds(t){const n=ls(t);return n.includes("gpt53codexspark")||n.includes("gpt5")}i(Ds,"isModelSpecific");function vn({windows:t,source:n=null,error:a=null}){const r=hn(t),l=r.filter(u=>!Ds(u.label)),g=r.filter(u=>Ds(u.label));return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Codex subscription"}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:"Quota from the Codex subscription connected to this server."})]}),n?(0,e.jsx)("span",{className:"shrink-0 border border-border px-2.5 py-1 text-(length:--text-nano) font-semibold uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(n)}):null]}),a?(0,e.jsx)("div",{role:"status",className:"mt-4 text-sm text-muted-foreground",children:Ye(t.length>0)}):null,(0,e.jsxs)("div",{className:"mt-4 space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Account windows"}),(0,e.jsx)("div",{className:"space-y-3",children:l.map(u=>(0,e.jsx)(Fs,{window:u},u.label))})]}),g.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Model windows"}),(0,e.jsx)("div",{className:"space-y-3",children:g.map(u=>(0,e.jsx)(Fs,{window:u},u.label))})]}):null]})]})}i(vn,"CodexSubscriptionPanel");function Fs({window:t}){const n=gn(t);return t.usedPercent==null?(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:t.label}),t.valueLabel?(0,e.jsx)("div",{className:"text-sm font-semibold tabular-nums text-foreground",children:t.valueLabel}):null]}),n?(0,e.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:n}):null]}):(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:t.label}),n?(0,e.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),(0,e.jsxs)("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[t.usedPercent,"% used"]})]}),(0,e.jsx)("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:$e("h-full transition-(--tp-width) duration-200",bn(t.usedPercent)),style:{width:`${Math.max(0,Math.min(100,t.usedPercent))}%`}})})]})}i(Fs,"QuotaWindowRow");var fn=["5h","24h","7d"];function Bs({provider:t,rows:n,budgetMonthlyCents:a,showBudgetUtilization:r=!0,totalCompanySpendCents:l,weekSpendCents:g,windowRows:u,showDeficitNotch:E,quotaAccounts:U,quotaRequestFailed:B,quotaWindows:v=[],quotaError:c=null,quotaSource:T=null,quotaLoading:R=!1}){const L=(0,p.useMemo)(()=>{let d=0,b=0,Z=0,ce=0,fe=0,de=0,O=0,De=0,Te=0,Me=0;for(const Q of n)d+=Q.inputTokens+Q.cachedInputTokens,b+=Q.outputTokens,Z+=Q.costCents,De+=Q.eventCount??0,Te+=Q.estimatedEventCount??0,Me+=Q.unpricedEventCount??0,ce+=Q.apiRunCount,fe+=Q.subscriptionRunCount,de+=Q.subscriptionInputTokens+Q.subscriptionCachedInputTokens,O+=Q.subscriptionOutputTokens;const xe=d+b,le=de+O,N=xe;return{totalInputTokens:d,totalOutputTokens:b,totalTokens:xe,totalCostCents:Z,eventCount:De,estimatedEventCount:Te,unpricedEventCount:Me,totalApiRuns:ce,totalSubRuns:fe,totalSubInputTokens:de,totalSubOutputTokens:O,totalSubTokens:le,subSharePct:N>0?le/N*100:0}},[n]),{totalInputTokens:$,totalOutputTokens:G,totalTokens:K,totalCostCents:z,totalApiRuns:w,totalSubRuns:k,totalSubInputTokens:C,totalSubOutputTokens:ve,totalSubTokens:ke,subSharePct:h}=L,D=a,y=D>0?Math.min(100,z/D*100):0,A=D>0?D/4.33:0,H=A>0?Math.min(100,g/A*100):0,He=r&&a>0,Ze=(0,p.useMemo)(()=>new Map(u.map(d=>[d.window,d])),[u]),Se=(0,p.useMemo)(()=>Math.max(...u.map(d=>d.costCents),0),[u]),te=t==="anthropic",x=t==="openai"&&T?.startsWith("codex-"),V=(t==="anthropic"||t==="openai")&&(R||!!U?.length||v.length>0||c!=null);return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-0 gap-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(ie,{className:"text-sm font-semibold",children:se(t)}),(0,e.jsxs)(be,{className:"text-xs mt-0.5",children:[(0,e.jsx)("span",{className:"font-mono",children:I($)})," in"," · ",(0,e.jsx)("span",{className:"font-mono",children:I(G)})," out",(w>0||k>0)&&(0,e.jsxs)("span",{className:"ml-1.5",children:["·"," ",w>0&&`~${w} api`,w>0&&k>0&&" / ",k>0&&`~${k} sub`," runs"]})]})]}),(0,e.jsx)("div",{className:"text-xl shrink-0",children:(0,e.jsx)(we,{costCents:z,eventCount:L.eventCount,estimatedEventCount:L.estimatedEventCount,unpricedEventCount:L.unpricedEventCount,showUnavailableCount:!0})})]})}),(0,e.jsxs)(X,{className:"px-4 pb-4 pt-3 space-y-4",children:[He&&(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Ge,{label:"Period spend",percentUsed:y,leftLabel:j(z),rightLabel:`${Math.round(y)}% of company budget`,showDeficitNotch:E}),(0,e.jsx)(Ge,{label:"This week",percentUsed:H,leftLabel:j(g),rightLabel:`~${j(Math.round(A))} / wk`,showDeficitNotch:H>=100})]}),u.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Rolling windows"}),(0,e.jsx)("div",{className:"space-y-2.5",children:fn.map(d=>{const b=Ze.get(d);if(!b)return null;const Z=b.costCents,ce=b.inputTokens+b.cachedInputTokens+b.outputTokens,fe=Se>0?Z/Se*100:0;return(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"font-mono text-muted-foreground w-6 shrink-0",children:d}),(0,e.jsxs)("span",{className:"text-muted-foreground font-mono flex-1",children:[I(ce)," tok"]}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:j(Z)})]}),(0,e.jsx)("div",{className:"h-2 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${fe}%`}})})]},d)})})]})]}),k>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription"}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-mono text-foreground",children:k})," runs"," · ",ke>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(ke)})," total"," · "]}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(C)})," in"," · ",(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(ve)})," out"]}),h>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"h-1.5 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${h}%`}})}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[Math.round(h),"% of token usage via subscription"]})]})]})]}),n.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsx)("div",{className:"space-y-3",children:n.map(d=>{const b=d.inputTokens+d.cachedInputTokens+d.outputTokens,Z=K>0?b/K*100:0,ce=z>0?d.costCents/z*100:0;return(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono block",children:d.model}),(0,e.jsxs)("span",{className:"text-(length:--text-micro) text-muted-foreground truncate block",children:[se(d.biller)," · ",cs(d.billingType)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3 shrink-0 tabular-nums text-xs",children:[(0,e.jsxs)("span",{className:"text-muted-foreground",children:[I(b)," tok"]}),(0,e.jsx)("span",{className:"font-medium",children:j(d.costCents)})]})]}),(0,e.jsxs)("div",{className:"relative h-2 w-full border border-border overflow-hidden",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${Z}%`},title:`${Math.round(Z)}% of provider tokens`}),(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 bg-primary/85 transition-(--tp-width) duration-150",style:{width:`${ce}%`},title:`${Math.round(ce)}% of provider cost`})]})]},`${d.provider}:${d.model}`)})})]}),V&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription quota"}),T&&!te&&!x?(0,e.jsx)("span",{className:"text-(length:--text-nano) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(T)}):null]}),R?(0,e.jsx)(jn,{}):U?.length?(0,e.jsx)(dn,{accounts:U,failed:B}):te?(0,e.jsx)(pn,{windows:v,source:T,error:c}):x?(0,e.jsx)(vn,{windows:v,source:T,error:c}):(0,e.jsxs)(e.Fragment,{children:[c?(0,e.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:Ye(v.length>0)}):null,(0,e.jsx)("div",{className:"space-y-2.5",children:v.map(d=>{const b=d.usedPercent==null?null:d.usedPercent>=90?"bg-(--status-task-blocked)":d.usedPercent>=70?"bg-(--status-task-todo)":"bg-(--status-task-done)";return(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"font-mono text-muted-foreground shrink-0",children:d.label}),(0,e.jsx)("span",{className:"flex-1"}),d.valueLabel!=null?(0,e.jsx)("span",{className:"font-medium tabular-nums",children:d.valueLabel}):d.usedPercent!=null?(0,e.jsxs)("span",{className:"font-medium tabular-nums",children:[d.usedPercent,"% used"]}):null]}),d.usedPercent!=null&&b!=null&&(0,e.jsx)("div",{className:"h-2 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:`h-full transition-(--tp-width) duration-150 ${b}`,style:{width:`${d.usedPercent}%`}})}),d.detail?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:d.detail}):d.resetsAt?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["resets ",new Date(d.resetsAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]}):null]},d.label)})})]})]})]})]})]})}i(Bs,"ProviderQuotaCard");function jn(){return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(ye,{className:"h-3 w-36"}),(0,e.jsx)(ye,{className:"h-4 w-64 max-w-full"})]}),(0,e.jsx)(ye,{className:"h-7 w-28"})]}),(0,e.jsx)("div",{className:"mt-4 space-y-3",children:Array.from({length:3}).map((t,n)=>(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(ye,{className:"h-4 w-32"}),(0,e.jsx)(ye,{className:"h-3 w-44 max-w-full"})]}),(0,e.jsx)(ye,{className:"h-4 w-20"})]}),(0,e.jsx)(ye,{className:"mt-3 h-2 w-full"})]},n))})]})}i(jn,"QuotaPanelSkeleton");var On=pt({Costs:i(()=>kn,"Costs")}),Rs="__none__";function yn(){const t=new Date,n=t.getDay(),a=n===0?-6:1-n,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()+a,0,0,0,0),l=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6,23,59,59,999);return{from:r.toISOString(),to:l.toISOString()}}i(yn,"currentWeekRange");function Nn({provider:t,rows:n}){const a=n.reduce((l,g)=>l+g.inputTokens+g.cachedInputTokens+g.outputTokens,0),r=n.reduce((l,g)=>l+g.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:se(t)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(a)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(r)})]})}i(Nn,"ProviderTabLabel");function Cn({biller:t,rows:n}){const a=n.reduce((l,g)=>l+g.inputTokens+g.cachedInputTokens+g.outputTokens,0),r=n.reduce((l,g)=>l+g.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:se(t)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(a)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(r)})]})}i(Cn,"BillerTabLabel");function J({label:t,value:n,subtitle:a,icon:r}){return(0,e.jsx)(W,{className:"block p-4",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:t}),(0,e.jsx)("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:n}),(0,e.jsx)("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:a})]}),(0,e.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border",children:(0,e.jsx)(r,{className:"h-4 w-4 text-muted-foreground"})})]})})}i(J,"MetricTile");function _s({debitCents:t,creditCents:n,netCents:a,estimatedDebitCents:r,eventCount:l}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(ie,{className:"text-base",children:"Finance ledger"}),(0,e.jsx)(be,{children:"Account-level charges that do not map to a single inference request."})]}),(0,e.jsxs)(X,{className:"grid gap-3 px-5 pb-5 pt-2 sm:grid-cols-2 xl:grid-cols-4",children:[(0,e.jsx)(J,{label:"Debits",value:j(t),subtitle:`${l} total event${l===1?"":"s"} in range`,icon:as}),(0,e.jsx)(J,{label:"Credits",value:j(n),subtitle:"Refunds, offsets, and credit returns",icon:yt}),(0,e.jsx)(J,{label:"Net",value:j(a),subtitle:"Debit minus credit for the selected period",icon:rs}),(0,e.jsx)(J,{label:"Estimated",value:j(r),subtitle:"Estimated debits that are not yet invoice-authoritative",icon:ns})]})]})}i(_s,"FinanceSummaryCard");function kn({embedded:t=!1,initialTab:n="overview",lockTab:a=!1,hideBudgetsTab:r=!1}={}){const{selectedCompanyId:l}=It(),{setBreadcrumbs:g}=Et(),u=qs(),[E,U]=_t(),B=E.get("agentId"),{data:v,error:c}=q({queryKey:[...F.agents.detail(B??Rs),l],queryFn:i(()=>Lt.get(B,l),"queryFn"),enabled:!!(l&&B)}),T=v?.adapterType==="paperclip_runner"&&v.adapterConfig.provider==="muse",[R,L]=(0,p.useState)(n),[$,G]=(0,p.useState)("all"),[K,z]=(0,p.useState)("all"),w=!(t&&a&&n==="budgets"),{preset:k,setPreset:C,customFrom:ve,setCustomFrom:ke,customTo:h,setCustomTo:D,from:y,to:A,customReady:H}=Wt();(0,p.useEffect)(()=>{t||g([{label:"Costs"}])},[t,g]),(0,p.useEffect)(()=>{const s=E.get("tab");L(!a&&s&&["overview","providers","billers","finance","budgets","decisions","fast-responses"].includes(s)?s:n)},[n,a,E]);const[He,Ze]=(0,p.useState)(()=>new Date().toDateString()),Se=(0,p.useRef)(null);(0,p.useEffect)(()=>{const s=i(()=>{const o=new Date,m=new Date(o.getFullYear(),o.getMonth(),o.getDate()+1).getTime()-o.getTime();Se.current=setTimeout(()=>{Ze(new Date().toDateString()),s()},m)},"schedule");return s(),()=>{Se.current!=null&&clearTimeout(Se.current)}},[]);const te=(0,p.useMemo)(()=>yn(),[He]),x=l??Rs,V=["custom","mtd","ytd"].includes(k)&&y||void 0,d=k==="custom"?A||void 0:k,{data:b,error:Z}=q({queryKey:["cost-subscriptions",x,V,d],queryFn:i(()=>Ve.report(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),ce=i(()=>{u.invalidateQueries({queryKey:["cost-subscriptions",x]})},"invalidateSubscriptions"),fe=(0,p.useRef)(null),de=Ae({mutationFn:i(s=>Ve.refresh(s),"mutationFn"),onSuccess:i((s,o)=>{u.invalidateQueries({queryKey:["cost-subscriptions",o]})},"onSuccess")});(0,p.useEffect)(()=>{!l||!w||!b?.canRefresh||fe.current===l||(fe.current=l,de.mutate(l))},[l,w,b?.canRefresh,de.mutate]);const{data:O,isLoading:De,error:Te}=q({queryKey:F.budgets.overview(x),queryFn:i(()=>ts.overview(x),"queryFn"),enabled:!!l&&H,refetchInterval:3e4,staleTime:5e3}),Me=i(()=>{l&&(u.invalidateQueries({queryKey:F.budgets.overview(l)}),u.invalidateQueries({queryKey:F.dashboard(l)}),u.invalidateQueries({queryKey:F.agents.list(l)}),u.invalidateQueries({queryKey:F.projects.all(l)}))},"invalidateBudgetViews"),xe=Ae({mutationFn:i(({summary:s,changes:o})=>ts.upsertPolicy(x,{scopeType:s.scopeType,scopeId:s.scopeId,metric:s.metric,windowKind:s.windowKind,...o}),"mutationFn"),onSuccess:Me}),le=Ae({mutationFn:i(s=>ts.resolveIncident(x,s.incidentId,s),"mutationFn"),onSuccess:Me}),{data:N,isLoading:Q,error:us}=q({queryKey:F.costs(x,V,d),queryFn:i(async()=>{const[s,o,m,f]=await Promise.all([_.summary(x,y||void 0,A||void 0),_.byAgent(x,y||void 0,A||void 0),_.byProject(x,y||void 0,A||void 0),_.byAgentModel(x,y||void 0,A||void 0)]);return{summary:s,byAgent:o,byProject:m,byAgentModel:f}},"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),{data:Je,error:Ys}=q({queryKey:[...F.costs(x,V,d),"by-user"],queryFn:i(()=>_.byUser(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&w&&R==="overview",refetchInterval:3e4}),{data:S,isLoading:ms,error:xs}=q({queryKey:[F.financeSummary(x,V,d),F.financeByBiller(x,V,d),F.financeByKind(x,V,d),F.financeEvents(x,V,d,18)],queryFn:i(async()=>{const[s,o,m,f]=await Promise.all([_.financeSummary(x,y||void 0,A||void 0),_.financeByBiller(x,y||void 0,A||void 0),_.financeByKind(x,y||void 0,A||void 0),_.financeEvents(x,y||void 0,A||void 0,18)]);return{summary:s,byBiller:o,byKind:m,events:f}},"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),[Hs,ps]=(0,p.useState)(new Set);(0,p.useEffect)(()=>{ps(new Set)},[x,k,ve,h]);function Zs(s){ps(o=>{const m=new Set(o);return m.has(s)?m.delete(s):m.add(s),m})}i(Zs,"toggleAgent");const Js=(0,p.useMemo)(()=>{const s=new Map;for(const o of N?.byAgentModel??[]){const m=s.get(o.agentId)??[];m.push(o),s.set(o.agentId,m)}for(const[o,m]of s)s.set(o,m.slice().sort((f,P)=>P.costCents-f.costCents));return s},[N?.byAgentModel]),{data:Fe,error:Xs}=q({queryKey:F.usageByProvider(x,V,d),queryFn:i(()=>_.byProvider(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&(R==="providers"||R==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:hs,error:et}=q({queryKey:F.usageByBiller(x,V,d),queryFn:i(()=>_.byBiller(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&R==="billers",refetchInterval:3e4,staleTime:1e4}),{data:gs,error:st}=q({queryKey:F.usageByProvider(x,te.from,te.to),queryFn:i(()=>_.byProvider(x,te.from,te.to),"queryFn"),enabled:!!l&&(R==="providers"||R==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:bs,error:tt}=q({queryKey:F.usageByBiller(x,te.from,te.to),queryFn:i(()=>_.byBiller(x,te.from,te.to),"queryFn"),enabled:!!l&&R==="billers",refetchInterval:3e4,staleTime:1e4}),{data:vs,error:nt}=q({queryKey:F.usageWindowSpend(x),queryFn:i(()=>_.windowSpend(x),"queryFn"),enabled:!!l&&R==="providers",refetchInterval:3e4,staleTime:1e4}),{data:pe,isLoading:fs,error:Be}=q({queryKey:F.usageQuotaWindows(x),queryFn:i(()=>_.quotaWindows(x),"queryFn"),structuralSharing:i((s,o)=>cn(s,o),"structuralSharing"),enabled:!!l&&R==="providers",refetchInterval:3e5,staleTime:6e4}),ne=(0,p.useMemo)(()=>{const s=new Map;for(const o of Fe??[]){const m=s.get(o.provider)??[];m.push(o),s.set(o.provider,m)}return s},[Fe]),ue=(0,p.useMemo)(()=>{const s=new Map;for(const o of hs??[]){const m=s.get(o.biller)??[];m.push(o),s.set(o.biller,m)}return s},[hs]),js=(0,p.useMemo)(()=>{const s=new Map;for(const o of gs??[])s.set(o.provider,(s.get(o.provider)??0)+o.costCents);return s},[gs]),ys=(0,p.useMemo)(()=>{const s=new Map;for(const o of bs??[])s.set(o.biller,(s.get(o.biller)??0)+o.costCents);return s},[bs]),Ns=(0,p.useMemo)(()=>{const s=new Map;for(const o of vs??[]){const m=s.get(o.provider)??[];m.push(o),s.set(o.provider,m)}return s},[vs]),Cs=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])o.windows.length>0&&s.set(o.provider,o.windows);return s},[pe]),ks=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])o.ok||s.set(o.provider,"unavailable");return Be&&(s.set("anthropic","unavailable"),s.set("openai","unavailable")),s},[pe,Be]),Ss=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])typeof o.source=="string"&&o.source.length>0&&s.set(o.provider,o.source);return s},[pe]),Ts=(0,p.useMemo)(()=>{const s=new Map;if(k!=="mtd")return s;const o=N?.summary.budgetCents??0;if(o<=0)return s;const m=new Date,f=m.getUTCDate(),P=new Date(Date.UTC(m.getUTCFullYear(),m.getUTCMonth()+1,0)).getUTCDate();for(const[ae,Y]of ne){const Is=Y.reduce((ut,mt)=>ut+mt.costCents,0),dt=Is/Math.max(f,1);s.set(ae,Is+dt*(P-f)>o)}return s},[k,N,ne]),Re=(0,p.useMemo)(()=>Array.from(ne.keys()),[ne]),_e=(0,p.useMemo)(()=>Array.from(ue.keys()),[ue]),Ue=$==="all"||Re.includes($)?$:"all";(0,p.useEffect)(()=>{Ue!==$&&G("all")},[Ue,$]);const Le=K==="all"||_e.includes(K)?K:"all";(0,p.useEffect)(()=>{Le!==K&&z("all")},[Le,K]);const at=(0,p.useMemo)(()=>{const s=Array.from(ne.keys()),o=s.reduce((f,P)=>f+(ne.get(P)?.reduce((ae,Y)=>ae+Y.inputTokens+Y.cachedInputTokens+Y.outputTokens,0)??0),0),m=s.reduce((f,P)=>f+(ne.get(P)?.reduce((ae,Y)=>ae+Y.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All providers"}),s.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(o)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(m)})]}):null]})},...s.map(f=>({value:f,label:(0,e.jsx)(Nn,{provider:f,rows:ne.get(f)??[]})}))]},[ne]),rt=(0,p.useMemo)(()=>{const s=Array.from(ue.keys()),o=s.reduce((f,P)=>f+(ue.get(P)?.reduce((ae,Y)=>ae+Y.inputTokens+Y.cachedInputTokens+Y.outputTokens,0)??0),0),m=s.reduce((f,P)=>f+(ue.get(P)?.reduce((ae,Y)=>ae+Y.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All billers"}),s.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(o)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(m)})]}):null]})},...s.map(f=>({value:f,label:(0,e.jsx)(Cn,{biller:f,rows:ue.get(f)??[]})}))]},[ue]),it=S?.events??[],Ee=O?.policies??[],he=O?.activeIncidents??[],ot=(0,p.useMemo)(()=>({company:Ee.filter(s=>s.scopeType==="company"),agent:Ee.filter(s=>s.scopeType==="agent"),project:Ee.filter(s=>s.scopeType==="project")}),[Ee]);if(!l)return(0,e.jsx)(Ut,{icon:Xe,message:"Select an organization to view costs."});const Ie=k==="custom"&&!H,lt=Q&&H,ct=!N&&us;return(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-6",children:[c&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load agent details. Totals below show recorded organization costs."}),T&&(0,e.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:[v.name,"'s Muse activity has no reported usage or cost. Totals below show recorded organization charges only. Microvac cannot enforce a Muse spend ceiling."]}),w?(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,e.jsx)("div",{children:t?(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Costs"}):(0,e.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Costs"})}),(0,e.jsx)("div",{"data-canonical-toolbar":"cost-range",role:"toolbar","aria-label":"Cost date range",className:"flex flex-wrap items-center gap-2",children:Gt.map(s=>(0,e.jsx)(ee,{variant:k===s?"secondary":"ghost",size:"sm",onClick:i(()=>C(s),"onClick"),"aria-pressed":k===s,children:Qt[s]},s))})]}),k==="custom"?(0,e.jsxs)("div",{"data-canonical-toolbar":"cost-dates",className:"flex flex-wrap items-center gap-2 border border-border p-3",children:[(0,e.jsx)("input",{type:"date",value:ve,onChange:i(s=>ke(s.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"to"}),(0,e.jsx)("input",{type:"date",value:h,onChange:i(s=>D(s.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"})]}):null,S?.summary.currencies?.some(s=>s.currency!=="USD")&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Finance headline totals are USD only. Other currencies are listed separately; no exchange-rate conversion is applied."}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-5",children:[(0,e.jsx)(J,{label:"API spend",value:b?b.api.unpricedEventCount===b.api.eventCount&&b.api.eventCount>0?"—":j(Number(b.api.costCents)):"—",subtitle:b?(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(Ot,{eventCount:b.api.eventCount,estimatedEventCount:b.api.estimatedEventCount}),(0,e.jsx)("div",{children:(0,e.jsx)(is,{usage:b.api})})]}):Z?"API usage is unavailable":"API usage is loading",icon:Xe}),(0,e.jsx)(en,{companyId:x,report:b,error:Z,onChanged:ce},x),(0,e.jsx)(J,{label:"Budget",value:he.length>0?String(he.length):N?.summary.budgetCents&&N.summary.budgetCents>0?k==="mtd"?`${N.summary.utilizationPercent}%`:j(N.summary.budgetCents):"Open",subtitle:he.length>0?`${O?.pausedAgentCount??0} agents paused · ${O?.pausedProjectCount??0} projects paused`:N?.summary.budgetCents&&N.summary.budgetCents>0?k==="mtd"?`${j(N.summary.spendCents)} of ${j(N.summary.budgetCents)} this month`:"Monthly limit":"No monthly cap configured",icon:ns}),(0,e.jsx)(J,{label:"Recorded charges",value:S?j(S.summary.netCents):"—",subtitle:S?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"block whitespace-nowrap",children:[j(S.summary.debitCents)," debits"]}),(0,e.jsxs)("span",{className:"block whitespace-nowrap",children:[j(S.summary.creditCents)," credits"]})]}):"Financial data unavailable",icon:rs}),(0,e.jsx)(J,{label:"Finance events",value:S?String(S.summary.eventCount):"—",subtitle:S?`${j(S.summary.estimatedDebitCents)} estimated in range`:"Financial data unavailable",icon:as})]}),b&&Number(b.subscription.costCents)>0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Subscription accounts also have ",j(Number(b.subscription.costCents))," in recorded usage charges for this period, separate from monthly fees."]}),b&&b.unknown.eventCount>0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Other billing usage: ",I(b.unknown.inputTokens+b.unknown.cachedInputTokens+b.unknown.outputTokens)," tokens",Number(b.unknown.costCents)>0?` · ${j(Number(b.unknown.costCents))} in recorded charges`:"",", included in the inference ledger."]}),Z&&b&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Showing the last loaded API and subscription usage. Updates will resume automatically."}),de.error&&(0,e.jsxs)("div",{role:"status",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,e.jsx)("p",{children:"Connected accounts could not be checked. Existing subscription estimates are still shown."}),b?.canRefresh&&(0,e.jsx)(ee,{variant:"outline",size:"sm",disabled:de.isPending,onClick:i(()=>de.mutate(x),"onClick"),children:"Retry account check"})]}),R==="overview"&&N&&(N.summary.unpricedEventCount>0||N.summary.pendingRunCount>0||(N.summary.unknownBillingEventCount??0)>0)&&(0,e.jsx)(nn,{companyId:x,from:y||void 0,to:A||void 0,reportKey:F.costs(x,V,d),unpricedCount:N.summary.unpricedEventCount,pendingCount:N.summary.pendingRunCount,unknownBillingCount:N.summary.unknownBillingEventCount??0},`${x}:${V}:${d}`)]}):null,Te&&!O?(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Budget data could not be loaded. Please try again shortly."}):null,N&&us||S&&xs||O&&Te||Xs||et||st||tt||nt?(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Showing the last loaded data. Updates will resume automatically."}):null,le.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not update the budget. Check any pending runs or unpriced usage shown on this page, then try again."}),(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:R,onValueChange:i(s=>{L(s),U(o=>{const m=new URLSearchParams(o);return m.set("tab",s),m},{replace:!0})},"onValueChange"),children:[a?null:(0,e.jsx)("div",{className:"max-w-full overflow-x-auto pb-2",children:(0,e.jsxs)(Dt,{variant:"line",className:"justify-start",children:[(0,e.jsx)(je,{value:"overview",children:"Overview"}),r?null:(0,e.jsx)(je,{value:"budgets",children:"Budgets"}),(0,e.jsx)(je,{value:"providers",children:"Providers"}),(0,e.jsx)(je,{value:"billers",children:"Billers"}),(0,e.jsx)(je,{value:"finance",children:"Finance"}),(0,e.jsx)(je,{value:"decisions",children:"Decisions"}),(0,e.jsx)(je,{value:"fast-responses",children:"Fast responses"})]})}),(0,e.jsx)(re,{value:"fast-responses",className:"mt-4 min-w-0 max-w-full",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(Jt,{companyId:x,from:y,to:A})}),(0,e.jsx)(re,{value:"decisions",className:"mt-4 min-w-0 max-w-full",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(Zt,{companyId:x,from:y,to:A})}),(0,e.jsx)(re,{value:"overview",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):lt?(0,e.jsx)(ss,{variant:"costs"}):ct?(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Cost data could not be loaded. Please try again shortly."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"grid min-w-0 gap-4 xl:grid-cols-(--gtc-32)",children:[(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-4",children:[(0,e.jsxs)(W,{className:"gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By agent"})}),(0,e.jsx)(X,{className:"space-y-2 px-5",children:(N?.byAgent.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events yet."}):N?.byAgent.map(s=>{const o=Js.get(s.agentId)??[],m=Hs.has(s.agentId),f=o.length>0;return(0,e.jsxs)("div",{role:"group","aria-label":`${s.agentName??s.agentId??"Microvac services"} costs`,className:"border border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:$e("flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",f?"cursor-pointer select-none":""),onClick:i(()=>f&&Zs(s.agentId),"onClick"),children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[f?m?(0,e.jsx)(Os,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)(Qs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)("span",{className:"h-3 w-3 shrink-0"}),s.agentId?(0,e.jsx)(Tt,{agent:{id:s.agentId,name:s.agentName??s.agentId,appearance:s.agentAppearance},size:"sm"}):(0,e.jsx)("span",{className:"font-medium",children:"Microvac services"}),s.agentStatus==="terminated"?(0,e.jsx)(jt,{status:"terminated"}):null]}),(0,e.jsxs)("div",{className:"text-right text-sm tabular-nums",children:[(0,e.jsx)(we,{costCents:s.costCents,eventCount:s.eventCount,estimatedEventCount:s.estimatedEventCount}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["in ",I(s.inputTokens+s.cachedInputTokens)," (",I(s.cachedInputTokens)," cached) · out ",I(s.outputTokens)]}),s.apiRunCount>0||s.subscriptionRunCount>0?(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["runs: ",s.apiRunCount>0?`${s.apiRunCount} api`:"0 api"," · ",s.subscriptionRunCount>0?`${s.subscriptionRunCount} sub`:"0 sub"]}):null]})]}),m&&o.length>0?(0,e.jsx)("div",{className:"mt-3 space-y-2 border-l border-border pl-4",children:o.map(P=>{const ae=s.costCents>0?Math.round(P.costCents/s.costCents*100):0;return(0,e.jsxs)("div",{className:"flex flex-col gap-2 text-xs sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate font-medium text-foreground",children:[se(P.provider),(0,e.jsx)("span",{className:"mx-1 text-border",children:"/"}),(0,e.jsx)("span",{className:"font-mono",children:P.model})]}),(0,e.jsxs)("div",{className:"truncate text-muted-foreground",children:[se(P.biller)," · ",cs(P.billingType)]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)(we,{costCents:P.costCents,eventCount:P.eventCount,estimatedEventCount:P.estimatedEventCount,suffix:(0,e.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",ae,"%)"]})}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[I(P.inputTokens+P.cachedInputTokens+P.outputTokens)," tok"]})]})]},`${P.provider}:${P.model}:${P.billingType}`)})}):null]},s.agentId??"services")})})]}),Ys&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:Je?"User costs could not be refreshed. Showing the last loaded data.":"User costs could not be loaded. Please try again shortly."}),Je&&(0,e.jsx)(sn,{report:Je})]}),(0,e.jsx)("div",{className:"min-w-0 max-w-full space-y-4",children:(0,e.jsxs)(W,{className:"gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By project"})}),(0,e.jsx)(X,{className:"space-y-2 px-5",children:(N?.byProject.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No project-attributed run costs yet."}):N?.byProject.map((s,o)=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2 text-sm",children:[(0,e.jsx)("span",{className:"truncate",children:s.projectName??s.projectId??"Unattributed"}),(0,e.jsx)(we,{costCents:s.costCents,eventCount:s.eventCount,estimatedEventCount:s.estimatedEventCount})]},s.projectId??`unattributed-${o}`))})]})})]}),he.length>0?(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:he.slice(0,2).map(s=>(0,e.jsx)(Ms,{incident:s,isMutating:le.isPending,onKeepPaused:i(()=>le.mutate({incidentId:s.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:i(o=>le.mutate({incidentId:s.id,action:"raise_budget_and_resume",amount:o}),"onRaiseAndResume")},s.id))}):null,S?(0,e.jsx)(_s,{debitCents:S.summary.debitCents,creditCents:S.summary.creditCents,netCents:S.summary.netCents,estimatedDebitCents:S.summary.estimatedDebitCents,eventCount:S.summary.eventCount}):(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:ms?"Loading financial events…":"Financial events could not be loaded. Please try again shortly."})]})}),(0,e.jsxs)(re,{value:"budgets",className:"mt-4 min-w-0 max-w-full space-y-4",children:[xe.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not update the budget policy. Review your settings and try again."}),De?(0,e.jsx)(ss,{variant:"costs"}):Te&&!O?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(W,{className:"border-border/70 bg-(image:--gradient-extract-2)",children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-3",children:[(0,e.jsx)(ie,{className:"text-base",children:"Budget control plane"}),(0,e.jsx)(be,{children:"Hard-stop spend limits for agents and projects. Provider subscription quota stays separate and appears under Providers."})]}),(0,e.jsxs)(X,{className:"grid gap-3 px-5 pb-5 pt-0 md:grid-cols-4",children:[(0,e.jsx)(J,{label:"Active incidents",value:String(he.length),subtitle:"Open soft or hard threshold crossings",icon:rs}),(0,e.jsx)(J,{label:"Pending approvals",value:String(O?.pendingApprovalCount??0),subtitle:"Budget override approvals awaiting board action",icon:as}),(0,e.jsx)(J,{label:"Paused agents",value:String(O?.pausedAgentCount??0),subtitle:"Agent heartbeats blocked by budget",icon:ns}),(0,e.jsx)(J,{label:"Paused projects",value:String(O?.pausedProjectCount??0),subtitle:"Project execution blocked by budget",icon:Xe})]})]}),he.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Active incidents"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Raise the budget or keep a hard stop paused. Dismiss a warning when no action is needed."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:he.map(s=>(0,e.jsx)(Ms,{incident:s,isMutating:le.isPending,onKeepPaused:i(()=>le.mutate({incidentId:s.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:i(o=>le.mutate({incidentId:s.id,action:"raise_budget_and_resume",amount:o}),"onRaiseAndResume")},s.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-5",children:[["company","agent","project"].map(s=>{const o=ot[s];return o.length===0?null:(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h2",{className:"text-lg font-semibold capitalize",children:[s==="company"?"organization":s," budgets"]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:s==="company"?"Organization-wide monthly policy.":s==="agent"?"Recurring monthly spend policies for individual agents.":"Lifetime spend policies for execution-bound projects."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:o.map(m=>(0,e.jsx)(ft,{summary:m,onReservationChange:i(f=>xe.mutate({summary:m,changes:{reservationCents:f}}),"onReservationChange"),onUnpricedUsagePolicyChange:i(f=>xe.mutate({summary:m,changes:{unpricedUsagePolicy:f}}),"onUnpricedUsagePolicyChange"),isSaving:xe.isPending,onSave:i(f=>xe.mutate({summary:m,changes:{amount:f}}),"onSave")},m.policyId))})]},s)}),Ee.length===0?(0,e.jsx)(W,{children:(0,e.jsx)(X,{className:"px-5 py-8 text-sm text-muted-foreground",children:"No budget policies yet. Set agent and project budgets from their detail pages, or use the existing organization monthly budget control."})}):null]})]})]}),(0,e.jsx)(re,{value:"providers",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:Ue,onValueChange:G,children:[(0,e.jsx)(As,{items:at,value:Ue,onValueChange:G}),(0,e.jsx)(re,{value:"all",className:"mt-4",children:Re.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Re.map(s=>(0,e.jsx)(Bs,{provider:s,rows:ne.get(s)??[],budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,weekSpendCents:js.get(s)??0,windowRows:Ns.get(s)??[],showDeficitNotch:Ts.get(s)??!1,quotaAccounts:pe?.filter(o=>o.provider===s),quotaRequestFailed:!!Be,quotaWindows:Cs.get(s)??[],quotaError:ks.get(s)??null,quotaSource:Ss.get(s)??null,quotaLoading:fs},s))})}),Re.map(s=>(0,e.jsx)(re,{value:s,className:"mt-4",children:(0,e.jsx)(Bs,{provider:s,rows:ne.get(s)??[],budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,weekSpendCents:js.get(s)??0,windowRows:Ns.get(s)??[],showDeficitNotch:Ts.get(s)??!1,quotaAccounts:pe?.filter(o=>o.provider===s),quotaRequestFailed:!!Be,quotaWindows:Cs.get(s)??[],quotaError:ks.get(s)??null,quotaSource:Ss.get(s)??null,quotaLoading:fs})},s))]})})}),(0,e.jsx)(re,{value:"billers",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:Le,onValueChange:z,children:[(0,e.jsx)(As,{items:rt,value:Le,onValueChange:z}),(0,e.jsx)(re,{value:"all",className:"mt-4",children:_e.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No billable events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:_e.map(s=>{const o=(ue.get(s)??[])[0];if(!o)return null;const m=(Fe??[]).filter(f=>f.biller===s);return(0,e.jsx)($s,{row:o,weekSpendCents:ys.get(s)??0,budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,providerRows:m},s)})})}),_e.map(s=>{const o=(ue.get(s)??[])[0];if(!o)return null;const m=(Fe??[]).filter(f=>f.biller===s);return(0,e.jsx)(re,{value:s,className:"mt-4",children:(0,e.jsx)($s,{row:o,weekSpendCents:ys.get(s)??0,budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,providerRows:m})},s)})]})})}),(0,e.jsxs)(re,{value:"finance",className:"mt-4 min-w-0 max-w-full space-y-4",children:[S?.summary.providerReportedCentsExact!==void 0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Provider API cost reports: ",j(S.summary.providerReportedCents??0),". Report totals overlap invoices and run estimates and are shown separately from recorded charges."]}),Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):ms?(0,e.jsx)(ss,{variant:"costs"}):xs&&!S?(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Financial events could not be loaded. Please try again shortly."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(_s,{debitCents:S?.summary.debitCents??0,creditCents:S?.summary.creditCents??0,netCents:S?.summary.netCents??0,estimatedDebitCents:S?.summary.estimatedDebitCents??0,eventCount:S?.summary.eventCount??0}),(0,e.jsxs)("div",{className:"grid min-w-0 gap-4 xl:grid-cols-(--gtc-33)",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(ie,{className:"text-base",children:"By biller"}),(0,e.jsx)(be,{children:"Account-level financial events grouped by who charged or credited them."})]}),(0,e.jsx)(X,{className:"grid gap-4 px-5 pb-5 pt-2 md:grid-cols-2",children:(S?.byBiller.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events yet."}):S?.byBiller.map(s=>(0,e.jsx)(an,{row:s},`${s.biller}:${s.currency}`))})]}),(0,e.jsx)(on,{rows:it})]}),(0,e.jsx)(rn,{rows:S?.byKind??[]})]})]})]})]})]})}i(kn,"Costs");export{On as n,kn as t};
|
|
1
|
+
var xt=Object.defineProperty;var i=(t,n)=>xt(t,"name",{value:n,configurable:!0});import{a as Us,n as pt}from"./rolldown-runtime-DhZMWcEn.js";import{a as ht,i as gt,n as bt,r as vt,t as ft}from"./BudgetPolicyCard-BYMlczCq.js";import{b as jt}from"./collections-B58p51lw.js";import{t as yt}from"./arrow-down-left-Ck9VQyqQ.js";import{t as ns}from"./coins-BDAh8hDQ.js";import{$A as Nt,$S as Ls,Ai as re,BA as M,BE as Ct,CA as Ps,Di as As,EA as Ne,E_ as W,FA as Oe,GA as kt,GE as St,GS as F,Gb as Qe,HE as j,H_ as We,IA as me,Kr as Tt,LS as It,ME as qs,M_ as ie,Mb as Pt,Mi as je,NE as ee,OA as Ks,O_ as X,RE as cs,UT as as,VA as At,VE as zs,WC as rs,WE as Ce,XE as I,__ as ws,bE as Ae,cv as wt,fy as Mt,iT as Xe,ib as Et,jT as Os,j_ as oe,jb as $t,ji as Dt,kT as Qs,k_ as be,ki as es,ly as Ft,mb as ye,my as Bt,nD as se,nj as Rt,oE as _t,on as Ut,op as Pe,pb as ss,rD as ds,rb as Lt,sy as qt,uE as qe,uy as Kt,wA as zt,xE as q,zE as $e}from"./index-BJtnP7H1.js";import{t as ts}from"./budgets-CAWPqcn4.js";import{a as Ot,i as we,n as Qt,o as _,r as Wt,s as Ms,t as Gt}from"./useDateRange-CnZQr2KO.js";import{n as Vt,r as Yt,t as Ht}from"./useFastResponsesEnabled-B8tHSJ1y.js";import{t as Ge}from"./QuotaBar-Drp3CaxX.js";var ge=At([M().max(160),Oe().finite()]).transform((t,n)=>{try{if((typeof t=="number"?t<0:t.startsWith("-"))||bt(t)<0n)throw new Error("Money cannot be negative");return gt(t)}catch(a){return n.addIssue({code:"custom",message:a instanceof Error?a.message:"Invalid money"}),kt}}),Ws=me({source:Ne(["provider_reported","provider_invoice","operator","rate_card","unknown"]).default("unknown"),version:M().max(100).optional(),evidence:M().max(1e3).optional(),inputCentsPerMillion:ge.optional(),cachedInputCentsPerMillion:ge.optional(),outputCentsPerMillion:ge.optional(),cacheWriteCentsPerMillion:ge.optional(),serviceTier:M().max(50).optional(),contextTier:Ne(["short","long"]).optional()}),Bn=me({biller:M().trim().min(1).max(150),externalId:M().trim().min(1).max(200),currency:M().regex(/^[A-Za-z]{3}$/).transform(t=>t.toUpperCase()),lines:Ks(me({externalId:M().trim().min(1).max(200),kind:Ne(["inference","fee","credit"]).default("inference"),amountCents:ge,occurredAt:zt({offset:!0}),costEventId:M().uuid().optional(),runId:M().uuid().optional(),providerRequestId:M().min(1).max(250).optional(),model:M().min(1).max(250).optional(),pricing:Ws.optional()})).min(1).max(2e3)}).superRefine((t,n)=>{new Set(t.lines.map(a=>a.externalId)).size!==t.lines.length&&n.addIssue({code:"custom",path:["lines"],message:"Invoice line identifiers must be unique"})}),Rn=me({idempotencyKey:M().trim().min(1).max(200),expectedCents:ge,correctedCents:ge,invoiceLineId:M().uuid().optional(),reason:M().trim().min(1).max(1e3),pricing:Ws}),_n=me({fingerprint:M().regex(/^[a-f0-9]{64}$/),reason:M().trim().min(1).max(1e3)}),Un=me({runId:M().uuid()}),Ln=me({provider:Ne(["openai","anthropic"]),secretId:M().uuid(),accountId:M().trim().min(1).max(150).regex(/^[a-zA-Z0-9_-]+$/),scopeIds:Ks(M().trim().min(1).max(150)).min(1).max(25),from:Ps(),to:Ps()}).superRefine((t,n)=>{const a=Date.parse(t.to)-Date.parse(t.from);(a<=0||a>26784e5||Date.parse(t.to)>Math.floor(Date.now()/864e5)*864e5)&&n.addIssue({code:"custom",message:"Choose up to 31 completed UTC days; the end date is exclusive."}),new Set(t.scopeIds).size!==t.scopeIds.length&&n.addIssue({code:"custom",message:"Project/workspace identifiers must be unique."})}),Gs=["USD","EUR","GBP","CAD","AUD","CHF"],qn=me({expectedRevision:Oe().int().nonnegative(),plan:M().trim().min(1).max(100),amountCents:ge.nullable(),currency:Ne(Gs),cadence:Ne(["month","year"]),status:Ne(["active","ended","excluded"])}).strict(),Kn=me({targetId:M().uuid(),expectedRevision:Oe().int().nonnegative(),targetRevision:Oe().int().nonnegative()}).strict(),zn=[["openai","free","ChatGPT Free","0","https://learn.chatgpt.com/docs/pricing"],["openai","go","ChatGPT Go","800","https://learn.chatgpt.com/docs/pricing"],["openai","plus","ChatGPT Plus","2000","https://learn.chatgpt.com/docs/pricing"],["anthropic","pro","Claude Pro","2000","https://claude.com/pricing"],["anthropic","max_5x","Claude Max 5x","10000","https://claude.com/pricing"],["anthropic","max_20x","Claude Max 20x","20000","https://claude.com/pricing"],["xai","supergrok","SuperGrok","3000","https://x.ai/pricing"],["xai","supergrok_plus","SuperGrok Plus","10000","https://x.ai/pricing"]].map(([t,n,a,r,l])=>({provider:t,id:n,name:a,monthlyCents:r,sourceUrl:l,currency:"USD",checkedAt:"2026-10-08"})),e=Us(Nt(),1);function Vs({entries:t,fastResponse:n=!1,fastResponsesEnabled:a=!0}){return t.length?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recent requests. Inputs are not retained."}),(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm","aria-label":n?"Fast responses":"Decision requests",children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{className:"border-b border-border text-muted-foreground",children:["When / feature","Responsible","Task",...n?["Connection"]:[],"Model","Status","Duration","Tokens in / out","Cost"].map(r=>(0,e.jsx)("th",{className:"px-3 py-2 text-left font-medium",children:r},r))})}),(0,e.jsx)("tbody",{children:t.map(r=>(0,e.jsxs)("tr",{className:"border-b border-border last:border-0",children:[(0,e.jsxs)("td",{className:"px-3 py-3",children:[(0,e.jsx)("div",{className:"whitespace-nowrap",children:Ce(r.startedAt)}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.feature==="settings.test"?"Setup test":r.feature})]}),(0,e.jsx)("td",{className:"px-3 py-3",children:r.actorType==="system"?"Microvac services":r.userName??(r.responsibleUserId==="local-board"?"Board":"Former user")}),(0,e.jsx)("td",{className:"px-3 py-3",children:r.issueId?(0,e.jsx)(Qe,{className:"underline underline-offset-4",to:`/issues/${r.issueIdentifier??r.issueId}`,children:r.issueIdentifier??"View task"}):"—"}),n&&(0,e.jsx)("td",{className:"px-3 py-3 ph-mask ph-sensitive",children:r.connectionName??(r.connectionId?"Removed connection":"—")}),(0,e.jsx)("td",{className:"px-3 py-3 font-mono text-xs",children:r.model}),(0,e.jsxs)("td",{className:"px-3 py-3",children:[(0,e.jsx)("div",{children:r.status==="succeeded"?"Succeeded":r.status==="running"?"Running":r.status==="unknown"?"Unresolved":r.status==="skipped"?"Skipped":r.status==="pending"?"Pending":"Failed"}),r.publicationStatus&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.publicationStatus}),r.errorCode&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:r.errorCode.replaceAll("_"," ")})]}),(0,e.jsx)("td",{className:"px-3 py-3 font-mono",children:r.durationMs===null?"—":`${(r.durationMs/1e3).toFixed(1)}s`}),(0,e.jsxs)("td",{className:"whitespace-nowrap px-3 py-3 font-mono",children:[r.inputTokens===null?"—":I(r.inputTokens)," / ",r.outputTokens===null?"—":I(r.outputTokens)]}),(0,e.jsxs)("td",{className:"px-3 py-3 font-mono",children:[(0,e.jsx)("div",{children:r.costCents===null?"Unknown":St(r.costCents)}),r.costStatus!=="unpriced"&&r.costStatus&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:r.costStatus==="estimated"?"Estimated":"Reported"})]})]},r.id))})]})})]}):(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:[n?"No fast responses in this period.":"No decision requests in this period."," ",(0,e.jsx)(Qe,{to:n&&!a?"/company/settings/instance/experimental":"/company/settings/connections",className:"underline underline-offset-4",children:n?a?"Configure fast response":"Enable experimental fast responses":"Configure a decision model"})," to run a test."]})}i(Vs,"DecisionHistoryTable");function Zt({companyId:t,from:n,to:a}){const r=q({queryKey:["decision-history",t,n,a],queryFn:i(()=>Yt.history(t,n,a),"queryFn"),refetchInterval:i(l=>l.state.data?.some(g=>g.status==="running")?5e3:!1,"refetchInterval")});return r.isPending?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading decision requests…"}):r.error?(0,e.jsxs)("div",{role:"alert",className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Could not load decision requests."}),(0,e.jsx)(ee,{variant:"outline",onClick:i(()=>{r.refetch()},"onClick"),children:"Try again"})]}):(0,e.jsx)(Vs,{entries:r.data??[]})}i(Zt,"DecisionHistory");function Jt({companyId:t,from:n,to:a}){const{enabled:r}=Ht(),l=q({queryKey:["fast-response-history",t,n,a],queryFn:i(()=>Vt.history(t,n??void 0,a??void 0),"queryFn"),refetchInterval:i(g=>g.state.data?.some(u=>["pending","running"].includes(u.status)||["pending","streaming","retry"].includes(u.publicationStatus))?3e3:!1,"refetchInterval")});return l.isPending?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading fast responses…"}):l.error?(0,e.jsxs)("div",{role:"alert",children:[(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Could not load fast responses."}),(0,e.jsx)(ee,{variant:"outline",onClick:i(()=>{l.refetch()},"onClick"),children:"Try again"})]}):(0,e.jsx)(Vs,{entries:l.data??[],fastResponse:!0,fastResponsesEnabled:r})}i(Jt,"FastResponseHistory");var p=Us(Rt(),1),Ve={report(t,n,a){const r=new URLSearchParams;return n&&r.set("from",n),a&&r.set("to",a),!n&&!a&&r.set("period","all"),qe.get(`/companies/${t}/costs/subscriptions?${r}`)},refresh:i(t=>qe.post(`/companies/${t}/costs/subscriptions/refresh`,{}),"refresh"),update:i((t,n,a)=>qe.patch(`/companies/${t}/costs/subscriptions/${n}`,a),"update"),link:i((t,n,a,r,l)=>qe.post(`/companies/${t}/costs/subscriptions/${n}/link`,{targetId:a,expectedRevision:r,targetRevision:l}),"link")};function Es(t,n){return n==="USD"?j(Number(t)):new Intl.NumberFormat(void 0,{style:"currency",currency:n,currencyDisplay:"code"}).format(Number(t)/100)}i(Es,"subscriptionMoney");function is({usage:t}){return(0,e.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:[I(t.inputTokens+t.cachedInputTokens)," in · ",I(t.outputTokens)," out",t.cachedInputTokens>0&&(0,e.jsxs)("span",{className:"block",children:[I(t.cachedInputTokens)," input cached"]})]})}i(is,"SubscriptionTokenUsage");function Xt({account:t,accounts:n,companyId:a,onDone:r}){const[l,g]=(0,p.useState)(t.price.plan),[u,E]=(0,p.useState)(t.price.amountCents==null?"":vt(t.price.amountCents).replace(/\.?0+$/,"")),[U,B]=(0,p.useState)(t.price.currency),[v,c]=(0,p.useState)(t.price.cadence),[T,R]=(0,p.useState)(t.price.status),[L,$]=(0,p.useState)(""),G=Ae({mutationFn:i(()=>Ve.update(a,t.id,{expectedRevision:t.price.revision,plan:l,amountCents:u.trim()?ht(u.trim()):null,currency:U,cadence:v,status:T}),"mutationFn"),onSuccess:r}),K=Ae({mutationFn:i(()=>Ve.link(a,t.id,L,t.price.revision,n.find(C=>C.id===L).price.revision),"mutationFn"),onSuccess:r}),z=n.filter(C=>C.id!==t.id&&C.provider===t.provider&&C.canEdit),w=G.isPending||K.isPending,k="h-9 rounded-md border border-input bg-background px-3 text-sm";return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("form",{className:"space-y-4",onSubmit:i(C=>{C.preventDefault(),G.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-plan",children:"Plan"}),(0,e.jsx)(ws,{id:"subscription-plan",value:l,onChange:i(C=>g(C.target.value),"onChange"),required:!0,maxLength:100})]}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-price",children:"Price per billing period"}),(0,e.jsx)(ws,{id:"subscription-price",type:"number",min:"0",step:"any",value:u,placeholder:"Unknown",onChange:i(C=>E(C.target.value),"onChange")})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-currency",children:"Currency"}),(0,e.jsx)("select",{id:"subscription-currency",className:k,value:U,onChange:i(C=>B(C.target.value),"onChange"),children:Gs.map(C=>(0,e.jsx)("option",{children:C},C))})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-cadence",children:"Billed"}),(0,e.jsxs)("select",{id:"subscription-cadence",className:k,value:v,onChange:i(C=>c(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"month",children:"Monthly"}),(0,e.jsx)("option",{value:"year",children:"Annually"})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-status",children:"Tracking"}),(0,e.jsxs)("select",{id:"subscription-status",className:k,value:T,onChange:i(C=>R(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"active",children:"Active"}),(0,e.jsx)("option",{value:"ended",children:"Subscription ended"}),(0,e.jsx)("option",{value:"excluded",children:"Exclude from this organization"})]})]})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter the full amount for one account or seat. Annual prices are divided by 12. Changes apply from now. Ending tracking here does not cancel your provider subscription."}),G.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not save this price. Check the amount, or reopen the account if another person updated it."}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ee,{type:"button",variant:"ghost",disabled:w,onClick:r,children:"Cancel"}),(0,e.jsx)(ee,{type:"submit",disabled:w,children:G.isPending?"Saving…":"Save price"})]})]}),z.length>0&&(0,e.jsxs)("div",{className:"space-y-2 border-t border-border pt-4",children:[(0,e.jsx)(Pe,{htmlFor:"subscription-link",children:"Same subscription as another account?"}),(0,e.jsxs)("select",{id:"subscription-link",className:$e(k,"ph-mask ph-sensitive"),value:L,onChange:i(C=>$(C.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Choose an account"}),z.map(C=>(0,e.jsxs)("option",{value:C.id,children:[C.name," · ",C.price.plan]},C.id))]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Linking counts these accounts once, combines their Microvac usage, and keeps the selected account’s price. Only link the same subscription or paid seat."}),K.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not link these accounts. Reopen their details and try again."}),(0,e.jsx)(ee,{type:"button",variant:"outline",disabled:!L||w,onClick:i(()=>K.mutate(),"onClick"),children:"Link accounts"})]})]})}i(Xt,"SubscriptionEditor");function en({companyId:t,report:n,error:a,onChanged:r}){const[l,g]=(0,p.useState)(!1),[u,E]=(0,p.useState)(null),U=i(()=>{E(null),r()},"closeEditor"),B=n?.monthlyTotals.length,v=n?.monthlyTotals.reduce((c,T)=>c+T.estimatedCount,0)??0;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(W,{className:"block p-4",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"Subscriptions"}),(0,e.jsx)("div",{className:"mt-2 font-mono text-2xl font-semibold tabular-nums",children:B?n.monthlyTotals.map(c=>(0,e.jsxs)("div",{children:[Es(c.amountCents,c.currency),(0,e.jsx)("span",{className:"text-sm font-normal",children:"/month"})]},c.currency)):n&&n.activeCount===0&&n.accounts.length>0?"$0.00/month":"—"}),(0,e.jsxs)("div",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:[n?(0,e.jsxs)(e.Fragment,{children:[v>0&&(0,e.jsx)("div",{children:(0,e.jsx)(We,{variant:"outline",className:"font-normal text-muted-foreground",children:v<n.activeCount-n.unknownPriceCount?"Partially estimated":"Estimated"})}),n.unknownPriceCount>0&&!!B&&(0,e.jsx)("div",{children:"Known monthly subtotal"}),(0,e.jsx)("div",{children:n.accounts.length===0?"No visible subscriptions":(0,e.jsxs)(e.Fragment,{children:[n.activeCount," active ",n.activeCount===1?"subscription":"subscriptions",n.unknownPriceCount>0&&` · ${n.unknownPriceCount} ${n.unknownPriceCount===1?"price":"prices"} unknown`]})}),n.accounts.length>0&&(0,e.jsx)("div",{children:"Monthly fees for accounts visible to you"}),n.unidentifiedAccountCount>0&&(0,e.jsxs)("div",{children:[n.unidentifiedAccountCount," unconfirmed ",n.unidentifiedAccountCount===1?"account identity":"account identities"]}),(0,e.jsx)(is,{usage:n.subscription})]}):a?(0,e.jsx)("div",{children:"Subscription data is unavailable."}):(0,e.jsx)("div",{children:"Loading subscriptions…"}),n&&a?(0,e.jsx)("div",{children:"Showing last loaded subscription data."}):null]}),(0,e.jsx)(ee,{variant:"link",size:"sm",className:"h-auto p-0",onClick:i(()=>g(!0),"onClick"),disabled:!n,children:"View details"})]}),(0,e.jsx)(qt,{open:l,onOpenChange:i(c=>{g(c),c||E(null)},"onOpenChange"),children:(0,e.jsxs)(Ft,{className:"max-h-(--sz-80vh) overflow-y-auto sm:max-w-3xl",children:[(0,e.jsxs)(Mt,{children:[(0,e.jsx)(Bt,{children:u?"Subscription price":"Subscriptions"}),(0,e.jsx)(Kt,{children:"Current monthly costs for accounts visible to you. Token totals cover company work in the selected period."})]}),u?(0,e.jsx)(Xt,{companyId:t,account:u,accounts:n?.accounts??[],onDone:U},u.id):(0,e.jsxs)("div",{className:"space-y-4",children:[n?.accounts.length===0&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No subscriptions are visible to you yet. Connect an AI account or run an agent with a connected subscription."}),n?.accounts.map(c=>(0,e.jsxs)("div",{className:"space-y-2 border-b border-border pb-4 last:border-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:Ls,children:[(0,e.jsx)("div",{className:"font-medium",children:c.name}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[c.shared?"Shared":c.ownerName??(c.ownerUserId?"Account owner":"Personal accounts")," · ",se(c.provider)," · ",c.price.plan]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)("div",{className:"font-mono",children:c.price.status!=="active"?c.price.status==="ended"?"Ended":"Excluded":c.price.monthlyCents==null?"Price unknown":`${Es(c.price.monthlyCents,c.price.currency)}/month`}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[c.price.source==="catalog"?"Estimated · before tax":c.price.source==="user"?"User supplied":"",c.price.cadence==="year"?" · annual payment ÷ 12":""]})]})]}),(0,e.jsx)(is,{usage:c.usage}),Number(c.usage.costCents)>0&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j(Number(c.usage.costCents))," recorded usage charges in selected period, separate from the subscription fee."]}),c.agents.length>0&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Used by ",c.agents.map(T=>T.name).join(", ")]}),!c.identityVerified&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Account identity is unconfirmed. Link duplicates if these connections use the same subscription."}),c.observedAt&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Plan checked ",Ce(c.observedAt),c.refreshStatus==="unavailable"?" · latest check unavailable":""]}),c.refreshStatus==="unavailable"&&!c.observedAt&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"The provider did not make plan details available. You can enter the price yourself."}),c.canEdit&&(0,e.jsx)("div",{children:(0,e.jsx)(ee,{variant:"outline",size:"sm",onClick:i(()=>E(c),"onClick"),children:"Edit price"})})]},c.id)),!!n?.unattributedSubscription.eventCount&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Some subscription usage has no recorded account. It is included in the subscription token total."}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Monthly fees cover the whole account, including use outside Microvac. They are separate from recorded charges and agent budgets. Currencies are totaled separately."})]})]})})]})}i(en,"SubscriptionCostCard");function sn({report:t}){return(0,e.jsxs)(W,{className:"min-w-0 max-w-full gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By user"})}),(0,e.jsxs)(X,{className:"min-w-0 px-5",children:[(0,e.jsx)("div",{className:"max-w-full overflow-x-auto",children:(0,e.jsxs)("table",{"aria-label":"Costs by user",className:"w-full text-sm",children:[(0,e.jsx)("thead",{className:"text-muted-foreground",children:(0,e.jsxs)("tr",{className:"border-b border-border",children:[(0,e.jsx)("th",{scope:"col",className:"py-2 pr-4 text-left font-medium",children:"User"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Runs"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Input"}),(0,e.jsx)("th",{scope:"col",className:"px-4 py-2 text-right font-medium",children:"Output"}),(0,e.jsx)("th",{scope:"col",className:"py-2 pl-4 text-right font-medium",children:"Cost"})]})}),(0,e.jsxs)("tbody",{children:[t.rows.length===0&&(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"py-3 text-muted-foreground",children:"No user-attributed costs yet."})}),t.rows.map(n=>(0,e.jsxs)("tr",{className:"border-b border-border last:border-0",children:[(0,e.jsx)("th",{scope:"row",className:"py-3 pr-4 text-left font-normal",children:n.userId?(0,e.jsx)(Pt,{name:n.userName??"Unknown user",avatarUrl:n.userImage}):"Unattributed"}),(0,e.jsx)("td",{className:"px-4 py-3 text-right tabular-nums",children:n.runCount.toLocaleString()}),(0,e.jsxs)("td",{className:"px-4 py-3 text-right tabular-nums",children:[I(n.inputTokens+n.cachedInputTokens),n.cachedInputTokens>0&&(0,e.jsxs)("div",{className:"whitespace-nowrap text-xs text-muted-foreground",children:[I(n.cachedInputTokens)," cached"]})]}),(0,e.jsx)("td",{className:"px-4 py-3 text-right tabular-nums",children:I(n.outputTokens)}),(0,e.jsxs)("td",{className:"py-3 pl-4 text-right tabular-nums",children:[(0,e.jsx)(we,{costCents:n.costCents,eventCount:n.eventCount,estimatedEventCount:n.estimatedEventCount,unpricedEventCount:n.unpricedEventCount}),n.unpricedEventCount>0&&(0,e.jsxs)("div",{className:"whitespace-nowrap text-xs text-muted-foreground",children:[n.unpricedEventCount," unpriced ",n.unpricedEventCount===1?"charge":"charges"]})]})]},n.userId??"unattributed"))]})]})}),t.rows.some(n=>n.userId===null)&&(0,e.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"Unattributed costs have no recorded user in this organization."})]})]})}i(sn,"CostByUserTable");var tn={unknown_billing:{label:"Billing category unknown",description:"This run did not identify API or subscription billing. Any recorded charges are included in the inference ledger. For future runs, select an AI connection in the agent’s configuration so Microvac can identify its billing."},missing_model:{label:"Model not reported",description:"Token usage was recorded without a model, so Microvac cannot estimate its cost. Select an explicit model in the agent’s configuration for future runs. Changing settings will not reprice this past run."},missing_price:{label:"Cost unavailable",description:"The provider did not supply a reliable price for this usage. There is no action required for this past entry. New API runs with complete usage and a supported model are estimated automatically."},waiting_for_receipt:{label:"Receiving usage",description:"This run has stopped. Microvac is waiting for its final usage data and will record it automatically. You do not need to rerun the agent."},receipt_unavailable:{label:"Final usage unavailable",description:"This run stopped without final usage data. Its cost remains unresolved for budget checks. Microvac will record a late receipt if one arrives; rerunning the agent will not recover this usage."},retryable:{label:"Ready to record",description:"Saved usage data is ready to be recorded. Microvac retries automatically, or you can retry now. This records costs only; it does not rerun the agent."}};function nn({companyId:t,from:n,to:a,reportKey:r,unpricedCount:l,pendingCount:g,unknownBillingCount:u}){const[E,U]=(0,p.useState)(!1),B=l+g,v=B>0||u>0,c=(0,p.useId)(),T=qs(),{pushToast:R}=wt(),L=[...r,"data-quality"],{data:$,error:G,isPending:K,refetch:z}=q({queryKey:L,queryFn:i(()=>_.dataQuality(t,n,a),"queryFn"),enabled:E&&v,refetchInterval:E&&v?3e4:!1}),w=Ae({mutationFn:i(h=>_.retryAccounting(t,h),"mutationFn"),onSuccess:i(h=>{R({title:h.accounted?"Costs recorded.":"No new cost data is available.",body:"The agent was not rerun.",tone:h.accounted?"success":"info"}),T.invalidateQueries({queryKey:["costs",t]}),T.invalidateQueries({queryKey:L}),T.invalidateQueries({queryKey:["cost-subscriptions",t]})},"onSuccess")}),k=B>0?`${B} run ${B===1?"cost":"costs"} unavailable`:`${u} billing ${u===1?"type":"types"} unknown`,C=new Map;for(const[h,D]of[["event",$?.events??[]],["run",$?.runs??[]]])for(const y of D){let A=C.get(y.agentId);A||(A={agent:{id:y.agentId??void 0,name:y.agentName??(y.agentId?"Unknown agent":"Microvac services"),appearance:y.agentAppearance},items:[]},C.set(y.agentId,A)),A.items.push({item:y,source:h})}const ve=[...C.values()].sort((h,D)=>h.agent.name.localeCompare(D.agent.name,"en",{sensitivity:"base",numeric:!0})||(h.agent.id??"").localeCompare(D.agent.id??""));for(const h of ve)h.items.sort((D,y)=>Date.parse(y.item.occurredAt)-Date.parse(D.item.occurredAt)||`${D.source}:${D.item.id}`.localeCompare(`${y.source}:${y.item.id}`));function ke(h,D){const y=tn[h.reason];return(0,e.jsxs)("li",{className:"space-y-2 border-b border-border py-3 last:border-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(We,{variant:"outline",className:"font-normal text-muted-foreground",children:y.label}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,e.jsx)("time",{dateTime:h.occurredAt,children:Ce(h.occurredAt)}),h.runId&&h.agentId&&(0,e.jsx)(Qe,{className:"text-primary underline underline-offset-4 hover:text-primary/80",to:`/agents/${h.agentId}/runs/${h.runId}`,children:"View run"}),h.reason==="retryable"&&h.runId&&$?.canRetry&&(0,e.jsx)(ee,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs font-normal underline hover:text-primary/80",disabled:w.isPending,onClick:i(()=>{w.reset(),w.mutate(h.runId)},"onClick"),children:"Retry cost recording"})]})]}),(0,e.jsx)("p",{children:y.description}),w.variables===h.runId&&w.isPending&&(0,e.jsx)("p",{role:"status",children:"Recording saved costs…"}),w.variables===h.runId&&w.error&&(0,e.jsx)("p",{role:"status",children:"Cost recording failed. Try again shortly."})]},`${D}:${h.id}`)}return i(ke,"itemRow"),(0,e.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,e.jsxs)(ee,{type:"button",variant:"ghost",size:"sm",className:"h-auto justify-start gap-1 px-0 py-1 font-normal has-[>svg]:px-0","aria-expanded":E,"aria-controls":c,onClick:i(()=>U(h=>!h),"onClick"),children:[E?(0,e.jsx)(Os,{className:"size-3","aria-hidden":"true"}):(0,e.jsx)(Qs,{className:"size-3","aria-hidden":"true"}),k]}),E&&(0,e.jsxs)("div",{id:c,className:"space-y-2",children:[v&&K&&(0,e.jsx)("p",{role:"status",children:"Loading affected runs…"}),v&&G&&!$&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{role:"status",children:"Cost details could not be loaded."}),(0,e.jsx)(ee,{variant:"outline",size:"sm",onClick:i(()=>z(),"onClick"),children:"Retry loading"})]}),v&&$&&(0,e.jsxs)(e.Fragment,{children:[G&&(0,e.jsx)("p",{role:"status",children:"Showing the last loaded cost details. Updates will resume automatically."}),$.events.length===0&&$.runs.length===0&&(0,e.jsx)("p",{role:"status",children:"No cost gaps remain in this period."}),(0,e.jsx)("ul",{"aria-label":"Cost details by agent",className:"space-y-4",children:ve.map(h=>(0,e.jsxs)("li",{children:[(0,e.jsxs)("h3",{className:"flex items-center gap-2 font-medium text-foreground",children:[(0,e.jsx)($t,{agent:h.agent,size:20}),h.agent.id?(0,e.jsx)(Qe,{className:"text-primary underline underline-offset-4 hover:text-primary/80",to:`/agents/${h.agent.id}/configuration`,children:h.agent.name}):h.agent.name]}),(0,e.jsx)("ul",{"aria-label":`${h.agent.name} cost details`,children:h.items.map(({item:D,source:y})=>ke(D,y))})]},h.agent.id??"services"))}),($.hasMoreEvents||$.hasMoreRuns)&&(0,e.jsx)("p",{className:"text-xs",children:"Showing the 25 most recent entries in each category. Select a shorter date range to inspect more."})]})]})]})}i(nn,"CostDataQualityNotice");function $s({row:t,weekSpendCents:n,budgetMonthlyCents:a,showBudgetUtilization:r=!0,totalCompanySpendCents:l,providerRows:g}){const u=(0,p.useMemo)(()=>{const v=new Map;for(const c of g){const T=v.get(c.provider)??{provider:c.provider,costCents:0,inputTokens:0,outputTokens:0};T.costCents+=c.costCents,T.inputTokens+=c.inputTokens+c.cachedInputTokens,T.outputTokens+=c.outputTokens,v.set(c.provider,T)}return Array.from(v.values()).sort((c,T)=>T.costCents-c.costCents)},[g]),E=(0,p.useMemo)(()=>{const v=new Map;for(const c of g)v.set(c.billingType,(v.get(c.billingType)??0)+c.costCents);return Array.from(v.entries()).sort((c,T)=>T[1]-c[1])},[g]),U=a,B=U>0?Math.min(100,t.costCents/U*100):0;return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-0 gap-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(ie,{className:"text-sm font-semibold",children:se(t.biller)}),(0,e.jsxs)(be,{className:"text-xs mt-0.5",children:[(0,e.jsx)("span",{className:"font-mono",children:I(t.inputTokens+t.cachedInputTokens)})," in"," · ",(0,e.jsx)("span",{className:"font-mono",children:I(t.outputTokens)})," out"," · ",t.providerCount," provider",t.providerCount===1?"":"s"," · ",t.modelCount," model",t.modelCount===1?"":"s"]})]}),(0,e.jsx)("div",{className:"text-xl shrink-0",children:(0,e.jsx)(we,{costCents:t.costCents,eventCount:t.eventCount,estimatedEventCount:t.estimatedEventCount,unpricedEventCount:t.unpricedEventCount,showUnavailableCount:!0})})]})}),(0,e.jsxs)(X,{className:"px-4 pb-4 pt-3 space-y-4",children:[r&&a>0&&(0,e.jsx)(Ge,{label:"Period spend",percentUsed:B,leftLabel:j(t.costCents),rightLabel:`${Math.round(B)}% of company budget`}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[t.apiRunCount>0?`${t.apiRunCount} metered run${t.apiRunCount===1?"":"s"}`:"0 metered runs"," · ",t.subscriptionRunCount>0?`${t.subscriptionRunCount} subscription run${t.subscriptionRunCount===1?"":"s"}`:"0 subscription runs"," · ",j(n)," this week"]}),E.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Billing types"}),(0,e.jsx)("div",{className:"space-y-1.5",children:E.map(([v,c])=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:cs(v)}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:j(c)})]},v))})]})]}),u.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Upstream providers"}),(0,e.jsx)("div",{className:"space-y-1.5",children:u.map(v=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:se(v.provider)}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"font-medium",children:j(v.costCents)}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[I(v.inputTokens+v.outputTokens)," tok"]})]})]},v.provider))})]})]})]})]})}i($s,"BillerSpendCard");function an({row:t}){return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(ie,{className:"text-base",children:se(t.biller)}),(0,e.jsxs)(be,{className:"mt-1 text-xs",children:[t.eventCount," event",t.eventCount===1?"":"s"," across ",t.kindCount," kind",t.kindCount===1?"":"s"]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)("div",{className:"text-lg font-semibold tabular-nums",children:j(t.netCents,t.currency)}),(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"net"})]})]})}),(0,e.jsx)(X,{className:"space-y-3 px-4 pb-4 pt-3",children:(0,e.jsxs)("div",{className:"grid gap-2 text-sm sm:grid-cols-3",children:[(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"debits"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.debitCents,t.currency)})]}),(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"credits"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.creditCents,t.currency)})]}),(0,e.jsxs)("div",{className:"border border-border p-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:"estimated"}),(0,e.jsx)("div",{className:"mt-1 font-medium tabular-nums",children:j(t.estimatedDebitCents,t.currency)})]})]})})]})}i(an,"FinanceBillerCard");function rn({rows:t}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-4 pt-4 pb-1",children:[(0,e.jsx)(ie,{className:"text-base",children:"Financial event mix"}),(0,e.jsx)(be,{children:"Account-level charges grouped by event kind."})]}),(0,e.jsx)(X,{className:"space-y-2 px-4 pb-4 pt-3",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events in this period."}):t.map(n=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium",children:zs(n.eventKind)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[n.eventCount," event",n.eventCount===1?"":"s"," · ",n.billerCount," biller",n.billerCount===1?"":"s"]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:j(n.netCents,n.currency)}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j(n.debitCents,n.currency)," debits"]})]})]},`${n.eventKind}:${n.currency}`))})]})}i(rn,"FinanceKindCard");function on({rows:t,emptyMessage:n="No financial events recorded in this period. Events appear when reported through the API, CLI, or a supported integration."}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-4 pt-4 pb-1",children:[(0,e.jsx)(ie,{className:"text-base",children:"Recent financial events"}),(0,e.jsx)(be,{children:"Provider charges, subscriptions, fees, and credits. Reported separately from run-cost estimates."})]}),(0,e.jsx)(X,{className:"space-y-3 px-4 pb-4 pt-3",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:n}):t.map(a=>(0,e.jsx)("div",{className:"border border-border p-3",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(We,{variant:"secondary",children:a.metadataJson?.source==="provider_cost_report"?"Provider cost report":zs(a.eventKind)}),(0,e.jsx)(We,{variant:a.direction==="credit"?"outline":"secondary",children:Ct(a.direction)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:Ce(a.occurredAt)})]}),(0,e.jsxs)("div",{className:"text-sm font-medium",children:[se(a.biller),a.provider?` -> ${se(a.provider)}`:"",a.model?(0,e.jsx)("span",{className:"ml-1 font-mono text-xs text-muted-foreground",children:a.model}):null]}),(a.description||a.externalInvoiceId||a.region||a.pricingTier)&&(0,e.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground",children:[a.description?(0,e.jsx)("div",{children:a.description}):null,a.externalInvoiceId?(0,e.jsxs)("div",{children:["invoice ",a.externalInvoiceId]}):null,a.region?(0,e.jsxs)("div",{children:["region ",a.region]}):null,a.pricingTier?(0,e.jsxs)("div",{children:["tier ",a.pricingTier]}):null]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)("div",{className:"text-sm font-semibold",children:j(a.amountCents,a.currency)}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:a.currency}),a.estimated?(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-amber-600",children:"estimated"}):null]})]})},a.id))})]})}i(on,"FinanceTimelineCard");var ln=new Set(["credentials_unavailable","authentication_required","refresh_token_reused","refresh_token_expired","refresh_token_invalidated"]);function cn(t,n){return n.map(a=>{if(a.ok||a.errorFamily&&ln.has(a.errorFamily))return a;const r=t?.find(l=>l.provider===a.provider&&l.accountKey===a.accountKey);return r?.windows.length?{...a,windows:r.windows,source:r.source,capturedAt:r.capturedAt}:a})}i(cn,"retainQuotaWindows");function Ye(t){return t?"Showing the last available quota. Updates will resume automatically.":"Subscription quota is currently unavailable. Check usage with your provider."}i(Ye,"quotaUnavailableMessage");function dn({accounts:t,failed:n}){return(0,e.jsx)("div",{className:"space-y-4",children:t.map(a=>(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("p",{className:$e("text-sm font-medium",Ls),children:a.accountLabel??"Subscription account"}),(n||!a.ok)&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a.errorFamily==="credentials_unavailable"?"Connect or reconnect a subscription in AI connections to view its quota.":Ye(a.windows.length>0)}),a.windows.map((r,l)=>r.usedPercent==null?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:r.label}),(0,e.jsx)("span",{className:"font-mono text-muted-foreground",children:r.valueLabel??"Usage not reported"})]}),r.resetsAt&&(0,e.jsxs)("p",{className:"text-xs font-mono text-muted-foreground",children:["Resets ",Ce(r.resetsAt)]})]},`${r.label}:${l}`):(0,e.jsx)(Ge,{className:"font-mono",label:r.label,percentUsed:r.usedPercent,leftLabel:r.valueLabel??(r.usedPercent===null?"Usage not reported":`${r.usedPercent}% used`),rightLabel:r.resetsAt?`Resets ${Ce(r.resetsAt)}`:void 0},`${r.label}:${l}`)),a.capturedAt&&(0,e.jsxs)("p",{className:"text-xs font-mono text-muted-foreground",children:["Last checked ",Ce(a.capturedAt)]})]},a.accountKey??a.provider))})}i(dn,"AccountQuotaPanels");var Ke=["currentsession","currentweekallmodels","currentweeksonnetonly","currentweeksonnet","currentweekopusonly","currentweekopus","extrausage"];function os(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(os,"normalizeLabel$1");function un(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}i(un,"detailText$1");function mn(t){return[...t].sort((n,a)=>{const r=Ke.indexOf(os(n.label)),l=Ke.indexOf(os(a.label));return(r===-1?Ke.length:r)-(l===-1?Ke.length:l)})}i(mn,"orderedWindows$1");function xn(t){return t==null?"bg-zinc-700":t>=90?"bg-(--status-task-blocked)":t>=70?"bg-(--status-task-todo)":"bg-primary/70"}i(xn,"fillClass$1");function pn({windows:t,source:n=null,error:a=null}){const r=mn(t);return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Anthropic subscription"}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:"Quota from the Claude subscription connected to this server."})]}),n?(0,e.jsx)("span",{className:"shrink-0 border border-border px-2.5 py-1 text-(length:--text-nano) font-semibold uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(n)}):null]}),a?(0,e.jsx)("div",{role:"status",className:"mt-4 text-sm text-muted-foreground",children:Ye(t.length>0)}):null,(0,e.jsx)("div",{className:"mt-4 space-y-4",children:r.map(l=>{const g=os(l.label),u=un(l);if(g==="extrausage")return(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.label}),l.valueLabel?(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.valueLabel}):null]}),u?(0,e.jsx)("div",{className:"mt-2 text-sm text-muted-foreground",children:u}):null]},l.label);const E=Math.min(100,Math.max(0,l.usedPercent??0));return(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:l.label}),u?(0,e.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:u}):null]}),l.usedPercent!=null?(0,e.jsxs)("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[l.usedPercent,"% used"]}):null]}),(0,e.jsx)("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:$e("h-full transition-(--tp-width) duration-200",xn(l.usedPercent)),style:{width:`${E}%`}})})]},l.label)})})]})}i(pn,"ClaudeSubscriptionPanel");var ze=["5hlimit","weeklylimit","credits"];function ls(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(ls,"normalizeLabel");function hn(t){return[...t].sort((n,a)=>{const r=ls(n.label).replace(/^gpt53codexspark/,""),l=ls(a.label).replace(/^gpt53codexspark/,""),g=ze.indexOf(r),u=ze.indexOf(l);return(g===-1?ze.length:g)-(u===-1?ze.length:u)})}i(hn,"orderedWindows");function gn(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}i(gn,"detailText");function bn(t){return t==null?"bg-zinc-700":t>=90?"bg-(--status-task-blocked)":t>=70?"bg-(--status-task-todo)":"bg-primary/70"}i(bn,"fillClass");function Ds(t){const n=ls(t);return n.includes("gpt53codexspark")||n.includes("gpt5")}i(Ds,"isModelSpecific");function vn({windows:t,source:n=null,error:a=null}){const r=hn(t),l=r.filter(u=>!Ds(u.label)),g=r.filter(u=>Ds(u.label));return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Codex subscription"}),(0,e.jsx)("div",{className:"mt-1 text-sm text-muted-foreground",children:"Quota from the Codex subscription connected to this server."})]}),n?(0,e.jsx)("span",{className:"shrink-0 border border-border px-2.5 py-1 text-(length:--text-nano) font-semibold uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(n)}):null]}),a?(0,e.jsx)("div",{role:"status",className:"mt-4 text-sm text-muted-foreground",children:Ye(t.length>0)}):null,(0,e.jsxs)("div",{className:"mt-4 space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Account windows"}),(0,e.jsx)("div",{className:"space-y-3",children:l.map(u=>(0,e.jsx)(Fs,{window:u},u.label))})]}),g.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Model windows"}),(0,e.jsx)("div",{className:"space-y-3",children:g.map(u=>(0,e.jsx)(Fs,{window:u},u.label))})]}):null]})]})}i(vn,"CodexSubscriptionPanel");function Fs({window:t}){const n=gn(t);return t.usedPercent==null?(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:t.label}),t.valueLabel?(0,e.jsx)("div",{className:"text-sm font-semibold tabular-nums text-foreground",children:t.valueLabel}):null]}),n?(0,e.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:n}):null]}):(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:t.label}),n?(0,e.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),(0,e.jsxs)("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[t.usedPercent,"% used"]})]}),(0,e.jsx)("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:(0,e.jsx)("div",{className:$e("h-full transition-(--tp-width) duration-200",bn(t.usedPercent)),style:{width:`${Math.max(0,Math.min(100,t.usedPercent))}%`}})})]})}i(Fs,"QuotaWindowRow");var fn=["5h","24h","7d"];function Bs({provider:t,rows:n,budgetMonthlyCents:a,showBudgetUtilization:r=!0,totalCompanySpendCents:l,weekSpendCents:g,windowRows:u,showDeficitNotch:E,quotaAccounts:U,quotaRequestFailed:B,quotaWindows:v=[],quotaError:c=null,quotaSource:T=null,quotaLoading:R=!1}){const L=(0,p.useMemo)(()=>{let d=0,b=0,Z=0,ce=0,fe=0,de=0,O=0,De=0,Te=0,Me=0;for(const Q of n)d+=Q.inputTokens+Q.cachedInputTokens,b+=Q.outputTokens,Z+=Q.costCents,De+=Q.eventCount??0,Te+=Q.estimatedEventCount??0,Me+=Q.unpricedEventCount??0,ce+=Q.apiRunCount,fe+=Q.subscriptionRunCount,de+=Q.subscriptionInputTokens+Q.subscriptionCachedInputTokens,O+=Q.subscriptionOutputTokens;const xe=d+b,le=de+O,N=xe;return{totalInputTokens:d,totalOutputTokens:b,totalTokens:xe,totalCostCents:Z,eventCount:De,estimatedEventCount:Te,unpricedEventCount:Me,totalApiRuns:ce,totalSubRuns:fe,totalSubInputTokens:de,totalSubOutputTokens:O,totalSubTokens:le,subSharePct:N>0?le/N*100:0}},[n]),{totalInputTokens:$,totalOutputTokens:G,totalTokens:K,totalCostCents:z,totalApiRuns:w,totalSubRuns:k,totalSubInputTokens:C,totalSubOutputTokens:ve,totalSubTokens:ke,subSharePct:h}=L,D=a,y=D>0?Math.min(100,z/D*100):0,A=D>0?D/4.33:0,H=A>0?Math.min(100,g/A*100):0,He=r&&a>0,Ze=(0,p.useMemo)(()=>new Map(u.map(d=>[d.window,d])),[u]),Se=(0,p.useMemo)(()=>Math.max(...u.map(d=>d.costCents),0),[u]),te=t==="anthropic",x=t==="openai"&&T?.startsWith("codex-"),V=(t==="anthropic"||t==="openai")&&(R||!!U?.length||v.length>0||c!=null);return(0,e.jsxs)(W,{children:[(0,e.jsx)(oe,{className:"px-4 pt-4 pb-0 gap-1",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(ie,{className:"text-sm font-semibold",children:se(t)}),(0,e.jsxs)(be,{className:"text-xs mt-0.5",children:[(0,e.jsx)("span",{className:"font-mono",children:I($)})," in"," · ",(0,e.jsx)("span",{className:"font-mono",children:I(G)})," out",(w>0||k>0)&&(0,e.jsxs)("span",{className:"ml-1.5",children:["·"," ",w>0&&`~${w} api`,w>0&&k>0&&" / ",k>0&&`~${k} sub`," runs"]})]})]}),(0,e.jsx)("div",{className:"text-xl shrink-0",children:(0,e.jsx)(we,{costCents:z,eventCount:L.eventCount,estimatedEventCount:L.estimatedEventCount,unpricedEventCount:L.unpricedEventCount,showUnavailableCount:!0})})]})}),(0,e.jsxs)(X,{className:"px-4 pb-4 pt-3 space-y-4",children:[He&&(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Ge,{label:"Period spend",percentUsed:y,leftLabel:j(z),rightLabel:`${Math.round(y)}% of company budget`,showDeficitNotch:E}),(0,e.jsx)(Ge,{label:"This week",percentUsed:H,leftLabel:j(g),rightLabel:`~${j(Math.round(A))} / wk`,showDeficitNotch:H>=100})]}),u.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Rolling windows"}),(0,e.jsx)("div",{className:"space-y-2.5",children:fn.map(d=>{const b=Ze.get(d);if(!b)return null;const Z=b.costCents,ce=b.inputTokens+b.cachedInputTokens+b.outputTokens,fe=Se>0?Z/Se*100:0;return(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"font-mono text-muted-foreground w-6 shrink-0",children:d}),(0,e.jsxs)("span",{className:"text-muted-foreground font-mono flex-1",children:[I(ce)," tok"]}),(0,e.jsx)("span",{className:"font-medium tabular-nums",children:j(Z)})]}),(0,e.jsx)("div",{className:"h-2 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${fe}%`}})})]},d)})})]})]}),k>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription"}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-mono text-foreground",children:k})," runs"," · ",ke>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(ke)})," total"," · "]}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(C)})," in"," · ",(0,e.jsx)("span",{className:"font-mono text-foreground",children:I(ve)})," out"]}),h>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"h-1.5 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${h}%`}})}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[Math.round(h),"% of token usage via subscription"]})]})]})]}),n.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsx)("div",{className:"space-y-3",children:n.map(d=>{const b=d.inputTokens+d.cachedInputTokens+d.outputTokens,Z=K>0?b/K*100:0,ce=z>0?d.costCents/z*100:0;return(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono block",children:d.model}),(0,e.jsxs)("span",{className:"text-(length:--text-micro) text-muted-foreground truncate block",children:[se(d.biller)," · ",cs(d.billingType)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3 shrink-0 tabular-nums text-xs",children:[(0,e.jsxs)("span",{className:"text-muted-foreground",children:[I(b)," tok"]}),(0,e.jsx)("span",{className:"font-medium",children:j(d.costCents)})]})]}),(0,e.jsxs)("div",{className:"relative h-2 w-full border border-border overflow-hidden",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 bg-primary/60 transition-(--tp-width) duration-150",style:{width:`${Z}%`},title:`${Math.round(Z)}% of provider tokens`}),(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 bg-primary/85 transition-(--tp-width) duration-150",style:{width:`${ce}%`},title:`${Math.round(ce)}% of provider cost`})]})]},`${d.provider}:${d.model}`)})})]}),V&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription quota"}),T&&!te&&!x?(0,e.jsx)("span",{className:"text-(length:--text-nano) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:ds(T)}):null]}),R?(0,e.jsx)(jn,{}):U?.length?(0,e.jsx)(dn,{accounts:U,failed:B}):te?(0,e.jsx)(pn,{windows:v,source:T,error:c}):x?(0,e.jsx)(vn,{windows:v,source:T,error:c}):(0,e.jsxs)(e.Fragment,{children:[c?(0,e.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:Ye(v.length>0)}):null,(0,e.jsx)("div",{className:"space-y-2.5",children:v.map(d=>{const b=d.usedPercent==null?null:d.usedPercent>=90?"bg-(--status-task-blocked)":d.usedPercent>=70?"bg-(--status-task-todo)":"bg-(--status-task-done)";return(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"font-mono text-muted-foreground shrink-0",children:d.label}),(0,e.jsx)("span",{className:"flex-1"}),d.valueLabel!=null?(0,e.jsx)("span",{className:"font-medium tabular-nums",children:d.valueLabel}):d.usedPercent!=null?(0,e.jsxs)("span",{className:"font-medium tabular-nums",children:[d.usedPercent,"% used"]}):null]}),d.usedPercent!=null&&b!=null&&(0,e.jsx)("div",{className:"h-2 w-full border border-border overflow-hidden",children:(0,e.jsx)("div",{className:`h-full transition-(--tp-width) duration-150 ${b}`,style:{width:`${d.usedPercent}%`}})}),d.detail?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:d.detail}):d.resetsAt?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["resets ",new Date(d.resetsAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]}):null]},d.label)})})]})]})]})]})]})}i(Bs,"ProviderQuotaCard");function jn(){return(0,e.jsxs)("div",{className:"border border-border px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(ye,{className:"h-3 w-36"}),(0,e.jsx)(ye,{className:"h-4 w-64 max-w-full"})]}),(0,e.jsx)(ye,{className:"h-7 w-28"})]}),(0,e.jsx)("div",{className:"mt-4 space-y-3",children:Array.from({length:3}).map((t,n)=>(0,e.jsxs)("div",{className:"border border-border px-3.5 py-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(ye,{className:"h-4 w-32"}),(0,e.jsx)(ye,{className:"h-3 w-44 max-w-full"})]}),(0,e.jsx)(ye,{className:"h-4 w-20"})]}),(0,e.jsx)(ye,{className:"mt-3 h-2 w-full"})]},n))})]})}i(jn,"QuotaPanelSkeleton");var On=pt({Costs:i(()=>kn,"Costs")}),Rs="__none__";function yn(){const t=new Date,n=t.getDay(),a=n===0?-6:1-n,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()+a,0,0,0,0),l=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6,23,59,59,999);return{from:r.toISOString(),to:l.toISOString()}}i(yn,"currentWeekRange");function Nn({provider:t,rows:n}){const a=n.reduce((l,g)=>l+g.inputTokens+g.cachedInputTokens+g.outputTokens,0),r=n.reduce((l,g)=>l+g.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:se(t)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(a)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(r)})]})}i(Nn,"ProviderTabLabel");function Cn({biller:t,rows:n}){const a=n.reduce((l,g)=>l+g.inputTokens+g.cachedInputTokens+g.outputTokens,0),r=n.reduce((l,g)=>l+g.costCents,0);return(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:se(t)}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(a)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(r)})]})}i(Cn,"BillerTabLabel");function J({label:t,value:n,subtitle:a,icon:r}){return(0,e.jsx)(W,{className:"block p-4",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-(--tracking-eyebrow) text-muted-foreground",children:t}),(0,e.jsx)("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:n}),(0,e.jsx)("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:a})]}),(0,e.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border",children:(0,e.jsx)(r,{className:"h-4 w-4 text-muted-foreground"})})]})})}i(J,"MetricTile");function _s({debitCents:t,creditCents:n,netCents:a,estimatedDebitCents:r,eventCount:l}){return(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(ie,{className:"text-base",children:"Finance ledger"}),(0,e.jsx)(be,{children:"Account-level charges that do not map to a single inference request."})]}),(0,e.jsxs)(X,{className:"grid gap-3 px-5 pb-5 pt-2 sm:grid-cols-2 xl:grid-cols-4",children:[(0,e.jsx)(J,{label:"Debits",value:j(t),subtitle:`${l} total event${l===1?"":"s"} in range`,icon:as}),(0,e.jsx)(J,{label:"Credits",value:j(n),subtitle:"Refunds, offsets, and credit returns",icon:yt}),(0,e.jsx)(J,{label:"Net",value:j(a),subtitle:"Debit minus credit for the selected period",icon:rs}),(0,e.jsx)(J,{label:"Estimated",value:j(r),subtitle:"Estimated debits that are not yet invoice-authoritative",icon:ns})]})]})}i(_s,"FinanceSummaryCard");function kn({embedded:t=!1,initialTab:n="overview",lockTab:a=!1,hideBudgetsTab:r=!1}={}){const{selectedCompanyId:l}=It(),{setBreadcrumbs:g}=Et(),u=qs(),[E,U]=_t(),B=E.get("agentId"),{data:v,error:c}=q({queryKey:[...F.agents.detail(B??Rs),l],queryFn:i(()=>Lt.get(B,l),"queryFn"),enabled:!!(l&&B)}),T=v?.adapterType==="paperclip_runner"&&v.adapterConfig.provider==="muse",[R,L]=(0,p.useState)(n),[$,G]=(0,p.useState)("all"),[K,z]=(0,p.useState)("all"),w=!(t&&a&&n==="budgets"),{preset:k,setPreset:C,customFrom:ve,setCustomFrom:ke,customTo:h,setCustomTo:D,from:y,to:A,customReady:H}=Wt();(0,p.useEffect)(()=>{t||g([{label:"Costs"}])},[t,g]),(0,p.useEffect)(()=>{const s=E.get("tab");L(!a&&s&&["overview","providers","billers","finance","budgets","decisions","fast-responses"].includes(s)?s:n)},[n,a,E]);const[He,Ze]=(0,p.useState)(()=>new Date().toDateString()),Se=(0,p.useRef)(null);(0,p.useEffect)(()=>{const s=i(()=>{const o=new Date,m=new Date(o.getFullYear(),o.getMonth(),o.getDate()+1).getTime()-o.getTime();Se.current=setTimeout(()=>{Ze(new Date().toDateString()),s()},m)},"schedule");return s(),()=>{Se.current!=null&&clearTimeout(Se.current)}},[]);const te=(0,p.useMemo)(()=>yn(),[He]),x=l??Rs,V=["custom","mtd","ytd"].includes(k)&&y||void 0,d=k==="custom"?A||void 0:k,{data:b,error:Z}=q({queryKey:["cost-subscriptions",x,V,d],queryFn:i(()=>Ve.report(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),ce=i(()=>{u.invalidateQueries({queryKey:["cost-subscriptions",x]})},"invalidateSubscriptions"),fe=(0,p.useRef)(null),de=Ae({mutationFn:i(s=>Ve.refresh(s),"mutationFn"),onSuccess:i((s,o)=>{u.invalidateQueries({queryKey:["cost-subscriptions",o]})},"onSuccess")});(0,p.useEffect)(()=>{!l||!w||!b?.canRefresh||fe.current===l||(fe.current=l,de.mutate(l))},[l,w,b?.canRefresh,de.mutate]);const{data:O,isLoading:De,error:Te}=q({queryKey:F.budgets.overview(x),queryFn:i(()=>ts.overview(x),"queryFn"),enabled:!!l&&H,refetchInterval:3e4,staleTime:5e3}),Me=i(()=>{l&&(u.invalidateQueries({queryKey:F.budgets.overview(l)}),u.invalidateQueries({queryKey:F.dashboard(l)}),u.invalidateQueries({queryKey:F.agents.list(l)}),u.invalidateQueries({queryKey:F.projects.all(l)}))},"invalidateBudgetViews"),xe=Ae({mutationFn:i(({summary:s,changes:o})=>ts.upsertPolicy(x,{scopeType:s.scopeType,scopeId:s.scopeId,metric:s.metric,windowKind:s.windowKind,...o}),"mutationFn"),onSuccess:Me}),le=Ae({mutationFn:i(s=>ts.resolveIncident(x,s.incidentId,s),"mutationFn"),onSuccess:Me}),{data:N,isLoading:Q,error:us}=q({queryKey:F.costs(x,V,d),queryFn:i(async()=>{const[s,o,m,f]=await Promise.all([_.summary(x,y||void 0,A||void 0),_.byAgent(x,y||void 0,A||void 0),_.byProject(x,y||void 0,A||void 0),_.byAgentModel(x,y||void 0,A||void 0)]);return{summary:s,byAgent:o,byProject:m,byAgentModel:f}},"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),{data:Je,error:Ys}=q({queryKey:[...F.costs(x,V,d),"by-user"],queryFn:i(()=>_.byUser(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&w&&R==="overview",refetchInterval:3e4}),{data:S,isLoading:ms,error:xs}=q({queryKey:[F.financeSummary(x,V,d),F.financeByBiller(x,V,d),F.financeByKind(x,V,d),F.financeEvents(x,V,d,18)],queryFn:i(async()=>{const[s,o,m,f]=await Promise.all([_.financeSummary(x,y||void 0,A||void 0),_.financeByBiller(x,y||void 0,A||void 0),_.financeByKind(x,y||void 0,A||void 0),_.financeEvents(x,y||void 0,A||void 0,18)]);return{summary:s,byBiller:o,byKind:m,events:f}},"queryFn"),enabled:!!l&&H&&w,refetchInterval:3e4}),[Hs,ps]=(0,p.useState)(new Set);(0,p.useEffect)(()=>{ps(new Set)},[x,k,ve,h]);function Zs(s){ps(o=>{const m=new Set(o);return m.has(s)?m.delete(s):m.add(s),m})}i(Zs,"toggleAgent");const Js=(0,p.useMemo)(()=>{const s=new Map;for(const o of N?.byAgentModel??[]){const m=s.get(o.agentId)??[];m.push(o),s.set(o.agentId,m)}for(const[o,m]of s)s.set(o,m.slice().sort((f,P)=>P.costCents-f.costCents));return s},[N?.byAgentModel]),{data:Fe,error:Xs}=q({queryKey:F.usageByProvider(x,V,d),queryFn:i(()=>_.byProvider(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&(R==="providers"||R==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:hs,error:et}=q({queryKey:F.usageByBiller(x,V,d),queryFn:i(()=>_.byBiller(x,y||void 0,A||void 0),"queryFn"),enabled:!!l&&H&&R==="billers",refetchInterval:3e4,staleTime:1e4}),{data:gs,error:st}=q({queryKey:F.usageByProvider(x,te.from,te.to),queryFn:i(()=>_.byProvider(x,te.from,te.to),"queryFn"),enabled:!!l&&(R==="providers"||R==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:bs,error:tt}=q({queryKey:F.usageByBiller(x,te.from,te.to),queryFn:i(()=>_.byBiller(x,te.from,te.to),"queryFn"),enabled:!!l&&R==="billers",refetchInterval:3e4,staleTime:1e4}),{data:vs,error:nt}=q({queryKey:F.usageWindowSpend(x),queryFn:i(()=>_.windowSpend(x),"queryFn"),enabled:!!l&&R==="providers",refetchInterval:3e4,staleTime:1e4}),{data:pe,isLoading:fs,error:Be}=q({queryKey:F.usageQuotaWindows(x),queryFn:i(()=>_.quotaWindows(x),"queryFn"),structuralSharing:i((s,o)=>cn(s,o),"structuralSharing"),enabled:!!l&&R==="providers",refetchInterval:3e5,staleTime:6e4}),ne=(0,p.useMemo)(()=>{const s=new Map;for(const o of Fe??[]){const m=s.get(o.provider)??[];m.push(o),s.set(o.provider,m)}return s},[Fe]),ue=(0,p.useMemo)(()=>{const s=new Map;for(const o of hs??[]){const m=s.get(o.biller)??[];m.push(o),s.set(o.biller,m)}return s},[hs]),js=(0,p.useMemo)(()=>{const s=new Map;for(const o of gs??[])s.set(o.provider,(s.get(o.provider)??0)+o.costCents);return s},[gs]),ys=(0,p.useMemo)(()=>{const s=new Map;for(const o of bs??[])s.set(o.biller,(s.get(o.biller)??0)+o.costCents);return s},[bs]),Ns=(0,p.useMemo)(()=>{const s=new Map;for(const o of vs??[]){const m=s.get(o.provider)??[];m.push(o),s.set(o.provider,m)}return s},[vs]),Cs=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])o.windows.length>0&&s.set(o.provider,o.windows);return s},[pe]),ks=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])o.ok||s.set(o.provider,"unavailable");return Be&&(s.set("anthropic","unavailable"),s.set("openai","unavailable")),s},[pe,Be]),Ss=(0,p.useMemo)(()=>{const s=new Map;for(const o of pe??[])typeof o.source=="string"&&o.source.length>0&&s.set(o.provider,o.source);return s},[pe]),Ts=(0,p.useMemo)(()=>{const s=new Map;if(k!=="mtd")return s;const o=N?.summary.budgetCents??0;if(o<=0)return s;const m=new Date,f=m.getUTCDate(),P=new Date(Date.UTC(m.getUTCFullYear(),m.getUTCMonth()+1,0)).getUTCDate();for(const[ae,Y]of ne){const Is=Y.reduce((ut,mt)=>ut+mt.costCents,0),dt=Is/Math.max(f,1);s.set(ae,Is+dt*(P-f)>o)}return s},[k,N,ne]),Re=(0,p.useMemo)(()=>Array.from(ne.keys()),[ne]),_e=(0,p.useMemo)(()=>Array.from(ue.keys()),[ue]),Ue=$==="all"||Re.includes($)?$:"all";(0,p.useEffect)(()=>{Ue!==$&&G("all")},[Ue,$]);const Le=K==="all"||_e.includes(K)?K:"all";(0,p.useEffect)(()=>{Le!==K&&z("all")},[Le,K]);const at=(0,p.useMemo)(()=>{const s=Array.from(ne.keys()),o=s.reduce((f,P)=>f+(ne.get(P)?.reduce((ae,Y)=>ae+Y.inputTokens+Y.cachedInputTokens+Y.outputTokens,0)??0),0),m=s.reduce((f,P)=>f+(ne.get(P)?.reduce((ae,Y)=>ae+Y.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All providers"}),s.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(o)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(m)})]}):null]})},...s.map(f=>({value:f,label:(0,e.jsx)(Nn,{provider:f,rows:ne.get(f)??[]})}))]},[ne]),rt=(0,p.useMemo)(()=>{const s=Array.from(ue.keys()),o=s.reduce((f,P)=>f+(ue.get(P)?.reduce((ae,Y)=>ae+Y.inputTokens+Y.cachedInputTokens+Y.outputTokens,0)??0),0),m=s.reduce((f,P)=>f+(ue.get(P)?.reduce((ae,Y)=>ae+Y.costCents,0)??0),0);return[{value:"all",label:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{children:"All billers"}),s.length>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:I(o)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:j(m)})]}):null]})},...s.map(f=>({value:f,label:(0,e.jsx)(Cn,{biller:f,rows:ue.get(f)??[]})}))]},[ue]),it=S?.events??[],Ee=O?.policies??[],he=O?.activeIncidents??[],ot=(0,p.useMemo)(()=>({company:Ee.filter(s=>s.scopeType==="company"),agent:Ee.filter(s=>s.scopeType==="agent"),project:Ee.filter(s=>s.scopeType==="project")}),[Ee]);if(!l)return(0,e.jsx)(Ut,{icon:Xe,message:"Select an organization to view costs."});const Ie=k==="custom"&&!H,lt=Q&&H,ct=!N&&us;return(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-6",children:[c&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load agent details. Totals below show recorded organization costs."}),T&&(0,e.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:[v.name,"'s Muse activity has no reported usage or cost. Totals below show recorded organization charges only. Microvac cannot enforce a Muse spend ceiling."]}),w?(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,e.jsx)("div",{children:t?(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Costs"}):(0,e.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Costs"})}),(0,e.jsx)("div",{"data-canonical-toolbar":"cost-range",role:"toolbar","aria-label":"Cost date range",className:"flex flex-wrap items-center gap-2",children:Gt.map(s=>(0,e.jsx)(ee,{variant:k===s?"secondary":"ghost",size:"sm",onClick:i(()=>C(s),"onClick"),"aria-pressed":k===s,children:Qt[s]},s))})]}),k==="custom"?(0,e.jsxs)("div",{"data-canonical-toolbar":"cost-dates",className:"flex flex-wrap items-center gap-2 border border-border p-3",children:[(0,e.jsx)("input",{type:"date",value:ve,onChange:i(s=>ke(s.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"to"}),(0,e.jsx)("input",{type:"date",value:h,onChange:i(s=>D(s.target.value),"onChange"),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"})]}):null,S?.summary.currencies?.some(s=>s.currency!=="USD")&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Finance headline totals are USD only. Other currencies are listed separately; no exchange-rate conversion is applied."}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-5",children:[(0,e.jsx)(J,{label:"API spend",value:b?b.api.unpricedEventCount===b.api.eventCount&&b.api.eventCount>0?"—":j(Number(b.api.costCents)):"—",subtitle:b?(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(Ot,{eventCount:b.api.eventCount,estimatedEventCount:b.api.estimatedEventCount}),(0,e.jsx)("div",{children:(0,e.jsx)(is,{usage:b.api})})]}):Z?"API usage is unavailable":"API usage is loading",icon:Xe}),(0,e.jsx)(en,{companyId:x,report:b,error:Z,onChanged:ce},x),(0,e.jsx)(J,{label:"Budget",value:he.length>0?String(he.length):N?.summary.budgetCents&&N.summary.budgetCents>0?k==="mtd"?`${N.summary.utilizationPercent}%`:j(N.summary.budgetCents):"Open",subtitle:he.length>0?`${O?.pausedAgentCount??0} agents paused · ${O?.pausedProjectCount??0} projects paused`:N?.summary.budgetCents&&N.summary.budgetCents>0?k==="mtd"?`${j(N.summary.spendCents)} of ${j(N.summary.budgetCents)} this month`:"Monthly limit":"No monthly cap configured",icon:ns}),(0,e.jsx)(J,{label:"Recorded charges",value:S?j(S.summary.netCents):"—",subtitle:S?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"block whitespace-nowrap",children:[j(S.summary.debitCents)," debits"]}),(0,e.jsxs)("span",{className:"block whitespace-nowrap",children:[j(S.summary.creditCents)," credits"]})]}):"Financial data unavailable",icon:rs}),(0,e.jsx)(J,{label:"Finance events",value:S?String(S.summary.eventCount):"—",subtitle:S?`${j(S.summary.estimatedDebitCents)} estimated in range`:"Financial data unavailable",icon:as})]}),b&&Number(b.subscription.costCents)>0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Subscription accounts also have ",j(Number(b.subscription.costCents))," in recorded usage charges for this period, separate from monthly fees."]}),b&&b.unknown.eventCount>0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Other billing usage: ",I(b.unknown.inputTokens+b.unknown.cachedInputTokens+b.unknown.outputTokens)," tokens",Number(b.unknown.costCents)>0?` · ${j(Number(b.unknown.costCents))} in recorded charges`:"",", included in the inference ledger."]}),Z&&b&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Showing the last loaded API and subscription usage. Updates will resume automatically."}),de.error&&(0,e.jsxs)("div",{role:"status",className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,e.jsx)("p",{children:"Connected accounts could not be checked. Existing subscription estimates are still shown."}),b?.canRefresh&&(0,e.jsx)(ee,{variant:"outline",size:"sm",disabled:de.isPending,onClick:i(()=>de.mutate(x),"onClick"),children:"Retry account check"})]}),R==="overview"&&N&&(N.summary.unpricedEventCount>0||N.summary.pendingRunCount>0||(N.summary.unknownBillingEventCount??0)>0)&&(0,e.jsx)(nn,{companyId:x,from:y||void 0,to:A||void 0,reportKey:F.costs(x,V,d),unpricedCount:N.summary.unpricedEventCount,pendingCount:N.summary.pendingRunCount,unknownBillingCount:N.summary.unknownBillingEventCount??0},`${x}:${V}:${d}`)]}):null,Te&&!O?(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Budget data could not be loaded. Please try again shortly."}):null,N&&us||S&&xs||O&&Te||Xs||et||st||tt||nt?(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Showing the last loaded data. Updates will resume automatically."}):null,le.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not update the budget. Check any pending runs or unpriced usage shown on this page, then try again."}),(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:R,onValueChange:i(s=>{L(s),U(o=>{const m=new URLSearchParams(o);return m.set("tab",s),m},{replace:!0})},"onValueChange"),children:[a?null:(0,e.jsx)("div",{className:"max-w-full overflow-x-auto pb-2",children:(0,e.jsxs)(Dt,{variant:"line",className:"justify-start",children:[(0,e.jsx)(je,{value:"overview",children:"Overview"}),r?null:(0,e.jsx)(je,{value:"budgets",children:"Budgets"}),(0,e.jsx)(je,{value:"providers",children:"Providers"}),(0,e.jsx)(je,{value:"billers",children:"Billers"}),(0,e.jsx)(je,{value:"finance",children:"Finance"}),(0,e.jsx)(je,{value:"decisions",children:"Decisions"}),(0,e.jsx)(je,{value:"fast-responses",children:"Fast responses"})]})}),(0,e.jsx)(re,{value:"fast-responses",className:"mt-4 min-w-0 max-w-full",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(Jt,{companyId:x,from:y,to:A})}),(0,e.jsx)(re,{value:"decisions",className:"mt-4 min-w-0 max-w-full",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(Zt,{companyId:x,from:y,to:A})}),(0,e.jsx)(re,{value:"overview",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):lt?(0,e.jsx)(ss,{variant:"costs"}):ct?(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Cost data could not be loaded. Please try again shortly."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"grid min-w-0 gap-4 xl:grid-cols-(--gtc-32)",children:[(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-4",children:[(0,e.jsxs)(W,{className:"gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By agent"})}),(0,e.jsx)(X,{className:"space-y-2 px-5",children:(N?.byAgent.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events yet."}):N?.byAgent.map(s=>{const o=Js.get(s.agentId)??[],m=Hs.has(s.agentId),f=o.length>0;return(0,e.jsxs)("div",{role:"group","aria-label":`${s.agentName??s.agentId??"Microvac services"} costs`,className:"border border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:$e("flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",f?"cursor-pointer select-none":""),onClick:i(()=>f&&Zs(s.agentId),"onClick"),children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[f?m?(0,e.jsx)(Os,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)(Qs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):(0,e.jsx)("span",{className:"h-3 w-3 shrink-0"}),s.agentId?(0,e.jsx)(Tt,{agent:{id:s.agentId,name:s.agentName??s.agentId,appearance:s.agentAppearance},size:"sm"}):(0,e.jsx)("span",{className:"font-medium",children:"Microvac services"}),s.agentStatus==="terminated"?(0,e.jsx)(jt,{status:"terminated"}):null]}),(0,e.jsxs)("div",{className:"text-right text-sm tabular-nums",children:[(0,e.jsx)(we,{costCents:s.costCents,eventCount:s.eventCount,estimatedEventCount:s.estimatedEventCount}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["in ",I(s.inputTokens+s.cachedInputTokens)," (",I(s.cachedInputTokens)," cached) · out ",I(s.outputTokens)]}),s.apiRunCount>0||s.subscriptionRunCount>0?(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["runs: ",s.apiRunCount>0?`${s.apiRunCount} api`:"0 api"," · ",s.subscriptionRunCount>0?`${s.subscriptionRunCount} sub`:"0 sub"]}):null]})]}),m&&o.length>0?(0,e.jsx)("div",{className:"mt-3 space-y-2 border-l border-border pl-4",children:o.map(P=>{const ae=s.costCents>0?Math.round(P.costCents/s.costCents*100):0;return(0,e.jsxs)("div",{className:"flex flex-col gap-2 text-xs sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate font-medium text-foreground",children:[se(P.provider),(0,e.jsx)("span",{className:"mx-1 text-border",children:"/"}),(0,e.jsx)("span",{className:"font-mono",children:P.model})]}),(0,e.jsxs)("div",{className:"truncate text-muted-foreground",children:[se(P.biller)," · ",cs(P.billingType)]})]}),(0,e.jsxs)("div",{className:"text-right tabular-nums",children:[(0,e.jsx)(we,{costCents:P.costCents,eventCount:P.eventCount,estimatedEventCount:P.estimatedEventCount,suffix:(0,e.jsxs)("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",ae,"%)"]})}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[I(P.inputTokens+P.cachedInputTokens+P.outputTokens)," tok"]})]})]},`${P.provider}:${P.model}:${P.billingType}`)})}):null]},s.agentId??"services")})})]}),Ys&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:Je?"User costs could not be refreshed. Showing the last loaded data.":"User costs could not be loaded. Please try again shortly."}),Je&&(0,e.jsx)(sn,{report:Je})]}),(0,e.jsx)("div",{className:"min-w-0 max-w-full space-y-4",children:(0,e.jsxs)(W,{className:"gap-3 py-4",children:[(0,e.jsx)(oe,{className:"gap-0 px-5",children:(0,e.jsx)(ie,{className:"text-base",children:"By project"})}),(0,e.jsx)(X,{className:"space-y-2 px-5",children:(N?.byProject.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No project-attributed run costs yet."}):N?.byProject.map((s,o)=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2 text-sm",children:[(0,e.jsx)("span",{className:"truncate",children:s.projectName??s.projectId??"Unattributed"}),(0,e.jsx)(we,{costCents:s.costCents,eventCount:s.eventCount,estimatedEventCount:s.estimatedEventCount})]},s.projectId??`unattributed-${o}`))})]})})]}),he.length>0?(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:he.slice(0,2).map(s=>(0,e.jsx)(Ms,{incident:s,isMutating:le.isPending,onKeepPaused:i(()=>le.mutate({incidentId:s.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:i(o=>le.mutate({incidentId:s.id,action:"raise_budget_and_resume",amount:o}),"onRaiseAndResume")},s.id))}):null,S?(0,e.jsx)(_s,{debitCents:S.summary.debitCents,creditCents:S.summary.creditCents,netCents:S.summary.netCents,estimatedDebitCents:S.summary.estimatedDebitCents,eventCount:S.summary.eventCount}):(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:ms?"Loading financial events…":"Financial events could not be loaded. Please try again shortly."})]})}),(0,e.jsxs)(re,{value:"budgets",className:"mt-4 min-w-0 max-w-full space-y-4",children:[xe.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not update the budget policy. Review your settings and try again."}),De?(0,e.jsx)(ss,{variant:"costs"}):Te&&!O?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(W,{className:"border-border/70 bg-(image:--gradient-extract-2)",children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-3",children:[(0,e.jsx)(ie,{className:"text-base",children:"Budget control plane"}),(0,e.jsx)(be,{children:"Hard-stop spend limits for agents and projects. Provider subscription quota stays separate and appears under Providers."})]}),(0,e.jsxs)(X,{className:"grid gap-3 px-5 pb-5 pt-0 md:grid-cols-4",children:[(0,e.jsx)(J,{label:"Active incidents",value:String(he.length),subtitle:"Open soft or hard threshold crossings",icon:rs}),(0,e.jsx)(J,{label:"Pending approvals",value:String(O?.pendingApprovalCount??0),subtitle:"Budget override approvals awaiting board action",icon:as}),(0,e.jsx)(J,{label:"Paused agents",value:String(O?.pausedAgentCount??0),subtitle:"Agent heartbeats blocked by budget",icon:ns}),(0,e.jsx)(J,{label:"Paused projects",value:String(O?.pausedProjectCount??0),subtitle:"Project execution blocked by budget",icon:Xe})]})]}),he.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Active incidents"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Raise the budget or keep a hard stop paused. Dismiss a warning when no action is needed."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:he.map(s=>(0,e.jsx)(Ms,{incident:s,isMutating:le.isPending,onKeepPaused:i(()=>le.mutate({incidentId:s.id,action:"keep_paused"}),"onKeepPaused"),onRaiseAndResume:i(o=>le.mutate({incidentId:s.id,action:"raise_budget_and_resume",amount:o}),"onRaiseAndResume")},s.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-5",children:[["company","agent","project"].map(s=>{const o=ot[s];return o.length===0?null:(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h2",{className:"text-lg font-semibold capitalize",children:[s==="company"?"organization":s," budgets"]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:s==="company"?"Organization-wide monthly policy.":s==="agent"?"Recurring monthly spend policies for individual agents.":"Lifetime spend policies for execution-bound projects."})]}),(0,e.jsx)("div",{className:"grid gap-4 xl:grid-cols-2",children:o.map(m=>(0,e.jsx)(ft,{summary:m,onReservationChange:i(f=>xe.mutate({summary:m,changes:{reservationCents:f}}),"onReservationChange"),onUnpricedUsagePolicyChange:i(f=>xe.mutate({summary:m,changes:{unpricedUsagePolicy:f}}),"onUnpricedUsagePolicyChange"),isSaving:xe.isPending,onSave:i(f=>xe.mutate({summary:m,changes:{amount:f}}),"onSave")},m.policyId))})]},s)}),Ee.length===0?(0,e.jsx)(W,{children:(0,e.jsx)(X,{className:"px-5 py-8 text-sm text-muted-foreground",children:"No budget policies yet. Set agent and project budgets from their detail pages, or use the existing organization monthly budget control."})}):null]})]})]}),(0,e.jsx)(re,{value:"providers",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:Ue,onValueChange:G,children:[(0,e.jsx)(As,{items:at,value:Ue,onValueChange:G}),(0,e.jsx)(re,{value:"all",className:"mt-4",children:Re.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No cost events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Re.map(s=>(0,e.jsx)(Bs,{provider:s,rows:ne.get(s)??[],budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,weekSpendCents:js.get(s)??0,windowRows:Ns.get(s)??[],showDeficitNotch:Ts.get(s)??!1,quotaAccounts:pe?.filter(o=>o.provider===s),quotaRequestFailed:!!Be,quotaWindows:Cs.get(s)??[],quotaError:ks.get(s)??null,quotaSource:Ss.get(s)??null,quotaLoading:fs},s))})}),Re.map(s=>(0,e.jsx)(re,{value:s,className:"mt-4",children:(0,e.jsx)(Bs,{provider:s,rows:ne.get(s)??[],budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,weekSpendCents:js.get(s)??0,windowRows:Ns.get(s)??[],showDeficitNotch:Ts.get(s)??!1,quotaAccounts:pe?.filter(o=>o.provider===s),quotaRequestFailed:!!Be,quotaWindows:Cs.get(s)??[],quotaError:ks.get(s)??null,quotaSource:Ss.get(s)??null,quotaLoading:fs})},s))]})})}),(0,e.jsx)(re,{value:"billers",className:"mt-4 min-w-0 max-w-full space-y-4",children:Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)(es,{className:"min-w-0 max-w-full",value:Le,onValueChange:z,children:[(0,e.jsx)(As,{items:rt,value:Le,onValueChange:z}),(0,e.jsx)(re,{value:"all",className:"mt-4",children:_e.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No billable events in this period."}):(0,e.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:_e.map(s=>{const o=(ue.get(s)??[])[0];if(!o)return null;const m=(Fe??[]).filter(f=>f.biller===s);return(0,e.jsx)($s,{row:o,weekSpendCents:ys.get(s)??0,budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,providerRows:m},s)})})}),_e.map(s=>{const o=(ue.get(s)??[])[0];if(!o)return null;const m=(Fe??[]).filter(f=>f.biller===s);return(0,e.jsx)(re,{value:s,className:"mt-4",children:(0,e.jsx)($s,{row:o,weekSpendCents:ys.get(s)??0,budgetMonthlyCents:N?.summary.budgetCents??0,showBudgetUtilization:k==="mtd",totalCompanySpendCents:N?.summary.spendCents??0,providerRows:m})},s)})]})})}),(0,e.jsxs)(re,{value:"finance",className:"mt-4 min-w-0 max-w-full space-y-4",children:[S?.summary.providerReportedCentsExact!==void 0&&(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Provider API cost reports: ",j(S.summary.providerReportedCents??0),". Report totals overlap invoices and run estimates and are shown separately from recorded charges."]}),Ie?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):ms?(0,e.jsx)(ss,{variant:"costs"}):xs&&!S?(0,e.jsx)("p",{className:"text-sm text-destructive",children:"Financial events could not be loaded. Please try again shortly."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(_s,{debitCents:S?.summary.debitCents??0,creditCents:S?.summary.creditCents??0,netCents:S?.summary.netCents??0,estimatedDebitCents:S?.summary.estimatedDebitCents??0,eventCount:S?.summary.eventCount??0}),(0,e.jsxs)("div",{className:"grid min-w-0 gap-4 xl:grid-cols-(--gtc-33)",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,e.jsxs)(W,{children:[(0,e.jsxs)(oe,{className:"px-5 pt-5 pb-2",children:[(0,e.jsx)(ie,{className:"text-base",children:"By biller"}),(0,e.jsx)(be,{children:"Account-level financial events grouped by who charged or credited them."})]}),(0,e.jsx)(X,{className:"grid gap-4 px-5 pb-5 pt-2 md:grid-cols-2",children:(S?.byBiller.length??0)===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No finance events yet."}):S?.byBiller.map(s=>(0,e.jsx)(an,{row:s},`${s.biller}:${s.currency}`))})]}),(0,e.jsx)(on,{rows:it})]}),(0,e.jsx)(rn,{rows:S?.byKind??[]})]})]})]})]})]})}i(kn,"Costs");export{On as n,kn as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var n=(t,s)=>u(t,"name",{value:s,configurable:!0});import{a as m}from"./rolldown-runtime-DhZMWcEn.js";import{G as b,Mi as x,N as p,P as d}from"./issue-detail-
|
|
1
|
+
var u=Object.defineProperty;var n=(t,s)=>u(t,"name",{value:s,configurable:!0});import{a as m}from"./rolldown-runtime-DhZMWcEn.js";import{G as b,Mi as x,N as p,P as d}from"./issue-detail-CZfjXs0M.js";import{$A as g,E_ as f,Fb as j,Mb as w,Pb as y,zE as N}from"./index-BJtnP7H1.js";var e=m(g(),1);function l({index:t,title:s,description:a,children:c,columns:h=2}){return(0,e.jsxs)("section",{className:"rounded-2xl border border-border/70 bg-background/85 p-5 shadow-sm",children:[(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:t}),(0,e.jsx)("h2",{className:"mt-1 text-base font-semibold text-foreground",children:s}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a})]}),(0,e.jsx)("div",{className:N("grid gap-4",h===2&&"lg:grid-cols-2"),children:c})]})}n(l,"LabSection");function r({label:t,children:s}){return(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:t}),(0,e.jsx)(f,{className:"block border-border/60 p-3",children:s})]})}n(r,"Frame");function o({authorName:t,onBehalfOf:s,body:a}){return(0,e.jsxs)("div",{className:"flex flex-col items-start py-1.5",children:[(0,e.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 px-1",children:[(0,e.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,e.jsx)(y,{size:"sm",className:"size-5",children:(0,e.jsx)(j,{className:"text-(length:--text-nano)",children:t.slice(0,2).toUpperCase()})})}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:t}),s?(0,e.jsx)(b,{agentName:t,userName:s}):null]}),(0,e.jsx)("div",{className:"min-w-0 max-w-(--pct-85) break-words border border-border bg-card px-3 py-2 text-sm text-foreground [border-radius:14px_14px_14px_4px]",children:a})]})}n(o,"AgentCommentBubble");function i({actorName:t,verb:s,children:a}){return(0,e.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(w,{name:t,size:"sm"}),(0,e.jsx)("span",{children:s}),(0,e.jsx)("span",{className:"ml-auto shrink-0",children:"2m ago"})]}),a]})}n(i,"ActivityRow");var v=new Map([["3108ef8e-5ed0-41d9-b561-6b41c41b8545","ClaudeCoder"],["6670e11b-91d3-4429-82e0-436b88b51808","UXDesigner"]]);function I(){const t=n(a=>v.get(a)??null,"resolveAgentLabel"),s=n(a=>a==="user-dotta"?"Dotta":null,"resolveUserLabel");return(0,e.jsx)("div",{className:"min-h-screen bg-muted/20 p-6",children:(0,e.jsxs)("div",{className:"mx-auto max-w-5xl space-y-6",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Open cross-task collaboration"}),(0,e.jsx)("h1",{className:"mt-1 text-xl font-semibold text-foreground",children:"Open cross-task collaboration — attribution, audit, and denial copy"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agents may now write to any task they can read. These are the three surfaces that keep that legible: whose authority a comment rode, what an edit changed, and — when a write is refused — which boundary fired and what to do instead."})]}),(0,e.jsxs)(l,{index:"1 · Attribution chip (plan §3a)",title:"“Fable · for Dotta” on a cross-task agent comment",description:"An agent commenting on a task it is not assigned to names the responsible user whose authority it rode. The assignee's own comments stay unchipped — that is the ordinary case, and chipping every bubble would be noise.",children:[(0,e.jsx)(r,{label:"Assignee's own comment — no chip",children:(0,e.jsx)(o,{authorName:"CodexCoder",body:"Rebased onto master and re-ran the containment suite; all green."})}),(0,e.jsx)(r,{label:"Cross-task comment — chipped",children:(0,e.jsx)(o,{authorName:"Fable",onBehalfOf:"Dotta",body:"Dotta asked me to flag that the retry window here overlaps TASK-482. Worth a look before you close this."})}),(0,e.jsx)(r,{label:"Responsible user not in the loaded directory",children:(0,e.jsx)(o,{authorName:"Fable",onBehalfOf:"the responsible user",body:"Falls back to a generic label rather than printing a raw user id."})}),(0,e.jsx)(r,{label:"Long user name truncates in the chip",children:(0,e.jsx)(o,{authorName:"Fable",onBehalfOf:"Alexandra Konstantinopoulos-Whitfield",body:"The chip caps its width and truncates; the tooltip carries the full name."})})]}),(0,e.jsxs)(l,{index:"2 · Field-edit audit receipt (plan §3b)",title:"Every PATCH says who changed what, and under which authorization",description:"Required for agent and board edits alike. Before/after per field, the responsible user behind the write, and the authorization reason that let it through.",children:[(0,e.jsx)(r,{label:"Cross-task agent edit",children:(0,e.jsx)(i,{actorName:"Fable",verb:"changed the status from todo to in progress",children:(0,e.jsx)(d,{event:{action:"issue.updated",responsibleUserId:"user-dotta",details:{authorizationReason:"allow_visible_issue_write",changes:{status:{from:"todo",to:"in_progress"},priority:{from:"medium",to:"high"}}}},resolveAgentLabel:t,resolveUserLabel:s})})}),(0,e.jsx)(r,{label:"Board (human) edit — audited the same way",children:(0,e.jsx)(i,{actorName:"Dotta",verb:"updated the issue",children:(0,e.jsx)(d,{event:{action:"issue.updated",responsibleUserId:"user-dotta",details:{authorizationReason:"allow_board_actor",changes:{assigneeAgentId:{from:"3108ef8e-5ed0-41d9-b561-6b41c41b8545",to:"6670e11b-91d3-4429-82e0-436b88b51808"},description:{from:"Old brief…",to:"New brief…",updated:!0}}}},resolveAgentLabel:t,resolveUserLabel:s})})}),(0,e.jsx)(r,{label:"Reassignment, blockers, and work mode in one write",children:(0,e.jsx)(i,{actorName:"CTO",verb:"updated the issue",children:(0,e.jsx)(d,{event:{action:"issue.updated",responsibleUserId:"user-dotta",details:{authorizationReason:"allow_visible_issue_write",changes:{blockedByIssueIds:{from:[],to:["TASK-491","TASK-492"]},workMode:{from:"planning",to:"standard"},assigneeAgentId:{from:null,to:"3108ef8e-5ed0-41d9-b561-6b41c41b8545"}}}},resolveAgentLabel:t,resolveUserLabel:s})})}),(0,e.jsx)(r,{label:"Older activity row — no receipt, renders unchanged",children:(0,e.jsx)(i,{actorName:"CodexCoder",verb:"checked out the issue"})})]}),(0,e.jsxs)(l,{index:"3 · Actionable denial copy (plan §6)",title:"Every wall names the boundary, who can act, and the sanctioned path",description:"A real incident burned a full detour discovering a workaround behind an opaque 403. These are all the ways an issue write can now be refused — the same copy the API error body carries.",columns:1,children:[(0,e.jsx)(r,{label:"Before — what the incident actually saw",children:(0,e.jsxs)("div",{className:"text-xs",children:[(0,e.jsx)("span",{className:"text-red-600 dark:text-red-400",children:"403 Forbidden: Issue is outside this actor's authorization boundary"}),(0,e.jsx)("p",{className:"mt-1 text-muted-foreground",children:"No boundary named, nobody named, no path forward. The workaround (create a child issue) had to be discovered by trial and error."})]})}),x.map(a=>(0,e.jsx)(r,{label:`After — ${a}`,children:(0,e.jsx)(p,{code:a,context:{actorLabel:"Fable",assigneeLabel:"CodexCoder",responsibleUserName:"Dotta",issueIdentifier:"TASK-482",cap:20,count:21}})},a))]})]})})}n(I,"CrossIssueCollaborationUxLab");export{I as CrossIssueCollaborationUxLab,I as default};
|