@protobase/ui 0.115.0 → 0.116.0
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/change-confirm/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/conversation/messages.d.ts +2 -2
- package/dist/app/conversation/thread-state.d.ts +1 -1
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/custom-section.d.ts +1 -1
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/list-cards.d.ts +1 -1
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/widget-part.d.ts +1 -1
- 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/file-viewers/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/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-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/new-version/messages.d.ts +2 -2
- package/dist/app/pages/custom-boundary.d.ts +1 -1
- package/dist/app/pages/custom-chosen.d.ts +1 -1
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/saved/saved-list.d.ts +1 -1
- package/dist/app/saved/use-favorite.d.ts +1 -1
- package/dist/app/search/messages.d.ts +2 -2
- 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/auth-provider.d.ts +3 -2
- package/dist/auth/auth-provider.js +8 -5
- package/dist/auth/messages.d.ts +2 -2
- package/dist/auth/native-sign-in.d.ts +11 -0
- package/dist/auth/native-sign-in.js +11 -0
- package/dist/calls/messages.d.ts +2 -2
- package/dist/chat/messages.d.ts +2 -2
- package/dist/compact-table/messages.d.ts +2 -2
- package/dist/data-grid/column-spec.d.ts +1 -1
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/format/messages.d.ts +2 -2
- package/dist/forms/messages.d.ts +2 -2
- package/dist/inline-child-table/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/live/messages.d.ts +2 -2
- package/dist/mailbox/messages.d.ts +2 -2
- package/dist/mentions/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +1 -1
- package/dist/mocks/invoices.d.ts +2 -2
- package/dist/mocks/orders.d.ts +2 -2
- 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/plugins/before-sign-in.d.ts +1 -1
- package/dist/plugins/messages.d.ts +2 -2
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-XnRBgIm3.js → account-page-9Aq9kvrG.js} +2 -2
- package/dist/shell/assets/app-BnDutf0s.js +34 -0
- package/dist/shell/assets/{app-BdzxOK1l.css → app-DcrDZ6Fc.css} +1 -1
- package/dist/shell/assets/{assistant-shell-B0UOjO9j.js → assistant-shell-BGtjYwwY.js} +2 -2
- package/dist/shell/assets/{board-display-82tI8eop.js → board-display-Ck6nnv4b.js} +2 -2
- package/dist/shell/assets/{calendar-display-DdVa8wHA.js → calendar-display-DKXi1P_o.js} +2 -2
- package/dist/shell/assets/{call-rings-CtUeFpjU.js → call-rings-Bs9dtURX.js} +2 -2
- package/dist/shell/assets/{calls-Joul8uMN.js → calls-DR-Ci2ND.js} +2 -2
- package/dist/shell/assets/{circle-alert-CKfEY2eG.js → circle-alert-C0Jeesr7.js} +2 -2
- package/dist/shell/assets/{composed-page-BRTMBrpL.js → composed-page-Bdzzzuyj.js} +2 -2
- package/dist/shell/assets/{composer-section-DAIjBfXV.js → composer-section-rLoyhseD.js} +2 -2
- package/dist/shell/assets/{connect-route-DApl7e0e.js → connect-route-B9xNNieq.js} +2 -2
- package/dist/shell/assets/{copy-field-BHZX0DSt.js → copy-field-DkCyHPwg.js} +2 -2
- package/dist/shell/assets/{create-route-V5JNc_Kq.js → create-route-DBrv5Kqi.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-DC27oiuQ.js → custom-step-container-field-Do5pWJ_q.js} +2 -2
- package/dist/shell/assets/{embedded-list-DAjlopsR.js → embedded-list-CPgxhzPw.js} +3 -3
- package/dist/shell/assets/{export-dialog-Co7gghJ9.js → export-dialog-CovrAwYy.js} +2 -2
- package/dist/shell/assets/{graph-view-D7yvxu1M.js → graph-view-BfRhAOfb.js} +2 -2
- package/dist/shell/assets/{group-donut-BrffJgvP.js → group-donut-DC8GLnC8.js} +2 -2
- package/dist/shell/assets/{guest-call-page-B0thHXzD.js → guest-call-page-Dc8M5yz6.js} +3 -3
- package/dist/shell/assets/{html-viewer-BbtenCM5.js → html-viewer-DH_s-gLB.js} +2 -2
- package/dist/shell/assets/{import-dialog-Q-qqFWmI.js → import-dialog-Ge24RdwQ.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-CEDYy6gW.js → import-table-dialog-D1aVXF3R.js} +2 -2
- package/dist/shell/assets/{index-ygoGHYZq.js → index-Bi_Jks-d.js} +1 -1
- package/dist/shell/assets/{invitations-page-DZ_oGyRY.js → invitations-page-CFwYUoqb.js} +2 -2
- package/dist/shell/assets/{layout-grid-DV6ebMSb.js → layout-grid-DCBxzjaE.js} +2 -2
- package/dist/shell/assets/{legend-item-ClY5HSFP.js → legend-item-BZXnHPzh.js} +2 -2
- package/dist/shell/assets/{list-page-CxylG_Bi.js → list-page-DwIEEzTz.js} +4 -4
- package/dist/shell/assets/{maplibre-BIJVsLGQ.js → maplibre-C7kZagL3.js} +2 -2
- package/dist/shell/assets/{markdown-content-B-r0DBG0.js → markdown-content-DMl-cVjQ.js} +2 -2
- package/dist/shell/assets/{members-page-UU96y7EQ.js → members-page-BfrzLCXo.js} +2 -2
- package/dist/shell/assets/{messages-03zmq2oA.js → messages-D5XhIbDz.js} +2 -2
- package/dist/shell/assets/{organization-page-Bj3c9EW9.js → organization-page-DxA2154P.js} +2 -2
- package/dist/shell/assets/{organizations-page-Cwn2LlFj.js → organizations-page-Bf4oXbvZ.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-JzQ9tOn_.js → pending-invitation-row-BIO4J3ts.js} +2 -2
- package/dist/shell/assets/{period-chart-CWBy03F7.js → period-chart-CoT2IDzy.js} +2 -2
- package/dist/shell/assets/{person-row-BJP4ag6H.js → person-row-DBeHOA2K.js} +2 -2
- package/dist/shell/assets/{public-form-page-Ct45rBwR.js → public-form-page-Dhinql3j.js} +2 -2
- package/dist/shell/assets/{record-lines-DCs-txvG.js → record-lines-Dmb8bl38.js} +2 -2
- package/dist/shell/assets/{record-map-BMZTdCJn.js → record-map-BR34Q9uI.js} +2 -2
- package/dist/shell/assets/{record-opens-DQrqEFru.js → record-opens-Dbjd4FLe.js} +2 -2
- package/dist/shell/assets/{record-page-C6tevfpa.js → record-page-Dnpo_8uE.js} +3 -3
- package/dist/shell/assets/{record-preview-Bqm2whUV.js → record-preview-CarOT-Gn.js} +2 -2
- package/dist/shell/assets/{records-map-Dq1fZ0Ll.js → records-map-CXanq-qN.js} +2 -2
- package/dist/shell/assets/{render-node-DQMrGelM.js → render-node-DGYXKoGV.js} +3 -3
- package/dist/shell/assets/{reorder-button-C8G3bjeB.js → reorder-button-9_dAk_3O.js} +2 -2
- package/dist/shell/assets/{run-trace-view-BoSTWwYy.js → run-trace-view-D1DZCrDs.js} +2 -2
- package/dist/shell/assets/{runner-install-field-BcduhfGA.js → runner-install-field-C2XhrG0M.js} +2 -2
- package/dist/shell/assets/{runtime-update-BRoaUFOx.js → runtime-update-C5TxLpYf.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-Ck4mYbeU.js → shared-protobase-ui-HnfzBwws.js} +1 -1
- package/dist/shell/assets/{sheet-source-RncsoczT.js → sheet-source-DqFYbJpm.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-azN2k0xv.js → sign-in-policy-page-vjGTg9Do.js} +2 -2
- package/dist/shell/assets/{start-block-queries-kp3ICAXt.js → start-block-queries-CmVDv8_F.js} +2 -2
- package/dist/shell/assets/{step-catalog-QFTLEUUW.js → step-catalog-PWiIgJSI.js} +2 -2
- package/dist/shell/assets/{step-panel-CcBoYcad.js → step-panel-TfW-31Gv.js} +2 -2
- package/dist/shell/assets/{timeline-display-Cr61_SZU.js → timeline-display-eBf3tuig.js} +2 -2
- package/dist/shell/assets/{trash-Bb3IsZeK.js → trash-BjnGkZfx.js} +2 -2
- package/dist/shell/assets/{update-set-D8rImCxw.js → update-set-BahNKmxv.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-DP_MzXTz.js → use-calendar-move-Bfp2yC0P.js} +2 -2
- package/dist/shell/assets/{use-display-rows-3xQM1gvv.js → use-display-rows-DsBBYuKB.js} +2 -2
- package/dist/shell/assets/{use-paged-search-DcNUhIL9.js → use-paged-search-DaT4uUhX.js} +2 -2
- package/dist/shell/assets/{use-run-trace-B9v2XkVL.js → use-run-trace-DHk7l8MX.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-DZZERjMt.js → use-workflow-page-DPIhXcnb.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-BRe2O0QF.js → use-workflow-types-Bp8iqkBg.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-Be_DnY83.js → workflow-canvas-CiGUTx4K.js} +2 -2
- package/dist/shell/assets/{workflow-field-D3BW-Lvk.js → workflow-field-lqBx3RDj.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-J0pJUxAk.js → workflow-graph-editor-DgufTFii.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-DCoSJYVl.js → workflow-run-field-C4BtvPnB.js} +3 -3
- package/dist/shell/assets/{workflow-status-field-btxWS0rc.js → workflow-status-field-CqDaP0V9.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-lBJ6-WBD.js → workflow-workbench-CgL6wHPG.js} +2 -2
- 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-XnRBgIm3.js.map → account-page-9Aq9kvrG.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-BnDutf0s.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-B0UOjO9j.js.map → assistant-shell-BGtjYwwY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-82tI8eop.js.map → board-display-Ck6nnv4b.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-DdVa8wHA.js.map → calendar-display-DKXi1P_o.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-CtUeFpjU.js.map → call-rings-Bs9dtURX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-Joul8uMN.js.map → calls-DR-Ci2ND.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-CKfEY2eG.js.map → circle-alert-C0Jeesr7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-BRTMBrpL.js.map → composed-page-Bdzzzuyj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-DAIjBfXV.js.map → composer-section-rLoyhseD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-DApl7e0e.js.map → connect-route-B9xNNieq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-BHZX0DSt.js.map → copy-field-DkCyHPwg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-V5JNc_Kq.js.map → create-route-DBrv5Kqi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-DC27oiuQ.js.map → custom-step-container-field-Do5pWJ_q.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-DAjlopsR.js.map → embedded-list-CPgxhzPw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-Co7gghJ9.js.map → export-dialog-CovrAwYy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-D7yvxu1M.js.map → graph-view-BfRhAOfb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-BrffJgvP.js.map → group-donut-DC8GLnC8.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-B0thHXzD.js.map → guest-call-page-Dc8M5yz6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-BbtenCM5.js.map → html-viewer-DH_s-gLB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-Q-qqFWmI.js.map → import-dialog-Ge24RdwQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-CEDYy6gW.js.map → import-table-dialog-D1aVXF3R.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-DZ_oGyRY.js.map → invitations-page-CFwYUoqb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-DV6ebMSb.js.map → layout-grid-DCBxzjaE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-ClY5HSFP.js.map → legend-item-BZXnHPzh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-CxylG_Bi.js.map → list-page-DwIEEzTz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-BIJVsLGQ.js.map → maplibre-C7kZagL3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-B-r0DBG0.js.map → markdown-content-DMl-cVjQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-UU96y7EQ.js.map → members-page-BfrzLCXo.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-03zmq2oA.js.map → messages-D5XhIbDz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-Bj3c9EW9.js.map → organization-page-DxA2154P.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-Cwn2LlFj.js.map → organizations-page-Bf4oXbvZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-JzQ9tOn_.js.map → pending-invitation-row-BIO4J3ts.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-CWBy03F7.js.map → period-chart-CoT2IDzy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-BJP4ag6H.js.map → person-row-DBeHOA2K.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-Ct45rBwR.js.map → public-form-page-Dhinql3j.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-DCs-txvG.js.map → record-lines-Dmb8bl38.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-BMZTdCJn.js.map → record-map-BR34Q9uI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-DQrqEFru.js.map → record-opens-Dbjd4FLe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-C6tevfpa.js.map → record-page-Dnpo_8uE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-Bqm2whUV.js.map → record-preview-CarOT-Gn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-Dq1fZ0Ll.js.map → records-map-CXanq-qN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-DQMrGelM.js.map → render-node-DGYXKoGV.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-C8G3bjeB.js.map → reorder-button-9_dAk_3O.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-BoSTWwYy.js.map → run-trace-view-D1DZCrDs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-BcduhfGA.js.map → runner-install-field-C2XhrG0M.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-BRoaUFOx.js.map → runtime-update-C5TxLpYf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-RncsoczT.js.map → sheet-source-DqFYbJpm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-azN2k0xv.js.map → sign-in-policy-page-vjGTg9Do.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-kp3ICAXt.js.map → start-block-queries-CmVDv8_F.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-QFTLEUUW.js.map → step-catalog-PWiIgJSI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-CcBoYcad.js.map → step-panel-TfW-31Gv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-Cr61_SZU.js.map → timeline-display-eBf3tuig.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-Bb3IsZeK.js.map → trash-BjnGkZfx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-D8rImCxw.js.map → update-set-BahNKmxv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-DP_MzXTz.js.map → use-calendar-move-Bfp2yC0P.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-3xQM1gvv.js.map → use-display-rows-DsBBYuKB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-DcNUhIL9.js.map → use-paged-search-DaT4uUhX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-B9v2XkVL.js.map → use-run-trace-DHk7l8MX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-DZZERjMt.js.map → use-workflow-page-DPIhXcnb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-BRe2O0QF.js.map → use-workflow-types-Bp8iqkBg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-Be_DnY83.js.map → workflow-canvas-CiGUTx4K.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-D3BW-Lvk.js.map → workflow-field-lqBx3RDj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-J0pJUxAk.js.map → workflow-graph-editor-DgufTFii.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-DCoSJYVl.js.map → workflow-run-field-C4BtvPnB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-btxWS0rc.js.map → workflow-status-field-CqDaP0V9.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-lBJ6-WBD.js.map → workflow-workbench-CgL6wHPG.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/tokens.css +10 -10
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
- package/dist/shell/assets/app-p7iRIIoG.js +0 -34
- package/dist/shell-source-maps/assets/app-p7iRIIoG.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
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{Aa as r,Bo as i,Ga as a,Go as o,Qs as s,Rc as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,ds as m,qa as h,vo as g}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Aa as r,Bo as i,Ga as a,Go as o,Qs as s,Rc as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,ds as m,qa as h,vo as g}from"./app-BnDutf0s.js";import{o as _}from"./vendor-DQHyyBk1.js";import{t as v}from"./page-header-Ddz2r5ic.js";import{n as y,t as b}from"./person-row-DBeHOA2K.js";var x=e(t(),1),S=e(n(),1),C=e=>e?.role===`owner`?[`owner`,`admin`,`member`]:[`admin`,`member`],w=({member:e,current:t,status:n,presence:r,onChanged:i})=>{let{session:o,organizations:s}=p(),c=t.organization.id,{busy:l,error:m,run:_}=u(),v=s?.roles??[],x=e.id===t.memberId,w=C(t),T=e.role===`owner`&&t.role!==`owner`,E=v.filter(e=>e.membership);return(0,S.jsx)(b,{name:e.name,email:e.email,self:x,error:m,...(n||r)&&{status:(0,S.jsx)(g,{status:n,presence:r})},actions:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`select`,{"aria-label":f(`roleOf`,{name:e.name}),value:e.role,disabled:l||T,onChange:t=>void _(async()=>{await o.organizations.setRole(c,e.id,t.target.value),i()}),className:`h-7 rounded-md border border-border-strong bg-background px-2 text-body`,children:(T?[e.role]:w).map(e=>(0,S.jsx)(`option`,{value:e,children:h(e)},e))}),!x&&(0,S.jsx)(d,{size:`sm`,variant:`danger`,loading:l,disabled:T,onClick:()=>void _(async()=>{await o.organizations.removeMember(c,e.id),i()}),children:f(`remove`)})]}),children:(0,S.jsx)(y,{roles:E,selected:e.appRoles,grantable:a(v,t),disabled:l,onChange:t=>void _(async()=>{await o.organizations.setAppRoles(e.id,t),i()})})})},T=({current:e,statuses:t,presence:n})=>{let{session:a}=p(),u=e?.organization?.id,d=_({queryKey:c.organizationMembers(u??``),queryFn:()=>a.organizations.members(u),enabled:!!u,retry:!1}),h=d.data,g=d.error?d.error instanceof m?o(d.error):f(`couldNotReadMembers`):void 0,{refetch:y}=d,b=(0,x.useCallback)(()=>void y(),[y]);return e?.organization?(0,S.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,S.jsx)(v,{title:f(`members`),subtitle:f(`whoWorks`,{organization:e.organization.name})}),(0,S.jsxs)(i,{title:f(`members`),description:f(`membersDescription`),children:[(0,S.jsx)(l,{message:g}),h?(0,S.jsx)(`ul`,{className:`divide-y rounded-md border`,children:h.map(i=>(0,S.jsx)(w,{member:i,current:e,status:t?.find(e=>e.userId===i.userId),presence:r(n,i.userId),onChanged:b},`${i.id}/${i.role}/${i.appRoles.join()}`))}):!g&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,S.jsx)(s,{}),` `,f(`loading`)]})]})]}):null};export{T as MembersPage,C as assignableOrganizationRoles};
|
|
2
|
+
//# debugId=5faf32c2-5e80-4341-b754-598cdc29d5ba
|
|
@@ -1,2 +1,2 @@
|
|
|
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{Ca as e,Fs as t,Jc as n,Mi as r,Ml as i,Nl as a,Ui as o,tl as s,ui as c,zc as l}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Ca as e,Fs as t,Jc as n,Mi as r,Ml as i,Nl as a,Ui as o,tl as s,ui as c,zc as l}from"./app-BnDutf0s.js";var u=(t,n)=>{let r=t.position;if(!r||!e(n,`update`))return;let i=t.fields[r.field];return i&&!i.readOnly?r.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,i)=>{if(t===void 0||e?.list?.drag?.rank!==!0||i!==``)return!1;let a=r(n);return a.columnId===t&&a.direction===`asc`},m=l(`app/hand-order`),h=(e,n,{title:r,place:i})=>!t(e)||e.status!==412?{state:`error`,title:n,description:c(e)}:r===void 0?{state:`warning`,title:n,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:o(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(e,t,r,c)=>{let l=t.position?.after;if(!l)return{after:[],before:[]};let u=t.primaryKey[0],d=o(t,c),f=e=>s([e]),p=await _(e,l.resource,v(a(i.or(i.eq(l.field,d),i.eq(l.key,d))),l.filter)),m=(e,t)=>p.flatMap(n=>f(n[e])===f(d)&&f(n[t])!==f(d)?[n[t]]:[]),h=m(l.field,l.key),g=m(l.key,l.field),[y,b]=await Promise.all([_(e,t.name,v(a(i.in(u,[d,...h])),l.while)),g.length===0?[]:_(e,t.name,a(i.in(u,g)))]),x=e=>{let i=s(o(t,e));return{key:i,rank:e[t.position.field],title:n(t,r,e,i)}},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 s=t=>r[t]?o(e,r[t]):null,c=a&&i===r.length-1;return{op:`move`,resource:e.name,field:t,key:o(e,r[i]),after:s(i-1),...!c&&{before:s(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=l(`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=f95e121b-0f39-4e66-8260-e1f778535a02
|
|
@@ -1,2 +1,2 @@
|
|
|
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{$o as r,Bo as i,Ea as a,Js as o,Ka as s,M as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,po as m,qa as h,ts as g}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{$o as r,Bo as i,Ea as a,Js as o,Ka as s,M as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,po as m,qa as h,ts as g}from"./app-BnDutf0s.js";import{t as _}from"./page-header-Ddz2r5ic.js";var v=e(t(),1),y=e(n(),1),b=({organization:e,editable:t,onSaved:n})=>{let{session:r}=p(),[a,o]=(0,v.useState)(e.name),[s,c]=(0,v.useState)(e.slug),{busy:h,error:g,run:_}=u(),b=a.trim()!==e.name||s!==e.slug;return(0,y.jsxs)(i,{title:f(`details`),description:f(t?`detailsEditable`:`detailsReadOnly`),children:[(0,y.jsx)(l,{message:g}),(0,y.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:t=>{t.preventDefault(),_(async()=>{await r.organizations.rename(e.id,{name:a.trim(),slug:s}),n()})},children:[(0,y.jsx)(m,{"aria-label":f(`name`),value:a,disabled:!t,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`}),(0,y.jsx)(m,{"aria-label":f(`slug`),value:s,disabled:!t,onChange:e=>c(e.target.value),wrapperClassName:`sm:w-48`}),t&&(0,y.jsx)(d,{type:`submit`,variant:`primary`,loading:h,disabled:!b||!a.trim(),children:f(`save`)})]})]})},x=({organization:e,memberId:t})=>{let{session:n}=p(),[r,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(``),{busy:c,error:m,run:h}=u();return(0,v.useEffect)(()=>{n.organizations.members(e.id).then(e=>a(e.filter(e=>e.id!==t)),()=>a([]))},[n,e.id,t]),(0,y.jsxs)(i,{title:f(`handOver`),description:f(`handOverDescription`),children:[(0,y.jsx)(l,{message:m}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,y.jsxs)(`select`,{"aria-label":f(`newOwner`),value:o,onChange:e=>s(e.target.value),className:`h-8 flex-1 rounded-md border border-border-strong bg-background px-2`,children:[(0,y.jsx)(`option`,{value:``,children:f(`chooseMember`)}),r.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),(0,y.jsx)(d,{loading:c,disabled:!o,onClick:()=>void h(async()=>{await n.organizations.transferOwnership(o),window.location.reload()}),children:f(`handOver`)})]})]})},S=({organization:e,basePath:t})=>{let{session:n}=p(),[r,s]=(0,v.useState)(!1),[c,h]=(0,v.useState)(``),{busy:g,error:_,run:b}=u(),x=()=>b(async()=>{await n.organizations.remove(e.id),a(t)});return(0,y.jsxs)(i,{title:f(`deleteOrganization`),description:f(`deleteDescription`),children:[(0,y.jsx)(l,{message:r?void 0:_}),(0,y.jsx)(d,{variant:`danger`,onClick:()=>s(!0),children:f(`deleteOrganization`)}),r&&(0,y.jsxs)(o,{title:f(`deleteTitle`,{name:e.name}),description:f(`deleteConfirm`),onClose:()=>s(!1),actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{onClick:()=>s(!1),children:f(`cancel`)}),(0,y.jsx)(d,{variant:`danger`,loading:g,disabled:c!==e.name,onClick:()=>void x(),children:f(`delete`)})]}),children:[(0,y.jsx)(l,{message:_}),(0,y.jsx)(m,{"aria-label":f(`organizationName`),value:c,onChange:e=>h(e.target.value)})]})]})},C=({editable:e})=>{let t=g(),[n,r]=(0,v.useState)(),{busy:a,error:o,run:s}=u();return(0,v.useEffect)(()=>{t.callGuests.allowed().then(r)},[t]),n===void 0?null:(0,y.jsxs)(i,{title:f(`guestLinks`),description:f(`guestLinksDescription`),children:[(0,y.jsx)(l,{message:o}),(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,y.jsx)(c,{checked:n,label:f(`guestLinksAllowed`),...e&&!a&&{onChange:e=>void s(async()=>{await t.callGuests.setAllowed(e),r(e)})}}),f(`guestLinksAllowed`)]})]})},w=({organization:e,basePath:t,owner:n})=>{let{session:r}=p(),{busy:o,error:s,run:c}=u();return(0,y.jsxs)(i,{title:f(`leave`),description:f(n?`leaveOwner`:`leaveMember`),children:[(0,y.jsx)(l,{message:s}),(0,y.jsx)(d,{loading:o,onClick:()=>void c(async()=>{await r.organizations.leave(e.id),a(t)}),children:f(`leaveName`,{name:e.name})})]})},T=({current:e,basePath:t,onChanged:n})=>{let i=r().data?.calls===!0,a=e?.organization;if(!a)return(0,y.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 md:px-6`,children:(0,y.jsx)(_,{title:f(`organization`),subtitle:f(`noOrganization`)})});let o=e.role===`owner`;return(0,y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,y.jsx)(_,{title:a.name,subtitle:e.role?f(`youAre`,{role:h(e.role).toLowerCase()}):f(`throughGlobalRoles`)}),(0,y.jsx)(b,{organization:a,editable:s(e),onSaved:n},`${a.name}/${a.slug}`),i&&e.role&&(0,y.jsx)(C,{editable:s(e)}),o&&e.memberId&&(0,y.jsx)(x,{organization:a,memberId:e.memberId}),e.role&&(0,y.jsx)(w,{organization:a,basePath:t,owner:o}),o&&(0,y.jsx)(S,{organization:a,basePath:t})]})};export{T as OrganizationPage};
|
|
2
|
+
//# debugId=f1036d79-e0f8-4836-a25c-fa12c0ad38e2
|
|
@@ -1,2 +1,2 @@
|
|
|
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{Ba as r,Bo as i,Ea as a,Hc as o,Ja as s,Uo as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,po as m}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Ba as r,Bo as i,Ea as a,Hc as o,Ja as s,Uo as c,Vo as l,Wa as u,Xs as d,Ya as f,cs as p,po as m}from"./app-BnDutf0s.js";import{t as h}from"./page-header-Ddz2r5ic.js";import{n as g,t as _}from"./use-paged-search-DaT4uUhX.js";var v=e(t(),1),y=e(n(),1),b=({organization:e,current:t,busy:n,onOpen:r})=>(0,y.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.slug})]}),t?(0,y.jsx)(c,{tone:`green`,children:f(`current`)}):(0,y.jsx)(d,{size:`sm`,loading:n,onClick:r,children:f(`open`)})]}),x=({basePath:e,currentId:t})=>{let{session:n}=p(),[r,i]=(0,v.useState)(``),o=(0,v.useCallback)((e,t)=>n.organizations.search(e,t).then(e=>({items:e.organizations,total:e.total})),[n]),s=_(o,r),{busy:c,error:l,run:d}=u();return(0,y.jsx)(g,{title:f(`allOrganizations`),description:f(`allOrganizationsDescription`),searchLabel:f(`findOrganization`),placeholder:f(`nameOrSlug`),query:r,onQuery:i,list:s,error:l,renderRow:r=>(0,y.jsx)(b,{organization:r,current:r.id===t,busy:c,onOpen:()=>void d(async()=>{await n.organizations.switchTo(r.id),a(e)})},r.id)})},S=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,63),C=({basePath:e})=>{let{session:t}=p(),[n,r]=(0,v.useState)(``),[o,s]=(0,v.useState)(),{busy:c,error:h,run:g}=u(),_=()=>g(async()=>{await t.organizations.create({name:n.trim(),slug:o??S(n)}),a(e)});return(0,y.jsxs)(i,{title:f(`newOrganization`),description:f(`newOrganizationDescription`),children:[(0,y.jsx)(l,{message:h}),(0,y.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,y.jsx)(m,{"aria-label":f(`name`),placeholder:f(`name`),value:n,onChange:e=>r(e.target.value),wrapperClassName:`flex-1`}),(0,y.jsx)(m,{"aria-label":f(`slug`),placeholder:`slug`,value:o??S(n),onChange:e=>s(e.target.value),wrapperClassName:`sm:w-48`}),(0,y.jsx)(d,{type:`submit`,variant:`primary`,loading:c,disabled:!n.trim(),children:f(`create`)})]})]})},w=({basePath:e})=>{let{session:t,organizations:n}=p(),[r,c]=(0,v.useState)([]),{busy:m,error:h,run:g}=u();if((0,v.useEffect)(()=>{t.organizations.myInvitations().then(c,()=>c([]))},[t]),r.length===0)return null;let _=n?.roles??[],b=n=>g(async()=>{await t.organizations.acceptMine(n),a(e)});return(0,y.jsxs)(i,{title:f(`invitationsForYou`),description:f(`invitationsForYouDescription`),children:[(0,y.jsx)(l,{message:h}),(0,y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:r.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`span`,{className:`font-medium`,children:e.organizationName??f(`anOrganization`)}),`: `,e.appRoles.map(e=>s(_,e)).join(`, `)||f(`noAppRoles`),(0,y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:f(`until`,{date:new Date(e.expiresAt).toLocaleDateString(o())})})]}),(0,y.jsx)(d,{size:`sm`,variant:`primary`,loading:m,onClick:()=>void b(e.id),children:f(`accept`)})]},e.id))})]})},T=({state:e,basePath:t})=>{let{session:n,organizations:o,state:s}=p(),{busy:c,error:d,run:m}=u(),g=s.kind===`signed-in`?s.user:void 0,_=o?.create===`everyone`||g!==void 0&&r(g),v=e.current?.organization?.id;return(0,y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,y.jsx)(h,{title:f(`organizations`),subtitle:f(`organizationsSubtitle`)}),(0,y.jsxs)(i,{title:f(`yourOrganizations`),description:e.organizations.length>0?f(`memberOf`):f(`notMember`),children:[(0,y.jsx)(l,{message:d??e.error}),e.organizations.length>0&&(0,y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.organizations.map(e=>(0,y.jsx)(b,{organization:e,current:e.id===v,busy:c,onOpen:()=>void m(async()=>{await n.organizations.switchTo(e.id),a(t)})},e.id))})]}),(0,y.jsx)(w,{basePath:t}),_&&(0,y.jsx)(C,{basePath:t}),(e.current?.globalRoles.length??0)>0&&(0,y.jsx)(x,{basePath:t,currentId:v})]})};export{T as OrganizationsPage};
|
|
2
|
+
//# debugId=5fe285db-bd9c-4f42-918c-a0e275a36627
|
package/dist/shell/assets/{pending-invitation-row-JzQ9tOn_.js → pending-invitation-row-BIO4J3ts.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
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{Bo as r,Hc as i,Vo as a,Wa as o,Xs as s,po as c,zc as l}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Bo as r,Hc as i,Vo as a,Wa as o,Xs as s,po as c,zc as l}from"./app-BnDutf0s.js";var u=e(t(),1),d=l(`invitations`),f=e(n(),1),p=({link:e})=>e?(0,f.jsx)(`p`,{className:`mt-3 break-all rounded-md border bg-muted px-3 py-2 text-xs`,children:d.rich(`passLinkOn`,{link:(0,f.jsx)(`span`,{className:`font-mono`,children:e})})}):null,m=({title:e,description:t,onInvite:n,beside:i,children:l,incomplete:m=!1})=>{let[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(),{busy:y,error:b,run:x}=o(),S=()=>x(async()=>{v((await n(h.trim())).link),g(``)});return(0,f.jsxs)(r,{title:e,description:t,children:[(0,f.jsx)(a,{message:b}),(0,f.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,f.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,f.jsx)(c,{"aria-label":d(`email`),type:`email`,placeholder:`name@example.com`,value:h,onChange:e=>g(e.target.value),wrapperClassName:`flex-1`}),i,(0,f.jsx)(s,{type:`submit`,variant:`primary`,loading:y,disabled:!h.trim()||m,children:d(`invite`)})]}),l]}),(0,f.jsx)(p,{link:_})]})},h=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:c})=>{let[l,m]=(0,u.useState)(),{busy:h,error:g,run:_}=o(),v=new Date(n).getTime()<Date.now();return(0,f.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(`span`,{className:`block truncate font-medium`,children:e}),(0,f.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t,` · `,v?d(`expired`):d(`until`,{date:new Date(n).toLocaleDateString(i())})]})]}),(0,f.jsx)(s,{size:`sm`,loading:h,onClick:()=>void _(async()=>m((await r()).link)),children:d(`sendAgain`)}),(0,f.jsx)(s,{size:`sm`,variant:`danger`,loading:h,onClick:()=>void _(c),children:d(`revoke`)})]}),(0,f.jsx)(a,{message:g}),(0,f.jsx)(p,{link:l})]})};export{m as n,h as t};
|
|
2
|
+
//# debugId=483b8277-b6cb-4862-bf5e-72b57227b103
|
|
@@ -1,2 +1,2 @@
|
|
|
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{Hc as r,No as i,fa as a,ma as o,pa as s}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Hc as r,No as i,fa as a,ma as o,pa as s}from"./app-BnDutf0s.js";import{bt as c,vt as l}from"./embedded-list-CPgxhzPw.js";import{a as u,c as d,d as f,f as p,i as m,n as h,o as g,r as _,s as v,u as y}from"./lib-recharts-B1lKFZ5P.js";import{t as b}from"./legend-item-BZXnHPzh.js";var x=e(t(),1),S=864e5,C={day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`,hour12:!1},w={day:`numeric`,month:`short`,year:`numeric`},T={day:`numeric`,month:`short`},E={minute:C,"5_minutes":C,"15_minutes":C,hour:C,day:w,year:{year:`numeric`}},D=e=>o(`period:${JSON.stringify(e)}`,t=>new Intl.DateTimeFormat(t,{...e,timeZone:`UTC`})),O=(e,t)=>{let n=new Date(e);if(t===`day`)return e+S;if(t===`week`)return e+7*S;if(t===`month`)return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1);if(t===`year`)return Date.UTC(n.getUTCFullYear()+1,0,1)},k=(e,t,n)=>{let r=O(e,t);return e<=n&&r!==void 0&&n<r},A=(e,t,n)=>{if(k(e,t,n)){if(t===`day`)return c(`today`);let r=new Date(e).getUTCFullYear()===new Date(n).getUTCFullYear();return c(`toToday`,{start:D(r?T:w).format(e)})}let r=E[t];if(r)return D(r).format(e);let i=O(e,t);if(i===void 0)throw Error(`A ${t} bucket has no period to name`);return D(w).formatRange(e,i-S)},j=e(n(),1),M=({points:e,measure:t,bucket:n,now:r,series:i})=>{let a=i??[],o=!i||t.kind===`count`||t.kind===`sum`;return(0,j.jsx)(`div`,{className:`sr-only`,children:(0,j.jsxs)(`table`,{children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{scope:`col`,children:c(`period`)}),a.map(e=>(0,j.jsx)(`th`,{scope:`col`,children:e.label},e.key)),o&&(0,j.jsx)(`th`,{scope:`col`,children:c(t.kind)})]})}),(0,j.jsx)(`tbody`,{children:e.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{scope:`row`,children:A(e.at,n,r)}),a.map(n=>(0,j.jsx)(`td`,{children:l(e[n.key]??null,n.measure??t)},n.key)),o&&(0,j.jsx)(`td`,{children:l(e.value,t)})]},e.at))})]})})},N={hour:`2-digit`,minute:`2-digit`,hour12:!1},P={day:`numeric`,month:`short`,...N},F={minute:N,"5_minutes":N,"15_minutes":N,hour:N,day:{day:`numeric`,month:`short`},week:{day:`numeric`,month:`short`},month:{month:`short`,year:`2-digit`},year:{year:`numeric`}},I=e=>{let t=new Intl.DateTimeFormat(r(),{...e,timeZone:`UTC`});return e=>t.format(e)},L={fontSize:`0.6875rem`,fill:`var(--muted-foreground)`},R=864e5,z=new Set([`minute`,`5_minutes`,`15_minutes`,`hour`]),B=(e,t)=>{let n=t.length>1?t.at(-1).at-t[0].at:0;return z.has(e)&&n>=R?P:F[e]},V=()=>{let e=Date.now();return e+s(e,a())},H=({active:e,payload:t,measure:n,bucket:r,now:i,series:a})=>{let o=t?.[0]?.payload;return!e||!o?null:(0,j.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,j.jsx)(`div`,{className:`text-muted-foreground`,children:A(o.at,r,i)}),a?.map(e=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:e.color},"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,j.jsx)(`span`,{className:`font-semibold tabular-nums`,children:l(o[e.key]??null,e.measure??n)})]},e.key)),a&&(n.kind===`count`||n.kind===`sum`)&&(0,j.jsx)(`div`,{className:`mt-0.5 border-t pt-0.5 font-semibold tabular-nums`,children:l(o.value,n)}),!a&&(0,j.jsx)(`div`,{className:`font-semibold tabular-nums`,children:l(o.value,n)})]})},U=e=>({fillOpacity:.35,stroke:e,strokeWidth:1.5,strokeDasharray:`3 2`}),W=`[&_.recharts-surface]:rounded-sm [&_.recharts-surface:focus-visible]:outline-2 [&_.recharts-surface:focus-visible]:outline-offset-2 [&_.recharts-surface:focus-visible]:outline-primary`,G=({points:e,measure:t,bucket:n,type:a,series:o,resource:s,view:l,compact:S})=>{let C=i(`(min-width: 640px)`),[w,T]=(0,x.useState)(!1),E=V(),D=e.findIndex(e=>k(e.at,n,E)),O=I(B(n,e)),A=(0,j.jsx)(d,{vertical:!1,stroke:`var(--border)`}),N=(0,j.jsx)(u,{dataKey:`at`,tickFormatter:O,tick:L,axisLine:!1,tickLine:!1,minTickGap:C?24:40,height:18}),P=(0,j.jsx)(m,{width:C?48:36,tick:L,axisLine:!1,tickLine:!1,tickCount:3,tickFormatter:e=>e.toLocaleString(r(),{notation:`compact`})}),F=(0,j.jsx)(f,{...w&&{active:!1},cursor:a===`bar`?{fill:`var(--muted)`}:{stroke:`var(--border-strong)`},content:(0,j.jsx)(H,{measure:t,bucket:n,now:E,...o&&{series:o}}),isAnimationActive:!1}),R=o??[{key:`value`,label:``,color:`var(--chart-1)`}],z=t=>({cx:n,cy:r,index:i})=>n===void 0||r===void 0?null:i===D?(0,j.jsx)(`circle`,{cx:n,cy:r,r:3.5,fill:`var(--background)`,stroke:t,strokeWidth:2}):e.length<=31?(0,j.jsx)(`circle`,{cx:n,cy:r,r:3,fill:t}):null,G=e=>T(e.key===`Escape`),K=()=>T(!1),q={"aria-label":c(`chartKeys`)},J=(0,j.jsxs)(`div`,{className:`${S?`h-24`:`h-40`} ${W}`,onKeyDown:G,onPointerMove:K,onFocus:K,children:[(0,j.jsx)(p,{width:`100%`,height:`100%`,children:a===`line`?(0,j.jsxs)(_,{data:e,margin:{top:6,right:6,bottom:0,left:0},...q,children:[A,N,P,F,R.map(e=>(0,j.jsx)(v,{dataKey:e.key,stroke:e.color,strokeWidth:2,dot:z(e.color),activeDot:{r:4,stroke:`var(--background)`,strokeWidth:2},isAnimationActive:!1},e.key))]}):(0,j.jsxs)(h,{data:e,margin:{top:6,right:0,bottom:0,left:0},barCategoryGap:`22%`,...q,children:[A,N,P,F,R.map((t,n)=>(0,j.jsx)(g,{dataKey:t.key,fill:t.color,...o&&{stackId:`split`},radius:n===R.length-1?[4,4,0,0]:0,isAnimationActive:!1,children:e.map((e,n)=>(0,j.jsx)(y,{...n===D&&U(t.color)},e.at))},t.key))]})}),(0,j.jsx)(M,{points:e,measure:t,bucket:n,now:E,...o&&{series:o}})]});return!o||s===void 0?J:(0,j.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[J,(0,j.jsx)(`ul`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-sm`,children:o.map(e=>(0,j.jsx)(b,{resource:s,view:l,color:e.color,label:e.label,...e.filter!==void 0&&{filter:e.filter}},e.key))})]})};export{G as PeriodChart};
|
|
2
|
+
//# debugId=a84f6203-cf20-4e6c-afe0-70b038d0cc45
|
|
@@ -1,2 +1,2 @@
|
|
|
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{t}from"./react-CuiNlnus.js";import{Vo as n,Xa as r,Ya as i,jc as a}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{t}from"./react-CuiNlnus.js";import{Vo as n,Xa as r,Ya as i,jc as a}from"./app-BnDutf0s.js";var o=e(t(),1),s=({roles:e,selected:t,grantable:n,disabled:s,onChange:c})=>(0,o.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:e.map(e=>{let l=t.includes(e.name),u=s||!n.has(e.name);return(0,o.jsxs)(`label`,{title:u&&!s?i(`cannotChangeRole`):void 0,className:a(`inline-flex items-center gap-1.5`,u&&`text-muted-foreground`),children:[(0,o.jsx)(r,{checked:l,label:e.label,onChange:u?void 0:n=>c(n?[...t,e.name]:t.filter(t=>t!==e.name)),className:a(u&&`cursor-default opacity-60`)}),e.label]},e.name)})}),c=({name:e,email:t,self:r,actions:i,children:a,error:s,status:c})=>(0,o.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-3`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c?(0,o.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,o.jsxs)(`span`,{className:`truncate font-medium`,children:[e,r&&` (you)`]}),c]}):(0,o.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,r&&` (you)`]}),(0,o.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),i]}),a,(0,o.jsx)(n,{message:s})]});export{s as n,c as t};
|
|
2
|
+
//# debugId=c1787380-d8a6-40ca-9916-a778ef16b15b
|
|
@@ -1,2 +1,2 @@
|
|
|
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{Fs as r,Qs as i,R as a,Rc as o,Xo as s,Xs as c,Zc as l,_ as u,a as d,ao as f,b as p,c as m,gr as h,i as g,o as _,qo as v,ro as y,ts as b,u as x,v as S,y as C,zc as w}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Fs as r,Qs as i,R as a,Rc as o,Xo as s,Xs as c,Zc as l,_ as u,a as d,ao as f,b as p,c as m,gr as h,i as g,o as _,qo as v,ro as y,ts as b,u as x,v as S,y as C,zc as w}from"./app-BnDutf0s.js";import{o as T}from"./vendor-DQHyyBk1.js";import{n as E,t as D}from"./lib-altcha-lib-BK1uKcxH.js";var O=e(t(),1),k=w(`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=b(),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)(i,{}),` `,k(`loading`)]}):n.error?r(n.error)&&n.error.status===404?(0,j.jsx)(v,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(v,{title:s(`cannotReach`),children:r(n.error)?n.error.message:s(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=b(),{resource:n,view:r}=e,i=e.title??r.names?.singular??l(r.resource);f(i);let[o,s]=(0,O.useState)(()=>_(n,[{title:i,fields:e.fields}])),[v,w]=(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=u(F);if(N)return(0,j.jsx)(y,{title:i,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)=>{w(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),s(n=>({...n,[e]:t}))},z=async()=>{M(!0),E(void 0);try{await t.submitForm(e.name,g(n,{},o),await A(t,e.name)),P(!0)}catch(e){let t=S(e);w(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(y,{title:i,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],i=r.fields[e],s=i?.label??l(e),c=v[e];return(0,j.jsx)(a,{name:e,label:s,help:i?.help,required:m(t),error:c&&C(t,s,c),children:(0,j.jsx)(p,{field:t,hints:i,value:o[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:d(t)?k(`setByDatabase`):x(t),invalid:!!c,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(h,{title:k(`notSent`),error:T}),(0,j.jsx)(c,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
|
|
2
|
+
//# debugId=e18a7aa5-de33-476e-b7a2-aacac74258d9
|
|
@@ -1,2 +1,2 @@
|
|
|
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{Ca as r,Fi as i,Jc as a,Jo as o,P as s,Ta as c,Xs as l,Yo as u,Zc as d,b as f,cc as p,do as m,fo as h,g,gc as _,jc as v,l as y,mo as b,s as x,y as S,zc as C}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{Ca as r,Fi as i,Jc as a,Jo as o,P as s,Ta as c,Xs as l,Yo as u,Zc as d,b as f,cc as p,do as m,fo as h,g,gc as _,jc as v,l as y,mo as b,s as x,y as S,zc as C}from"./app-BnDutf0s.js";import{At as w}from"./embedded-list-CPgxhzPw.js";import{_ as T,a as E,i as D,o as O,s as k,t as A,v as j}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as M,i as N,r as P,t as F}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import"./record-page-Dnpo_8uE.js";var I=e=>e.width??`minmax(8rem,1fr)`,L=e=>({"--line-columns":e.map(I).join(` `)}),R=e=>`${e.reduce((e,t)=>e+(t.width?.endsWith(`px`)?parseInt(t.width)/16:8),6)}rem`,z=`grid grid-cols-[28px_var(--line-columns)_32px] items-center gap-2 pointer-coarse:grid-cols-[44px_var(--line-columns)_44px]`,B=e(t(),1),V=e(n(),1),H=({items:e,label:t})=>{let[n,r]=(0,B.useState)(!1),i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=m(n,i,a),s=h(n,i,a,o?.right);return(0,B.useEffect)(()=>{if(!n)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!i.current?.contains(e.target))&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[n]),(0,V.jsxs)(`div`,{ref:i,className:`relative flex justify-center`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(!n),className:`inline-flex size-7 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11`,children:(0,V.jsx)(_,{className:`size-4`})}),n&&(0,V.jsx)(`ul`,{ref:a,role:`menu`,style:{...o,...s},className:`absolute right-0 top-full z-30 mt-1 w-max min-w-36 rounded-md border bg-background py-1 shadow-pop`,children:e.map(e=>(0,V.jsx)(`li`,{role:`none`,children:(0,V.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,className:v(`block min-h-9 w-full px-3 py-1.5 text-left hover:bg-muted disabled:text-faint-foreground disabled:hover:bg-transparent`,e.destructive&&`text-danger-text`),onClick:()=>{r(!1),e.onSelect()},children:e.label})},e.label))})]})},U=C(`inline-child-table`),W=({line:e,name:t,columns:n,position:r,count:i,reorderable:a,onRemove:o,onMove:s,error:c})=>{let{attributes:l,listeners:u,setNodeRef:d,setActivatorNodeRef:f,transform:p,transition:m,isDragging:h}=N({id:e.id,disabled:!a}),g=[...a?[{label:U(`moveUp`),disabled:r===0,onSelect:()=>s(r-1)},{label:U(`moveDown`),disabled:r===i-1,onSelect:()=>s(r+1)}]:[],...o?[{label:U(`removeLine`),destructive:!0,onSelect:o}]:[]];return(0,V.jsxs)(`div`,{ref:d,"data-line-id":e.id,"aria-invalid":c?!0:void 0,style:{transform:p?`translate3d(0, ${p.y}px, 0)`:void 0,transition:m},className:v(`group relative border-b border-border bg-background px-2 py-1 last:border-b-0 hover:bg-surface`,z,h&&`z-10 bg-surface opacity-80 shadow-pop`,c&&`bg-danger-soft`),children:[a?(0,V.jsx)(`button`,{ref:f,type:`button`,"aria-label":U(`dragToReorder`,{name:t}),...l,...u,style:{touchAction:`none`},className:`flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground opacity-60 hover:bg-muted hover:opacity-100 focus-visible:opacity-100 active:cursor-grabbing pointer-coarse:size-11`,children:(0,V.jsx)(w,{className:`size-4`})}):(0,V.jsx)(`span`,{}),n.map(t=>(0,V.jsx)(`div`,{className:v(`min-w-0`,t.align===`right`&&`text-right`),children:t.cell(e)},t.key)),g.length>0?(0,V.jsx)(H,{label:U(`actionsFor`,{name:t}),items:g}):(0,V.jsx)(`span`,{}),c&&(0,V.jsx)(`p`,{role:`alert`,className:`col-span-full px-2 pb-1 text-xs text-danger-text`,children:c})]})},G=(e,t,n)=>{if(t===n||t<0||t>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return r.splice(Math.min(Math.max(n,0),r.length),0,i),r},K=`px-2 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground`,q=(e,t)=>{let n=n=>{let r=e.find(e=>e.id===n);return r?t(r):U(`line`)},r=t=>e.findIndex(e=>e.id===t)+1;return{onDragStart:({active:t})=>U(`pickedUp`,{name:n(t.id),place:r(t.id),count:e.length}),onDragOver:({active:t,over:i})=>i?U(`over`,{name:n(t.id),place:r(i.id),count:e.length}):void 0,onDragEnd:({active:t,over:i})=>i?U(`dropped`,{name:n(t.id),place:r(i.id),count:e.length}):U(`droppedAtStart`,{name:n(t.id)}),onDragCancel:({active:e})=>U(`cancelled`,{name:n(e.id),place:r(e.id)})}},J=({lines:e,columns:t,lineName:n,onReorder:r,reorderable:i=!!r,onAdd:a,onRemove:o,removable:s=()=>!0,lineError:c,footer:u})=>{let d=j(T(E,{activationConstraint:{distance:4}}),T(O,{activationConstraint:{delay:250,tolerance:5}}),T(D,{coordinateGetter:P})),f=(t,n)=>{let i=e[t];!i||!r||n<0||n>=e.length||t===n||r(G(e,t,n),{id:i.id,from:t,to:n})};return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,style:L(t),children:[(0,V.jsxs)(`div`,{className:`${z} border-b border-border bg-surface px-2 py-2`,children:[(0,V.jsx)(`span`,{}),t.map(e=>(0,V.jsx)(`span`,{className:v(K,e.align===`right`&&`text-right`),children:e.label},e.key)),(0,V.jsx)(`span`,{})]}),e.length===0&&(0,V.jsx)(`p`,{className:`px-4 py-3 text-muted-foreground`,children:U(`noLines`)}),(0,V.jsx)(A,{sensors:d,collisionDetection:k,onDragEnd:({active:t,over:n})=>{n&&t.id!==n.id&&f(e.findIndex(e=>e.id===t.id),e.findIndex(e=>e.id===n.id))},accessibility:{announcements:q(e,n),screenReaderInstructions:{draggable:U(`instructions`)}},children:(0,V.jsx)(F,{items:e.map(e=>e.id),strategy:M,children:e.map((r,a)=>(0,V.jsx)(W,{line:r,name:n(r),columns:t,position:a,count:e.length,reorderable:i,onRemove:o&&s(r)?()=>o(r):void 0,onMove:e=>f(a,e),error:c?.(r)},r.id))})}),a&&(0,V.jsx)(`div`,{className:`border-t border-border bg-surface px-2 py-1.5`,children:(0,V.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:a,children:[(0,V.jsx)(p,{className:`size-3.5`}),U(`addLine`)]})})]}),u]})},Y=({field:e,hints:t,label:n,lineNumber:r,resource:i,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:l,locked:u,problem:d,onChange:p})=>{let m=(0,B.useId)(),h=d&&S(e,n,d);return(0,V.jsxs)(b.Provider,{value:{id:m,invalid:!!d,required:!1,...h&&{describedBy:`${m}-error`}},children:[(0,V.jsx)(`label`,{htmlFor:m,className:`sr-only`,children:g(`lineField`,{label:n,place:r})}),(0,V.jsx)(f,{field:e,hints:t,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:l,locked:u,invalid:!!d,resource:i,onChange:p}),h&&(0,V.jsx)(`p`,{id:`${m}-error`,className:`px-1 pt-0.5 text-xs text-danger-text`,children:h})]})},X=({lines:e,editable:t,saving:n})=>{let{resources:l,views:f}=o(),{item:p,model:m,columns:h,data:_,draft:v}=e,b=u(m.name),S=f[m.name],[C,w]=(0,B.useState)({}),T=t&&_.complete&&!_.loading&&!n,E=T&&r(b,`update`),D=T&&r(b,`create`),O=T&&r(b,`delete`),k=e=>e.stored?E&&c(e.stored,`update`):D,A=e=>v.shown.indexOf(e)+1,j=e=>v.rejection?.id===e.id?v.rejection:void 0,M=h.map(e=>{let t=m.fields[e],n=S?.fields[e],r=n?.label??d(e),i=t.relation?l[t.relation.resource]:void 0,a=i&&i.primaryKey.length===1?i:void 0;return{key:e,label:r,...[`integer`,`bigint`,`decimal`].includes(t.type)&&{align:`right`,width:`minmax(6rem,0.6fr)`},cell:i=>{let o=v.value(i.id,e),s=o==null||o===``?void 0:String(o);return(0,V.jsx)(Y,{field:t,hints:n,label:r,lineNumber:A(i),resource:m.name,value:o,stored:i.stored?.[e],relationLabel:s===void 0?void 0:C[`${i.id}/${e}`]??_.labels[e]?.[s],relationTo:a&&s!==void 0?{kind:`record`,resource:a.name,key:s}:void 0,relationPicker:a&&{target:a,view:f[a.name]},locked:!k(i),problem:j(i)?.fields[e],onChange:t=>{if(!a||!x(t))return v.change(i.id,e,t);w(n=>({...n,[`${i.id}/${e}`]:t.label})),v.change(i.id,e,y(a,t.key))}})}}});return(0,V.jsxs)(s,{title:p.title,help:p.help,children:[!_.complete&&(0,V.jsx)(`p`,{className:`mb-2 text-muted-foreground`,children:g(`tooManyLines`,{limit:i(1e3)})}),(0,V.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0`,children:(0,V.jsx)(`div`,{style:{minWidth:R(M)},children:(0,V.jsx)(J,{lines:v.shown,columns:M,lineName:e=>a(m,S,e.stored??{},``)||g(`lineNumber`,{place:A(e)}),onReorder:e=>v.setOrder(e.map(e=>e.id)),reorderable:E,onAdd:D?()=>void v.add():void 0,onRemove:D||O?e=>v.remove(e.id):void 0,removable:e=>e.stored?O&&c(e.stored,`delete`):D,lineError:e=>{let t=j(e);if(t&&!h.some(e=>t.fields[e]))return t.message}})})})]})};export{X as RecordLines};
|
|
2
|
+
//# debugId=e66fc6e5-dfcd-4010-bd5d-3acb6344d323
|
|
@@ -1,2 +1,2 @@
|
|
|
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{t}from"./react-CuiNlnus.js";import{n,r,t as i}from"./maplibre-
|
|
2
|
-
//# debugId=
|
|
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{t}from"./react-CuiNlnus.js";import{n,r,t as i}from"./maplibre-C7kZagL3.js";import{a,i as o,r as s}from"./lib-vis.gl-react-maplibre-CdxVSk--.js";var c=e(t(),1),l=({style:e,layers:t,position:l,zoom:u})=>(0,c.jsxs)(a,{mapLib:i,mapStyle:e,initialViewState:{...l,zoom:u},cooperativeGestures:!0,style:{width:`100%`,height:`100%`},children:[(0,c.jsx)(s,{showCompass:!1}),(0,c.jsx)(n,{layers:t}),(0,c.jsx)(o,{latitude:l.latitude,longitude:l.longitude,anchor:`bottom`,children:(0,c.jsx)(r,{"aria-hidden":!0,className:`size-8 fill-primary text-primary-foreground drop-shadow`,strokeWidth:1.5})})]});export{l as RecordMap};
|
|
2
|
+
//# debugId=51df843d-b883-4d00-a544-7592480c4a9e
|
|
@@ -1,2 +1,2 @@
|
|
|
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{bl as r,g as i,qo as a,zr as o}from"./app-
|
|
2
|
-
//# debugId=
|
|
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{bl as r,g as i,qo as a,zr as o}from"./app-BnDutf0s.js";var s=e(t(),1),c=e(n(),1),l=(e,t)=>{let n=r(e,t);return n.kind===`record`&&(Array.isArray(n.key)?n.key:[n.key]).some(e=>e===``)?void 0:n},u=({to:e})=>{let{go:t}=o();return(0,s.useEffect)(()=>t(e,{replace:!0}),[e,t]),(0,c.jsx)(a,{title:i(`loading`),children:i(`fetching`)})};export{l as n,u as t};
|
|
2
|
+
//# debugId=db8dde05-2de6-4407-b9b8-ae6f3c1b2651
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-
|
|
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,$i as a,Ac as o,An as s,Ar as c,C as l,Ca as u,Cc as d,Ci as f,Cn as p,D as m,Do as h,Dr as g,Dt as _,E as v,En as y,Eo as b,Er as x,Et as ee,Fa as S,Fi as te,Fr as C,Fs as w,Gs as ne,Gt as T,Hc as E,Hi as D,Hn as re,I as ie,Ia as ae,Jo as O,Kc as k,Ks as oe,Ll as se,Lt as ce,Ma as le,Mn as ue,Mo as de,Nl as A,Nn as fe,O as pe,Oi as me,Oo as he,Ot as ge,P as j,Pn as _e,R as ve,Rc as M,Ri as N,Rr as P,Sa as ye,Sc as F,Si as be,Sn as xe,Tc as Se,To as Ce,Tt as we,Ui as I,Uo as Te,Va as Ee,Vi as De,Vs as Oe,Wn as ke,Ws as L,Xn as Ae,Xs as R,Yo as je,Ys as z,Z as B,Zc as V,Zs as Me,_ as Ne,_i as Pe,aa as Fe,ar as Ie,as as Le,b as Re,bo as ze,cc as Be,cs as Ve,ct as H,d as He,ec as Ue,et as We,f as Ge,fa as Ke,fi as qe,fn as Je,g as U,gi as Ye,gn as Xe,go as Ze,gr as W,h as Qe,hl as $e,ir as et,it as tt,jc as G,ji as nt,jl as K,jo as rt,k as it,ka as at,ki as ot,kn as st,ko as ct,kr as lt,l as ut,m as dt,nn as ft,nt as pt,ol as mt,ot as ht,p as gt,qo as _t,qs as q,rt as vt,s as yt,st as bt,tl as xt,ts as J,ui as St,v as Ct,vi as wt,w as Tt,wa as Et,wi as Dt,x as Ot,xn as kt,xo as At,y as jt,yi as Mt,yn as Nt,zc as Pt,zi as Ft,zl as It,zr as Lt,zs as Rt}from"./app-p7iRIIoG.js";import{S as zt,i as Bt,m as Vt,o as Ht,r as Ut,s as Wt}from"./vendor-DQHyyBk1.js";import{Ct as Gt,Dt as Kt,Et as qt,Mt as Jt,Tt as Yt,_ as Xt,a as Zt,c as Qt,lt as $t,n as en,ot as tn,pt as nn,rt as rn,s as an,t as on,tt as sn,yt as cn}from"./embedded-list-DAjlopsR.js";import{a as ln,i as un,n as dn,r as fn,t as pn}from"./reorder-button-C8G3bjeB.js";import{a as mn,c as hn,i as gn,l as _n,n as vn,o as yn,r as bn,s as xn,t as Sn}from"./render-node-DQMrGelM.js";import{t as Cn}from"./trash-Bb3IsZeK.js";import{n as wn,t as Tn}from"./record-sidebar-HqyBXBwn.js";import{t as En}from"./start-block-queries-kp3ICAXt.js";import{n as Dn,t as On}from"./record-opens-DQrqEFru.js";import{u as kn}from"./messages-03zmq2oA.js";var An={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`}]]};An.node;var jn=o(An),Mn={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`}]]};Mn.node;var Nn=o(Mn),Pn={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`}]]};Pn.node;var Fn=o(Pn),In={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`}]]};In.node;var Ln=o(In),Rn={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`}]]};Rn.node;var zn=o(Rn),Y=e(r(),1),Bn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,Y.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,Y.jsxs)(`div`,{children:[e&&(0,Y.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,Y.jsxs)(Y.Fragment,{children:[H(`lastEditedBy`),` `,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,Y.jsx)(Y.Fragment,{children:H(`lastUpdated`,{ago:r.ago})})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(he,{people:i,size:`md`}),H(`viewing`,{count:i.length})]}),a]})]}),X=e(t(),1),Vn=`text-base font-semibold text-foreground`,Hn=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,X.useId)();return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:G(`py-8`,r&&`pb-0`),children:[(0,Y.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,Y.jsxs)(P,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:G(`inline-flex items-center gap-1.5`,Vn),children:[(0,Y.jsx)(F,{className:G(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,Y.jsx)(`span`,{className:Vn,children:e}),n]}),t&&(0,Y.jsx)(`p`,{className:G(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,Y.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,Y.jsx)(ie.Provider,{value:2,children:a})})]})},Un=({tabs:e})=>(0,Y.jsx)(`nav`,{"aria-label":H(`tabs`),className:`overflow-x-auto py-6`,children:(0,Y.jsx)(`span`,{className:At.group(`md`),children:e.map(e=>(0,Y.jsx)(P,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:G(At.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Wn=({rows:e})=>(0,Y.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:G(`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,Y.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Gn=({facts:e})=>(0,Y.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,Y.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),Kn=`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`,qn=({actions:e})=>(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,Y.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:H(`actions`)}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{className:G(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:G(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,Y.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,Y.jsx)(`li`,{children:s?s({className:Kn,children:c}):(0,Y.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:Kn,children:c})},e)})})]}),Jn=e(n(),1),Yn=1e3,Xn=(e,t,n,r,i)=>{let a=C(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,X.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,X.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Zn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),Qn=(e,t)=>e.sidebar?e.title?(0,Y.jsx)(wn,{title:e.title,children:t}):t:e.title?(0,Y.jsx)(j,{title:e.title,children:t}):(0,Y.jsx)(`section`,{className:`py-8`,children:t}),$n=({item:e,scope:t,fallback:n})=>{let{components:r}=at(),i=r?.[e.component],a=i&&(0,Y.jsx)(et,{value:t,children:(0,Y.jsx)(i,{...$e(e.props??{})})});return n===void 0?Qn(e,(0,Y.jsx)(vn,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,Y.jsx)(vn,{name:e.component,registered:!!i,fallback:n,children:Qn(e,a)})},er=({component:e,scope:t,standard:n})=>{let{components:r}=at(),i=r?.[e];return i?(0,Y.jsx)(Ee,{name:e,fallback:n,children:(0,Y.jsx)(tr,{children:(0,Y.jsx)(et,{value:t,children:(0,Y.jsx)(i,{})})})}):n},tr=({children:e})=>(ct(!1),(0,Y.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),nr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,rr=(e,t,n)=>It(()=>{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),ir=(e,t,n)=>It(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),ar=e=>ce(e)??zn,or=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=Lt(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Gt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,X.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Zt(e.run,t.record,a):void 0;return{name:e.label,icon:ar(e.icon),blocked:n,running:c.running===e.name,...Kt(e)&&{tone:`danger`},onRun:()=>qt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,Y.jsx)(ne,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:U(`edit`),icon:ln,render:({className:e,children:t,role:n})=>(0,Y.jsx)(P,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:U(`delete`),icon:Cn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,Y.jsx)(Yt,{action:l,label:l.label,danger:Kt(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)}})}},sr=e=>{let t=Ze(),{actions:n,prompt:r}=or(e);return n.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,Y.jsx)(qn,{actions:n})}),t&&(0,Jn.createPortal)((0,Y.jsx)(bt,{actions:n,label:U(`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]})},cr=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}`},lr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?L(`operationFailed`,{index:n+1,label:cr(r),message:e.message}):L(`nothingSaved`,{message:e.message})},ur=(e,t)=>new e.constructor({...e.problem,detail:lr(e,t)}),dr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),fr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=J(),c=Vt(),u=g(e.name,n),d=Qe(r,i),[f]=(0,X.useState)(()=>a?rr(localStorage,a,t.etag):void 0),[p,h]=(0,X.useState)(f?.fields??{}),[_,v]=(0,X.useState)(!!f),[y,b]=(0,X.useState)(!1),[ee,S]=(0,X.useState)({}),[te,C]=(0,X.useState)({}),[ne,T]=(0,X.useState)(0),E=Object.entries(p).filter(([n,r])=>l(e.fields[n],r,t.record[n])),D=E.length>0,re=D||!!o?.dirty;(0,X.useEffect)(()=>{f?.order&&o?.setOrder(f.order)},[]),(0,X.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(p).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;ir(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,p,o?.order,t.etag]);let ie=n=>n in p?p[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:m(t.record[n]),ae=(n,r)=>{C(e=>dr(e,n));let i=typeof r==`string`?r!==m(t.record[n]):l(e.fields[n],r,t.record[n]);h(e=>i?{...e,[n]:r}:dr(e,n))},O=async()=>{let r=await s.get(e.name,n);c.setQueryData(M.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(p)){let s=e.fields[n];l(s,o,r.record[n])&&(a[n]=o,m(r.record[n])!==m(t.record[n])&&(i[n]=s.type===`file`?Pe(s,r.record[n]):m(r.record[n])))}h(a),S(i)},k=()=>Object.fromEntries(E.map(([t,n])=>[t,it(e.fields[t],n)])),oe=e=>{let t=Ct(e);C(t),Object.keys(t).length>0&&T(e=>e+1)},se=async()=>{try{await u.mutateAsync({patch:k(),etag:t.etag})}catch(e){throw x(e)?await O():w(e)&&oe(e),e}},ce=async r=>{let i=D?[{op:`update`,resource:e.name,key:n,data:k(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(x(e))await O(),await c.invalidateQueries({queryKey:[`list`]}),b(!0);else if(w(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?oe(e):n&&o?.reject(n,e)}throw w(e)?ur(e,a):e}await Promise.all([c.invalidateQueries({queryKey:M.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:ie,change:ae,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await ce(e):await se(),h({}),S({}),C({}),b(!1),v(!1)}),dirty:re,discard:()=>{h({}),S({}),C({}),b(!1),v(!1),o?.reset()},restored:_&&re,dismissRestored:()=>v(!1),linesConflict:y,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:ee,errors:te,rejections:ne,keepMine:e=>S(t=>dr(t,e)),useTheirs:e=>{S(t=>dr(t,e)),h(t=>dr(t,e))}}},Z=Pt(`focus-record`),pr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,Y.jsx)(Y.Fragment,{children:e.map(({name:e,label:r})=>[(0,Y.jsx)(R,{size:`sm`,onClick:()=>t(e),children:Z(`keepMine`,{field:r})},`mine:${e}`),(0,Y.jsx)(R,{size:`sm`,onClick:()=>n(e),children:Z(`useTheirs`,{field:r})},`theirs:${e}`)])}),mr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=vt(`primary`),o=ht()?.size===`compact`,s=(0,Y.jsx)(R,{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,Y.jsx)(pt,{zone:`secondary`,children:s}):(0,Y.jsx)(pt,{zone:`primary`,fallback:!0,children:s})},hr=({record:e,saved:t,readOnly:n})=>{let r=ht()?.size,i=n?Z(`readOnly`):e.saving?Z(`saving`):e.dirty?Z(r===`wide`?`unsaved`:`unsavedShort`):t?Z(`saved`):void 0;return i?(0,Y.jsx)(pt,{zone:`state`,fallback:!0,children:(0,Y.jsxs)(`span`,{role:`status`,title:n?Z(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,Y.jsx)(Se,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},gr=({model:e,recordKey:t,stored:n,page:r})=>{let a=O().views[e.name],{address:o,go:s}=Lt(),c=De()(e,a,n.record,t),{state:l}=Ve(),d=fr({model:e,stored:n,recordKey:t,mode:`button`,subject:c,draftKey:l.kind===`signed-in`?`${nr(l.user.id,e.name,t)}:focus`:void 0});Oe(d.dirty||d.saving),Le(d.dirty);let f=Vt(),[p,m]=(0,X.useState)(!1),h=a?.names?.singular??V(e.name),g=je(e.name),_=fn(e),v=o?.kind===`record`&&o.version!==void 0&&o.version!==Number(n.record.version),y=`surface`in r&&(Et(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),b=u(g,`update`)&&n.permissions?.update!==!1&&!y,x=!b||v,ee=u(g,`delete`)&&n.permissions?.delete!==!1,S=un({model:e,view:a,restore:_,onDeleted:()=>s({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void f.invalidateQueries({queryKey:M.record(e.name,t)})}),{actions:te,prompt:C}=or({model:e,stored:n,recordKey:t,onDelete:ee?()=>void S.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0}),w=(0,X.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),ne=te.filter(e=>e.tone===`danger`),T=[...te.filter(e=>e.tone!==`danger`),...d.dirty?[{name:Z(`discardChanges`),icon:Ln,onRun:()=>m(!0)}]:[],{name:Z(`detailsOf`,{noun:h}),icon:Fn,render:({className:e,children:t,role:n})=>(0,Y.jsx)(P,{to:w,role:n,className:e,children:t})},...ne],E={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:x,mayUpdate:b,value:d.value,change:(e,t)=>x?void 0:d.change(e,t),dirty:d.dirty,saving:d.saving,refused:d.message!==void 0,save:async()=>!x&&!!await d.save(),discard:d.discard,details:w},D=`surface`in r?r.surface:void 0,re=p&&d.dirty&&(0,Y.jsx)(We,{level:`draft`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{size:`sm`,variant:`danger`,onClick:()=>{d.discard(),m(!1)},children:Z(`discardChanges`)}),(0,Y.jsx)(R,{size:`sm`,onClick:()=>m(!1),children:Z(`keep`)})]}),children:Z(`discardAsk`)}),ie=Object.keys(d.conflicts).length>0,ae=D?d.errors[D]:void 0,k=ae&&D?jt(e.fields[D],a?.fields[D]?.label??V(D),ae):void 0;return(0,Y.jsxs)(B.Provider,{value:E,children:[!x&&(0,Y.jsx)(mr,{record:E,label:Z(`save`)}),(0,Y.jsx)(hr,{record:E,saved:d.phase===`saved`,readOnly:x}),(0,Y.jsx)(i,{actions:T}),d.message&&!p&&(0,Y.jsxs)(We,{level:`refused`,actions:(0,Y.jsx)(P,{to:w,className:`text-body font-medium text-primary-text hover:underline`,children:Z(`detailsOf`,{noun:h})}),children:[(0,Y.jsx)(`strong`,{className:`font-medium`,children:Z(`notSaved`)}),` `,k??d.message]}),ie&&(0,Y.jsx)(We,{level:`conflict`,actions:(0,Y.jsx)(pr,{fields:Object.keys(d.conflicts).map(e=>({name:e,label:a?.fields[e]?.label??V(e)})),onKeepMine:d.keepMine,onUseTheirs:d.useTheirs}),children:Z(`conflict`)}),re,d.restored&&!p&&(0,Y.jsx)(We,{level:`draft`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{size:`sm`,onClick:d.dismissRestored,children:Z(`keep`)}),(0,Y.jsx)(R,{size:`sm`,onClick:d.discard,children:Z(`discard`)})]}),children:Z(`restored`)}),D?(0,Y.jsx)(_r,{model:e,name:D,stored:n,editor:d,readOnly:x}):(0,Y.jsx)(vr,{name:r.component,model:e,stored:n,recordKey:t}),S.dialogs,C]})},_r=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=O().views[e.name]?.fields[t];if(Et(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,Y.jsx)(`div`,{className:`absolute inset-0`,children:(0,Y.jsx)(Re,{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)})})},vr=({name:e,model:t,stored:n,recordKey:r})=>{let i=at().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,Y.jsx)(`div`,{className:`absolute inset-0`,children:(0,Y.jsx)(et,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,Y.jsx)(i,{})})})},yr=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=De()(e,O().views[e.name],n.record,t);return(0,Y.jsx)(Ee,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,Y.jsx)(tt,{label:a,children:(0,Y.jsx)(gr,{model:e,recordKey:t,stored:n,page:r})})})},br=(0,X.lazy)(()=>zt(()=>import(`./record-map-BMZTdCJn.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),xr=15,Sr=({item:e,record:t})=>{let n=O().maps,r=n?.style,i=Xt(t,e);if(!r||!i)return null;let a=(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,Y.jsx)(X.Suspense,{fallback:null,children:(0,Y.jsx)(br,{style:r,layers:n?.layers,position:i,zoom:e.zoom??xr},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,Y.jsx)(wn,{title:e.title,children:a}):(0,Y.jsx)(j,{title:e.title,children:a})},Cr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},wr=(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}))},Q=Pt(`app/record-chart`),Tr=K(),Er=[`1h`,`24h`,`7d`],Dr={"1h":`hour`,"24h":`day`,"7d":`week`},Or=({item:e,recordKey:t})=>{let{resources:n,views:r}=O(),[i,a]=(0,X.useState)(e.range??`1h`),[o,s]=(0,X.useState)(`average`),l=n[e.resource],u=r[e.resource],d=Cr[i],f=A(Tr.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...o===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:Ke()})),m=c(e.resource,p,!!l);if(!l)return null;let h=e.series.map(e=>({kind:o,field:l.fields[e],...u?.fields[e]&&{hints:u.fields[e]}})),g=e.series.map((e,t)=>({key:`s${t}`,label:u?.fields[e]?.label??V(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?wr(m.map(e=>e.data.groups),g.map(e=>e.key),o):[],v=(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(ze,{label:Q(`measure`),value:o,onChange:s,options:[{value:`average`,label:Q(`average`)},{value:`maximum`,label:Q(`maximum`)}]}),(0,Y.jsx)(ze,{label:Q(`range`),value:i,onChange:a,options:Er.map(e=>({value:e,label:Q(Dr[e])}))})]});return(0,Y.jsx)(j,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,Y.jsx)(`p`,{className:`text-danger-text`,children:Q(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,Y.jsx)(q,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Q(`noSamples`)}):(0,Y.jsx)(nn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},kr=Pt(`app/record-trend`),Ar=(e,t)=>kr(`total_${t}`,{count:e}),jr=K(),Mr={kind:`count`},Nr=({item:e,recordKey:t})=>{let n=A(jr.eq(e.field,t)),r=lt(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Ke()});return(0,Y.jsx)(j,{title:e.title,help:e.help,children:(0,Y.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,Y.jsx)(q,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,Y.jsx)(W,{title:kr(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:Ar(t,e.range)}),(0,Y.jsx)(nn,{points:cn(r.data.groups,Mr),measure:Mr,bucket:e.granularity,type:`bar`})]})})()})})},Pr=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],Fr=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),Ir=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)}},Lr=(e,t)=>e.find(e=>e.title===t)??e[0],Rr=e=>mt(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),zr=(e,t,n)=>{if(t&&!Rr(t).some(n))return e.find(e=>Rr(e).some(n))},Br={added:[],edits:{},removed:[]},Vr=(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},Hr=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&l(i,r,n[t])?[[t,it(i,r)]]:[]})),Ur=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,it(r,n)]]})),Wr=({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=>[D(e,t),t])),c=[...s.keys()],l=Vr(c,i),u=t=>I(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=Hr(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?[[xt(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:{...Ur(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},Gr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Kr=(e,t)=>{let[n,r]=(0,X.useState)(Br),[i,a]=(0,X.useState)(),o=(0,X.useRef)(1),s=(0,X.useMemo)(()=>new Map(e?t.map(t=>[D(e.model,t),t]):[]),[e,t]),c=Vr([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Wr({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,d=(0,X.useMemo)(()=>{let e=Vr([...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:pe(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:Gr(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Br),a(void 0)},reject:(e,t)=>a({id:e,fields:Ct(t),message:t.message}),rejection:i,plan:l}},qr=(e,t)=>{let n=mt(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}},Jr=(e,t,n,r)=>k(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Yr=(e,t)=>{let{resources:n,views:r}=O(),i=(0,X.useMemo)(()=>qr(n,r[e.name]),[n,r,e]),a=i?.model,o=i?Jr(i.model,r[i.model.name],i.link.name,i.position):[],s=Xn(a,i?.link,i?.position,t,a?Ae(n,r,a,o):void 0),c=Kr((0,X.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:ut(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Xr=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Zr=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,Qr=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,$r=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),ei=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,ti=`protobase:lightbox-details`,ni=e=>It(()=>e.getItem(ti)===`true`,!1),ri=(e,t)=>It(()=>t?e.setItem(ti,`true`):e.removeItem(ti),void 0),$=Pt(`app/gallery`),ii=`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`,ai=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=$(`details`)})=>{let s=(0,X.useRef)(null),c=(0,X.useRef)(void 0),l=(0,X.useId)(),u=rt(),[f,p]=(0,X.useState)(()=>ni(localStorage)),[m,h]=(0,X.useState)(!1);z(s,!0,i),(0,X.useEffect)(()=>h(!0),[]);let g=t.length,_=e=>{let t=$r(n,e,g);t!==n&&r(t)},v=ot(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{p(e),ri(localStorage,e)};return(0,Y.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&ei(e))return e.preventDefault(),x(!f);let t=Qr(e.key);t!==0&&(e.preventDefault(),_(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,Y.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,Y.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${g}`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":f,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!f),children:(0,Y.jsx)(Nn,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsx)(`button`,{type:`button`,className:ii,"aria-label":$(`close`),onClick:i,children:(0,Y.jsx)(Ue,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,Y.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&&=(_(Zr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,Y.jsx)(ke,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),g>1&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`previousPhoto`),"aria-disabled":n===0,onClick:()=>_(-1),children:(0,Y.jsx)(d,{className:`size-5`,"aria-hidden":!0})}),(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`nextPhoto`),"aria-disabled":n===g-1,onClick:()=>_(1),children:(0,Y.jsx)(F,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&f&&u&&(0,Y.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,Y.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),y]}),(0,Y.jsx)(T,{title:o,open:b&&f&&!u&&m,onClose:()=>x(!1),children:(0,Y.jsx)(`div`,{className:`pt-3`,children:y})})]})},oi=(e,t,n)=>{let r=mt(t?.layout??[]).flatMap(e=>e.kind===`section`&&dt(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)&&dt(t?.fields[r]?.when,!1))},si=({model:e,view:t,photoKey:n,fields:r})=>{let i=ae(e.name,n),a=(t?.names?.singular??V(e.name)).toLowerCase();if(i.isPending)return(0,Y.jsx)(q,{className:`h-4 w-48`});if(i.error)return(0,Y.jsx)(W,{title:$(`couldNotLoadOne`,{singular:a}),error:i.error});let o=r.filter(e=>Et(i.data.permissions,e)!==`hidden`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Wn,{rows:o.map(n=>({label:t?.fields[n]?.label??V(n),value:(0,Y.jsx)(kt,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,Y.jsx)(P,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:a})})]})},ci=e=>ot(e,{width:0,height:0})!==void 0,li=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return xt(n)},ui=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!me(t)||!ci(t))return[];let i=r&&li(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!me(e)||!ci(e))return i;let a=t=>me(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))]},di=K(),fi=(e,t,n)=>{let r=J(),{resources:i}=O(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?A(di.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Ht({queryKey:M.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:ui(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},pi={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`,``,``,``,``]},mi=({photo:e,large:t})=>{let n=ot(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,Y.jsx)(ke,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},hi=({item:e,record:t,recordKey:n})=>{let{views:r}=O(),i=fi(e,t,n),a=je(i.holder?.name??``),[o,s]=(0,X.useState)();if(i.isPending)return(0,Y.jsx)(j,{title:e.title,children:(0,Y.jsx)(q,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,Y.jsx)(j,{title:e.title,children:(0,Y.jsx)(W,{title:$(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=Xr(c),d=i.holder,f=d&&r[d.name],p=d?oi(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,Y.jsxs)(j,{title:e.title,children:[(0,Y.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,Y.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:c}):$(`showPhoto`,{index:t+1,count:c}),onClick:()=>s(t),className:G(`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`,pi[l][t]),children:[(0,Y.jsx)(mi,{photo:e.file,large:t===0}),n&&(0,Y.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,Y.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,Y.jsx)(jn,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,Y.jsx)(ai,{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,Y.jsx)(si,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&$(`holderDetails`,{singular:f?.names?.singular??V(d.name)})})]})},gi=Pt(`app/history`),_i=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?gi(`databaseRole`,{role:e.databaseRole}):gi(`database`),vi=(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??V(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:Pe(i,e.before[r],a),after:Pe(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?gi(`changedThis`):gi(e.operation);return{who:_i(e),verb:i,fields:r}},yi=1500,bi=(e,t,n,r)=>{let i=J(),a=Ut({queryKey:M.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,X.useEffect)(()=>{let e=setTimeout(()=>void o(),yi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},xi=()=>(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(q,{className:`h-4 w-full`},t))}),Si=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:o}=vi(e,t,n),s=Date.parse(e.at);return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,Y.jsxs)(`time`,{dateTime:e.at,title:a(s),className:`text-muted-foreground`,children:[`· `,Fe(Math.max(0,Math.round((Date.now()-s)/1e3)))]})]}),o.length>0&&(0,Y.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:o.map(e=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,Y.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},Ci=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=bi(t.name,r,e.limit??10,i);return(0,Y.jsx)(j,{title:e.title,children:a.isPending?(0,Y.jsx)(xi,{}):a.error?(0,Y.jsx)(W,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,Y.jsx)(Si,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,Y.jsx)(R,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},wi=({comment:e})=>(0,Y.jsx)(we,{text:e.body,mentions:e.mentions}),Ti=(e,t)=>{let n=J(),r=Vt();return Bt({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:M.comments(e,t)})})},Ei=Pt(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,X.useState)(_),i=J(),a=le(),o=Ti(e,t),s=(0,X.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Oe(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:ge(n.text,n.picked)},{onSuccess:()=>r(_),onError:e=>a.show({state:`error`,title:Ei(`couldNotPost`),description:St(e)})})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(ee,{"aria-label":Ei(`comment`),placeholder:Ei(`placeholder`),value:n,onChange:r,searchPeople:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(R,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:Ei(`comment`)})})]})},Oi=20,ki=(e,t)=>{let n=J(),r=Ut({queryKey:M.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,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(q,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,Y.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(h,{initials:b(t)||`?`,hue:Ce(e.author.id),size:`md`,className:`ring-0`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,Y.jsxs)(`time`,{dateTime:e.createdAt,title:a(n),className:`text-muted-foreground`,children:[`· `,Fe(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,Y.jsx)(wi,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,Y.jsxs)(j,{title:e.title,children:[i.isPending?(0,Y.jsx)(Ai,{}):i.error?(0,Y.jsx)(W,{title:Ei(`couldNotLoad`),error:i.error}):(0,Y.jsxs)(Y.Fragment,{children:[i.hasNextPage&&(0,Y.jsx)(R,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:Ei(`showEarlier`)}),i.items.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Ei(`noComments`)}):(0,Y.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,Y.jsx)(ji,{comment:e},e.id))})]}),r&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.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=>Rt(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 Rt(a)?!r&&t[i++]===!0:dt(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,yn(i,t),n,r)},zi=K(),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:A(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=J(),{session:r,organizations:i}=Ve(),a=(0,X.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,X.useState)(a?{state:`looking`}:{state:`missing`});return(0,X.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=J(),a=Vt(),o=De(),c=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),l=Wt({queries:c.map(e=>{let o=t[e.relation.resource];return s(a,i,o,n[o.name],String(r[e.name]))})}),u=c.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(c.map((e,t)=>[e.name,u[t]])),labels:Object.fromEntries(c.map((e,i)=>{let a=t[e.relation.resource];return[e.name,st(l[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=K(),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??V(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??V(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:A(Wi.eq(e.field,t))}),Ji=K(),Yi=(e,t,n)=>{let r=J(),i=Wt({queries:e.map(e=>{let i=A(Ji.eq(e.field,n));return{queryKey:M.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}=O(),{components:a}=at(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,Y.jsx)(wn,{title:U(`relatedRecords`),children:(0,Y.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(P,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,Y.jsx)(q,{className:`h-4 w-6`}):`${te(n.count)}${n.exact?``:`+`}`,(0,Y.jsx)(F,{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,Y.jsx)(q,{className:`inline-block h-5 w-7 rounded-full`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Te,{dot:!1,className:G(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(E())})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t?H(`headingCount`,{count:e,...t}):H(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&ye(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e??_n(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??V(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:a,sort:o,fields:s,button:c,empty:l,add:u})=>{let d=de(),{resources:f}=O(),p=o||nt(r,i),m=Nt(r,{filter:a,sort:p,pageSize:2});if(m.isPending)return(0,Y.jsx)(j,{title:e,help:t,count:n,children:(0,Y.jsx)(q,{className:`h-24 w-full`})});if(m.error)return(0,Y.jsx)(j,{title:e,help:t,count:n,children:(0,Y.jsx)(W,{title:_n(`couldNotLoad`),error:m.error})});let[h,g]=m.data.items;if(!h){let a=u&&(0,Y.jsxs)(P,{to:u,className:Me({size:`sm`}),children:[(0,Y.jsx)(Be,{className:`size-3.5`}),_n(`add`,{singular:ea(r,i)})]});return(0,Y.jsx)(j,{title:e,help:t,count:n,actions:a,children:(0,Y.jsx)($i,{empty:l})})}let _=Xe(r,h),v=ea(r,i),y=i?.names?.plural??V(r.name),b=s.length>1,x=s.map(e=>(0,Y.jsx)(hn,{scope:_,path:e,labelled:b},e)),ee=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c&&(0,Y.jsx)(sn,{button:c,model:r,view:i,record:h,models:f}),(0,Y.jsx)(P,{to:{kind:`record`,resource:r.name,key:I(r,h)},className:Me({size:`sm`}),children:_n(`open`,{singular:v})})]});return(0,Y.jsx)(j,{title:e,help:t,count:n,actions:ee,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[b?(0,Y.jsx)(`dl`,{className:`flex flex-col gap-4`,children:x}):x,g&&(0,Y.jsxs)(P,{to:tn(r,i,d,{filter:a,orderBy:p,display:rn(i,d,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[$t(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:y.toLowerCase()}),(0,Y.jsx)(Jt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=K(),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(A(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=se(ra(A(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(A(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=J(),{resources:r}=O(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Wt({queries:i.map(({model:e,match:r})=>({...Je(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=K(),ca=({empty:e})=>(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e??U(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=O(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=mn(s,`related:${n}:${e.title}`,e.display),d=je(e.resource),[f,p]=(0,X.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,Y.jsx)(Zi,{count:m,names:s?.names}):void 0},g=an(e,o,r),_=e.columns??k(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,Y.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,Y.jsx)(j,{...h,children:v(n=>(0,Y.jsx)(xn,{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,Y.jsx)(j,{...h,children:(0,Y.jsx)(ca,{empty:e.empty})}):(0,Y.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=kn(e,o,d),b=(0,Y.jsx)(on,{view:s,value:l,onChange:u}),x=y?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,Y.jsx)(pn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,Y.jsx)(j,{...h,actions:x,children:(0,Y.jsx)(dn,{model:o,view:s,field:y,filter:A(sa.eq(e.field,t)),columns:_})}):(0,Y.jsx)(j,{...h,actions:x,children:v(t=>(0,Y.jsx)(en,{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:Qt(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=O(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,Y.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=K(),ma=(e,t)=>A(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=O(),[r]=yn(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,Y.jsx)(j,{title:e.title,help:e.help,children:(0,Y.jsx)(bn,{children:(0,Y.jsx)(gn,{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,Y.jsx)(Ie,{value:t,children:(0,Y.jsxs)(ft,{tree:n,plan:r,children:[(0,Y.jsx)(En,{tree:n,plan:r}),(0,Y.jsx)(Sn,{node:n,at:``})]})})},_a=Ft(()=>zt(()=>import(`./record-lines-DCs-txvG.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,Y.jsx)(q,{className:`h-32 w-full rounded-lg`})),va=Ft(()=>zt(()=>import(`./composer-section-DAIjBfXV.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,Y.jsx)(q,{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:U(`details`),fields:a},...e.history?[{kind:`history`,title:U(`history`)}]:[],...e.comments?[{kind:`comments`,title:U(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=O(),{address:i}=Lt(),a=at(),o=n[e],s=S(e,t);if(!o)return(0,Y.jsx)(_t,{title:L(`notFound`),children:L(`noResource`,{name:e})});if(s.isPending)return(0,Y.jsx)(N,{});if(s.error)return(0,Y.jsx)(`div`,{className:`p-8`,children:w(s.error)&&s.error.status===404?(0,Y.jsx)(Sa,{model:o,recordKey:t}):(0,Y.jsx)(W,{title:U(`couldNotLoad`),error:s.error})});let c=(0,Y.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?p(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,Y.jsx)(xe,{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,Y.jsx)(N,{});let e=Dn(f,s.data.record);if(e)return(0,Y.jsx)(On,{to:e})}let m=r[e]?.record;if(!m||d)return c;if(s.isPlaceholderData)return(0,Y.jsx)(N,{});if(`surface`in m||m.focus)return(0,Y.jsx)(yr,{model:o,recordKey:t,stored:s.data,page:m,standard:c});let{record:h,etag:g,permissions:_}=s.data;return(0,Y.jsx)(er,{component:m.component,scope:{model:o,record:h,key:t,etag:g,permissions:_},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,Y.jsx)(N,{}):n.state===`switching`?(0,Y.jsx)(_t,{title:U(`loading`),children:U(`openingElsewhere`)}):n.state===`failed`?(0,Y.jsx)(W,{title:U(`couldNotLoad`),error:n.error}):(0,Y.jsx)(_t,{title:L(`notFound`),children:U(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=O(),{address:a,go:o}=Lt(),s=i.views[e.name],c=De()(e,s,n.record,t),{state:l}=Ve(),d=Yr(e,t),p=fr({model:e,stored:n,recordKey:t,mode:s?.saveFeedback??`toast`,subject:c,draftKey:!r&&l.kind===`signed-in`?nr(l.user.id,e.name,t):void 0,lines:d.draft}),m=Vt(),h=J(),g=Ne(p.rejections),_=je(e.name),b=fn(e),x=a?.kind===`record`&&a.version!==void 0,ee=u(_,`update`)&&n.permissions?.update!==!1&&!x,{shown:S,offersEdit:te,editing:C}=gt(s?.recordMode,ee,a?.kind===`record`&&a.edit===!0);Oe(p.dirty&&S===`form`||p.saving),Le(p.dirty);let w=a?.kind===`record`?a.open:void 0,ne=a?.kind===`record`&&a.edit===!0,T=a?.kind===`record`?a.tab:void 0,E=a?.kind===`record`&&a.standard===!0,D=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...E&&{standard:E}}),ie=D(w,!1,T),ae=D(w,!0,T),k=S===`form`&&s?.recordMode!==void 0&&s.recordMode!==`edit`,se=u(_,`delete`)&&n.permissions?.delete!==!1,le=un({model:e,view:s,restore:b,onDeleted:()=>o({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void m.invalidateQueries({queryKey:M.record(e.name,t)})}),de=Ui(e,i.resources,i.views,n.record),A=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},pe=Object.values(e.fields).filter(e=>A(e.name)),me={...n.record,...Object.fromEntries(pe.map(e=>[e.name,Tt(e,p.value(e.name))]))},he=Ui(e,i.resources,i.views,me),ge=(e,t)=>{let n=A(e);if(!n||!yt(t))return p.change(e,t);m.setQueryData(M.relatedLabel(n.name,t.key),{label:t.label}),p.change(e,ut(n,t.key))},{fields:N}=at(),ye={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},F=Ri(ba(e,s,S===`read`),ye,C,r),{before:xe,tabs:Ce,after:we}=Ir(F),I=Lr(Ce,T),Te=e=>C&&(p.errors[e]!==void 0||p.conflicts[e]!==void 0);(0,X.useEffect)(()=>{if(p.rejections===0)return;let e=zr(Ce,I,Te);e&&o(D(w,ne,e===Ce[0]?void 0:e.title),{replace:!0})},[p.rejections]);let Ee=F.flatMap(e=>e.kind===`sidebar`?e.fields:[]),ke=Zn(e,`updated`),L=e=>s?.fields[e],Ae=t=>Et(n.permissions,t)!==`hidden`&&dt(L(t)?.when,C)&&(S===`form`||!e.fields[t]?.writeOnly),z=e=>!r||Object.hasOwn(n.record,e),B=fa(e,s,n.record,Ee,Ae),Fe=B&&(0,Y.jsxs)(y,{value:n.record[B],hints:L(B),children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[L(B)?.label??V(B),`: `]}),Pe(e.fields[B],n.record[B],L(B))]}),Ie=r=>{let a=e.fields[r],o=Et(n.permissions,r);if(!a||o===`hidden`)return null;let c=p.conflicts[r],l=A(r),u=L(r)?.label??V(r),d=p.errors[r],f=S!==`form`||o===`read`;return(0,Y.jsx)(ve,{name:r,label:u,required:S===`form`&&o!==`read`&&v(a),help:He(L(r),s,C),error:d&&jt(a,u,d),wide:fe(N,a,L(r)),readOnly:Ot(a,L(r),f,!!l),conflict:c===void 0?void 0:{user:{name:U(`someoneElse`),initials:`?`,hue:40},ago:U(`justNow`),theirValue:c||`—`,onKeepMine:()=>p.keepMine(r),onUseTheirs:()=>p.useTheirs(r)},children:z(r)?(0,Y.jsx)(Re,{field:a,hints:L(r),value:p.value(r),stored:n.record[r],relationLabel:he.labels[r],relationTo:he.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:f,invalid:!!p.errors[r],reveal:a.sensitive&&!a.writeOnly?()=>h.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:L(r)?.format===`url`?Ye(e,s,r,n.record,de.labels):void 0,onChange:e=>ge(r,e)}):(0,Y.jsx)(q,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},ze=r=>{let i=e.fields[r],a=z(r)?i.sensitive?(0,Y.jsx)(Re,{field:i,hints:L(r),value:``,stored:n.record[r],locked:!0,reveal:()=>h.reveal(e.name,t,r),resource:e.name,onChange:e=>p.change(r,e)}):(0,Y.jsx)(kt,{model:e,field:i,value:n.record[r],relationLabel:de.labels[r],record:n.record,relationLabels:de.labels}):(0,Y.jsx)(q,{className:`h-4 w-32`});return{label:L(r)?.label??V(r),help:He(L(r),s,C),wide:fe(N,i,L(r)),value:a}},Be=F.findIndex(e=>e.kind===`sidebar`),H=(0,Y.jsx)(Tn,{title:U(`summary`),rows:Ee.flatMap(t=>{let r=e.fields[t];if(!r||!Ae(t))return[];if(!z(t))return[{label:L(t)?.label??V(t),value:(0,Y.jsx)(q,{className:`h-4 w-24`})}];let i=n.record[t],a=f(r,L(t))&&typeof i==`string`&&i!==``,o=r.type===`json`&&i!=null,c=a?Dt(i):o?Mt(i):Pe(r,i,L(t)),l=r.type===`text`&&typeof i==`string`&&i!==``?be(L(t)):void 0,u=r.type===`enum`?(0,Y.jsx)(y,{value:i,hints:L(t),children:c}):l?(0,Y.jsx)(re,{format:l,value:c,label:Ye(e,s,t,n.record,de.labels)}):(0,Y.jsx)(`span`,{title:wt(r,i,void 0,L(t)),children:c}),d=_e(N,r,L(t));return[{label:L(t)?.label??V(t),title:c,value:d?(0,Y.jsx)(ue,{shown:d,part:`display`,field:r,value:n.record[t],fallback:u}):u}]})}),Ue=async()=>{await p.save()&&k&&o(ie,{replace:!0})},We=se?()=>void le.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0,Ke=S===`form`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(R,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:p.saving,disabled:!p.dirty&&p.phase!==`saved`,onClick:()=>void Ue(),children:[p.phase===`saved`&&(0,Y.jsx)(Se,{className:`size-4`}),p.phase===`saved`?U(`saved`):U(`save`)]}),k&&(0,Y.jsx)(P,{to:ie,className:G(Me(),`max-md:min-h-11 md:w-full`),onClick:e=>oe(e)&&p.discard(),children:U(`cancel`)}),p.dirty&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:U(`unsavedChanges`)})]}),Je=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(Je);if(e.length===0)return[];let r=Fr(i,w,Te),a=i.collapsed?D(Pr(w,i.title),ne,T):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||z(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,Y.jsx)(da,{sections:o}):void 0;return[(0,Y.jsx)(Hn,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!d.model||!d.item||r?[]:[(0,Y.jsx)(_a,{lines:{...d,model:d.model,item:d.item},editable:S===`form`,saving:p.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!z(i.from)?[]:[(0,Y.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,Y.jsx)(Or,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,Y.jsx)(Nr,{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,Y.jsx)($n,{item:i,scope:ye,fallback:i.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ii(i).flatMap(([e,t])=>Je(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,Y.jsx)(Sr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,Y.jsx)(hi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,Y.jsx)(Ci,{item:i,model:e,view:s,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,Y.jsx)(ha,{item:i,scope:ye},`thread:${a}`)];if(i.kind===`blocks`)return[(0,Y.jsx)(ga,{item:i,scope:ye},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,Y.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,Y.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:l.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&Ae(t)),c=S===`read`&&i.presentation===`facts`,u=c?qe(n.record,o):o;return u.length===0?[]:[(0,Y.jsx)(j,{title:i.title,help:Ge(i.helpWhen,s,C)?i.help:void 0,children:c?(0,Y.jsx)(Gn,{facts:u.map(e=>({label:ze(e).label,value:ze(e).value,icon:ce(L(e)?.icon)}))}):S===`read`?(0,Y.jsx)(Wn,{rows:u.map(ze)}):(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:u.map(Ie)})},i.title)]},Xe=(e,t)=>e.kind===`map`?(0,Y.jsx)(Sr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,Y.jsx)($n,{item:e,scope:ye,fallback:e.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ii(e).map(([e,t])=>Xe(e,t))})},`custom:${t}`):null;return(0,Y.jsxs)(`div`,{ref:g,className:`flex flex-1 flex-col`,inert:r,children:[le.dialogs,(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsxs)(`div`,{className:G(s?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,Y.jsx)(Bn,{title:c,badge:Fe}),p.message&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(W,{title:U(`notSaved`),error:Error(p.message)})}),p.linesConflict&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(W,{title:U(`linesChanged`),error:Error(U(`linesReloaded`))})}),S!==`form`&&te&&p.dirty&&(0,Y.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,Y.jsx)(`span`,{children:U(`unsavedKept`)}),(0,Y.jsxs)(`span`,{className:`flex gap-2`,children:[(0,Y.jsx)(P,{to:ae,className:Me({size:`sm`}),children:U(`continueEditing`)}),(0,Y.jsx)(R,{size:`sm`,onClick:p.discard,children:U(`discard`)})]})]}),S===`form`&&p.restored&&(0,Y.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,Y.jsx)(`span`,{children:U(`unsavedRestored`)}),(0,Y.jsxs)(`span`,{className:`flex gap-2`,children:[(0,Y.jsx)(R,{size:`sm`,onClick:p.dismissRestored,children:U(`keep`)}),(0,Y.jsx)(R,{size:`sm`,onClick:p.discard,children:U(`discard`)})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,Y.jsxs)(`div`,{className:`divide-y divide-border`,children:[xe.flatMap(Je),I&&(0,Y.jsx)(Un,{tabs:Ce.map((e,t)=>({title:e.title,to:D(w,ne,t===0?void 0:e.title),current:e===I}))}),I&&(0,Y.jsx)(`div`,{className:`divide-y divide-border`,children:I.items.flatMap(Je)},`tab:${I.title}`),we.flatMap(Je)]}),(0,Y.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:[Ke&&(0,Y.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ke}),!r&&(0,Y.jsx)(sr,{model:e,stored:n,recordKey:t,edit:te?ae:void 0,onDelete:We}),Be===-1&&H,F.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Xe(e,t):t===Be?(0,Y.jsx)(X.Fragment,{children:H},`summary`):null),(0,Y.jsx)(Tn,{title:U(`details`),rows:[Zn(e,`created`),ke].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!Ae(t)||Ee.includes(t)?[]:[{label:L(t)?.label??V(t),value:z(t)?(0,Y.jsx)(`span`,{title:wt(r,n.record[t],void 0,L(t)),children:Pe(r,n.record[t],L(t))}):(0,Y.jsx)(q,{className:`h-4 w-24`})}]})}),!r&&(0,Y.jsx)(Xi,{model:e,recordKey:t,layout:F})]})]})]})}),Ke&&(0,Y.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:Ke})]})};export{xa as RecordPage,Yn as t};
|
|
3
|
-
//# debugId=
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-BR34Q9uI.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-C7kZagL3.js","assets/app-BnDutf0s.js","assets/vendor-DQHyyBk1.js","assets/app-DcrDZ6Fc.css","assets/lib-maplibre-gl-CFGgq6sa.js","assets/lib-maplibre-gl-DBE96hFo.css","assets/lib-vis.gl-react-maplibre-CdxVSk--.js","assets/lib-pmtiles-G7iEFxNu.js","assets/lib-fflate-HbhbPPwS.js","assets/record-lines-Dmb8bl38.js","assets/embedded-list-CPgxhzPw.js","assets/update-set-BahNKmxv.js","assets/layout-grid-DCBxzjaE.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-CarOT-Gn.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-rLoyhseD.js","assets/render-node-DGYXKoGV.js","assets/circle-alert-C0Jeesr7.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-BIO4J3ts.js","assets/person-row-DBeHOA2K.js","assets/use-paged-search-DaT4uUhX.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-DkCyHPwg.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,$i as a,Ac as o,An as s,Ar as c,C as l,Ca as u,Cc as d,Ci as f,Cn as p,D as m,Do as h,Dr as g,Dt as _,E as v,En as y,Eo as b,Er as x,Et as ee,Fa as S,Fi as te,Fr as C,Fs as w,Gs as ne,Gt as T,Hc as E,Hi as D,Hn as re,I as ie,Ia as ae,Jo as O,Kc as k,Ks as oe,Ll as se,Lt as ce,Ma as le,Mn as ue,Mo as de,Nl as A,Nn as fe,O as pe,Oi as me,Oo as he,Ot as ge,P as j,Pn as _e,R as ve,Rc as M,Ri as N,Rr as P,Sa as ye,Sc as F,Si as be,Sn as xe,Tc as Se,To as Ce,Tt as we,Ui as I,Uo as Te,Va as Ee,Vi as De,Vs as Oe,Wn as ke,Ws as L,Xn as Ae,Xs as R,Yo as je,Ys as z,Z as B,Zc as V,Zs as Me,_ as Ne,_i as Pe,aa as Fe,ar as Ie,as as Le,b as Re,bo as ze,cc as Be,cs as Ve,ct as H,d as He,ec as Ue,et as We,f as Ge,fa as Ke,fi as qe,fn as Je,g as U,gi as Ye,gn as Xe,go as Ze,gr as W,h as Qe,hl as $e,ir as et,it as tt,jc as G,ji as nt,jl as K,jo as rt,k as it,ka as at,ki as ot,kn as st,ko as ct,kr as lt,l as ut,m as dt,nn as ft,nt as pt,ol as mt,ot as ht,p as gt,qo as _t,qs as q,rt as vt,s as yt,st as bt,tl as xt,ts as J,ui as St,v as Ct,vi as wt,w as Tt,wa as Et,wi as Dt,x as Ot,xn as kt,xo as At,y as jt,yi as Mt,yn as Nt,zc as Pt,zi as Ft,zl as It,zr as Lt,zs as Rt}from"./app-BnDutf0s.js";import{S as zt,i as Bt,m as Vt,o as Ht,r as Ut,s as Wt}from"./vendor-DQHyyBk1.js";import{Ct as Gt,Dt as Kt,Et as qt,Mt as Jt,Tt as Yt,_ as Xt,a as Zt,c as Qt,lt as $t,n as en,ot as tn,pt as nn,rt as rn,s as an,t as on,tt as sn,yt as cn}from"./embedded-list-CPgxhzPw.js";import{a as ln,i as un,n as dn,r as fn,t as pn}from"./reorder-button-9_dAk_3O.js";import{a as mn,c as hn,i as gn,l as _n,n as vn,o as yn,r as bn,s as xn,t as Sn}from"./render-node-DGYXKoGV.js";import{t as Cn}from"./trash-BjnGkZfx.js";import{n as wn,t as Tn}from"./record-sidebar-HqyBXBwn.js";import{t as En}from"./start-block-queries-CmVDv8_F.js";import{n as Dn,t as On}from"./record-opens-Dbjd4FLe.js";import{u as kn}from"./messages-D5XhIbDz.js";var An={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`}]]};An.node;var jn=o(An),Mn={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`}]]};Mn.node;var Nn=o(Mn),Pn={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`}]]};Pn.node;var Fn=o(Pn),In={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`}]]};In.node;var Ln=o(In),Rn={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`}]]};Rn.node;var zn=o(Rn),Y=e(r(),1),Bn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,Y.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,Y.jsxs)(`div`,{children:[e&&(0,Y.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,Y.jsxs)(Y.Fragment,{children:[H(`lastEditedBy`),` `,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,Y.jsx)(Y.Fragment,{children:H(`lastUpdated`,{ago:r.ago})})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(he,{people:i,size:`md`}),H(`viewing`,{count:i.length})]}),a]})]}),X=e(t(),1),Vn=`text-base font-semibold text-foreground`,Hn=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,X.useId)();return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:G(`py-8`,r&&`pb-0`),children:[(0,Y.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,Y.jsxs)(P,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:G(`inline-flex items-center gap-1.5`,Vn),children:[(0,Y.jsx)(F,{className:G(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,Y.jsx)(`span`,{className:Vn,children:e}),n]}),t&&(0,Y.jsx)(`p`,{className:G(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,Y.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,Y.jsx)(ie.Provider,{value:2,children:a})})]})},Un=({tabs:e})=>(0,Y.jsx)(`nav`,{"aria-label":H(`tabs`),className:`overflow-x-auto py-6`,children:(0,Y.jsx)(`span`,{className:At.group(`md`),children:e.map(e=>(0,Y.jsx)(P,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:G(At.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Wn=({rows:e})=>(0,Y.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:G(`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,Y.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Gn=({facts:e})=>(0,Y.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,Y.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),Kn=`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`,qn=({actions:e})=>(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,Y.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:H(`actions`)}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{className:G(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:G(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,Y.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,Y.jsx)(`li`,{children:s?s({className:Kn,children:c}):(0,Y.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:Kn,children:c})},e)})})]}),Jn=e(n(),1),Yn=1e3,Xn=(e,t,n,r,i)=>{let a=C(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,X.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,X.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Zn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),Qn=(e,t)=>e.sidebar?e.title?(0,Y.jsx)(wn,{title:e.title,children:t}):t:e.title?(0,Y.jsx)(j,{title:e.title,children:t}):(0,Y.jsx)(`section`,{className:`py-8`,children:t}),$n=({item:e,scope:t,fallback:n})=>{let{components:r}=at(),i=r?.[e.component],a=i&&(0,Y.jsx)(et,{value:t,children:(0,Y.jsx)(i,{...$e(e.props??{})})});return n===void 0?Qn(e,(0,Y.jsx)(vn,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,Y.jsx)(vn,{name:e.component,registered:!!i,fallback:n,children:Qn(e,a)})},er=({component:e,scope:t,standard:n})=>{let{components:r}=at(),i=r?.[e];return i?(0,Y.jsx)(Ee,{name:e,fallback:n,children:(0,Y.jsx)(tr,{children:(0,Y.jsx)(et,{value:t,children:(0,Y.jsx)(i,{})})})}):n},tr=({children:e})=>(ct(!1),(0,Y.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),nr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,rr=(e,t,n)=>It(()=>{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),ir=(e,t,n)=>It(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),ar=e=>ce(e)??zn,or=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=Lt(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Gt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,X.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Zt(e.run,t.record,a):void 0;return{name:e.label,icon:ar(e.icon),blocked:n,running:c.running===e.name,...Kt(e)&&{tone:`danger`},onRun:()=>qt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,Y.jsx)(ne,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:U(`edit`),icon:ln,render:({className:e,children:t,role:n})=>(0,Y.jsx)(P,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:U(`delete`),icon:Cn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,Y.jsx)(Yt,{action:l,label:l.label,danger:Kt(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)}})}},sr=e=>{let t=Ze(),{actions:n,prompt:r}=or(e);return n.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,Y.jsx)(qn,{actions:n})}),t&&(0,Jn.createPortal)((0,Y.jsx)(bt,{actions:n,label:U(`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]})},cr=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}`},lr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?L(`operationFailed`,{index:n+1,label:cr(r),message:e.message}):L(`nothingSaved`,{message:e.message})},ur=(e,t)=>new e.constructor({...e.problem,detail:lr(e,t)}),dr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),fr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=J(),c=Vt(),u=g(e.name,n),d=Qe(r,i),[f]=(0,X.useState)(()=>a?rr(localStorage,a,t.etag):void 0),[p,h]=(0,X.useState)(f?.fields??{}),[_,v]=(0,X.useState)(!!f),[y,b]=(0,X.useState)(!1),[ee,S]=(0,X.useState)({}),[te,C]=(0,X.useState)({}),[ne,T]=(0,X.useState)(0),E=Object.entries(p).filter(([n,r])=>l(e.fields[n],r,t.record[n])),D=E.length>0,re=D||!!o?.dirty;(0,X.useEffect)(()=>{f?.order&&o?.setOrder(f.order)},[]),(0,X.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(p).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;ir(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,p,o?.order,t.etag]);let ie=n=>n in p?p[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:m(t.record[n]),ae=(n,r)=>{C(e=>dr(e,n));let i=typeof r==`string`?r!==m(t.record[n]):l(e.fields[n],r,t.record[n]);h(e=>i?{...e,[n]:r}:dr(e,n))},O=async()=>{let r=await s.get(e.name,n);c.setQueryData(M.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(p)){let s=e.fields[n];l(s,o,r.record[n])&&(a[n]=o,m(r.record[n])!==m(t.record[n])&&(i[n]=s.type===`file`?Pe(s,r.record[n]):m(r.record[n])))}h(a),S(i)},k=()=>Object.fromEntries(E.map(([t,n])=>[t,it(e.fields[t],n)])),oe=e=>{let t=Ct(e);C(t),Object.keys(t).length>0&&T(e=>e+1)},se=async()=>{try{await u.mutateAsync({patch:k(),etag:t.etag})}catch(e){throw x(e)?await O():w(e)&&oe(e),e}},ce=async r=>{let i=D?[{op:`update`,resource:e.name,key:n,data:k(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(x(e))await O(),await c.invalidateQueries({queryKey:[`list`]}),b(!0);else if(w(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?oe(e):n&&o?.reject(n,e)}throw w(e)?ur(e,a):e}await Promise.all([c.invalidateQueries({queryKey:M.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:ie,change:ae,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await ce(e):await se(),h({}),S({}),C({}),b(!1),v(!1)}),dirty:re,discard:()=>{h({}),S({}),C({}),b(!1),v(!1),o?.reset()},restored:_&&re,dismissRestored:()=>v(!1),linesConflict:y,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:ee,errors:te,rejections:ne,keepMine:e=>S(t=>dr(t,e)),useTheirs:e=>{S(t=>dr(t,e)),h(t=>dr(t,e))}}},Z=Pt(`focus-record`),pr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,Y.jsx)(Y.Fragment,{children:e.map(({name:e,label:r})=>[(0,Y.jsx)(R,{size:`sm`,onClick:()=>t(e),children:Z(`keepMine`,{field:r})},`mine:${e}`),(0,Y.jsx)(R,{size:`sm`,onClick:()=>n(e),children:Z(`useTheirs`,{field:r})},`theirs:${e}`)])}),mr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=vt(`primary`),o=ht()?.size===`compact`,s=(0,Y.jsx)(R,{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,Y.jsx)(pt,{zone:`secondary`,children:s}):(0,Y.jsx)(pt,{zone:`primary`,fallback:!0,children:s})},hr=({record:e,saved:t,readOnly:n})=>{let r=ht()?.size,i=n?Z(`readOnly`):e.saving?Z(`saving`):e.dirty?Z(r===`wide`?`unsaved`:`unsavedShort`):t?Z(`saved`):void 0;return i?(0,Y.jsx)(pt,{zone:`state`,fallback:!0,children:(0,Y.jsxs)(`span`,{role:`status`,title:n?Z(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,Y.jsx)(Se,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},gr=({model:e,recordKey:t,stored:n,page:r})=>{let a=O().views[e.name],{address:o,go:s}=Lt(),c=De()(e,a,n.record,t),{state:l}=Ve(),d=fr({model:e,stored:n,recordKey:t,mode:`button`,subject:c,draftKey:l.kind===`signed-in`?`${nr(l.user.id,e.name,t)}:focus`:void 0});Oe(d.dirty||d.saving),Le(d.dirty);let f=Vt(),[p,m]=(0,X.useState)(!1),h=a?.names?.singular??V(e.name),g=je(e.name),_=fn(e),v=o?.kind===`record`&&o.version!==void 0&&o.version!==Number(n.record.version),y=`surface`in r&&(Et(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),b=u(g,`update`)&&n.permissions?.update!==!1&&!y,x=!b||v,ee=u(g,`delete`)&&n.permissions?.delete!==!1,S=un({model:e,view:a,restore:_,onDeleted:()=>s({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void f.invalidateQueries({queryKey:M.record(e.name,t)})}),{actions:te,prompt:C}=or({model:e,stored:n,recordKey:t,onDelete:ee?()=>void S.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0}),w=(0,X.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),ne=te.filter(e=>e.tone===`danger`),T=[...te.filter(e=>e.tone!==`danger`),...d.dirty?[{name:Z(`discardChanges`),icon:Ln,onRun:()=>m(!0)}]:[],{name:Z(`detailsOf`,{noun:h}),icon:Fn,render:({className:e,children:t,role:n})=>(0,Y.jsx)(P,{to:w,role:n,className:e,children:t})},...ne],E={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:x,mayUpdate:b,value:d.value,change:(e,t)=>x?void 0:d.change(e,t),dirty:d.dirty,saving:d.saving,refused:d.message!==void 0,save:async()=>!x&&!!await d.save(),discard:d.discard,details:w},D=`surface`in r?r.surface:void 0,re=p&&d.dirty&&(0,Y.jsx)(We,{level:`draft`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{size:`sm`,variant:`danger`,onClick:()=>{d.discard(),m(!1)},children:Z(`discardChanges`)}),(0,Y.jsx)(R,{size:`sm`,onClick:()=>m(!1),children:Z(`keep`)})]}),children:Z(`discardAsk`)}),ie=Object.keys(d.conflicts).length>0,ae=D?d.errors[D]:void 0,k=ae&&D?jt(e.fields[D],a?.fields[D]?.label??V(D),ae):void 0;return(0,Y.jsxs)(B.Provider,{value:E,children:[!x&&(0,Y.jsx)(mr,{record:E,label:Z(`save`)}),(0,Y.jsx)(hr,{record:E,saved:d.phase===`saved`,readOnly:x}),(0,Y.jsx)(i,{actions:T}),d.message&&!p&&(0,Y.jsxs)(We,{level:`refused`,actions:(0,Y.jsx)(P,{to:w,className:`text-body font-medium text-primary-text hover:underline`,children:Z(`detailsOf`,{noun:h})}),children:[(0,Y.jsx)(`strong`,{className:`font-medium`,children:Z(`notSaved`)}),` `,k??d.message]}),ie&&(0,Y.jsx)(We,{level:`conflict`,actions:(0,Y.jsx)(pr,{fields:Object.keys(d.conflicts).map(e=>({name:e,label:a?.fields[e]?.label??V(e)})),onKeepMine:d.keepMine,onUseTheirs:d.useTheirs}),children:Z(`conflict`)}),re,d.restored&&!p&&(0,Y.jsx)(We,{level:`draft`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(R,{size:`sm`,onClick:d.dismissRestored,children:Z(`keep`)}),(0,Y.jsx)(R,{size:`sm`,onClick:d.discard,children:Z(`discard`)})]}),children:Z(`restored`)}),D?(0,Y.jsx)(_r,{model:e,name:D,stored:n,editor:d,readOnly:x}):(0,Y.jsx)(vr,{name:r.component,model:e,stored:n,recordKey:t}),S.dialogs,C]})},_r=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=O().views[e.name]?.fields[t];if(Et(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,Y.jsx)(`div`,{className:`absolute inset-0`,children:(0,Y.jsx)(Re,{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)})})},vr=({name:e,model:t,stored:n,recordKey:r})=>{let i=at().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,Y.jsx)(`div`,{className:`absolute inset-0`,children:(0,Y.jsx)(et,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,Y.jsx)(i,{})})})},yr=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=De()(e,O().views[e.name],n.record,t);return(0,Y.jsx)(Ee,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,Y.jsx)(tt,{label:a,children:(0,Y.jsx)(gr,{model:e,recordKey:t,stored:n,page:r})})})},br=(0,X.lazy)(()=>zt(()=>import(`./record-map-BR34Q9uI.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),xr=15,Sr=({item:e,record:t})=>{let n=O().maps,r=n?.style,i=Xt(t,e);if(!r||!i)return null;let a=(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,Y.jsx)(X.Suspense,{fallback:null,children:(0,Y.jsx)(br,{style:r,layers:n?.layers,position:i,zoom:e.zoom??xr},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,Y.jsx)(wn,{title:e.title,children:a}):(0,Y.jsx)(j,{title:e.title,children:a})},Cr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},wr=(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}))},Q=Pt(`app/record-chart`),Tr=K(),Er=[`1h`,`24h`,`7d`],Dr={"1h":`hour`,"24h":`day`,"7d":`week`},Or=({item:e,recordKey:t})=>{let{resources:n,views:r}=O(),[i,a]=(0,X.useState)(e.range??`1h`),[o,s]=(0,X.useState)(`average`),l=n[e.resource],u=r[e.resource],d=Cr[i],f=A(Tr.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...o===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:Ke()})),m=c(e.resource,p,!!l);if(!l)return null;let h=e.series.map(e=>({kind:o,field:l.fields[e],...u?.fields[e]&&{hints:u.fields[e]}})),g=e.series.map((e,t)=>({key:`s${t}`,label:u?.fields[e]?.label??V(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?wr(m.map(e=>e.data.groups),g.map(e=>e.key),o):[],v=(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(ze,{label:Q(`measure`),value:o,onChange:s,options:[{value:`average`,label:Q(`average`)},{value:`maximum`,label:Q(`maximum`)}]}),(0,Y.jsx)(ze,{label:Q(`range`),value:i,onChange:a,options:Er.map(e=>({value:e,label:Q(Dr[e])}))})]});return(0,Y.jsx)(j,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,Y.jsx)(`p`,{className:`text-danger-text`,children:Q(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,Y.jsx)(q,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Q(`noSamples`)}):(0,Y.jsx)(nn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},kr=Pt(`app/record-trend`),Ar=(e,t)=>kr(`total_${t}`,{count:e}),jr=K(),Mr={kind:`count`},Nr=({item:e,recordKey:t})=>{let n=A(jr.eq(e.field,t)),r=lt(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Ke()});return(0,Y.jsx)(j,{title:e.title,help:e.help,children:(0,Y.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,Y.jsx)(q,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,Y.jsx)(W,{title:kr(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:Ar(t,e.range)}),(0,Y.jsx)(nn,{points:cn(r.data.groups,Mr),measure:Mr,bucket:e.granularity,type:`bar`})]})})()})})},Pr=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],Fr=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),Ir=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)}},Lr=(e,t)=>e.find(e=>e.title===t)??e[0],Rr=e=>mt(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),zr=(e,t,n)=>{if(t&&!Rr(t).some(n))return e.find(e=>Rr(e).some(n))},Br={added:[],edits:{},removed:[]},Vr=(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},Hr=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&l(i,r,n[t])?[[t,it(i,r)]]:[]})),Ur=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,it(r,n)]]})),Wr=({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=>[D(e,t),t])),c=[...s.keys()],l=Vr(c,i),u=t=>I(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=Hr(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?[[xt(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:{...Ur(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},Gr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Kr=(e,t)=>{let[n,r]=(0,X.useState)(Br),[i,a]=(0,X.useState)(),o=(0,X.useRef)(1),s=(0,X.useMemo)(()=>new Map(e?t.map(t=>[D(e.model,t),t]):[]),[e,t]),c=Vr([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Wr({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,d=(0,X.useMemo)(()=>{let e=Vr([...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:pe(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:Gr(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Br),a(void 0)},reject:(e,t)=>a({id:e,fields:Ct(t),message:t.message}),rejection:i,plan:l}},qr=(e,t)=>{let n=mt(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}},Jr=(e,t,n,r)=>k(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Yr=(e,t)=>{let{resources:n,views:r}=O(),i=(0,X.useMemo)(()=>qr(n,r[e.name]),[n,r,e]),a=i?.model,o=i?Jr(i.model,r[i.model.name],i.link.name,i.position):[],s=Xn(a,i?.link,i?.position,t,a?Ae(n,r,a,o):void 0),c=Kr((0,X.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:ut(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Xr=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Zr=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,Qr=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,$r=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),ei=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,ti=`protobase:lightbox-details`,ni=e=>It(()=>e.getItem(ti)===`true`,!1),ri=(e,t)=>It(()=>t?e.setItem(ti,`true`):e.removeItem(ti),void 0),$=Pt(`app/gallery`),ii=`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`,ai=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=$(`details`)})=>{let s=(0,X.useRef)(null),c=(0,X.useRef)(void 0),l=(0,X.useId)(),u=rt(),[f,p]=(0,X.useState)(()=>ni(localStorage)),[m,h]=(0,X.useState)(!1);z(s,!0,i),(0,X.useEffect)(()=>h(!0),[]);let g=t.length,_=e=>{let t=$r(n,e,g);t!==n&&r(t)},v=ot(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{p(e),ri(localStorage,e)};return(0,Y.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&ei(e))return e.preventDefault(),x(!f);let t=Qr(e.key);t!==0&&(e.preventDefault(),_(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,Y.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,Y.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${g}`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":f,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!f),children:(0,Y.jsx)(Nn,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsx)(`button`,{type:`button`,className:ii,"aria-label":$(`close`),onClick:i,children:(0,Y.jsx)(Ue,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,Y.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&&=(_(Zr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,Y.jsx)(ke,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),g>1&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`previousPhoto`),"aria-disabled":n===0,onClick:()=>_(-1),children:(0,Y.jsx)(d,{className:`size-5`,"aria-hidden":!0})}),(0,Y.jsx)(`button`,{type:`button`,className:G(ii,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`nextPhoto`),"aria-disabled":n===g-1,onClick:()=>_(1),children:(0,Y.jsx)(F,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&f&&u&&(0,Y.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,Y.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),y]}),(0,Y.jsx)(T,{title:o,open:b&&f&&!u&&m,onClose:()=>x(!1),children:(0,Y.jsx)(`div`,{className:`pt-3`,children:y})})]})},oi=(e,t,n)=>{let r=mt(t?.layout??[]).flatMap(e=>e.kind===`section`&&dt(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)&&dt(t?.fields[r]?.when,!1))},si=({model:e,view:t,photoKey:n,fields:r})=>{let i=ae(e.name,n),a=(t?.names?.singular??V(e.name)).toLowerCase();if(i.isPending)return(0,Y.jsx)(q,{className:`h-4 w-48`});if(i.error)return(0,Y.jsx)(W,{title:$(`couldNotLoadOne`,{singular:a}),error:i.error});let o=r.filter(e=>Et(i.data.permissions,e)!==`hidden`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Wn,{rows:o.map(n=>({label:t?.fields[n]?.label??V(n),value:(0,Y.jsx)(kt,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,Y.jsx)(P,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:a})})]})},ci=e=>ot(e,{width:0,height:0})!==void 0,li=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return xt(n)},ui=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!me(t)||!ci(t))return[];let i=r&&li(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!me(e)||!ci(e))return i;let a=t=>me(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))]},di=K(),fi=(e,t,n)=>{let r=J(),{resources:i}=O(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?A(di.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Ht({queryKey:M.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:ui(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},pi={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`,``,``,``,``]},mi=({photo:e,large:t})=>{let n=ot(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,Y.jsx)(ke,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},hi=({item:e,record:t,recordKey:n})=>{let{views:r}=O(),i=fi(e,t,n),a=je(i.holder?.name??``),[o,s]=(0,X.useState)();if(i.isPending)return(0,Y.jsx)(j,{title:e.title,children:(0,Y.jsx)(q,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,Y.jsx)(j,{title:e.title,children:(0,Y.jsx)(W,{title:$(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=Xr(c),d=i.holder,f=d&&r[d.name],p=d?oi(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,Y.jsxs)(j,{title:e.title,children:[(0,Y.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,Y.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:c}):$(`showPhoto`,{index:t+1,count:c}),onClick:()=>s(t),className:G(`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`,pi[l][t]),children:[(0,Y.jsx)(mi,{photo:e.file,large:t===0}),n&&(0,Y.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,Y.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,Y.jsx)(jn,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,Y.jsx)(ai,{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,Y.jsx)(si,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&$(`holderDetails`,{singular:f?.names?.singular??V(d.name)})})]})},gi=Pt(`app/history`),_i=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?gi(`databaseRole`,{role:e.databaseRole}):gi(`database`),vi=(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??V(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:Pe(i,e.before[r],a),after:Pe(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?gi(`changedThis`):gi(e.operation);return{who:_i(e),verb:i,fields:r}},yi=1500,bi=(e,t,n,r)=>{let i=J(),a=Ut({queryKey:M.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,X.useEffect)(()=>{let e=setTimeout(()=>void o(),yi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},xi=()=>(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(q,{className:`h-4 w-full`},t))}),Si=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:o}=vi(e,t,n),s=Date.parse(e.at);return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,Y.jsxs)(`time`,{dateTime:e.at,title:a(s),className:`text-muted-foreground`,children:[`· `,Fe(Math.max(0,Math.round((Date.now()-s)/1e3)))]})]}),o.length>0&&(0,Y.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:o.map(e=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,Y.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},Ci=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=bi(t.name,r,e.limit??10,i);return(0,Y.jsx)(j,{title:e.title,children:a.isPending?(0,Y.jsx)(xi,{}):a.error?(0,Y.jsx)(W,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,Y.jsx)(Si,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,Y.jsx)(R,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},wi=({comment:e})=>(0,Y.jsx)(we,{text:e.body,mentions:e.mentions}),Ti=(e,t)=>{let n=J(),r=Vt();return Bt({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:M.comments(e,t)})})},Ei=Pt(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,X.useState)(_),i=J(),a=le(),o=Ti(e,t),s=(0,X.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Oe(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:ge(n.text,n.picked)},{onSuccess:()=>r(_),onError:e=>a.show({state:`error`,title:Ei(`couldNotPost`),description:St(e)})})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(ee,{"aria-label":Ei(`comment`),placeholder:Ei(`placeholder`),value:n,onChange:r,searchPeople:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(R,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:Ei(`comment`)})})]})},Oi=20,ki=(e,t)=>{let n=J(),r=Ut({queryKey:M.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,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(q,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,Y.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(h,{initials:b(t)||`?`,hue:Ce(e.author.id),size:`md`,className:`ring-0`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,Y.jsxs)(`time`,{dateTime:e.createdAt,title:a(n),className:`text-muted-foreground`,children:[`· `,Fe(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,Y.jsx)(wi,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,Y.jsxs)(j,{title:e.title,children:[i.isPending?(0,Y.jsx)(Ai,{}):i.error?(0,Y.jsx)(W,{title:Ei(`couldNotLoad`),error:i.error}):(0,Y.jsxs)(Y.Fragment,{children:[i.hasNextPage&&(0,Y.jsx)(R,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:Ei(`showEarlier`)}),i.items.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Ei(`noComments`)}):(0,Y.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,Y.jsx)(ji,{comment:e},e.id))})]}),r&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.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=>Rt(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 Rt(a)?!r&&t[i++]===!0:dt(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,yn(i,t),n,r)},zi=K(),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:A(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=J(),{session:r,organizations:i}=Ve(),a=(0,X.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,X.useState)(a?{state:`looking`}:{state:`missing`});return(0,X.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=J(),a=Vt(),o=De(),c=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),l=Wt({queries:c.map(e=>{let o=t[e.relation.resource];return s(a,i,o,n[o.name],String(r[e.name]))})}),u=c.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(c.map((e,t)=>[e.name,u[t]])),labels:Object.fromEntries(c.map((e,i)=>{let a=t[e.relation.resource];return[e.name,st(l[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=K(),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??V(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??V(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:A(Wi.eq(e.field,t))}),Ji=K(),Yi=(e,t,n)=>{let r=J(),i=Wt({queries:e.map(e=>{let i=A(Ji.eq(e.field,n));return{queryKey:M.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}=O(),{components:a}=at(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,Y.jsx)(wn,{title:U(`relatedRecords`),children:(0,Y.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(P,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,Y.jsx)(q,{className:`h-4 w-6`}):`${te(n.count)}${n.exact?``:`+`}`,(0,Y.jsx)(F,{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,Y.jsx)(q,{className:`inline-block h-5 w-7 rounded-full`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Te,{dot:!1,className:G(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(E())})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t?H(`headingCount`,{count:e,...t}):H(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&ye(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e??_n(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??V(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:a,sort:o,fields:s,button:c,empty:l,add:u})=>{let d=de(),{resources:f}=O(),p=o||nt(r,i),m=Nt(r,{filter:a,sort:p,pageSize:2});if(m.isPending)return(0,Y.jsx)(j,{title:e,help:t,count:n,children:(0,Y.jsx)(q,{className:`h-24 w-full`})});if(m.error)return(0,Y.jsx)(j,{title:e,help:t,count:n,children:(0,Y.jsx)(W,{title:_n(`couldNotLoad`),error:m.error})});let[h,g]=m.data.items;if(!h){let a=u&&(0,Y.jsxs)(P,{to:u,className:Me({size:`sm`}),children:[(0,Y.jsx)(Be,{className:`size-3.5`}),_n(`add`,{singular:ea(r,i)})]});return(0,Y.jsx)(j,{title:e,help:t,count:n,actions:a,children:(0,Y.jsx)($i,{empty:l})})}let _=Xe(r,h),v=ea(r,i),y=i?.names?.plural??V(r.name),b=s.length>1,x=s.map(e=>(0,Y.jsx)(hn,{scope:_,path:e,labelled:b},e)),ee=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c&&(0,Y.jsx)(sn,{button:c,model:r,view:i,record:h,models:f}),(0,Y.jsx)(P,{to:{kind:`record`,resource:r.name,key:I(r,h)},className:Me({size:`sm`}),children:_n(`open`,{singular:v})})]});return(0,Y.jsx)(j,{title:e,help:t,count:n,actions:ee,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[b?(0,Y.jsx)(`dl`,{className:`flex flex-col gap-4`,children:x}):x,g&&(0,Y.jsxs)(P,{to:tn(r,i,d,{filter:a,orderBy:p,display:rn(i,d,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[$t(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:y.toLowerCase()}),(0,Y.jsx)(Jt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=K(),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(A(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=se(ra(A(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(A(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=J(),{resources:r}=O(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Wt({queries:i.map(({model:e,match:r})=>({...Je(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=K(),ca=({empty:e})=>(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e??U(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=O(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=mn(s,`related:${n}:${e.title}`,e.display),d=je(e.resource),[f,p]=(0,X.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,Y.jsx)(Zi,{count:m,names:s?.names}):void 0},g=an(e,o,r),_=e.columns??k(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,Y.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,Y.jsx)(j,{...h,children:v(n=>(0,Y.jsx)(xn,{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,Y.jsx)(j,{...h,children:(0,Y.jsx)(ca,{empty:e.empty})}):(0,Y.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=kn(e,o,d),b=(0,Y.jsx)(on,{view:s,value:l,onChange:u}),x=y?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,Y.jsx)(pn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,Y.jsx)(j,{...h,actions:x,children:(0,Y.jsx)(dn,{model:o,view:s,field:y,filter:A(sa.eq(e.field,t)),columns:_})}):(0,Y.jsx)(j,{...h,actions:x,children:v(t=>(0,Y.jsx)(en,{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:Qt(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=O(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,Y.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=K(),ma=(e,t)=>A(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=O(),[r]=yn(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,Y.jsx)(j,{title:e.title,help:e.help,children:(0,Y.jsx)(bn,{children:(0,Y.jsx)(gn,{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,Y.jsx)(Ie,{value:t,children:(0,Y.jsxs)(ft,{tree:n,plan:r,children:[(0,Y.jsx)(En,{tree:n,plan:r}),(0,Y.jsx)(Sn,{node:n,at:``})]})})},_a=Ft(()=>zt(()=>import(`./record-lines-Dmb8bl38.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,Y.jsx)(q,{className:`h-32 w-full rounded-lg`})),va=Ft(()=>zt(()=>import(`./composer-section-rLoyhseD.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,Y.jsx)(q,{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:U(`details`),fields:a},...e.history?[{kind:`history`,title:U(`history`)}]:[],...e.comments?[{kind:`comments`,title:U(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=O(),{address:i}=Lt(),a=at(),o=n[e],s=S(e,t);if(!o)return(0,Y.jsx)(_t,{title:L(`notFound`),children:L(`noResource`,{name:e})});if(s.isPending)return(0,Y.jsx)(N,{});if(s.error)return(0,Y.jsx)(`div`,{className:`p-8`,children:w(s.error)&&s.error.status===404?(0,Y.jsx)(Sa,{model:o,recordKey:t}):(0,Y.jsx)(W,{title:U(`couldNotLoad`),error:s.error})});let c=(0,Y.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?p(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,Y.jsx)(xe,{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,Y.jsx)(N,{});let e=Dn(f,s.data.record);if(e)return(0,Y.jsx)(On,{to:e})}let m=r[e]?.record;if(!m||d)return c;if(s.isPlaceholderData)return(0,Y.jsx)(N,{});if(`surface`in m||m.focus)return(0,Y.jsx)(yr,{model:o,recordKey:t,stored:s.data,page:m,standard:c});let{record:h,etag:g,permissions:_}=s.data;return(0,Y.jsx)(er,{component:m.component,scope:{model:o,record:h,key:t,etag:g,permissions:_},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,Y.jsx)(N,{}):n.state===`switching`?(0,Y.jsx)(_t,{title:U(`loading`),children:U(`openingElsewhere`)}):n.state===`failed`?(0,Y.jsx)(W,{title:U(`couldNotLoad`),error:n.error}):(0,Y.jsx)(_t,{title:L(`notFound`),children:U(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=O(),{address:a,go:o}=Lt(),s=i.views[e.name],c=De()(e,s,n.record,t),{state:l}=Ve(),d=Yr(e,t),p=fr({model:e,stored:n,recordKey:t,mode:s?.saveFeedback??`toast`,subject:c,draftKey:!r&&l.kind===`signed-in`?nr(l.user.id,e.name,t):void 0,lines:d.draft}),m=Vt(),h=J(),g=Ne(p.rejections),_=je(e.name),b=fn(e),x=a?.kind===`record`&&a.version!==void 0,ee=u(_,`update`)&&n.permissions?.update!==!1&&!x,{shown:S,offersEdit:te,editing:C}=gt(s?.recordMode,ee,a?.kind===`record`&&a.edit===!0);Oe(p.dirty&&S===`form`||p.saving),Le(p.dirty);let w=a?.kind===`record`?a.open:void 0,ne=a?.kind===`record`&&a.edit===!0,T=a?.kind===`record`?a.tab:void 0,E=a?.kind===`record`&&a.standard===!0,D=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...E&&{standard:E}}),ie=D(w,!1,T),ae=D(w,!0,T),k=S===`form`&&s?.recordMode!==void 0&&s.recordMode!==`edit`,se=u(_,`delete`)&&n.permissions?.delete!==!1,le=un({model:e,view:s,restore:b,onDeleted:()=>o({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void m.invalidateQueries({queryKey:M.record(e.name,t)})}),de=Ui(e,i.resources,i.views,n.record),A=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},pe=Object.values(e.fields).filter(e=>A(e.name)),me={...n.record,...Object.fromEntries(pe.map(e=>[e.name,Tt(e,p.value(e.name))]))},he=Ui(e,i.resources,i.views,me),ge=(e,t)=>{let n=A(e);if(!n||!yt(t))return p.change(e,t);m.setQueryData(M.relatedLabel(n.name,t.key),{label:t.label}),p.change(e,ut(n,t.key))},{fields:N}=at(),ye={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},F=Ri(ba(e,s,S===`read`),ye,C,r),{before:xe,tabs:Ce,after:we}=Ir(F),I=Lr(Ce,T),Te=e=>C&&(p.errors[e]!==void 0||p.conflicts[e]!==void 0);(0,X.useEffect)(()=>{if(p.rejections===0)return;let e=zr(Ce,I,Te);e&&o(D(w,ne,e===Ce[0]?void 0:e.title),{replace:!0})},[p.rejections]);let Ee=F.flatMap(e=>e.kind===`sidebar`?e.fields:[]),ke=Zn(e,`updated`),L=e=>s?.fields[e],Ae=t=>Et(n.permissions,t)!==`hidden`&&dt(L(t)?.when,C)&&(S===`form`||!e.fields[t]?.writeOnly),z=e=>!r||Object.hasOwn(n.record,e),B=fa(e,s,n.record,Ee,Ae),Fe=B&&(0,Y.jsxs)(y,{value:n.record[B],hints:L(B),children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[L(B)?.label??V(B),`: `]}),Pe(e.fields[B],n.record[B],L(B))]}),Ie=r=>{let a=e.fields[r],o=Et(n.permissions,r);if(!a||o===`hidden`)return null;let c=p.conflicts[r],l=A(r),u=L(r)?.label??V(r),d=p.errors[r],f=S!==`form`||o===`read`;return(0,Y.jsx)(ve,{name:r,label:u,required:S===`form`&&o!==`read`&&v(a),help:He(L(r),s,C),error:d&&jt(a,u,d),wide:fe(N,a,L(r)),readOnly:Ot(a,L(r),f,!!l),conflict:c===void 0?void 0:{user:{name:U(`someoneElse`),initials:`?`,hue:40},ago:U(`justNow`),theirValue:c||`—`,onKeepMine:()=>p.keepMine(r),onUseTheirs:()=>p.useTheirs(r)},children:z(r)?(0,Y.jsx)(Re,{field:a,hints:L(r),value:p.value(r),stored:n.record[r],relationLabel:he.labels[r],relationTo:he.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:f,invalid:!!p.errors[r],reveal:a.sensitive&&!a.writeOnly?()=>h.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:L(r)?.format===`url`?Ye(e,s,r,n.record,de.labels):void 0,onChange:e=>ge(r,e)}):(0,Y.jsx)(q,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},ze=r=>{let i=e.fields[r],a=z(r)?i.sensitive?(0,Y.jsx)(Re,{field:i,hints:L(r),value:``,stored:n.record[r],locked:!0,reveal:()=>h.reveal(e.name,t,r),resource:e.name,onChange:e=>p.change(r,e)}):(0,Y.jsx)(kt,{model:e,field:i,value:n.record[r],relationLabel:de.labels[r],record:n.record,relationLabels:de.labels}):(0,Y.jsx)(q,{className:`h-4 w-32`});return{label:L(r)?.label??V(r),help:He(L(r),s,C),wide:fe(N,i,L(r)),value:a}},Be=F.findIndex(e=>e.kind===`sidebar`),H=(0,Y.jsx)(Tn,{title:U(`summary`),rows:Ee.flatMap(t=>{let r=e.fields[t];if(!r||!Ae(t))return[];if(!z(t))return[{label:L(t)?.label??V(t),value:(0,Y.jsx)(q,{className:`h-4 w-24`})}];let i=n.record[t],a=f(r,L(t))&&typeof i==`string`&&i!==``,o=r.type===`json`&&i!=null,c=a?Dt(i):o?Mt(i):Pe(r,i,L(t)),l=r.type===`text`&&typeof i==`string`&&i!==``?be(L(t)):void 0,u=r.type===`enum`?(0,Y.jsx)(y,{value:i,hints:L(t),children:c}):l?(0,Y.jsx)(re,{format:l,value:c,label:Ye(e,s,t,n.record,de.labels)}):(0,Y.jsx)(`span`,{title:wt(r,i,void 0,L(t)),children:c}),d=_e(N,r,L(t));return[{label:L(t)?.label??V(t),title:c,value:d?(0,Y.jsx)(ue,{shown:d,part:`display`,field:r,value:n.record[t],fallback:u}):u}]})}),Ue=async()=>{await p.save()&&k&&o(ie,{replace:!0})},We=se?()=>void le.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0,Ke=S===`form`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(R,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:p.saving,disabled:!p.dirty&&p.phase!==`saved`,onClick:()=>void Ue(),children:[p.phase===`saved`&&(0,Y.jsx)(Se,{className:`size-4`}),p.phase===`saved`?U(`saved`):U(`save`)]}),k&&(0,Y.jsx)(P,{to:ie,className:G(Me(),`max-md:min-h-11 md:w-full`),onClick:e=>oe(e)&&p.discard(),children:U(`cancel`)}),p.dirty&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:U(`unsavedChanges`)})]}),Je=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(Je);if(e.length===0)return[];let r=Fr(i,w,Te),a=i.collapsed?D(Pr(w,i.title),ne,T):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||z(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,Y.jsx)(da,{sections:o}):void 0;return[(0,Y.jsx)(Hn,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!d.model||!d.item||r?[]:[(0,Y.jsx)(_a,{lines:{...d,model:d.model,item:d.item},editable:S===`form`,saving:p.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!z(i.from)?[]:[(0,Y.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,Y.jsx)(Or,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,Y.jsx)(Nr,{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,Y.jsx)($n,{item:i,scope:ye,fallback:i.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ii(i).flatMap(([e,t])=>Je(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,Y.jsx)(Sr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,Y.jsx)(hi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,Y.jsx)(Ci,{item:i,model:e,view:s,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,Y.jsx)(ha,{item:i,scope:ye},`thread:${a}`)];if(i.kind===`blocks`)return[(0,Y.jsx)(ga,{item:i,scope:ye},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,Y.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,Y.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:l.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&Ae(t)),c=S===`read`&&i.presentation===`facts`,u=c?qe(n.record,o):o;return u.length===0?[]:[(0,Y.jsx)(j,{title:i.title,help:Ge(i.helpWhen,s,C)?i.help:void 0,children:c?(0,Y.jsx)(Gn,{facts:u.map(e=>({label:ze(e).label,value:ze(e).value,icon:ce(L(e)?.icon)}))}):S===`read`?(0,Y.jsx)(Wn,{rows:u.map(ze)}):(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:u.map(Ie)})},i.title)]},Xe=(e,t)=>e.kind===`map`?(0,Y.jsx)(Sr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,Y.jsx)($n,{item:e,scope:ye,fallback:e.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ii(e).map(([e,t])=>Xe(e,t))})},`custom:${t}`):null;return(0,Y.jsxs)(`div`,{ref:g,className:`flex flex-1 flex-col`,inert:r,children:[le.dialogs,(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsxs)(`div`,{className:G(s?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,Y.jsx)(Bn,{title:c,badge:Fe}),p.message&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(W,{title:U(`notSaved`),error:Error(p.message)})}),p.linesConflict&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(W,{title:U(`linesChanged`),error:Error(U(`linesReloaded`))})}),S!==`form`&&te&&p.dirty&&(0,Y.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,Y.jsx)(`span`,{children:U(`unsavedKept`)}),(0,Y.jsxs)(`span`,{className:`flex gap-2`,children:[(0,Y.jsx)(P,{to:ae,className:Me({size:`sm`}),children:U(`continueEditing`)}),(0,Y.jsx)(R,{size:`sm`,onClick:p.discard,children:U(`discard`)})]})]}),S===`form`&&p.restored&&(0,Y.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,Y.jsx)(`span`,{children:U(`unsavedRestored`)}),(0,Y.jsxs)(`span`,{className:`flex gap-2`,children:[(0,Y.jsx)(R,{size:`sm`,onClick:p.dismissRestored,children:U(`keep`)}),(0,Y.jsx)(R,{size:`sm`,onClick:p.discard,children:U(`discard`)})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,Y.jsxs)(`div`,{className:`divide-y divide-border`,children:[xe.flatMap(Je),I&&(0,Y.jsx)(Un,{tabs:Ce.map((e,t)=>({title:e.title,to:D(w,ne,t===0?void 0:e.title),current:e===I}))}),I&&(0,Y.jsx)(`div`,{className:`divide-y divide-border`,children:I.items.flatMap(Je)},`tab:${I.title}`),we.flatMap(Je)]}),(0,Y.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:[Ke&&(0,Y.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ke}),!r&&(0,Y.jsx)(sr,{model:e,stored:n,recordKey:t,edit:te?ae:void 0,onDelete:We}),Be===-1&&H,F.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Xe(e,t):t===Be?(0,Y.jsx)(X.Fragment,{children:H},`summary`):null),(0,Y.jsx)(Tn,{title:U(`details`),rows:[Zn(e,`created`),ke].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!Ae(t)||Ee.includes(t)?[]:[{label:L(t)?.label??V(t),value:z(t)?(0,Y.jsx)(`span`,{title:wt(r,n.record[t],void 0,L(t)),children:Pe(r,n.record[t],L(t))}):(0,Y.jsx)(q,{className:`h-4 w-24`})}]})}),!r&&(0,Y.jsx)(Xi,{model:e,recordKey:t,layout:F})]})]})]})}),Ke&&(0,Y.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:Ke})]})};export{xa as RecordPage,Yn as t};
|
|
3
|
+
//# debugId=e7a68ffc-b847-4630-8c07-d896b9cfd5fd
|