@protobase/ui 0.123.1 → 0.123.3
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/account/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/conversation-page/messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-edit/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/new-version/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/data/use-live-updates.d.ts +1 -1
- package/dist/data/use-live-updates.js +3 -1
- package/dist/data-grid/column-spec.d.ts +1 -1
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/format/messages.d.ts +2 -2
- package/dist/forms/messages.d.ts +2 -2
- package/dist/inline-child-table/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/live/messages.d.ts +2 -2
- package/dist/mailbox/messages.d.ts +2 -2
- package/dist/mentions/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +1 -1
- package/dist/mocks/invoices.d.ts +2 -2
- package/dist/mocks/orders.d.ts +1 -1
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/relay/relay-store.d.ts +2 -0
- package/dist/relay/relay-store.js +6 -0
- package/dist/shell/assets/{account-page-DS2lZVD1.js → account-page-IZQQcp3C.js} +2 -2
- package/dist/shell/assets/{app-1IZYQXW2.js → app-CgllsYQy.js} +5 -5
- package/dist/shell/assets/{assistant-shell-BIpWuqnT.js → assistant-shell-ClWlf9GV.js} +2 -2
- package/dist/shell/assets/{board-display-Buo0YyZ5.js → board-display-DhHkhSdi.js} +2 -2
- package/dist/shell/assets/{calendar-display-10AgoW3N.js → calendar-display-C_X68Umc.js} +2 -2
- package/dist/shell/assets/{call-rings-BUUwC1QU.js → call-rings-B0-gGLW5.js} +2 -2
- package/dist/shell/assets/{calls-eQ3_Fp6k.js → calls-VTUC3xS7.js} +2 -2
- package/dist/shell/assets/{circle-alert-D7B_KeB7.js → circle-alert-D8UYAgz6.js} +2 -2
- package/dist/shell/assets/{composed-page-Btkd6u0m.js → composed-page-FL2hq-qi.js} +2 -2
- package/dist/shell/assets/{composer-section-DUmPQLgo.js → composer-section-DBsqoWhe.js} +2 -2
- package/dist/shell/assets/{connect-route-DQIlzdmb.js → connect-route-DI8OFx4L.js} +2 -2
- package/dist/shell/assets/{copy-field-BfYo47Io.js → copy-field-DBuqCBWo.js} +2 -2
- package/dist/shell/assets/{create-route-CSTAtNAw.js → create-route-CCx6gOjR.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-Dxltzn8J.js → custom-step-container-field-tmox-exj.js} +2 -2
- package/dist/shell/assets/{embedded-list-7l7TUHug.js → embedded-list-BIvz_g-b.js} +3 -3
- package/dist/shell/assets/{export-dialog-DWcXdfEj.js → export-dialog-cqfMEBd7.js} +2 -2
- package/dist/shell/assets/{first-organization-page-77PHesxY.js → first-organization-page-CC7DrhYu.js} +2 -2
- package/dist/shell/assets/{graph-view-DQOQDrmJ.js → graph-view-DRWl6A2P.js} +2 -2
- package/dist/shell/assets/{group-donut-BGfuQ6iU.js → group-donut-D1l1-O4a.js} +2 -2
- package/dist/shell/assets/{guest-call-page-BdV2Hwhv.js → guest-call-page-BLh17iiD.js} +3 -3
- package/dist/shell/assets/{html-viewer-CXABej3u.js → html-viewer-BeLoV4vw.js} +2 -2
- package/dist/shell/assets/{import-dialog-Cqu_xO6L.js → import-dialog-CwnPFP3s.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-MwfAiAmM.js → import-table-dialog-D__S72Yl.js} +2 -2
- package/dist/shell/assets/{index-DJQ4glyU.js → index-Nvo-_PXE.js} +1 -1
- package/dist/shell/assets/{invitations-page-C6LjToJR.js → invitations-page-MQ6ujhc1.js} +2 -2
- package/dist/shell/assets/{layout-grid-C_uTX3Tb.js → layout-grid-B4X2fG6K.js} +2 -2
- package/dist/shell/assets/{legend-item-DzqFlC4D.js → legend-item-BoMo0Yub.js} +2 -2
- package/dist/shell/assets/{list-page-CTGtveKF.js → list-page-BceXf9dP.js} +4 -4
- package/dist/shell/assets/{maplibre-aCJmOb1H.js → maplibre-BZGHDnqB.js} +2 -2
- package/dist/shell/assets/{markdown-content-CDmFTB6r.js → markdown-content-CB2LNHPp.js} +2 -2
- package/dist/shell/assets/{members-page-Defqhu24.js → members-page-DnPAIXBn.js} +2 -2
- package/dist/shell/assets/{message-content-CeLDUud8.js → message-content-C6ld-XsS.js} +2 -2
- package/dist/shell/assets/{messages-XnV72On0.js → messages-CWURrUB-.js} +2 -2
- package/dist/shell/assets/{organization-page-Cdfaqvsh.js → organization-page-DnmV85sX.js} +2 -2
- package/dist/shell/assets/{organizations-page-C37kxzUq.js → organizations-page-CKJB2qGB.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-Cyu7Ucej.js → pending-invitation-row-DAXBo7SZ.js} +2 -2
- package/dist/shell/assets/{period-chart-T4rBI9Y2.js → period-chart-CbzGqkpY.js} +2 -2
- package/dist/shell/assets/{person-row-DjxZAaa3.js → person-row-BNM1LeOM.js} +2 -2
- package/dist/shell/assets/{public-form-page-DaPFaXOT.js → public-form-page-BTILqkb8.js} +2 -2
- package/dist/shell/assets/{record-lines-CSeqYQnm.js → record-lines-BuGPIPkM.js} +2 -2
- package/dist/shell/assets/{record-map-l-E3DvxV.js → record-map-H5uvOI5d.js} +2 -2
- package/dist/shell/assets/{record-opens-DPMtZw1p.js → record-opens-BLwJhTqE.js} +2 -2
- package/dist/shell/assets/{record-page-DK2-zwXx.js → record-page-CCfn7bkb.js} +3 -3
- package/dist/shell/assets/{record-preview-0BdCZkO9.js → record-preview-CWciJJ5e.js} +2 -2
- package/dist/shell/assets/{records-map-DSg2fbqb.js → records-map-CPYxm3fv.js} +2 -2
- package/dist/shell/assets/{render-node-qPc-4XAK.js → render-node-BiDgPc8P.js} +3 -3
- package/dist/shell/assets/{reorder-button-Z_evPIxl.js → reorder-button-CeZV0Cqx.js} +2 -2
- package/dist/shell/assets/{run-trace-view-ChuThRe4.js → run-trace-view-CsT4mLDc.js} +2 -2
- package/dist/shell/assets/{runner-install-field-8Ap9WvhK.js → runner-install-field-8Oz3ILhl.js} +2 -2
- package/dist/shell/assets/{runtime-update-B4DPgHIL.js → runtime-update-CQ7qAQHh.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-ClTsd7Ce.js → shared-protobase-ui-C3HDx4Ie.js} +1 -1
- package/dist/shell/assets/{sheet-source-D0v07JHr.js → sheet-source-Ch5uFlt5.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-CV3iE_o8.js → sign-in-policy-page-DyroONcf.js} +2 -2
- package/dist/shell/assets/{start-block-queries-DJX-JI2P.js → start-block-queries-heBbb7IN.js} +2 -2
- package/dist/shell/assets/{step-catalog-DSHlXxWA.js → step-catalog-C7zY05CI.js} +2 -2
- package/dist/shell/assets/{step-panel-CF6x9K8Y.js → step-panel-DifkdQUN.js} +2 -2
- package/dist/shell/assets/{timeline-display-DpVKeXjG.js → timeline-display-DgD-tH2t.js} +2 -2
- package/dist/shell/assets/{trash-Ccs0JhuD.js → trash-sDDKsEVa.js} +2 -2
- package/dist/shell/assets/{update-set-L1kw--38.js → update-set-t56Pch6F.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-DHCS22jF.js → use-calendar-move-B5Nd4WqC.js} +2 -2
- package/dist/shell/assets/{use-display-rows-DcY7w9cN.js → use-display-rows-Evx7hciH.js} +2 -2
- package/dist/shell/assets/{use-my-invitations-Dodu_ib9.js → use-my-invitations-BeEVmA84.js} +2 -2
- package/dist/shell/assets/{use-paged-search-Crpqw2e-.js → use-paged-search-CHtW6YbU.js} +2 -2
- package/dist/shell/assets/{use-run-trace-Cozaxsfl.js → use-run-trace-B0JxFskZ.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-eP9jGrad.js → use-workflow-page-3QycD-Ie.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-DjJ87TLL.js → use-workflow-types-7sud5u7m.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-NJSHRDav.js → workflow-canvas-CzzTk8Bv.js} +2 -2
- package/dist/shell/assets/{workflow-field-D_pqVGeK.js → workflow-field-ehSWu4Iq.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-D4zxMPy4.js → workflow-graph-editor-89M8HZOe.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-DcL-8XS_.js → workflow-run-field-Dxg2lHnv.js} +3 -3
- package/dist/shell/assets/{workflow-status-field-15bq7T5K.js → workflow-status-field-Bws1hFJF.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-CC_mXUfW.js → workflow-workbench-D2Piourk.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-DS2lZVD1.js.map → account-page-IZQQcp3C.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-CgllsYQy.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-BIpWuqnT.js.map → assistant-shell-ClWlf9GV.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-Buo0YyZ5.js.map → board-display-DhHkhSdi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-10AgoW3N.js.map → calendar-display-C_X68Umc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-BUUwC1QU.js.map → call-rings-B0-gGLW5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-eQ3_Fp6k.js.map → calls-VTUC3xS7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-D7B_KeB7.js.map → circle-alert-D8UYAgz6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-Btkd6u0m.js.map → composed-page-FL2hq-qi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-DUmPQLgo.js.map → composer-section-DBsqoWhe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-DQIlzdmb.js.map → connect-route-DI8OFx4L.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-BfYo47Io.js.map → copy-field-DBuqCBWo.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-CSTAtNAw.js.map → create-route-CCx6gOjR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-Dxltzn8J.js.map → custom-step-container-field-tmox-exj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-7l7TUHug.js.map → embedded-list-BIvz_g-b.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-DWcXdfEj.js.map → export-dialog-cqfMEBd7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{first-organization-page-77PHesxY.js.map → first-organization-page-CC7DrhYu.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-DQOQDrmJ.js.map → graph-view-DRWl6A2P.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-BGfuQ6iU.js.map → group-donut-D1l1-O4a.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-BdV2Hwhv.js.map → guest-call-page-BLh17iiD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-CXABej3u.js.map → html-viewer-BeLoV4vw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-Cqu_xO6L.js.map → import-dialog-CwnPFP3s.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-MwfAiAmM.js.map → import-table-dialog-D__S72Yl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-C6LjToJR.js.map → invitations-page-MQ6ujhc1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-C_uTX3Tb.js.map → layout-grid-B4X2fG6K.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-DzqFlC4D.js.map → legend-item-BoMo0Yub.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-CTGtveKF.js.map → list-page-BceXf9dP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-aCJmOb1H.js.map → maplibre-BZGHDnqB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-CDmFTB6r.js.map → markdown-content-CB2LNHPp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-Defqhu24.js.map → members-page-DnPAIXBn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{message-content-CeLDUud8.js.map → message-content-C6ld-XsS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-XnV72On0.js.map → messages-CWURrUB-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-Cdfaqvsh.js.map → organization-page-DnmV85sX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-C37kxzUq.js.map → organizations-page-CKJB2qGB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-Cyu7Ucej.js.map → pending-invitation-row-DAXBo7SZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-T4rBI9Y2.js.map → period-chart-CbzGqkpY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-DjxZAaa3.js.map → person-row-BNM1LeOM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-DaPFaXOT.js.map → public-form-page-BTILqkb8.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-CSeqYQnm.js.map → record-lines-BuGPIPkM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-l-E3DvxV.js.map → record-map-H5uvOI5d.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-DPMtZw1p.js.map → record-opens-BLwJhTqE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-DK2-zwXx.js.map → record-page-CCfn7bkb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-0BdCZkO9.js.map → record-preview-CWciJJ5e.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-DSg2fbqb.js.map → records-map-CPYxm3fv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-qPc-4XAK.js.map → render-node-BiDgPc8P.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-Z_evPIxl.js.map → reorder-button-CeZV0Cqx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-ChuThRe4.js.map → run-trace-view-CsT4mLDc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-8Ap9WvhK.js.map → runner-install-field-8Oz3ILhl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-B4DPgHIL.js.map → runtime-update-CQ7qAQHh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-D0v07JHr.js.map → sheet-source-Ch5uFlt5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-CV3iE_o8.js.map → sign-in-policy-page-DyroONcf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-DJX-JI2P.js.map → start-block-queries-heBbb7IN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-DSHlXxWA.js.map → step-catalog-C7zY05CI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-CF6x9K8Y.js.map → step-panel-DifkdQUN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-DpVKeXjG.js.map → timeline-display-DgD-tH2t.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-Ccs0JhuD.js.map → trash-sDDKsEVa.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-L1kw--38.js.map → update-set-t56Pch6F.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-DHCS22jF.js.map → use-calendar-move-B5Nd4WqC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-DcY7w9cN.js.map → use-display-rows-Evx7hciH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-my-invitations-Dodu_ib9.js.map → use-my-invitations-BeEVmA84.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-Crpqw2e-.js.map → use-paged-search-CHtW6YbU.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-Cozaxsfl.js.map → use-run-trace-B0JxFskZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-eP9jGrad.js.map → use-workflow-page-3QycD-Ie.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-DjJ87TLL.js.map → use-workflow-types-7sud5u7m.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-NJSHRDav.js.map → workflow-canvas-CzzTk8Bv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-D_pqVGeK.js.map → workflow-field-ehSWu4Iq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-D4zxMPy4.js.map → workflow-graph-editor-89M8HZOe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-DcL-8XS_.js.map → workflow-run-field-Dxg2lHnv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-15bq7T5K.js.map → workflow-status-field-Bws1hFJF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-CC_mXUfW.js.map → workflow-workbench-D2Piourk.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
- package/dist/shell-source-maps/assets/app-1IZYQXW2.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$a as r,$c as i,$r as a,$s as o,$t as s,A as c,Ac as l,An as u,Bl as d,Cc as f,Cl as p,Cn as m,Cr as h,Cs as g,Dl as _,Dn as v,Ec as y,En as b,Eo as x,Er as S,Es as C,Fc as w,Fl as T,Fn as E,Fo as D,Ft as ee,Gc as te,Gi as ne,Gs as O,Hl as re,Hs as k,I as ie,Il as ae,In as oe,It as se,Jn as ce,Kn as le,Kr as ue,Ks as de,La as fe,Lc as pe,Ma as me,Mi as he,Ms as ge,Mt as _e,N as ve,Na as ye,Nc as A,Nl as be,Nt as xe,O as Se,Oc as Ce,Oi as we,On as Te,Oo as Ee,Os as De,Pa as Oe,Pc as ke,Pi as Ae,Pt as je,Qa as Me,Ra as Ne,Rn as Pe,Sn as Fe,So as Ie,Sr as Le,Ss as j,Ta as Re,Tc as ze,Tn as Be,To as Ve,Tr as M,Ts as N,Us as He,V as Ue,Va as We,Vi as Ge,Vs as P,Ws as Ke,Xc as qe,Xn as Je,Xo as F,Xr as Ye,Xs as Xe,Ya as Ze,Yn as Qe,Yr as $e,Ys as et,Zs as tt,_n as nt,_s as I,_t as rt,a as it,ac as at,an as ot,at as st,b as ct,br as L,bs as R,c as lt,cc as ut,cn as dt,cs as ft,da as pt,dc as mt,dn as ht,dr as gt,du as _t,ea as vt,ec as yt,en as bt,fa as xt,fc as St,fn as Ct,fo as wt,fs as Tt,gn as Et,gr as Dt,gs as Ot,gt as kt,hl as z,hn as At,ho as jt,hs as B,iu as Mt,ja as Nt,jc as V,jl as Pt,jn as Ft,kn as It,ks as Lt,lc as Rt,ll as zt,ls as Bt,ma as Vt,mc as Ht,ml as H,mo as Ut,mr as Wt,ms as U,nc as Gt,oc as Kt,ol as qt,or as Jt,pc as Yt,pn as W,po as G,pr as Xt,ps as Zt,qc as Qt,qn as $t,rn as en,ru as tn,sc as nn,sr as rn,tc as an,tr as on,u as sn,uc as cn,un as ln,ur as un,uu as dn,v as fn,va as pn,vn as mn,vr as hn,vs as K,vu as gn,w as _n,wc as vn,wl as yn,wn as bn,wr as q,wt as xn,x as Sn,xc as Cn,xi as wn,xr as Tn,xs as En,y as Dn,ya as On,yn as kn,yr as J,ys as An,z as jn,zi as Mn}from"./app-1IZYQXW2.js";import{C as Nn,f as Pn,o as Fn,s as In}from"./vendor-t7Q7QbPu.js";import{C as Ln,Ct as Rn,Dt as zn,Et as Bn,O as Vn,Ot as Hn,Q as Un,St as Wn,Tt as Gn,X as Kn,Z as qn,_t as Jn,at as Yn,b as Xn,ct as Zn,dt as Qn,ft as $n,gt as er,it as tr,jt as nr,k as rr,l as ir,lt as ar,mt as or,n as sr,nt as cr,o as lr,ot as ur,rt as dr,st as fr,t as pr,tt as mr,ut as hr,wt as gr,x as _r,xt as vr,y as yr}from"./embedded-list-7l7TUHug.js";import{t as br}from"./circle-alert-D7B_KeB7.js";import{t as xr}from"./page-header-Ddz2r5ic.js";import{n as Sr,t as Cr}from"./pending-invitation-row-Cyu7Ucej.js";import{n as wr,t as Tr}from"./person-row-DjxZAaa3.js";import{n as Er,t as Dr}from"./use-paged-search-Crpqw2e-.js";import{n as Or,t as kr}from"./client-publisher-D39SlIhp.js";import{t as Ar}from"./copy-field-BfYo47Io.js";var jr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};jr.node;var Mr=H(jr),Nr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Nr.node;var Pr=H(Nr),Fr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Fr.node;var Ir=H(Fr),Lr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Lr.node;var Rr=H(Lr),zr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};zr.node;var Br=H(zr),Vr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Vr.node;var Hr=H(Vr),Ur={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ur.node;var Wr=H(Ur),Gr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Gr.node;var Kr=H(Gr),qr=[`done`,`error`,`running`];Yt(`TextField`,!1),Yt(`NumberField`,!1),Yt(`DateField`,!1),Yt(`BooleanField`,!1),Yt(`UrlField`,!1),Yt(`ChipField`,!1);var Jr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Yr=e=>typeof e!=`string`&&!e.custom&&Jr.has(e.type),Xr=e=>typeof e==`string`||Yr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Zr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Qr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),$r=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},ei=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},ti=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,ni=new Set([`http:`,`https:`,`mailto:`,`tel:`]),ri=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:ni.has(`${n.toLowerCase()}:`)?e:void 0},ii=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),ai=e=>e==null||e===``?void 0:String(e),oi=(e,t)=>e<t?-1:+(e>t),si=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=ai(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=ai(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>ai(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=ai(e[i.source]),s=ai(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>oi(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>oi(e.id,t.id)),edges:s.sort((e,t)=>oi(e.source,t.source)||oi(e.target,t.target)||oi(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ci=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=N(),s=Rn(e.name,void 0),c=vt(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>m(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let h=f.length-p.length,g=vr(`actionCount`,{label:r??d.label,count:p.length}),_=e=>s.runEach(d,p,h,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Bn(d)?u(!0):void _(),children:g}),l&&(0,X.jsx)(Gn,{action:d,label:g,danger:i===`danger`||i===void 0&&zn(d),records:p.map(e=>e.record),names:p.map(t=>Wn(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),_()},onSubmit:async e=>{u(!1),await _(e)}})]})},li=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=hn(),c=gr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Bn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Gn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ui=({node:e,className:t})=>{let n=W(e),r=h(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ci,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(li,{...n,className:t})},di=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=W(e);return(0,X.jsx)(q,{title:i,description:a,actions:n.actions,className:z(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},fi=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=h();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...m(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Wt,{value:s,row:{index:o,count:i.length},children:e}),c)})},pi=({children:e})=>(0,X.jsx)(fi,{children:e}),mi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=ln(t),p=b(e,{filter:n,sort:r,pageSize:i,enabled:!f}),m=f??p,h=f?f.rows:p.data?.items??[];return(0,X.jsx)(q,{title:a,description:o,actions:c,className:d,children:m.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(l,{className:`h-24 w-56`},t))}):m.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:m.error}):h.length===0?(0,X.jsx)(M,{children:s??G(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(Tn,{value:{model:e,items:h,...f&&{planned:!0}},children:(0,X.jsx)(fi,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:u})})})})},hi=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=W(e),o=N().resources[i];return o?(0,X.jsx)(mi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},gi=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=W(e),{resources:u,views:d}=N(),f=u[r];return f?(0,X.jsx)(q,{title:i,description:a,actions:t.actions,className:z(`h-full`,n),children:(0,X.jsx)($n,{model:f,view:d[r],...l})}):null},_i=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Be(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Wt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(M,{children:G(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},vi=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},yi=e=>e==null?``:String(e),bi=(e,t,n)=>n===0?0:(e-t)/n*100,xi=(e,t,n)=>{let r=new Map;for(let i of e){let e=vi(i[t.start]);if(e===void 0)continue;let a=vi(i[t.end]),o=Math.max(e,a??n),s=r.get(yi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(yi(i[t.lane]),s);let c=s.bars.get(yi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(yi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},Si=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},Ci=(e,t,n)=>{let r=xi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:bi(n,a,s),width:bi(r,a,s)-bi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:bi(o,a,s),width:bi(c,a,s)-bi(o,a,s),segments:i}});return{key:e,value:n.value,rows:Si(r)}}),from:a,to:o}},wi=(e,t)=>{let n=e.end-e.start;return{left:bi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},Ti=6e4,Ei=60*Ti,Z=24*Ei,Di=[5*Ti,15*Ti,30*Ti,Ei,3*Ei,6*Ei,12*Ei,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],Oi=365*Z,ki=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Ai=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=Di.find(n=>ki(e,t,n,i,a)<=6)??Math.ceil(r/5/Oi)*Oi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:bi(a,e,r)})}return{daily:o>=Z,ticks:s}},ji=e=>({lane:yi(e.lane),bar:e.key}),Mi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ni=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Pi=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Fi=({from:e,to:t,dated:n})=>{let r=n?`UTC`:Re(),i=e=>n?0:Ni(e,r),{daily:a,ticks:o}=Ai(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Pi(e.left)}`,style:{left:`${e.left}%`},children:a?Vt(e.at+i(e.at)):On(e.at,r)},e.at))})},Ii=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&re(a)?{className:En[a],striped:i}:{color:er(e,t,n===void 0?null:n,-1),striped:i}},Li=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ri=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Ii(t,n,r.value),{left:o,width:s}=wi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:z(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...Li(a)}},i)}),zi=(e,t)=>t?pt(e):xt(e),Bi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return G(`timelineRange`,{from:zi(n,a),to:i?G(`timelineNow`):zi(r,a)})},Vi=(e,t,n,r)=>`${we(t.fields[r.color],e.value,n?.fields[r.color])}: ${Bi(t,r,e.start,e.end,e.open)}`,Hi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??we(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Bi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Vi(e,t,n,r))].join(`; `)},Ui=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Wi=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=N().resources[t.fields[r.bar]?.relation?.resource??``],s=Pe(o??t,e.key,o!==void 0),c=Hi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ri,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Ui,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(Ce,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:z(Ui,f&&`ring-2 ring-foreground`),...l,children:d})},Gi=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Fi,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(Te,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Wi,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ki=({model:e,view:t,fields:n,value:r})=>{let i=Ii(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:z(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:Li(i)})},qi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ki,{...t,value:e}),we(n,e,t.view?.fields[t.fields.color])]},e))})},Ji=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:G(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(Te,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Bi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ki,{...t,value:e.value}),we(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Bi(n,i,e.start,e.end,e.open)]},a))})]})},Yi=500,Xi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...p.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Yi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Zi=(e,{enabled:t=!0,...n})=>Fn({...Xi(ge(),e,n),enabled:t,placeholderData:Pn}),Qi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=ut,title:s,description:c,empty:u,actions:d,className:f,choose:p,details:m})=>{let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e=>e?ji(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=ln(i),C=Zi(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),w=x??C,T=x?x.rows:C.data?.rows??[],E=!x&&C.data?.cut===!0,D=Ci(T,n,Date.now());return(0,X.jsxs)(q,{title:s,description:c,actions:d,className:z(`h-full`,f),children:[(()=>{if(w.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(l,{className:`h-6`},t))});if(w.error)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:w.error});if(D.lanes.length===0)return(0,X.jsx)(M,{children:u??G(`nothingYet`)});let r=new Set(T.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Gi,{shape:D,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),E&&(0,X.jsx)(M,{children:G(`timelineCut`,{count:T.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Ji,{bar:Mi(D,h)??Mi(D,_),model:e,view:t,fields:n})})]})})(),m]})},$i=(e,t)=>e.type===`integer`?Number(t):t,ea=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=gt(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,X.jsx)(y,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{filter:Jn(s,$i(s,a),n.filter),sort:n.sort},children:t},a)});return(0,X.jsx)(Qi,{...n,choose:{barTo:o,chosen:a},details:c})},ta=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=W(e),{resources:h,views:g}=N(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Rt(e),sort:cn(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Qi,{...v}):(0,X.jsx)(ea,{...v,select:s,children:r})},na=({node:e,children:t})=>{let n=St(e),r=Xt(),{resources:i}=N();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(y,{name:n.param,children:(0,X.jsx)(_i,{model:o,query:{key:a},className:``,children:t},a)})},ra=(0,Y.lazy)(()=>Nn(()=>import(`./graph-view-DQOQDrmJ.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ia=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(w,{})}),aa=({node:e,at:t,slots:n,children:r,className:i})=>{let a=W(e),o=dt(e,t),s=Xt(),c=o.nodes,l=o.edges,{label:u,group:d,status:f,source:p,target:m}=a,h=(0,Y.useMemo)(()=>({label:u,source:p,target:m,...d!==void 0&&{group:d},...f!==void 0&&{status:f}}),[u,p,m,d,f]),g=JSON.stringify([c?.rows,l?.rows,h]),_=(0,Y.useMemo)(()=>c&&l&&si({nodes:c.rows,edges:l.rows,key:c.model.primaryKey[0],edgeKey:l.model.primaryKey,fields:h}),[g]);if(!c||!l||!_)return null;let v=c.error??l.error;if(v&&e.fallback)throw v;if(v)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:v});if(c.isPending||l.isPending)return ia;if(_.nodes.length===0)return(0,X.jsx)(M,{children:a.empty??G(`nothingYet`)});let y=a.select,b=y!==void 0&&s?{chosen:s.given[y],linkTo:e=>s.linkTo({[y]:e})}:void 0;return(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:ia,children:(0,X.jsx)(ra,{shape:_,nodes:c,edges:l,fields:h,props:a,...b&&{select:b},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&b?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(na,{node:e,children:r})})]})},oa=({onPick:e,accept:t})=>{let n=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:n,type:`file`,multiple:!0,hidden:!0,accept:t,"aria-label":s(`filesToAttach`),onChange:t=>{e([...t.target.files??[]]),t.target.value=``}}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`attachFiles`),title:s(`attachFiles`),onClick:()=>n.current?.click(),children:(0,X.jsx)(Qt,{className:`size-4`})})]})},sa=`message`,ca=(e,t,n,r)=>[{op:`create`,resource:e,ref:sa,data:t},...r.map(e=>({op:`create`,resource:n.resource,data:{[n.field]:{$ref:sa},[n.file]:e}}))],la=e=>{let t=e.results[0];if(t?.op!==`create`)throw Error(`A message batch starts with the message it creates`);return t.record},ua=(e,t,n,r)=>[...e.attachments?r.map(t=>({op:`delete`,resource:e.attachments.resource,key:t.key})):[],{op:`delete`,resource:e.resource,key:sn(t,n)}],da=(e,t)=>{if(!(t===void 0||e.size<=t))return s(`fileTooLarge`,{size:Ge(e.size),max:Ge(t)})},fa=(e,t,n)=>e.map((e,r)=>({key:t+r,name:e.name,size:e.size,sent:0,refusal:da(e,n)})),pa=e=>e.ticket===void 0&&e.refusal===void 0,ma=e=>e.flatMap(e=>e.ticket===void 0?[]:[e.ticket]),ha=e=>!e.some(pa)&&ma(e).length>0,ga=e=>e.refusal===void 0?e.ticket!==void 0||e.size===0?Ge(e.size):s(`uploadedPercent`,{percent:Math.floor(Math.min(e.sent,e.size)/e.size*100)}):e.refusal,_a=({uploads:e,onRemove:t})=>(0,X.jsx)(`ul`,{"aria-label":s(`filesToSend`),className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex max-w-full items-center gap-1 rounded-md border border-border py-0.5 pl-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:e.name}),(0,X.jsx)(`span`,{role:e.refusal===void 0?void 0:`alert`,className:z(`min-w-0`,e.refusal===void 0?`text-muted-foreground`:`text-danger-text`),children:ga(e)}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`takeFileOff`,{name:e.name}),title:s(`takeFileOff`,{name:e.name}),onClick:()=>t(e.key),children:(0,X.jsx)(pe,{className:`size-3.5`})})]},e.key))}),va=e=>{let t=ge(),{resources:n}=N(),r=e&&n[e.resource]?.fields[e.file]?.file?.maxSize,[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(0),c=(0,Y.useRef)(new Map),l=(e,t)=>a(n=>n.map(n=>n.key===e?{...n,...t}:n)),u=(e,n,r)=>{let i=new AbortController;c.current.set(n.key,i),t.upload(e.resource,e.file,r,{signal:i.signal,onProgress:e=>l(n.key,{sent:e})}).then(e=>l(n.key,{ticket:e.value}),e=>{i.signal.aborted||l(n.key,{refusal:s(`fileNotUploaded`,{reason:wn(e)})})}).finally(()=>c.current.delete(n.key))};return(0,Y.useEffect)(()=>{let e=c.current;return()=>e.forEach(e=>e.abort())},[]),{uploads:i,tickets:ma(i),uploading:i.some(pa),ready:ha(i),pick:t=>{if(!e||t.length===0)return;let n=fa(t,o.current,r);o.current+=t.length,a(e=>[...e,...n]),n.forEach((n,r)=>{n.refusal===void 0&&u(e,n,t[r])})},remove:e=>{c.current.get(e)?.abort(),a(t=>t.filter(t=>t.key!==e))},sent:e=>a(t=>t.filter(t=>pa(t)||t.ticket!==void 0&&!e.includes(t.ticket)))}},Q=yn(`app/conversation`),ya=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a,attachments:o,onDraft:s,onSent:c})=>{let{resources:l}=N(),u=ge(),d=v(),f=C(e),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(),_=va(o);if(!l[e]||!We(f,`create`))return null;let y=o&&l[o.resource]?.fields[o.file],b=y&&Mn(y);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h!==void 0&&(0,X.jsx)(S,{title:Q(`notSent`),error:h}),(0,X.jsx)(xn,{onSend:async(r,i)=>{m(!0),g(void 0);let s=_.tickets,f={...n,...r!==``&&{[t]:r},...a!==void 0&&{[a]:i}},p=o&&s.length>0?u.batchWrite(ca(e,f,o,s)).then(la):u.create(e,f).then(e=>e.record),h=l[e],v=await p.then(e=>(c?.(String(Ne(h,e))),!0),e=>(g(e),!1));return m(!1),v?(d(e),o&&_.sent(s),o&&s.length>0&&d(o.resource),!0):!1},busy:p||_.uploading,placeholder:r,searchPeople:i,onDraft:s,...o&&{actions:(0,X.jsx)(oa,{onPick:_.pick,accept:b}),attachments:_.uploads.length>0&&(0,X.jsx)(_a,{uploads:_.uploads,onRemove:_.remove}),canSendEmpty:_.ready,onFiles:_.pick}})]})},ba=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=W(e);return(0,X.jsx)(ya,{resource:t,field:n,values:r,placeholder:i})},xa=({node:e,children:t,className:n})=>{let{open:r}=W(e);return(0,X.jsx)(`details`,{open:r,className:z(`[&[open]>summary]:mb-2`,n),children:t})},Sa=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:z(`cursor-pointer font-medium`,t),children:e}),Ca=({node:e,className:t})=>{let{source:n,emptyText:r}=W(e),i=mn(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(l,{className:z(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:z(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=kt(a);return o?(0,X.jsx)(`div`,{className:z(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(rt,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:z(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},wa=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),Ta=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ae(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Ea=({node:e,className:t})=>{let{source:n,label:r,format:i}=W(e),{views:a}=N(),o=mn(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(l,{className:`h-4 w-24`}):o.state===`plain`?wa(o.value):(0,X.jsx)(Te,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??Ta(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:z(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},Da={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Oa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ka={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},Aa=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ja=({node:e,children:t,className:n})=>{let{columns:r=2}=W(e),i=e.children,a=i.length>0&&i.every(Aa);return(0,X.jsx)(`div`,{className:z(`grid grid-cols-1 gap-4`,a?Oa[r]:Da[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:z(`min-w-0`,r&&ka[r]),children:e},t)})})},Ma=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),Na=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},Pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),Fa=e=>e instanceof Blob&&e.type.startsWith(`image/`),Ia=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},La=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},Ra=({name:e,alt:t,width:n,height:i,refresh:a,className:o})=>{let s=ge(),{theme:c}=r(),[u,d]=st(),f=Na({width:n,height:i,space:d,theme:c}),m=Fn({queryKey:p.image(e,f??{}),enabled:f!==void 0,placeholderData:Pn,...Pa(a),queryFn:async()=>{let t=await s.invoke(e,{query:f,cache:`no-store`});if(!Fa(t))throw Error(`The function "${e}" answered no picture`);return t}}),h=Ia(m.data),[g,_]=La(h),v={...n!==void 0&&{width:n},...i!==void 0&&{height:i}};return(0,X.jsx)(`div`,{ref:u,className:z(`min-w-0`,o),children:m.isError||g?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):h?(0,X.jsx)(`img`,{src:h,alt:t??``,onError:_,style:v,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(l,{className:`w-full max-w-full`,style:{height:i??160,...n!==void 0&&{width:n}}})})},za=({node:e,className:t})=>{let n=W(e);return n.src===void 0?(0,X.jsx)(Ra,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(Ma,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},Ba=e=>function({node:t,className:n}){let r=W(t),{views:i}=N(),a=mn(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(l,{className:`inline-block h-3 w-16 align-middle`}):Zr(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},Va=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?T(e,n?.valueLabels):Qr(e),Ha=Ba(Va),Ua=Ba(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:$r(e,t,_())})),Wa=Ba(({value:e,props:t})=>{let n=ei(e,t,{locale:_(),now:Date.now(),relative:pn});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),Ga=Ba(({value:e,props:t})=>{let n=ti(e,t,{yes:ne(`yes`),no:ne(`no`)});return e?(0,X.jsx)(on,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ka=Ba(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=ri(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),qa=Ba(e=>(0,X.jsx)(oe,{value:e.value,hints:e.hints,children:Va(e)})),Ja=`font-medium text-primary-text hover:underline`,Ya=({node:e,children:t,className:n})=>{let r=W(e),i={...L(J()),params:un()},a=r.variant?z(ke({variant:r.variant}),n):n??Ja,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=dn(r.to,Xe(i));return(0,X.jsx)($e,{to:e,className:a,children:o??Cn(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},Xa=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:Se(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:Se(i)]})),Za=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return lt(r)?r.key===Se(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:_n(i,r,n[t])?[[t,c(i,r)]]:[]})),Qa=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=N(),u=ge(),d=Me(),f=v(),p=l[e.name],[m,h]=(0,Y.useState)(()=>Xa(e,a,t?.record)),[g,_]=(0,Y.useState)({}),[y,b]=(0,Y.useState)(0),x=fn(y),[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),[D,ee]=(0,Y.useState)(!1);vn(D||T,`input-lost`);let te=async()=>{E(!0),w(void 0),await(n===`create`?u.create(e.name,{...it(e,c,m),...o}):u.update(e.name,t.key,Za(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:G(`saved`,{label:i??r})}),s()},e=>{let t=Dn(e);_(t),Object.keys(t).length>0&&b(e=>e+1),w(e)}),E(!1)};return(0,X.jsx)(V,{title:i??r,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:s,children:G(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:T,onClick:()=>void te(),children:G(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:x,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),te()},children:[C!==void 0&&Object.keys(g).length===0&&(0,X.jsx)(S,{title:G(`notSaved`),error:C}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??ae(n),s=g[n];return(0,X.jsx)(jn,{name:n,label:o,help:p?.fields[n]?.help,error:s&&ct(r,o,s),children:(0,X.jsx)(Sn,{field:r,hints:p?.fields[n],value:lt(i)?i.key:i,stored:t?.record[n],relationLabel:lt(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),ee(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},$a=({model:e,recordKey:t,children:n})=>{let r=Be(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},eo=({node:e})=>{let t=W(e),n=hn(),{resources:r}=N(),i=r[t.resource??n?.model.name??``],a=C(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?We(a,`create`):We(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(Qa,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)($a,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},to=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=W(e);return(0,X.jsx)(`div`,{className:z(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(xr,{title:i,subtitle:a,actions:n.actions}),t]})})},no=(e,t)=>{let n=J(),r=typeof e==`string`?Dt(n,e):void 0,i=Et(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},ro=({node:e,className:t})=>{let{value:n,max:r,label:i}=W(e),a=no(n,0),o=no(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(l,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:z(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(_()),` / `,o.toLocaleString(_())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},io=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=ln(t),p=Be(e,{filter:n,sort:r,key:i,enabled:!f}),m=f?Fe(e,f):p,h=e=>m.data?(0,X.jsx)(Wt,{value:m.data,children:e}):void 0,g=m.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]}):m.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:m.error}):m.data?h((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:u})):(0,X.jsx)(M,{children:s??G(`nothingYet`)});return(0,X.jsx)(q,{title:a,description:o,actions:c?h(c):void 0,className:z(`h-full`,d),children:g})},ao=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=W(e),f=N().resources[a];return f?(0,X.jsx)(io,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},oo=yn(`app/related-cards`),so=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:z(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:oo(n?`showLess`:`showMore`)})]})},co=e=>e==null||e===``,lo=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=N(),a=Et(e,t);if(a.state===`missing`||a.state===`ready`&&co(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(l,{className:`h-4 w-24`}):(0,X.jsx)(Te,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(so,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=Ta(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},uo=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=vt(),{resources:l}=N(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:z(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(en,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:z(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)($e,{to:{kind:`record`,resource:e.model.name,key:Ne(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(lo,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(lo,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Wt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(mr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(li,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},fo=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=vt(),{resources:c}=N(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(en,{view:t,field:r,record:e.record}),(0,X.jsx)($e,{to:{kind:`record`,resource:e.model.name,key:Ne(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(lo,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Wt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(mr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(li,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},po=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,mo=e=>[...e.querySelectorAll(`button`)].find(po)??e.querySelector(`a`),ho=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},go=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},_o=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(oo(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=ho(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?mo(s):go(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},vo=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(l,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),yo=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:c,empty:l,carousel:u,compact:d,tone:f,planned:p})=>{let h=Bt(),g=hr(),_=t?.names?.plural??ae(e.name),v=r||Oe(e,t),y=b(e,{filter:n,sort:v,pageSize:s,enabled:!p}),x=bn(e,n,!p),C=p?p.rows:{isPending:y.isPending,error:y.error},w=p?p.rows.rows:y.data?.items,T=p?{data:p.total&&!p.total.isPending&&!p.total.error?cr(p.total):void 0}:x,E=(0,Y.useMemo)(()=>(w??[]).map(t=>m(e,t)),[e,w]),D=_o((0,Y.useMemo)(()=>E.map(e=>e.key),[E]));return(0,X.jsxs)(`div`,{ref:D.root,children:[(()=>{if(C.isPending)return(0,X.jsx)(vo,{compact:!!d,limit:s});if(C.error)return(0,X.jsx)(S,{title:oo(`couldNotLoad`),error:C.error});if(E.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:l??oo(`nothingYet`)});let r=E.map(e=>{let n=(t,n)=>D.acted(e.key,t,n);return d?(0,X.jsx)(uo,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(fo,{scope:e,view:t,fields:i,tone:f,actions:a,button:o,onActed:n},e.key)}),p=T.data===void 0?void 0:Zn(E.length,T.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,X.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Qn,{scroll:g,label:_,share:u,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p}),(0,X.jsxs)($e,{to:ur(e,t,h,{filter:n,orderBy:v,display:dr(t,h,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[ar(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,X.jsx)(nr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:D.announcement})]})},bo={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},xo=({node:e,at:t,slots:n,className:r})=>{let i=W(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=ii(i),{resources:_,views:v}=N(),[y,b]=ht([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,X.jsx)(`section`,{className:z(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(ie,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(yo,{model:S,view:C,filter:o,sort:s,fields:c??Pt(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?bo[g]:void 0,...x&&{planned:x}})})})},So=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:o}=N(),s=a(i,o,e.name),c=Vn(e.name,t.listOf,!0),u=(t.names?.plural??ae(e.name)).toLowerCase();if(!s.listOf)return null;if(c.error)return(0,X.jsx)(S,{title:Ln(`couldNotLoadYour`,{plural:u}),error:c.error});if(!c.data)return(0,X.jsx)(l,{className:`h-24`});let d=rr(s.model,c.data);return d?(0,X.jsx)(_r,{...r,model:s.model,view:s.view,filter:``,scope:d,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??Ln(`noneYet`,{plural:u})})},Co=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=d(Ne(e,i)),{name:o,chips:s,title:c,body:l}=yr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)($e,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Kn,{chips:s})})}),(0,X.jsx)(_r,{...l})]})},wo=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=N(),a=t.searchesOf,o=r[a.resource],s=Xn(e.name,!0),c=(t.names?.plural??ae(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(S,{title:qn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??qn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(Co,{model:e,view:t,target:o,targetView:i[a.resource],row:n},d(Ne(e,n))))}):(0,X.jsx)(l,{className:`h-40`}):null},To=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=W(e),{resources:d,views:f}=N(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(q,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(wo,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(_r,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(So,{model:p,view:m,limit:o,display:s,empty:u})})},Eo=e=>e.type===`boolean`||e.type===`enum`,Do=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=N(),c=C(e.name),l=ge(),u=Me(),d=v(),f=s[e.name],[p,h]=(0,Y.useState)(i),[g,_]=(0,Y.useState)(()=>Xa(e,t,i?.record)),[y,b]=(0,Y.useState)({}),[x,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),D=(0,Y.useRef)(Promise.resolve()),ee=(0,Y.useRef)(i),te=Xa(e,t,void 0),ne=p?We(c,`update`)&&p.permissions?.update!==!1:We(c,`create`),O=t.filter(t=>!Eo(e.fields[t])),re=O.some(t=>p?_n(e.fields[t],g[t],p.record[t]):g[t]!==te[t]),k=async t=>{let n=ee.current;if(n){let r=await l.update(e.name,n.key,Za(e,t,n.record),n.etag??`*`);return{...m(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,it(e,o,{...te,...t}));return{...m(e,r.record),etag:r.etag}},ie=t=>{let r=D.current.then(async()=>{E(!0),w(void 0),await k(t).then(async r=>{ee.current=r,h(r),b(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:G(`saved`,{label:n??G(`settings`)})})},e=>{b(t=>({...t,...Dn(e)})),w(e)}),E(!1)});D.current=r},oe=(t,n)=>{_(e=>({...e,[t]:n})),Eo(e.fields[t])&&ie({[t]:n})};return(0,X.jsx)(q,{title:n,description:r,className:z(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re&&ie(Object.fromEntries(O.map(e=>[e,g[e]])))},children:[x!==void 0&&Object.keys(y).length===0&&(0,X.jsx)(S,{title:G(`notSaved`),error:x}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??ae(t),i=y[t];return(0,X.jsx)(jn,{name:t,label:r,help:f?.fields[t]?.help,error:i&&ct(n,r,i),children:(0,X.jsx)(Sn,{field:n,hints:f?.fields[t],value:g[t],stored:p?.record[t]??te[t],invalid:!!i,locked:!ne||n.readOnly,resource:e.name,onChange:e=>oe(t,e)})},t)}),ne&&re&&(0,X.jsx)(`div`,{children:(0,X.jsx)(A,{type:`submit`,variant:`primary`,size:`sm`,loading:T,children:G(`save`)})})]})})},Oo=e=>{let t=Be(e.model,{});return t.isPending?(0,X.jsx)(q,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(q,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(S,{title:G(`couldNotLoad`),error:t.error})}):(0,X.jsx)(Do,{...e,stored:t.data??void 0})},ko=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=W(e),o=N().resources[n];return o?(0,X.jsx)(Oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},Ao=(e,t)=>jo(e,t?[t]:[]),jo=(e,t)=>{let{resources:n}=N(),r=ge(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(nn),[i]),o=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=at(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>Dt(t,e)),f=nt(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=In({queries:u.map(e=>kn(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return Kt(e,t)})},Mo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,No=({node:e,children:t,slots:n,className:r})=>{let{when:i}=W(e),[a]=jo([i],J());if(a===void 0)return null;let o=a?t:Mo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},Po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(et(e,L(t)).props.when)]),Fo=({node:e,children:t,slots:n,className:r})=>{let i=J(),a=jo(Po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?Mo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},Io=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),Lo=`text-2xl font-semibold tracking-tight tabular-nums`,Ro=({model:e,at:t,filter:n})=>{let{views:r}=N(),i=ln(t),a=bn(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(l,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:G(`couldNotCount`)});let s=i?cr(i):a.data;return(0,X.jsx)($e,{to:or(r[e.name],e.name,n),className:`${Lo} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(_())})},zo=({field:e,format:t})=>{let n=mn(e);return n.state===`loading`?(0,X.jsx)(l,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:Lo,children:wa(n.value)}):(0,X.jsx)(`span`,{className:Lo,children:(0,X.jsx)(Te,{model:n.model,field:n.field,value:n.value,format:t})})},Bo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=W(e),{resources:u}=N(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(q,{className:z(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:Lo,children:i}),d&&(0,X.jsx)(Ro,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(zo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},Vo=(e,t,n)=>{let r=Bt(),i=tr(t),[a,o]=(0,Y.useState)(()=>Yn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),fr(localStorage,i,e)},[i]);return[dr(e,r,{picked:a,preferred:n}),s]},Ho=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=N(),d=u[e.name],{fields:f}=Ze(),p=We(C(e.name),`update`),{go:m,href:h}=Ye(),g=Bt(),_=!ft(),v=(0,Y.useMemo)(()=>n?.map(yt)??Pt(e,d),[n,e,d]),y=(0,Y.useMemo)(()=>At(e,d,v,{resources:l,views:u,fieldTypes:f}),[e,d,v,l,u,f]),b=(0,Y.useMemo)(()=>g?Ct(n)(y):y,[g,n,y]),x=(0,Y.useMemo)(()=>r?ir(b,e,d,r,l,_):b,[b,e,d,r,l,_]),S=(0,Y.useMemo)(()=>t.map(t=>({...t,id:fe(e,t)})),[t,e]),w=(0,Y.useMemo)(()=>({total:S.length,rowAt:e=>S[e]}),[S]),T=lr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:p}),E=e=>({href:h(e),onFollow:()=>m(e)});return(0,X.jsx)(q,{title:i,description:a,actions:s,className:c,children:S.length===0?(0,X.jsx)(M,{children:o??G(`nothingYet`)}):(0,X.jsx)(Un,{fit:!0,columns:x,source:w,latencyMs:0,onOpenRow:e=>m(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},Uo=e=>{let t=h();return t?.model?(0,X.jsx)(Ho,{...e,model:t.model,items:t.items}):null},Wo=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=Vo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?tn:g,y=(0,Y.useMemo)(()=>i?.map(yt),[i]),b=(0,Y.useMemo)(()=>Ct(i),[i]);return(0,X.jsxs)(q,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(pr,{view:t,value:v,onChange:_}),f]}),className:z(`h-full`,p),children:[(0,X.jsx)(sr,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},Go=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=W(e),{resources:u,views:d}=N(),[f,p]=ht([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(Uo,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Wo,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(Ko,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},Ko=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=gt(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,X.jsx)(y,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{key:o},children:t},o)});return(0,X.jsx)(Wo,{...n,chosen:{rowTo:a,key:o,details:s}})},qo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=ye(),{navigate:a}=ze(),o=me(e),s=Nt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":G(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":G(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(f,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:z(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(Ut,{children:G(`noTab`,{name:r??``})})]})},Jo=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Yo=e=>e===void 0?1/0:Date.parse(e),Xo=(e,t)=>{let n=e=>e.more&&e.items.length>0?Yo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Yo(e.items[a].time)>=Yo(t.items[o].time)?e.items[a++]:t.items[o++];if(Yo(n.time)<r)break;i.push(n)}return i},Zo=({value:e,hints:t,mark:n})=>{let r=T(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(zt,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(w,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&he(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(br,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},Qo=({value:e})=>{let t=typeof e==`string`?le(e):e;return t===$t?(0,X.jsx)(Qe,{children:String(e)}):(0,X.jsx)(ce,{value:t})},$o=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),es=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(A,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(qt,{"aria-hidden":!0,className:z(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)($o,{label:Q(`callInput`),children:(0,X.jsx)(Qo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)($o,{label:Q(`callResult`),children:(0,X.jsx)(Qo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)($o,{label:Q(`callError`),children:(0,X.jsx)(Qe,{children:e.error})})]})]})},ts=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),ns=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},rs=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&se(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:ee(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:ns(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},is=e=>qr.includes(e??``)?e:void 0,as=e=>e==null||e===``?void 0:String(e),os=e=>`call:${JSON.stringify(e)}`,ss=(e,t,n)=>{let r=as(e[n.status]),i=is(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:as(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},cs=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},ls=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=ue(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),cs({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},us=(e,t,n)=>{let{views:r}=N(),i=e?.model.name??``,a=ls(i,{filter:e?.filter,orderBy:e&&mt(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>ss(t,os(Ne(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},ds=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,fs=(e,t)=>e.isLoading?t.loading:t.empty,ps=e=>e.items.length>0&&!!e.error,ms=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),hs=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},gs=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:l,planned:u})=>{let{resources:d,views:f}=N(),p=He(),m=p?.state.kind===`signed-in`?p.state.user.id:void 0,h=n===void 0?[]:[n],g=Jt(d,f,e,h),_=ls(e.name,{filter:t,orderBy:mt(r),pageSize:o,labels:g},u?.messages),v=us(l,o,u?.calls),y=ds(_);if(y===`error`)return(0,X.jsx)(S,{title:Q(`couldNotLoad`),error:_.error,onRetry:ms(_)});if(y===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(M,{children:Q(`loadingMessages`)})});let b=rn(d,e,h,_.items,_.labels),x=Xo({items:v.calls,more:v.hasNextPage},{items:ts(b,r),more:_.hasNextPage}),C=rs(x,{key:t=>String(Ne(e,t)),sender:n,time:r,text:i,status:a}),w=a===void 0?void 0:f[e.name]?.fields[a],T=e.fields[i]!==void 0&&Ae(e.fields[i],f[e.name]?.fields[i]),D=C.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===m);return(0,X.jsxs)(X.Fragment,{children:[ps(_)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(S,{title:Q(`couldNotLoad`),error:_.error,onRetry:ms(_)})}),l&&v.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(S,{title:Q(`couldNotLoadCalls`),error:v.list.error,onRetry:ms(v.list)})}),(0,X.jsx)(_e,{length:x.length,followKey:D?.key,working:c,empty:fs(v.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:_.hasNextPage||v.hasNextPage?()=>hs([_,v.list]):void 0,loadingEarlier:_.isFetchingNextPage||v.isFetchingNextPage,children:C.map(e=>e.kind===`day`?(0,X.jsx)(je,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(es,{call:e,statusHints:v.statusHints},e.key):(0,X.jsx)(xe,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:w}),children:T&&e.text!==``?(0,X.jsx)(E,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},_s=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),vs=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=W(e),{resources:g}=N(),[_]=jo(f===void 0?[]:[f],J()),[v,y]=ht([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:z(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(ie,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(_s,{children:(0,X.jsx)(gs,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},ys=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),bs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:z(`flex`,t),children:e}),xs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:z(`flex flex-col`,t),children:e}),Ss=({node:e,children:t,className:n})=>{let{as:r=`p`}=W(e);return(0,X.jsx)(r,{className:n,children:t})},Cs=({node:e,children:t})=>{let{source:n}=W(e),r=tt(L(J()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Tn,{value:i,children:t})},ws=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=W(e),{values:o,linkTo:s}=gt(),c=o[n];return(0,X.jsxs)(`div`,{className:z(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(Ue,{label:i,value:c??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>s({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,X.jsx)(`span`,{children:c})]})},Ts=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},Es=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=ue(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),Ts({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},Ds=({node:e,at:t,children:n})=>{let r=W(e),i=N().resources[r.reference],a=Xe(L(J())),o=ln(t);return i?(0,X.jsx)(Os,{model:i,...Gt(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},Os=({empty:e,children:t,...n})=>{let{read:r,list:i}=Es(n);return(0,X.jsx)(Le,{read:r,list:i,empty:e,children:t})},ks=({node:e,at:t,children:n})=>{let r=W(e),i=N().resources[r.reference],a=Xe(L(J())),o=ln(t);return i?(0,X.jsx)(Os,{model:i,...an(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},As=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=N(),s=ln(t),c=Be(e,{key:n,enabled:!s}),u=s?Fe(e,s):c;if(u.isPending)return(0,X.jsx)(l,{className:`h-4 w-24`});if(u.error)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:u.error});if(!u.data)return null;let d=i.length>0?(0,X.jsx)(Wt,{value:u.data,children:i}):be(e,o[e.name],u.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:d}):(0,X.jsx)($e,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:d})},js=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=W(e),c=N().resources[i],l=tt(L(J()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(As,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},Ms=(e,t)=>t.map(t=>Ie(e,t)).join(`, `),$=yn(`users`),Ns=({roles:e})=>{let{session:t}=k(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(wr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(I,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(Cr,{email:n.email,gives:Ms(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},Ps=({roles:e,onCreated:t})=>{let{session:n}=k(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=jt(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(I,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(K,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(F,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(F,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(F,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(wr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(A,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},Fs=({user:e,roles:t,self:n})=>{let{session:r}=k(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=jt(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(Tr,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(R,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(A,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(A,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(wr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Is=({roles:e,version:t})=>{let{session:n,state:r}=k(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=Dr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(Er,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(Fs,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},Ls=()=>{let{session:e}=k(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof O?j(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Rs=()=>{let{roles:e,error:t}=Ls(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(K,{message:t}),(0,X.jsx)(Is,{roles:e,version:n}),(0,X.jsx)(Ns,{roles:e}),(0,X.jsx)(Ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},zs=()=>(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(An,{message:P(`checkUnavailable`)})}),Bs=(e,t)=>t.status===`waiting`?(0,X.jsx)(An,{message:P(`checkWaiting`,{address:e})}):t.status===`confirmed`?(0,X.jsx)(An,{message:P(`checkConfirmed`,{address:e})}):t.status===`mismatch`?(0,X.jsx)(K,{message:P(`checkMismatch`,{address:e,from:t.from})}):t.status===`timed_out`?(0,X.jsx)(An,{message:P(`checkTimedOut`)}):null,Vs=({address:e,state:t,error:n,onCheck:r})=>{if(t.status===`unchecked`)return(0,X.jsx)(zs,{});let i=t.status===`waiting`;return(0,X.jsxs)(`div`,{className:`mt-4`,children:[Bs(e,t),(0,X.jsx)(K,{message:n}),(0,X.jsx)(A,{size:`sm`,loading:i,onClick:r,children:t.status===`idle`||i?P(`checkFromAddress`):P(`checkAgain`)})]})},Hs=3e3,Us=async({start:e,result:t,wait:n,stopped:r,onState:i})=>{i({status:`waiting`});let a=await e();if(!r()){if(a.status!==`waiting`)return i(a);for(let e=0;e<40;e++){if(await n(Hs),r())return;let e=await t(a.check);if(r())return;if(e.status!==`waiting`)return i(e)}i({status:`timed_out`})}},Ws=e=>new Promise(t=>setTimeout(t,e)),Gs=(e,t=!1)=>{let[n,r]=(0,Y.useState)({status:`idle`}),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(e);c.current=e;let l=(0,Y.useCallback)(async()=>{if(!o.current){o.current=!0,a(void 0);try{await Us({...c.current,wait:Ws,stopped:()=>s.current,onState:r})}catch(e){if(s.current)return;if(r({status:`idle`}),e instanceof TypeError)return a(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;a(j(e))}finally{o.current=!1}}},[]);return(0,Y.useEffect)(()=>(s.current=!1,t&&l(),()=>{s.current=!0}),[t,l]),{state:n,error:i,check:l}},Ks=({address:e,calls:t,auto:n=!1})=>{let{state:r,error:i,check:a}=Gs(t,n);return(0,X.jsx)(Vs,{address:e,state:r,error:i,onCheck:()=>void a()})},qs=({sender:e,check:t,busy:n,error:r,onSave:i,onClose:a})=>{let[o,s]=(0,Y.useState)(e?.address??``),[c,l]=(0,Y.useState)(e?.name??``),[u,d]=(0,Y.useState)(e?.signature??``),[f,p]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(V,{title:e?e.address:P(`addFromAddress`),description:P(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:a,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:a,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:n,disabled:!o.trim(),onClick:()=>i({address:o.trim(),name:c.trim(),signature:u,isDefault:f}),children:P(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`fromAddress`),(0,X.jsx)(F,{autoFocus:!0,type:`email`,value:o,maxLength:254,placeholder:P(`fromAddressPlaceholder`),onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`fromName`),(0,X.jsx)(F,{value:c,maxLength:100,placeholder:P(`fromNamePlaceholder`),onChange:e=>l(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:P(`defaultFromAddress`)}),(0,X.jsx)(ve,{checked:f,onChange:p,label:P(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`signature`),(0,X.jsx)(Je,{value:u,maxLength:2e3,placeholder:P(`signaturePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsx)(K,{message:r}),t&&!t.available&&(0,X.jsx)(zs,{}),e&&t?.available&&t.calls&&(0,X.jsx)(Ks,{address:e.address,calls:t.calls,...t.auto&&{auto:!0}})]})},Js=e=>e.signature?P(`ownSignature`):P(`genericSignature`),Ys=({senders:{address:e,senders:t,checks:n=!1},onAdd:r,onUpdate:i,onRemove:a,onCheck:o,onCheckResult:s})=>{let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(),m=(0,Y.useRef)(!1),h=t.find(e=>e.isDefault),g=()=>{p(void 0),d(void 0)},_=async e=>{if(!m.current){m.current=!0,l(!0),d(void 0);try{p(await e()||void 0)}catch(e){if(e instanceof TypeError)return d(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;d(j(e))}finally{m.current=!1,l(!1)}}},v=e=>_(async()=>{let t=e.name||null,a=e.signature.trim()?e.signature:null;if(f?.kind===`change`)return void await i(f.sender.id,{name:t,signature:a,isDefault:e.isDefault});let o=await r({address:e.address,...t&&{name:t},...a&&{signature:a}});if(e.isDefault&&await i(o.id,{isDefault:!0}),n)return{kind:`change`,sender:{...o,isDefault:e.isDefault},autoCheck:!0}});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:P(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:P(`fromAddressesDescription`)}),(0,X.jsx)(K,{message:f?void 0:u}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:P(`mailboxOwnAddress`)})]}),h?(0,X.jsx)(A,{size:`sm`,variant:`ghost`,loading:c,onClick:()=>void _(async()=>void await i(h.id,{isDefault:!1})),children:P(`makeDefault`)}):(0,X.jsx)(R,{tone:`blue`,children:P(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Js(e)})]}),e.isDefault&&(0,X.jsx)(R,{tone:`blue`,children:P(`default`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>p({kind:`change`,sender:e}),children:P(`edit`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>p({kind:`remove`,sender:e}),children:P(`remove`)})]},e.id))]}),(0,X.jsxs)(A,{onClick:()=>p({kind:`add`}),children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`addFromAddress`)]}),f?.kind===`add`&&(0,X.jsx)(qs,{check:{available:n},busy:c,error:u,onSave:e=>void v(e),onClose:g}),f?.kind===`change`&&(0,X.jsx)(qs,{sender:f.sender,check:((e,t=!1)=>({available:n,calls:{start:()=>o(e.id),result:t=>s(e.id,t)},...t&&{auto:t}}))(f.sender,f.autoCheck),busy:c,error:u,onSave:e=>void v(e),onClose:g},f.sender.id),f?.kind===`remove`&&(0,X.jsx)(V,{title:P(`removeFromAddress`,{address:f.sender.address}),description:P(`removeFromAddressDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:g,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:c,onClick:()=>void _(()=>a(f.sender.id)),children:P(`remove`)})]}),children:(0,X.jsx)(K,{message:u})})]})},Xs=(e,t,n)=>Object.fromEntries(Hn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,u(`signInOnly`,{provider:n(e.provider),name:e.name})])),Zs=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=k(),{account:i}=t,[a]=(0,Y.useState)(Zt),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=U(o,P(`couldNotReadMethods`));return s?(0,X.jsx)(Ot,{title:P(`mailbox`),description:P(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:Xs(e,s,e=>r.find(t=>t.id===e)?.name??Ke(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&g(a,e.length===1?e[0].name:P(`theProvider`)),children:(0,X.jsx)(Ys,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return It(),await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),It(),await l()},onRemove:async e=>{await i.removeMailSender(e),It(),await l()},onCheck:e=>i.checkMailSender(e),onCheckResult:(e,t)=>i.mailSenderCheckResult(e,t)})}):(0,X.jsx)(B,{error:c})},Qs=()=>{let{personalMail:e}=k();return e.length>0?(0,X.jsx)(Zs,{links:e}):null},$s=e=>Or(e.name)??`An unnamed app`,ec=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),tc=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof O))throw e;a(j(e))}r(!1)};return(0,X.jsxs)(I,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(K,{message:o?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=kr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Pr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:$s(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,pt(Date.parse(e.allowedAt)),` · `,ec(e)]})]}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(V,{title:`Disconnect ${$s(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(A,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(K,{message:i})})]})},nc=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},rc=({url:e,appName:t})=>(0,X.jsx)(I,{title:P(`mcpAddress`),description:P(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ar,{value:e,copyLabel:P(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:nc(e,t),target:`_blank`,rel:`noreferrer`,className:ke(),children:[(0,X.jsx)(i,{className:`size-3.5`}),P(`addToClaude`)]})]})}),ic=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.connectedApps(),[e]),P(`couldNotReadMethods`));return t?(0,X.jsx)(tc,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(B,{error:n})},ac=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rc,{url:e,appName:N().appName}),(0,X.jsx)(ic,{})]}),oc=()=>{let{mcp:e}=k();return e?(0,X.jsx)(ac,{url:e.url}):null},sc={30:30,90:90,365:365,never:void 0},cc={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},lc=e=>pt(Date.parse(e)),uc=e=>e?P(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:lc(e)}):P(`neverExpires`),dc=e=>[P(`createdOn`,{date:lc(e.createdAt)}),uc(e.expiresAt),e.lastUsedAt?P(`lastUsedOn`,{date:lc(e.lastUsedAt)}):P(`notUsedYet`),e.organization?P(`actsAsIn`,{role:e.role,organization:e.organization}):P(`actsAs`,{role:e.role})].join(` · `),fc=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`90`),[p,m]=(0,Y.useState)(),h=()=>{c(void 0),o(void 0),m(void 0)},g=(0,Y.useRef)(!1),_=async e=>{if(!g.current){g.current=!0,i(!0),o(void 0);try{c(await e()),m(void 0)}catch(e){if(e instanceof TypeError)return o(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):o(j(e))}finally{g.current=!1,i(!1)}}},v=()=>_(async()=>{let e=sc[d];return{kind:`created`,created:await t({name:l.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(I,{title:P(`accessTokens`),description:P(`accessTokensDescription`),children:[(0,X.jsx)(K,{message:s?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:P(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:dc(e)})]}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>c({kind:`revoke`,token:e}),children:P(`revoke`)})]},e.id))}),(0,X.jsxs)(A,{onClick:()=>{u(``),f(`90`),c({kind:`create`})},children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`newAccessToken`)]}),s?.kind===`create`&&(0,X.jsxs)(V,{title:P(`newAccessToken`),description:P(`newAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:h,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:r,disabled:!l.trim(),onClick:()=>void v(),children:P(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:l,maxLength:100,placeholder:P(`accessTokenNamePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`accessTokenExpiry`),(0,X.jsx)(Ft,{value:d,onChange:e=>f(e.target.value),children:Object.keys(sc).map(e=>(0,X.jsx)(`option`,{value:e,children:P(cc[e])},e))})]}),p===`asked`&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:P(`confirmedCreateAccessToken`)}),(0,X.jsx)(K,{message:a})]}),s?.kind===`created`&&(0,X.jsx)(V,{title:P(`accessTokenCreated`,{name:s.created.personalAccessToken.name}),description:P(`accessTokenCreatedDescription`),onClose:h,actions:(0,X.jsx)(A,{variant:`primary`,onClick:h,children:P(`done`)}),children:(0,X.jsx)(Ar,{value:s.created.token,copyLabel:P(`copyAccessToken`)})}),s?.kind===`revoke`&&(0,X.jsx)(V,{title:P(`revokeAccessToken`,{name:s.token.name}),description:P(`revokeAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:h,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:r,onClick:()=>void _(async()=>(await n(s.token.id),void 0)),children:P(`revoke`)})]}),children:(0,X.jsx)(K,{message:a})})]})},pc=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),P(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{message:n}),(0,X.jsx)(fc,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(B,{error:n})},mc=()=>k().personalAccessTokens?(0,X.jsx)(pc,{}):null,hc={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},gc=e=>e.provider===`google`,_c=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof O))throw e;s(j(e))}finally{a(void 0)}};return(0,X.jsxs)(I,{title:P(`connections`),description:P(`connectionsDescription`),children:[(0,X.jsx)(K,{message:c?void 0:o}),(0,X.jsx)(An,{message:u}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Br,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(A,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?P(`connectAgain`,{name:e.label}):P(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[P(`connectedOn`,{date:pt(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(R,{tone:`amber`,children:P(`connectionNeedsSignIn`)}):(0,X.jsx)(R,{tone:`green`,children:P(`connected`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:P(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:P(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(bt,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(V,{title:P(`disconnectTitle`,{name:c.connection.label}),description:gc(c.connection)?`${P(`disconnectDescription`)} ${P(`disconnectWholeGrant`)}`:P(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>l(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(P(hc[await n(c.accountId)]))),children:P(`disconnect`)})]}),children:o&&(0,X.jsx)(K,{message:o})})]})},vc=()=>{let{session:e,connectAccount:t}=k(),{account:n}=e,[r]=(0,Y.useState)(Zt),{data:i,error:a,reload:o}=U((0,Y.useCallback)(()=>n.workflowConnections(),[n]),P(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(_c,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&g(r,P(`theProvider`))}):(0,X.jsx)(B,{error:a})},yc=e=>e.code===`LAST_ADMIN`?P(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?P(`deleteAccountLocked`):j(e),bc=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(!1),d=(0,Y.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(yc(e)),o(!1)}};return(0,X.jsxs)(V,{title:P(`deleteAccountQuestion`),description:P(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:n,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:P(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`deleteAccountPassword`),(0,X.jsx)(F,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(K,{message:s})]}),l&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},xc=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(I,{title:P(`deleteAccount`),description:P(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(A,{variant:`danger`,onClick:()=>i(!0),children:P(`deleteAccount`)}),r&&(0,X.jsx)(bc,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},Sc=()=>{let{session:e,state:t,deleteAccount:n}=k(),{account:r}=e,{data:i,error:a}=U((0,Y.useCallback)(()=>r.signInMethods(),[r]),P(`couldNotReadMethods`));return i?(0,X.jsx)(xc,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(B,{error:a})},Cc=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],wc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Tc=(e,t)=>e.find(([e])=>e.test(t))?.[1],Ec=e=>e?{browser:Tc(Cc,e),system:Tc(wc,e)}:{},Dc=e=>e.device?P(`deviceThrough`,{device:e.device,provider:e.name}):e.name,Oc=(e,t)=>{if(e.staff)return t?P(`staffOf`,{operator:t}):P(`staff`);let{browser:n,system:r}=Ec(e.userAgent);return n&&r?P(`browserOn`,{browser:n,system:r}):r?P(`aBrowserOn`,{system:r}):n??P(`unknownDevice`)},kc=e=>{if(e.staff)return Hr;let{system:t}=Ec(e.userAgent);return t===`iPhone`||t===`Android`?Wr:t===`iPad`?Kr:Rr},Ac=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),jc=(e,t)=>e.kind===`one`?P(`signOutDevice`,{name:Oc(e.session,t)}):e.kind===`link`?P(`signOutDevice`,{name:Dc(e.link)}):P(`signOutOthersTitle`),Mc=e=>P(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),Nc=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof O))throw e;l(j(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(I,{title:P(`devices`),description:P(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:P(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[Ac(f).map(e=>{let n=kc(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Oc(e,t)}),e.current&&(0,X.jsx)(R,{tone:`green`,children:P(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[P(`signedInFromUntil`,{from:xt(Date.parse(e.createdAt)),until:xt(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:P(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Dc(t)}),n&&(0,X.jsx)(R,{tone:`green`,children:P(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:P(`linkedOn`,{date:xt(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:P(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(A,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:P(`signOutOthers`)}),u&&(0,X.jsx)(V,{title:jc(u,t),description:Mc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>d(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:o,onClick:()=>void h(u),children:P(`signOut`)})]}),children:(0,X.jsx)(K,{message:c})})]})},Pc=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=k(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=U(i,P(`couldNotReadDevices`));return a?(0,X.jsx)(Nc,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(B,{error:o})},Fc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},Ic=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(),h=e===`required`&&t.length<=1,g=async e=>{o(!0),c(void 0),m(void 0);try{await e(),u(void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):c(j(e))}o(!1)};return(0,X.jsxs)(I,{title:P(`passkeys`),status:e===`required`&&(0,X.jsx)(R,{tone:`blue`,children:P(`required`)}),description:P(Fc[e]),children:[(0,X.jsx)(K,{message:l?void 0:s}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(qe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??P(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?P(`addedOn`,{date:pt(Date.parse(e.createdAt))}):P(`addedEarlier`),` · `,e.backedUp?P(`synced`):P(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>{f(e.name??``),u({kind:`rename`,passkey:e})},children:P(`rename`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,disabled:h,title:h?P(`keepLastPasskey`):void 0,onClick:()=>u({kind:`remove`,passkey:e}),children:P(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(A,{loading:a&&!l,onClick:()=>void g(n),children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`addPasskey`)]}),p===`asked`&&(0,X.jsx)(Ee,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:P(`confirmedAddPasskey`)}),l?.kind===`rename`&&(0,X.jsxs)(V,{title:P(`renamePasskey`),description:P(`renamePasskeyDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>u(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:a,disabled:!d.trim(),onClick:()=>void g(()=>r(l.passkey.id,d.trim())),children:P(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:d,maxLength:60,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(K,{message:s})]}),l?.kind===`remove`&&(0,X.jsx)(V,{title:P(`removePasskey`),description:P(`removePasskeyDescription`,{name:l.passkey.name??P(`thisPasskey`)}),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>u(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:a,onClick:()=>void g(()=>i(l.passkey.id)),children:P(`remove`)})]}),children:s&&(0,X.jsx)(K,{message:s})})]})},Lc=()=>{let{account:e}=k().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=U(t,P(`couldNotReadMethods`));if(!n)return(0,X.jsx)(B,{error:r});let[a,o]=n;return(0,X.jsx)(Ic,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},Rc=e=>e.code===`PASSWORD_TOO_SHORT`?P(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?P(`passwordTooLong`):j(e),zc=(e,t)=>{if(e.length<12)return P(`useAtLeast`,{length:12});if(e!==t)return P(`passwordsDiffer`)},Bc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=zc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof O))throw e;f(Rc(e)),u(!1)}}};return(0,X.jsx)(V,{title:P(e?`changePassword`:`setPassword`),description:P(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:n,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:P(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`currentPassword`),(0,X.jsx)(F,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`newPassword`),(0,X.jsx)(F,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`repeatPassword`),(0,X.jsx)(F,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:P(`changeSignsOutOthers`)}),(0,X.jsx)(K,{message:d})]})})},Vc=({rule:e,hasPassword:t,staff:n})=>P(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),Hc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(I,{title:P(`password`),description:Vc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(An,{message:s?P(`passwordSaved`):void 0}),l&&(0,X.jsx)(A,{onClick:()=>{c(!1),o(!0)},children:P(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(Bc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},Uc=()=>{let{session:e,state:t}=k(),{account:n}=e,{data:r,error:i,reload:a}=U((0,Y.useCallback)(()=>n.signInMethods(),[n]),P(`couldNotReadMethods`));return r?(0,X.jsx)(Hc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(B,{error:i})},Wc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof O))throw e;p(j(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(V,{title:P(`changeEmail`),description:P(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:P(`otherAddress`)}),(0,X.jsx)(A,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:P(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`code`),(0,X.jsx)(D,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(K,{message:f})]}):(0,X.jsxs)(V,{title:P(`changeEmail`),description:P(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:r,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:P(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`newEmail`),(0,X.jsx)(F,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(K,{message:f})]})},Gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof O))throw e;m(j(e))}f(!1)};return(0,X.jsxs)(I,{title:P(`profile`),description:P(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:P(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:P(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(A,{onClick:()=>{u(e),m(void 0),o(!0)},children:P(`changeName`)}),r&&(0,X.jsx)(A,{onClick:()=>c(!0),children:P(`changeEmail`)})]}),a&&(0,X.jsxs)(V,{title:P(`changeName`),description:P(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>o(!1),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:P(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(K,{message:p})]}),s&&r&&(0,X.jsx)(Wc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},Kc=()=>{let{session:e,changeEmail:t}=k(),{data:n,loaded:r,error:i,reload:a}=U((0,Y.useCallback)(()=>e.session(),[e]),P(`couldNotReadProfile`));if(!r)return(0,X.jsx)(B,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(Gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},qc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),[p,m]=(0,Y.useState)(!1),h=async()=>{u(!0),f(void 0),m(!1);try{await a(i?s:void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(!0):f(j(e)),u(!1)}};return(0,X.jsxs)(V,{title:e,description:t,onClose:o,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:o,children:P(`cancel`)}),(0,X.jsx)(A,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void h(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`yourPassword`),(0,X.jsx)(F,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:s,invalid:!!d,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s&&void h()})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d}),p&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>void h()})]})},Jc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Yc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(R,{tone:`green`,children:P(`on`)}):t===`required`?(0,X.jsx)(R,{tone:`amber`,children:P(`required`)}):(0,X.jsx)(R,{children:P(`off`)}),p=P(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:Jc[t]);return l?.kind===`setup`?(0,X.jsx)(I,{title:P(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(Ve,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(I,{title:P(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(A,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:P(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(A,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:P(`addAuthenticator`)}),n&&r&&(0,X.jsx)(A,{onClick:()=>u({kind:`new-codes`}),children:P(`newBackupCodes`)}),n&&(0,X.jsx)(A,{variant:`danger`,disabled:t===`required`,title:t===`required`?P(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:P(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(qc,{title:P(`turnOffTitle`),description:P(`turnOffDescription`),confirmLabel:P(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(qc,{title:P(`newCodesTitle`),description:P(`newCodesDescription`),confirmLabel:P(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(V,{title:P(`yourNewCodes`),description:P(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(A,{variant:`primary`,onClick:d,children:P(`savedCodes`)}),children:(0,X.jsx)(x,{codes:l.codes})})]})},Xc=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.signInMethods(),[e]),P(`couldNotReadMethods`));return t?(0,X.jsx)(Yc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(B,{error:n})},Zc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(Ut,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Qc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(wt,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Zc,{problem:G.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Zc,{problem:G.rich(`noComponent`,{component:e}),fallback:n}),$c={Page:to,Grid:ja,Card:di,Stat:Bo,RecordCard:ao,Field:Ea,Diff:Ca,Table:Go,CardRow:hi,RecordRow:To,RecordCards:xo,Chart:gi,Timeline:ta,Graph:aa,Progress:ro,Image:za,ModalForm:eo,Thread:vs,Composer:ba,Action:ui,Show:No,Switch:Fo,Match:Io,Link:Ya,Settings:ko,Tabs:qo,Tab:Jo,Users:Rs,Profile:Kc,Password:Uc,Passkeys:Lc,TwoFactor:Xc,ConnectedAccounts:Tt,PersonalMail:Qs,Connections:vc,Devices:Pc,ConnectedApps:oc,PersonalAccessTokens:mc,DeleteAccount:Sc,Box:ys,Row:bs,Column:xs,Text:Ss,ReferenceManyField:Ds,ReferenceArrayField:ks,ArrayField:Cs,RecordsIterator:pi,ReferenceField:js,SelectInput:ws,Details:xa,Summary:Sa,TextField:Ha,NumberField:Ua,DateField:Wa,BooleanField:Ga,UrlField:Ka,ChipField:qa},el=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),tl=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:o(t,...n,r)}})),nl=({text:e})=>{let t=J(),n=un(),r={...L(t),params:n};return(0,X.jsx)(X.Fragment,{children:_t(e,e=>gn(tt(r,e)))})},rl=(e,t)=>e.includes(`{{`)?(0,X.jsx)(nl,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),il=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?rl(e,n):(0,X.jsx)(dl,{node:e,at:t},n)),al=e=>{let t=[];for(let n of e){let e=t.at(-1);Xr(n.child)&&e&&Xr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Xr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:il(e)},t):(0,X.jsx)(dl,{node:n.child,at:n.at},t)})},ol=e=>Ht(e)||Array.isArray(e)&&e.length>0&&e.every(Ht),sl=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>ol(n)?[[e,(0,X.jsx)(X.Fragment,{children:al(cl(n,t,e))})]]:[])),cl=(e,t,n)=>Array.isArray(e)?tl(e,t,`props`,n):[{child:e,...t!==void 0&&{at:o(t,`props`,n)}}],ll=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ul=(e,t)=>{let n=ll(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>Ht(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=de(t,String(e.props.i18nKey),ll(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Ht(e)?e:String(e)):[i]},dl=({node:e,at:t})=>{let{components:n}=Ze(),r=J(),i=un(),a=De(),o=(0,Y.useMemo)(()=>Lt(et(e,{...L(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:il(ul(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(na,{node:o,children:al(tl(o.children,t,`children`))}):void 0;return(0,X.jsx)(Qc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(ot,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...Mt(o.props),children:r})})})}let s=$c[o.type];if(!s)return(0,X.jsx)(Ut,{children:G.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=tl(o.children,t,`children`),u=(0,X.jsx)(s,{node:o,at:t,slots:sl(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?il(l):al(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||el.has(o.type)?u:(0,X.jsx)(`div`,{className:c,children:u});return o.fallback?(0,X.jsx)(wt,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:d}):d};export{ms as a,ns as c,yo as d,lo as f,ua as h,gs as i,Vo as l,ya as m,Qc as n,ps as o,oo as p,_s as r,ds as s,dl as t,Ao as u};
|
|
3
|
-
//# debugId=
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-DRWl6A2P.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-CgllsYQy.js","assets/vendor-t7Q7QbPu.js","assets/app-lQJl2mz_.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$a as r,$c as i,$r as a,$s as o,$t as s,A as c,Ac as l,An as u,Bl as d,Cc as f,Cl as p,Cn as m,Cr as h,Cs as g,Dl as _,Dn as v,Ec as y,En as b,Eo as x,Er as S,Es as C,Fc as w,Fl as T,Fn as E,Fo as D,Ft as ee,Gc as te,Gi as ne,Gs as O,Hl as re,Hs as k,I as ie,Il as ae,In as oe,It as se,Jn as ce,Kn as le,Kr as ue,Ks as de,La as fe,Lc as pe,Ma as me,Mi as he,Ms as ge,Mt as _e,N as ve,Na as ye,Nc as A,Nl as be,Nt as xe,O as Se,Oc as Ce,Oi as we,On as Te,Oo as Ee,Os as De,Pa as Oe,Pc as ke,Pi as Ae,Pt as je,Qa as Me,Ra as Ne,Rn as Pe,Sn as Fe,So as Ie,Sr as Le,Ss as j,Ta as Re,Tc as ze,Tn as Be,To as Ve,Tr as M,Ts as N,Us as He,V as Ue,Va as We,Vi as Ge,Vs as P,Ws as Ke,Xc as qe,Xn as Je,Xo as F,Xr as Ye,Xs as Xe,Ya as Ze,Yn as Qe,Yr as $e,Ys as et,Zs as tt,_n as nt,_s as I,_t as rt,a as it,ac as at,an as ot,at as st,b as ct,br as L,bs as R,c as lt,cc as ut,cn as dt,cs as ft,da as pt,dc as mt,dn as ht,dr as gt,du as _t,ea as vt,ec as yt,en as bt,fa as xt,fc as St,fn as Ct,fo as wt,fs as Tt,gn as Et,gr as Dt,gs as Ot,gt as kt,hl as z,hn as At,ho as jt,hs as B,iu as Mt,ja as Nt,jc as V,jl as Pt,jn as Ft,kn as It,ks as Lt,lc as Rt,ll as zt,ls as Bt,ma as Vt,mc as Ht,ml as H,mo as Ut,mr as Wt,ms as U,nc as Gt,oc as Kt,ol as qt,or as Jt,pc as Yt,pn as W,po as G,pr as Xt,ps as Zt,qc as Qt,qn as $t,rn as en,ru as tn,sc as nn,sr as rn,tc as an,tr as on,u as sn,uc as cn,un as ln,ur as un,uu as dn,v as fn,va as pn,vn as mn,vr as hn,vs as K,vu as gn,w as _n,wc as vn,wl as yn,wn as bn,wr as q,wt as xn,x as Sn,xc as Cn,xi as wn,xr as Tn,xs as En,y as Dn,ya as On,yn as kn,yr as J,ys as An,z as jn,zi as Mn}from"./app-CgllsYQy.js";import{C as Nn,f as Pn,o as Fn,s as In}from"./vendor-t7Q7QbPu.js";import{C as Ln,Ct as Rn,Dt as zn,Et as Bn,O as Vn,Ot as Hn,Q as Un,St as Wn,Tt as Gn,X as Kn,Z as qn,_t as Jn,at as Yn,b as Xn,ct as Zn,dt as Qn,ft as $n,gt as er,it as tr,jt as nr,k as rr,l as ir,lt as ar,mt as or,n as sr,nt as cr,o as lr,ot as ur,rt as dr,st as fr,t as pr,tt as mr,ut as hr,wt as gr,x as _r,xt as vr,y as yr}from"./embedded-list-BIvz_g-b.js";import{t as br}from"./circle-alert-D8UYAgz6.js";import{t as xr}from"./page-header-Ddz2r5ic.js";import{n as Sr,t as Cr}from"./pending-invitation-row-DAXBo7SZ.js";import{n as wr,t as Tr}from"./person-row-BNM1LeOM.js";import{n as Er,t as Dr}from"./use-paged-search-CHtW6YbU.js";import{n as Or,t as kr}from"./client-publisher-D39SlIhp.js";import{t as Ar}from"./copy-field-DBuqCBWo.js";var jr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};jr.node;var Mr=H(jr),Nr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Nr.node;var Pr=H(Nr),Fr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Fr.node;var Ir=H(Fr),Lr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Lr.node;var Rr=H(Lr),zr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};zr.node;var Br=H(zr),Vr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Vr.node;var Hr=H(Vr),Ur={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ur.node;var Wr=H(Ur),Gr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Gr.node;var Kr=H(Gr),qr=[`done`,`error`,`running`];Yt(`TextField`,!1),Yt(`NumberField`,!1),Yt(`DateField`,!1),Yt(`BooleanField`,!1),Yt(`UrlField`,!1),Yt(`ChipField`,!1);var Jr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Yr=e=>typeof e!=`string`&&!e.custom&&Jr.has(e.type),Xr=e=>typeof e==`string`||Yr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Zr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Qr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),$r=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},ei=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},ti=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,ni=new Set([`http:`,`https:`,`mailto:`,`tel:`]),ri=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:ni.has(`${n.toLowerCase()}:`)?e:void 0},ii=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),ai=e=>e==null||e===``?void 0:String(e),oi=(e,t)=>e<t?-1:+(e>t),si=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=ai(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=ai(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>ai(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=ai(e[i.source]),s=ai(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>oi(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>oi(e.id,t.id)),edges:s.sort((e,t)=>oi(e.source,t.source)||oi(e.target,t.target)||oi(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ci=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=N(),s=Rn(e.name,void 0),c=vt(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>m(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let h=f.length-p.length,g=vr(`actionCount`,{label:r??d.label,count:p.length}),_=e=>s.runEach(d,p,h,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Bn(d)?u(!0):void _(),children:g}),l&&(0,X.jsx)(Gn,{action:d,label:g,danger:i===`danger`||i===void 0&&zn(d),records:p.map(e=>e.record),names:p.map(t=>Wn(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),_()},onSubmit:async e=>{u(!1),await _(e)}})]})},li=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=hn(),c=gr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Bn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Gn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ui=({node:e,className:t})=>{let n=W(e),r=h(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ci,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(li,{...n,className:t})},di=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=W(e);return(0,X.jsx)(q,{title:i,description:a,actions:n.actions,className:z(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},fi=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=h();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...m(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Wt,{value:s,row:{index:o,count:i.length},children:e}),c)})},pi=({children:e})=>(0,X.jsx)(fi,{children:e}),mi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=ln(t),p=b(e,{filter:n,sort:r,pageSize:i,enabled:!f}),m=f??p,h=f?f.rows:p.data?.items??[];return(0,X.jsx)(q,{title:a,description:o,actions:c,className:d,children:m.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(l,{className:`h-24 w-56`},t))}):m.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:m.error}):h.length===0?(0,X.jsx)(M,{children:s??G(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(Tn,{value:{model:e,items:h,...f&&{planned:!0}},children:(0,X.jsx)(fi,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:u})})})})},hi=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=W(e),o=N().resources[i];return o?(0,X.jsx)(mi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},gi=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=W(e),{resources:u,views:d}=N(),f=u[r];return f?(0,X.jsx)(q,{title:i,description:a,actions:t.actions,className:z(`h-full`,n),children:(0,X.jsx)($n,{model:f,view:d[r],...l})}):null},_i=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Be(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Wt,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(M,{children:G(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},vi=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},yi=e=>e==null?``:String(e),bi=(e,t,n)=>n===0?0:(e-t)/n*100,xi=(e,t,n)=>{let r=new Map;for(let i of e){let e=vi(i[t.start]);if(e===void 0)continue;let a=vi(i[t.end]),o=Math.max(e,a??n),s=r.get(yi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(yi(i[t.lane]),s);let c=s.bars.get(yi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(yi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},Si=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},Ci=(e,t,n)=>{let r=xi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:bi(n,a,s),width:bi(r,a,s)-bi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:bi(o,a,s),width:bi(c,a,s)-bi(o,a,s),segments:i}});return{key:e,value:n.value,rows:Si(r)}}),from:a,to:o}},wi=(e,t)=>{let n=e.end-e.start;return{left:bi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},Ti=6e4,Ei=60*Ti,Z=24*Ei,Di=[5*Ti,15*Ti,30*Ti,Ei,3*Ei,6*Ei,12*Ei,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],Oi=365*Z,ki=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Ai=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=Di.find(n=>ki(e,t,n,i,a)<=6)??Math.ceil(r/5/Oi)*Oi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:bi(a,e,r)})}return{daily:o>=Z,ticks:s}},ji=e=>({lane:yi(e.lane),bar:e.key}),Mi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ni=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Pi=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Fi=({from:e,to:t,dated:n})=>{let r=n?`UTC`:Re(),i=e=>n?0:Ni(e,r),{daily:a,ticks:o}=Ai(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Pi(e.left)}`,style:{left:`${e.left}%`},children:a?Vt(e.at+i(e.at)):On(e.at,r)},e.at))})},Ii=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&re(a)?{className:En[a],striped:i}:{color:er(e,t,n===void 0?null:n,-1),striped:i}},Li=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ri=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Ii(t,n,r.value),{left:o,width:s}=wi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:z(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...Li(a)}},i)}),zi=(e,t)=>t?pt(e):xt(e),Bi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return G(`timelineRange`,{from:zi(n,a),to:i?G(`timelineNow`):zi(r,a)})},Vi=(e,t,n,r)=>`${we(t.fields[r.color],e.value,n?.fields[r.color])}: ${Bi(t,r,e.start,e.end,e.open)}`,Hi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??we(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Bi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Vi(e,t,n,r))].join(`; `)},Ui=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Wi=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=N().resources[t.fields[r.bar]?.relation?.resource??``],s=Pe(o??t,e.key,o!==void 0),c=Hi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ri,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Ui,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(Ce,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:z(Ui,f&&`ring-2 ring-foreground`),...l,children:d})},Gi=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Fi,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(Te,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Wi,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ki=({model:e,view:t,fields:n,value:r})=>{let i=Ii(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:z(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:Li(i)})},qi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ki,{...t,value:e}),we(n,e,t.view?.fields[t.fields.color])]},e))})},Ji=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:G(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(Te,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Bi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ki,{...t,value:e.value}),we(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Bi(n,i,e.start,e.end,e.open)]},a))})]})},Yi=500,Xi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...p.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Yi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Zi=(e,{enabled:t=!0,...n})=>Fn({...Xi(ge(),e,n),enabled:t,placeholderData:Pn}),Qi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=ut,title:s,description:c,empty:u,actions:d,className:f,choose:p,details:m})=>{let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e=>e?ji(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=ln(i),C=Zi(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),w=x??C,T=x?x.rows:C.data?.rows??[],E=!x&&C.data?.cut===!0,D=Ci(T,n,Date.now());return(0,X.jsxs)(q,{title:s,description:c,actions:d,className:z(`h-full`,f),children:[(()=>{if(w.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(l,{className:`h-6`},t))});if(w.error)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:w.error});if(D.lanes.length===0)return(0,X.jsx)(M,{children:u??G(`nothingYet`)});let r=new Set(T.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Gi,{shape:D,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),E&&(0,X.jsx)(M,{children:G(`timelineCut`,{count:T.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Ji,{bar:Mi(D,h)??Mi(D,_),model:e,view:t,fields:n})})]})})(),m]})},$i=(e,t)=>e.type===`integer`?Number(t):t,ea=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=gt(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,X.jsx)(y,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{filter:Jn(s,$i(s,a),n.filter),sort:n.sort},children:t},a)});return(0,X.jsx)(Qi,{...n,choose:{barTo:o,chosen:a},details:c})},ta=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=W(e),{resources:h,views:g}=N(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Rt(e),sort:cn(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Qi,{...v}):(0,X.jsx)(ea,{...v,select:s,children:r})},na=({node:e,children:t})=>{let n=St(e),r=Xt(),{resources:i}=N();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,X.jsx)(y,{name:n.param,children:(0,X.jsx)(_i,{model:o,query:{key:a},className:``,children:t},a)})},ra=(0,Y.lazy)(()=>Nn(()=>import(`./graph-view-DRWl6A2P.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),ia=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(w,{})}),aa=({node:e,at:t,slots:n,children:r,className:i})=>{let a=W(e),o=dt(e,t),s=Xt(),c=o.nodes,l=o.edges,{label:u,group:d,status:f,source:p,target:m}=a,h=(0,Y.useMemo)(()=>({label:u,source:p,target:m,...d!==void 0&&{group:d},...f!==void 0&&{status:f}}),[u,p,m,d,f]),g=JSON.stringify([c?.rows,l?.rows,h]),_=(0,Y.useMemo)(()=>c&&l&&si({nodes:c.rows,edges:l.rows,key:c.model.primaryKey[0],edgeKey:l.model.primaryKey,fields:h}),[g]);if(!c||!l||!_)return null;let v=c.error??l.error;if(v&&e.fallback)throw v;if(v)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:v});if(c.isPending||l.isPending)return ia;if(_.nodes.length===0)return(0,X.jsx)(M,{children:a.empty??G(`nothingYet`)});let y=a.select,b=y!==void 0&&s?{chosen:s.given[y],linkTo:e=>s.linkTo({[y]:e})}:void 0;return(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:ia,children:(0,X.jsx)(ra,{shape:_,nodes:c,edges:l,fields:h,props:a,...b&&{select:b},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&b?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(na,{node:e,children:r})})]})},oa=({onPick:e,accept:t})=>{let n=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:n,type:`file`,multiple:!0,hidden:!0,accept:t,"aria-label":s(`filesToAttach`),onChange:t=>{e([...t.target.files??[]]),t.target.value=``}}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`attachFiles`),title:s(`attachFiles`),onClick:()=>n.current?.click(),children:(0,X.jsx)(Qt,{className:`size-4`})})]})},sa=`message`,ca=(e,t,n,r)=>[{op:`create`,resource:e,ref:sa,data:t},...r.map(e=>({op:`create`,resource:n.resource,data:{[n.field]:{$ref:sa},[n.file]:e}}))],la=e=>{let t=e.results[0];if(t?.op!==`create`)throw Error(`A message batch starts with the message it creates`);return t.record},ua=(e,t,n,r)=>[...e.attachments?r.map(t=>({op:`delete`,resource:e.attachments.resource,key:t.key})):[],{op:`delete`,resource:e.resource,key:sn(t,n)}],da=(e,t)=>{if(!(t===void 0||e.size<=t))return s(`fileTooLarge`,{size:Ge(e.size),max:Ge(t)})},fa=(e,t,n)=>e.map((e,r)=>({key:t+r,name:e.name,size:e.size,sent:0,refusal:da(e,n)})),pa=e=>e.ticket===void 0&&e.refusal===void 0,ma=e=>e.flatMap(e=>e.ticket===void 0?[]:[e.ticket]),ha=e=>!e.some(pa)&&ma(e).length>0,ga=e=>e.refusal===void 0?e.ticket!==void 0||e.size===0?Ge(e.size):s(`uploadedPercent`,{percent:Math.floor(Math.min(e.sent,e.size)/e.size*100)}):e.refusal,_a=({uploads:e,onRemove:t})=>(0,X.jsx)(`ul`,{"aria-label":s(`filesToSend`),className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex max-w-full items-center gap-1 rounded-md border border-border py-0.5 pl-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:e.name}),(0,X.jsx)(`span`,{role:e.refusal===void 0?void 0:`alert`,className:z(`min-w-0`,e.refusal===void 0?`text-muted-foreground`:`text-danger-text`),children:ga(e)}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`takeFileOff`,{name:e.name}),title:s(`takeFileOff`,{name:e.name}),onClick:()=>t(e.key),children:(0,X.jsx)(pe,{className:`size-3.5`})})]},e.key))}),va=e=>{let t=ge(),{resources:n}=N(),r=e&&n[e.resource]?.fields[e.file]?.file?.maxSize,[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(0),c=(0,Y.useRef)(new Map),l=(e,t)=>a(n=>n.map(n=>n.key===e?{...n,...t}:n)),u=(e,n,r)=>{let i=new AbortController;c.current.set(n.key,i),t.upload(e.resource,e.file,r,{signal:i.signal,onProgress:e=>l(n.key,{sent:e})}).then(e=>l(n.key,{ticket:e.value}),e=>{i.signal.aborted||l(n.key,{refusal:s(`fileNotUploaded`,{reason:wn(e)})})}).finally(()=>c.current.delete(n.key))};return(0,Y.useEffect)(()=>{let e=c.current;return()=>e.forEach(e=>e.abort())},[]),{uploads:i,tickets:ma(i),uploading:i.some(pa),ready:ha(i),pick:t=>{if(!e||t.length===0)return;let n=fa(t,o.current,r);o.current+=t.length,a(e=>[...e,...n]),n.forEach((n,r)=>{n.refusal===void 0&&u(e,n,t[r])})},remove:e=>{c.current.get(e)?.abort(),a(t=>t.filter(t=>t.key!==e))},sent:e=>a(t=>t.filter(t=>pa(t)||t.ticket!==void 0&&!e.includes(t.ticket)))}},Q=yn(`app/conversation`),ya=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a,attachments:o,onDraft:s,onSent:c})=>{let{resources:l}=N(),u=ge(),d=v(),f=C(e),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(),_=va(o);if(!l[e]||!We(f,`create`))return null;let y=o&&l[o.resource]?.fields[o.file],b=y&&Mn(y);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h!==void 0&&(0,X.jsx)(S,{title:Q(`notSent`),error:h}),(0,X.jsx)(xn,{onSend:async(r,i)=>{m(!0),g(void 0);let s=_.tickets,f={...n,...r!==``&&{[t]:r},...a!==void 0&&{[a]:i}},p=o&&s.length>0?u.batchWrite(ca(e,f,o,s)).then(la):u.create(e,f).then(e=>e.record),h=l[e],v=await p.then(e=>(c?.(String(Ne(h,e))),!0),e=>(g(e),!1));return m(!1),v?(d(e),o&&_.sent(s),o&&s.length>0&&d(o.resource),!0):!1},busy:p||_.uploading,placeholder:r,searchPeople:i,onDraft:s,...o&&{actions:(0,X.jsx)(oa,{onPick:_.pick,accept:b}),attachments:_.uploads.length>0&&(0,X.jsx)(_a,{uploads:_.uploads,onRemove:_.remove}),canSendEmpty:_.ready,onFiles:_.pick}})]})},ba=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=W(e);return(0,X.jsx)(ya,{resource:t,field:n,values:r,placeholder:i})},xa=({node:e,children:t,className:n})=>{let{open:r}=W(e);return(0,X.jsx)(`details`,{open:r,className:z(`[&[open]>summary]:mb-2`,n),children:t})},Sa=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:z(`cursor-pointer font-medium`,t),children:e}),Ca=({node:e,className:t})=>{let{source:n,emptyText:r}=W(e),i=mn(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(l,{className:z(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:z(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=kt(a);return o?(0,X.jsx)(`div`,{className:z(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(rt,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:z(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},wa=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),Ta=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ae(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Ea=({node:e,className:t})=>{let{source:n,label:r,format:i}=W(e),{views:a}=N(),o=mn(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(l,{className:`h-4 w-24`}):o.state===`plain`?wa(o.value):(0,X.jsx)(Te,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??Ta(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:z(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},Da={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Oa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ka={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},Aa=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ja=({node:e,children:t,className:n})=>{let{columns:r=2}=W(e),i=e.children,a=i.length>0&&i.every(Aa);return(0,X.jsx)(`div`,{className:z(`grid grid-cols-1 gap-4`,a?Oa[r]:Da[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:z(`min-w-0`,r&&ka[r]),children:e},t)})})},Ma=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),Na=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},Pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),Fa=e=>e instanceof Blob&&e.type.startsWith(`image/`),Ia=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},La=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},Ra=({name:e,alt:t,width:n,height:i,refresh:a,className:o})=>{let s=ge(),{theme:c}=r(),[u,d]=st(),f=Na({width:n,height:i,space:d,theme:c}),m=Fn({queryKey:p.image(e,f??{}),enabled:f!==void 0,placeholderData:Pn,...Pa(a),queryFn:async()=>{let t=await s.invoke(e,{query:f,cache:`no-store`});if(!Fa(t))throw Error(`The function "${e}" answered no picture`);return t}}),h=Ia(m.data),[g,_]=La(h),v={...n!==void 0&&{width:n},...i!==void 0&&{height:i}};return(0,X.jsx)(`div`,{ref:u,className:z(`min-w-0`,o),children:m.isError||g?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):h?(0,X.jsx)(`img`,{src:h,alt:t??``,onError:_,style:v,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(l,{className:`w-full max-w-full`,style:{height:i??160,...n!==void 0&&{width:n}}})})},za=({node:e,className:t})=>{let n=W(e);return n.src===void 0?(0,X.jsx)(Ra,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(Ma,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},Ba=e=>function({node:t,className:n}){let r=W(t),{views:i}=N(),a=mn(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(l,{className:`inline-block h-3 w-16 align-middle`}):Zr(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},Va=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?T(e,n?.valueLabels):Qr(e),Ha=Ba(Va),Ua=Ba(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:$r(e,t,_())})),Wa=Ba(({value:e,props:t})=>{let n=ei(e,t,{locale:_(),now:Date.now(),relative:pn});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),Ga=Ba(({value:e,props:t})=>{let n=ti(e,t,{yes:ne(`yes`),no:ne(`no`)});return e?(0,X.jsx)(on,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ka=Ba(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=ri(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),qa=Ba(e=>(0,X.jsx)(oe,{value:e.value,hints:e.hints,children:Va(e)})),Ja=`font-medium text-primary-text hover:underline`,Ya=({node:e,children:t,className:n})=>{let r=W(e),i={...L(J()),params:un()},a=r.variant?z(ke({variant:r.variant}),n):n??Ja,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=dn(r.to,Xe(i));return(0,X.jsx)($e,{to:e,className:a,children:o??Cn(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},Xa=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:Se(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:Se(i)]})),Za=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return lt(r)?r.key===Se(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:_n(i,r,n[t])?[[t,c(i,r)]]:[]})),Qa=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=N(),u=ge(),d=Me(),f=v(),p=l[e.name],[m,h]=(0,Y.useState)(()=>Xa(e,a,t?.record)),[g,_]=(0,Y.useState)({}),[y,b]=(0,Y.useState)(0),x=fn(y),[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),[D,ee]=(0,Y.useState)(!1);vn(D||T,`input-lost`);let te=async()=>{E(!0),w(void 0),await(n===`create`?u.create(e.name,{...it(e,c,m),...o}):u.update(e.name,t.key,Za(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:G(`saved`,{label:i??r})}),s()},e=>{let t=Dn(e);_(t),Object.keys(t).length>0&&b(e=>e+1),w(e)}),E(!1)};return(0,X.jsx)(V,{title:i??r,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:s,children:G(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:T,onClick:()=>void te(),children:G(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:x,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),te()},children:[C!==void 0&&Object.keys(g).length===0&&(0,X.jsx)(S,{title:G(`notSaved`),error:C}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??ae(n),s=g[n];return(0,X.jsx)(jn,{name:n,label:o,help:p?.fields[n]?.help,error:s&&ct(r,o,s),children:(0,X.jsx)(Sn,{field:r,hints:p?.fields[n],value:lt(i)?i.key:i,stored:t?.record[n],relationLabel:lt(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),ee(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},$a=({model:e,recordKey:t,children:n})=>{let r=Be(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},eo=({node:e})=>{let t=W(e),n=hn(),{resources:r}=N(),i=r[t.resource??n?.model.name??``],a=C(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?We(a,`create`):We(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(Qa,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)($a,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},to=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=W(e);return(0,X.jsx)(`div`,{className:z(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(xr,{title:i,subtitle:a,actions:n.actions}),t]})})},no=(e,t)=>{let n=J(),r=typeof e==`string`?Dt(n,e):void 0,i=Et(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},ro=({node:e,className:t})=>{let{value:n,max:r,label:i}=W(e),a=no(n,0),o=no(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(l,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:z(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(_()),` / `,o.toLocaleString(_())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},io=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:u,className:d})=>{let f=ln(t),p=Be(e,{filter:n,sort:r,key:i,enabled:!f}),m=f?Fe(e,f):p,h=e=>m.data?(0,X.jsx)(Wt,{value:m.data,children:e}):void 0,g=m.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]}):m.error?(0,X.jsx)(S,{title:G(`couldNotLoad`),error:m.error}):m.data?h((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:u})):(0,X.jsx)(M,{children:s??G(`nothingYet`)});return(0,X.jsx)(q,{title:a,description:o,actions:c?h(c):void 0,className:z(`h-full`,d),children:g})},ao=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=W(e),f=N().resources[a];return f?(0,X.jsx)(io,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},oo=yn(`app/related-cards`),so=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:z(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:oo(n?`showLess`:`showMore`)})]})},co=e=>e==null||e===``,lo=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=N(),a=Et(e,t);if(a.state===`missing`||a.state===`ready`&&co(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(l,{className:`h-4 w-24`}):(0,X.jsx)(Te,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(so,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=Ta(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},uo=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=vt(),{resources:l}=N(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:z(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(en,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:z(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)($e,{to:{kind:`record`,resource:e.model.name,key:Ne(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(lo,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(lo,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Wt,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(mr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(li,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},fo=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=vt(),{resources:c}=N(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(en,{view:t,field:r,record:e.record}),(0,X.jsx)($e,{to:{kind:`record`,resource:e.model.name,key:Ne(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(lo,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Wt,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(mr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(li,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},po=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,mo=e=>[...e.querySelectorAll(`button`)].find(po)??e.querySelector(`a`),ho=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},go=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},_o=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(oo(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=ho(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?mo(s):go(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},vo=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(l,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),yo=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:c,empty:l,carousel:u,compact:d,tone:f,planned:p})=>{let h=Bt(),g=hr(),_=t?.names?.plural??ae(e.name),v=r||Oe(e,t),y=b(e,{filter:n,sort:v,pageSize:s,enabled:!p}),x=bn(e,n,!p),C=p?p.rows:{isPending:y.isPending,error:y.error},w=p?p.rows.rows:y.data?.items,T=p?{data:p.total&&!p.total.isPending&&!p.total.error?cr(p.total):void 0}:x,E=(0,Y.useMemo)(()=>(w??[]).map(t=>m(e,t)),[e,w]),D=_o((0,Y.useMemo)(()=>E.map(e=>e.key),[E]));return(0,X.jsxs)(`div`,{ref:D.root,children:[(()=>{if(C.isPending)return(0,X.jsx)(vo,{compact:!!d,limit:s});if(C.error)return(0,X.jsx)(S,{title:oo(`couldNotLoad`),error:C.error});if(E.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:l??oo(`nothingYet`)});let r=E.map(e=>{let n=(t,n)=>D.acted(e.key,t,n);return d?(0,X.jsx)(uo,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(fo,{scope:e,view:t,fields:i,tone:f,actions:a,button:o,onActed:n},e.key)}),p=T.data===void 0?void 0:Zn(E.length,T.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,X.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Qn,{scroll:g,label:_,share:u,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p}),(0,X.jsxs)($e,{to:ur(e,t,h,{filter:n,orderBy:v,display:dr(t,h,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[ar(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,X.jsx)(nr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:D.announcement})]})},bo={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},xo=({node:e,at:t,slots:n,className:r})=>{let i=W(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=ii(i),{resources:_,views:v}=N(),[y,b]=ht([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,X.jsx)(`section`,{className:z(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(ie,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(yo,{model:S,view:C,filter:o,sort:s,fields:c??Pt(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?bo[g]:void 0,...x&&{planned:x}})})})},So=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:o}=N(),s=a(i,o,e.name),c=Vn(e.name,t.listOf,!0),u=(t.names?.plural??ae(e.name)).toLowerCase();if(!s.listOf)return null;if(c.error)return(0,X.jsx)(S,{title:Ln(`couldNotLoadYour`,{plural:u}),error:c.error});if(!c.data)return(0,X.jsx)(l,{className:`h-24`});let d=rr(s.model,c.data);return d?(0,X.jsx)(_r,{...r,model:s.model,view:s.view,filter:``,scope:d,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??Ln(`noneYet`,{plural:u})})},Co=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=d(Ne(e,i)),{name:o,chips:s,title:c,body:l}=yr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)($e,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Kn,{chips:s})})}),(0,X.jsx)(_r,{...l})]})},wo=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=N(),a=t.searchesOf,o=r[a.resource],s=Xn(e.name,!0),c=(t.names?.plural??ae(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(S,{title:qn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??qn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(Co,{model:e,view:t,target:o,targetView:i[a.resource],row:n},d(Ne(e,n))))}):(0,X.jsx)(l,{className:`h-40`}):null},To=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=W(e),{resources:d,views:f}=N(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(q,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(wo,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(_r,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(So,{model:p,view:m,limit:o,display:s,empty:u})})},Eo=e=>e.type===`boolean`||e.type===`enum`,Do=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=N(),c=C(e.name),l=ge(),u=Me(),d=v(),f=s[e.name],[p,h]=(0,Y.useState)(i),[g,_]=(0,Y.useState)(()=>Xa(e,t,i?.record)),[y,b]=(0,Y.useState)({}),[x,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(!1),D=(0,Y.useRef)(Promise.resolve()),ee=(0,Y.useRef)(i),te=Xa(e,t,void 0),ne=p?We(c,`update`)&&p.permissions?.update!==!1:We(c,`create`),O=t.filter(t=>!Eo(e.fields[t])),re=O.some(t=>p?_n(e.fields[t],g[t],p.record[t]):g[t]!==te[t]),k=async t=>{let n=ee.current;if(n){let r=await l.update(e.name,n.key,Za(e,t,n.record),n.etag??`*`);return{...m(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,it(e,o,{...te,...t}));return{...m(e,r.record),etag:r.etag}},ie=t=>{let r=D.current.then(async()=>{E(!0),w(void 0),await k(t).then(async r=>{ee.current=r,h(r),b(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:G(`saved`,{label:n??G(`settings`)})})},e=>{b(t=>({...t,...Dn(e)})),w(e)}),E(!1)});D.current=r},oe=(t,n)=>{_(e=>({...e,[t]:n})),Eo(e.fields[t])&&ie({[t]:n})};return(0,X.jsx)(q,{title:n,description:r,className:z(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),re&&ie(Object.fromEntries(O.map(e=>[e,g[e]])))},children:[x!==void 0&&Object.keys(y).length===0&&(0,X.jsx)(S,{title:G(`notSaved`),error:x}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??ae(t),i=y[t];return(0,X.jsx)(jn,{name:t,label:r,help:f?.fields[t]?.help,error:i&&ct(n,r,i),children:(0,X.jsx)(Sn,{field:n,hints:f?.fields[t],value:g[t],stored:p?.record[t]??te[t],invalid:!!i,locked:!ne||n.readOnly,resource:e.name,onChange:e=>oe(t,e)})},t)}),ne&&re&&(0,X.jsx)(`div`,{children:(0,X.jsx)(A,{type:`submit`,variant:`primary`,size:`sm`,loading:T,children:G(`save`)})})]})})},Oo=e=>{let t=Be(e.model,{});return t.isPending?(0,X.jsx)(q,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(l,{className:`h-4 w-1/2`}),(0,X.jsx)(l,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(q,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(S,{title:G(`couldNotLoad`),error:t.error})}):(0,X.jsx)(Do,{...e,stored:t.data??void 0})},ko=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=W(e),o=N().resources[n];return o?(0,X.jsx)(Oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},Ao=(e,t)=>jo(e,t?[t]:[]),jo=(e,t)=>{let{resources:n}=N(),r=ge(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(nn),[i]),o=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=at(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>Dt(t,e)),f=nt(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=In({queries:u.map(e=>kn(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return Kt(e,t)})},Mo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,No=({node:e,children:t,slots:n,className:r})=>{let{when:i}=W(e),[a]=jo([i],J());if(a===void 0)return null;let o=a?t:Mo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},Po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(et(e,L(t)).props.when)]),Fo=({node:e,children:t,slots:n,className:r})=>{let i=J(),a=jo(Po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?Mo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},Io=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),Lo=`text-2xl font-semibold tracking-tight tabular-nums`,Ro=({model:e,at:t,filter:n})=>{let{views:r}=N(),i=ln(t),a=bn(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(l,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:G(`couldNotCount`)});let s=i?cr(i):a.data;return(0,X.jsx)($e,{to:or(r[e.name],e.name,n),className:`${Lo} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(_())})},zo=({field:e,format:t})=>{let n=mn(e);return n.state===`loading`?(0,X.jsx)(l,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:Lo,children:wa(n.value)}):(0,X.jsx)(`span`,{className:Lo,children:(0,X.jsx)(Te,{model:n.model,field:n.field,value:n.value,format:t})})},Bo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=W(e),{resources:u}=N(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(q,{className:z(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:Lo,children:i}),d&&(0,X.jsx)(Ro,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(zo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},Vo=(e,t,n)=>{let r=Bt(),i=tr(t),[a,o]=(0,Y.useState)(()=>Yn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),fr(localStorage,i,e)},[i]);return[dr(e,r,{picked:a,preferred:n}),s]},Ho=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=N(),d=u[e.name],{fields:f}=Ze(),p=We(C(e.name),`update`),{go:m,href:h}=Ye(),g=Bt(),_=!ft(),v=(0,Y.useMemo)(()=>n?.map(yt)??Pt(e,d),[n,e,d]),y=(0,Y.useMemo)(()=>At(e,d,v,{resources:l,views:u,fieldTypes:f}),[e,d,v,l,u,f]),b=(0,Y.useMemo)(()=>g?Ct(n)(y):y,[g,n,y]),x=(0,Y.useMemo)(()=>r?ir(b,e,d,r,l,_):b,[b,e,d,r,l,_]),S=(0,Y.useMemo)(()=>t.map(t=>({...t,id:fe(e,t)})),[t,e]),w=(0,Y.useMemo)(()=>({total:S.length,rowAt:e=>S[e]}),[S]),T=lr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:p}),E=e=>({href:h(e),onFollow:()=>m(e)});return(0,X.jsx)(q,{title:i,description:a,actions:s,className:c,children:S.length===0?(0,X.jsx)(M,{children:o??G(`nothingYet`)}):(0,X.jsx)(Un,{fit:!0,columns:x,source:w,latencyMs:0,onOpenRow:e=>m(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},Uo=e=>{let t=h();return t?.model?(0,X.jsx)(Ho,{...e,model:t.model,items:t.items}):null},Wo=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=Vo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?tn:g,y=(0,Y.useMemo)(()=>i?.map(yt),[i]),b=(0,Y.useMemo)(()=>Ct(i),[i]);return(0,X.jsxs)(q,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(pr,{view:t,value:v,onChange:_}),f]}),className:z(`h-full`,p),children:[(0,X.jsx)(sr,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},Go=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=W(e),{resources:u,views:d}=N(),[f,p]=ht([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(Uo,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Wo,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(Ko,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},Ko=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=gt(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,X.jsx)(y,{name:e,children:(0,X.jsx)(_i,{model:n.model,query:{key:o},children:t},o)});return(0,X.jsx)(Wo,{...n,chosen:{rowTo:a,key:o,details:s}})},qo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=ye(),{navigate:a}=ze(),o=me(e),s=Nt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:z(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":G(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":G(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(f,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:z(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(Ut,{children:G(`noTab`,{name:r??``})})]})},Jo=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Yo=e=>e===void 0?1/0:Date.parse(e),Xo=(e,t)=>{let n=e=>e.more&&e.items.length>0?Yo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Yo(e.items[a].time)>=Yo(t.items[o].time)?e.items[a++]:t.items[o++];if(Yo(n.time)<r)break;i.push(n)}return i},Zo=({value:e,hints:t,mark:n})=>{let r=T(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(zt,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(w,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&he(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(br,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},Qo=({value:e})=>{let t=typeof e==`string`?le(e):e;return t===$t?(0,X.jsx)(Qe,{children:String(e)}):(0,X.jsx)(ce,{value:t})},$o=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),es=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(A,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(qt,{"aria-hidden":!0,className:z(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)($o,{label:Q(`callInput`),children:(0,X.jsx)(Qo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)($o,{label:Q(`callResult`),children:(0,X.jsx)(Qo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)($o,{label:Q(`callError`),children:(0,X.jsx)(Qe,{children:e.error})})]})]})},ts=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),ns=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},rs=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&se(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:ee(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:ns(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},is=e=>qr.includes(e??``)?e:void 0,as=e=>e==null||e===``?void 0:String(e),os=e=>`call:${JSON.stringify(e)}`,ss=(e,t,n)=>{let r=as(e[n.status]),i=is(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:as(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},cs=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},ls=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=ue(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),cs({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},us=(e,t,n)=>{let{views:r}=N(),i=e?.model.name??``,a=ls(i,{filter:e?.filter,orderBy:e&&mt(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>ss(t,os(Ne(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},ds=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,fs=(e,t)=>e.isLoading?t.loading:t.empty,ps=e=>e.items.length>0&&!!e.error,ms=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),hs=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},gs=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:l,planned:u})=>{let{resources:d,views:f}=N(),p=He(),m=p?.state.kind===`signed-in`?p.state.user.id:void 0,h=n===void 0?[]:[n],g=Jt(d,f,e,h),_=ls(e.name,{filter:t,orderBy:mt(r),pageSize:o,labels:g},u?.messages),v=us(l,o,u?.calls),y=ds(_);if(y===`error`)return(0,X.jsx)(S,{title:Q(`couldNotLoad`),error:_.error,onRetry:ms(_)});if(y===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(M,{children:Q(`loadingMessages`)})});let b=rn(d,e,h,_.items,_.labels),x=Xo({items:v.calls,more:v.hasNextPage},{items:ts(b,r),more:_.hasNextPage}),C=rs(x,{key:t=>String(Ne(e,t)),sender:n,time:r,text:i,status:a}),w=a===void 0?void 0:f[e.name]?.fields[a],T=e.fields[i]!==void 0&&Ae(e.fields[i],f[e.name]?.fields[i]),D=C.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===m);return(0,X.jsxs)(X.Fragment,{children:[ps(_)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(S,{title:Q(`couldNotLoad`),error:_.error,onRetry:ms(_)})}),l&&v.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(S,{title:Q(`couldNotLoadCalls`),error:v.list.error,onRetry:ms(v.list)})}),(0,X.jsx)(_e,{length:x.length,followKey:D?.key,working:c,empty:fs(v.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:_.hasNextPage||v.hasNextPage?()=>hs([_,v.list]):void 0,loadingEarlier:_.isFetchingNextPage||v.isFetchingNextPage,children:C.map(e=>e.kind===`day`?(0,X.jsx)(je,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(es,{call:e,statusHints:v.statusHints},e.key):(0,X.jsx)(xe,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Zo,{value:e.status,hints:w}),children:T&&e.text!==``?(0,X.jsx)(E,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},_s=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),vs=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=W(e),{resources:g}=N(),[_]=jo(f===void 0?[]:[f],J()),[v,y]=ht([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:z(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(ie,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(_s,{children:(0,X.jsx)(gs,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},ys=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),bs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:z(`flex`,t),children:e}),xs=({children:e,className:t})=>(0,X.jsx)(`div`,{className:z(`flex flex-col`,t),children:e}),Ss=({node:e,children:t,className:n})=>{let{as:r=`p`}=W(e);return(0,X.jsx)(r,{className:n,children:t})},Cs=({node:e,children:t})=>{let{source:n}=W(e),r=tt(L(J()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Tn,{value:i,children:t})},ws=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=W(e),{values:o,linkTo:s}=gt(),c=o[n];return(0,X.jsxs)(`div`,{className:z(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,X.jsx)(Ue,{label:i,value:c??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>s({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,X.jsx)(`span`,{children:c})]})},Ts=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},Es=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=ue(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),Ts({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},Ds=({node:e,at:t,children:n})=>{let r=W(e),i=N().resources[r.reference],a=Xe(L(J())),o=ln(t);return i?(0,X.jsx)(Os,{model:i,...Gt(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},Os=({empty:e,children:t,...n})=>{let{read:r,list:i}=Es(n);return(0,X.jsx)(Le,{read:r,list:i,empty:e,children:t})},ks=({node:e,at:t,children:n})=>{let r=W(e),i=N().resources[r.reference],a=Xe(L(J())),o=ln(t);return i?(0,X.jsx)(Os,{model:i,...an(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},As=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=N(),s=ln(t),c=Be(e,{key:n,enabled:!s}),u=s?Fe(e,s):c;if(u.isPending)return(0,X.jsx)(l,{className:`h-4 w-24`});if(u.error)return(0,X.jsx)(S,{title:G(`couldNotLoad`),error:u.error});if(!u.data)return null;let d=i.length>0?(0,X.jsx)(Wt,{value:u.data,children:i}):be(e,o[e.name],u.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:d}):(0,X.jsx)($e,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:d})},js=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=W(e),c=N().resources[i],l=tt(L(J()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(As,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},Ms=(e,t)=>t.map(t=>Ie(e,t)).join(`, `),$=yn(`users`),Ns=({roles:e})=>{let{session:t}=k(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(wr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(I,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(Cr,{email:n.email,gives:Ms(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},Ps=({roles:e,onCreated:t})=>{let{session:n}=k(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=jt(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(I,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(K,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(F,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(F,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(F,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(wr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(A,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},Fs=({user:e,roles:t,self:n})=>{let{session:r}=k(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=jt(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(Tr,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(R,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(A,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(A,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(wr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Is=({roles:e,version:t})=>{let{session:n,state:r}=k(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=Dr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(Er,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(Fs,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},Ls=()=>{let{session:e}=k(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof O?j(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Rs=()=>{let{roles:e,error:t}=Ls(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(K,{message:t}),(0,X.jsx)(Is,{roles:e,version:n}),(0,X.jsx)(Ns,{roles:e}),(0,X.jsx)(Ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},zs=()=>(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(An,{message:P(`checkUnavailable`)})}),Bs=(e,t)=>t.status===`waiting`?(0,X.jsx)(An,{message:P(`checkWaiting`,{address:e})}):t.status===`confirmed`?(0,X.jsx)(An,{message:P(`checkConfirmed`,{address:e})}):t.status===`mismatch`?(0,X.jsx)(K,{message:P(`checkMismatch`,{address:e,from:t.from})}):t.status===`timed_out`?(0,X.jsx)(An,{message:P(`checkTimedOut`)}):null,Vs=({address:e,state:t,error:n,onCheck:r})=>{if(t.status===`unchecked`)return(0,X.jsx)(zs,{});let i=t.status===`waiting`;return(0,X.jsxs)(`div`,{className:`mt-4`,children:[Bs(e,t),(0,X.jsx)(K,{message:n}),(0,X.jsx)(A,{size:`sm`,loading:i,onClick:r,children:t.status===`idle`||i?P(`checkFromAddress`):P(`checkAgain`)})]})},Hs=3e3,Us=async({start:e,result:t,wait:n,stopped:r,onState:i})=>{i({status:`waiting`});let a=await e();if(!r()){if(a.status!==`waiting`)return i(a);for(let e=0;e<40;e++){if(await n(Hs),r())return;let e=await t(a.check);if(r())return;if(e.status!==`waiting`)return i(e)}i({status:`timed_out`})}},Ws=e=>new Promise(t=>setTimeout(t,e)),Gs=(e,t=!1)=>{let[n,r]=(0,Y.useState)({status:`idle`}),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(e);c.current=e;let l=(0,Y.useCallback)(async()=>{if(!o.current){o.current=!0,a(void 0);try{await Us({...c.current,wait:Ws,stopped:()=>s.current,onState:r})}catch(e){if(s.current)return;if(r({status:`idle`}),e instanceof TypeError)return a(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;a(j(e))}finally{o.current=!1}}},[]);return(0,Y.useEffect)(()=>(s.current=!1,t&&l(),()=>{s.current=!0}),[t,l]),{state:n,error:i,check:l}},Ks=({address:e,calls:t,auto:n=!1})=>{let{state:r,error:i,check:a}=Gs(t,n);return(0,X.jsx)(Vs,{address:e,state:r,error:i,onCheck:()=>void a()})},qs=({sender:e,check:t,busy:n,error:r,onSave:i,onClose:a})=>{let[o,s]=(0,Y.useState)(e?.address??``),[c,l]=(0,Y.useState)(e?.name??``),[u,d]=(0,Y.useState)(e?.signature??``),[f,p]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(V,{title:e?e.address:P(`addFromAddress`),description:P(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:a,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:a,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:n,disabled:!o.trim(),onClick:()=>i({address:o.trim(),name:c.trim(),signature:u,isDefault:f}),children:P(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`fromAddress`),(0,X.jsx)(F,{autoFocus:!0,type:`email`,value:o,maxLength:254,placeholder:P(`fromAddressPlaceholder`),onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`fromName`),(0,X.jsx)(F,{value:c,maxLength:100,placeholder:P(`fromNamePlaceholder`),onChange:e=>l(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:P(`defaultFromAddress`)}),(0,X.jsx)(ve,{checked:f,onChange:p,label:P(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`signature`),(0,X.jsx)(Je,{value:u,maxLength:2e3,placeholder:P(`signaturePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,X.jsx)(K,{message:r}),t&&!t.available&&(0,X.jsx)(zs,{}),e&&t?.available&&t.calls&&(0,X.jsx)(Ks,{address:e.address,calls:t.calls,...t.auto&&{auto:!0}})]})},Js=e=>e.signature?P(`ownSignature`):P(`genericSignature`),Ys=({senders:{address:e,senders:t,checks:n=!1},onAdd:r,onUpdate:i,onRemove:a,onCheck:o,onCheckResult:s})=>{let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(),m=(0,Y.useRef)(!1),h=t.find(e=>e.isDefault),g=()=>{p(void 0),d(void 0)},_=async e=>{if(!m.current){m.current=!0,l(!0),d(void 0);try{p(await e()||void 0)}catch(e){if(e instanceof TypeError)return d(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;d(j(e))}finally{m.current=!1,l(!1)}}},v=e=>_(async()=>{let t=e.name||null,a=e.signature.trim()?e.signature:null;if(f?.kind===`change`)return void await i(f.sender.id,{name:t,signature:a,isDefault:e.isDefault});let o=await r({address:e.address,...t&&{name:t},...a&&{signature:a}});if(e.isDefault&&await i(o.id,{isDefault:!0}),n)return{kind:`change`,sender:{...o,isDefault:e.isDefault},autoCheck:!0}});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:P(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:P(`fromAddressesDescription`)}),(0,X.jsx)(K,{message:f?void 0:u}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:P(`mailboxOwnAddress`)})]}),h?(0,X.jsx)(A,{size:`sm`,variant:`ghost`,loading:c,onClick:()=>void _(async()=>void await i(h.id,{isDefault:!1})),children:P(`makeDefault`)}):(0,X.jsx)(R,{tone:`blue`,children:P(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Js(e)})]}),e.isDefault&&(0,X.jsx)(R,{tone:`blue`,children:P(`default`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>p({kind:`change`,sender:e}),children:P(`edit`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>p({kind:`remove`,sender:e}),children:P(`remove`)})]},e.id))]}),(0,X.jsxs)(A,{onClick:()=>p({kind:`add`}),children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`addFromAddress`)]}),f?.kind===`add`&&(0,X.jsx)(qs,{check:{available:n},busy:c,error:u,onSave:e=>void v(e),onClose:g}),f?.kind===`change`&&(0,X.jsx)(qs,{sender:f.sender,check:((e,t=!1)=>({available:n,calls:{start:()=>o(e.id),result:t=>s(e.id,t)},...t&&{auto:t}}))(f.sender,f.autoCheck),busy:c,error:u,onSave:e=>void v(e),onClose:g},f.sender.id),f?.kind===`remove`&&(0,X.jsx)(V,{title:P(`removeFromAddress`,{address:f.sender.address}),description:P(`removeFromAddressDescription`),onClose:g,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:g,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:c,onClick:()=>void _(()=>a(f.sender.id)),children:P(`remove`)})]}),children:(0,X.jsx)(K,{message:u})})]})},Xs=(e,t,n)=>Object.fromEntries(Hn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,u(`signInOnly`,{provider:n(e.provider),name:e.name})])),Zs=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=k(),{account:i}=t,[a]=(0,Y.useState)(Zt),o=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=U(o,P(`couldNotReadMethods`));return s?(0,X.jsx)(Ot,{title:P(`mailbox`),description:P(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:Xs(e,s,e=>r.find(t=>t.id===e)?.name??Ke(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&g(a,e.length===1?e[0].name:P(`theProvider`)),children:(0,X.jsx)(Ys,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return It(),await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),It(),await l()},onRemove:async e=>{await i.removeMailSender(e),It(),await l()},onCheck:e=>i.checkMailSender(e),onCheckResult:(e,t)=>i.mailSenderCheckResult(e,t)})}):(0,X.jsx)(B,{error:c})},Qs=()=>{let{personalMail:e}=k();return e.length>0?(0,X.jsx)(Zs,{links:e}):null},$s=e=>Or(e.name)??`An unnamed app`,ec=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),tc=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof O))throw e;a(j(e))}r(!1)};return(0,X.jsxs)(I,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(K,{message:o?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=kr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Pr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:$s(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,pt(Date.parse(e.allowedAt)),` · `,ec(e)]})]}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(V,{title:`Disconnect ${$s(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(A,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(K,{message:i})})]})},nc=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},rc=({url:e,appName:t})=>(0,X.jsx)(I,{title:P(`mcpAddress`),description:P(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ar,{value:e,copyLabel:P(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:nc(e,t),target:`_blank`,rel:`noreferrer`,className:ke(),children:[(0,X.jsx)(i,{className:`size-3.5`}),P(`addToClaude`)]})]})}),ic=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.connectedApps(),[e]),P(`couldNotReadMethods`));return t?(0,X.jsx)(tc,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(B,{error:n})},ac=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rc,{url:e,appName:N().appName}),(0,X.jsx)(ic,{})]}),oc=()=>{let{mcp:e}=k();return e?(0,X.jsx)(ac,{url:e.url}):null},sc={30:30,90:90,365:365,never:void 0},cc={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},lc=e=>pt(Date.parse(e)),uc=e=>e?P(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:lc(e)}):P(`neverExpires`),dc=e=>[P(`createdOn`,{date:lc(e.createdAt)}),uc(e.expiresAt),e.lastUsedAt?P(`lastUsedOn`,{date:lc(e.lastUsedAt)}):P(`notUsedYet`),e.organization?P(`actsAsIn`,{role:e.role,organization:e.organization}):P(`actsAs`,{role:e.role})].join(` · `),fc=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`90`),[p,m]=(0,Y.useState)(),h=()=>{c(void 0),o(void 0),m(void 0)},g=(0,Y.useRef)(!1),_=async e=>{if(!g.current){g.current=!0,i(!0),o(void 0);try{c(await e()),m(void 0)}catch(e){if(e instanceof TypeError)return o(P(`noAnswerFromServer`));if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):o(j(e))}finally{g.current=!1,i(!1)}}},v=()=>_(async()=>{let e=sc[d];return{kind:`created`,created:await t({name:l.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(I,{title:P(`accessTokens`),description:P(`accessTokensDescription`),children:[(0,X.jsx)(K,{message:s?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:P(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:dc(e)})]}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>c({kind:`revoke`,token:e}),children:P(`revoke`)})]},e.id))}),(0,X.jsxs)(A,{onClick:()=>{u(``),f(`90`),c({kind:`create`})},children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`newAccessToken`)]}),s?.kind===`create`&&(0,X.jsxs)(V,{title:P(`newAccessToken`),description:P(`newAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:h,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:r,disabled:!l.trim(),onClick:()=>void v(),children:P(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:l,maxLength:100,placeholder:P(`accessTokenNamePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[P(`accessTokenExpiry`),(0,X.jsx)(Ft,{value:d,onChange:e=>f(e.target.value),children:Object.keys(sc).map(e=>(0,X.jsx)(`option`,{value:e,children:P(cc[e])},e))})]}),p===`asked`&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:P(`confirmedCreateAccessToken`)}),(0,X.jsx)(K,{message:a})]}),s?.kind===`created`&&(0,X.jsx)(V,{title:P(`accessTokenCreated`,{name:s.created.personalAccessToken.name}),description:P(`accessTokenCreatedDescription`),onClose:h,actions:(0,X.jsx)(A,{variant:`primary`,onClick:h,children:P(`done`)}),children:(0,X.jsx)(Ar,{value:s.created.token,copyLabel:P(`copyAccessToken`)})}),s?.kind===`revoke`&&(0,X.jsx)(V,{title:P(`revokeAccessToken`,{name:s.token.name}),description:P(`revokeAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:h,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:r,onClick:()=>void _(async()=>(await n(s.token.id),void 0)),children:P(`revoke`)})]}),children:(0,X.jsx)(K,{message:a})})]})},pc=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),P(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{message:n}),(0,X.jsx)(fc,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(B,{error:n})},mc=()=>k().personalAccessTokens?(0,X.jsx)(pc,{}):null,hc={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},gc=e=>e.provider===`google`,_c=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof O))throw e;s(j(e))}finally{a(void 0)}};return(0,X.jsxs)(I,{title:P(`connections`),description:P(`connectionsDescription`),children:[(0,X.jsx)(K,{message:c?void 0:o}),(0,X.jsx)(An,{message:u}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Br,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(A,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?P(`connectAgain`,{name:e.label}):P(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[P(`connectedOn`,{date:pt(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(R,{tone:`amber`,children:P(`connectionNeedsSignIn`)}):(0,X.jsx)(R,{tone:`green`,children:P(`connected`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:P(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:P(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(bt,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(V,{title:P(`disconnectTitle`,{name:c.connection.label}),description:gc(c.connection)?`${P(`disconnectDescription`)} ${P(`disconnectWholeGrant`)}`:P(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>l(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(P(hc[await n(c.accountId)]))),children:P(`disconnect`)})]}),children:o&&(0,X.jsx)(K,{message:o})})]})},vc=()=>{let{session:e,connectAccount:t}=k(),{account:n}=e,[r]=(0,Y.useState)(Zt),{data:i,error:a,reload:o}=U((0,Y.useCallback)(()=>n.workflowConnections(),[n]),P(`couldNotReadMethods`));return i?i.length===0?null:(0,X.jsx)(_c,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&g(r,P(`theProvider`))}):(0,X.jsx)(B,{error:a})},yc=e=>e.code===`LAST_ADMIN`?P(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?P(`deleteAccountLocked`):j(e),bc=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(!1),d=(0,Y.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(yc(e)),o(!1)}};return(0,X.jsxs)(V,{title:P(`deleteAccountQuestion`),description:P(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:n,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:P(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`deleteAccountPassword`),(0,X.jsx)(F,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(K,{message:s})]}),l&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},xc=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(I,{title:P(`deleteAccount`),description:P(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(A,{variant:`danger`,onClick:()=>i(!0),children:P(`deleteAccount`)}),r&&(0,X.jsx)(bc,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},Sc=()=>{let{session:e,state:t,deleteAccount:n}=k(),{account:r}=e,{data:i,error:a}=U((0,Y.useCallback)(()=>r.signInMethods(),[r]),P(`couldNotReadMethods`));return i?(0,X.jsx)(xc,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(B,{error:a})},Cc=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],wc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Tc=(e,t)=>e.find(([e])=>e.test(t))?.[1],Ec=e=>e?{browser:Tc(Cc,e),system:Tc(wc,e)}:{},Dc=e=>e.device?P(`deviceThrough`,{device:e.device,provider:e.name}):e.name,Oc=(e,t)=>{if(e.staff)return t?P(`staffOf`,{operator:t}):P(`staff`);let{browser:n,system:r}=Ec(e.userAgent);return n&&r?P(`browserOn`,{browser:n,system:r}):r?P(`aBrowserOn`,{system:r}):n??P(`unknownDevice`)},kc=e=>{if(e.staff)return Hr;let{system:t}=Ec(e.userAgent);return t===`iPhone`||t===`Android`?Wr:t===`iPad`?Kr:Rr},Ac=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),jc=(e,t)=>e.kind===`one`?P(`signOutDevice`,{name:Oc(e.session,t)}):e.kind===`link`?P(`signOutDevice`,{name:Dc(e.link)}):P(`signOutOthersTitle`),Mc=e=>P(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),Nc=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof O))throw e;l(j(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(I,{title:P(`devices`),description:P(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:P(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[Ac(f).map(e=>{let n=kc(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Oc(e,t)}),e.current&&(0,X.jsx)(R,{tone:`green`,children:P(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[P(`signedInFromUntil`,{from:xt(Date.parse(e.createdAt)),until:xt(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:P(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Dc(t)}),n&&(0,X.jsx)(R,{tone:`green`,children:P(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:P(`linkedOn`,{date:xt(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:P(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(A,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:P(`signOutOthers`)}),u&&(0,X.jsx)(V,{title:jc(u,t),description:Mc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>d(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:o,onClick:()=>void h(u),children:P(`signOut`)})]}),children:(0,X.jsx)(K,{message:c})})]})},Pc=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=k(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=U(i,P(`couldNotReadDevices`));return a?(0,X.jsx)(Nc,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(B,{error:o})},Fc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},Ic=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(),h=e===`required`&&t.length<=1,g=async e=>{o(!0),c(void 0),m(void 0);try{await e(),u(void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):c(j(e))}o(!1)};return(0,X.jsxs)(I,{title:P(`passkeys`),status:e===`required`&&(0,X.jsx)(R,{tone:`blue`,children:P(`required`)}),description:P(Fc[e]),children:[(0,X.jsx)(K,{message:l?void 0:s}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(qe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??P(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?P(`addedOn`,{date:pt(Date.parse(e.createdAt))}):P(`addedEarlier`),` · `,e.backedUp?P(`synced`):P(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(A,{size:`sm`,variant:`ghost`,onClick:()=>{f(e.name??``),u({kind:`rename`,passkey:e})},children:P(`rename`)}),(0,X.jsx)(A,{size:`sm`,variant:`ghost`,disabled:h,title:h?P(`keepLastPasskey`):void 0,onClick:()=>u({kind:`remove`,passkey:e}),children:P(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(A,{loading:a&&!l,onClick:()=>void g(n),children:[(0,X.jsx)(te,{className:`size-3.5`}),P(`addPasskey`)]}),p===`asked`&&(0,X.jsx)(Ee,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:P(`confirmedAddPasskey`)}),l?.kind===`rename`&&(0,X.jsxs)(V,{title:P(`renamePasskey`),description:P(`renamePasskeyDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>u(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:a,disabled:!d.trim(),onClick:()=>void g(()=>r(l.passkey.id,d.trim())),children:P(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:d,maxLength:60,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(K,{message:s})]}),l?.kind===`remove`&&(0,X.jsx)(V,{title:P(`removePasskey`),description:P(`removePasskeyDescription`,{name:l.passkey.name??P(`thisPasskey`)}),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>u(void 0),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`danger`,loading:a,onClick:()=>void g(()=>i(l.passkey.id)),children:P(`remove`)})]}),children:s&&(0,X.jsx)(K,{message:s})})]})},Lc=()=>{let{account:e}=k().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=U(t,P(`couldNotReadMethods`));if(!n)return(0,X.jsx)(B,{error:r});let[a,o]=n;return(0,X.jsx)(Ic,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},Rc=e=>e.code===`PASSWORD_TOO_SHORT`?P(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?P(`passwordTooLong`):j(e),zc=(e,t)=>{if(e.length<12)return P(`useAtLeast`,{length:12});if(e!==t)return P(`passwordsDiffer`)},Bc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=zc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof O))throw e;f(Rc(e)),u(!1)}}};return(0,X.jsx)(V,{title:P(e?`changePassword`:`setPassword`),description:P(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:n,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:P(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`currentPassword`),(0,X.jsx)(F,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`newPassword`),(0,X.jsx)(F,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`repeatPassword`),(0,X.jsx)(F,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:P(`changeSignsOutOthers`)}),(0,X.jsx)(K,{message:d})]})})},Vc=({rule:e,hasPassword:t,staff:n})=>P(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),Hc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(I,{title:P(`password`),description:Vc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(An,{message:s?P(`passwordSaved`):void 0}),l&&(0,X.jsx)(A,{onClick:()=>{c(!1),o(!0)},children:P(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(Bc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},Uc=()=>{let{session:e,state:t}=k(),{account:n}=e,{data:r,error:i,reload:a}=U((0,Y.useCallback)(()=>n.signInMethods(),[n]),P(`couldNotReadMethods`));return r?(0,X.jsx)(Hc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(B,{error:i})},Wc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof O))throw e;p(j(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(V,{title:P(`changeEmail`),description:P(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:P(`otherAddress`)}),(0,X.jsx)(A,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:P(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`code`),(0,X.jsx)(D,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(K,{message:f})]}):(0,X.jsxs)(V,{title:P(`changeEmail`),description:P(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:r,children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:P(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`newEmail`),(0,X.jsx)(F,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(K,{message:f})]})},Gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof O))throw e;m(j(e))}f(!1)};return(0,X.jsxs)(I,{title:P(`profile`),description:P(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:P(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:P(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(A,{onClick:()=>{u(e),m(void 0),o(!0)},children:P(`changeName`)}),r&&(0,X.jsx)(A,{onClick:()=>c(!0),children:P(`changeEmail`)})]}),a&&(0,X.jsxs)(V,{title:P(`changeName`),description:P(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:()=>o(!1),children:P(`cancel`)}),(0,X.jsx)(A,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:P(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`name`),(0,X.jsx)(F,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(K,{message:p})]}),s&&r&&(0,X.jsx)(Wc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},Kc=()=>{let{session:e,changeEmail:t}=k(),{data:n,loaded:r,error:i,reload:a}=U((0,Y.useCallback)(()=>e.session(),[e]),P(`couldNotReadProfile`));if(!r)return(0,X.jsx)(B,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(Gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},qc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),[p,m]=(0,Y.useState)(!1),h=async()=>{u(!0),f(void 0),m(!1);try{await a(i?s:void 0)}catch(e){if(!(e instanceof O))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(!0):f(j(e)),u(!1)}};return(0,X.jsxs)(V,{title:e,description:t,onClose:o,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{onClick:o,children:P(`cancel`)}),(0,X.jsx)(A,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void h(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[P(`yourPassword`),(0,X.jsx)(F,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:s,invalid:!!d,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s&&void h()})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d}),p&&(0,X.jsx)(Ee,{purpose:`change`,minutes:15,onConfirmed:()=>void h()})]})},Jc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Yc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(R,{tone:`green`,children:P(`on`)}):t===`required`?(0,X.jsx)(R,{tone:`amber`,children:P(`required`)}):(0,X.jsx)(R,{children:P(`off`)}),p=P(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:Jc[t]);return l?.kind===`setup`?(0,X.jsx)(I,{title:P(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(Ve,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(I,{title:P(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(A,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:P(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(A,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:P(`addAuthenticator`)}),n&&r&&(0,X.jsx)(A,{onClick:()=>u({kind:`new-codes`}),children:P(`newBackupCodes`)}),n&&(0,X.jsx)(A,{variant:`danger`,disabled:t===`required`,title:t===`required`?P(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:P(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(qc,{title:P(`turnOffTitle`),description:P(`turnOffDescription`),confirmLabel:P(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(qc,{title:P(`newCodesTitle`),description:P(`newCodesDescription`),confirmLabel:P(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(V,{title:P(`yourNewCodes`),description:P(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(A,{variant:`primary`,onClick:d,children:P(`savedCodes`)}),children:(0,X.jsx)(x,{codes:l.codes})})]})},Xc=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=U((0,Y.useCallback)(()=>e.signInMethods(),[e]),P(`couldNotReadMethods`));return t?(0,X.jsx)(Yc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(B,{error:n})},Zc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(Ut,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Qc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(wt,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Zc,{problem:G.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Zc,{problem:G.rich(`noComponent`,{component:e}),fallback:n}),$c={Page:to,Grid:ja,Card:di,Stat:Bo,RecordCard:ao,Field:Ea,Diff:Ca,Table:Go,CardRow:hi,RecordRow:To,RecordCards:xo,Chart:gi,Timeline:ta,Graph:aa,Progress:ro,Image:za,ModalForm:eo,Thread:vs,Composer:ba,Action:ui,Show:No,Switch:Fo,Match:Io,Link:Ya,Settings:ko,Tabs:qo,Tab:Jo,Users:Rs,Profile:Kc,Password:Uc,Passkeys:Lc,TwoFactor:Xc,ConnectedAccounts:Tt,PersonalMail:Qs,Connections:vc,Devices:Pc,ConnectedApps:oc,PersonalAccessTokens:mc,DeleteAccount:Sc,Box:ys,Row:bs,Column:xs,Text:Ss,ReferenceManyField:Ds,ReferenceArrayField:ks,ArrayField:Cs,RecordsIterator:pi,ReferenceField:js,SelectInput:ws,Details:xa,Summary:Sa,TextField:Ha,NumberField:Ua,DateField:Wa,BooleanField:Ga,UrlField:Ka,ChipField:qa},el=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),tl=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:o(t,...n,r)}})),nl=({text:e})=>{let t=J(),n=un(),r={...L(t),params:n};return(0,X.jsx)(X.Fragment,{children:_t(e,e=>gn(tt(r,e)))})},rl=(e,t)=>e.includes(`{{`)?(0,X.jsx)(nl,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),il=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?rl(e,n):(0,X.jsx)(dl,{node:e,at:t},n)),al=e=>{let t=[];for(let n of e){let e=t.at(-1);Xr(n.child)&&e&&Xr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Xr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:il(e)},t):(0,X.jsx)(dl,{node:n.child,at:n.at},t)})},ol=e=>Ht(e)||Array.isArray(e)&&e.length>0&&e.every(Ht),sl=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>ol(n)?[[e,(0,X.jsx)(X.Fragment,{children:al(cl(n,t,e))})]]:[])),cl=(e,t,n)=>Array.isArray(e)?tl(e,t,`props`,n):[{child:e,...t!==void 0&&{at:o(t,`props`,n)}}],ll=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ul=(e,t)=>{let n=ll(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>Ht(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=de(t,String(e.props.i18nKey),ll(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Ht(e)?e:String(e)):[i]},dl=({node:e,at:t})=>{let{components:n}=Ze(),r=J(),i=un(),a=De(),o=(0,Y.useMemo)(()=>Lt(et(e,{...L(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:il(ul(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(na,{node:o,children:al(tl(o.children,t,`children`))}):void 0;return(0,X.jsx)(Qc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)(ot,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...Mt(o.props),children:r})})})}let s=$c[o.type];if(!s)return(0,X.jsx)(Ut,{children:G.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=tl(o.children,t,`children`),u=(0,X.jsx)(s,{node:o,at:t,slots:sl(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?il(l):al(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||el.has(o.type)?u:(0,X.jsx)(`div`,{className:c,children:u});return o.fallback?(0,X.jsx)(wt,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:al(tl(o.fallback,t,`fallback`))}),children:d}):d};export{ms as a,ns as c,yo as d,lo as f,ua as h,gs as i,Vo as l,ya as m,Qc as n,ps as o,oo as p,_s as r,ds as s,dl as t,Ao as u};
|
|
3
|
+
//# debugId=620e03dc-f0f7-4e8b-8a92-8ca048257ae4
|