@protobase/ui 0.119.3 → 0.119.5
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/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-types/json/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/definition.d.ts +1 -1
- 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/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/import/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/meta-gate-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/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/saved/use-favorite.d.ts +1 -1
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/searches/use-save-search.d.ts +1 -1
- 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/forms/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/markdown/markdown-html.js +2 -29
- package/dist/markdown/safe-html.d.ts +11 -0
- package/dist/markdown/safe-html.js +35 -0
- package/dist/mentions/link-text.d.ts +7 -0
- package/dist/mentions/link-text.js +19 -0
- package/dist/mentions/mention-text.d.ts +2 -0
- package/dist/mentions/mention-text.js +3 -1
- package/dist/mentions/mentioned-text.d.ts +7 -7
- package/dist/mentions/mentioned-text.js +14 -4
- package/dist/mentions/message-content.d.ts +10 -0
- package/dist/mentions/message-content.js +17 -0
- package/dist/mentions/message-html.d.ts +11 -0
- package/dist/mentions/message-html.js +55 -0
- package/dist/mentions/message-lines.d.ts +4 -0
- package/dist/mentions/message-lines.js +38 -0
- 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/shell/assets/{account-page-d4bA-Rnh.js → account-page-ve4BUXRh.js} +2 -2
- package/dist/shell/assets/{app-xwgcmboV.css → app-DLkpxjgP.css} +1 -1
- package/dist/shell/assets/{app-B94YfKGx.js → app-DU-Bny4k.js} +7 -7
- package/dist/shell/assets/{assistant-shell-DTNOfaAZ.js → assistant-shell-KyMQvcsn.js} +2 -2
- package/dist/shell/assets/board-display-BaMLmYUJ.js +2 -0
- package/dist/shell/assets/calendar-display-CzQPcItV.js +2 -0
- package/dist/shell/assets/{call-rings-D8cGALi4.js → call-rings-DUzC7UYz.js} +2 -2
- package/dist/shell/assets/{calls-DLSo4hNS.js → calls-drZLv0wW.js} +2 -2
- package/dist/shell/assets/{circle-alert-C8YjGdRx.js → circle-alert-COV0WNyG.js} +2 -2
- package/dist/shell/assets/composed-page-CBJLOXNJ.js +2 -0
- package/dist/shell/assets/{composer-section-6TvE0L2w.js → composer-section-05sGMnpR.js} +2 -2
- package/dist/shell/assets/{connect-route-C8Km-e8S.js → connect-route-KBsPFlW4.js} +2 -2
- package/dist/shell/assets/{copy-field-DXp0fGDR.js → copy-field-14Vmg95D.js} +2 -2
- package/dist/shell/assets/create-route-DAprAV2h.js +2 -0
- package/dist/shell/assets/{custom-step-container-field-B8ut5WnP.js → custom-step-container-field-D0cmhURR.js} +4 -4
- package/dist/shell/assets/embedded-list-Ra3OLUh6.js +3 -0
- package/dist/shell/assets/{export-dialog-gSUSlzOy.js → export-dialog-Cz26bxgN.js} +2 -2
- package/dist/shell/assets/{first-organization-page-C7YZ32Kt.js → first-organization-page-C9ejBI4S.js} +2 -2
- package/dist/shell/assets/{graph-view-_7poAZsr.js → graph-view-B3TE-xbG.js} +2 -2
- package/dist/shell/assets/{group-donut-XjNEBVUq.js → group-donut-BAyTgqYv.js} +2 -2
- package/dist/shell/assets/{guest-call-page-Cj6F3D3u.js → guest-call-page-CEcPrLXS.js} +3 -3
- package/dist/shell/assets/{html-viewer-CmYTAzWa.js → html-viewer-DaeVR6PB.js} +2 -2
- package/dist/shell/assets/{import-dialog-bNG6qX6Q.js → import-dialog-6I25EI49.js} +2 -2
- package/dist/shell/assets/import-table-dialog-COsPNket.js +2 -0
- package/dist/shell/assets/{index-CYraq2Hi.js → index-CLyiQa16.js} +1 -1
- package/dist/shell/assets/{invitations-page-XV6kL2Mk.js → invitations-page-TBz_-ekD.js} +2 -2
- package/dist/shell/assets/{layout-grid-dpoR6hFU.js → layout-grid-BTGS8Vdw.js} +2 -2
- package/dist/shell/assets/{legend-item-WwKh2W6n.js → legend-item-DkIaBiD0.js} +2 -2
- package/dist/shell/assets/list-page-Dpq9M7YO.js +4 -0
- package/dist/shell/assets/{maplibre-Bm0OQH9k.js → maplibre-JTZsxvhv.js} +2 -2
- package/dist/shell/assets/{markdown-content-BZLiLira.js → markdown-content-DBVa63k_.js} +2 -2
- package/dist/shell/assets/members-page-CHRY9H9W.js +2 -0
- package/dist/shell/assets/message-content-DzyGCvgQ.js +3 -0
- package/dist/shell/assets/messages-BwcGcxFR.js +2 -0
- package/dist/shell/assets/organization-page-BE182e_K.js +2 -0
- package/dist/shell/assets/organizations-page-DaN6zQZj.js +2 -0
- package/dist/shell/assets/{pending-invitation-row-BZVOux9W.js → pending-invitation-row-DvqK-Lh5.js} +2 -2
- package/dist/shell/assets/{period-chart-GDqLnl9l.js → period-chart-Cn9bgVfB.js} +2 -2
- package/dist/shell/assets/{person-row-DgXLW9D8.js → person-row-CSBZnBQc.js} +2 -2
- package/dist/shell/assets/public-form-page-CaNVr6BS.js +2 -0
- package/dist/shell/assets/{record-lines-CDTPiIdF.js → record-lines-3DhkRSpH.js} +2 -2
- package/dist/shell/assets/{record-map-Dcmuv9J8.js → record-map-D4rgUOwb.js} +2 -2
- package/dist/shell/assets/{record-opens-D7SV04zf.js → record-opens-BSFQWqio.js} +2 -2
- package/dist/shell/assets/record-page-Cbx9gqMY.js +3 -0
- package/dist/shell/assets/{record-preview-DsIrTWKZ.js → record-preview-Bdzkrw0H.js} +2 -2
- package/dist/shell/assets/{records-map-G0QXqaUR.js → records-map-BfkBfva4.js} +2 -2
- package/dist/shell/assets/render-node-ChsAMZVA.js +3 -0
- package/dist/shell/assets/reorder-button-pGaEX5DI.js +2 -0
- package/dist/shell/assets/{run-trace-view-DLY3Mt5m.js → run-trace-view-Cd3DppYM.js} +2 -2
- package/dist/shell/assets/{runner-install-field-Iwp4UP6o.js → runner-install-field-CK3olYt5.js} +2 -2
- package/dist/shell/assets/{runtime-update-DKcAQek2.js → runtime-update-BNTp15Vo.js} +2 -2
- package/dist/shell/assets/safe-html-CmkqDcA6.js +2 -0
- package/dist/shell/assets/shared-protobase-ui-gnK6D3Al.js +1 -0
- package/dist/shell/assets/sheet-source-DONoSDqu.js +3 -0
- package/dist/shell/assets/sign-in-policy-page-C4MEEpwM.js +2 -0
- package/dist/shell/assets/start-block-queries-B7qJvkWD.js +2 -0
- package/dist/shell/assets/step-catalog-CgPcuEu_.js +2 -0
- package/dist/shell/assets/{step-panel-BXHWAw8x.js → step-panel-CoFQOZfZ.js} +2 -2
- package/dist/shell/assets/timeline-display-F8qMrey9.js +2 -0
- package/dist/shell/assets/{trash-MHAT5Hf3.js → trash-BFH8OA7M.js} +2 -2
- package/dist/shell/assets/{update-set-B0D_tNDz.js → update-set-CivHicWr.js} +2 -2
- package/dist/shell/assets/use-calendar-move-CezBW0KE.js +2 -0
- package/dist/shell/assets/{use-display-rows-vjthlkqo.js → use-display-rows-7iLrRpz6.js} +2 -2
- package/dist/shell/assets/use-my-invitations-B7w0Q5kk.js +2 -0
- package/dist/shell/assets/{use-paged-search-DRj8498k.js → use-paged-search-CblCRsCd.js} +2 -2
- package/dist/shell/assets/{use-run-trace-CWGAibgF.js → use-run-trace-vMzYYuXG.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-C9ZEXX5R.js → use-workflow-page-Dac4wyOA.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-DDh28X2_.js → use-workflow-types-Bi8u42jQ.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-n_YJtaOh.js → workflow-canvas-2owtFZNz.js} +4 -4
- package/dist/shell/assets/{workflow-field-CpkY17Cc.js → workflow-field-Ct0HoH5Z.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-V-ZGHSrC.js → workflow-graph-editor-oAKVQAgf.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-CoUJGVdX.js → workflow-run-field-C7ff1D9_.js} +3 -3
- package/dist/shell/assets/workflow-status-field-iHUr4FZM.js +2 -0
- package/dist/shell/assets/workflow-workbench-BCsEjQVw.js +4 -0
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-d4bA-Rnh.js.map → account-page-ve4BUXRh.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-DU-Bny4k.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-DTNOfaAZ.js.map → assistant-shell-KyMQvcsn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-ClTe26F0.js.map → board-display-BaMLmYUJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-CwBcu_JO.js.map → calendar-display-CzQPcItV.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-D8cGALi4.js.map → call-rings-DUzC7UYz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-DLSo4hNS.js.map → calls-drZLv0wW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-C8YjGdRx.js.map → circle-alert-COV0WNyG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-DBHl-wl_.js.map → composed-page-CBJLOXNJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-6TvE0L2w.js.map → composer-section-05sGMnpR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-C8Km-e8S.js.map → connect-route-KBsPFlW4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-DXp0fGDR.js.map → copy-field-14Vmg95D.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-s8RsjtyM.js.map → create-route-DAprAV2h.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-B8ut5WnP.js.map → custom-step-container-field-D0cmhURR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-OJQKeuBN.js.map → embedded-list-Ra3OLUh6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-gSUSlzOy.js.map → export-dialog-Cz26bxgN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{first-organization-page-C7YZ32Kt.js.map → first-organization-page-C9ejBI4S.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-_7poAZsr.js.map → graph-view-B3TE-xbG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-XjNEBVUq.js.map → group-donut-BAyTgqYv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-Cj6F3D3u.js.map → guest-call-page-CEcPrLXS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-CmYTAzWa.js.map → html-viewer-DaeVR6PB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-bNG6qX6Q.js.map → import-dialog-6I25EI49.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-BbI7GJ8R.js.map → import-table-dialog-COsPNket.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-XV6kL2Mk.js.map → invitations-page-TBz_-ekD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-dpoR6hFU.js.map → layout-grid-BTGS8Vdw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-WwKh2W6n.js.map → legend-item-DkIaBiD0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-DImD2FRO.js.map → list-page-Dpq9M7YO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-Bm0OQH9k.js.map → maplibre-JTZsxvhv.js.map} +1 -1
- package/dist/shell-source-maps/assets/markdown-content-DBVa63k_.js.map +1 -0
- package/dist/shell-source-maps/assets/{members-page-ZcqzlQu6.js.map → members-page-CHRY9H9W.js.map} +1 -1
- package/dist/shell-source-maps/assets/message-content-DzyGCvgQ.js.map +1 -0
- package/dist/shell-source-maps/assets/{messages-vzi5T1Xo.js.map → messages-BwcGcxFR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-CjrQmpot.js.map → organization-page-BE182e_K.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-C7gJsoCx.js.map → organizations-page-DaN6zQZj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-BZVOux9W.js.map → pending-invitation-row-DvqK-Lh5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-GDqLnl9l.js.map → period-chart-Cn9bgVfB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-DgXLW9D8.js.map → person-row-CSBZnBQc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-DjLnqHPx.js.map → public-form-page-CaNVr6BS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-CDTPiIdF.js.map → record-lines-3DhkRSpH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-Dcmuv9J8.js.map → record-map-D4rgUOwb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-D7SV04zf.js.map → record-opens-BSFQWqio.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-DGWHTUdD.js.map → record-page-Cbx9gqMY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-DsIrTWKZ.js.map → record-preview-Bdzkrw0H.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-G0QXqaUR.js.map → records-map-BfkBfva4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-0_Pb8ixy.js.map → render-node-ChsAMZVA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-BhhzhhTO.js.map → reorder-button-pGaEX5DI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-DLY3Mt5m.js.map → run-trace-view-Cd3DppYM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-Iwp4UP6o.js.map → runner-install-field-CK3olYt5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-DKcAQek2.js.map → runtime-update-BNTp15Vo.js.map} +1 -1
- package/dist/shell-source-maps/assets/safe-html-CmkqDcA6.js.map +1 -0
- package/dist/shell-source-maps/assets/{sheet-source-DxVQhlKF.js.map → sheet-source-DONoSDqu.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-E1eBhmUM.js.map → sign-in-policy-page-C4MEEpwM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-Bu7xMabd.js.map → start-block-queries-B7qJvkWD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-BPk6WuYH.js.map → step-catalog-CgPcuEu_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-BXHWAw8x.js.map → step-panel-CoFQOZfZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CJHQiDm9.js.map → timeline-display-F8qMrey9.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-MHAT5Hf3.js.map → trash-BFH8OA7M.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-B0D_tNDz.js.map → update-set-CivHicWr.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-O_48Gqvs.js.map → use-calendar-move-CezBW0KE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-vjthlkqo.js.map → use-display-rows-7iLrRpz6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-my-invitations-DDPuugTE.js.map → use-my-invitations-B7w0Q5kk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-DRj8498k.js.map → use-paged-search-CblCRsCd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-CWGAibgF.js.map → use-run-trace-vMzYYuXG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-C9ZEXX5R.js.map → use-workflow-page-Dac4wyOA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-DDh28X2_.js.map → use-workflow-types-Bi8u42jQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-n_YJtaOh.js.map → workflow-canvas-2owtFZNz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-CpkY17Cc.js.map → workflow-field-Ct0HoH5Z.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-V-ZGHSrC.js.map → workflow-graph-editor-oAKVQAgf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-CoUJGVdX.js.map → workflow-run-field-C7ff1D9_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-nmrhtSls.js.map → workflow-status-field-iHUr4FZM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-DvzNEdn3.js.map → workflow-workbench-BCsEjQVw.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/assets/board-display-ClTe26F0.js +0 -2
- package/dist/shell/assets/calendar-display-CwBcu_JO.js +0 -2
- package/dist/shell/assets/composed-page-DBHl-wl_.js +0 -2
- package/dist/shell/assets/create-route-s8RsjtyM.js +0 -2
- package/dist/shell/assets/embedded-list-OJQKeuBN.js +0 -3
- package/dist/shell/assets/import-table-dialog-BbI7GJ8R.js +0 -2
- package/dist/shell/assets/list-page-DImD2FRO.js +0 -4
- package/dist/shell/assets/members-page-ZcqzlQu6.js +0 -2
- package/dist/shell/assets/messages-vzi5T1Xo.js +0 -2
- package/dist/shell/assets/organization-page-CjrQmpot.js +0 -2
- package/dist/shell/assets/organizations-page-C7gJsoCx.js +0 -2
- package/dist/shell/assets/public-form-page-DjLnqHPx.js +0 -2
- package/dist/shell/assets/record-page-DGWHTUdD.js +0 -3
- package/dist/shell/assets/render-node-0_Pb8ixy.js +0 -3
- package/dist/shell/assets/reorder-button-BhhzhhTO.js +0 -2
- package/dist/shell/assets/shared-protobase-ui-XTZSVgEm.js +0 -1
- package/dist/shell/assets/sheet-source-DxVQhlKF.js +0 -3
- package/dist/shell/assets/sign-in-policy-page-E1eBhmUM.js +0 -2
- package/dist/shell/assets/start-block-queries-Bu7xMabd.js +0 -2
- package/dist/shell/assets/step-catalog-BPk6WuYH.js +0 -2
- package/dist/shell/assets/timeline-display-CJHQiDm9.js +0 -2
- package/dist/shell/assets/use-calendar-move-O_48Gqvs.js +0 -2
- package/dist/shell/assets/use-my-invitations-DDPuugTE.js +0 -2
- package/dist/shell/assets/workflow-status-field-nmrhtSls.js +0 -2
- package/dist/shell/assets/workflow-workbench-DvzNEdn3.js +0 -4
- package/dist/shell-source-maps/assets/app-B94YfKGx.js.map +0 -1
- package/dist/shell-source-maps/assets/markdown-content-BZLiLira.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(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{Gl as e,Kl as t,Ks as n,Xc as r,al as i,fl as a,li as o,va as s,wa as c,xa as l}from"./app-B94YfKGx.js";var u=(e,t)=>{let n=e.position;if(!n||!c(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},d=(e,t)=>e.position?.within===void 0?u(e,t):void 0,f=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?u(t,n):void 0,p=(e,t,n,r)=>{if(t===void 0||e?.list?.drag?.rank!==!0||r!==``)return!1;let i=s(n);return i.columnId===t&&i.direction===`asc`},m=r(`app/hand-order`),h=(e,t,{title:r,place:i})=>!n(e)||e.status!==412?{state:`error`,title:t,description:o(e)}:r===void 0?{state:`warning`,title:t,description:m(`orderChangedSince`,{place:i})}:{state:`warning`,title:m(`notSaved`,{title:r}),description:m(`orderChangedThere`,{place:i})},g=(e,t,n)=>t.flatMap(({before:t,record:r,etag:i})=>{let a=n.filter(e=>Object.hasOwn(t,e)&&t[e]!==r[e]);return a.length===0?[]:[{op:`update`,resource:e.name,key:l(e,r),data:Object.fromEntries(a.map(e=>[e,t[e]])),etag:i}]}),_=async(e,t,n)=>{let r=[],i=``;do{let a=await e.search(t,{filter:n,pageSize:100,...i&&{pageToken:i}});r.push(...a.items),i=a.nextPageToken}while(i);return r},v=(e,t)=>t===void 0?e:`(${e}) AND (${t})`,y=async(n,r,o,s)=>{let c=r.position?.after;if(!c)return{after:[],before:[]};let u=r.primaryKey[0],d=l(r,s),f=e=>a([e]),p=await _(n,c.resource,v(t(e.or(e.eq(c.field,d),e.eq(c.key,d))),c.filter)),m=(e,t)=>p.flatMap(n=>f(n[e])===f(d)&&f(n[t])!==f(d)?[n[t]]:[]),h=m(c.field,c.key),g=m(c.key,c.field),[y,b]=await Promise.all([_(n,r.name,v(t(e.in(u,[d,...h])),c.while)),g.length===0?[]:_(n,r.name,t(e.in(u,g)))]),x=e=>{let t=a(l(r,e));return{key:t,rank:e[r.position.field],title:i(r,o,e,t)}},S=y.some(e=>f(e[u])===f(d));return{after:y.filter(e=>f(e[u])!==f(d)).map(x),before:S?b.map(x):[]}},b=(e,t,n,r,i,a=!1)=>{let o=t=>r[t]?l(e,r[t]):null,s=a&&i===r.length-1;return{op:`move`,resource:e.name,field:t,key:l(e,r[i]),after:o(i-1),...!s&&{before:o(i+1)},...n&&{filter:n}}},x=(e,t)=>{let n=new Map;for(let r of e)if(r.op===`reorder`||r.op===`move`)for(let e of r.records){let r=t(e.record);n.has(r)||n.set(r,e.previous)}return n},S=r(`app/rank-after`);export{g as a,p as c,y as i,d as l,x as n,h as o,b as r,m as s,S as t,f as u};
|
|
2
|
-
//# debugId=2fce2e53-d57a-4944-beea-271c83ef4008
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(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{Da as r,Do as i,Jo as a,Ka as o,M as s,Oa as c,Xa as l,Yo as u,Za as d,ac as f,eo as p,ls as m,sc as h,ss as g,ys as _}from"./app-B94YfKGx.js";import{t as v}from"./page-header-Ddz2r5ic.js";var y=e(t(),1),b=e(n(),1),x=({organization:e,editable:t,onSaved:n})=>{let{session:r}=_(),[s,c]=(0,y.useState)(e.name),[l,d]=(0,y.useState)(e.slug),{busy:f,error:m,run:g}=o(),v=s.trim()!==e.name||l!==e.slug;return(0,b.jsxs)(a,{title:p(`details`),description:p(t?`detailsEditable`:`detailsReadOnly`),children:[(0,b.jsx)(u,{message:m}),(0,b.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:t=>{t.preventDefault(),g(async()=>{await r.organizations.rename(e.id,{name:s.trim(),slug:l}),n()})},children:[(0,b.jsx)(i,{"aria-label":p(`name`),value:s,disabled:!t,onChange:e=>c(e.target.value),wrapperClassName:`flex-1`}),(0,b.jsx)(i,{"aria-label":p(`slug`),value:l,disabled:!t,onChange:e=>d(e.target.value),wrapperClassName:`sm:w-48`}),t&&(0,b.jsx)(h,{type:`submit`,variant:`primary`,loading:f,disabled:!v||!s.trim(),children:p(`save`)})]})]})},S=({organization:e,memberId:t})=>{let{session:n}=_(),[r,i]=(0,y.useState)([]),[s,c]=(0,y.useState)(``),{busy:l,error:d,run:f}=o();return(0,y.useEffect)(()=>{n.organizations.members(e.id).then(e=>i(e.filter(e=>e.id!==t)),()=>i([]))},[n,e.id,t]),(0,b.jsxs)(a,{title:p(`handOver`),description:p(`handOverDescription`),children:[(0,b.jsx)(u,{message:d}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,b.jsxs)(`select`,{"aria-label":p(`newOwner`),value:s,onChange:e=>c(e.target.value),className:`h-8 flex-1 rounded-md border border-border-strong bg-background px-2`,children:[(0,b.jsx)(`option`,{value:``,children:p(`chooseMember`)}),r.map(e=>(0,b.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),(0,b.jsx)(h,{loading:l,disabled:!s,onClick:()=>void f(async()=>{await n.organizations.transferOwnership(s),window.location.reload()}),children:p(`handOver`)})]})]})},C=({organization:e,basePath:t})=>{let{session:n}=_(),[s,l]=(0,y.useState)(!1),[d,m]=(0,y.useState)(``),{busy:g,error:v,run:x}=o(),S=c(),C=()=>x(async()=>{await n.organizations.remove(e.id),r(t)});return(0,b.jsxs)(a,{title:S(`deleteOrganization`),description:S(`deleteDescription`),children:[(0,b.jsx)(u,{message:s?void 0:v}),(0,b.jsx)(h,{variant:`danger`,onClick:()=>l(!0),children:S(`deleteOrganization`)}),s&&(0,b.jsxs)(f,{title:p(`deleteTitle`,{name:e.name}),description:p(`deleteConfirm`),onClose:()=>l(!1),actions:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(h,{onClick:()=>l(!1),children:p(`cancel`)}),(0,b.jsx)(h,{variant:`danger`,loading:g,disabled:d!==e.name,onClick:()=>void C(),children:p(`delete`)})]}),children:[(0,b.jsx)(u,{message:v}),(0,b.jsx)(i,{"aria-label":S(`organizationName`),value:d,onChange:e=>m(e.target.value)})]})]})},w=({editable:e})=>{let t=m(),[n,r]=(0,y.useState)(),{busy:i,error:c,run:l}=o();return(0,y.useEffect)(()=>{t.callGuests.allowed().then(r)},[t]),n===void 0?null:(0,b.jsxs)(a,{title:p(`guestLinks`),description:p(`guestLinksDescription`),children:[(0,b.jsx)(u,{message:c}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,b.jsx)(s,{checked:n,label:p(`guestLinksAllowed`),...e&&!i&&{onChange:e=>void l(async()=>{await t.callGuests.setAllowed(e),r(e)})}}),p(`guestLinksAllowed`)]})]})},T=({organization:e,basePath:t,owner:n})=>{let{session:i}=_(),{busy:s,error:c,run:l}=o();return(0,b.jsxs)(a,{title:p(`leave`),description:p(n?`leaveOwner`:`leaveMember`),children:[(0,b.jsx)(u,{message:c}),(0,b.jsx)(h,{loading:s,onClick:()=>void l(async()=>{await i.organizations.leave(e.id),r(t)}),children:p(`leaveName`,{name:e.name})})]})},E=({current:e,basePath:t,onChanged:n})=>{let r=g().data?.calls===!0,i=c(),a=e?.organization;if(!a)return(0,b.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 md:px-6`,children:(0,b.jsx)(v,{title:i(`organization`),subtitle:i(`noOrganization`)})});let o=e.role===`owner`;return(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,b.jsx)(v,{title:a.name,subtitle:e.role?p(`youAre`,{role:d(e.role).toLowerCase()}):p(`throughGlobalRoles`)}),(0,b.jsx)(x,{organization:a,editable:l(e),onSaved:n},`${a.name}/${a.slug}`),r&&e.role&&(0,b.jsx)(w,{editable:l(e)}),o&&e.memberId&&(0,b.jsx)(S,{organization:a,memberId:e.memberId}),e.role&&(0,b.jsx)(T,{organization:a,basePath:t,owner:o}),o&&(0,b.jsx)(C,{organization:a,basePath:t})]})};export{E as OrganizationPage};
|
|
2
|
-
//# debugId=a3ad09a9-a2da-4b15-b7ca-12f197a77589
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(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{Da as r,Ha as i,Jo as a,Ka as o,Oa as s,Yo as c,Zo as l,eo as u,sc as d,ys as f}from"./app-B94YfKGx.js";import{t as p}from"./page-header-Ddz2r5ic.js";import{n as m,t as h}from"./use-paged-search-DRj8498k.js";import{i as g,n as _,r as v,t as y}from"./use-my-invitations-DDPuugTE.js";var b=e(t(),1),x=e(n(),1),S=({organization:e,current:t,busy:n,onOpen:r})=>(0,x.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,x.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.slug})]}),t?(0,x.jsx)(l,{tone:`green`,children:u(`current`)}):(0,x.jsx)(d,{size:`sm`,loading:n,onClick:r,children:u(`open`)})]}),C=({basePath:e,currentId:t})=>{let{session:n}=f(),i=s(),[a,c]=(0,b.useState)(``),l=(0,b.useCallback)((e,t)=>n.organizations.search(e,t).then(e=>({items:e.organizations,total:e.total})),[n]),d=h(l,a),{busy:p,error:g,run:_}=o();return(0,x.jsx)(m,{title:i(`allOrganizations`),description:i(`allOrganizationsDescription`),searchLabel:i(`findOrganization`),placeholder:u(`nameOrSlug`),query:a,onQuery:c,list:d,error:g,renderRow:i=>(0,x.jsx)(S,{organization:i,current:i.id===t,busy:p,onOpen:()=>void _(async()=>{await n.organizations.switchTo(i.id),r(e)})},i.id)})},w=({basePath:e})=>{let t=s(),n=y(),i=n.state===`ready`?n.invitations:void 0,{busy:o,error:l,joining:u,join:d}=_(()=>r(e));return!i||i.length===0?null:(0,x.jsxs)(a,{title:t(`invitationsForYou`),description:t(`invitationsForYouDescription`),children:[(0,x.jsx)(c,{message:l}),(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(e=>(0,x.jsx)(g,{invitation:e,t,busy:o,joining:u===e.id,onJoin:()=>d(e.id)},e.id))})]})},T=({state:e,basePath:t})=>{let{session:n,organizations:l,state:u}=f(),d=s(),{busy:m,error:h,run:g}=o(),_=u.kind===`signed-in`?u.user:void 0,y=l?.create===`everyone`||_!==void 0&&i(_),b=e.current?.organization?.id;return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(p,{title:d(`organizations`),subtitle:d(`organizationsSubtitle`)}),(0,x.jsxs)(a,{title:d(`yourOrganizations`),description:e.organizations.length>0?d(`memberOf`):d(`notMember`),children:[(0,x.jsx)(c,{message:h??e.error}),e.organizations.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.organizations.map(e=>(0,x.jsx)(S,{organization:e,current:e.id===b,busy:m,onOpen:()=>void g(async()=>{await n.organizations.switchTo(e.id),r(t)})},e.id))})]}),(0,x.jsx)(w,{basePath:t}),y&&(0,x.jsx)(a,{title:d(`newOrganization`),description:d(`newOrganizationDescription`),children:(0,x.jsx)(v,{onCreated:()=>r(t)})}),(e.current?.globalRoles.length??0)>0&&(0,x.jsx)(C,{basePath:t,currentId:b})]})};export{T as OrganizationsPage};
|
|
2
|
-
//# debugId=bb809b28-0b12-4ba3-bd7f-60b23655f8bd
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(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{Ks as r,R as i,Xc as a,Yc as o,_ as s,a as c,b as l,c as u,cl as d,co as f,i as p,is as m,lc as h,ls as g,mr as _,o as v,sc as y,ts as b,u as x,uo as S,v as C,y as w}from"./app-B94YfKGx.js";import{o as T}from"./vendor-t7Q7QbPu.js";import{n as E,t as D}from"./lib-altcha-lib-BK1uKcxH.js";var O=e(t(),1),k=a(`forms`),A=async(e,t)=>{let n=await e.formChallenge(t),r=await E({challenge:n,deriveKey:D});if(!r)throw Error(k(`checkTooLong`));return{challenge:n,solution:{counter:r.counter,derivedKey:r.derivedKey}}},j=e(n(),1),M=({name:e})=>{let t=g(),n=T({queryKey:o.publicForm(e),queryFn:()=>t.form(e)});return n.isPending?(0,j.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,j.jsx)(h,{}),` `,k(`loading`)]}):n.error?r(n.error)&&n.error.status===404?(0,j.jsx)(b,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(b,{title:m(`cannotReach`),children:r(n.error)?n.error.message:m(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=g(),{resource:n,view:r}=e,a=e.title??r.names?.singular??d(r.resource);S(a);let[o,m]=(0,O.useState)(()=>v(n,[{title:a,fields:e.fields}])),[h,b]=(0,O.useState)({}),[T,E]=(0,O.useState)(),[D,M]=(0,O.useState)(!1),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(0),L=s(F);if(N)return(0,j.jsx)(f,{title:a,size:`md`,children:(0,j.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:e.thanks})});let R=(e,t)=>{b(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),m(n=>({...n,[e]:t}))},z=async()=>{M(!0),E(void 0);try{await t.submitForm(e.name,p(n,{},o),await A(t,e.name)),P(!0)}catch(e){let t=C(e);b(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(f,{title:a,size:`md`,children:(0,j.jsxs)(`form`,{ref:L,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),z()},children:[e.fields.map(e=>{let t=n.fields[e],a=r.fields[e],s=a?.label??d(e),f=h[e];return(0,j.jsx)(i,{name:e,label:s,help:a?.help,required:u(t),error:f&&w(t,s,f),children:(0,j.jsx)(l,{field:t,hints:a,value:o[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:c(t)?k(`setByDatabase`):x(t),invalid:!!f,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(_,{title:k(`notSent`),error:T}),(0,j.jsx)(y,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
|
|
2
|
-
//# debugId=e32e7a87-3f1d-487c-9723-08d95fbaa9a0
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-Dcmuv9J8.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-Bm0OQH9k.js","assets/app-B94YfKGx.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.css","assets/lib-maplibre-gl-CFGgq6sa.js","assets/lib-maplibre-gl-DBE96hFo.css","assets/lib-vis.gl-react-maplibre-1cv426UN.js","assets/lib-pmtiles-G7iEFxNu.js","assets/lib-fflate-HbhbPPwS.js","assets/record-lines-CDTPiIdF.js","assets/embedded-list-OJQKeuBN.js","assets/update-set-B0D_tNDz.js","assets/layout-grid-dpoR6hFU.js","assets/lib-tanstack-react-table-uAPG3Sdi.js","assets/lib-tanstack-store-KbP08Dw1.js","assets/lib-tanstack-react-store-BKI8EKbh.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-tanstack-table-core-2MHQ7o_e.js","assets/record-preview-DsIrTWKZ.js","assets/lib-dnd-kit-core-xi-7xL_N.js","assets/lib-dnd-kit-utilities-Bvr0fWXF.js","assets/lib-dnd-kit-accessibility-AUTLnqh4.js","assets/lib-dnd-kit-sortable-CNDSKqCD.js","assets/composer-section-6TvE0L2w.js","assets/render-node-0_Pb8ixy.js","assets/circle-alert-C8YjGdRx.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-BZVOux9W.js","assets/person-row-DgXLW9D8.js","assets/use-paged-search-DRj8498k.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-DXp0fGDR.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,r as n,t as r}from"./react-CuiNlnus.js";import{$ as i,$c as a,An as o,Bn as s,Bo as c,C as l,Ca as u,Ci as d,D as f,Di as p,Dn as m,Dr as h,Dt as g,E as _,Et as v,Fi as y,Fo as b,Hc as x,Hn as S,I as C,Ic as ee,Ii as w,Io as te,Jn as T,Kl as E,Ks as D,La as O,Lo as ne,Lr as k,Lt as re,Mn as ie,Nc as A,No as ae,O as oe,Oi as se,Ol as ce,On as le,Or as ue,Ot as de,P as j,Pa as fe,Pc as pe,Pi as me,Po as he,Pr as ge,Ql as M,Qs as _e,R as ve,Ra as ye,Ri as be,Rr as xe,Si as Se,Ta as Ce,Tr as we,Tt as Te,Ua as Ee,Vc as N,Wl as P,Xc as F,Xl as De,Xs as I,Yc as L,Yi as Oe,Z as R,Zo as z,_ as ke,_a as Ae,_i as je,_n as Me,b as Ne,ba as Pe,bn as Fe,bo as Ie,ca as Le,cc as Re,cl as B,ct as V,d as ze,dc as Be,di as Ve,en as He,et as Ue,f as We,fl as Ge,g as H,gi as Ke,gs as qe,h as Je,hi as Ye,ic as U,it as Xe,ja as Ze,ji as Qe,jn as $e,k as et,l as tt,li as nt,ls as W,m as rt,mn as it,mo as at,mr as G,nc as ot,nr as st,ns as K,nt as ct,oc as lt,ot as ut,p as dt,rc as ft,rl as pt,rr as mt,rs as ht,rt as gt,s as _t,sc as q,st as vt,ta as yt,tc as bt,ts as xt,un as St,v as Ct,vi as wt,w as Tt,wa as Et,wn as Dt,wr as Ot,x as kt,xa as At,xi as jt,xn as Mt,xo as Nt,y as Pt,yc as Ft,yl as It,yn as Lt,yo as Rt,ys as zt,zo as Bt}from"./app-B94YfKGx.js";import{C as Vt,h as Ht,i as Ut,o as Wt,r as Gt,s as Kt}from"./vendor-t7Q7QbPu.js";import{Ct as qt,Dt as Jt,Et as Yt,Mt as Xt,Tt as Zt,_ as Qt,a as $t,c as en,lt as tn,n as nn,ot as rn,pt as an,rt as on,s as sn,t as cn,tt as ln,yt as un}from"./embedded-list-OJQKeuBN.js";import{a as dn,i as fn,n as pn,r as mn,t as hn}from"./reorder-button-BhhzhhTO.js";import{a as gn,c as _n,i as vn,l as yn,n as bn,o as xn,r as Sn,s as Cn,t as wn}from"./render-node-0_Pb8ixy.js";import{t as Tn}from"./trash-MHAT5Hf3.js";import{n as En,t as Dn}from"./record-sidebar-HqyBXBwn.js";import{t as On}from"./start-block-queries-Bu7xMabd.js";import{t as kn}from"./record-opens-D7SV04zf.js";import{u as An}from"./messages-vzi5T1Xo.js";var jn={name:`images`,size:24,node:[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]};jn.node;var Mn=N(jn),Nn={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};Nn.node;var Pn=N(Nn),Fn={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};Fn.node;var In=N(Fn),Ln={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Ln.node;var Rn=N(Ln),zn={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};zn.node;var Bn=N(zn),J=e(r(),1),Vn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 border-b border-border pb-6 md:flex-row md:items-end md:justify-between md:gap-6`,children:[(0,J.jsxs)(`div`,{children:[e&&(0,J.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,J.jsxs)(J.Fragment,{children:[V(`lastEditedBy`),` `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,J.jsx)(J.Fragment,{children:V(`lastUpdated`,{ago:r.ago})})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(te,{people:i,size:`md`}),V(`viewing`,{count:i.length})]}),a]})]}),Y=e(t(),1),Hn=`text-base font-semibold text-foreground`,Un=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,Y.useId)();return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:x(`py-8`,r&&`pb-0`),children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,J.jsxs)(k,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:x(`inline-flex items-center gap-1.5`,Hn),children:[(0,J.jsx)(A,{className:x(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,J.jsx)(`span`,{className:Hn,children:e}),n]}),t&&(0,J.jsx)(`p`,{className:x(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,J.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,J.jsx)(C.Provider,{value:2,children:a})})]})},Wn=({tabs:e})=>(0,J.jsx)(`nav`,{"aria-label":V(`tabs`),className:`overflow-x-auto py-6`,children:(0,J.jsx)(`span`,{className:Nt.group(`md`),children:e.map(e=>(0,J.jsx)(k,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:x(Nt.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Gn=({rows:e})=>(0,J.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,J.jsxs)(`div`,{className:x(`grid gap-x-4 border-b border-border py-2.5`,e.wide?`grid-cols-1 gap-y-1.5`:`grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`),children:[(0,J.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,J.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Kn=({facts:e})=>(0,J.jsx)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-5 sm:flex sm:flex-wrap sm:gap-x-10`,children:e.map(({label:e,value:t,icon:n})=>(0,J.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),qn=`flex min-h-11 items-center gap-2 rounded-md border border-border-strong px-3 text-left hover:bg-surface disabled:cursor-default disabled:opacity-60 md:min-h-0 md:w-full md:items-start md:gap-3 md:rounded-none md:border-0 md:px-4 md:py-3`,Jn=({actions:e})=>(0,J.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,J.jsx)(`h2`,{className:`hidden border-b border-border px-4 py-2.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground md:block`,children:V(`actions`)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2 p-2 md:block md:divide-y md:divide-border md:p-0`,children:e.map(({name:e,description:t,icon:n,onRun:r,blocked:i,running:a,tone:o,render:s})=>{let c=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{className:x(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:x(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,J.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,J.jsx)(`li`,{children:s?s({className:qn,children:c}):(0,J.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:qn,children:c})},e)})})]}),Yn=e(n(),1),Xn=1e3,Zn=(e,t,n,r,i)=>{let a=ge(e?.name??``,{enabled:!!(e&&t),filter:t?`${t.name} = "${r}"`:void 0,pageSize:500,labels:i,...n&&e?.fields[n]?.sortable&&{orderBy:`${n} asc`}}),o=(0,Y.useMemo)(()=>n?[...a.items].sort((e,t)=>Number(e[n])-Number(t[n])):a.items,[a.data,n]),s=a.hasNextPage&&a.items.length<1e3;return(0,Y.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Qn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),$n=(e,t)=>e.sidebar?e.title?(0,J.jsx)(En,{title:e.title,children:t}):t:e.title?(0,J.jsx)(j,{title:e.title,children:t}):(0,J.jsx)(`section`,{className:`py-8`,children:t}),er=({item:e,scope:t,fallback:n})=>{let{components:r}=Ze(),i=r?.[e.component],a=i&&(0,J.jsx)(st,{value:t,children:(0,J.jsx)(i,{...ce(e.props??{})})});return n===void 0?$n(e,(0,J.jsx)(bn,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,J.jsx)(bn,{name:e.component,registered:!!i,fallback:n,children:$n(e,a)})},tr=({component:e,scope:t,standard:n})=>{let{components:r}=Ze(),i=r?.[e];return i?(0,J.jsx)(Ee,{name:e,fallback:n,children:(0,J.jsx)(nr,{children:(0,J.jsx)(st,{value:t,children:(0,J.jsx)(i,{})})})}):n},nr=({children:e})=>(ne(!1),(0,J.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),rr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,ir=(e,t,n)=>M(()=>{let r=e.getItem(t);if(r===null)return;let i=JSON.parse(r);if(i&&i.etag===n&&typeof i.fields==`object`&&i.fields!==null)return{etag:n,fields:i.fields,...Array.isArray(i.order)&&{order:i.order.map(String)}}},void 0),ar=(e,t,n)=>M(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),or=e=>re(e)??Bn,sr=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=xe(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=qt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,Y.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?$t(e.run,t.record,a):void 0;return{name:e.label,icon:or(e.icon),blocked:n,running:c.running===e.name,...Jt(e)&&{tone:`danger`},onRun:()=>Yt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,J.jsx)(ot,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:H(`edit`),icon:dn,render:({className:e,children:t,role:n})=>(0,J.jsx)(k,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:H(`delete`),icon:Tn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,J.jsx)(Zt,{action:l,label:l.label,danger:Jt(l),records:[t.record],onCancel:()=>u(void 0),onConfirm:()=>{u(void 0),c.run(l)},onSubmit:async e=>{await c.submit(l,e),u(void 0)}})}},cr=e=>{let t=at(),{actions:n,prompt:r}=sr(e);return n.length===0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,J.jsx)(Jn,{actions:n})}),t&&(0,Yn.createPortal)((0,J.jsx)(vt,{actions:n,label:H(`recordActions`),className:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`}),t),r]})},lr=e=>{let t=typeof e.resource==`string`?e.resource:e.resource.toModel().name;return e.op===`reorder`?`reorder ${t} by ${e.field}`:`${e.op} ${t}`},ur=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?bt(`operationFailed`,{index:n+1,label:lr(r),message:e.message}):bt(`nothingSaved`,{message:e.message})},dr=(e,t)=>new e.constructor({...e.problem,detail:ur(e,t)}),fr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),pr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=W(),c=Ht(),u=we(e.name,n),d=Je(r,i),[p]=(0,Y.useState)(()=>a?ir(localStorage,a,t.etag):void 0),[m,h]=(0,Y.useState)(p?.fields??{}),[g,_]=(0,Y.useState)(!!p),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)({}),[S,C]=(0,Y.useState)({}),[ee,w]=(0,Y.useState)(0),te=Object.entries(m).filter(([n,r])=>l(e.fields[n],r,t.record[n])),T=te.length>0,E=T||!!o?.dirty;(0,Y.useEffect)(()=>{p?.order&&o?.setOrder(p.order)},[]),(0,Y.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(m).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;ar(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,m,o?.order,t.etag]);let O=n=>n in m?m[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:f(t.record[n]),ne=(n,r)=>{C(e=>fr(e,n));let i=typeof r==`string`?r!==f(t.record[n]):l(e.fields[n],r,t.record[n]);h(e=>i?{...e,[n]:r}:fr(e,n))},k=async()=>{let r=await s.get(e.name,n);c.setQueryData(L.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(m)){let s=e.fields[n];l(s,o,r.record[n])&&(a[n]=o,f(r.record[n])!==f(t.record[n])&&(i[n]=s.type===`file`?Ke(s,r.record[n]):f(r.record[n])))}h(a),x(i)},re=()=>Object.fromEntries(te.map(([t,n])=>[t,et(e.fields[t],n)])),ie=e=>{let t=Ct(e);C(t),Object.keys(t).length>0&&w(e=>e+1)},A=async()=>{try{await u.mutateAsync({patch:re(),etag:t.etag})}catch(e){throw Ot(e)?await k():D(e)&&ie(e),e}},ae=async r=>{let i=T?[{op:`update`,resource:e.name,key:n,data:re(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(Ot(e))await k(),await c.invalidateQueries({queryKey:[`list`]}),y(!0);else if(D(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?ie(e):n&&o?.reject(n,e)}throw D(e)?dr(e,a):e}await Promise.all([c.invalidateQueries({queryKey:L.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:O,change:ne,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await ae(e):await A(),h({}),x({}),C({}),y(!1),_(!1)}),dirty:E,discard:()=>{h({}),x({}),C({}),y(!1),_(!1),o?.reset()},restored:g&&E,dismissRestored:()=>_(!1),linesConflict:v,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:b,errors:S,rejections:ee,keepMine:e=>x(t=>fr(t,e)),useTheirs:e=>{x(t=>fr(t,e)),h(t=>fr(t,e))}}},X=F(`focus-record`),mr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,J.jsx)(J.Fragment,{children:e.map(({name:e,label:r})=>[(0,J.jsx)(q,{size:`sm`,onClick:()=>t(e),children:X(`keepMine`,{field:r})},`mine:${e}`),(0,J.jsx)(q,{size:`sm`,onClick:()=>n(e),children:X(`useTheirs`,{field:r})},`theirs:${e}`)])}),hr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=gt(`primary`),o=ut()?.size===`compact`,s=(0,J.jsx)(q,{variant:!a||n?`primary`:`secondary`,loading:r,"aria-disabled":!n,className:`max-md:min-h-11`,onClick:()=>void(n&&!r&&i()),children:t});return o&&!n?null:a?(0,J.jsx)(ct,{zone:`secondary`,children:s}):(0,J.jsx)(ct,{zone:`primary`,fallback:!0,children:s})},gr=({record:e,saved:t,readOnly:n})=>{let r=ut()?.size,i=n?X(`readOnly`):e.saving?X(`saving`):e.dirty?X(r===`wide`?`unsaved`:`unsavedShort`):t?X(`saved`):void 0;return i?(0,J.jsx)(ct,{zone:`state`,fallback:!0,children:(0,J.jsxs)(`span`,{role:`status`,title:n?X(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,J.jsx)(ee,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},_r=({model:e,recordKey:t,stored:n,page:r})=>{let a=K().views[e.name],{address:o,go:s}=xe(),c=be()(e,a,n.record,t),{state:l}=zt(),u=pr({model:e,stored:n,recordKey:t,mode:`button`,subject:c,draftKey:l.kind===`signed-in`?`${rr(l.user.id,e.name,t)}:focus`:void 0});_e(u.dirty||u.saving),qe(u.dirty);let d=Ht(),[f,p]=(0,Y.useState)(!1),m=a?.names?.singular??B(e.name),h=ht(e.name),g=mn(e),_=o?.kind===`record`&&o.version!==void 0&&o.version!==Number(n.record.version),v=`surface`in r&&(Ce(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),y=Et(h,`update`)&&n.permissions?.update!==!1&&!v,b=!y||_,x=Et(h,`delete`)&&n.permissions?.delete!==!1,S=fn({model:e,view:a,restore:g,onDeleted:()=>s({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void d.invalidateQueries({queryKey:L.record(e.name,t)})}),{actions:C,prompt:ee}=sr({model:e,stored:n,recordKey:t,onDelete:x?()=>void S.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0}),w=(0,Y.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),te=C.filter(e=>e.tone===`danger`),T=[...C.filter(e=>e.tone!==`danger`),...u.dirty?[{name:X(`discardChanges`),icon:Rn,onRun:()=>p(!0)}]:[],{name:X(`detailsOf`,{noun:m}),icon:In,render:({className:e,children:t,role:n})=>(0,J.jsx)(k,{to:w,role:n,className:e,children:t})},...te],E={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:b,mayUpdate:y,value:u.value,change:(e,t)=>b?void 0:u.change(e,t),dirty:u.dirty,saving:u.saving,refused:u.message!==void 0,save:async()=>!b&&!!await u.save(),discard:u.discard,details:w},D=`surface`in r?r.surface:void 0,O=f&&u.dirty&&(0,J.jsx)(Ue,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(q,{size:`sm`,variant:`danger`,onClick:()=>{u.discard(),p(!1)},children:X(`discardChanges`)}),(0,J.jsx)(q,{size:`sm`,onClick:()=>p(!1),children:X(`keep`)})]}),children:X(`discardAsk`)}),ne=Object.keys(u.conflicts).length>0,re=D?u.errors[D]:void 0,ie=re&&D?Pt(e.fields[D],a?.fields[D]?.label??B(D),re):void 0;return(0,J.jsxs)(R.Provider,{value:E,children:[!b&&(0,J.jsx)(hr,{record:E,label:X(`save`)}),(0,J.jsx)(gr,{record:E,saved:u.phase===`saved`,readOnly:b}),(0,J.jsx)(i,{actions:T}),u.message&&!f&&(0,J.jsxs)(Ue,{level:`refused`,actions:(0,J.jsx)(k,{to:w,className:`text-body font-medium text-primary-text hover:underline`,children:X(`detailsOf`,{noun:m})}),children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:X(`notSaved`)}),` `,ie??u.message]}),ne&&(0,J.jsx)(Ue,{level:`conflict`,actions:(0,J.jsx)(mr,{fields:Object.keys(u.conflicts).map(e=>({name:e,label:a?.fields[e]?.label??B(e)})),onKeepMine:u.keepMine,onUseTheirs:u.useTheirs}),children:X(`conflict`)}),O,u.restored&&!f&&(0,J.jsx)(Ue,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(q,{size:`sm`,onClick:u.dismissRestored,children:X(`keep`)}),(0,J.jsx)(q,{size:`sm`,onClick:u.discard,children:X(`discard`)})]}),children:X(`restored`)}),D?(0,J.jsx)(vr,{model:e,name:D,stored:n,editor:u,readOnly:b}):(0,J.jsx)(yr,{name:r.component,model:e,stored:n,recordKey:t}),S.dialogs,ee]})},vr=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=K().views[e.name]?.fields[t];if(Ce(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,J.jsx)(`div`,{className:`absolute inset-0`,children:(0,J.jsx)(Ne,{field:e.fields[t],hints:a,value:r.value(t),stored:n.record[t],locked:i,invalid:!!r.errors[t],resource:e.name,onChange:e=>r.change(t,e)})})},yr=({name:e,model:t,stored:n,recordKey:r})=>{let i=Ze().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,J.jsx)(`div`,{className:`absolute inset-0`,children:(0,J.jsx)(st,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,J.jsx)(i,{})})})},br=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=be()(e,K().views[e.name],n.record,t);return(0,J.jsx)(Ee,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,J.jsx)(Xe,{label:a,children:(0,J.jsx)(_r,{model:e,recordKey:t,stored:n,page:r})})})},xr=(0,Y.lazy)(()=>Vt(()=>import(`./record-map-Dcmuv9J8.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Sr=15,Cr=({item:e,record:t})=>{let n=K().maps,r=n?.style,i=Qt(t,e);if(!r||!i)return null;let a=(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,J.jsx)(Y.Suspense,{fallback:null,children:(0,J.jsx)(xr,{style:r,layers:n?.layers,position:i,zoom:e.zoom??Sr},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,J.jsx)(En,{title:e.title,children:a}):(0,J.jsx)(j,{title:e.title,children:a})},wr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},Tr=(e,t,n)=>{let r=new Map;e.forEach((e,i)=>{for(let a of e){let e=Date.parse(`${String(a.value)}Z`),o=r.get(e)??{at:e,value:null,count:0};o[t[i]]=a[n]??null,o.count=Math.max(o.count,a.count),r.set(e,o)}});let i=Object.fromEntries(t.map(e=>[e,null]));return[...r.values()].sort((e,t)=>e.at-t.at).map(e=>({...i,...e}))},Z=F(`app/record-chart`),Er=P(),Dr=[`1h`,`24h`,`7d`],Or={"1h":`hour`,"24h":`day`,"7d":`week`},kr=({item:e,recordKey:t})=>{let{resources:n,views:r}=K(),[i,a]=(0,Y.useState)(e.range??`1h`),[o,s]=(0,Y.useState)(`average`),c=n[e.resource],l=r[e.resource],u=wr[i],d=E(Er.eq(e.field,t)),f=e.series.map(t=>({groupBy:e.at,filter:d,...o===`average`?{average:t}:{maximum:t},range:i,granularity:u,timeZone:Le()})),p=ue(e.resource,f,!!c);if(!c)return null;let m=e.series.map(e=>({kind:o,field:c.fields[e],...l?.fields[e]&&{hints:l.fields[e]}})),h=e.series.map((e,t)=>({key:`s${t}`,label:l?.fields[e]?.label??B(e),color:`var(--chart-${t+1})`,measure:m[t]})),g=p.every(e=>e.data)?Tr(p.map(e=>e.data.groups),h.map(e=>e.key),o):[],_=(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(Ie,{label:Z(`measure`),value:o,onChange:s,options:[{value:`average`,label:Z(`average`)},{value:`maximum`,label:Z(`maximum`)}]}),(0,J.jsx)(Ie,{label:Z(`range`),value:i,onChange:a,options:Dr.map(e=>({value:e,label:Z(Or[e])}))})]});return(0,J.jsx)(j,{title:e.title,help:e.help,actions:_,children:p.some(e=>e.error)?(0,J.jsx)(`p`,{className:`text-danger-text`,children:Z(`couldNotLoad`)}):p.some(e=>e.isPending)?(0,J.jsx)(U,{className:`h-40 w-full`}):g.every(e=>e.count===0)?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`noSamples`)}):(0,J.jsx)(an,{points:g,measure:m[0],bucket:u,type:`line`,series:h,...h.length>1&&{resource:e.resource,view:l}})})},Ar=F(`app/record-trend`),jr=(e,t)=>Ar(`total_${t}`,{count:e}),Mr=P(),Nr={kind:`count`},Pr=({item:e,recordKey:t})=>{let n=E(Mr.eq(e.field,t)),r=h(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Le()});return(0,J.jsx)(j,{title:e.title,help:e.help,children:(0,J.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,J.jsx)(U,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,J.jsx)(G,{title:Ar(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:jr(t,e.range)}),(0,J.jsx)(an,{points:un(r.data.groups,Nr),measure:Nr,bucket:e.granularity,type:`bar`})]})})()})})},Fr=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],Ir=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),Lr=e=>{let t=e.findIndex(e=>e.kind===`tab`);if(t===-1)return{before:e,tabs:[],after:[]};let n=[];for(let r of e.slice(t)){if(r.kind!==`tab`)break;n.push(r)}return{before:e.slice(0,t),tabs:n,after:e.slice(t+n.length)}},Rr=(e,t)=>e.find(e=>e.title===t)??e[0],zr=e=>It(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),Br=(e,t,n)=>{if(t&&!zr(t).some(n))return e.find(e=>zr(e).some(n))},Vr={added:[],edits:{},removed:[]},Hr=(e,t)=>{let n=[...e.filter(e=>!t.removed.includes(e)),...t.added];return t.order?[...t.order.filter(e=>n.includes(e)),...n.filter(e=>!t.order.includes(e))]:n},Ur=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&l(i,r,n[t])?[[t,et(i,r)]]:[]})),Wr=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,et(r,n)]]})),Gr=({model:e,position:t,link:n,stored:r,state:i})=>{let a={ops:[],rows:[]},o=(e,t)=>{a.ops.push(e),a.rows.push(t)},s=new Map(r.map(t=>[Pe(e,t),t])),c=[...s.keys()],l=Hr(c,i),u=t=>At(e,s.get(t)),d=e=>{let t=s.get(e).etag;return typeof t==`string`?t:void 0};for(let t of i.removed){if(!s.has(t))continue;let n=d(t);o({op:`delete`,resource:e.name,key:u(t),...n&&{etag:n}},t)}let f=new Set;for(let[t,n]of Object.entries(i.edits)){if(!s.has(t)||i.removed.includes(t))continue;let r=Ur(e,n,s.get(t));if(Object.keys(r).length===0)continue;let a=d(t);o({op:`update`,resource:e.name,key:u(t),data:r,...a&&{etag:a}},t),f.add(t)}let p=l.filter(e=>s.has(e)),m=l.filter(e=>!s.has(e)),h=(e,t)=>Object.fromEntries(e.flatMap(e=>{let n=t||f.has(e)?`*`:d(e);return n?[[Ge(u(e)),n]]:[]})),g=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),_=(r,a,o)=>({op:`create`,resource:e.name,data:{...Wr(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),v=e=>Number(e[t])||0,y=p.some((e,t)=>e!==c.filter(e=>p.includes(e))[t]);if(m.every(e=>l.indexOf(e)>=p.length)){y&&o(g(p.map(u),1,h(p,!1)));let e=y?p.length:Math.max(0,...p.map(e=>v(s.get(e))));return m.forEach((t,n)=>o(_(t,e+1+n),t)),a}let b=Math.max(l.length,...r.map(v))+1;p.length>0&&o(g(p.map(u),b,h(p,!1)));let x=e=>`line${m.indexOf(e)+1}`;for(let e of m)o(_(e,l.indexOf(e)+1,x(e)),e);return o(g(l.map(e=>s.has(e)?u(e):{$ref:x(e)}),1,h(p,!0))),a},Kr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),qr=(e,t)=>{let[n,r]=(0,Y.useState)(Vr),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(1),s=(0,Y.useMemo)(()=>new Map(e?t.map(t=>[Pe(e.model,t),t]):[]),[e,t]),c=Hr([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Gr({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,d=(0,Y.useMemo)(()=>{let e=Hr([...s.keys()],n).filter(e=>s.has(e)),t=[...s.keys()].filter(t=>e.includes(t));return n.order!==void 0&&e.some((e,n)=>e!==t[n])?e:void 0},[s,n]),f=(t,r)=>{let i=n.edits[t];if(i&&r in i)return i[r];let a=e?.model.fields[r],o=s.get(t)?.[r];return a?[`boolean`,`file`].includes(a.type)?o:oe(a,o):o},p=e=>a(t=>t?.id===e?void 0:t);return{shown:c,dirty:u,order:d,value:f,change:(e,t,n)=>{p(e),r(r=>({...r,edits:{...r.edits,[e]:{...r.edits[e],[t]:n}}}))},add:()=>{let e=`new:${o.current++}`;return r(t=>({...t,added:[...t.added,e]})),e},remove:e=>{p(e),r(t=>t.added.includes(e)?{...t,added:t.added.filter(t=>t!==e),edits:Kr(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Vr),a(void 0)},reject:(e,t)=>a({id:e,fields:Ct(t),message:t.message}),rejection:i,plan:l}},Jr=(e,t)=>{let n=It(t?.layout??[]).find(e=>e.kind===`related`&&e.lines===!0);if(n?.kind!==`related`)return;let r=e[n.resource],i=r?.fields[n.field],a=r?.position?.field;if(r&&i&&a&&r.position?.within===n.field)return{item:n,model:r,link:i,position:a}},Yr=(e,t,n,r)=>pt(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Xr=(e,t)=>{let{resources:n,views:r}=K(),i=(0,Y.useMemo)(()=>Jr(n,r[e.name]),[n,r,e]),a=i?.model,o=i?Yr(i.model,r[i.model.name],i.link.name,i.position):[],s=Zn(a,i?.link,i?.position,t,a?T(n,r,a,o):void 0),c=qr((0,Y.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:tt(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Zr=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Qr=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,$r=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,ei=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),ti=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,ni=`protobase:lightbox-details`,ri=e=>M(()=>e.getItem(ni)===`true`,!1),ii=(e,t)=>M(()=>t?e.setItem(ni,`true`):e.removeItem(ni),void 0),Q=F(`app/gallery`),ai=`flex size-10 shrink-0 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,oi=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=Q(`details`)})=>{let s=(0,Y.useRef)(null),c=(0,Y.useRef)(void 0),l=(0,Y.useId)(),u=Bt(),[d,f]=(0,Y.useState)(()=>ri(localStorage)),[p,m]=(0,Y.useState)(!1);lt(s,!0,i),(0,Y.useEffect)(()=>m(!0),[]);let h=t.length,g=e=>{let t=ei(n,e,h);t!==n&&r(t)},_=se(t[n],{width:1600,height:1200}),v=a?.(n),y=v!==void 0,b=e=>{f(e),ii(localStorage,e)};return(0,J.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(y&&ti(e))return e.preventDefault(),b(!d);let t=$r(e.key);t!==0&&(e.preventDefault(),g(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,J.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,J.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y&&(0,J.jsx)(`button`,{type:`button`,className:x(ai,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>b(!d),children:(0,J.jsx)(Pn,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:ai,"aria-label":Q(`close`),onClick:i,children:(0,J.jsx)(Be,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,J.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-[calc(0.75rem+var(--pb-safe-bottom))] md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(g(Qr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[_&&(0,J.jsx)(S,{image:_,className:`max-h-full max-w-full select-none object-contain`},_.url),h>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:x(ai,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":Q(`previousPhoto`),"aria-disabled":n===0,onClick:()=>g(-1),children:(0,J.jsx)(pe,{className:`size-5`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:x(ai,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":Q(`nextPhoto`),"aria-disabled":n===h-1,onClick:()=>g(1),children:(0,J.jsx)(A,{className:`size-5`,"aria-hidden":!0})})]})]})]}),y&&d&&u&&(0,J.jsxs)(`aside`,{id:l,"aria-label":o,className:`min-h-dvh w-[360px] shrink-0 border-l border-border bg-background p-5 pt-[calc(1.25rem+var(--pb-safe-top))] text-foreground`,children:[(0,J.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),v]}),(0,J.jsx)(Rt,{title:o,open:y&&d&&!u&&p,onClose:()=>b(!1),children:(0,J.jsx)(`div`,{className:`pt-3`,children:v})})]})},si=(e,t,n)=>{let r=It(t?.layout??[]).flatMap(e=>e.kind===`section`&&rt(e.when,!1)?e.fields:[]);return(r.length>0?[...new Set(r)]:Object.keys(e.fields).filter(t=>t!==e.tenant&&!e.primaryKey.includes(t))).filter(r=>e.fields[r]&&!e.fields[r].sensitive&&!n.includes(r)&&rt(t?.fields[r]?.when,!1))},ci=({model:e,view:t,photoKey:n,fields:r})=>{let i=ye(e.name,n),a=(t?.names?.singular??B(e.name)).toLowerCase();if(i.isPending)return(0,J.jsx)(U,{className:`h-4 w-48`});if(i.error)return(0,J.jsx)(G,{title:Q(`couldNotLoadOne`,{singular:a}),error:i.error});let o=r.filter(e=>Ce(i.data.permissions,e)!==`hidden`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Gn,{rows:o.map(n=>({label:t?.fields[n]?.label??B(n),value:(0,J.jsx)(Lt,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,J.jsx)(k,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:Q(`open`,{singular:a})})]})},li=e=>se(e,{width:0,height:0})!==void 0,ui=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return Ge(n)},di=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!p(t)||!li(t))return[];let i=r&&ui(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!p(e)||!li(e))return i;let a=t=>p(t.file)&&t.file.uri===e.uri,o=i.find(a)?.key;return[{file:e,...o!==void 0&&{key:o}},...i.filter(e=>!a(e))]},fi=P(),pi=(e,t,n)=>{let r=W(),{resources:i}=K(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?E(fi.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Wt({queryKey:L.list(a?.name??``,o,s,500,`gallery`),enabled:a!==void 0,queryFn:async()=>(await r.list(a.name,{filter:o,...s&&{orderBy:s},pageSize:500})).items});return{holder:a,items:di(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},mi={1:[`md:col-span-4 md:row-span-2`],2:[`md:col-span-2 md:row-span-2`,`md:col-span-2 md:row-span-2`],3:[`md:col-span-2 md:row-span-2`,`md:col-span-2`,`md:col-span-2`],5:[`md:col-span-2 md:row-span-2`,``,``,``,``]},hi=({photo:e,large:t})=>{let n=se(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,J.jsx)(S,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},gi=({item:e,record:t,recordKey:n})=>{let{views:r}=K(),i=pi(e,t,n),a=ht(i.holder?.name??``),[o,s]=(0,Y.useState)();if(i.isPending)return(0,J.jsx)(j,{title:e.title,children:(0,J.jsx)(U,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,J.jsx)(j,{title:e.title,children:(0,J.jsx)(G,{title:Q(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=Zr(c),d=i.holder,f=d&&r[d.name],p=d?si(d,f,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],m=d!==void 0&&a.read!==!1&&p.length>0;return(0,J.jsxs)(j,{title:e.title,children:[(0,J.jsx)(`div`,{className:`grid aspect-[4/3] grid-cols-4 grid-rows-2 gap-1.5 overflow-hidden rounded-lg md:aspect-[2/1]`,children:i.items.slice(0,l).map((e,t)=>{let n=t===l-1&&u>0;return(0,J.jsxs)(`button`,{type:`button`,"aria-label":n?Q(`showAll`,{count:c}):Q(`showPhoto`,{index:t+1,count:c}),onClick:()=>s(t),className:x(`group/tile relative overflow-hidden bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,t===0?`col-span-4 row-span-2`:`max-md:hidden`,mi[l][t]),children:[(0,J.jsx)(hi,{photo:e.file,large:t===0}),n&&(0,J.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${u}`}),t===0&&c>1&&(0,J.jsxs)(`span`,{className:`absolute bottom-2 right-2 flex items-center gap-1.5 rounded-full bg-background/85 px-2.5 py-1 text-xs font-medium tabular-nums text-foreground md:hidden`,"aria-hidden":!0,children:[(0,J.jsx)(Mn,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,J.jsx)(oi,{title:e.title,photos:i.items.map(e=>e.file),index:o,onIndex:s,onClose:()=>s(void 0),details:e=>{let t=i.items[e]?.key;return m&&t!==void 0?(0,J.jsx)(ci,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&Q(`holderDetails`,{singular:f?.names?.singular??B(d.name)})})]})},_i=F(`app/history`),vi=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?_i(`databaseRole`,{role:e.databaseRole}):_i(`database`),yi=(e,t,n)=>{let r=(e.operation===`create`?[]:e.changed).flatMap(r=>{let i=t.fields[r];if(!i||r===t.softDelete)return[];let a=n?.fields[r],o=a?.label??B(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:Ke(i,e.before[r],a),after:Ke(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?_i(`changedThis`):_i(e.operation);return{who:vi(e),verb:i,fields:r}},bi=1500,xi=(e,t,n,r)=>{let i=W(),a=Gt({queryKey:L.history(e,t,n),initialPageParam:``,queryFn:({pageParam:r})=>i.history(e,t,{pageSize:n,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0}),{refetch:o}=a;return(0,Y.useEffect)(()=>{let e=setTimeout(()=>void o(),bi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},Si=()=>(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,J.jsx)(U,{className:`h-4 w-full`},t))}),Ci=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=yi(e,t,n),o=Date.parse(e.at);return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,J.jsxs)(`time`,{dateTime:e.at,title:Oe(o),className:`text-muted-foreground`,children:[`· `,yt(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,J.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,J.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},wi=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=xi(t.name,r,e.limit??10,i);return(0,J.jsx)(j,{title:e.title,children:a.isPending?(0,J.jsx)(Si,{}):a.error?(0,J.jsx)(G,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,J.jsx)(Ci,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,J.jsx)(q,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},Ti=({comment:e})=>(0,J.jsx)(Te,{text:e.body,mentions:e.mentions}),Ei=(e,t)=>{let n=W(),r=Ht();return Ut({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:L.comments(e,t)})})},$=F(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,Y.useState)(g),i=W(),a=fe(),o=Ei(e,t),s=(0,Y.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);_e(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:de(n.text,n.picked)},{onSuccess:()=>r(g),onError:e=>a.show({state:`error`,title:$(`couldNotPost`),description:nt(e)})})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(v,{"aria-label":$(`comment`),placeholder:$(`placeholder`),value:n,onChange:r,searchPeople:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,J.jsx)(`div`,{children:(0,J.jsx)(q,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:$(`comment`)})})]})},Oi=20,ki=(e,t)=>{let n=W(),r=Gt({queryKey:L.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:Oi,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},Ai=()=>(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,J.jsx)(U,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,J.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,J.jsx)(b,{initials:he(t)||`?`,hue:ae(e.author.id),size:`md`,className:`ring-0`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,J.jsxs)(`time`,{dateTime:e.createdAt,title:Oe(n),className:`text-muted-foreground`,children:[`· `,yt(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,J.jsx)(Ti,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,J.jsxs)(j,{title:e.title,children:[i.isPending?(0,J.jsx)(Ai,{}):i.error?(0,J.jsx)(G,{title:$(`couldNotLoad`),error:i.error}):(0,J.jsxs)(J.Fragment,{children:[i.hasNextPage&&(0,J.jsx)(q,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:$(`showEarlier`)}),i.items.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:$(`noComments`)}):(0,J.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,J.jsx)(ji,{comment:e},e.id))})]}),r&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(Di,{resource:t,recordKey:n})})]})},Ni=e=>e.kind===`group`||e.kind===`tab`?e.items:e.kind===`custom`?e.fallback??[]:[],Pi=e=>e.kind===`tab`?void 0:e.when,Fi=e=>e.flatMap(e=>[e,...Fi(Ni(e))]).filter(e=>I(Pi(e))),Ii=e=>(e.fallback??[]).map((t,n)=>[t,e.fallbackAt?.[n]??n]),Li=(e,t,n,r)=>{let i=0,a=e=>{let a=Pi(e);return I(a)?!r&&t[i++]===!0:rt(a,n)},o=e=>e.flatMap(e=>{let t=a(e);if(e.kind===`custom`&&e.fallback){let n=e.fallback.map(e=>o([e])),r=n.flatMap((e,t)=>e.length>0?[t]:[]);return t?[{...e,fallback:n.flat(),fallbackAt:r}]:[]}if(e.kind!==`group`&&e.kind!==`tab`)return t?[e]:[];let n=o(e.items);return t&&n.length>0?[{...e,items:n}]:[]});return o(e)},Ri=(e,t,n,r)=>{let i=r?[]:Fi(e).map(e=>Pi(e));return Li(e,xn(i,t),n,r)},zi=P(),Bi=(e,t)=>{let[n,...r]=e.primaryKey;if(!(!e.tenantAcross||e.tenant===void 0||n===void 0||r.length>0||!e.fields[n]?.filterable))return{filter:E(zi.eq(n,t)),pageSize:1,fields:[n,e.tenant]}},Vi=(e,t,n)=>{let r=t?.[e.tenant];if(r!=null&&String(r)!==n)return String(r)},Hi=(e,t)=>{let n=W(),{session:r,organizations:i}=zt(),a=(0,Y.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,Y.useState)(a?{state:`looking`}:{state:`missing`});return(0,Y.useEffect)(()=>{a&&(async()=>{let[t,i]=await Promise.all([n.list(e.name,a),r.organizations.current()]),o=Vi(e,t.items[0],i.organization?.id);if(o===void 0)return s({state:`missing`});s({state:`switching`}),await r.organizations.switchTo(o),window.location.reload()})().catch(e=>s({state:`failed`,error:e}))},[n,r,e,a]),o},Ui=(e,t,n,r)=>{let i=W(),a=Ht(),o=be(),s=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),c=Kt({queries:s.map(e=>{let o=t[e.relation.resource];return le(a,i,o,n[o.name],String(r[e.name]))})}),l=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,l[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,m(c[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=P(),Gi=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let a=new Set(Ki(r,i).flatMap(e=>e.kind===`thread`?[`${e.resource}.${e.field}`,...e.calls?[`${e.calls.resource}.${e.calls.field}`]:[]]:e.kind===`related`&&!e.through&&!e.from?[`${e.resource}.${e.field}`]:[])),o=Object.values(t).flatMap(t=>Object.values(t.fields).filter(t=>t.type===`relation`&&t.relation?.resource===e.name&&t.relation.columns.length===1&&t.filterable).filter(e=>e.name!==t.tenant&&!a.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return o.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??B(e.name),a=o.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:a?`${i} (${r?.fields[t]?.label??B(t)})`:i}})},Ki=(e,t)=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Ki(e.items,t):e.kind===`custom`&&!t(e.component)?[e,...Ki(e.fallback??[],t)]:[e]),qi=(e,t)=>({kind:`list`,resource:e.resource,filter:E(Wi.eq(e.field,t))}),Ji=P(),Yi=(e,t,n)=>{let r=W(),i=Kt({queries:e.map(e=>{let i=E(Ji.eq(e.field,n));return{queryKey:L.list(e.resource,i,``,1,`incoming`),queryFn:async()=>{let n=await r.list(e.resource,{filter:i,pageSize:1,count:`exact`,fields:t[e.resource].primaryKey});return{count:n.totalSize??n.totalSizeEstimate,exact:n.totalSize!==void 0}}}})});return e.flatMap((e,t)=>{let n=i[t];return n.error?[]:[{relation:e,count:n.data}]})},Xi=({model:e,recordKey:t,layout:n})=>{let{resources:r,views:i}=K(),{components:a}=Ze(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,J.jsx)(En,{title:H(`relatedRecords`),children:(0,J.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(k,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,J.jsx)(U,{className:`h-4 w-6`}):`${Qe(n.count)}${n.exact?``:`+`}`,(0,J.jsx)(A,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},Zi=({count:e,names:t})=>e===null?null:e===void 0?(0,J.jsx)(U,{className:`inline-block h-5 w-7 rounded-full`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(z,{dot:!1,className:x(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,J.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(a())})}),(0,J.jsx)(`span`,{className:`sr-only`,children:t?V(`headingCount`,{count:e,...t}):V(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&u(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??yn(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??B(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:a,sort:o,fields:s,button:l,empty:u,add:d})=>{let f=c(),{resources:p}=K(),m=o||Ae(r,i),h=Me(r,{filter:a,sort:m,pageSize:2});if(h.isPending)return(0,J.jsx)(j,{title:e,help:t,count:n,children:(0,J.jsx)(U,{className:`h-24 w-full`})});if(h.error)return(0,J.jsx)(j,{title:e,help:t,count:n,children:(0,J.jsx)(G,{title:yn(`couldNotLoad`),error:h.error})});let[g,_]=h.data.items;if(!g){let a=d&&(0,J.jsxs)(k,{to:d,className:Re({size:`sm`}),children:[(0,J.jsx)(Ft,{className:`size-3.5`}),yn(`add`,{singular:ea(r,i)})]});return(0,J.jsx)(j,{title:e,help:t,count:n,actions:a,children:(0,J.jsx)($i,{empty:u})})}let v=it(r,g),y=ea(r,i),b=i?.names?.plural??B(r.name),x=s.length>1,S=s.map(e=>(0,J.jsx)(_n,{scope:v,path:e,labelled:x},e)),C=(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l&&(0,J.jsx)(ln,{button:l,model:r,view:i,record:g,models:p}),(0,J.jsx)(k,{to:{kind:`record`,resource:r.name,key:At(r,g)},className:Re({size:`sm`}),children:yn(`open`,{singular:y})})]});return(0,J.jsx)(j,{title:e,help:t,count:n,actions:C,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[x?(0,J.jsx)(`dl`,{className:`flex flex-col gap-4`,children:S}):S,_&&(0,J.jsxs)(k,{to:rn(r,i,f,{filter:a,orderBy:m,display:on(i,f,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[tn(`viewAll`),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:b.toLowerCase()}),(0,J.jsx)(Xt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=P(),ra=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},ia=(e,t,n)=>{let{through:r}=e;if(t===null)return null;if(!r)return ra(E(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=De(ra(E(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(E(na.related(e.field,r.resource,i,a.ast)),e.filter)},aa=e=>{if(e.some(e=>e===null))return null;if(!e.some(e=>e===void 0))return e.reduce((e,t)=>e+t,0)},oa=(e,t=!0)=>{let n=W(),{resources:r}=K(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Kt({queries:i.map(({model:e,match:r})=>({...St(n,e,r??``),enabled:t&&r!==null}))});return aa(i.map(({match:e},t)=>{if(e===null)return 0;let n=a[t];return n.isError?null:n.isSuccess?n.data??null:void 0}))},sa=P(),ca=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??H(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=K(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=gn(s,`related:${n}:${e.title}`,e.display),d=ht(e.resource),[f,p]=(0,Y.useState)(!1),m=oa([{item:e,value:t}],!!(e.hideEmpty||e.count));if(!o||e.hideEmpty&&(m===void 0||m===0))return null;let h={title:e.title,help:e.help,count:e.count?(0,J.jsx)(Zi,{count:m,names:s?.names}):void 0},g=sn(e,o,r),_=e.columns??pt(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,J.jsx)(ca,{empty:e.empty}):t(c);if(e.presentation===`cards`||e.presentation===`compact`){let t=e.presentation===`compact`?{time:e.time}:void 0,n=t?_.filter(t=>t!==e.time):_,r=e.tone===void 0||n.includes(e.tone)?n:[e.tone,...n];return(0,J.jsx)(j,{...h,children:v(n=>(0,J.jsx)(Cn,{model:o,view:s,filter:n,sort:e.sort??``,fields:r,actions:e.actions??[],button:e.button,limit:e.limit??10,display:e.display,empty:e.empty,compact:t,tone:e.tone}))})}if(e.presentation===`record`)return c===null?(0,J.jsx)(j,{...h,children:(0,J.jsx)(ca,{empty:e.empty})}):(0,J.jsx)(ta,{...h,model:o,view:s,filter:c,sort:e.sort??``,fields:_,button:e.button,empty:e.empty,add:Qi(e,t,s,a,d)},c);let y=An(e,o,d),b=(0,J.jsx)(cn,{view:s,value:l,onChange:u}),x=y?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,J.jsx)(hn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,J.jsx)(j,{...h,actions:x,children:(0,J.jsx)(pn,{model:o,view:s,field:y,filter:E(sa.eq(e.field,t)),columns:_})}):(0,J.jsx)(j,{...h,actions:x,children:v(t=>(0,J.jsx)(nn,{model:o,view:s,filter:t,sort:e.sort??``,columns:_,limit:e.limit??10,display:l,empty:e.empty,opens:g,button:e.button},t))})},ua=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:en(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=K(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,J.jsx)(Zi,{count:t,names:a})},fa=(e,t,n,r,i)=>{let a=e.fields.status?.type===`enum`&&!r.includes(`status`)?`status`:void 0,o=t?.titleBadge??a;if(o===void 0||!e.fields[o]||!i(o))return;let s=n[o];if(s!=null&&s!==``)return o},pa=P(),ma=(e,t)=>E(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=K(),[r]=xn(e.working===void 0?[]:[e.working],t),i=n[e.resource];if(!i)return null;let a=e.calls&&n[e.calls.resource],o=e.calls&&a&&{model:a,filter:ma(e.calls.field,t.key),fields:e.calls};return(0,J.jsx)(j,{title:e.title,help:e.help,children:(0,J.jsx)(Sn,{children:(0,J.jsx)(vn,{model:i,filter:ma(e.field,t.key),sender:e.sender,time:e.time,text:e.text,status:e.status,calls:o,limit:e.limit,empty:e.empty,working:e.working===void 0?void 0:r===!0})})})},ga=({item:e,scope:t})=>{let n=e.tree,r=e.reads;return(0,J.jsx)(mt,{value:t,children:(0,J.jsxs)(He,{tree:n,plan:r,children:[(0,J.jsx)(On,{tree:n,plan:r}),(0,J.jsx)(wn,{node:n,at:``})]})})},_a=y(()=>Vt(()=>import(`./record-lines-CDTPiIdF.js`).then(e=>e.RecordLines),__vite__mapDeps([12,1,2,4,5,6,13,14,15,16,17,18,19,20,21,22,23,24,25])),()=>(0,J.jsx)(U,{className:`h-32 w-full rounded-lg`})),va=y(()=>Vt(()=>import(`./composer-section-6TvE0L2w.js`).then(e=>e.ComposerSection),__vite__mapDeps([26,1,2,4,5,6,27,13,14,15,16,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34])),()=>(0,J.jsx)(U,{className:`h-24 w-full rounded-lg`})),ya=(e,t)=>t===e.tenant||e.primaryKey.includes(t),ba=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!ya(e,t.name)&&!t.writeOnly),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:H(`details`),fields:a},...e.history?[{kind:`history`,title:H(`history`)}]:[],...e.comments?[{kind:`comments`,title:H(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=K(),{address:i}=xe(),a=Ze(),o=n[e],s=O(e,t);if(!o)return(0,J.jsx)(xt,{title:bt(`notFound`),children:bt(`noResource`,{name:e})});if(s.isPending)return(0,J.jsx)(me,{});if(s.error)return(0,J.jsx)(`div`,{className:`p-8`,children:D(s.error)&&s.error.status===404?(0,J.jsx)(Sa,{model:o,recordKey:t}):(0,J.jsx)(G,{title:H(`couldNotLoad`),error:s.error})});let c=(0,J.jsx)(Ca,{model:o,recordKey:t,stored:s.data,preview:s.isPlaceholderData},s.isPlaceholderData?`preview`:`loaded`),l=i?.kind===`record`&&i.file!==void 0&&!s.isPlaceholderData?Mt(a,o,s.data.record,i.file):void 0,u={kind:`record`,resource:e,key:t,...(r[e]?.recordOpens!==void 0||r[e]?.record!==void 0)&&{standard:!0}};if(l)return(0,J.jsx)(Fe,{model:o,record:s.data.record,viewed:l,back:u},l.file.uri);let d=i?.kind===`record`&&i.standard===!0,f=r[e]?.recordOpens;if(f&&!d){if(s.isPlaceholderData)return(0,J.jsx)(me,{});let e=w(f,s.data.record);if(e)return(0,J.jsx)(kn,{to:e})}let p=r[e]?.record;if(!p||d)return c;if(s.isPlaceholderData)return(0,J.jsx)(me,{});if(`surface`in p||p.focus)return(0,J.jsx)(br,{model:o,recordKey:t,stored:s.data,page:p,standard:c});let{record:m,etag:h,permissions:g}=s.data;return(0,J.jsx)(tr,{component:p.component,scope:{model:o,record:m,key:t,etag:h,permissions:g},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,J.jsx)(me,{}):n.state===`switching`?(0,J.jsx)(xt,{title:H(`loading`),children:H(`openingElsewhere`)}):n.state===`failed`?(0,J.jsx)(G,{title:H(`couldNotLoad`),error:n.error}):(0,J.jsx)(xt,{title:bt(`notFound`),children:H(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=K(),{address:a,go:c}=xe(),l=i.views[e.name],u=be()(e,l,n.record,t),{state:f}=zt(),p=Xr(e,t),m=pr({model:e,stored:n,recordKey:t,mode:l?.saveFeedback??`toast`,subject:u,draftKey:!r&&f.kind===`signed-in`?rr(f.user.id,e.name,t):void 0,lines:p.draft}),h=Ht(),g=W(),v=ke(m.rejections),y=ht(e.name),b=mn(e),S=a?.kind===`record`&&a.version!==void 0,C=Et(y,`update`)&&n.permissions?.update!==!1&&!S,{shown:w,offersEdit:te,editing:T}=dt(l?.recordMode,C,a?.kind===`record`&&a.edit===!0);_e(m.dirty&&w===`form`||m.saving),qe(m.dirty);let E=a?.kind===`record`?a.open:void 0,D=a?.kind===`record`&&a.edit===!0,O=a?.kind===`record`?a.tab:void 0,ne=a?.kind===`record`&&a.standard===!0,A=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...ne&&{standard:ne}}),ae=A(E,!1,O),oe=A(E,!0,O),se=w===`form`&&l?.recordMode!==void 0&&l.recordMode!==`edit`,ce=Et(y,`delete`)&&n.permissions?.delete!==!1,le=fn({model:e,view:l,restore:b,onDeleted:()=>c({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void h.invalidateQueries({queryKey:L.record(e.name,t)})}),ue=Ui(e,i.resources,i.views,n.record),de=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},fe=Object.values(e.fields).filter(e=>de(e.name)),pe={...n.record,...Object.fromEntries(fe.map(e=>[e.name,Tt(e,m.value(e.name))]))},me=Ui(e,i.resources,i.views,pe),he=(e,t)=>{let n=de(e);if(!n||!_t(t))return m.change(e,t);h.setQueryData(L.relatedLabel(n.name,t.key),{label:t.label}),m.change(e,tt(n,t.key))},{fields:ge}=Ze(),M={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ye=Ri(ba(e,l,w===`read`),M,T,r),{before:we,tabs:Te,after:Ee}=Lr(ye),N=Rr(Te,O),P=e=>T&&(m.errors[e]!==void 0||m.conflicts[e]!==void 0);(0,Y.useEffect)(()=>{if(m.rejections===0)return;let e=Br(Te,N,P);e&&c(A(E,D,e===Te[0]?void 0:e.title),{replace:!0})},[m.rejections]);let F=ye.flatMap(e=>e.kind===`sidebar`?e.fields:[]),De=Qn(e,`updated`),I=e=>l?.fields[e],Oe=t=>Ce(n.permissions,t)!==`hidden`&&rt(I(t)?.when,T)&&(w===`form`||!e.fields[t]?.writeOnly),R=e=>!r||Object.hasOwn(n.record,e),z=fa(e,l,n.record,F,Oe),Ae=z&&(0,J.jsxs)(Dt,{value:n.record[z],hints:I(z),children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[I(z)?.label??B(z),`: `]}),Ke(e.fields[z],n.record[z],I(z))]}),Me=r=>{let a=e.fields[r],o=Ce(n.permissions,r);if(!a||o===`hidden`)return null;let s=m.conflicts[r],c=de(r),u=I(r)?.label??B(r),d=m.errors[r],f=w!==`form`||o===`read`;return(0,J.jsx)(ve,{name:r,label:u,required:w===`form`&&o!==`read`&&_(a),help:ze(I(r),l,T),error:d&&Pt(a,u,d),wide:$e(ge,a,I(r)),readOnly:kt(a,I(r),f,!!c),conflict:s===void 0?void 0:{user:{name:H(`someoneElse`),initials:`?`,hue:40},ago:H(`justNow`),theirValue:s||`—`,onKeepMine:()=>m.keepMine(r),onUseTheirs:()=>m.useTheirs(r)},children:R(r)?(0,J.jsx)(Ne,{field:a,hints:I(r),value:m.value(r),stored:n.record[r],relationLabel:me.labels[r],relationTo:me.addresses[r],relationPicker:c&&{target:c,view:i.views[c.name]},locked:f,invalid:!!m.errors[r],reveal:a.sensitive&&!a.writeOnly?()=>g.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:I(r)?.format===`url`?Ye(e,l,r,n.record,ue.labels):void 0,onChange:e=>he(r,e)}):(0,J.jsx)(U,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},Pe=r=>{let i=e.fields[r],a=R(r)?i.sensitive?(0,J.jsx)(Ne,{field:i,hints:I(r),value:``,stored:n.record[r],locked:!0,reveal:()=>g.reveal(e.name,t,r),resource:e.name,onChange:e=>m.change(r,e)}):(0,J.jsx)(Lt,{model:e,field:i,value:n.record[r],relationLabel:ue.labels[r],record:n.record,relationLabels:ue.labels}):(0,J.jsx)(U,{className:`h-4 w-32`});return{label:I(r)?.label??B(r),help:ze(I(r),l,T),wide:$e(ge,i,I(r)),value:a}},Fe=ye.findIndex(e=>e.kind===`sidebar`),Ie=(0,J.jsx)(Dn,{title:H(`summary`),rows:F.flatMap(t=>{let r=e.fields[t];if(!r||!Oe(t))return[];if(!R(t))return[{label:I(t)?.label??B(t),value:(0,J.jsx)(U,{className:`h-4 w-24`})}];let i=n.record[t],a=Se(r,I(t))&&typeof i==`string`&&i!==``,c=r.type===`json`&&i!=null,u=a?d(i):c?wt(i):Ke(r,i,I(t)),f=r.type===`text`&&typeof i==`string`&&i!==``?jt(I(t)):void 0,p=r.type===`enum`?(0,J.jsx)(Dt,{value:i,hints:I(t),children:u}):f?(0,J.jsx)(s,{format:f,value:u,label:Ye(e,l,t,n.record,ue.labels)}):(0,J.jsx)(`span`,{title:je(r,i,void 0,I(t)),children:u}),m=ie(ge,r,I(t));return[{label:I(t)?.label??B(t),title:u,value:m?(0,J.jsx)(o,{shown:m,part:`display`,field:r,value:n.record[t],fallback:p}):p}]})}),Le=async()=>{await m.save()&&se&&c(ae,{replace:!0})},V=ce?()=>void le.start({key:t,title:u,etag:n.etag,snapshot:n.record}):void 0,Be=w===`form`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(q,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:m.saving,disabled:!m.dirty&&m.phase!==`saved`,onClick:()=>void Le(),children:[m.phase===`saved`&&(0,J.jsx)(ee,{className:`size-4`}),m.phase===`saved`?H(`saved`):H(`save`)]}),se&&(0,J.jsx)(k,{to:ae,className:x(Re(),`max-md:min-h-11 md:w-full`),onClick:e=>ft(e)&&m.discard(),children:H(`cancel`)}),m.dirty&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:H(`unsavedChanges`)})]}),He=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(He);if(e.length===0)return[];let r=Ir(i,E,P),a=i.collapsed?A(Fr(E,i.title),D,O):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||R(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,J.jsx)(da,{sections:o}):void 0;return[(0,J.jsx)(Un,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!p.model||!p.item||r?[]:[(0,J.jsx)(_a,{lines:{...p,model:p.model,item:p.item},editable:w===`form`,saving:m.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!R(i.from)?[]:[(0,J.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,J.jsx)(kr,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,J.jsx)(Pr,{item:i,recordKey:t},`trend:${a}`)];if(r&&(i.kind===`custom`||i.kind===`map`||i.kind===`gallery`||i.kind===`blocks`))return[];if(i.kind===`custom`)return i.sidebar?[]:[(0,J.jsx)(er,{item:i,scope:M,fallback:i.fallback&&(0,J.jsx)(J.Fragment,{children:Ii(i).flatMap(([e,t])=>He(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,J.jsx)(Cr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,J.jsx)(gi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,J.jsx)(wi,{item:i,model:e,view:l,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,J.jsx)(ha,{item:i,scope:M},`thread:${a}`)];if(i.kind===`blocks`)return[(0,J.jsx)(ga,{item:i,scope:M},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,J.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,J.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:f.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&Oe(t)),s=w===`read`&&i.presentation===`facts`,c=s?Ve(n.record,o):o;return c.length===0?[]:[(0,J.jsx)(j,{title:i.title,help:We(i.helpWhen,l,T)?i.help:void 0,children:s?(0,J.jsx)(Kn,{facts:c.map(e=>({label:Pe(e).label,value:Pe(e).value,icon:re(I(e)?.icon)}))}):w===`read`?(0,J.jsx)(Gn,{rows:c.map(Pe)}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:c.map(Me)})},i.title)]},Ue=(e,t)=>e.kind===`map`?(0,J.jsx)(Cr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,J.jsx)(er,{item:e,scope:M,fallback:e.fallback&&(0,J.jsx)(J.Fragment,{children:Ii(e).map(([e,t])=>Ue(e,t))})},`custom:${t}`):null;return(0,J.jsxs)(`div`,{ref:v,className:`flex flex-1 flex-col`,inert:r,children:[le.dialogs,(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsxs)(`div`,{className:x(l?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,J.jsx)(Vn,{title:u,badge:Ae}),m.message&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(G,{title:H(`notSaved`),error:Error(m.message)})}),m.linesConflict&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(G,{title:H(`linesChanged`),error:Error(H(`linesReloaded`))})}),w!==`form`&&te&&m.dirty&&(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,J.jsx)(`span`,{children:H(`unsavedKept`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(k,{to:oe,className:Re({size:`sm`}),children:H(`continueEditing`)}),(0,J.jsx)(q,{size:`sm`,onClick:m.discard,children:H(`discard`)})]})]}),w===`form`&&m.restored&&(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,J.jsx)(`span`,{children:H(`unsavedRestored`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(q,{size:`sm`,onClick:m.dismissRestored,children:H(`keep`)}),(0,J.jsx)(q,{size:`sm`,onClick:m.discard,children:H(`discard`)})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,J.jsxs)(`div`,{className:`divide-y divide-border`,children:[we.flatMap(He),N&&(0,J.jsx)(Wn,{tabs:Te.map((e,t)=>({title:e.title,to:A(E,D,t===0?void 0:e.title),current:e===N}))}),N&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:N.items.flatMap(He)},`tab:${N.title}`),Ee.flatMap(He)]}),(0,J.jsxs)(`aside`,{className:`space-y-4 md:sticky md:top-[var(--pb-sticky-top,0px)] md:max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px))] md:self-start md:overflow-y-auto md:pb-4 md:pt-8`,children:[Be&&(0,J.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Be}),!r&&(0,J.jsx)(cr,{model:e,stored:n,recordKey:t,edit:te?oe:void 0,onDelete:V}),Fe===-1&&Ie,ye.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ue(e,t):t===Fe?(0,J.jsx)(Y.Fragment,{children:Ie},`summary`):null),(0,J.jsx)(Dn,{title:H(`details`),rows:[Qn(e,`created`),De].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!Oe(t)||F.includes(t)?[]:[{label:I(t)?.label??B(t),value:R(t)?(0,J.jsx)(`span`,{title:je(r,n.record[t],void 0,I(t)),children:Ke(r,n.record[t],I(t))}):(0,J.jsx)(U,{className:`h-4 w-24`})}]})}),!r&&(0,J.jsx)(Xi,{model:e,recordKey:t,layout:ye})]})]})]})}),Be&&(0,J.jsx)(`div`,{className:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20 flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden`,children:Be})]})};export{xa as RecordPage,Xn as t};
|
|
3
|
-
//# debugId=c65874d4-7432-4e8c-92f4-eca468844045
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-_7poAZsr.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B94YfKGx.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.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,$n as a,$o as o,$s as s,$t as c,As as l,At as u,B as d,Bo as f,Bs as p,C as m,Cc as h,Cn as g,Cs as _,D as v,Dl as y,Do as b,Ec as x,En as S,Es as C,F as w,Fa as T,Fl as E,Fn as ee,Fs as te,Ga as ne,Go as D,Gt as re,Hc as O,Hl as ie,Hs as ae,Ic as oe,In as se,Is as ce,Ji as le,Jn as ue,Jo as k,Jt as de,Ka as fe,Ko as A,Ln as pe,Lr as me,Ls as he,M as ge,Mt as _e,Nc as ve,Nt as ye,Ol as be,Os as xe,Pa as Se,Pl as Ce,Pn as we,Pr as Te,Ps as Ee,Pt as De,Qn as Oe,Qo as ke,Qs as Ae,R as je,Ri as Me,Rn as Ne,Rr as Pe,Rs as Fe,Si as Ie,Ss as j,Ts as Le,Ua as Re,Un as ze,Uo as Be,Us as Ve,V as He,Vc as M,Vr as Ue,Vs as We,Wa as N,Wo as Ge,Xc as Ke,Xo as qe,Xt as Je,Yc as Ye,Yi as Xe,Yn as Ze,Yo as P,Ys as Qe,Zi as $e,Zo as F,Zs as et,_ as tt,_a as nt,_n as rt,_t as it,ac as I,al as at,ao as ot,as as st,at as ct,b as lt,ba as ut,bi as dt,bs as ft,ca as pt,cc as mt,cl as ht,cn as gt,cr as L,dr as _t,ec as vt,es as yt,fl as bt,fo as xt,fr as R,ga as St,gi as Ct,gn as wt,gt as Tt,ha as Et,hn as Dt,i as Ot,ic as z,in as B,ir as kt,ja as At,js as jt,jt as Mt,k as Nt,ki as Pt,ks as Ft,lc as It,ln as Lt,lr as Rt,ls as zt,ma as Bt,ml as Vt,mn as Ht,mr as V,na as Ut,nc as Wt,nn as Gt,no as Kt,nr as qt,ns as H,on as Jt,or as Yt,os as Xt,pn as Zt,pr as U,qo as Qt,rl as $t,rn as en,ro as tn,rs as nn,s as rn,sc as W,sl as an,sn as on,sr as G,ta as sn,tn as cn,tr as ln,un,ur as dn,v as fn,vn as pn,vs as K,wa as mn,wn as hn,ws as gn,wt as _n,xa as vn,xs as yn,y as bn,yc as xn,yn as Sn,ys as q,zo as Cn,zs as wn}from"./app-B94YfKGx.js";import{C as Tn,f as En,o as Dn,s as On}from"./vendor-t7Q7QbPu.js";import{C as kn,Ct as An,Dt as jn,Et as Mn,Mt as Nn,O as Pn,Ot as Fn,Q as In,St as Ln,Tt as Rn,X as zn,Z as Bn,_t as Vn,at as Hn,b as Un,ct as Wn,dt as Gn,ft as Kn,gt as qn,it as Jn,k as Yn,kt as Xn,l as Zn,lt as Qn,mt as $n,n as er,nt as tr,o as nr,ot as rr,rt as ir,st as ar,t as or,tt as sr,ut as cr,wt as lr,x as ur,xt as dr,y as fr}from"./embedded-list-OJQKeuBN.js";import{t as pr}from"./circle-alert-C8YjGdRx.js";import{t as mr}from"./page-header-Ddz2r5ic.js";import{n as hr,t as gr}from"./pending-invitation-row-BZVOux9W.js";import{n as _r,t as vr}from"./person-row-DgXLW9D8.js";import{n as yr,t as br}from"./use-paged-search-DRj8498k.js";import{n as xr,t as Sr}from"./client-publisher-D39SlIhp.js";import{t as Cr}from"./copy-field-DXp0fGDR.js";var wr={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`}]]};wr.node;var Tr=M(wr),Er={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`}]]};Er.node;var Dr=M(Er),Or={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`}]]};Or.node;var kr=M(Or),Ar={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`}]]};Ar.node;var jr=M(Ar),Mr={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`]};Mr.node;var Nr=M(Mr),Pr={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`}]]};Pr.node;var Fr=M(Pr),Ir={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`}]]};Ir.node;var Lr=M(Ir),Rr={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`}]]};Rr.node;var zr=M(Rr),Br=[`done`,`error`,`running`];ae(`TextField`,!1),ae(`NumberField`,!1),ae(`DateField`,!1),ae(`BooleanField`,!1),ae(`UrlField`,!1),ae(`ChipField`,!1);var Vr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Hr=e=>typeof e!=`string`&&!e.custom&&Vr.has(e.type),Ur=e=>typeof e==`string`||Hr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Wr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Gr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Kr=(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)},qr=(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)},Jr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Yr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Xr=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:Yr.has(`${n.toLowerCase()}:`)?e:void 0},Zr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Qr=e=>e==null||e===``?void 0:String(e),$r=(e,t)=>e<t?-1:+(e>t),ei=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Qr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Qr(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=>Qr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Qr(e[i.source]),s=Qr(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)=>$r(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>$r(e.id,t.id)),edges:s.sort((e,t)=>$r(e.source,t.source)||$r(e.target,t.target)||$r(e.id,t.id))}},J=e(t(),1),Y=e(n(),1),ti=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=H(),s=An(e.name,void 0),c=Me(),[l,u]=(0,J.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=>Ht(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=dr(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>Mn(d)?u(!0):void g(),children:h}),l&&(0,Y.jsx)(Rn,{action:d,label:h,danger:i===`danger`||i===void 0&&jn(d),records:p.map(e=>e.record),names:p.map(t=>Ln(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ni=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=Yt(),c=lr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,J.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{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:()=>Mn(c.action)?u(!0):void c.run(),children:d}),l&&(0,Y.jsx)(Rn,{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)}})]})},ri=({node:e,className:t})=>{let n=B(e),r=_t(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,Y.jsx)(ti,{...n,model:i,items:r.items,className:t}):(0,Y.jsx)(ni,{...n,className:t})},ii=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=B(e);return(0,Y.jsx)(R,{title:i,description:a,actions:n.actions,className:O(`h-full`,r),children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ai=({children:e,wrap:t=(e,t)=>(0,Y.jsx)(J.Fragment,{children:e},t)})=>{let n=_t();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...Ht(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,Y.jsx)(qt,{value:s,row:{index:o,count:i.length},children:e}),c)})},oi=({children:e})=>(0,Y.jsx)(ai,{children:e}),si=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=cn(t),f=rt(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,Y.jsx)(R,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,Y.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-24 w-56`},t))}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):m.length===0?(0,Y.jsx)(U,{children:s??N(`nothingYet`)}):(0,Y.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,Y.jsx)(Rt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,Y.jsx)(ai,{wrap:(e,t)=>(0,Y.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:l})})})})},ci=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=B(e),o=H().resources[i];return o?(0,Y.jsx)(si,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},li=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=B(e),{resources:u,views:d}=H(),f=u[r];return f?(0,Y.jsx)(R,{title:i,description:a,actions:t.actions,className:O(`h-full`,n),children:(0,Y.jsx)(Kn,{model:f,view:d[r],...l})}):null},ui=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=wt(e,t),a=i.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):i.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:i.error}):i.data?(0,Y.jsx)(qt,{value:i.data,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,Y.jsx)(U,{children:N(`nothingYet`)});return(0,Y.jsx)(`div`,{className:n,children:a})},di=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},fi=e=>e==null?``:String(e),X=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=di(i[t.start]);if(e===void 0)continue;let a=di(i[t.end]),o=Math.max(e,a??n),s=r.get(fi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(fi(i[t.lane]),s);let c=s.bars.get(fi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(fi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=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},hi=(e,t,n)=>{let r=pi(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:X(n,a,s),width:X(r,a,s)-X(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:X(o,a,s),width:X(c,a,s)-X(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:X(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,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:X(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:fi(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(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},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:pt(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,Y.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,Y.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?$e(e.at+i(e.at)):Ut(e.at,r)},e.at))})},Oi=(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&&Vt(a)?{className:ke[a],striped:i}:{color:qn(e,t,n===void 0?null:n,-1),striped:i}},ki=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)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?le(e):Xe(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return N(`timelineRange`,{from:ji(n,a),to:i?N(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${Ct(t.fields[r.color],e.value,n?.fields[r.color])}: ${Mi(t,r,e.start,e.end,e.open)}`,Pi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??Ct(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Mi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Ni(e,t,n,r))].join(`; `)},Fi=`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`,Ii=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=H().resources[t.fields[r.bar]?.relation?.resource??``],s=S(o??t,e.key,o!==void 0),c=Pi(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,Y.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,Y.jsx)(Wt,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:O(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,Y.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,Y.jsx)(Sn,{model:n,field:i,value:e.value})}),(0,Y.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,Y.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,Y.jsx)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ri,{...t,value:e}),Ct(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:N(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:(0,Y.jsx)(Sn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(Ri,{...t,value:e.value}),Ct(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Mi(n,i,e.start,e.end,e.open)]},a))})]})},Vi=500,Hi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...Ye.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(Vi,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}}}),Ui=(e,{enabled:t=!0,...n})=>Dn({...Hi(zt(),e,n),enabled:t,placeholderData:En}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=he,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=cn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),S=b??x,C=b?b.rows:x.data?.rows??[],w=!b&&x.data?.cut===!0,T=hi(C,n,Date.now());return(0,Y.jsxs)(R,{title:s,description:c,actions:u,className:O(`h-full`,d),children:[(()=>{if(S.isPending)return(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(z,{className:`h-6`},t))});if(S.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:S.error});if(T.lanes.length===0)return(0,Y.jsx)(U,{children:l??N(`nothingYet`)});let r=new Set(C.map(e=>String(e[n.color])));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,Y.jsx)(Li,{shape:T,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),w&&(0,Y.jsx)(U,{children:N(`timelineCut`,{count:C.length})}),(0,Y.jsx)(`div`,{"aria-live":`polite`,children:(0,Y.jsx)(Bi,{bar:wi(T,m)??wi(T,g),model:e,view:t,fields:n})})]})})(),p]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=a(),o=r[e],s=t=>i({[e]:t}),c=n.model.fields[n.fields.bar],l=o===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{filter:Vn(c,Gi(c,o),n.filter),sort:n.sort},children:t},o)});return(0,Y.jsx)(Wi,{...n,choose:{barTo:s,chosen:o},details:l})},qi=({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}=B(e),{resources:h,views:g}=H(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Fe(e),sort:wn(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,Y.jsx)(Wi,{...v}):(0,Y.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=We(e),r=ln(),{resources:i}=H();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,Y.jsx)(vt,{name:n.param,children:(0,Y.jsx)(ui,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,J.lazy)(()=>Tn(()=>import(`./graph-view-_7poAZsr.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]))),Xi=(0,Y.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,Y.jsx)(It,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=B(e),o=c(e,t),s=ln(),l=o.nodes,u=o.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,J.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([l?.rows,u?.rows,g]),v=(0,J.useMemo)(()=>l&&u&&ei({nodes:l.rows,edges:u.rows,key:l.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!l||!u||!v)return null;let y=l.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,Y.jsx)(U,{children:a.empty??N(`nothingYet`)});let b=a.select,x=b!==void 0&&s?{chosen:s.given[b],linkTo:e=>s.linkTo({[b]:e})}:void 0;return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(J.Suspense,{fallback:Xi,children:(0,Y.jsx)(Yi,{shape:v,nodes:l,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,Y.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,Y.jsx)(Ji,{node:e,children:r})})]})},Q=Ke(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=H(),a=zt(),o=pn(),s=nn(e),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)();return!i[e]||!mn(s,`create`)?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,Y.jsx)(V,{title:Q(`notSent`),error:u}),(0,Y.jsx)(_n,{onSend:async r=>{l(!0),d(void 0);let i=await a.create(e,{...n,[t]:r}).then(()=>!0,e=>(d(e),!1));return l(!1),i&&o(e),i},busy:c,placeholder:r})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=B(e);return(0,Y.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=B(e);return(0,Y.jsx)(`details`,{open:r,className:O(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,Y.jsx)(`summary`,{className:O(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=B(e),i=Lt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,Y.jsx)(z,{className:O(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,Y.jsx)(`p`,{className:O(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=Tt(a);return o?(0,Y.jsx)(`div`,{className:O(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,Y.jsx)(it,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,Y.jsx)(`pre`,{className:O(`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})},ra=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),ia=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>ht(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=B(e),{views:a}=H(),o=Lt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,Y.jsx)(Sn,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,Y.jsx)(`div`,{className:t,children:s});let c=r??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={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`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=B(e),i=e.children,a=i.length>0&&i.every(la);return(0,Y.jsx)(`div`,{className:O(`grid grid-cols-1 gap-4`,a?sa[r]:oa[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,Y.jsx)(`div`,{className:O(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,Y.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),fa=({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}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=e=>{let[t,n]=(0,J.useState)();return(0,J.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},ga=e=>{let[t,n]=(0,J.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=zt(),{theme:s}=T(),[c,l]=ct(),u=fa({width:n,height:r,space:l,theme:s}),d=Dn({queryKey:Ye.image(e,u??{}),enabled:u!==void 0,placeholderData:En,...pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=ha(d.data),[p,m]=ga(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,Y.jsx)(`div`,{ref:c,className:O(`min-w-0`,a),children:d.isError||p?t&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,Y.jsx)(`img`,{src:f,alt:t??``,onError:m,style:h,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,Y.jsx)(z,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=B(e);return n.src===void 0?(0,Y.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,Y.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=B(t),{views:i}=H(),a=Lt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,Y.jsx)(z,{className:`inline-block h-3 w-16 align-middle`}):Wr(t.type,a.value)?r.emptyText?(0,Y.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?an(e,n?.valueLabels):Gr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Kr(e,t,i())})),Ca=ya(({value:e,props:t})=>{let n=qr(e,t,{locale:i(),now:Date.now(),relative:sn});return(0,Y.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=Jr(e,t,{yes:Pt(`yes`),no:Pt(`no`)});return e?(0,Y.jsx)(ze,{label:n,className:`align-middle`}):(0,Y.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Xr(n);return i===void 0?r:(0,Y.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),Ea=ya(e=>(0,Y.jsx)(hn,{value:e.value,hints:e.hints,children:ba(e)})),Da=`font-medium text-primary-text hover:underline`,Oa=({node:e,children:t,className:n})=>{let r=B(e),i={...L(G()),params:Oe()},a=r.variant?O(mt({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=Ce(r.to,Le(i));return(0,Y.jsx)(me,{to:e,className:a,children:o??Qe(e)})}let s=r.href??``;return(0,Y.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},ka=(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]:v(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:v(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return rn(r)?r.key===v(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:m(i,r,n[t])?[[t,Nt(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=H(),u=zt(),d=Se(),f=pn(),p=l[e.name],[m,h]=(0,J.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,J.useState)({}),[v,y]=(0,J.useState)(0),b=tt(v),[x,S]=(0,J.useState)(),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(!1);Ae(T||C,`input-lost`);let ee=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Ot(e,c,m),...o}):u.update(e.name,t.key,Aa(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:N(`saved`,{label:i??r})}),s()},e=>{let t=fn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,Y.jsx)(I,{title:i??r,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:N(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:C,onClick:()=>void ee(),children:N(n===`create`?`create`:`save`)})]}),children:(0,Y.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ee()},children:[x!==void 0&&Object.keys(g).length===0&&(0,Y.jsx)(V,{title:N(`notSaved`),error:x}),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??ht(n),s=g[n];return(0,Y.jsx)(je,{name:n,label:o,help:p?.fields[n]?.help,error:s&&bn(r,o,s),children:(0,Y.jsx)(lt,{field:r,hints:p?.fields[n],value:rn(i)?i.key:i,stored:t?.record[n],relationLabel:rn(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),E(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=wt(e,{key:t});return(0,Y.jsx)(Y.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=B(e),n=Yt(),{resources:r}=H(),i=r[t.resource??n?.model.name??``],a=nn(i?.name??``),[o,s]=(0,J.useState)(!1);if(!i||!(t.mode===`create`?mn(a,`create`):mn(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,Y.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,Y.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=B(e);return(0,Y.jsx)(`div`,{className:O(`flex-1`,r),children:(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(mr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=G(),r=typeof e==`string`?kt(n,e):void 0,i=on(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},Ia=({node:e,className:t})=>{let{value:n,max:r,label:a}=B(e),o=Fa(n,0),s=Fa(r,100);if(o===void 0||s===void 0)return(0,Y.jsx)(z,{className:`h-6 w-full`});if(!Number.isFinite(o)||!Number.isFinite(s))return null;let c=s>0?Math.min(1,Math.max(0,o/s)):0;return(0,Y.jsxs)(`div`,{className:O(`min-w-0`,t),children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[o.toLocaleString(i()),` / `,s.toLocaleString(i())]})]}),(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":a,"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":s,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:c>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${c*100}%`}})})]})},La=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=cn(t),f=wt(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Zt(e,d):f,m=e=>p.data?(0,Y.jsx)(qt,{value:p.data,children:e}):void 0,h=p.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]}):p.error?(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:p.error}):p.data?m((0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,Y.jsx)(U,{children:s??N(`nothingYet`)});return(0,Y.jsx)(R,{title:a,description:o,actions:c?m(c):void 0,className:O(`h-full`,u),children:h})},Ra=({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}=B(e),f=H().resources[a];return f?(0,Y.jsx)(La,{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},za=Ke(`app/related-cards`),Ba=({children:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1);return(0,J.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,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,Y.jsx)(`div`,{className:O(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,Y.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:za(n?`showLess`:`showMore`)})]})},Va=e=>e==null||e===``,Ha=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=H(),a=on(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,Y.jsx)(z,{className:`h-4 w-24`}):(0,Y.jsx)(Sn,{model:a.model,field:a.field,value:a.value}),s=r?(0,Y.jsx)(Ba,{children:o}):o;if(!n)return(0,Y.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=Me(),{resources:l}=H(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,Y.jsxs)(`li`,{"data-card":e.key,className:O(`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,Y.jsx)(de,{view:t,field:i,record:e.record}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(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,Y.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,Y.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,Y.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,Y.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,Y.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,Y.jsx)(qt,{value:e,children:(0,Y.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,Y.jsx)(sr,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,Y.jsx)(ni,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=Me(),{resources:c}=H(),l=s(e.model,t,e.record,e.key);return(0,Y.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,Y.jsx)(de,{view:t,field:r,record:e.record}),(0,Y.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:vn(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,Y.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,Y.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,Y.jsx)(qt,{value:e,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,Y.jsx)(sr,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,Y.jsx)(ni,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(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)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=e=>{let t=(0,J.useRef)(null),n=(0,J.useRef)({current:e,previous:e}),r=(0,J.useRef)(void 0),[i,a]=(0,J.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(t.current))?.focus()};return(0,J.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}},Xa=({compact:e,limit:t})=>(0,Y.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,Y.jsx)(z,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),Za=({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:p,planned:m})=>{let h=f(),g=cr(),_=t?.names?.plural??ht(e.name),v=r||nt(e,t),y=rt(e,{filter:n,sort:v,pageSize:s,enabled:!m}),b=Dt(e,n,!m),x=m?m.rows:{isPending:y.isPending,error:y.error},S=m?m.rows.rows:y.data?.items,C=m?{data:m.total&&!m.total.isPending&&!m.total.error?tr(m.total):void 0}:b,w=(0,J.useMemo)(()=>(S??[]).map(t=>Ht(e,t)),[e,S]),T=Ya((0,J.useMemo)(()=>w.map(e=>e.key),[w]));return(0,Y.jsxs)(`div`,{ref:T.root,children:[(()=>{if(x.isPending)return(0,Y.jsx)(Xa,{compact:!!d,limit:s});if(x.error)return(0,Y.jsx)(V,{title:za(`couldNotLoad`),error:x.error});if(w.length===0)return(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=w.map(e=>{let n=(t,n)=>T.acted(e.key,t,n);return d?(0,Y.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:p,actions:a,button:o,onActed:n},e.key):(0,Y.jsx)(Wa,{scope:e,view:t,fields:i,tone:p,actions:a,button:o,onActed:n},e.key)}),f=C.data===void 0?void 0:Wn(w.length,C.data,!1);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,Y.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,Y.jsx)(Gn,{scroll:g,label:_,share:u,children:r}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f}),(0,Y.jsxs)(me,{to:rr(e,t,h,{filter:n,orderBy:v,display:ir(t,h,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Qn(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:_.toLowerCase()}),(0,Y.jsx)(Nn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,Y.jsx)(`p`,{role:`status`,className:`sr-only`,children:T.announcement})]})},Qa={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},$a=({node:e,at:t,slots:n,className:r})=>{let i=B(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}=Zr(i),{resources:_,views:v}=H(),[y,b]=Gt([t,t===void 0?void 0:`${t}#total`]),x=(0,J.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let C=v[S.name];return(0,Y.jsx)(`section`,{className:O(`min-w-0`,r),"aria-label":f,children:(0,Y.jsx)(w,{title:f,help:p,actions:n.actions,children:(0,Y.jsx)(Za,{model:S,view:C,filter:o,sort:s,fields:c??$t(S,C),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...x&&{planned:x}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=H(),o=Ue(i,a,e.name),s=Pn(e.name,t.listOf,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,Y.jsx)(V,{title:kn(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,Y.jsx)(z,{className:`h-24`});let l=Yn(o.model,s.data);return l?(0,Y.jsx)(ur,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??kn(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=bt(vn(e,i)),{name:o,chips:s,title:c,body:l}=fr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,Y.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,Y.jsx)(me,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,Y.jsx)(zn,{chips:s})})}),(0,Y.jsx)(ur,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=H(),a=t.searchesOf,o=r[a.resource],s=Un(e.name,!0),c=(t.names?.plural??ht(e.name)).toLowerCase();return o?s.error?(0,Y.jsx)(V,{title:Bn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??Bn(`noneYet`,{plural:c})}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,Y.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},bt(vn(e,n))))}):(0,Y.jsx)(z,{className:`h-40`}):null},ro=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=B(e),{resources:d,views:f}=H(),p=d[r];if(!p)return null;let m=f[p.name];return(0,Y.jsx)(R,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,Y.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,Y.jsx)(ur,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,Y.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=H(),c=nn(e.name),l=zt(),u=Se(),d=pn(),f=s[e.name],[p,h]=(0,J.useState)(i),[g,_]=(0,J.useState)(()=>ka(e,t,i?.record)),[v,y]=(0,J.useState)({}),[b,x]=(0,J.useState)(),[S,C]=(0,J.useState)(!1),w=(0,J.useRef)(Promise.resolve()),T=(0,J.useRef)(i),E=ka(e,t,void 0),ee=p?mn(c,`update`)&&p.permissions?.update!==!1:mn(c,`create`),te=t.filter(t=>!io(e.fields[t])),ne=te.some(t=>p?m(e.fields[t],g[t],p.record[t]):g[t]!==E[t]),D=async t=>{let n=T.current;if(n){let r=await l.update(e.name,n.key,Aa(e,t,n.record),n.etag??`*`);return{...Ht(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Ot(e,o,{...E,...t}));return{...Ht(e,r.record),etag:r.etag}},re=t=>{let r=w.current.then(async()=>{C(!0),x(void 0),await D(t).then(async r=>{T.current=r,h(r),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:N(`saved`,{label:n??N(`settings`)})})},e=>{y(t=>({...t,...fn(e)})),x(e)}),C(!1)});w.current=r},ie=(t,n)=>{_(e=>({...e,[t]:n})),io(e.fields[t])&&re({[t]:n})};return(0,Y.jsx)(R,{title:n,description:r,className:O(`h-full`,a),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ne&&re(Object.fromEntries(te.map(e=>[e,g[e]])))},children:[b!==void 0&&Object.keys(v).length===0&&(0,Y.jsx)(V,{title:N(`notSaved`),error:b}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??ht(t),i=v[t];return(0,Y.jsx)(je,{name:t,label:r,help:f?.fields[t]?.help,error:i&&bn(n,r,i),children:(0,Y.jsx)(lt,{field:n,hints:f?.fields[t],value:g[t],stored:p?.record[t]??E[t],invalid:!!i,locked:!ee||n.readOnly,resource:e.name,onChange:e=>ie(t,e)})},t)}),ee&&ne&&(0,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,size:`sm`,loading:S,children:N(`save`)})})]})})},oo=e=>{let t=wt(e.model,{});return t.isPending?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(z,{className:`h-4 w-1/2`}),(0,Y.jsx)(z,{className:`h-4 w-1/3`})]})}):t.error?(0,Y.jsx)(R,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:t.error})}):(0,Y.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=B(e),o=H().resources[n];return o?(0,Y.jsx)(oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=H(),r=zt(),i=JSON.stringify(e),a=(0,J.useMemo)(()=>JSON.parse(i).map(ce),[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=Ee(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=>kt(t,e)),f=gt(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=On({queries:u.map(e=>un(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 te(e,t)})},uo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,fo=({node:e,children:t,slots:n,className:r})=>{let{when:i}=B(e),[a]=lo([i],G());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:o}):(0,Y.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(gn(e,L(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=G(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(e,n):t[o];return s==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:s}):(0,Y.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=H(),a=cn(t),o=Dt(e,n,!a),s=a??o;if(s.isPending)return(0,Y.jsx)(z,{className:`h-8 w-16`});if(s.error)return(0,Y.jsx)(`span`,{className:`text-danger-text`,children:N(`couldNotCount`)});let c=a?tr(a):o.data;return(0,Y.jsx)(me,{to:$n(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:c.toLocaleString(i())})},vo=({field:e,format:t})=>{let n=Lt(e);return n.state===`loading`?(0,Y.jsx)(z,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,Y.jsx)(`span`,{className:go,children:ra(n.value)}):(0,Y.jsx)(`span`,{className:go,children:(0,Y.jsx)(Sn,{model:n.model,field:n.field,value:n.value,format:t})})},yo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=B(e),{resources:u}=H(),d=a===void 0?void 0:u[a];return(0,Y.jsxs)(R,{className:O(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,Y.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,Y.jsx)(`span`,{className:go,children:i}),d&&(0,Y.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,Y.jsx)(vo,{field:s,format:c})]}),l&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=f(),i=Jn(t),[a,o]=(0,J.useState)(()=>Hn(localStorage,i)),s=(0,J.useCallback)(e=>{o(e),ar(localStorage,i,e)},[i]);return[ir(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:u}=H(),d=u[e.name],{fields:p}=At(),m=mn(nn(e.name),`update`),{go:h,href:g}=Pe(),_=f(),v=!Cn(),y=(0,J.useMemo)(()=>n?.map(Ft)??$t(e,d),[n,e,d]),b=(0,J.useMemo)(()=>Jt(e,d,y,{resources:l,views:u,fieldTypes:p}),[e,d,y,l,u,p]),x=(0,J.useMemo)(()=>_?en(n)(b):b,[_,n,b]),S=(0,J.useMemo)(()=>r?Zn(x,e,d,r,l,v):x,[x,e,d,r,l,v]),C=(0,J.useMemo)(()=>t.map(t=>({...t,id:ut(e,t)})),[t,e]),w=(0,J.useMemo)(()=>({total:C.length,rowAt:e=>C[e]}),[C]),T=nr({model:e,view:d,opens:void 0,resources:l,views:u,canUpdate:m}),E=e=>({href:g(e),onFollow:()=>h(e)});return(0,Y.jsx)(R,{title:i,description:a,actions:s,className:c,children:C.length===0?(0,Y.jsx)(U,{children:o??N(`nothingYet`)}):(0,Y.jsx)(In,{fit:!0,columns:S,source:w,latencyMs:0,onOpenRow:e=>h(T.address(e)),rowLink:e=>E(T.address(e)),rowActions:T.actions(E),rowNumbers:!1,selectable:!1})})},So=e=>{let t=_t();return t?.model?(0,Y.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({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,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?y:g,b=(0,J.useMemo)(()=>i?.map(Ft),[i]),x=(0,J.useMemo)(()=>en(i),[i]);return(0,Y.jsxs)(R,{title:l,description:u,actions:(0,Y.jsxs)(Y.Fragment,{children:[!m&&(0,Y.jsx)(or,{view:t,value:v,onChange:_}),f]}),className:O(`h-full`,p),children:[(0,Y.jsx)(er,{model:e,view:t,filter:n,sort:r,columns:b,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:x,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},wo=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=B(e),{resources:u,views:d}=H(),[f,p]=Gt([t,t===void 0?void 0:`${t}#total`]),m=(0,J.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,Y.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,Y.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,Y.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=a(),o=t=>i({[e]:t}),s=r[e],c=s===void 0?null:(0,Y.jsx)(vt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{key:s},children:t},s)});return(0,Y.jsx)(Co,{...n,chosen:{rowTo:o,key:s,details:c}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=St(),{navigate:a}=s(),o=Et(e),c=Bt(o,r),l=e=>i(e===o[0]?.name?void 0:e);return(0,Y.jsxs)(`div`,{className:O(`flex flex-col gap-6`,n),children:[(0,Y.jsxs)(`select`,{"aria-label":N(`tabs`),value:c?.name??``,onChange:e=>a(l(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!c&&(0,Y.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,Y.jsx)(`nav`,{"aria-label":N(`tabs`),className:`hidden border-b md:block`,children:(0,Y.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(et,{to:l(e.name),"aria-current":e===c?`page`:void 0,className:O(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===c?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),c?(0,Y.jsx)(J.Fragment,{children:t[o.indexOf(c)]},c.name):(0,Y.jsx)(ne,{children:N(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(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&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=an(e,t?.valueLabels);return n===`done`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(It,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&dt(t?.valueColors,e)!==`red`?r:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,Y.jsx)(pr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?we(e):e;return t===ee?(0,Y.jsx)(pe,{children:String(e)}):(0,Y.jsx)(se,{value:t})},Mo=({label:e,children:t})=>(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,J.useState)(!1),i=(0,J.useId)(),a=e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,Y.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,Y.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,Y.jsxs)(W,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,Y.jsx)(ve,{"aria-hidden":!0,className:O(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,Y.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callInput`),children:(0,Y.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callResult`),children:(0,Y.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callError`),children:(0,Y.jsx)(pe,{children:e.error})})]})]})},Po=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),Fo=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}}},Io=(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&&De(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:ye(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:Fo(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},Lo=e=>Br.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(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:Ro(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}}},Vo=({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}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,J.useState)(!1),s=Te(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,J.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=H(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&p(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(vn(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}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:l,planned:d})=>{let{resources:f,views:m}=H(),h=ft(),_=h?.state.kind===`signed-in`?h.state.user.id:void 0,v=n===void 0?[]:[n],y=ue(f,m,e,v),b=Ho(e.name,{filter:t,orderBy:p(r),pageSize:o,labels:y},d?.messages),x=Uo(l,o,d?.calls),S=Wo(b);if(S===`error`)return(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)});if(S===`loading`)return(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(U,{children:Q(`loadingMessages`)})});let C=Ze(f,e,v,b.items,b.labels),w=ko({items:x.calls,more:x.hasNextPage},{items:Po(C,r),more:b.hasNextPage}),T=Io(w,{key:t=>String(vn(e,t)),sender:n,time:r,text:i,status:a}),E=a===void 0?void 0:m[e.name]?.fields[a],ee=e.fields[i]!==void 0&&Ie(e.fields[i],m[e.name]?.fields[i]),te=T.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===_);return(0,Y.jsxs)(Y.Fragment,{children:[Ko(b)&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoad`),error:b.error,onRetry:qo(b)})}),l&&x.list.error&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(V,{title:Q(`couldNotLoadCalls`),error:x.list.error,onRetry:qo(x.list)})}),(0,Y.jsx)(u,{length:w.length,followKey:te?.key,working:c,empty:Go(x.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:b.hasNextPage||x.hasNextPage?()=>Jo([b,x.list]):void 0,loadingEarlier:b.isFetchingNextPage||x.isFetchingNextPage,children:T.map(e=>e.kind===`day`?(0,Y.jsx)(_e,{label:e.label},e.key):e.kind===`call`?(0,Y.jsx)(No,{call:e,statusHints:x.statusHints},e.key):(0,Y.jsx)(Mt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:E}),children:ee&&e.text!==``?(0,Y.jsx)(g,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,Y.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({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}=B(e),{resources:g}=H(),[_]=lo(f===void 0?[]:[f],G()),[v,y]=Gt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,Y.jsx)(`section`,{className:O(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,Y.jsx)(w,{title:i,help:a,actions:n.actions,children:(0,Y.jsx)(Xo,{children:(0,Y.jsx)(Yo,{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}}})})})})},Qo=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex`,t),children:e}),es=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:O(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=B(e);return(0,Y.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=B(e),r=C(L(G()),n),i=(0,J.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,Y.jsx)(Rt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:o}=B(e),{values:s,linkTo:c}=a(),l=s[n];return(0,Y.jsxs)(`div`,{className:O(`flex flex-wrap items-center gap-2`,t),children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,Y.jsx)(d,{label:i,value:l??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:o!==void 0&&e===String(o)?void 0:e})}):(0,Y.jsx)(`span`,{children:l})]})},is=({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}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,J.useState)(!1),c=Te(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,J.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),is({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}})},os=({node:e,at:t,children:n})=>{let r=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...jt(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,Y.jsx)(dn,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=B(e),i=H().resources[r.reference],a=Le(L(G())),o=cn(t);return i?(0,Y.jsx)(ss,{model:i,...l(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},ls=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=H(),s=cn(t),c=wt(e,{key:n,enabled:!s}),l=s?Zt(e,s):c;if(l.isPending)return(0,Y.jsx)(z,{className:`h-4 w-24`});if(l.error)return(0,Y.jsx)(V,{title:N(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,Y.jsx)(qt,{value:l.data,children:i}):at(e,o[e.name],l.data.record,n);return r===!1?(0,Y.jsx)(`span`,{className:a,children:u}):(0,Y.jsx)(me,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:u})},us=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=B(e),c=H().resources[i],l=C(L(G()),a);return c?l==null||l===``?s===void 0?null:(0,Y.jsx)(`span`,{className:r,children:s}):(0,Y.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>r(e,t)).join(`, `),$=Ke(`users`),fs=({roles:e})=>{let{session:t}=q(),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)([]),o=(0,J.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,J.useEffect)(o,[o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(hr,{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,Y.jsx)(_r,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,Y.jsx)(k,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,Y.jsx)(gr,{email:n.email,gives:ds(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}=q(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)([]),{busy:d,error:f,run:p}=fe(),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,Y.jsxs)(k,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,Y.jsx)(P,{message:f}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Y.jsx)(b,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,Y.jsx)(b,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,Y.jsx)(b,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,Y.jsx)(_r,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(W,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=q(),[i,a]=(0,J.useState)(e),{busy:o,error:s,run:c,setError:l}=fe(),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,Y.jsx)(vr,{name:i.name,email:i.email,self:n,error:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[i.blocked&&(0,Y.jsx)(F,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,Y.jsx)(W,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,Y.jsx)(W,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,Y.jsx)(_r,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=q(),[i,a]=(0,J.useState)(``),o=(0,J.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=br(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,Y.jsx)(yr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,Y.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=q(),[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)();return(0,J.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof j?o(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,J.useState)(0);return(0,Y.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,Y.jsx)(P,{message:t}),(0,Y.jsx)(hs,{roles:e,version:n}),(0,Y.jsx)(fs,{roles:e}),(0,Y.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,J.useState)(e?.address??``),[s,c]=(0,J.useState)(e?.name??``),[l,u]=(0,J.useState)(e?.signature??``),[d,f]=(0,J.useState)(e?.isDefault??!1);return(0,Y.jsxs)(I,{title:e?e.address:K(`addFromAddress`),description:K(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:i,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:K(e?`save`:`addAddress`)})]}),children:[!e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`fromAddress`),(0,Y.jsx)(b,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:K(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`fromName`),(0,Y.jsx)(b,{value:s,maxLength:100,placeholder:K(`fromNamePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:K(`defaultFromAddress`)}),(0,Y.jsx)(ge,{checked:d,onChange:f,label:K(`defaultFromAddress`)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`signature`),(0,Y.jsx)(Ne,{value:l,maxLength:2e3,placeholder:K(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,Y.jsx)(P,{message:n})]})},ys=e=>e.signature?K(`ownSignature`):K(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),f=(0,J.useRef)(!1),p=t.find(e=>e.isDefault),m=()=>{d(void 0),l(void 0)},h=async e=>{if(!f.current){f.current=!0,s(!0),l(void 0);try{await e(),d(void 0)}catch(e){if(e instanceof TypeError)return l(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;l(o(e))}finally{f.current=!1,s(!1)}}},g=e=>h(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(u?.kind===`change`)return r(u.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,Y.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:K(`fromAddresses`)}),(0,Y.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:K(`fromAddressesDescription`)}),(0,Y.jsx)(P,{message:u?void 0:c}),(e||t.length>0)&&(0,Y.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`mailboxOwnAddress`)})]}),p?(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void h(()=>r(p.id,{isDefault:!1})),children:K(`makeDefault`)}):(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)})]}),t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,Y.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,Y.jsx)(F,{tone:`blue`,children:K(`default`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`change`,sender:e}),children:K(`edit`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>d({kind:`remove`,sender:e}),children:K(`remove`)})]},e.id))]}),(0,Y.jsxs)(W,{onClick:()=>d({kind:`add`}),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addFromAddress`)]}),u?.kind===`add`&&(0,Y.jsx)(vs,{busy:a,error:c,onSave:e=>void g(e),onClose:m}),u?.kind===`change`&&(0,Y.jsx)(vs,{sender:u.sender,busy:a,error:c,onSave:e=>void g(e),onClose:m},u.sender.id),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removeFromAddress`,{address:u.sender.address}),description:K(`removeFromAddressDescription`),onClose:m,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:m,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void h(()=>i(u.sender.id)),children:K(`remove`)})]}),children:(0,Y.jsx)(P,{message:c})})]})},xs=(e,t,n)=>Object.fromEntries(Fn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Xn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=q(),{account:i}=t,[a]=(0,J.useState)(Ge),o=(0,J.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}=D(o,K(`couldNotReadMethods`));return s?(0,Y.jsx)(Qt,{title:K(`mailbox`),description:K(`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??yn(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&yt(a,e.length===1?e[0].name:K(`theProvider`)),children:(0,Y.jsx)(bs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),await l()},onRemove:async e=>{await i.removeMailSender(e),await l()}})}):(0,Y.jsx)(A,{error:c})},Cs=()=>{let{personalMail:e}=q();return e.length>0?(0,Y.jsx)(Ss,{links:e}):null},ws=e=>xr(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(),[s,c]=(0,J.useState)(),l=async e=>{r(!0),a(void 0);try{await t(e.clientId),c(void 0)}catch(e){if(!(e instanceof j))throw e;a(o(e))}r(!1)};return(0,Y.jsxs)(k,{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,Y.jsx)(P,{message:s?void 0:i}),e.length===0?(0,Y.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,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=Sr(e.clientId);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Dr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,le(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>c(e),children:`Disconnect`})]},e.clientId)})}),s&&(0,Y.jsx)(I,{title:`Disconnect ${ws(s)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>c(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>c(void 0),children:`Cancel`}),(0,Y.jsx)(W,{variant:`danger`,loading:n,onClick:()=>void l(s),children:`Disconnect`})]}),children:i&&(0,Y.jsx)(P,{message:i})})]})},Ds=(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},Os=({url:e,appName:t})=>(0,Y.jsx)(k,{title:K(`mcpAddress`),description:K(`mcpAddressDescription`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Cr,{value:e,copyLabel:K(`copyMcpAddress`)}),(0,Y.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:mt(),children:[(0,Y.jsx)(x,{className:`size-3.5`}),K(`addToClaude`)]})]})}),ks=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.connectedApps(),[e]),K(`couldNotReadMethods`));return t?(0,Y.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,Y.jsx)(A,{error:n})},As=({url:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Os,{url:e,appName:H().appName}),(0,Y.jsx)(ks,{})]}),js=()=>{let{mcp:e}=q();return e?(0,Y.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>le(Date.parse(e)),Fs=e=>e?K(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):K(`neverExpires`),Is=e=>[K(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?K(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):K(`notUsedYet`),e.organization?K(`actsAsIn`,{role:e.role,organization:e.organization}):K(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,J.useState)(!1),[a,s]=(0,J.useState)(),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(`90`),[m,h]=(0,J.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,J.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(K(`noAnswerFromServer`));if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(o(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,Y.jsxs)(k,{title:K(`accessTokens`),description:K(`accessTokensDescription`),children:[(0,Y.jsx)(P,{message:c?void 0:a}),e.length===0?(0,Y.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`noAccessTokens`)}):(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(kr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:K(`revoke`)})]},e.id))}),(0,Y.jsxs)(W,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`newAccessToken`)]}),c?.kind===`create`&&(0,Y.jsxs)(I,{title:K(`newAccessToken`),description:K(`newAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:K(`createAccessToken`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,placeholder:K(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[K(`accessTokenExpiry`),(0,Y.jsx)(He,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,Y.jsx)(`option`,{value:e,children:K(Ns[e])},e))})]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedCreateAccessToken`)}),(0,Y.jsx)(P,{message:a})]}),c?.kind===`created`&&(0,Y.jsx)(I,{title:K(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:K(`accessTokenCreatedDescription`),onClose:g,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:g,children:K(`done`)}),children:(0,Y.jsx)(Cr,{value:c.created.token,copyLabel:K(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,Y.jsx)(I,{title:K(`revokeAccessToken`,{name:c.token.name}),description:K(`revokeAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:g,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:K(`revoke`)})]}),children:(0,Y.jsx)(P,{message:a})})]})},Rs=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.personalAccessTokens(),[e]),K(`couldNotReadAccessTokens`));return t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{message:n}),(0,Y.jsx)(Ls,{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,Y.jsx)(A,{error:n})},zs=()=>q().personalAccessTokens?(0,Y.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,J.useState)(),[s,c]=(0,J.useState)(r),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=async(e,t)=>{a(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof j))throw e;c(o(e))}finally{a(void 0)}};return(0,Y.jsxs)(k,{title:K(`connections`),description:K(`connectionsDescription`),children:[(0,Y.jsx)(P,{message:l?void 0:s}),(0,Y.jsx)(qe,{message:d}),(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Nr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,Y.jsx)(W,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?K(`connectAgain`,{name:e.label}):K(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[K(`connectedOn`,{date:le(Date.parse(t.created_at))}),` · `,(0,Y.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,Y.jsx)(F,{tone:`amber`,children:K(`connectionNeedsSignIn`)}):(0,Y.jsx)(F,{tone:`green`,children:K(`connected`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:K(`disconnect`)})]}),t.used_by.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:K(`connectionUsedBy`)}),t.used_by.map(e=>(0,Y.jsx)(re,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,Y.jsx)(I,{title:K(`disconnectTitle`,{name:l.connection.label}),description:Vs(l.connection)?`${K(`disconnectDescription`)} ${K(`disconnectWholeGrant`)}`:K(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>u(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:i===l.accountId,onClick:()=>void p(l.accountId,async()=>f(K(Bs[await n(l.accountId)]))),children:K(`disconnect`)})]}),children:s&&(0,Y.jsx)(P,{message:s})})]})},Us=()=>{let{session:e,connectAccount:t}=q(),{account:n}=e,[r]=(0,J.useState)(Ge),{data:i,error:a,reload:o}=D((0,J.useCallback)(()=>n.workflowConnections(),[n]),K(`couldNotReadMethods`));return i?i.length===0?null:(0,Y.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&yt(r,K(`theProvider`))}):(0,Y.jsx)(A,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?K(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?K(`deleteAccountLocked`):o(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(!1),d=(0,J.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(Ws(e)),o(!1)}};return(0,Y.jsxs)(I,{title:K(`deleteAccountQuestion`),description:K(`deleteAccountWarning`),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:K(`deleteAccountConfirm`)})]}),children:[(0,Y.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`deleteAccountPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,Y.jsx)(P,{message:s})]}),l&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(k,{title:K(`deleteAccount`),description:K(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,Y.jsx)(W,{variant:`danger`,onClick:()=>i(!0),children:K(`deleteAccount`)}),r&&(0,Y.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=q(),{account:r}=e,{data:i,error:a}=D((0,J.useCallback)(()=>r.signInMethods(),[r]),K(`couldNotReadMethods`));return i?(0,Y.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,Y.jsx)(A,{error:a})},Js=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],Ys=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Xs=(e,t)=>e.find(([e])=>e.test(t))?.[1],Zs=e=>e?{browser:Xs(Js,e),system:Xs(Ys,e)}:{},Qs=e=>e.device?K(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?K(`staffOf`,{operator:t}):K(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?K(`browserOn`,{browser:n,system:r}):r?K(`aBrowserOn`,{system:r}):n??K(`unknownDevice`)},ec=e=>{if(e.staff)return Fr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Lr:t===`iPad`?zr:jr},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?K(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?K(`signOutDevice`,{name:Qs(e.link)}):K(`signOutOthersTitle`),rc=e=>K(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),m=e.filter(e=>!e.current),h=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),g=async e=>{c(!0),u(void 0);try{await h(e),f(void 0)}catch(e){if(!(e instanceof j))throw e;u(o(e))}c(!1)},_=e=>{u(void 0),f(e)};return(0,Y.jsxs)(k,{title:K(`devices`),description:K(`devicesDescription`),children:[p.length===0&&n.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`noDevices`)}):(0,Y.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(p).map(e=>{let n=ec(e);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[K(`signedInFromUntil`,{from:Xe(Date.parse(e.createdAt)),until:Xe(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`one`,session:e}),children:K(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Lr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,Y.jsx)(F,{tone:`green`,children:K(`thisDevice`)})]}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`linkedOn`,{date:Xe(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>_({kind:`link`,link:t}),children:K(`signOut`)})]},t.id)})]}),m.length>0&&(0,Y.jsx)(W,{className:`mt-3`,onClick:()=>_({kind:`others`}),children:K(`signOutOthers`)}),d&&(0,Y.jsx)(I,{title:nc(d,t),description:rc(d),onClose:()=>f(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>f(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:s,onClick:()=>void g(d),children:K(`signOut`)})]}),children:(0,Y.jsx)(P,{message:l})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=q(),{account:r}=e,i=(0,J.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}=D(i,K(`couldNotReadDevices`));return a?(0,Y.jsx)(ic,{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,Y.jsx)(A,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(``),[m,g]=(0,J.useState)(),_=e===`required`&&t.length<=1,v=async e=>{s(!0),l(void 0),g(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?g(`asked`):l(o(e))}s(!1)};return(0,Y.jsxs)(k,{title:K(`passkeys`),status:e===`required`&&(0,Y.jsx)(F,{tone:`blue`,children:K(`required`)}),description:K(oc[e]),children:[(0,Y.jsx)(P,{message:u?void 0:c}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??K(`passkey`)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?K(`addedOn`,{date:le(Date.parse(e.createdAt))}):K(`addedEarlier`),` · `,e.backedUp?K(`synced`):K(`oneDevice`)]})]}),(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:K(`rename`)}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:_,title:_?K(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:K(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,Y.jsxs)(W,{loading:a&&!u,onClick:()=>void v(n),children:[(0,Y.jsx)(xn,{className:`size-3.5`}),K(`addPasskey`)]}),m===`asked`&&(0,Y.jsx)(ot,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>g(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:K(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,Y.jsxs)(I,{title:K(`renamePasskey`),description:K(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:a,disabled:!f.trim(),onClick:()=>void v(()=>r(u.passkey.id,f.trim())),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,Y.jsx)(P,{message:c})]}),u?.kind===`remove`&&(0,Y.jsx)(I,{title:K(`removePasskey`),description:K(`removePasskeyDescription`,{name:u.passkey.name??K(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>d(void 0),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`danger`,loading:a,onClick:()=>void v(()=>i(u.passkey.id)),children:K(`remove`)})]}),children:c&&(0,Y.jsx)(P,{message:c})})]})},cc=()=>{let{account:e}=q().session,t=(0,J.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=D(t,K(`couldNotReadMethods`));if(!n)return(0,Y.jsx)(A,{error:r});let[a,o]=n;return(0,Y.jsx)(sc,{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)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?K(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?K(`passwordTooLong`):o(e),uc=(e,t)=>{if(e.length<12)return K(`useAtLeast`,{length:12});if(e!==t)return K(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(),p=(0,J.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=uc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof j))throw e;f(lc(e)),u(!1)}}};return(0,Y.jsx)(I,{title:K(e?`changePassword`:`setPassword`),description:K(`atLeast`,{length:12}),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:n,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:K(`save`)})]}),children:(0,Y.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`currentPassword`),(0,Y.jsx)(b,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newPassword`),(0,Y.jsx)(b,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`repeatPassword`),(0,Y.jsx)(b,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:K(`changeSignsOutOthers`)}),(0,Y.jsx)(P,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>K(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=!n&&e===`allowed`;return(0,Y.jsxs)(k,{title:K(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,Y.jsx)(qe,{message:s?K(`passwordSaved`):void 0}),l&&(0,Y.jsx)(W,{onClick:()=>{c(!1),o(!0)},children:K(t?`changePassword`:`setPassword`)}),a&&(0,Y.jsx)(dc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},mc=()=>{let{session:e,state:t}=q(),{account:n}=e,{data:r,error:i,reload:a}=D((0,J.useCallback)(()=>n.signInMethods(),[n]),K(`couldNotReadMethods`));return r?(0,Y.jsx)(pc,{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,Y.jsx)(A,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,J.useState)(``),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof j))throw e;m(o(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:K(`otherAddress`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:K(`changeEmail`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`code`),(0,Y.jsx)(xt,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,Y.jsx)(P,{message:p})]}):(0,Y.jsxs)(I,{title:K(`changeEmail`),description:K(`changeEmailDescription`),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:r,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:K(`sendCode`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`newEmail`),(0,Y.jsx)(b,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,Y.jsx)(P,{message:p})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof j))throw e;h(o(e))}p(!1)};return(0,Y.jsxs)(k,{title:K(`profile`),description:K(`profileDescription`),children:[(0,Y.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`name`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:K(`email`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(W,{onClick:()=>{d(e),h(void 0),s(!0)},children:K(`changeName`)}),r&&(0,Y.jsx)(W,{onClick:()=>l(!0),children:K(`changeEmail`)})]}),a&&(0,Y.jsxs)(I,{title:K(`changeName`),description:K(`changeNameDescription`),onClose:()=>s(!1),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:()=>s(!1),children:K(`cancel`)}),(0,Y.jsx)(W,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:K(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`name`),(0,Y.jsx)(b,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,Y.jsx)(P,{message:m})]}),c&&r&&(0,Y.jsx)(hc,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=q(),{data:n,loaded:r,error:i,reload:a}=D((0,J.useCallback)(()=>e.session(),[e]),K(`couldNotReadProfile`));if(!r)return(0,Y.jsx)(A,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,Y.jsx)(gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},vc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:s})=>{let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),[m,h]=(0,J.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await a(i?c:void 0)}catch(e){if(!(e instanceof j))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(o(e)),d(!1)}};return(0,Y.jsxs)(I,{title:e,description:t,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{onClick:s,children:K(`cancel`)}),(0,Y.jsx)(W,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[K(`yourPassword`),(0,Y.jsx)(b,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,Y.jsx)(ot,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,J.useState)(),d=()=>u(void 0),f=n?(0,Y.jsx)(F,{tone:`green`,children:K(`on`)}):t===`required`?(0,Y.jsx)(F,{tone:`amber`,children:K(`required`)}):(0,Y.jsx)(F,{children:K(`off`)}),p=K(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,Y.jsx)(k,{title:K(`twoFactor`),status:f,description:p,children:(0,Y.jsx)(`div`,{className:`max-w-sm`,children:(0,Y.jsx)(Kt,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,Y.jsxs)(k,{title:K(`twoFactor`),status:f,description:p,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,Y.jsx)(W,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:K(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,Y.jsx)(W,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:K(`addAuthenticator`)}),n&&r&&(0,Y.jsx)(W,{onClick:()=>u({kind:`new-codes`}),children:K(`newBackupCodes`)}),n&&(0,Y.jsx)(W,{variant:`danger`,disabled:t===`required`,title:t===`required`?K(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:K(`turnOff`)})]}),l?.kind===`turn-off`&&(0,Y.jsx)(vc,{title:K(`turnOffTitle`),description:K(`turnOffDescription`),confirmLabel:K(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,Y.jsx)(vc,{title:K(`newCodesTitle`),description:K(`newCodesDescription`),confirmLabel:K(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,Y.jsx)(I,{title:K(`yourNewCodes`),description:K(`keepCodesSafe`),onClose:d,actions:(0,Y.jsx)(W,{variant:`primary`,onClick:d,children:K(`savedCodes`)}),children:(0,Y.jsx)(tn,{codes:l.codes})})]})},xc=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.signInMethods(),[e]),K(`couldNotReadMethods`));return t?(0,Y.jsx)(bc,{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,Y.jsx)(A,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,Y.jsx)(ne,{children:e}):(0,Y.jsxs)(Y.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,Y.jsx)(Re,{name:e,fallback:n===void 0?void 0:(0,Y.jsx)(Sc,{problem:N.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,Y.jsx)(Sc,{problem:N.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ii,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:ci,RecordRow:ro,RecordCards:$a,Chart:li,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ri,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:Be,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:oi,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=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(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:xe(t,...n,r)}})),Dc=({text:e})=>{let t=G(),n=Oe(),r={...L(t),params:n};return(0,Y.jsx)(Y.Fragment,{children:E(e,e=>ie(C(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,Y.jsx)(Dc,{text:e},t):(0,Y.jsx)(J.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,Y.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Ur(n.child)&&e&&Ur(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Ur(n.child)?(0,Y.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,Y.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>Ve(e)||Array.isArray(e)&&e.length>0&&e.every(Ve),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,Y.jsx)(Y.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:xe(t,`props`,n)}}],Pc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fc=(e,t)=>{let n=Pc(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>Ve(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=_(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||Ve(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=At(),r=G(),i=Oe(),a=st(),o=(0,J.useMemo)(()=>Xt(gn(e,{...L(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,Y.jsx)(Y.Fragment,{children:kc(Fc(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,Y.jsx)(Ji,{node:o,children:Ac(Ec(o.children,t,`children`))}):void 0;return(0,Y.jsx)(Cc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:e&&(0,Y.jsx)(Je,{node:o,...t!==void 0&&{at:t},children:(0,Y.jsx)(e,{...be(o.props),children:r})})})}let s=wc[o.type];if(!s)return(0,Y.jsx)(ne,{children:N.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=Ec(o.children,t,`children`),u=(0,Y.jsx)(s,{node:o,at:t,slots:Mc(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?kc(l):Ac(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Tc.has(o.type)?u:(0,Y.jsx)(`div`,{className:c,children:u});return o.fallback?(0,Y.jsx)(Re,{name:o.type,resetKey:o,fallback:(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:d}):d};export{bo as a,Ha as c,Yo as i,za as l,Cc as n,co as o,Xo as r,Za as s,Ic as t,Qi as u};
|
|
3
|
-
//# debugId=34fcf6fc-8b1c-44df-a08f-4f408681b094
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(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{Ga as r,Gs as i,Ic as a,Jn as o,Kl as s,Kr as c,Ks as l,Pa as u,Qr as d,Rr as f,Vc as p,Wl as m,Xc as h,Yc as g,Yn as _,ac as v,al as y,ba as b,cl as x,fl as S,gi as C,ic as w,ja as T,ls as E,mr as D,ns as O,on as k,sc as A,vn as j,xa as M}from"./app-B94YfKGx.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-OJQKeuBN.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as ee,r as B,s as V,t as H}from"./messages-vzi5T1Xo.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=p(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=p(G),q=e(t(),1),J=h(`app/delete`),Y=m(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let c=n[a]?.names?.plural??x(a),l=X({blockingPlural:c,noun:r});if(!o||i===void 0)return{text:l};let u={kind:`list`,resource:a,filter:s(Y.eq(o,i))};return{text:l,link:{label:J(`show`,{plural:c}),to:u}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(v,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,Q.jsx)(v,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(v,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(v,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(A,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(v,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(A,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??x(e.name),before:C(e,n[e.name],i),after:C(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:a})=>{let o=E(),s=N(),c=u(),[d,p]=(0,q.useState)(),[m,h]=(0,q.useState)(!1),g=t?.names?.singular??x(e.name),_=t?.names?.plural??x(e.name),{resources:v,views:y}=O(),{href:b,open:S}=f(),C=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:v,views:y,noun:g,...e.primaryKey.length===1&&{key:n.key}}),w=()=>{for(let t of[`page`,`list`,`first-page`,`map`])s.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])s.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await o.get(e.name,t.key)).etag;try{await o.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof i))throw e;return e}},D=t=>{w(),p(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&a&&{action:{label:J(`undo`),onClick:()=>{a(t).then(()=>{w(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!l(e))throw e;w(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},k=async(n,r)=>{h(!0);try{if(!await T(n,r))return D(n);let i=(await o.get(e.name,n.key)).record;p({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!l(e))throw e;p(void 0);let t=C(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:b(t.link.to),onNavigate:S}}})}finally{h(!1)}},A=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!l(t))throw t;return{title:e.title,message:C(t,e)?.text??t.message}}},j=async e=>{let t=[],n=[],r=0;p({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await A(a);i&&(t.push(i),n.push(a)),r+=1,p({kind:`bulk-running`,done:r,total:e.length})}})),w(),p({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>p(void 0);return{dialogs:d&&(0,Q.jsxs)(Q.Fragment,{children:[d.kind===`confirm`&&(0,Q.jsx)(te,{title:d.target.title,noun:g,busy:m,onCancel:M,onConfirm:()=>void k(d.target,d.target.etag)}),d.kind===`conflict`&&(0,Q.jsx)(ne,{title:d.target.title,changes:d.changes,busy:m,onCancel:M,onReview:()=>{M(),r?.(d.target,d.fresh)},onDeleteAnyway:()=>void k(d.target,`*`)}),d.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:d.targets.length,noun:g,plural:_,onCancel:()=>{M(),d.settle(d.targets)},onConfirm:()=>d.settle(j(d.targets))}),d.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:d.done,total:d.total}),d.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:d.total,failures:d.failures,onClose:M})]}),start:t=>e.softDelete?k(t,t.etag):p({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>p({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=E();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>S(M(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return H(`dependsOn`,{record:n,other:o.title});let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?H(`dependsOn`,{record:s.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let s=E(),l=u(),d=j(),{resources:f,views:p}=O(),m=`${n} asc`,h=P({queryKey:[...g.list(e.name,r,m,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=o(f,p,e,i),n=[],a=``;do{let o=await s.search(e.name,{filter:r||void 0,orderBy:m,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(..._(f,e,i,o.items,o.labels).map((t,n)=>({...t,id:b(e,o.items[n])}))),a=o.nextPageToken}while(a);return n}}),[v,x]=(0,q.useState)(),S=(0,q.useRef)(void 0),C=(0,q.useRef)([]),w=(0,q.useRef)(void 0),T=(0,q.useRef)(Promise.resolve()),D=(0,q.useRef)(0),k=(0,q.useRef)(void 0),A=async()=>{let t=S.current,r=C.current;if(C.current=[],!t||r.length===0)return;let i=await s.batchWrite(r),a=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[b(e,t.record),t])),o=z(i.results,t=>b(e,t)),c=L(e,[...a].map(([e,t])=>({...t,before:{[n]:o.get(e)}})),[n]);k.current!==void 0&&l.dismiss(k.current),k.current=l.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(c)}}),S.current&&=S.current.map(e=>{let t=a.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},M=(e,t)=>n=>{S.current=void 0,C.current=[],x(void 0),l.show(ee(n,e,{place:`list`,title:t?w.current:void 0}))},N=async()=>{--D.current,!(D.current>0)&&(await d(e.name),!(D.current>0)&&(S.current=void 0,x(void 0)))},F=(n,r)=>{let i=S.current??h.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,a);let o=c(e,i[n]).record,l=i[n].id;R(s,e,t,o).then(n=>{let i=S.current??h.data,s=ce(e,n,y(e,t,o,l));H(i,i.findIndex(e=>e.id===l),r,e=>s(e)??a?.(e))},M(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let l=s?U(i,a,o,s):o;a!==l&&(S.current=I(i,a,l),C.current=[...C.current,B(e,n,r,S.current,l)],x(S.current),D.current+=1,w.current=y(e,t,c(e,i[a]).record,i[a].id),T.current=T.current.then(A).catch(M(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>c(e,t).record),n,r,i);return a.reason!==void 0&&l.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{k.current!==void 0&&l.dismiss(k.current),k.current=void 0,D.current+=1,T.current=T.current.then(async()=>{await s.batchWrite(e),S.current=void 0,C.current=[],x(void 0)}).catch(M(V(`couldNotUndo`),!1)).then(N)};return{rows:v??h.data,loading:h.isPending,error:h.error,move:F}},de=({model:e,view:t,field:n,filter:i,columns:a,sort:o})=>{let{resources:s,views:c}=O(),{fields:l,dropRules:u}=T(),{go:p,href:m}=f(),h=o!==void 0,g=(0,q.useMemo)(()=>k(e,t,a,{resources:s,views:c,fieldTypes:l}).map(e=>h?e:{...e,sortable:!1}),[e,t,a.join(`,`),s,c,l,h]),_=(0,q.useMemo)(()=>d(e,t,g.map(e=>e.id)),[e,t,g]),v=t?.list?.drag?.rule,b=v===void 0?void 0:u?.[v],x=ue({model:e,view:t,field:n,filter:i,fields:_,...b&&{rule:b}}),S=x.rows,C=(0,q.useMemo)(()=>S&&{total:S.length,rowAt:e=>S[e]},[S]);if(v!==void 0&&!b)return(0,Q.jsx)(r,{children:V.rich(`noRule`,{rule:v})});if(x.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(w,{className:`h-4 w-full`},t))});if(x.error)return(0,Q.jsx)(D,{title:V(`couldNotLoad`),error:x.error});if(!C||C.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let E=t=>p({kind:`record`,resource:e.name,key:M(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:g,source:C,latencyMs:0,onOpenRow:E,rowLink:t=>({href:m({kind:`record`,resource:e.name,key:M(e,t)}),onFollow:()=>E(t)}),...o&&{sort:o.value,onSortChange:o.onChange},rowNumbers:!1,reorder:{label:n=>y(e,t,n,n.id),onMove:x.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(A,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(a,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
|
|
2
|
-
//# debugId=61873861-4ceb-49e4-a149-f0aac5bd4eb9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(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{$ as e,Aa as t,Ao as n,Ar as r,At as ee,B as te,Ba as i,Bi as a,Bt as o,Cn as s,Ct as c,Do as l,Dt as u,Et as d,Fr as f,Ft as p,G as m,Gc as h,Gi as g,Gt as _,H as v,Hi as y,Ht as b,Ir as x,Jc as S,Jt as C,K as w,Kc as T,Ki as E,Lr as D,Mo as O,Mt as k,N as A,Na as j,Nt as M,Ot as N,P,Pr as F,Pt as I,Q as L,Qt as R,R as z,Ra as B,Rn as V,Ro as H,Rr as U,Rt as W,Sr as G,St as K,Tr as q,Tt as J,U as Y,Uc as X,Ui as Z,V as Q,Va as ne,Vi as re,Vt as ie,W as ae,Wc as oe,Wi as se,X as ce,Yt as le,Zc as ue,Zt as $,_r as de,_t as fe,ac as pe,bo as me,br as he,bt as ge,cc as _e,co as ve,cs as ye,da as be,dt as xe,et as Se,fo as Ce,ft as we,go as Te,gr as Ee,gt as De,ho as Oe,hr as ke,ht as Ae,it as je,jo as Me,jr as Ne,jt as Pe,ka as Fe,ko as Ie,kr as Le,lc as Re,ls as ze,mt as Be,n as Ve,nc as He,nt as Ue,oo as We,or as Ge,ot as Ke,po as qe,pt as Je,qc as Ye,qt as Xe,r as Ze,rt as Qe,sc as $e,so as et,ss as tt,t as nt,tt as rt,us as it,ut as at,vo as ot,vt as st,wr as ct,wt as lt,xr as ut,xt as dt,yr as ft,yt as pt,z as mt,zi as ht,zt as gt}from"./app-B94YfKGx.js";import{h as _t,o as vt}from"./vendor-t7Q7QbPu.js";export{K as ActionCard,G as ActionInputError,ye as ApiProvider,f as App,D as AppLink,Me as AppMark,we as AssistantDock,ve as AuthLayout,Oe as AvailabilityMark,$e as Button,W as CallMark,b as CallView,w as Carousel,k as ChatDivider,Pe as ChatMessage,ee as ChatThread,mt as Choices,We as CodeForm,ge as CompactTable,lt as Composer,pe as Dialog,fe as DiffView,z as Field,le as FieldBadge,dt as FieldList,Ee as FileReadError,e as FocusActions,Se as FocusNotice,je as FocusPage,rt as FocusPanel,Ue as FocusSlot,A as Form,he as HtmlFrame,Ve as InPlaceForm,l as Input,O as LogoMark,s as Markdown,d as MentionBox,J as MentionedText,te as MenuSelect,ot as MenuSurface,Ce as OtpInput,Be as PartView,o as RecordCall,_ as RecordLink,nt as RecordPicker,et as ResendCodeButton,Z as ResponsiveDialog,He as RouteLink,ce as SearchPicker,P as Section,me as Segmented,Q as Select,c as SidePanel,p as SignInPrompt,Re as Spinner,Te as StatusMark,Ae as StepList,V as Textarea,C as ToneEdge,v as allowDelayMs,_e as buttonClass,M as chatDayLabel,H as closeSidebarEvent,Fe as definePlugin,t as defineUi,st as diffStats,u as emptyDraft,ut as fileNamed,ct as isConflict,Y as isFramed,n as logoTapEvent,N as mentionedIds,h as mergeUi,pt as parseDiff,De as parsePatch,Ye as pluginApi,X as pluginsChangedEvent,S as protobaseVersion,I as sameChatDay,ue as showTextsIn,ft as siblingPage,qe as signedOutEvent,a as statusRefreshMs,T as uiFromModule,x as uiReadyEvent,ne as useApiToken,U as useAppAddress,ae as useArmedAfterFocus,xe as useAssistant,at as useAssistantClient,Je as useBackendData,ze as useClient,$ as useComponentReads,R as useComponentSelect,Ze as useCreateForm,Le as useFacets,Ie as useFieldControl,de as useFileText,Ke as useFocusPage,L as useFocusRecord,Qe as useFocusZoneFilled,m as useGuardedPress,r as useHistogram,se as useInbox,Ge as useLayoutRecord,F as useList,Xe as useListDisplay,g as useMarkNotificationsRead,ht as useMembers,tt as useMeta,re as useOwnStatus,oe as usePlugin,j as usePresence,be as usePushNotifications,vt as useQuery,_t as useQueryClient,B as useRecord,ie as useRecordCallAddress,gt as useRecordCalls,it as useResourceClient,Ne as useSeries,ke as useSiblingPage,i as useSignedInUser,y as useStatuses,E as useUnreadNotifications,q as useUpdateRecord};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(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{$c as r,Hc as i,Kl as a,Ks as o,Oc as s,Qc as c,Vc as l,Wl as u,cl as d,gi as f,io as p,j as m,lc as h,mr as g,sc as _,sl as v}from"./app-B94YfKGx.js";import{c as y,d as b,l as ee,o as x,u as S}from"./list-page-DImD2FRO.js";var C={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};C.node;var te=l(C),w=e(t(),1),T=e(n(),1),ne=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,re=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>x(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,b(`line`),b(`problems`)],...n].map(e=>e.map(ne).join(`,`)).join(`\r
|
|
2
|
-
`)}\r\n`},E=({label:e,counts:t})=>(0,T.jsx)(`dl`,{"aria-label":e,className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:t.map(([e,t])=>(0,T.jsxs)(`div`,{className:`rounded-lg border px-3 py-2`,children:[(0,T.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,T.jsx)(`dd`,{className:`text-lg font-semibold tabular-nums`,children:t.toLocaleString(r())})]},e))}),D=(e,t)=>e?.fields[t]?.label??d(t),ie=new Set([`text`,`integer`,`bigint`,`decimal`,`boolean`,`date`,`timestamp`,`uuid`,`enum`,`relation`,`currency`,`country`]),O=(e,t)=>{let n=e.relation?t[e.relation.resource]:void 0;return n?.primaryKey.length===1?n:void 0},ae=(e,t,{json:n=!1}={})=>Object.values(e.fields).filter(r=>r.readOnly||r.name===e.tenant?!1:r.type===`json`?n:ie.has(r.type)?r.type!==`relation`||O(r,t)!==void 0:!1),oe=new Set([`text`,`integer`,`bigint`,`uuid`,`date`,`currency`,`country`,`enum`]),se=e=>{let t=e.primaryKey.length===1?[e.fields[e.primaryKey[0]]]:[],n=Object.values(e.fields).filter(t=>t.filterable&&!t.sensitive&&oe.has(t.type)&&!e.primaryKey.includes(t.name));return[...t,...n]},k=(e,t)=>O(e,t),A=e=>!e.nullable&&!e.default,j=e=>e.toLowerCase().replace(/[\s_-]+/g,``),ce=(e,t,n)=>{let r=new Set;return e.flatMap((e,i)=>{let a=j(e);if(a===``)return[];let o=t.find(e=>!r.has(e.name)&&(j(D(n,e.name))===a||j(e.name)===a));return o?(r.add(o.name),[{column:i,field:o.name}]):[]})},le=(e,t,n)=>{if(e===`update`)return[];let r=new Set(n.map(e=>e.field));return t.filter(e=>A(e)&&!r.has(e.name))},M=e=>({ok:!0,value:e}),N=e=>({ok:!1,problem:e}),P=e=>`“${x(e)}”`,F=(e,t)=>{if(typeof e==`number`)return String(e);if(typeof e==`string`)return m(e,t.decimal)},ue=(e,t,n)=>{let r=F(t,n);if(r===void 0)return N(b(`notNumber`,{cell:P(t)}));let[i,a=``]=r.split(`.`);if(/[1-9]/.test(a)||/e/i.test(r))return N(b(`notWholeNumber`,{cell:P(t)}));if(e.type===`bigint`)return M(String(BigInt(i)));let o=Number(i);return Number.isSafeInteger(o)?M(o):N(b(`tooLarge`,{cell:P(t)}))},de=(e,t)=>{let n=F(e,t);return n===void 0?N(b(`notNumber`,{cell:P(e)})):M(n)},fe=new Set([`true`,`yes`,`1`]),pe=new Set([`false`,`no`,`0`]),me=e=>{if(typeof e==`boolean`)return M(e);let t=typeof e==`string`||typeof e==`number`?String(e).trim().toLowerCase():``;return fe.has(t)?M(!0):pe.has(t)?M(!1):N(b(`notBoolean`,{cell:P(e)}))},I=e=>String(e).padStart(2,`0`),he=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));if(r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n)return`${e}-${I(t)}-${I(n)}`},L=`(\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?`,ge=(e,t)=>{let n=RegExp(`^(\\d{4})[-/](\\d{1,2})[-/](\\d{1,2})(?:[T ]${L}(Z|[+-]\\d{2}:?\\d{2})?)?$`).exec(e.trim()),r=RegExp(`^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})(?: ${L})?$`).exec(e.trim());if(!n&&!r)return;let[i,a,o]=n?[n[1],n[2],n[3]].map(Number):t===`dmy`?[r[3],r[2],r[1]].map(Number):[r[3],r[1],r[2]].map(Number),s=he(i,a,o);if(!s)return;let[c,l,u=`0`]=n?n.slice(4,7):r.slice(4,7);if(c===void 0)return{date:s};if(!(Number(c)>23||Number(l)>59||Number(u)>59))return{date:s,time:`${I(Number(c))}:${l}:${I(Number(u))}`,zone:n?.[7]}},R=(e,t)=>{if(ee(e)){let[t,n]=e.date.split(`T`);return{date:t,time:n}}return typeof e==`string`?ge(e,t.dateOrder):void 0},z=(e,t)=>N(b(`notDate`,{cell:P(e),dayFirst:t.dateOrder===`dmy`})),_e=(e,t)=>{let n=R(e,t);return n?n.time&&n.time!==`00:00:00`?N(b(`hasTime`,{cell:P(e)})):M(n.date):z(e,t)},ve=(e,t)=>{let n=R(e,t);if(!n)return z(e,t);if(n.zone)return M(new Date(`${n.date}T${n.time}${n.zone===`Z`?`Z`:n.zone.replace(/^([+-]\d{2})(\d{2})$/,`$1:$2`)}`).toISOString());let[r,i,a]=n.date.split(`-`).map(Number),[o,s,c]=(n.time??`00:00:00`).split(`:`).map(Number);return M(new Date(r,i-1,a,o,s,c).toISOString())},B=e=>e.trim().toLowerCase().replace(/\s+/g,` `),ye=(e,t,n)=>{let r=e.enumValues??[],i=B(x(n)),a=r.filter(e=>B(e)===i||B(v(e,t?.valueLabels))===i);return a.length===1?M(a[0]):a.length>1?N(b(`severalValues`,{cell:P(n),values:a.map(e=>v(e,t?.valueLabels)).join(`, `)})):N(b(`notOneOf`,{cell:P(n),values:r.map(e=>v(e,t?.valueLabels)).join(`, `)}))},be=(e,t)=>typeof e==`boolean`&&!t.booleanText?N(b(`notText`,{cell:P(e)})):M(x(e)),xe=e=>S(e)?M(e.json):M(e),V=(e,t,n,r)=>{if(y(n))return e.nullable?M(null):N(b(`emptyRequired`));if(e.type===`json`)return xe(n);if(S(n))return N(b(`nestedValue`,{cell:P(n)}));switch(e.type){case`integer`:case`bigint`:return ue(e,n,r);case`decimal`:return de(n,r);case`boolean`:return me(n);case`date`:return _e(n,r);case`timestamp`:return ve(n,r);case`enum`:return ye(e,t,n);case`text`:case`uuid`:case`currency`:case`country`:return be(n,r);default:throw Error(`Not implemented: importing ${e.type} fields, which importableFields leaves out`)}},Se=(e,t)=>e[t]?.names?.singular??d(t),Ce=(e,t)=>e[t]?.names?.plural??d(t),we=(e,t,n)=>{let{model:r,resources:i,views:a}=n,o=a[r.name],s={},c={},l=[],u=[];for(let{column:n,field:d,matchBy:f}of t.columns){let p=r.fields[d],m=e.cells[n]??null,h=D(o,d),g=k(p,i);if(g&&!y(m)){let e=f??g.primaryKey[0],n=V(g.fields[e],a[g.name]?.fields[e],m,t.options);n.ok?u.push({field:d,finding:{model:g,field:e,value:n.value}}):l.push(`${h}: ${n.problem}`),s[d]=x(m);continue}let _=V(p,o?.fields[d],m,t.options);_.ok?c[d]=s[d]=_.value:l.push(`${h}: ${_.problem}`)}let d;if(t.match&&t.mode!==`create`){let n=r.fields[t.match.field],i=V({...n,nullable:!1},o?.fields[n.name],e.cells[t.match.column]??null,t.options);i.ok?d={model:r,field:n.name,value:i.value}:l.push(`${D(o,n.name)}: ${i.problem}`)}return{values:s,data:c,problems:l,relations:u,match:d}},H=(e,t)=>{let n=e.lookups.keysOf(t.model.name,t.field,t.value),r=`${D(e.views[t.model.name],t.field).toLowerCase()} “${String(t.value)}”`;return n.length===1?{key:n[0]}:n.length===0?{none:b(`noneHas`,{singular:Se(e.views,t.model.name),named:r})}:{several:b(`severalHave`,{count:n.length,plural:Ce(e.views,t.model.name),named:r})}},Te=e=>e.cells.every(y),U=async(e,t,n)=>{let{model:r,views:i}=n,a=e.filter(e=>!Te(e)).map(e=>({row:e,...we(e,t,n)})),o=new Map;for(let e of a.flatMap(e=>[...e.relations.map(e=>e.finding),...e.match?[e.match]:[]])){let t=`${e.model.name}.${e.field}`;o.has(t)||o.set(t,{model:e.model,field:e.field,values:[]}),o.get(t).values.push(e.value)}for(let{model:e,field:t,values:r}of o.values())await n.lookups.load(e,t,r);return a.map(({row:e,values:a,data:o,problems:s,relations:c,match:l})=>{let u={...o};for(let{field:e,finding:t}of c){let a=H(n,t);`key`in a?u[e]=a.key:s.push(`${D(i[r.name],e)}: ${a.none??a.several}`)}let d=l&&H(n,l);d?.several&&s.push(b(`notOneRecord`,{found:d.several})),d?.none&&t.mode===`update`&&s.push(b(`nothingToUpdate`,{found:d.none}));let f={line:e.line,cells:e.cells,values:a,problems:s};return s.length>0?f:d&&`key`in d?{...f,op:{op:`update`,resource:r.name,key:d.key,etag:`*`,data:u}}:{...f,op:{op:`create`,resource:r.name,data:u}}})},Ee=5,De=5,Oe=async(e,t)=>{let n=e.rows(t),{value:r=[]}=await n.next();await n.return(void 0);let[i,...a]=r;return{headers:(i?.cells??[]).map(x),sample:a.slice(0,Ee)}};async function*W(e,t){let n=!0;for await(let r of e.rows(t))yield n?r.slice(1):r,n=!1}var ke=async(e,t,n,r,i,a)=>{let o={rows:0,creates:0,updates:0,problems:[],preview:[]};for await(let s of W(e,t)){a?.throwIfAborted();for(let e of await U(s,n,r))o.rows++,o.preview.length<De&&o.preview.push(e),e.op?.op===`create`?o.creates++:e.op?.op===`update`?o.updates++:o.problems.push({line:e.line,cells:e.cells,problems:e.problems});i(o.rows)}return o},Ae=(e,t)=>{if(!o(e))return[e.message];let n=e.errors.filter(e=>e.field);return n.length===0?[e.message]:n.map(e=>`${D(t.views[t.model.name],e.field)}: ${e.message}`)},je=async(e,t,n,r,{client:i,onProgress:a,cancelled:s})=>{let c={created:0,updated:0,skipped:0,failed:0,notWritten:[]},l=async e=>{let t=[...e];for(;t.length>0;){let e=t.map(e=>e.op);try{let{results:t}=await i.batchWrite(e);for(let e of t)e.op===`create`?c.created++:e.op===`update`&&c.updated++;return}catch(e){let n=o(e)?e.operation:void 0;if(n===void 0||!t[n])throw e;let[i]=t.splice(n,1);c.failed++,c.notWritten.push({line:i.line,cells:i.cells,problems:Ae(e,r)})}}},u=[],d=async e=>{for(;u.length>=100||e&&u.length>0;){if(s())return!1;await l(u.splice(0,100)),a({...c})}return!0};for await(let i of W(e,t)){for(let e of await U(i,n,r))e.op?u.push(e):(c.skipped++,c.notWritten.push({line:e.line,cells:e.cells,problems:e.problems}));if(!await d(!1))return{...c,cancelled:!0}}return await d(!0)?{...c,cancelled:!1}:{...c,cancelled:!0}},G=50,K=(e,t,n)=>p(re(t,n),b(`notImportedFile`,{name:(e??`import`).replace(/\.[^.]+$/,``)}),`text/csv`),q=({rows:e})=>(0,T.jsxs)(`ul`,{"aria-label":b(`rowsNotImported`),className:`flex flex-col gap-1 text-body`,children:[e.slice(0,G).map(e=>(0,T.jsxs)(`li`,{children:[(0,T.jsx)(`span`,{className:`font-medium`,children:b(`rowProblems`,{line:e.line})}),` `,e.problems.join(`; `)]},e.line)),e.length>G&&(0,T.jsx)(`li`,{className:`text-muted-foreground`,children:b(`andMore`,{count:(e.length-G).toLocaleString(r())})})]}),Me=({rows:e})=>(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(h,{className:`size-3.5`}),b(`checkingRows`,{count:e.toLocaleString(r())})]}),Ne=({check:e,model:t,resources:n,views:r,columns:i,headers:a,fileName:o})=>{let c=r[t.name],l=i.map(e=>t.fields[e.field]);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsx)(E,{label:b(`check`),counts:[[b(`rows`),e.rows],[b(`toCreate`),e.creates],[b(`toUpdate`),e.updates],[b(`withProblems`),e.problems.length]]}),e.preview.length>0&&(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,T.jsxs)(`table`,{"aria-label":b(`firstRows`),className:`w-full text-left text-body`,children:[(0,T.jsx)(`thead`,{className:`bg-muted text-muted-foreground`,children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{className:`px-2 py-1.5 font-medium`,children:b(`row`)}),l.map(e=>(0,T.jsx)(`th`,{className:`whitespace-nowrap px-2 py-1.5 font-medium`,children:D(c,e.name)},e.name))]})}),(0,T.jsx)(`tbody`,{className:`divide-y`,children:e.preview.map(e=>(0,T.jsxs)(`tr`,{className:e.problems.length>0?`bg-danger-soft`:void 0,children:[(0,T.jsx)(`td`,{className:`px-2 py-1.5 tabular-nums text-muted-foreground`,children:e.line}),l.map(t=>(0,T.jsx)(`td`,{className:`max-w-48 truncate px-2 py-1.5`,children:k(t,n)?String(e.values[t.name]??`—`):t.name in e.values?f(t,e.values[t.name],c?.fields[t.name]):``},t.name))]},e.line))})]})}),e.problems.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`problemRows`)}),(0,T.jsxs)(_,{size:`sm`,onClick:()=>K(o,a,e.problems),children:[(0,T.jsx)(s,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(q,{rows:e.problems})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`batches`,{size:100})})]})},Pe=[`.xlsx`,`.csv`,`.json`],Fe=[`text/csv`,`application/json`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],Ie=[`text/comma-separated-values`,`application/csv`,`text/x-csv`,`application/vnd.ms-excel`,`text/plain`,`application/octet-stream`],Le=e=>/\bAndroid\b/.test(e),Re=e=>[...Pe,...Fe,...Le(e)?Ie:[]].join(`,`),J=({label:e,name:t,value:n,options:r,onChange:a,help:o,className:s})=>{let c=(0,w.useId)();return(0,T.jsxs)(`div`,{className:i(`flex min-w-0 flex-col gap-1.5`,s),children:[(0,T.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:e}),(0,T.jsx)(`select`,{id:c,"aria-label":t,value:n,onChange:e=>a(e.target.value),className:`h-8 w-full min-w-0 rounded-md border border-border-strong bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 max-sm:min-h-11`,children:r.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))}),o&&(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o})]})},Y=({file:e,sheets:t,sheet:n,reading:r,onChoose:i,onSheet:a})=>{let o=(0,w.useId)();return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(`label`,{htmlFor:o,className:`font-medium`,children:b(`file`)}),(0,T.jsx)(`input`,{id:o,type:`file`,accept:Re(globalThis.navigator?.userAgent??``),disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&i(t)},className:`file:mr-3 file:h-8 file:rounded-md file:border file:border-border-strong file:bg-background file:px-3 file:font-medium file:text-foreground max-sm:file:min-h-11`}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`fileHint`)})]}),r&&(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(h,{className:`size-3.5`}),b(`reading`,{name:e?.name??b(`theFile`)})]}),!r&&t.length>1&&(0,T.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,T.jsx)(te,{className:`mb-2 size-4 shrink-0 text-muted-foreground`}),(0,T.jsx)(J,{className:`flex-1`,label:b(`sheet`),value:n??``,options:t.map(e=>({value:e,label:e})),onChange:a})]})]})},X=e=>e.toLocaleString(r()),ze=({progress:e,total:t,cancelling:n})=>{let r=e.created+e.updated+e.failed;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:b(n?`stopping`:`saving`)}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[X(r),` / `,X(t)]})]}),(0,T.jsx)(`div`,{role:`progressbar`,"aria-label":b(`rowsSaved`),"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":t,className:`h-2 overflow-hidden rounded-full bg-muted`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${t>0?Math.min(100,r/t*100):0}%`}})})]})},Be=({result:e,stopped:t,headers:n,fileName:r})=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t!==void 0&&(0,T.jsx)(g,{title:b(`stopped`),error:t}),e.cancelled&&(0,T.jsx)(`p`,{role:`status`,children:b(`cancelled`)}),(0,T.jsx)(E,{label:b(`summary`),counts:[[b(`created`),e.created],[b(`updated`),e.updated],[b(`skipped`),e.skipped],[b(`failed`),e.failed]]}),e.notWritten.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`rowsNotImported`)}),(0,T.jsxs)(_,{size:`sm`,onClick:()=>K(r,n,e.notWritten),children:[(0,T.jsx)(s,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`notWrittenHint`)}),(0,T.jsx)(q,{rows:[...e.notWritten].sort((e,t)=>e.line-t.line)})]})]}),Ve=u(),Z=100,Q=e=>String(e),He=e=>{let t=new Map,n=(e,n)=>{let r=`${e}.${n}`;return t.has(r)||t.set(r,new Map),t.get(r)};return{load:async(t,r,i)=>{let o=n(t.name,r),s=[...new Map(i.filter(e=>!o.has(Q(e))).map(e=>[Q(e),e])).values()],c=t.primaryKey[0];for(let n=0;n<s.length;n+=Z){let i=s.slice(n,n+Z);for(let e of i)o.set(Q(e),[]);let l=a(Ve.in(r,i)),u;do{let n=await e(t.name).list(t.name,{filter:l,fields:[...new Set([c,r])],pageSize:1e3,pageToken:u});for(let e of n.items)o.get(Q(e[r]))?.push(e[c]);u=n.nextPageToken||void 0}while(u)}},keysOf:(e,t,r)=>n(e,t).get(Q(r))??[]}},Ue=500,$=()=>{let e=new Worker(new URL(`/assets/parse-worker-VaelBbE0.js`,``+import.meta.url),{type:`module`}),t=[],n;return e.onmessage=e=>{if(n){let t=n;n=void 0,t(e.data)}else t.push(e.data)},e.onerror=e=>{e.preventDefault();let r={type:`error`,message:b(`unreadable`)};n?n(r):t.push(r)},{send:t=>e.postMessage(t),receive:()=>t.length>0?Promise.resolve(t.shift()):new Promise(e=>n=e),stop:()=>e.terminate()}},We=e=>({sheets:async()=>{let t=$();try{t.send({type:`sheets`,file:e,locale:c()});let n=await t.receive();if(n.type===`error`)throw Error(n.message);if(n.type!==`sheets`)throw Error(`The parse worker answered ${n.type} to a request for sheets`);return n.sheets}finally{t.stop()}},rows:async function*(t){let n=$();try{for(n.send({type:`read`,file:e,sheet:t,chunk:Ue,locale:c()});;){let e=await n.receive();if(e.type===`error`)throw Error(e.message);if(e.type===`end`)return;if(e.type!==`rows`)throw Error(`The parse worker answered ${e.type} to a read`);yield e.rows,n.send({type:`next`})}}finally{n.stop()}}});export{A as _,Y as a,Me as c,je as d,ce as f,k as g,se as h,Be as i,ke as l,ae as m,He as n,J as o,D as p,ze as r,Ne as s,We as t,Oe as u,le as v};
|
|
3
|
-
//# debugId=f1550865-2851-495a-a761-146d1e3f7264
|