@protobase/ui 0.117.5 → 0.117.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/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-types/widget-part.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/field-types/workflow-status/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/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/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/searches/messages.d.ts +2 -2
- package/dist/app/searches/use-save-search.d.ts +1 -1
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/compact-table/messages.d.ts +2 -2
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/forms/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/live/messages.d.ts +2 -2
- package/dist/locale/texts-gate.d.ts +1 -1
- package/dist/mocks/orders.d.ts +1 -1
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/plugins/before-sign-in.d.ts +1 -1
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-BPtyska2.js → account-page-B_azef82.js} +2 -2
- package/dist/shell/assets/{app-DKn-6fgf.js → app-1j5nx8lw.js} +5 -5
- package/dist/shell/assets/{assistant-shell-BW59by36.js → assistant-shell-BDKCWgs7.js} +2 -2
- package/dist/shell/assets/{board-display-uC4sMccF.js → board-display-RfXJJ01f.js} +2 -2
- package/dist/shell/assets/{calendar-display-BZhTapxV.js → calendar-display-CWANjACC.js} +2 -2
- package/dist/shell/assets/{call-rings-DwyQO_zl.js → call-rings-ClQinnwb.js} +2 -2
- package/dist/shell/assets/{calls-DeHPxZSF.js → calls-s6XuZsjs.js} +2 -2
- package/dist/shell/assets/{circle-alert-mtPRl_1e.js → circle-alert-CCchwpE2.js} +2 -2
- package/dist/shell/assets/{composed-page-CqjAO9Zv.js → composed-page-Cj-OwCZB.js} +2 -2
- package/dist/shell/assets/{composer-section-D16PrwJe.js → composer-section-BWJgscVY.js} +2 -2
- package/dist/shell/assets/{connect-route-BHjM-n0c.js → connect-route-DpM6_5A-.js} +2 -2
- package/dist/shell/assets/{copy-field-C7SgGBWe.js → copy-field-DJZYMDoO.js} +2 -2
- package/dist/shell/assets/{create-route-CV6sScUu.js → create-route-CQeYkXaB.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-DbXZzPJp.js → custom-step-container-field-B0SWYcOK.js} +2 -2
- package/dist/shell/assets/{embedded-list-CG1SyUtd.js → embedded-list-CQ7VmI-J.js} +3 -3
- package/dist/shell/assets/{export-dialog-CMPyzZa3.js → export-dialog-DOtYGy3R.js} +2 -2
- package/dist/shell/assets/{graph-view-CfO5HJXO.js → graph-view-G-uTEd7F.js} +2 -2
- package/dist/shell/assets/{group-donut-UrNllcKD.js → group-donut-C_BThKYK.js} +2 -2
- package/dist/shell/assets/{guest-call-page-CgISSPNH.js → guest-call-page-CUucHFn7.js} +3 -3
- package/dist/shell/assets/{html-viewer-GgauWEUE.js → html-viewer-CxMoymHe.js} +2 -2
- package/dist/shell/assets/{import-dialog-BppJUUoF.js → import-dialog-DJdNJeuD.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-cfWZMJfg.js → import-table-dialog-vxHtntUq.js} +2 -2
- package/dist/shell/assets/{index-C6CE4Yqt.js → index-BpuPTpcS.js} +1 -1
- package/dist/shell/assets/{invitations-page-Cx960zfb.js → invitations-page-a0oQdGxB.js} +2 -2
- package/dist/shell/assets/{layout-grid-IdJUsNk6.js → layout-grid-IQchsfWp.js} +2 -2
- package/dist/shell/assets/{legend-item-FRGENXpR.js → legend-item-BlI2FIuO.js} +2 -2
- package/dist/shell/assets/{list-page-Di8ApAmU.js → list-page-BXVd_Eq3.js} +4 -4
- package/dist/shell/assets/{maplibre-B0oPa_5e.js → maplibre-BNosce4R.js} +2 -2
- package/dist/shell/assets/{markdown-content-CA74ofB3.js → markdown-content-C_-l2O5-.js} +2 -2
- package/dist/shell/assets/{members-page-UO-o4WSG.js → members-page-Bm3GFEhM.js} +2 -2
- package/dist/shell/assets/{messages-CjRWJI05.js → messages-DAlS_OLf.js} +2 -2
- package/dist/shell/assets/{organization-page-DaGSJbur.js → organization-page-BbzBkLeU.js} +2 -2
- package/dist/shell/assets/{organizations-page-C5oK_zsd.js → organizations-page-BkarXyu5.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-BEvgmW-N.js → pending-invitation-row-nDslRIg_.js} +2 -2
- package/dist/shell/assets/{period-chart-CW2NUL07.js → period-chart-Dbykq15D.js} +2 -2
- package/dist/shell/assets/{person-row-5VQjyq5t.js → person-row-RUXD4Z6I.js} +2 -2
- package/dist/shell/assets/{public-form-page-CqU7Cg33.js → public-form-page-CI1ghnwR.js} +2 -2
- package/dist/shell/assets/{record-lines-CJgNIVFS.js → record-lines-sVjQkysF.js} +2 -2
- package/dist/shell/assets/{record-map-DHkY7hYE.js → record-map-SrorcD8G.js} +2 -2
- package/dist/shell/assets/{record-opens-B0MlYjrH.js → record-opens-BkQP4ve9.js} +2 -2
- package/dist/shell/assets/{record-page-whDNzf71.js → record-page-CA2bmhxx.js} +3 -3
- package/dist/shell/assets/{record-preview-BUnzkT7g.js → record-preview-C8xkvcPt.js} +2 -2
- package/dist/shell/assets/{records-map-DjcDdJBM.js → records-map-DgQ3MJFS.js} +2 -2
- package/dist/shell/assets/{render-node-DGmdm-wr.js → render-node-eKuGRuq5.js} +3 -3
- package/dist/shell/assets/{reorder-button-q4oqy3UR.js → reorder-button-DFrAk-Xc.js} +2 -2
- package/dist/shell/assets/{run-trace-view-DjtMSojN.js → run-trace-view-C2MAxHm8.js} +2 -2
- package/dist/shell/assets/{runner-install-field-Ddxc9XB0.js → runner-install-field-BYzWk3Ye.js} +2 -2
- package/dist/shell/assets/{runtime-update-CKEA5P-k.js → runtime-update-CVNAIIII.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-tTqz9hwW.js → shared-protobase-ui-C_Oyn30V.js} +1 -1
- package/dist/shell/assets/{sheet-source-CAIVzfnw.js → sheet-source-BNfkNzNO.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-CdTIudi-.js → sign-in-policy-page-DqH94QZl.js} +2 -2
- package/dist/shell/assets/{start-block-queries-DjQjQ2Ef.js → start-block-queries-CAEd4yVp.js} +2 -2
- package/dist/shell/assets/{step-catalog-Dit0IJvs.js → step-catalog-wasAn9L1.js} +2 -2
- package/dist/shell/assets/{step-panel-9kx6xfm1.js → step-panel-DDSMdJhn.js} +2 -2
- package/dist/shell/assets/{timeline-display-CoQETrmW.js → timeline-display-CLcdY1TN.js} +2 -2
- package/dist/shell/assets/{trash-DJwJPifF.js → trash-Du1HjUvA.js} +2 -2
- package/dist/shell/assets/{update-set-DPSGWrcI.js → update-set-BQN3GDI3.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-CgXeokRh.js → use-calendar-move-C8LZwkOo.js} +2 -2
- package/dist/shell/assets/{use-display-rows-DFSNvNWx.js → use-display-rows-BWZ3ByZb.js} +2 -2
- package/dist/shell/assets/{use-paged-search-B52iaj1D.js → use-paged-search-DvGQocxR.js} +2 -2
- package/dist/shell/assets/{use-run-trace-KAufJAqD.js → use-run-trace-CNqw_HuX.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-171SXJ7G.js → use-workflow-page-jjK3t-vf.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-ZGEaDrEJ.js → use-workflow-types-CxeOmx1U.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-CCu4twlF.js → workflow-canvas-BgC2BoRd.js} +2 -2
- package/dist/shell/assets/{workflow-field-BFNHwCjK.js → workflow-field-DAk0UqrK.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-DTSyabCd.js → workflow-graph-editor-0KyZBj6R.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-D2fpm1Vk.js → workflow-run-field-rlISvE35.js} +3 -3
- package/dist/shell/assets/workflow-status-field-jZ1pLRdt.js +2 -0
- package/dist/shell/assets/{workflow-workbench-CN5-OYpd.js → workflow-workbench-CYjY4iZy.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +3 -3
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-BPtyska2.js.map → account-page-B_azef82.js.map} +1 -1
- package/dist/shell-source-maps/assets/{app-DKn-6fgf.js.map → app-1j5nx8lw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{assistant-shell-BW59by36.js.map → assistant-shell-BDKCWgs7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-uC4sMccF.js.map → board-display-RfXJJ01f.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-BZhTapxV.js.map → calendar-display-CWANjACC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-DwyQO_zl.js.map → call-rings-ClQinnwb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-DeHPxZSF.js.map → calls-s6XuZsjs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-mtPRl_1e.js.map → circle-alert-CCchwpE2.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-CqjAO9Zv.js.map → composed-page-Cj-OwCZB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-D16PrwJe.js.map → composer-section-BWJgscVY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-BHjM-n0c.js.map → connect-route-DpM6_5A-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-C7SgGBWe.js.map → copy-field-DJZYMDoO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-CV6sScUu.js.map → create-route-CQeYkXaB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-DbXZzPJp.js.map → custom-step-container-field-B0SWYcOK.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-CG1SyUtd.js.map → embedded-list-CQ7VmI-J.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-CMPyzZa3.js.map → export-dialog-DOtYGy3R.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-CfO5HJXO.js.map → graph-view-G-uTEd7F.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-UrNllcKD.js.map → group-donut-C_BThKYK.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-CgISSPNH.js.map → guest-call-page-CUucHFn7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-GgauWEUE.js.map → html-viewer-CxMoymHe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-BppJUUoF.js.map → import-dialog-DJdNJeuD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-cfWZMJfg.js.map → import-table-dialog-vxHtntUq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-Cx960zfb.js.map → invitations-page-a0oQdGxB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-IdJUsNk6.js.map → layout-grid-IQchsfWp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-FRGENXpR.js.map → legend-item-BlI2FIuO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-Di8ApAmU.js.map → list-page-BXVd_Eq3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-B0oPa_5e.js.map → maplibre-BNosce4R.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-CA74ofB3.js.map → markdown-content-C_-l2O5-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-UO-o4WSG.js.map → members-page-Bm3GFEhM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-CjRWJI05.js.map → messages-DAlS_OLf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-DaGSJbur.js.map → organization-page-BbzBkLeU.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-C5oK_zsd.js.map → organizations-page-BkarXyu5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-BEvgmW-N.js.map → pending-invitation-row-nDslRIg_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-CW2NUL07.js.map → period-chart-Dbykq15D.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-5VQjyq5t.js.map → person-row-RUXD4Z6I.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-CqU7Cg33.js.map → public-form-page-CI1ghnwR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-CJgNIVFS.js.map → record-lines-sVjQkysF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-DHkY7hYE.js.map → record-map-SrorcD8G.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-B0MlYjrH.js.map → record-opens-BkQP4ve9.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-whDNzf71.js.map → record-page-CA2bmhxx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-BUnzkT7g.js.map → record-preview-C8xkvcPt.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-DjcDdJBM.js.map → records-map-DgQ3MJFS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-DGmdm-wr.js.map → render-node-eKuGRuq5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-q4oqy3UR.js.map → reorder-button-DFrAk-Xc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-DjtMSojN.js.map → run-trace-view-C2MAxHm8.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-Ddxc9XB0.js.map → runner-install-field-BYzWk3Ye.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-CKEA5P-k.js.map → runtime-update-CVNAIIII.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-CAIVzfnw.js.map → sheet-source-BNfkNzNO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-CdTIudi-.js.map → sign-in-policy-page-DqH94QZl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-DjQjQ2Ef.js.map → start-block-queries-CAEd4yVp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-Dit0IJvs.js.map → step-catalog-wasAn9L1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-9kx6xfm1.js.map → step-panel-DDSMdJhn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CoQETrmW.js.map → timeline-display-CLcdY1TN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-DJwJPifF.js.map → trash-Du1HjUvA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-DPSGWrcI.js.map → update-set-BQN3GDI3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-CgXeokRh.js.map → use-calendar-move-C8LZwkOo.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-DFSNvNWx.js.map → use-display-rows-BWZ3ByZb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-B52iaj1D.js.map → use-paged-search-DvGQocxR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-KAufJAqD.js.map → use-run-trace-CNqw_HuX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-171SXJ7G.js.map → use-workflow-page-jjK3t-vf.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-ZGEaDrEJ.js.map → use-workflow-types-CxeOmx1U.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-CCu4twlF.js.map → workflow-canvas-BgC2BoRd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-BFNHwCjK.js.map → workflow-field-DAk0UqrK.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-DTSyabCd.js.map → workflow-graph-editor-0KyZBj6R.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-D2fpm1Vk.js.map → workflow-run-field-rlISvE35.js.map} +1 -1
- package/dist/shell-source-maps/assets/workflow-status-field-jZ1pLRdt.js.map +1 -0
- package/dist/shell-source-maps/assets/{workflow-workbench-CN5-OYpd.js.map → workflow-workbench-CYjY4iZy.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
- package/dist/shell/assets/workflow-status-field-D_4-8JIF.js +0 -2
- package/dist/shell-source-maps/assets/workflow-status-field-D_4-8JIF.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{Bc as r,Ho as i,Ja as a,Ka as o,Qs as s,Ua as c,Uo as l,Wa as u,ec as d,ka as f,ps as p,qo as m,uo as h,us 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{Bc as r,Ho as i,Ja as a,Ka as o,Qs as s,Ua as c,Uo as l,Wa as u,ec as d,ka as f,ps as p,qo as m,uo as h,us as g}from"./app-1j5nx8lw.js";import{o as _}from"./vendor-t7Q7QbPu.js";import{t as v}from"./page-header-Ddz2r5ic.js";import{n as y,t as b}from"./person-row-RUXD4Z6I.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:l,organizations:d}=g(),f=t.organization.id,{busy:p,error:m,run:_}=c(),v=d?.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)(h,{status:n,presence:r})},actions:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`select`,{"aria-label":a(`roleOf`,{name:e.name}),value:e.role,disabled:p||T,onChange:t=>void _(async()=>{await l.organizations.setRole(f,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:o(e)},e))}),!x&&(0,S.jsx)(s,{size:`sm`,variant:`danger`,loading:p,disabled:T,onClick:()=>void _(async()=>{await l.organizations.removeMember(f,e.id),i()}),children:a(`remove`)})]}),children:(0,S.jsx)(y,{roles:E,selected:e.appRoles,grantable:u(v,t),disabled:p,onChange:t=>void _(async()=>{await l.organizations.setAppRoles(e.id,t),i()})})})},T=({current:e,statuses:t,presence:n})=>{let{session:o}=g(),s=e?.organization?.id,c=_({queryKey:r.organizationMembers(s??``),queryFn:()=>o.organizations.members(s),enabled:!!s,retry:!1}),u=c.data,h=c.error?c.error instanceof p?m(c.error):a(`couldNotReadMembers`):void 0,{refetch:y}=c,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:a(`members`),subtitle:a(`whoWorks`,{organization:e.organization.name})}),(0,S.jsxs)(i,{title:a(`members`),description:a(`membersDescription`),children:[(0,S.jsx)(l,{message:h}),u?(0,S.jsx)(`ul`,{className:`divide-y rounded-md border`,children:u.map(r=>(0,S.jsx)(w,{member:r,current:e,status:t?.find(e=>e.userId===r.userId),presence:f(n,r.userId),onChanged:b},`${r.id}/${r.role}/${r.appRoles.join()}`))}):!h&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,S.jsx)(d,{}),` `,a(`loading`)]})]})]}):null};export{T as MembersPage,C as assignableOrganizationRoles};
|
|
2
|
+
//# debugId=66dc6144-84c0-4340-863b-f958b127b2e0
|
|
@@ -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{Ai as e,Fl as t,Ls as n,Pl as r,Sa as i,Vc as a,Vi as o,Xc as s,ci as c,rl 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{Ai as e,Fl as t,Ls as n,Pl as r,Sa as i,Vc as a,Vi as o,Xc as s,ci as c,rl as l}from"./app-1j5nx8lw.js";var u=(e,t)=>{let n=e.position;if(!n||!i(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},d=(e,t)=>e.position?.within===void 0?u(e,t):void 0,f=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?u(t,n):void 0,p=(t,n,r,i)=>{if(n===void 0||t?.list?.drag?.rank!==!0||i!==``)return!1;let a=e(r);return a.columnId===n&&a.direction===`asc`},m=a(`app/hand-order`),h=(e,t,{title:r,place:i})=>!n(e)||e.status!==412?{state:`error`,title:t,description:c(e)}:r===void 0?{state:`warning`,title:t,description:m(`orderChangedSince`,{place:i})}:{state:`warning`,title:m(`notSaved`,{title:r}),description:m(`orderChangedThere`,{place:i})},g=(e,t,n)=>t.flatMap(({before:t,record:r,etag:i})=>{let a=n.filter(e=>Object.hasOwn(t,e)&&t[e]!==r[e]);return a.length===0?[]:[{op:`update`,resource:e.name,key: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,n,i,a)=>{let c=n.position?.after;if(!c)return{after:[],before:[]};let u=n.primaryKey[0],d=o(n,a),f=e=>l([e]),p=await _(e,c.resource,v(t(r.or(r.eq(c.field,d),r.eq(c.key,d))),c.filter)),m=(e,t)=>p.flatMap(n=>f(n[e])===f(d)&&f(n[t])!==f(d)?[n[t]]:[]),h=m(c.field,c.key),g=m(c.key,c.field),[y,b]=await Promise.all([_(e,n.name,v(t(r.in(u,[d,...h])),c.while)),g.length===0?[]:_(e,n.name,t(r.in(u,g)))]),x=e=>{let t=l(o(n,e));return{key:t,rank:e[n.position.field],title:s(n,i,e,t)}},S=y.some(e=>f(e[u])===f(d));return{after:y.filter(e=>f(e[u])!==f(d)).map(x),before:S?b.map(x):[]}},b=(e,t,n,r,i,a=!1)=>{let 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=a(`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=c0952fce-2df3-48c5-a509-021ca4848fce
|
|
@@ -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{Ga as r,Ho as i,Ja as a,Ka as o,M as s,Qs as c,Ta as l,Ua as u,Uo as d,Xs as f,rs as p,ts as m,us as h,xo 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{Ga as r,Ho as i,Ja as a,Ka as o,M as s,Qs as c,Ta as l,Ua as u,Uo as d,Xs as f,rs as p,ts as m,us as h,xo as g}from"./app-1j5nx8lw.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}=h(),[o,s]=(0,v.useState)(e.name),[l,f]=(0,v.useState)(e.slug),{busy:p,error:m,run:_}=u(),b=o.trim()!==e.name||l!==e.slug;return(0,y.jsxs)(i,{title:a(`details`),description:a(t?`detailsEditable`:`detailsReadOnly`),children:[(0,y.jsx)(d,{message:m}),(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:o.trim(),slug:l}),n()})},children:[(0,y.jsx)(g,{"aria-label":a(`name`),value:o,disabled:!t,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`}),(0,y.jsx)(g,{"aria-label":a(`slug`),value:l,disabled:!t,onChange:e=>f(e.target.value),wrapperClassName:`sm:w-48`}),t&&(0,y.jsx)(c,{type:`submit`,variant:`primary`,loading:p,disabled:!b||!o.trim(),children:a(`save`)})]})]})},x=({organization:e,memberId:t})=>{let{session:n}=h(),[r,o]=(0,v.useState)([]),[s,l]=(0,v.useState)(``),{busy:f,error:p,run:m}=u();return(0,v.useEffect)(()=>{n.organizations.members(e.id).then(e=>o(e.filter(e=>e.id!==t)),()=>o([]))},[n,e.id,t]),(0,y.jsxs)(i,{title:a(`handOver`),description:a(`handOverDescription`),children:[(0,y.jsx)(d,{message:p}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,y.jsxs)(`select`,{"aria-label":a(`newOwner`),value:s,onChange:e=>l(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:a(`chooseMember`)}),r.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),(0,y.jsx)(c,{loading:f,disabled:!s,onClick:()=>void m(async()=>{await n.organizations.transferOwnership(s),window.location.reload()}),children:a(`handOver`)})]})]})},S=({organization:e,basePath:t})=>{let{session:n}=h(),[r,o]=(0,v.useState)(!1),[s,p]=(0,v.useState)(``),{busy:m,error:_,run:b}=u(),x=()=>b(async()=>{await n.organizations.remove(e.id),l(t)});return(0,y.jsxs)(i,{title:a(`deleteOrganization`),description:a(`deleteDescription`),children:[(0,y.jsx)(d,{message:r?void 0:_}),(0,y.jsx)(c,{variant:`danger`,onClick:()=>o(!0),children:a(`deleteOrganization`)}),r&&(0,y.jsxs)(f,{title:a(`deleteTitle`,{name:e.name}),description:a(`deleteConfirm`),onClose:()=>o(!1),actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(c,{onClick:()=>o(!1),children:a(`cancel`)}),(0,y.jsx)(c,{variant:`danger`,loading:m,disabled:s!==e.name,onClick:()=>void x(),children:a(`delete`)})]}),children:[(0,y.jsx)(d,{message:_}),(0,y.jsx)(g,{"aria-label":a(`organizationName`),value:s,onChange:e=>p(e.target.value)})]})]})},C=({editable:e})=>{let t=p(),[n,r]=(0,v.useState)(),{busy:o,error:c,run:l}=u();return(0,v.useEffect)(()=>{t.callGuests.allowed().then(r)},[t]),n===void 0?null:(0,y.jsxs)(i,{title:a(`guestLinks`),description:a(`guestLinksDescription`),children:[(0,y.jsx)(d,{message:c}),(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,y.jsx)(s,{checked:n,label:a(`guestLinksAllowed`),...e&&!o&&{onChange:e=>void l(async()=>{await t.callGuests.setAllowed(e),r(e)})}}),a(`guestLinksAllowed`)]})]})},w=({organization:e,basePath:t,owner:n})=>{let{session:r}=h(),{busy:o,error:s,run:f}=u();return(0,y.jsxs)(i,{title:a(`leave`),description:a(n?`leaveOwner`:`leaveMember`),children:[(0,y.jsx)(d,{message:s}),(0,y.jsx)(c,{loading:o,onClick:()=>void f(async()=>{await r.organizations.leave(e.id),l(t)}),children:a(`leaveName`,{name:e.name})})]})},T=({current:e,basePath:t,onChanged:n})=>{let i=m().data?.calls===!0,s=e?.organization;if(!s)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:a(`organization`),subtitle:a(`noOrganization`)})});let c=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:s.name,subtitle:e.role?a(`youAre`,{role:o(e.role).toLowerCase()}):a(`throughGlobalRoles`)}),(0,y.jsx)(b,{organization:s,editable:r(e),onSaved:n},`${s.name}/${s.slug}`),i&&e.role&&(0,y.jsx)(C,{editable:r(e)}),c&&e.memberId&&(0,y.jsx)(x,{organization:s,memberId:e.memberId}),e.role&&(0,y.jsx)(w,{organization:s,basePath:t,owner:c}),c&&(0,y.jsx)(S,{organization:s,basePath:t})]})};export{T as OrganizationPage};
|
|
2
|
+
//# debugId=5bcc190b-7942-44eb-8fbd-d79c5fa94c6d
|
|
@@ -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{Go as r,Ho as i,Ja as a,Qs as o,Ta as s,Ua as c,Uo as l,Wc as u,qa as d,us as f,xo as p,za 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{Go as r,Ho as i,Ja as a,Qs as o,Ta as s,Ua as c,Uo as l,Wc as u,qa as d,us as f,xo as p,za as m}from"./app-1j5nx8lw.js";import{t as h}from"./page-header-Ddz2r5ic.js";import{n as g,t as _}from"./use-paged-search-DvGQocxR.js";var v=e(t(),1),y=e(n(),1),b=({organization:e,current:t,busy:n,onOpen:i})=>(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)(r,{tone:`green`,children:a(`current`)}):(0,y.jsx)(o,{size:`sm`,loading:n,onClick:i,children:a(`open`)})]}),x=({basePath:e,currentId:t})=>{let{session:n}=f(),[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]),l=_(o,r),{busy:u,error:d,run:p}=c();return(0,y.jsx)(g,{title:a(`allOrganizations`),description:a(`allOrganizationsDescription`),searchLabel:a(`findOrganization`),placeholder:a(`nameOrSlug`),query:r,onQuery:i,list:l,error:d,renderRow:r=>(0,y.jsx)(b,{organization:r,current:r.id===t,busy:u,onOpen:()=>void p(async()=>{await n.organizations.switchTo(r.id),s(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}=f(),[n,r]=(0,v.useState)(``),[u,d]=(0,v.useState)(),{busy:m,error:h,run:g}=c(),_=()=>g(async()=>{await t.organizations.create({name:n.trim(),slug:u??S(n)}),s(e)});return(0,y.jsxs)(i,{title:a(`newOrganization`),description:a(`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)(p,{"aria-label":a(`name`),placeholder:a(`name`),value:n,onChange:e=>r(e.target.value),wrapperClassName:`flex-1`}),(0,y.jsx)(p,{"aria-label":a(`slug`),placeholder:`slug`,value:u??S(n),onChange:e=>d(e.target.value),wrapperClassName:`sm:w-48`}),(0,y.jsx)(o,{type:`submit`,variant:`primary`,loading:m,disabled:!n.trim(),children:a(`create`)})]})]})},w=({basePath:e})=>{let{session:t,organizations:n}=f(),[r,p]=(0,v.useState)([]),{busy:m,error:h,run:g}=c();if((0,v.useEffect)(()=>{t.organizations.myInvitations().then(p,()=>p([]))},[t]),r.length===0)return null;let _=n?.roles??[],b=n=>g(async()=>{await t.organizations.acceptMine(n),s(e)});return(0,y.jsxs)(i,{title:a(`invitationsForYou`),description:a(`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??a(`anOrganization`)}),`: `,e.appRoles.map(e=>d(_,e)).join(`, `)||a(`noAppRoles`),(0,y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`until`,{date:new Date(e.expiresAt).toLocaleDateString(u())})})]}),(0,y.jsx)(o,{size:`sm`,variant:`primary`,loading:m,onClick:()=>void b(e.id),children:a(`accept`)})]},e.id))})]})},T=({state:e,basePath:t})=>{let{session:n,organizations:r,state:o}=f(),{busy:u,error:d,run:p}=c(),g=o.kind===`signed-in`?o.user:void 0,_=r?.create===`everyone`||g!==void 0&&m(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:a(`organizations`),subtitle:a(`organizationsSubtitle`)}),(0,y.jsxs)(i,{title:a(`yourOrganizations`),description:e.organizations.length>0?a(`memberOf`):a(`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:u,onOpen:()=>void p(async()=>{await n.organizations.switchTo(e.id),s(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=646ab5f2-bb93-40ce-bb73-6c7415b835c7
|
package/dist/shell/assets/{pending-invitation-row-BEvgmW-N.js → pending-invitation-row-nDslRIg_.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{Ho as r,Qs as i,Ua as a,Uo as o,Vc as s,Wc as c,xo 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{Ho as r,Qs as i,Ua as a,Uo as o,Vc as s,Wc as c,xo as l}from"./app-1j5nx8lw.js";var u=e(t(),1),d=s(`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:s,children:c,incomplete:m=!1})=>{let[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(),{busy:y,error:b,run:x}=a(),S=()=>x(async()=>{v((await n(h.trim())).link),g(``)});return(0,f.jsxs)(r,{title:e,description:t,children:[(0,f.jsx)(o,{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)(l,{"aria-label":d(`email`),type:`email`,placeholder:`name@example.com`,value:h,onChange:e=>g(e.target.value),wrapperClassName:`flex-1`}),s,(0,f.jsx)(i,{type:`submit`,variant:`primary`,loading:y,disabled:!h.trim()||m,children:d(`invite`)})]}),c]}),(0,f.jsx)(p,{link:_})]})},h=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:s})=>{let[l,m]=(0,u.useState)(),{busy:h,error:g,run:_}=a(),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(c())})]})]}),(0,f.jsx)(i,{size:`sm`,loading:h,onClick:()=>void _(async()=>m((await r()).link)),children:d(`sendAgain`)}),(0,f.jsx)(i,{size:`sm`,variant:`danger`,loading:h,onClick:()=>void _(s),children:d(`revoke`)})]}),(0,f.jsx)(o,{message:g}),(0,f.jsx)(p,{link:l})]})};export{m as n,h as t};
|
|
2
|
+
//# debugId=270ec951-220f-49e9-bb7a-cd08cb2db0ec
|
|
@@ -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{Fo as r,Wc as i,da as a,fa 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{Fo as r,Wc as i,da as a,fa as o,pa as s}from"./app-1j5nx8lw.js";import{bt as c,vt as l}from"./embedded-list-CQ7VmI-J.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-BlI2FIuO.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=>s(`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(i(),{...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+o(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=r(`(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(i(),{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=dbca4ab5-e43d-427c-9ddd-6d8f66352506
|
|
@@ -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{Ja as n,Nc as r,Uo as i,Ya 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{Ja as n,Nc as r,Uo as i,Ya as a}from"./app-1j5nx8lw.js";var o=e(t(),1),s=({roles:e,selected:t,grantable:i,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||!i.has(e.name);return(0,o.jsxs)(`label`,{title:u&&!s?n(`cannotChangeRole`):void 0,className:r(`inline-flex items-center gap-1.5`,u&&`text-muted-foreground`),children:[(0,o.jsx)(a,{checked:l,label:e.label,onChange:u?void 0:n=>c(n?[...t,e.name]:t.filter(t=>t!==e.name)),className:r(u&&`cursor-default opacity-60`)}),e.label]},e.name)})}),c=({name:e,email:t,self:n,actions:r,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,n&&` (you)`]}),c]}):(0,o.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,n&&` (you)`]}),(0,o.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r]}),a,(0,o.jsx)(i,{message:s})]});export{s as n,c as t};
|
|
2
|
+
//# debugId=115170f8-67a2-4e50-a17e-c95433f22ed4
|
|
@@ -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{$c as r,Bc as i,Ls as a,Qo as o,Qs as s,R as c,Vc as l,Yo as u,_ as d,a as f,b as p,c as m,ec as h,i as g,io as _,mr as v,no as y,o as b,rs as x,u as S,v as C,y 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{$c as r,Bc as i,Ls as a,Qo as o,Qs as s,R as c,Vc as l,Yo as u,_ as d,a as f,b as p,c as m,ec as h,i as g,io as _,mr as v,no as y,o as b,rs as x,u as S,v as C,y as w}from"./app-1j5nx8lw.js";import{o as T}from"./vendor-t7Q7QbPu.js";import{n as E,t as D}from"./lib-altcha-lib-BK1uKcxH.js";var O=e(t(),1),k=l(`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=x(),n=T({queryKey:i.publicForm(e),queryFn:()=>t.form(e)});return n.isPending?(0,j.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,j.jsx)(h,{}),` `,k(`loading`)]}):n.error?a(n.error)&&n.error.status===404?(0,j.jsx)(u,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(u,{title:o(`cannotReach`),children:a(n.error)?n.error.message:o(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=x(),{resource:n,view:i}=e,a=e.title??i.names?.singular??r(i.resource);_(a);let[o,l]=(0,O.useState)(()=>b(n,[{title:a,fields:e.fields}])),[u,h]=(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=d(F);if(N)return(0,j.jsx)(y,{title:a,size:`md`,children:(0,j.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:e.thanks})});let R=(e,t)=>{h(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),l(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=C(e);h(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(y,{title:a,size:`md`,children:(0,j.jsxs)(`form`,{ref:L,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),z()},children:[e.fields.map(e=>{let t=n.fields[e],a=i.fields[e],s=a?.label??r(e),l=u[e];return(0,j.jsx)(c,{name:e,label:s,help:a?.help,required:m(t),error:l&&w(t,s,l),children:(0,j.jsx)(p,{field:t,hints:a,value:o[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:f(t)?k(`setByDatabase`):S(t),invalid:!!l,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(v,{title:k(`notSent`),error:T}),(0,j.jsx)(s,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
|
|
2
|
+
//# debugId=88d60867-c116-41a1-b4a8-231b9085784f
|
|
@@ -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{$c as r,Nc as i,Ni as a,P as o,Qs as s,Sa as c,So as l,Vc as u,Xc as d,Xo as f,Zo as p,b as m,bo as h,g,l as _,s as v,uc as y,vc as b,wa as x,y as S,yo 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{$c as r,Nc as i,Ni as a,P as o,Qs as s,Sa as c,So as l,Vc as u,Xc as d,Xo as f,Zo as p,b as m,bo as h,g,l as _,s as v,uc as y,vc as b,wa as x,y as S,yo as C}from"./app-1j5nx8lw.js";import{At as w}from"./embedded-list-CQ7VmI-J.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-CA2bmhxx.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),a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=C(n,a,o),c=h(n,a,o,s?.right);return(0,B.useEffect)(()=>{if(!n)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!a.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:a,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)(b,{className:`size-4`})}),n&&(0,V.jsx)(`ul`,{ref:o,role:`menu`,style:{...s,...c},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:i(`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=u(`inline-child-table`),W=({line:e,name:t,columns:n,position:r,count:a,reorderable:o,onRemove:s,onMove:c,error:l})=>{let{attributes:u,listeners:d,setNodeRef:f,setActivatorNodeRef:p,transform:m,transition:h,isDragging:g}=N({id:e.id,disabled:!o}),_=[...o?[{label:U(`moveUp`),disabled:r===0,onSelect:()=>c(r-1)},{label:U(`moveDown`),disabled:r===a-1,onSelect:()=>c(r+1)}]:[],...s?[{label:U(`removeLine`),destructive:!0,onSelect:s}]:[]];return(0,V.jsxs)(`div`,{ref:f,"data-line-id":e.id,"aria-invalid":l?!0:void 0,style:{transform:m?`translate3d(0, ${m.y}px, 0)`:void 0,transition:h},className:i(`group relative border-b border-border bg-background px-2 py-1 last:border-b-0 hover:bg-surface`,z,g&&`z-10 bg-surface opacity-80 shadow-pop`,l&&`bg-danger-soft`),children:[o?(0,V.jsx)(`button`,{ref:p,type:`button`,"aria-label":U(`dragToReorder`,{name:t}),...u,...d,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:i(`min-w-0`,t.align===`right`&&`text-right`),children:t.cell(e)},t.key)),_.length>0?(0,V.jsx)(H,{label:U(`actionsFor`,{name:t}),items:_}):(0,V.jsx)(`span`,{}),l&&(0,V.jsx)(`p`,{role:`alert`,className:`col-span-full px-2 pb-1 text-xs text-danger-text`,children:l})]})},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:a=!!r,onAdd:o,onRemove:c,removable:l=()=>!0,lineError:u,footer:d})=>{let f=j(T(E,{activationConstraint:{distance:4}}),T(O,{activationConstraint:{delay:250,tolerance:5}}),T(D,{coordinateGetter:P})),p=(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:i(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:f,collisionDetection:k,onDragEnd:({active:t,over:n})=>{n&&t.id!==n.id&&p(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,i)=>(0,V.jsx)(W,{line:r,name:n(r),columns:t,position:i,count:e.length,reorderable:a,onRemove:c&&l(r)?()=>c(r):void 0,onMove:e=>p(i,e),error:u?.(r)},r.id))})}),o&&(0,V.jsx)(`div`,{className:`border-t border-border bg-surface px-2 py-1.5`,children:(0,V.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:o,children:[(0,V.jsx)(y,{className:`size-3.5`}),U(`addLine`)]})})]}),d]})},Y=({field:e,hints:t,label:n,lineNumber:r,resource:i,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:u,locked:d,problem:f,onChange:p})=>{let h=(0,B.useId)(),_=f&&S(e,n,f);return(0,V.jsxs)(l.Provider,{value:{id:h,invalid:!!f,required:!1,..._&&{describedBy:`${h}-error`}},children:[(0,V.jsx)(`label`,{htmlFor:h,className:`sr-only`,children:g(`lineField`,{label:n,place:r})}),(0,V.jsx)(m,{field:e,hints:t,value:a,stored:o,relationLabel:s,relationTo:c,relationPicker:u,locked:d,invalid:!!f,resource:i,onChange:p}),_&&(0,V.jsx)(`p`,{id:`${h}-error`,className:`px-1 pt-0.5 text-xs text-danger-text`,children:_})]})},X=({lines:e,editable:t,saving:n})=>{let{resources:i,views:s}=f(),{item:l,model:u,columns:m,data:h,draft:y}=e,b=p(u.name),S=s[u.name],[C,w]=(0,B.useState)({}),T=t&&h.complete&&!h.loading&&!n,E=T&&c(b,`update`),D=T&&c(b,`create`),O=T&&c(b,`delete`),k=e=>e.stored?E&&x(e.stored,`update`):D,A=e=>y.shown.indexOf(e)+1,j=e=>y.rejection?.id===e.id?y.rejection:void 0,M=m.map(e=>{let t=u.fields[e],n=S?.fields[e],a=n?.label??r(e),o=t.relation?i[t.relation.resource]:void 0,c=o&&o.primaryKey.length===1?o:void 0;return{key:e,label:a,...[`integer`,`bigint`,`decimal`].includes(t.type)&&{align:`right`,width:`minmax(6rem,0.6fr)`},cell:r=>{let i=y.value(r.id,e),o=i==null||i===``?void 0:String(i);return(0,V.jsx)(Y,{field:t,hints:n,label:a,lineNumber:A(r),resource:u.name,value:i,stored:r.stored?.[e],relationLabel:o===void 0?void 0:C[`${r.id}/${e}`]??h.labels[e]?.[o],relationTo:c&&o!==void 0?{kind:`record`,resource:c.name,key:o}:void 0,relationPicker:c&&{target:c,view:s[c.name]},locked:!k(r),problem:j(r)?.fields[e],onChange:t=>{if(!c||!v(t))return y.change(r.id,e,t);w(n=>({...n,[`${r.id}/${e}`]:t.label})),y.change(r.id,e,_(c,t.key))}})}}});return(0,V.jsxs)(o,{title:l.title,help:l.help,children:[!h.complete&&(0,V.jsx)(`p`,{className:`mb-2 text-muted-foreground`,children:g(`tooManyLines`,{limit:a(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:y.shown,columns:M,lineName:e=>d(u,S,e.stored??{},``)||g(`lineNumber`,{place:A(e)}),onReorder:e=>y.setOrder(e.map(e=>e.id)),reorderable:E,onAdd:D?()=>void y.add():void 0,onRemove:D||O?e=>y.remove(e.id):void 0,removable:e=>e.stored?O&&x(e.stored,`delete`):D,lineError:e=>{let t=j(e);if(t&&!m.some(e=>t.fields[e]))return t.message}})})})]})};export{X as RecordLines};
|
|
2
|
+
//# debugId=2c563424-cac1-4f5f-97ca-27af43642a54
|
|
@@ -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-BNosce4R.js";import{a,i as o,r as s}from"./lib-vis.gl-react-maplibre-1cv426UN.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=12ae8adc-0fc1-485e-8a29-34f1980f22c6
|
|
@@ -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{Lr as r,Sl as i,Yo as a,g 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{Lr as r,Sl as i,Yo as a,g as o}from"./app-1j5nx8lw.js";var s=e(t(),1),c=e(n(),1),l=(e,t)=>{let n=i(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}=r();return(0,s.useEffect)(()=>t(e,{replace:!0}),[e,t]),(0,c.jsx)(a,{title:o(`loading`),children:o(`fetching`)})};export{l as n,u as t};
|
|
2
|
+
//# debugId=6440fe2f-7bd7-41df-bf92-e6414dead1c4
|
|
@@ -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,$c as a,$s as o,An as s,Ao as c,Ba as l,Bc as u,Bi as d,Bn as f,C as p,Ca as m,D as h,Dc as g,Di as _,Dn as v,Do as y,Dr as b,Dt as x,E as S,Ei as C,Et as w,Fa as ee,Fl as T,Go as E,Hn as D,I as O,Ii as k,Ir as A,Jc as j,Jn as M,Js as te,Ks as N,Li as P,Lr as ne,Ls as re,Lt as ie,Mc as ae,Mn as oe,Nc as F,Ni as se,Nl as I,No as ce,Nr as le,O as ue,Oa as de,On as fe,Oo as pe,Or as me,Ot as he,P as L,Pa as ge,Po as _e,Qi as ve,Qs as R,R as ye,Sa as be,Si as xe,Tc as Se,Tr as Ce,Tt as we,Us as Te,Vc as z,Vi as Ee,Vl as B,Vs as De,Wc as V,Xo as H,Yo as U,Ys as W,Z as Oe,Zo as ke,Zs as G,_ as Ae,_i as je,_l as Me,_n as Ne,b as Pe,bi as Fe,bn as Ie,ci as Le,cl as Re,co as ze,ct as K,d as Be,da as Ve,en as He,et as Ue,f as We,g as q,gi as Ge,h as Ke,hi as qe,ho as Je,ia as Ye,it as Xe,ja as Ze,jn as Qe,jo as $e,k as et,ki as tt,ko as nt,l as rt,m as it,mi as at,mn as ot,mo as st,mr as J,nc as ct,nr as lt,nt as ut,ot as dt,p as ft,po as pt,qs as mt,rl as ht,rr as gt,rs as Y,rt as _t,s as vt,ss as yt,st as bt,uc as xt,ui as St,un as Ct,us as wt,v as Tt,w as Et,wc as Dt,wn as Ot,wr as kt,x as At,xa as jt,xi as Mt,xn as Nt,y as Pt,yn as Ft,zi as It,zl as Lt}from"./app-DKn-6fgf.js";import{C as Rt,h as zt,i as Bt,o as Vt,r as Ht,s as Ut}from"./vendor-t7Q7QbPu.js";import{Ct as Wt,Dt as Gt,Et as Kt,Mt as qt,Tt as Jt,_ as Yt,a as Xt,c as Zt,lt as Qt,n as $t,ot as en,pt as tn,rt as nn,s as rn,t as an,tt as on,yt as sn}from"./embedded-list-CG1SyUtd.js";import{a as cn,i as ln,n as un,r as dn,t as fn}from"./reorder-button-q4oqy3UR.js";import{a as pn,c as mn,i as hn,l as gn,n as _n,o as vn,r as yn,s as bn,t as xn}from"./render-node-DGmdm-wr.js";import{t as Sn}from"./trash-DJwJPifF.js";import{n as Cn,t as wn}from"./record-sidebar-HqyBXBwn.js";import{t as Tn}from"./start-block-queries-DjQjQ2Ef.js";import{n as En,t as Dn}from"./record-opens-B0MlYjrH.js";import{u as On}from"./messages-CjRWJI05.js";var kn={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`}]]};kn.node;var An=ae(kn),jn={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`}]]};jn.node;var Mn=ae(jn),Nn={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`}]]};Nn.node;var Pn=ae(Nn),Fn={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`}]]};Fn.node;var In=ae(Fn),Ln={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`}]]};Ln.node;var Rn=ae(Ln),X=e(r(),1),zn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,X.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,X.jsxs)(`div`,{children:[e&&(0,X.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,X.jsxs)(X.Fragment,{children:[K(`lastEditedBy`),` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,X.jsx)(X.Fragment,{children:K(`lastUpdated`,{ago:r.ago})})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(c,{people:i,size:`md`}),K(`viewing`,{count:i.length})]}),a]})]}),Z=e(t(),1),Bn=`text-base font-semibold text-foreground`,Vn=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,Z.useId)();return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:F(`py-8`,r&&`pb-0`),children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,X.jsxs)(A,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:F(`inline-flex items-center gap-1.5`,Bn),children:[(0,X.jsx)(Dt,{className:F(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,X.jsx)(`span`,{className:Bn,children:e}),n]}),t&&(0,X.jsx)(`p`,{className:F(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,X.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,X.jsx)(O.Provider,{value:2,children:a})})]})},Hn=({tabs:e})=>(0,X.jsx)(`nav`,{"aria-label":K(`tabs`),className:`overflow-x-auto py-6`,children:(0,X.jsx)(`span`,{className:Je.group(`md`),children:e.map(e=>(0,X.jsx)(A,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:F(Je.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Un=({rows:e})=>(0,X.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,X.jsxs)(`div`,{className:F(`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,X.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Wn=({facts:e})=>(0,X.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,X.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),Gn=`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`,Kn=({actions:e})=>(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,X.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:K(`actions`)}),(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:F(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:F(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,X.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,X.jsx)(`li`,{children:s?s({className:Gn,children:c}):(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:Gn,children:c})},e)})})]}),qn=e(n(),1),Jn=1e3,Yn=(e,t,n,r,i)=>{let a=le(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,Z.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,Z.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Xn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),Zn=(e,t)=>e.sidebar?e.title?(0,X.jsx)(Cn,{title:e.title,children:t}):t:e.title?(0,X.jsx)(L,{title:e.title,children:t}):(0,X.jsx)(`section`,{className:`py-8`,children:t}),Qn=({item:e,scope:t,fallback:n})=>{let{components:r}=de(),i=r?.[e.component],a=i&&(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{...Me(e.props??{})})});return n===void 0?Zn(e,(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:n,children:Zn(e,a)})},$n=({component:e,scope:t,standard:n})=>{let{components:r}=de(),i=r?.[e];return i?(0,X.jsx)(l,{name:e,fallback:n,children:(0,X.jsx)(er,{children:(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{})})})}):n},er=({children:e})=>($e(!1),(0,X.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),tr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,nr=(e,t,n)=>B(()=>{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),rr=(e,t,n)=>B(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),ir=e=>ie(e)??Rn,ar=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=ne(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Wt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,Z.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Xt(e.run,t.record,a):void 0;return{name:e.label,icon:ir(e.icon),blocked:n,running:c.running===e.name,...Gt(e)&&{tone:`danger`},onRun:()=>Kt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,X.jsx)(mt,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:q(`edit`),icon:cn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:q(`delete`),icon:Sn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,X.jsx)(Jt,{action:l,label:l.label,danger:Gt(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)}})}},or=e=>{let t=ze(),{actions:n,prompt:r}=ar(e);return n.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,X.jsx)(Kn,{actions:n})}),t&&(0,qn.createPortal)((0,X.jsx)(bt,{actions:n,label:q(`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]})},sr=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}`},cr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?N(`operationFailed`,{index:n+1,label:sr(r),message:e.message}):N(`nothingSaved`,{message:e.message})},lr=(e,t)=>new e.constructor({...e.problem,detail:cr(e,t)}),ur=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),dr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=Y(),c=zt(),l=Ce(e.name,n),d=Ke(r,i),[f]=(0,Z.useState)(()=>a?nr(localStorage,a,t.etag):void 0),[m,g]=(0,Z.useState)(f?.fields??{}),[_,v]=(0,Z.useState)(!!f),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)({}),[ee,T]=(0,Z.useState)(0),E=Object.entries(m).filter(([n,r])=>p(e.fields[n],r,t.record[n])),D=E.length>0,O=D||!!o?.dirty;(0,Z.useEffect)(()=>{f?.order&&o?.setOrder(f.order)},[]),(0,Z.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(m).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;rr(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,m,o?.order,t.etag]);let k=n=>n in m?m[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:h(t.record[n]),A=(n,r)=>{w(e=>ur(e,n));let i=typeof r==`string`?r!==h(t.record[n]):p(e.fields[n],r,t.record[n]);g(e=>i?{...e,[n]:r}:ur(e,n))},j=async()=>{let r=await s.get(e.name,n);c.setQueryData(u.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(m)){let s=e.fields[n];p(s,o,r.record[n])&&(a[n]=o,h(r.record[n])!==h(t.record[n])&&(i[n]=s.type===`file`?qe(s,r.record[n]):h(r.record[n])))}g(a),S(i)},M=()=>Object.fromEntries(E.map(([t,n])=>[t,et(e.fields[t],n)])),te=e=>{let t=Tt(e);w(t),Object.keys(t).length>0&&T(e=>e+1)},N=async()=>{try{await l.mutateAsync({patch:M(),etag:t.etag})}catch(e){throw kt(e)?await j():re(e)&&te(e),e}},P=async r=>{let i=D?[{op:`update`,resource:e.name,key:n,data:M(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(kt(e))await j(),await c.invalidateQueries({queryKey:[`list`]}),b(!0);else if(re(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?te(e):n&&o?.reject(n,e)}throw re(e)?lr(e,a):e}await Promise.all([c.invalidateQueries({queryKey:u.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:k,change:A,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await P(e):await N(),g({}),S({}),w({}),b(!1),v(!1)}),dirty:O,discard:()=>{g({}),S({}),w({}),b(!1),v(!1),o?.reset()},restored:_&&O,dismissRestored:()=>v(!1),linesConflict:y,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:x,errors:C,rejections:ee,keepMine:e=>S(t=>ur(t,e)),useTheirs:e=>{S(t=>ur(t,e)),g(t=>ur(t,e))}}},Q=z(`focus-record`),fr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,X.jsx)(X.Fragment,{children:e.map(({name:e,label:r})=>[(0,X.jsx)(R,{size:`sm`,onClick:()=>t(e),children:Q(`keepMine`,{field:r})},`mine:${e}`),(0,X.jsx)(R,{size:`sm`,onClick:()=>n(e),children:Q(`useTheirs`,{field:r})},`theirs:${e}`)])}),pr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=_t(`primary`),o=dt()?.size===`compact`,s=(0,X.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,X.jsx)(ut,{zone:`secondary`,children:s}):(0,X.jsx)(ut,{zone:`primary`,fallback:!0,children:s})},mr=({record:e,saved:t,readOnly:n})=>{let r=dt()?.size,i=n?Q(`readOnly`):e.saving?Q(`saving`):e.dirty?Q(r===`wide`?`unsaved`:`unsavedShort`):t?Q(`saved`):void 0;return i?(0,X.jsx)(ut,{zone:`state`,fallback:!0,children:(0,X.jsxs)(`span`,{role:`status`,title:n?Q(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,X.jsx)(g,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},hr=({model:e,recordKey:t,stored:n,page:r})=>{let o=H().views[e.name],{address:s,go:c}=ne(),l=It()(e,o,n.record,t),{state:d}=wt(),f=dr({model:e,stored:n,recordKey:t,mode:`button`,subject:l,draftKey:d.kind===`signed-in`?`${tr(d.user.id,e.name,t)}:focus`:void 0});Te(f.dirty||f.saving),yt(f.dirty);let p=zt(),[h,g]=(0,Z.useState)(!1),_=o?.names?.singular??a(e.name),v=ke(e.name),y=dn(e),b=s?.kind===`record`&&s.version!==void 0&&s.version!==Number(n.record.version),x=`surface`in r&&(m(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),S=be(v,`update`)&&n.permissions?.update!==!1&&!x,C=!S||b,w=be(v,`delete`)&&n.permissions?.delete!==!1,ee=ln({model:e,view:o,restore:y,onDeleted:()=>c({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:u.record(e.name,t)})}),{actions:T,prompt:E}=ar({model:e,stored:n,recordKey:t,onDelete:w?()=>void ee.start({key:t,title:l,etag:n.etag,snapshot:n.record}):void 0}),D=(0,Z.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),O=T.filter(e=>e.tone===`danger`),k=[...T.filter(e=>e.tone!==`danger`),...f.dirty?[{name:Q(`discardChanges`),icon:In,onRun:()=>g(!0)}]:[],{name:Q(`detailsOf`,{noun:_}),icon:Pn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:D,role:n,className:e,children:t})},...O],j={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:C,mayUpdate:S,value:f.value,change:(e,t)=>C?void 0:f.change(e,t),dirty:f.dirty,saving:f.saving,refused:f.message!==void 0,save:async()=>!C&&!!await f.save(),discard:f.discard,details:D},M=`surface`in r?r.surface:void 0,te=h&&f.dirty&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,variant:`danger`,onClick:()=>{f.discard(),g(!1)},children:Q(`discardChanges`)}),(0,X.jsx)(R,{size:`sm`,onClick:()=>g(!1),children:Q(`keep`)})]}),children:Q(`discardAsk`)}),N=Object.keys(f.conflicts).length>0,P=M?f.errors[M]:void 0,re=P&&M?Pt(e.fields[M],o?.fields[M]?.label??a(M),P):void 0;return(0,X.jsxs)(Oe.Provider,{value:j,children:[!C&&(0,X.jsx)(pr,{record:j,label:Q(`save`)}),(0,X.jsx)(mr,{record:j,saved:f.phase===`saved`,readOnly:C}),(0,X.jsx)(i,{actions:k}),f.message&&!h&&(0,X.jsxs)(Ue,{level:`refused`,actions:(0,X.jsx)(A,{to:D,className:`text-body font-medium text-primary-text hover:underline`,children:Q(`detailsOf`,{noun:_})}),children:[(0,X.jsx)(`strong`,{className:`font-medium`,children:Q(`notSaved`)}),` `,re??f.message]}),N&&(0,X.jsx)(Ue,{level:`conflict`,actions:(0,X.jsx)(fr,{fields:Object.keys(f.conflicts).map(e=>({name:e,label:o?.fields[e]?.label??a(e)})),onKeepMine:f.keepMine,onUseTheirs:f.useTheirs}),children:Q(`conflict`)}),te,f.restored&&!h&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,onClick:f.dismissRestored,children:Q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:f.discard,children:Q(`discard`)})]}),children:Q(`restored`)}),M?(0,X.jsx)(gr,{model:e,name:M,stored:n,editor:f,readOnly:C}):(0,X.jsx)(_r,{name:r.component,model:e,stored:n,recordKey:t}),ee.dialogs,E]})},gr=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=H().views[e.name]?.fields[t];if(m(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(Pe,{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)})})},_r=({name:e,model:t,stored:n,recordKey:r})=>{let i=de().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(lt,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,X.jsx)(i,{})})})},vr=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=It()(e,H().views[e.name],n.record,t);return(0,X.jsx)(l,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,X.jsx)(Xe,{label:a,children:(0,X.jsx)(hr,{model:e,recordKey:t,stored:n,page:r})})})},yr=(0,Z.lazy)(()=>Rt(()=>import(`./record-map-DHkY7hYE.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),br=15,xr=({item:e,record:t})=>{let n=H().maps,r=n?.style,i=Yt(t,e);if(!r||!i)return null;let a=(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(yr,{style:r,layers:n?.layers,position:i,zoom:e.zoom??br},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,X.jsx)(Cn,{title:e.title,children:a}):(0,X.jsx)(L,{title:e.title,children:a})},Sr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},Cr=(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}))},wr=z(`app/record-chart`),Tr=I(),Er=[`1h`,`24h`,`7d`],Dr={"1h":`hour`,"24h":`day`,"7d":`week`},Or=({item:e,recordKey:t})=>{let{resources:n,views:r}=H(),[i,o]=(0,Z.useState)(e.range??`1h`),[s,c]=(0,Z.useState)(`average`),l=n[e.resource],u=r[e.resource],d=Sr[i],f=T(Tr.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...s===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:Ve()})),m=me(e.resource,p,!!l);if(!l)return null;let h=e.series.map(e=>({kind:s,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??a(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?Cr(m.map(e=>e.data.groups),g.map(e=>e.key),s):[],v=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(st,{label:wr(`measure`),value:s,onChange:c,options:[{value:`average`,label:wr(`average`)},{value:`maximum`,label:wr(`maximum`)}]}),(0,X.jsx)(st,{label:wr(`range`),value:i,onChange:o,options:Er.map(e=>({value:e,label:wr(Dr[e])}))})]});return(0,X.jsx)(L,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,X.jsx)(`p`,{className:`text-danger-text`,children:wr(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,X.jsx)(W,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:wr(`noSamples`)}):(0,X.jsx)(tn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},kr=z(`app/record-trend`),Ar=(e,t)=>kr(`total_${t}`,{count:e}),jr=I(),Mr={kind:`count`},Nr=({item:e,recordKey:t})=>{let n=T(jr.eq(e.field,t)),r=b(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Ve()});return(0,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,X.jsx)(W,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,X.jsx)(J,{title:kr(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:Ar(t,e.range)}),(0,X.jsx)(tn,{points:sn(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=>Re(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&&p(i,r,n[t])?[[t,et(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,et(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=>Ee(e,s.get(t)),f=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=f(t);o({op:`delete`,resource:e.name,key:u(t),...n&&{etag:n}},t)}let p=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=f(t);o({op:`update`,resource:e.name,key:u(t),data:r,...a&&{etag:a}},t),p.add(t)}let m=l.filter(e=>s.has(e)),h=l.filter(e=>!s.has(e)),g=(e,t)=>Object.fromEntries(e.flatMap(e=>{let n=t||p.has(e)?`*`:f(e);return n?[[ht(u(e)),n]]:[]})),_=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),v=(r,a,o)=>({op:`create`,resource:e.name,data:{...Ur(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),y=e=>Number(e[t])||0,b=m.some((e,t)=>e!==c.filter(e=>m.includes(e))[t]);if(h.every(e=>l.indexOf(e)>=m.length)){b&&o(_(m.map(u),1,g(m,!1)));let e=b?m.length:Math.max(0,...m.map(e=>y(s.get(e))));return h.forEach((t,n)=>o(v(t,e+1+n),t)),a}let x=Math.max(l.length,...r.map(y))+1;m.length>0&&o(_(m.map(u),x,g(m,!1)));let S=e=>`line${h.indexOf(e)+1}`;for(let e of h)o(v(e,l.indexOf(e)+1,S(e)),e);return o(_(l.map(e=>s.has(e)?u(e):{$ref:S(e)}),1,g(m,!0))),a},Gr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Kr=(e,t)=>{let[n,r]=(0,Z.useState)(Br),[i,a]=(0,Z.useState)(),o=(0,Z.useRef)(1),s=(0,Z.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,f=(0,Z.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]),p=(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:ue(a,o):o},m=e=>a(t=>t?.id===e?void 0:t);return{shown:c,dirty:u,order:f,value:p,change:(e,t,n)=>{m(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=>{m(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:Tt(t),message:t.message}),rejection:i,plan:l}},qr=(e,t)=>{let n=Re(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)=>j(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}=H(),i=(0,Z.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=Yn(a,i?.link,i?.position,t,a?M(n,r,a,o):void 0),c=Kr((0,Z.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:rt(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=>B(()=>e.getItem(ti)===`true`,!1),ri=(e,t)=>B(()=>t?e.setItem(ti,`true`):e.removeItem(ti),void 0),$=z(`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,Z.useRef)(null),c=(0,Z.useRef)(void 0),l=(0,Z.useId)(),u=ce(),[d,f]=(0,Z.useState)(()=>ni(localStorage)),[p,m]=(0,Z.useState)(!1);G(s,!0,i),(0,Z.useEffect)(()=>m(!0),[]);let h=t.length,g=e=>{let t=$r(n,e,h);t!==n&&r(t)},v=_(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{f(e),ri(localStorage,e)};return(0,X.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&ei(e))return e.preventDefault(),x(!d);let t=Qr(e.key);t!==0&&(e.preventDefault(),g(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,X.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,X.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,X.jsx)(`button`,{type:`button`,className:F(ii,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!d),children:(0,X.jsx)(Mn,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:ii,"aria-label":$(`close`),onClick:i,children:(0,X.jsx)(ct,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-[calc(0.75rem+var(--pb-safe-bottom))] md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(g(Zr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,X.jsx)(D,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),h>1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:F(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:()=>g(-1),children:(0,X.jsx)(Se,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:F(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===h-1,onClick:()=>g(1),children:(0,X.jsx)(Dt,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&d&&u&&(0,X.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,X.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),y]}),(0,X.jsx)(pt,{title:o,open:b&&d&&!u&&p,onClose:()=>x(!1),children:(0,X.jsx)(`div`,{className:`pt-3`,children:y})})]})},oi=(e,t,n)=>{let r=Re(t?.layout??[]).flatMap(e=>e.kind===`section`&&it(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)&&it(t?.fields[r]?.when,!1))},si=({model:e,view:t,photoKey:n,fields:r})=>{let i=ee(e.name,n),o=(t?.names?.singular??a(e.name)).toLowerCase();if(i.isPending)return(0,X.jsx)(W,{className:`h-4 w-48`});if(i.error)return(0,X.jsx)(J,{title:$(`couldNotLoadOne`,{singular:o}),error:i.error});let s=r.filter(e=>m(i.data.permissions,e)!==`hidden`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Un,{rows:s.map(n=>({label:t?.fields[n]?.label??a(n),value:(0,X.jsx)(Ft,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,X.jsx)(A,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:o})})]})},ci=e=>_(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 ht(n)},ui=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!C(t)||!ci(t))return[];let i=r&&li(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!C(e)||!ci(e))return i;let a=t=>C(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=I(),fi=(e,t,n)=>{let r=Y(),{resources:i}=H(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?T(di.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Vt({queryKey:u.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=_(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,X.jsx)(D,{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}=H(),i=fi(e,t,n),o=ke(i.holder?.name??``),[s,c]=(0,Z.useState)();if(i.isPending)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(W,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(J,{title:$(`couldNotLoad`),error:i.error})});let l=i.items.length;if(l===0)return null;let{shown:u,more:d}=Xr(l),f=i.holder,p=f&&r[f.name],m=f?oi(f,p,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],h=f!==void 0&&o.read!==!1&&m.length>0;return(0,X.jsxs)(L,{title:e.title,children:[(0,X.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,u).map((e,t)=>{let n=t===u-1&&d>0;return(0,X.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:l}):$(`showPhoto`,{index:t+1,count:l}),onClick:()=>c(t),className:F(`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[u][t]),children:[(0,X.jsx)(mi,{photo:e.file,large:t===0}),n&&(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${d}`}),t===0&&l>1&&(0,X.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,X.jsx)(An,{className:`size-3.5`}),l]})]},t)})}),s!==void 0&&(0,X.jsx)(ai,{title:e.title,photos:i.items.map(e=>e.file),index:s,onIndex:c,onClose:()=>c(void 0),details:e=>{let t=i.items[e]?.key;return h&&t!==void 0?(0,X.jsx)(si,{model:f,view:p,photoKey:t,fields:m},t):void 0},detailsTitle:f&&$(`holderDetails`,{singular:p?.names?.singular??a(f.name)})})]})},gi=z(`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 o=n?.fields[r],s=o?.label??a(r);return i.sensitive||!e.before||!e.after?[{name:r,label:s}]:[{name:r,label:s,before:qe(i,e.before[r],o),after:qe(i,e.after[r],o)}]}),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=Y(),a=Ht({queryKey:u.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,Z.useEffect)(()=>{let e=setTimeout(()=>void o(),yi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},xi=()=>(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),Si=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=vi(e,t,n),o=Date.parse(e.at);return(0,X.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,X.jsxs)(`time`,{dateTime:e.at,title:ve(o),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,X.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,X.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,X.jsx)(L,{title:e.title,children:a.isPending?(0,X.jsx)(xi,{}):a.error?(0,X.jsx)(J,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,X.jsx)(Si,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},wi=({comment:e})=>(0,X.jsx)(we,{text:e.body,mentions:e.mentions}),Ti=(e,t)=>{let n=Y(),r=zt();return Bt({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:u.comments(e,t)})})},Ei=z(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,Z.useState)(x),i=Y(),a=Ze(),o=Ti(e,t),s=(0,Z.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Te(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:he(n.text,n.picked)},{onSuccess:()=>r(x),onError:e=>a.show({state:`error`,title:Ei(`couldNotPost`),description:Le(e)})})};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(w,{"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,X.jsx)(`div`,{children:(0,X.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=Y(),r=Ht({queryKey:u.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,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,X.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsx)(nt,{initials:pe(t)||`?`,hue:y(e.author.id),size:`md`,className:`ring-0`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,X.jsxs)(`time`,{dateTime:e.createdAt,title:ve(n),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,X.jsx)(wi,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,X.jsxs)(L,{title:e.title,children:[i.isPending?(0,X.jsx)(Ai,{}):i.error?(0,X.jsx)(J,{title:Ei(`couldNotLoad`),error:i.error}):(0,X.jsxs)(X.Fragment,{children:[i.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:Ei(`showEarlier`)}),i.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Ei(`noComments`)}):(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,X.jsx)(ji,{comment:e},e.id))})]}),r&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.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=>De(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 De(a)?!r&&t[i++]===!0:it(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,vn(i,t),n,r)},zi=I(),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:T(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=Y(),{session:r,organizations:i}=wt(),a=(0,Z.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,Z.useState)(a?{state:`looking`}:{state:`missing`});return(0,Z.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=Y(),a=zt(),o=It(),s=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),c=Ut({queries:s.map(e=>{let o=t[e.relation.resource];return fe(a,i,o,n[o.name],String(r[e.name]))})}),l=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,l[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,v(c[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=I(),Gi=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let o=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}`]:[])),s=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&&!o.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return s.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??a(e.name),o=s.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:o?`${i} (${r?.fields[t]?.label??a(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:T(Wi.eq(e.field,t))}),Ji=I(),Yi=(e,t,n)=>{let r=Y(),i=Ut({queries:e.map(e=>{let i=T(Ji.eq(e.field,n));return{queryKey:u.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}=H(),{components:a}=de(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,X.jsx)(Cn,{title:q(`relatedRecords`),children:(0,X.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(A,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,X.jsx)(W,{className:`h-4 w-6`}):`${se(n.count)}${n.exact?``:`+`}`,(0,X.jsx)(Dt,{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,X.jsx)(W,{className:`inline-block h-5 w-7 rounded-full`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{dot:!1,className:F(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(V())})}),(0,X.jsx)(`span`,{className:`sr-only`,children:t?K(`headingCount`,{count:e,...t}):K(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&jt(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??gn(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??a(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:s,sort:c,fields:l,button:u,empty:d,add:f})=>{let p=_e(),{resources:m}=H(),h=c||tt(r,i),g=Ne(r,{filter:s,sort:h,pageSize:2});if(g.isPending)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(W,{className:`h-24 w-full`})});if(g.error)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(J,{title:gn(`couldNotLoad`),error:g.error})});let[_,v]=g.data.items;if(!_){let a=f&&(0,X.jsxs)(A,{to:f,className:o({size:`sm`}),children:[(0,X.jsx)(xt,{className:`size-3.5`}),gn(`add`,{singular:ea(r,i)})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:a,children:(0,X.jsx)($i,{empty:d})})}let y=ot(r,_),b=ea(r,i),x=i?.names?.plural??a(r.name),S=l.length>1,C=l.map(e=>(0,X.jsx)(mn,{scope:y,path:e,labelled:S},e)),w=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u&&(0,X.jsx)(on,{button:u,model:r,view:i,record:_,models:m}),(0,X.jsx)(A,{to:{kind:`record`,resource:r.name,key:Ee(r,_)},className:o({size:`sm`}),children:gn(`open`,{singular:b})})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:w,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[S?(0,X.jsx)(`dl`,{className:`flex flex-col gap-4`,children:C}):C,v&&(0,X.jsxs)(A,{to:en(r,i,p,{filter:s,orderBy:h,display:nn(i,p,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[Qt(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:x.toLowerCase()}),(0,X.jsx)(qt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=I(),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(T(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=Lt(ra(T(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(T(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=Y(),{resources:r}=H(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Ut({queries:i.map(({model:e,match:r})=>({...Ct(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=I(),ca=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??q(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=H(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=pn(s,`related:${n}:${e.title}`,e.display),d=ke(e.resource),[f,p]=(0,Z.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,X.jsx)(Zi,{count:m,names:s?.names}):void 0},g=rn(e,o,r),_=e.columns??j(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,X.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,X.jsx)(L,{...h,children:v(n=>(0,X.jsx)(bn,{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,X.jsx)(L,{...h,children:(0,X.jsx)(ca,{empty:e.empty})}):(0,X.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=On(e,o,d),b=(0,X.jsx)(an,{view:s,value:l,onChange:u}),x=y?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,X.jsx)(fn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,X.jsx)(L,{...h,actions:x,children:(0,X.jsx)(un,{model:o,view:s,field:y,filter:T(sa.eq(e.field,t)),columns:_})}):(0,X.jsx)(L,{...h,actions:x,children:v(t=>(0,X.jsx)($t,{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:Zt(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=H(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,X.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=I(),ma=(e,t)=>T(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=H(),[r]=vn(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,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(yn,{children:(0,X.jsx)(hn,{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,X.jsx)(gt,{value:t,children:(0,X.jsxs)(He,{tree:n,plan:r,children:[(0,X.jsx)(Tn,{tree:n,plan:r}),(0,X.jsx)(xn,{node:n,at:``})]})})},_a=P(()=>Rt(()=>import(`./record-lines-CJgNIVFS.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,X.jsx)(W,{className:`h-32 w-full rounded-lg`})),va=P(()=>Rt(()=>import(`./composer-section-D16PrwJe.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,X.jsx)(W,{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:q(`details`),fields:a},...e.history?[{kind:`history`,title:q(`history`)}]:[],...e.comments?[{kind:`comments`,title:q(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=H(),{address:i}=ne(),a=de(),o=n[e],s=ge(e,t);if(!o)return(0,X.jsx)(U,{title:N(`notFound`),children:N(`noResource`,{name:e})});if(s.isPending)return(0,X.jsx)(k,{});if(s.error)return(0,X.jsx)(`div`,{className:`p-8`,children:re(s.error)&&s.error.status===404?(0,X.jsx)(Sa,{model:o,recordKey:t}):(0,X.jsx)(J,{title:q(`couldNotLoad`),error:s.error})});let c=(0,X.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?Nt(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,X.jsx)(Ie,{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,X.jsx)(k,{});let e=En(f,s.data.record);if(e)return(0,X.jsx)(Dn,{to:e})}let p=r[e]?.record;if(!p||d)return c;if(s.isPlaceholderData)return(0,X.jsx)(k,{});if(`surface`in p||p.focus)return(0,X.jsx)(vr,{model:o,recordKey:t,stored:s.data,page:p,standard:c});let{record:m,etag:h,permissions:g}=s.data;return(0,X.jsx)($n,{component:p.component,scope:{model:o,record:m,key:t,etag:h,permissions:g},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,X.jsx)(k,{}):n.state===`switching`?(0,X.jsx)(U,{title:q(`loading`),children:q(`openingElsewhere`)}):n.state===`failed`?(0,X.jsx)(J,{title:q(`couldNotLoad`),error:n.error}):(0,X.jsx)(U,{title:N(`notFound`),children:q(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=H(),{address:c,go:l}=ne(),d=i.views[e.name],p=It()(e,d,n.record,t),{state:h}=wt(),_=Yr(e,t),v=dr({model:e,stored:n,recordKey:t,mode:d?.saveFeedback??`toast`,subject:p,draftKey:!r&&h.kind===`signed-in`?tr(h.user.id,e.name,t):void 0,lines:_.draft}),y=zt(),b=Y(),x=Ae(v.rejections),C=ke(e.name),w=dn(e),ee=c?.kind===`record`&&c.version!==void 0,T=be(C,`update`)&&n.permissions?.update!==!1&&!ee,{shown:E,offersEdit:D,editing:O}=ft(d?.recordMode,T,c?.kind===`record`&&c.edit===!0);Te(v.dirty&&E===`form`||v.saving),yt(v.dirty);let k=c?.kind===`record`?c.open:void 0,j=c?.kind===`record`&&c.edit===!0,M=c?.kind===`record`?c.tab:void 0,N=c?.kind===`record`&&c.standard===!0,P=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...N&&{standard:N}}),re=P(k,!1,M),ae=P(k,!0,M),se=E===`form`&&d?.recordMode!==void 0&&d.recordMode!==`edit`,I=be(C,`delete`)&&n.permissions?.delete!==!1,ce=ln({model:e,view:d,restore:w,onDeleted:()=>l({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void y.invalidateQueries({queryKey:u.record(e.name,t)})}),le=Ui(e,i.resources,i.views,n.record),ue=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},fe=Object.values(e.fields).filter(e=>ue(e.name)),pe={...n.record,...Object.fromEntries(fe.map(e=>[e.name,Et(e,v.value(e.name))]))},me=Ui(e,i.resources,i.views,pe),he=(e,t)=>{let n=ue(e);if(!n||!vt(t))return v.change(e,t);y.setQueryData(u.relatedLabel(n.name,t.key),{label:t.label}),v.change(e,rt(n,t.key))},{fields:ge}=de(),_e={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ve=Ri(ba(e,d,E===`read`),_e,O,r),{before:Se,tabs:Ce,after:we}=Ir(ve),z=Lr(Ce,M),Ee=e=>O&&(v.errors[e]!==void 0||v.conflicts[e]!==void 0);(0,Z.useEffect)(()=>{if(v.rejections===0)return;let e=zr(Ce,z,Ee);e&&l(P(k,j,e===Ce[0]?void 0:e.title),{replace:!0})},[v.rejections]);let B=ve.flatMap(e=>e.kind===`sidebar`?e.fields:[]),De=Xn(e,`updated`),V=e=>d?.fields[e],U=t=>m(n.permissions,t)!==`hidden`&&it(V(t)?.when,O)&&(E===`form`||!e.fields[t]?.writeOnly),Oe=e=>!r||Object.hasOwn(n.record,e),G=fa(e,d,n.record,B,U),Me=G&&(0,X.jsxs)(Ot,{value:n.record[G],hints:V(G),children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[V(G)?.label??a(G),`: `]}),qe(e.fields[G],n.record[G],V(G))]}),Ne=r=>{let o=e.fields[r],s=m(n.permissions,r);if(!o||s===`hidden`)return null;let c=v.conflicts[r],l=ue(r),u=V(r)?.label??a(r),f=v.errors[r],p=E!==`form`||s===`read`;return(0,X.jsx)(ye,{name:r,label:u,required:E===`form`&&s!==`read`&&S(o),help:Be(V(r),d,O),error:f&&Pt(o,u,f),wide:Qe(ge,o,V(r)),readOnly:At(o,V(r),p,!!l),conflict:c===void 0?void 0:{user:{name:q(`someoneElse`),initials:`?`,hue:40},ago:q(`justNow`),theirValue:c||`—`,onKeepMine:()=>v.keepMine(r),onUseTheirs:()=>v.useTheirs(r)},children:Oe(r)?(0,X.jsx)(Pe,{field:o,hints:V(r),value:v.value(r),stored:n.record[r],relationLabel:me.labels[r],relationTo:me.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:p,invalid:!!v.errors[r],reveal:o.sensitive&&!o.writeOnly?()=>b.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:V(r)?.format===`url`?at(e,d,r,n.record,le.labels):void 0,onChange:e=>he(r,e)}):(0,X.jsx)(W,{className:`h-9`})},o.sensitive?`${r}:${n.etag}`:r)},Ie=r=>{let i=e.fields[r],o=Oe(r)?i.sensitive?(0,X.jsx)(Pe,{field:i,hints:V(r),value:``,stored:n.record[r],locked:!0,reveal:()=>b.reveal(e.name,t,r),resource:e.name,onChange:e=>v.change(r,e)}):(0,X.jsx)(Ft,{model:e,field:i,value:n.record[r],relationLabel:le.labels[r],record:n.record,relationLabels:le.labels}):(0,X.jsx)(W,{className:`h-4 w-32`});return{label:V(r)?.label??a(r),help:Be(V(r),d,O),wide:Qe(ge,i,V(r)),value:o}},Le=ve.findIndex(e=>e.kind===`sidebar`),Re=(0,X.jsx)(wn,{title:q(`summary`),rows:B.flatMap(t=>{let r=e.fields[t];if(!r||!U(t))return[];if(!Oe(t))return[{label:V(t)?.label??a(t),value:(0,X.jsx)(W,{className:`h-4 w-24`})}];let i=n.record[t],o=Mt(r,V(t))&&typeof i==`string`&&i!==``,c=r.type===`json`&&i!=null,l=o?xe(i):c?je(i):qe(r,i,V(t)),u=r.type===`text`&&typeof i==`string`&&i!==``?Fe(V(t)):void 0,p=r.type===`enum`?(0,X.jsx)(Ot,{value:i,hints:V(t),children:l}):u?(0,X.jsx)(f,{format:u,value:l,label:at(e,d,t,n.record,le.labels)}):(0,X.jsx)(`span`,{title:Ge(r,i,void 0,V(t)),children:l}),m=oe(ge,r,V(t));return[{label:V(t)?.label??a(t),title:l,value:m?(0,X.jsx)(s,{shown:m,part:`display`,field:r,value:n.record[t],fallback:p}):p}]})}),ze=async()=>{await v.save()&&se&&l(re,{replace:!0})},K=I?()=>void ce.start({key:t,title:p,etag:n.etag,snapshot:n.record}):void 0,Ve=E===`form`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:v.saving,disabled:!v.dirty&&v.phase!==`saved`,onClick:()=>void ze(),children:[v.phase===`saved`&&(0,X.jsx)(g,{className:`size-4`}),v.phase===`saved`?q(`saved`):q(`save`)]}),se&&(0,X.jsx)(A,{to:re,className:F(o(),`max-md:min-h-11 md:w-full`),onClick:e=>te(e)&&v.discard(),children:q(`cancel`)}),v.dirty&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:q(`unsavedChanges`)})]}),He=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(He);if(e.length===0)return[];let r=Fr(i,k,Ee),a=i.collapsed?P(Pr(k,i.title),j,M):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||Oe(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,X.jsx)(da,{sections:o}):void 0;return[(0,X.jsx)(Vn,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!_.model||!_.item||r?[]:[(0,X.jsx)(_a,{lines:{..._,model:_.model,item:_.item},editable:E===`form`,saving:v.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!Oe(i.from)?[]:[(0,X.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,X.jsx)(Or,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,X.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,X.jsx)(Qn,{item:i,scope:_e,fallback:i.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(i).flatMap(([e,t])=>He(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,X.jsx)(xr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,X.jsx)(hi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,X.jsx)(Ci,{item:i,model:e,view:d,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,X.jsx)(ha,{item:i,scope:_e},`thread:${a}`)];if(i.kind===`blocks`)return[(0,X.jsx)(ga,{item:i,scope:_e},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,X.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,X.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:h.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&U(t)),s=E===`read`&&i.presentation===`facts`,c=s?St(n.record,o):o;return c.length===0?[]:[(0,X.jsx)(L,{title:i.title,help:We(i.helpWhen,d,O)?i.help:void 0,children:s?(0,X.jsx)(Wn,{facts:c.map(e=>({label:Ie(e).label,value:Ie(e).value,icon:ie(V(e)?.icon)}))}):E===`read`?(0,X.jsx)(Un,{rows:c.map(Ie)}):(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:c.map(Ne)})},i.title)]},Ue=(e,t)=>e.kind===`map`?(0,X.jsx)(xr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,X.jsx)(Qn,{item:e,scope:_e,fallback:e.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(e).map(([e,t])=>Ue(e,t))})},`custom:${t}`):null;return(0,X.jsxs)(`div`,{ref:x,className:`flex flex-1 flex-col`,inert:r,children:[ce.dialogs,(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsxs)(`div`,{className:F(d?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,X.jsx)(zn,{title:p,badge:Me}),v.message&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`notSaved`),error:Error(v.message)})}),v.linesConflict&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`linesChanged`),error:Error(q(`linesReloaded`))})}),E!==`form`&&D&&v.dirty&&(0,X.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,X.jsx)(`span`,{children:q(`unsavedKept`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{to:ae,className:o({size:`sm`}),children:q(`continueEditing`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),E===`form`&&v.restored&&(0,X.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,X.jsx)(`span`,{children:q(`unsavedRestored`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(R,{size:`sm`,onClick:v.dismissRestored,children:q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,X.jsxs)(`div`,{className:`divide-y divide-border`,children:[Se.flatMap(He),z&&(0,X.jsx)(Hn,{tabs:Ce.map((e,t)=>({title:e.title,to:P(k,j,t===0?void 0:e.title),current:e===z}))}),z&&(0,X.jsx)(`div`,{className:`divide-y divide-border`,children:z.items.flatMap(He)},`tab:${z.title}`),we.flatMap(He)]}),(0,X.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:[Ve&&(0,X.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ve}),!r&&(0,X.jsx)(or,{model:e,stored:n,recordKey:t,edit:D?ae:void 0,onDelete:K}),Le===-1&&Re,ve.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ue(e,t):t===Le?(0,X.jsx)(Z.Fragment,{children:Re},`summary`):null),(0,X.jsx)(wn,{title:q(`details`),rows:[Xn(e,`created`),De].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!U(t)||B.includes(t)?[]:[{label:V(t)?.label??a(t),value:Oe(t)?(0,X.jsx)(`span`,{title:Ge(r,n.record[t],void 0,V(t)),children:qe(r,n.record[t],V(t))}):(0,X.jsx)(W,{className:`h-4 w-24`})}]})}),!r&&(0,X.jsx)(Xi,{model:e,recordKey:t,layout:ve})]})]})]})}),Ve&&(0,X.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:Ve})]})};export{xa as RecordPage,Jn as t};
|
|
3
|
-
//# debugId=
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-SrorcD8G.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-BNosce4R.js","assets/app-1j5nx8lw.js","assets/vendor-t7Q7QbPu.js","assets/app-Dq5eubgK.css","assets/lib-maplibre-gl-CFGgq6sa.js","assets/lib-maplibre-gl-DBE96hFo.css","assets/lib-vis.gl-react-maplibre-1cv426UN.js","assets/lib-pmtiles-G7iEFxNu.js","assets/lib-fflate-HbhbPPwS.js","assets/record-lines-sVjQkysF.js","assets/embedded-list-CQ7VmI-J.js","assets/update-set-BQN3GDI3.js","assets/layout-grid-IQchsfWp.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-C8xkvcPt.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-BWJgscVY.js","assets/render-node-eKuGRuq5.js","assets/circle-alert-CCchwpE2.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-nDslRIg_.js","assets/person-row-RUXD4Z6I.js","assets/use-paged-search-DvGQocxR.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-DJZYMDoO.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,r as n,t as r}from"./react-CuiNlnus.js";import{$ as i,$c as a,$s as o,An as s,Ao as c,Ba as l,Bc as u,Bi as d,Bn as f,C as p,Ca as m,D as h,Dc as g,Di as _,Dn as v,Do as y,Dr as b,Dt as x,E as S,Ei as C,Et as w,Fa as ee,Fl as T,Go as E,Hn as D,I as O,Ii as k,Ir as A,Jc as j,Jn as M,Js as te,Ks as N,Li as P,Lr as ne,Ls as re,Lt as ie,Mc as ae,Mn as oe,Nc as F,Ni as se,Nl as I,No as ce,Nr as le,O as ue,Oa as de,On as fe,Oo as pe,Or as me,Ot as he,P as L,Pa as ge,Po as _e,Qi as ve,Qs as R,R as ye,Sa as be,Si as xe,Tc as Se,Tr as Ce,Tt as we,Us as Te,Vc as z,Vi as Ee,Vl as B,Vs as De,Wc as V,Xo as H,Yo as U,Ys as W,Z as Oe,Zo as ke,Zs as G,_ as Ae,_i as je,_l as Me,_n as Ne,b as Pe,bi as Fe,bn as Ie,ci as Le,cl as Re,co as ze,ct as K,d as Be,da as Ve,en as He,et as Ue,f as We,g as q,gi as Ge,h as Ke,hi as qe,ho as Je,ia as Ye,it as Xe,ja as Ze,jn as Qe,jo as $e,k as et,ki as tt,ko as nt,l as rt,m as it,mi as at,mn as ot,mo as st,mr as J,nc as ct,nr as lt,nt as ut,ot as dt,p as ft,po as pt,qs as mt,rl as ht,rr as gt,rs as Y,rt as _t,s as vt,ss as yt,st as bt,uc as xt,ui as St,un as Ct,us as wt,v as Tt,w as Et,wc as Dt,wn as Ot,wr as kt,x as At,xa as jt,xi as Mt,xn as Nt,y as Pt,yn as Ft,zi as It,zl as Lt}from"./app-1j5nx8lw.js";import{C as Rt,h as zt,i as Bt,o as Vt,r as Ht,s as Ut}from"./vendor-t7Q7QbPu.js";import{Ct as Wt,Dt as Gt,Et as Kt,Mt as qt,Tt as Jt,_ as Yt,a as Xt,c as Zt,lt as Qt,n as $t,ot as en,pt as tn,rt as nn,s as rn,t as an,tt as on,yt as sn}from"./embedded-list-CQ7VmI-J.js";import{a as cn,i as ln,n as un,r as dn,t as fn}from"./reorder-button-DFrAk-Xc.js";import{a as pn,c as mn,i as hn,l as gn,n as _n,o as vn,r as yn,s as bn,t as xn}from"./render-node-eKuGRuq5.js";import{t as Sn}from"./trash-Du1HjUvA.js";import{n as Cn,t as wn}from"./record-sidebar-HqyBXBwn.js";import{t as Tn}from"./start-block-queries-CAEd4yVp.js";import{n as En,t as Dn}from"./record-opens-BkQP4ve9.js";import{u as On}from"./messages-DAlS_OLf.js";var kn={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`}]]};kn.node;var An=ae(kn),jn={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`}]]};jn.node;var Mn=ae(jn),Nn={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`}]]};Nn.node;var Pn=ae(Nn),Fn={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`}]]};Fn.node;var In=ae(Fn),Ln={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`}]]};Ln.node;var Rn=ae(Ln),X=e(r(),1),zn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,X.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,X.jsxs)(`div`,{children:[e&&(0,X.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,X.jsxs)(X.Fragment,{children:[K(`lastEditedBy`),` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,X.jsx)(X.Fragment,{children:K(`lastUpdated`,{ago:r.ago})})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(c,{people:i,size:`md`}),K(`viewing`,{count:i.length})]}),a]})]}),Z=e(t(),1),Bn=`text-base font-semibold text-foreground`,Vn=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,Z.useId)();return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:F(`py-8`,r&&`pb-0`),children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,X.jsxs)(A,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:F(`inline-flex items-center gap-1.5`,Bn),children:[(0,X.jsx)(Dt,{className:F(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,X.jsx)(`span`,{className:Bn,children:e}),n]}),t&&(0,X.jsx)(`p`,{className:F(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,X.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,X.jsx)(O.Provider,{value:2,children:a})})]})},Hn=({tabs:e})=>(0,X.jsx)(`nav`,{"aria-label":K(`tabs`),className:`overflow-x-auto py-6`,children:(0,X.jsx)(`span`,{className:Je.group(`md`),children:e.map(e=>(0,X.jsx)(A,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:F(Je.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Un=({rows:e})=>(0,X.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,X.jsxs)(`div`,{className:F(`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,X.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Wn=({facts:e})=>(0,X.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,X.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),Gn=`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`,Kn=({actions:e})=>(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,X.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:K(`actions`)}),(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{className:F(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:F(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,X.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,X.jsx)(`li`,{children:s?s({className:Gn,children:c}):(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:Gn,children:c})},e)})})]}),qn=e(n(),1),Jn=1e3,Yn=(e,t,n,r,i)=>{let a=le(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,Z.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,Z.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Xn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),Zn=(e,t)=>e.sidebar?e.title?(0,X.jsx)(Cn,{title:e.title,children:t}):t:e.title?(0,X.jsx)(L,{title:e.title,children:t}):(0,X.jsx)(`section`,{className:`py-8`,children:t}),Qn=({item:e,scope:t,fallback:n})=>{let{components:r}=de(),i=r?.[e.component],a=i&&(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{...Me(e.props??{})})});return n===void 0?Zn(e,(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,X.jsx)(_n,{name:e.component,registered:!!i,fallback:n,children:Zn(e,a)})},$n=({component:e,scope:t,standard:n})=>{let{components:r}=de(),i=r?.[e];return i?(0,X.jsx)(l,{name:e,fallback:n,children:(0,X.jsx)(er,{children:(0,X.jsx)(lt,{value:t,children:(0,X.jsx)(i,{})})})}):n},er=({children:e})=>($e(!1),(0,X.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),tr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,nr=(e,t,n)=>B(()=>{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),rr=(e,t,n)=>B(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),ir=e=>ie(e)??Rn,ar=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=ne(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Wt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,Z.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Xt(e.run,t.record,a):void 0;return{name:e.label,icon:ir(e.icon),blocked:n,running:c.running===e.name,...Gt(e)&&{tone:`danger`},onRun:()=>Kt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,X.jsx)(mt,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:q(`edit`),icon:cn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:q(`delete`),icon:Sn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,X.jsx)(Jt,{action:l,label:l.label,danger:Gt(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)}})}},or=e=>{let t=ze(),{actions:n,prompt:r}=ar(e);return n.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,X.jsx)(Kn,{actions:n})}),t&&(0,qn.createPortal)((0,X.jsx)(bt,{actions:n,label:q(`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]})},sr=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}`},cr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?N(`operationFailed`,{index:n+1,label:sr(r),message:e.message}):N(`nothingSaved`,{message:e.message})},lr=(e,t)=>new e.constructor({...e.problem,detail:cr(e,t)}),ur=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),dr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=Y(),c=zt(),l=Ce(e.name,n),d=Ke(r,i),[f]=(0,Z.useState)(()=>a?nr(localStorage,a,t.etag):void 0),[m,g]=(0,Z.useState)(f?.fields??{}),[_,v]=(0,Z.useState)(!!f),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)({}),[ee,T]=(0,Z.useState)(0),E=Object.entries(m).filter(([n,r])=>p(e.fields[n],r,t.record[n])),D=E.length>0,O=D||!!o?.dirty;(0,Z.useEffect)(()=>{f?.order&&o?.setOrder(f.order)},[]),(0,Z.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(m).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;rr(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,m,o?.order,t.etag]);let k=n=>n in m?m[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:h(t.record[n]),A=(n,r)=>{w(e=>ur(e,n));let i=typeof r==`string`?r!==h(t.record[n]):p(e.fields[n],r,t.record[n]);g(e=>i?{...e,[n]:r}:ur(e,n))},j=async()=>{let r=await s.get(e.name,n);c.setQueryData(u.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(m)){let s=e.fields[n];p(s,o,r.record[n])&&(a[n]=o,h(r.record[n])!==h(t.record[n])&&(i[n]=s.type===`file`?qe(s,r.record[n]):h(r.record[n])))}g(a),S(i)},M=()=>Object.fromEntries(E.map(([t,n])=>[t,et(e.fields[t],n)])),te=e=>{let t=Tt(e);w(t),Object.keys(t).length>0&&T(e=>e+1)},N=async()=>{try{await l.mutateAsync({patch:M(),etag:t.etag})}catch(e){throw kt(e)?await j():re(e)&&te(e),e}},P=async r=>{let i=D?[{op:`update`,resource:e.name,key:n,data:M(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(kt(e))await j(),await c.invalidateQueries({queryKey:[`list`]}),b(!0);else if(re(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?te(e):n&&o?.reject(n,e)}throw re(e)?lr(e,a):e}await Promise.all([c.invalidateQueries({queryKey:u.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:k,change:A,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await P(e):await N(),g({}),S({}),w({}),b(!1),v(!1)}),dirty:O,discard:()=>{g({}),S({}),w({}),b(!1),v(!1),o?.reset()},restored:_&&O,dismissRestored:()=>v(!1),linesConflict:y,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:x,errors:C,rejections:ee,keepMine:e=>S(t=>ur(t,e)),useTheirs:e=>{S(t=>ur(t,e)),g(t=>ur(t,e))}}},Q=z(`focus-record`),fr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,X.jsx)(X.Fragment,{children:e.map(({name:e,label:r})=>[(0,X.jsx)(R,{size:`sm`,onClick:()=>t(e),children:Q(`keepMine`,{field:r})},`mine:${e}`),(0,X.jsx)(R,{size:`sm`,onClick:()=>n(e),children:Q(`useTheirs`,{field:r})},`theirs:${e}`)])}),pr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=_t(`primary`),o=dt()?.size===`compact`,s=(0,X.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,X.jsx)(ut,{zone:`secondary`,children:s}):(0,X.jsx)(ut,{zone:`primary`,fallback:!0,children:s})},mr=({record:e,saved:t,readOnly:n})=>{let r=dt()?.size,i=n?Q(`readOnly`):e.saving?Q(`saving`):e.dirty?Q(r===`wide`?`unsaved`:`unsavedShort`):t?Q(`saved`):void 0;return i?(0,X.jsx)(ut,{zone:`state`,fallback:!0,children:(0,X.jsxs)(`span`,{role:`status`,title:n?Q(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,X.jsx)(g,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},hr=({model:e,recordKey:t,stored:n,page:r})=>{let o=H().views[e.name],{address:s,go:c}=ne(),l=It()(e,o,n.record,t),{state:d}=wt(),f=dr({model:e,stored:n,recordKey:t,mode:`button`,subject:l,draftKey:d.kind===`signed-in`?`${tr(d.user.id,e.name,t)}:focus`:void 0});Te(f.dirty||f.saving),yt(f.dirty);let p=zt(),[h,g]=(0,Z.useState)(!1),_=o?.names?.singular??a(e.name),v=ke(e.name),y=dn(e),b=s?.kind===`record`&&s.version!==void 0&&s.version!==Number(n.record.version),x=`surface`in r&&(m(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),S=be(v,`update`)&&n.permissions?.update!==!1&&!x,C=!S||b,w=be(v,`delete`)&&n.permissions?.delete!==!1,ee=ln({model:e,view:o,restore:y,onDeleted:()=>c({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:u.record(e.name,t)})}),{actions:T,prompt:E}=ar({model:e,stored:n,recordKey:t,onDelete:w?()=>void ee.start({key:t,title:l,etag:n.etag,snapshot:n.record}):void 0}),D=(0,Z.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),O=T.filter(e=>e.tone===`danger`),k=[...T.filter(e=>e.tone!==`danger`),...f.dirty?[{name:Q(`discardChanges`),icon:In,onRun:()=>g(!0)}]:[],{name:Q(`detailsOf`,{noun:_}),icon:Pn,render:({className:e,children:t,role:n})=>(0,X.jsx)(A,{to:D,role:n,className:e,children:t})},...O],j={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:C,mayUpdate:S,value:f.value,change:(e,t)=>C?void 0:f.change(e,t),dirty:f.dirty,saving:f.saving,refused:f.message!==void 0,save:async()=>!C&&!!await f.save(),discard:f.discard,details:D},M=`surface`in r?r.surface:void 0,te=h&&f.dirty&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,variant:`danger`,onClick:()=>{f.discard(),g(!1)},children:Q(`discardChanges`)}),(0,X.jsx)(R,{size:`sm`,onClick:()=>g(!1),children:Q(`keep`)})]}),children:Q(`discardAsk`)}),N=Object.keys(f.conflicts).length>0,P=M?f.errors[M]:void 0,re=P&&M?Pt(e.fields[M],o?.fields[M]?.label??a(M),P):void 0;return(0,X.jsxs)(Oe.Provider,{value:j,children:[!C&&(0,X.jsx)(pr,{record:j,label:Q(`save`)}),(0,X.jsx)(mr,{record:j,saved:f.phase===`saved`,readOnly:C}),(0,X.jsx)(i,{actions:k}),f.message&&!h&&(0,X.jsxs)(Ue,{level:`refused`,actions:(0,X.jsx)(A,{to:D,className:`text-body font-medium text-primary-text hover:underline`,children:Q(`detailsOf`,{noun:_})}),children:[(0,X.jsx)(`strong`,{className:`font-medium`,children:Q(`notSaved`)}),` `,re??f.message]}),N&&(0,X.jsx)(Ue,{level:`conflict`,actions:(0,X.jsx)(fr,{fields:Object.keys(f.conflicts).map(e=>({name:e,label:o?.fields[e]?.label??a(e)})),onKeepMine:f.keepMine,onUseTheirs:f.useTheirs}),children:Q(`conflict`)}),te,f.restored&&!h&&(0,X.jsx)(Ue,{level:`draft`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{size:`sm`,onClick:f.dismissRestored,children:Q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:f.discard,children:Q(`discard`)})]}),children:Q(`restored`)}),M?(0,X.jsx)(gr,{model:e,name:M,stored:n,editor:f,readOnly:C}):(0,X.jsx)(_r,{name:r.component,model:e,stored:n,recordKey:t}),ee.dialogs,E]})},gr=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=H().views[e.name]?.fields[t];if(m(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(Pe,{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)})})},_r=({name:e,model:t,stored:n,recordKey:r})=>{let i=de().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(lt,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,X.jsx)(i,{})})})},vr=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=It()(e,H().views[e.name],n.record,t);return(0,X.jsx)(l,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,X.jsx)(Xe,{label:a,children:(0,X.jsx)(hr,{model:e,recordKey:t,stored:n,page:r})})})},yr=(0,Z.lazy)(()=>Rt(()=>import(`./record-map-SrorcD8G.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),br=15,xr=({item:e,record:t})=>{let n=H().maps,r=n?.style,i=Yt(t,e);if(!r||!i)return null;let a=(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(yr,{style:r,layers:n?.layers,position:i,zoom:e.zoom??br},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,X.jsx)(Cn,{title:e.title,children:a}):(0,X.jsx)(L,{title:e.title,children:a})},Sr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},Cr=(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}))},wr=z(`app/record-chart`),Tr=I(),Er=[`1h`,`24h`,`7d`],Dr={"1h":`hour`,"24h":`day`,"7d":`week`},Or=({item:e,recordKey:t})=>{let{resources:n,views:r}=H(),[i,o]=(0,Z.useState)(e.range??`1h`),[s,c]=(0,Z.useState)(`average`),l=n[e.resource],u=r[e.resource],d=Sr[i],f=T(Tr.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...s===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:Ve()})),m=me(e.resource,p,!!l);if(!l)return null;let h=e.series.map(e=>({kind:s,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??a(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?Cr(m.map(e=>e.data.groups),g.map(e=>e.key),s):[],v=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(st,{label:wr(`measure`),value:s,onChange:c,options:[{value:`average`,label:wr(`average`)},{value:`maximum`,label:wr(`maximum`)}]}),(0,X.jsx)(st,{label:wr(`range`),value:i,onChange:o,options:Er.map(e=>({value:e,label:wr(Dr[e])}))})]});return(0,X.jsx)(L,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,X.jsx)(`p`,{className:`text-danger-text`,children:wr(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,X.jsx)(W,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:wr(`noSamples`)}):(0,X.jsx)(tn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},kr=z(`app/record-trend`),Ar=(e,t)=>kr(`total_${t}`,{count:e}),jr=I(),Mr={kind:`count`},Nr=({item:e,recordKey:t})=>{let n=T(jr.eq(e.field,t)),r=b(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:Ve()});return(0,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,X.jsx)(W,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,X.jsx)(J,{title:kr(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:Ar(t,e.range)}),(0,X.jsx)(tn,{points:sn(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=>Re(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&&p(i,r,n[t])?[[t,et(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,et(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=>Ee(e,s.get(t)),f=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=f(t);o({op:`delete`,resource:e.name,key:u(t),...n&&{etag:n}},t)}let p=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=f(t);o({op:`update`,resource:e.name,key:u(t),data:r,...a&&{etag:a}},t),p.add(t)}let m=l.filter(e=>s.has(e)),h=l.filter(e=>!s.has(e)),g=(e,t)=>Object.fromEntries(e.flatMap(e=>{let n=t||p.has(e)?`*`:f(e);return n?[[ht(u(e)),n]]:[]})),_=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),v=(r,a,o)=>({op:`create`,resource:e.name,data:{...Ur(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),y=e=>Number(e[t])||0,b=m.some((e,t)=>e!==c.filter(e=>m.includes(e))[t]);if(h.every(e=>l.indexOf(e)>=m.length)){b&&o(_(m.map(u),1,g(m,!1)));let e=b?m.length:Math.max(0,...m.map(e=>y(s.get(e))));return h.forEach((t,n)=>o(v(t,e+1+n),t)),a}let x=Math.max(l.length,...r.map(y))+1;m.length>0&&o(_(m.map(u),x,g(m,!1)));let S=e=>`line${h.indexOf(e)+1}`;for(let e of h)o(v(e,l.indexOf(e)+1,S(e)),e);return o(_(l.map(e=>s.has(e)?u(e):{$ref:S(e)}),1,g(m,!0))),a},Gr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Kr=(e,t)=>{let[n,r]=(0,Z.useState)(Br),[i,a]=(0,Z.useState)(),o=(0,Z.useRef)(1),s=(0,Z.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,f=(0,Z.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]),p=(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:ue(a,o):o},m=e=>a(t=>t?.id===e?void 0:t);return{shown:c,dirty:u,order:f,value:p,change:(e,t,n)=>{m(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=>{m(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:Tt(t),message:t.message}),rejection:i,plan:l}},qr=(e,t)=>{let n=Re(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)=>j(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}=H(),i=(0,Z.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=Yn(a,i?.link,i?.position,t,a?M(n,r,a,o):void 0),c=Kr((0,Z.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:rt(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=>B(()=>e.getItem(ti)===`true`,!1),ri=(e,t)=>B(()=>t?e.setItem(ti,`true`):e.removeItem(ti),void 0),$=z(`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,Z.useRef)(null),c=(0,Z.useRef)(void 0),l=(0,Z.useId)(),u=ce(),[d,f]=(0,Z.useState)(()=>ni(localStorage)),[p,m]=(0,Z.useState)(!1);G(s,!0,i),(0,Z.useEffect)(()=>m(!0),[]);let h=t.length,g=e=>{let t=$r(n,e,h);t!==n&&r(t)},v=_(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{f(e),ri(localStorage,e)};return(0,X.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&ei(e))return e.preventDefault(),x(!d);let t=Qr(e.key);t!==0&&(e.preventDefault(),g(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,X.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,X.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,X.jsx)(`button`,{type:`button`,className:F(ii,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!d),children:(0,X.jsx)(Mn,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:ii,"aria-label":$(`close`),onClick:i,children:(0,X.jsx)(ct,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-[calc(0.75rem+var(--pb-safe-bottom))] md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(g(Zr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,X.jsx)(D,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),h>1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:F(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:()=>g(-1),children:(0,X.jsx)(Se,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:F(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===h-1,onClick:()=>g(1),children:(0,X.jsx)(Dt,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&d&&u&&(0,X.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,X.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),y]}),(0,X.jsx)(pt,{title:o,open:b&&d&&!u&&p,onClose:()=>x(!1),children:(0,X.jsx)(`div`,{className:`pt-3`,children:y})})]})},oi=(e,t,n)=>{let r=Re(t?.layout??[]).flatMap(e=>e.kind===`section`&&it(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)&&it(t?.fields[r]?.when,!1))},si=({model:e,view:t,photoKey:n,fields:r})=>{let i=ee(e.name,n),o=(t?.names?.singular??a(e.name)).toLowerCase();if(i.isPending)return(0,X.jsx)(W,{className:`h-4 w-48`});if(i.error)return(0,X.jsx)(J,{title:$(`couldNotLoadOne`,{singular:o}),error:i.error});let s=r.filter(e=>m(i.data.permissions,e)!==`hidden`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Un,{rows:s.map(n=>({label:t?.fields[n]?.label??a(n),value:(0,X.jsx)(Ft,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,X.jsx)(A,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:o})})]})},ci=e=>_(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 ht(n)},ui=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!C(t)||!ci(t))return[];let i=r&&li(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!C(e)||!ci(e))return i;let a=t=>C(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=I(),fi=(e,t,n)=>{let r=Y(),{resources:i}=H(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?T(di.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Vt({queryKey:u.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=_(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,X.jsx)(D,{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}=H(),i=fi(e,t,n),o=ke(i.holder?.name??``),[s,c]=(0,Z.useState)();if(i.isPending)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(W,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,X.jsx)(L,{title:e.title,children:(0,X.jsx)(J,{title:$(`couldNotLoad`),error:i.error})});let l=i.items.length;if(l===0)return null;let{shown:u,more:d}=Xr(l),f=i.holder,p=f&&r[f.name],m=f?oi(f,p,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],h=f!==void 0&&o.read!==!1&&m.length>0;return(0,X.jsxs)(L,{title:e.title,children:[(0,X.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,u).map((e,t)=>{let n=t===u-1&&d>0;return(0,X.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:l}):$(`showPhoto`,{index:t+1,count:l}),onClick:()=>c(t),className:F(`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[u][t]),children:[(0,X.jsx)(mi,{photo:e.file,large:t===0}),n&&(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${d}`}),t===0&&l>1&&(0,X.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,X.jsx)(An,{className:`size-3.5`}),l]})]},t)})}),s!==void 0&&(0,X.jsx)(ai,{title:e.title,photos:i.items.map(e=>e.file),index:s,onIndex:c,onClose:()=>c(void 0),details:e=>{let t=i.items[e]?.key;return h&&t!==void 0?(0,X.jsx)(si,{model:f,view:p,photoKey:t,fields:m},t):void 0},detailsTitle:f&&$(`holderDetails`,{singular:p?.names?.singular??a(f.name)})})]})},gi=z(`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 o=n?.fields[r],s=o?.label??a(r);return i.sensitive||!e.before||!e.after?[{name:r,label:s}]:[{name:r,label:s,before:qe(i,e.before[r],o),after:qe(i,e.after[r],o)}]}),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=Y(),a=Ht({queryKey:u.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,Z.useEffect)(()=>{let e=setTimeout(()=>void o(),yi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},xi=()=>(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),Si=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=vi(e,t,n),o=Date.parse(e.at);return(0,X.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,X.jsxs)(`time`,{dateTime:e.at,title:ve(o),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,X.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,X.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,X.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,X.jsx)(L,{title:e.title,children:a.isPending?(0,X.jsx)(xi,{}):a.error?(0,X.jsx)(J,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,X.jsx)(Si,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},wi=({comment:e})=>(0,X.jsx)(we,{text:e.body,mentions:e.mentions}),Ti=(e,t)=>{let n=Y(),r=zt();return Bt({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:u.comments(e,t)})})},Ei=z(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,Z.useState)(x),i=Y(),a=Ze(),o=Ti(e,t),s=(0,Z.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Te(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:he(n.text,n.picked)},{onSuccess:()=>r(x),onError:e=>a.show({state:`error`,title:Ei(`couldNotPost`),description:Le(e)})})};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(w,{"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,X.jsx)(`div`,{children:(0,X.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=Y(),r=Ht({queryKey:u.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,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,X.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,X.jsx)(nt,{initials:pe(t)||`?`,hue:y(e.author.id),size:`md`,className:`ring-0`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,X.jsxs)(`time`,{dateTime:e.createdAt,title:ve(n),className:`text-muted-foreground`,children:[`· `,Ye(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,X.jsx)(wi,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,X.jsxs)(L,{title:e.title,children:[i.isPending?(0,X.jsx)(Ai,{}):i.error?(0,X.jsx)(J,{title:Ei(`couldNotLoad`),error:i.error}):(0,X.jsxs)(X.Fragment,{children:[i.hasNextPage&&(0,X.jsx)(R,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:Ei(`showEarlier`)}),i.items.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Ei(`noComments`)}):(0,X.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,X.jsx)(ji,{comment:e},e.id))})]}),r&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.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=>De(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 De(a)?!r&&t[i++]===!0:it(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,vn(i,t),n,r)},zi=I(),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:T(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=Y(),{session:r,organizations:i}=wt(),a=(0,Z.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,Z.useState)(a?{state:`looking`}:{state:`missing`});return(0,Z.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=Y(),a=zt(),o=It(),s=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),c=Ut({queries:s.map(e=>{let o=t[e.relation.resource];return fe(a,i,o,n[o.name],String(r[e.name]))})}),l=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,l[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,v(c[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=I(),Gi=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let o=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}`]:[])),s=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&&!o.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return s.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??a(e.name),o=s.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:o?`${i} (${r?.fields[t]?.label??a(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:T(Wi.eq(e.field,t))}),Ji=I(),Yi=(e,t,n)=>{let r=Y(),i=Ut({queries:e.map(e=>{let i=T(Ji.eq(e.field,n));return{queryKey:u.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}=H(),{components:a}=de(),o=Yi(Gi(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,X.jsx)(Cn,{title:q(`relatedRecords`),children:(0,X.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(A,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,X.jsx)(W,{className:`h-4 w-6`}):`${se(n.count)}${n.exact?``:`+`}`,(0,X.jsx)(Dt,{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,X.jsx)(W,{className:`inline-block h-5 w-7 rounded-full`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{dot:!1,className:F(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(V())})}),(0,X.jsx)(`span`,{className:`sr-only`,children:t?K(`headingCount`,{count:e,...t}):K(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&jt(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??gn(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??a(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:s,sort:c,fields:l,button:u,empty:d,add:f})=>{let p=_e(),{resources:m}=H(),h=c||tt(r,i),g=Ne(r,{filter:s,sort:h,pageSize:2});if(g.isPending)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(W,{className:`h-24 w-full`})});if(g.error)return(0,X.jsx)(L,{title:e,help:t,count:n,children:(0,X.jsx)(J,{title:gn(`couldNotLoad`),error:g.error})});let[_,v]=g.data.items;if(!_){let a=f&&(0,X.jsxs)(A,{to:f,className:o({size:`sm`}),children:[(0,X.jsx)(xt,{className:`size-3.5`}),gn(`add`,{singular:ea(r,i)})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:a,children:(0,X.jsx)($i,{empty:d})})}let y=ot(r,_),b=ea(r,i),x=i?.names?.plural??a(r.name),S=l.length>1,C=l.map(e=>(0,X.jsx)(mn,{scope:y,path:e,labelled:S},e)),w=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[u&&(0,X.jsx)(on,{button:u,model:r,view:i,record:_,models:m}),(0,X.jsx)(A,{to:{kind:`record`,resource:r.name,key:Ee(r,_)},className:o({size:`sm`}),children:gn(`open`,{singular:b})})]});return(0,X.jsx)(L,{title:e,help:t,count:n,actions:w,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[S?(0,X.jsx)(`dl`,{className:`flex flex-col gap-4`,children:C}):C,v&&(0,X.jsxs)(A,{to:en(r,i,p,{filter:s,orderBy:h,display:nn(i,p,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[Qt(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:x.toLowerCase()}),(0,X.jsx)(qt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=I(),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(T(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=Lt(ra(T(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(T(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=Y(),{resources:r}=H(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Ut({queries:i.map(({model:e,match:r})=>({...Ct(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=I(),ca=({empty:e})=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e??q(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=H(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=pn(s,`related:${n}:${e.title}`,e.display),d=ke(e.resource),[f,p]=(0,Z.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,X.jsx)(Zi,{count:m,names:s?.names}):void 0},g=rn(e,o,r),_=e.columns??j(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,X.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,X.jsx)(L,{...h,children:v(n=>(0,X.jsx)(bn,{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,X.jsx)(L,{...h,children:(0,X.jsx)(ca,{empty:e.empty})}):(0,X.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=On(e,o,d),b=(0,X.jsx)(an,{view:s,value:l,onChange:u}),x=y?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,X.jsx)(fn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,X.jsx)(L,{...h,actions:x,children:(0,X.jsx)(un,{model:o,view:s,field:y,filter:T(sa.eq(e.field,t)),columns:_})}):(0,X.jsx)(L,{...h,actions:x,children:v(t=>(0,X.jsx)($t,{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:Zt(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=H(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,X.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=I(),ma=(e,t)=>T(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=H(),[r]=vn(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,X.jsx)(L,{title:e.title,help:e.help,children:(0,X.jsx)(yn,{children:(0,X.jsx)(hn,{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,X.jsx)(gt,{value:t,children:(0,X.jsxs)(He,{tree:n,plan:r,children:[(0,X.jsx)(Tn,{tree:n,plan:r}),(0,X.jsx)(xn,{node:n,at:``})]})})},_a=P(()=>Rt(()=>import(`./record-lines-sVjQkysF.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,X.jsx)(W,{className:`h-32 w-full rounded-lg`})),va=P(()=>Rt(()=>import(`./composer-section-BWJgscVY.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,X.jsx)(W,{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:q(`details`),fields:a},...e.history?[{kind:`history`,title:q(`history`)}]:[],...e.comments?[{kind:`comments`,title:q(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=H(),{address:i}=ne(),a=de(),o=n[e],s=ge(e,t);if(!o)return(0,X.jsx)(U,{title:N(`notFound`),children:N(`noResource`,{name:e})});if(s.isPending)return(0,X.jsx)(k,{});if(s.error)return(0,X.jsx)(`div`,{className:`p-8`,children:re(s.error)&&s.error.status===404?(0,X.jsx)(Sa,{model:o,recordKey:t}):(0,X.jsx)(J,{title:q(`couldNotLoad`),error:s.error})});let c=(0,X.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?Nt(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,X.jsx)(Ie,{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,X.jsx)(k,{});let e=En(f,s.data.record);if(e)return(0,X.jsx)(Dn,{to:e})}let p=r[e]?.record;if(!p||d)return c;if(s.isPlaceholderData)return(0,X.jsx)(k,{});if(`surface`in p||p.focus)return(0,X.jsx)(vr,{model:o,recordKey:t,stored:s.data,page:p,standard:c});let{record:m,etag:h,permissions:g}=s.data;return(0,X.jsx)($n,{component:p.component,scope:{model:o,record:m,key:t,etag:h,permissions:g},standard:c})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,X.jsx)(k,{}):n.state===`switching`?(0,X.jsx)(U,{title:q(`loading`),children:q(`openingElsewhere`)}):n.state===`failed`?(0,X.jsx)(J,{title:q(`couldNotLoad`),error:n.error}):(0,X.jsx)(U,{title:N(`notFound`),children:q(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=H(),{address:c,go:l}=ne(),d=i.views[e.name],p=It()(e,d,n.record,t),{state:h}=wt(),_=Yr(e,t),v=dr({model:e,stored:n,recordKey:t,mode:d?.saveFeedback??`toast`,subject:p,draftKey:!r&&h.kind===`signed-in`?tr(h.user.id,e.name,t):void 0,lines:_.draft}),y=zt(),b=Y(),x=Ae(v.rejections),C=ke(e.name),w=dn(e),ee=c?.kind===`record`&&c.version!==void 0,T=be(C,`update`)&&n.permissions?.update!==!1&&!ee,{shown:E,offersEdit:D,editing:O}=ft(d?.recordMode,T,c?.kind===`record`&&c.edit===!0);Te(v.dirty&&E===`form`||v.saving),yt(v.dirty);let k=c?.kind===`record`?c.open:void 0,j=c?.kind===`record`&&c.edit===!0,M=c?.kind===`record`?c.tab:void 0,N=c?.kind===`record`&&c.standard===!0,P=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...N&&{standard:N}}),re=P(k,!1,M),ae=P(k,!0,M),se=E===`form`&&d?.recordMode!==void 0&&d.recordMode!==`edit`,I=be(C,`delete`)&&n.permissions?.delete!==!1,ce=ln({model:e,view:d,restore:w,onDeleted:()=>l({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void y.invalidateQueries({queryKey:u.record(e.name,t)})}),le=Ui(e,i.resources,i.views,n.record),ue=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},fe=Object.values(e.fields).filter(e=>ue(e.name)),pe={...n.record,...Object.fromEntries(fe.map(e=>[e.name,Et(e,v.value(e.name))]))},me=Ui(e,i.resources,i.views,pe),he=(e,t)=>{let n=ue(e);if(!n||!vt(t))return v.change(e,t);y.setQueryData(u.relatedLabel(n.name,t.key),{label:t.label}),v.change(e,rt(n,t.key))},{fields:ge}=de(),_e={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ve=Ri(ba(e,d,E===`read`),_e,O,r),{before:Se,tabs:Ce,after:we}=Ir(ve),z=Lr(Ce,M),Ee=e=>O&&(v.errors[e]!==void 0||v.conflicts[e]!==void 0);(0,Z.useEffect)(()=>{if(v.rejections===0)return;let e=zr(Ce,z,Ee);e&&l(P(k,j,e===Ce[0]?void 0:e.title),{replace:!0})},[v.rejections]);let B=ve.flatMap(e=>e.kind===`sidebar`?e.fields:[]),De=Xn(e,`updated`),V=e=>d?.fields[e],U=t=>m(n.permissions,t)!==`hidden`&&it(V(t)?.when,O)&&(E===`form`||!e.fields[t]?.writeOnly),Oe=e=>!r||Object.hasOwn(n.record,e),G=fa(e,d,n.record,B,U),Me=G&&(0,X.jsxs)(Ot,{value:n.record[G],hints:V(G),children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[V(G)?.label??a(G),`: `]}),qe(e.fields[G],n.record[G],V(G))]}),Ne=r=>{let o=e.fields[r],s=m(n.permissions,r);if(!o||s===`hidden`)return null;let c=v.conflicts[r],l=ue(r),u=V(r)?.label??a(r),f=v.errors[r],p=E!==`form`||s===`read`;return(0,X.jsx)(ye,{name:r,label:u,required:E===`form`&&s!==`read`&&S(o),help:Be(V(r),d,O),error:f&&Pt(o,u,f),wide:Qe(ge,o,V(r)),readOnly:At(o,V(r),p,!!l),conflict:c===void 0?void 0:{user:{name:q(`someoneElse`),initials:`?`,hue:40},ago:q(`justNow`),theirValue:c||`—`,onKeepMine:()=>v.keepMine(r),onUseTheirs:()=>v.useTheirs(r)},children:Oe(r)?(0,X.jsx)(Pe,{field:o,hints:V(r),value:v.value(r),stored:n.record[r],relationLabel:me.labels[r],relationTo:me.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:p,invalid:!!v.errors[r],reveal:o.sensitive&&!o.writeOnly?()=>b.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:V(r)?.format===`url`?at(e,d,r,n.record,le.labels):void 0,onChange:e=>he(r,e)}):(0,X.jsx)(W,{className:`h-9`})},o.sensitive?`${r}:${n.etag}`:r)},Ie=r=>{let i=e.fields[r],o=Oe(r)?i.sensitive?(0,X.jsx)(Pe,{field:i,hints:V(r),value:``,stored:n.record[r],locked:!0,reveal:()=>b.reveal(e.name,t,r),resource:e.name,onChange:e=>v.change(r,e)}):(0,X.jsx)(Ft,{model:e,field:i,value:n.record[r],relationLabel:le.labels[r],record:n.record,relationLabels:le.labels}):(0,X.jsx)(W,{className:`h-4 w-32`});return{label:V(r)?.label??a(r),help:Be(V(r),d,O),wide:Qe(ge,i,V(r)),value:o}},Le=ve.findIndex(e=>e.kind===`sidebar`),Re=(0,X.jsx)(wn,{title:q(`summary`),rows:B.flatMap(t=>{let r=e.fields[t];if(!r||!U(t))return[];if(!Oe(t))return[{label:V(t)?.label??a(t),value:(0,X.jsx)(W,{className:`h-4 w-24`})}];let i=n.record[t],o=Mt(r,V(t))&&typeof i==`string`&&i!==``,c=r.type===`json`&&i!=null,l=o?xe(i):c?je(i):qe(r,i,V(t)),u=r.type===`text`&&typeof i==`string`&&i!==``?Fe(V(t)):void 0,p=r.type===`enum`?(0,X.jsx)(Ot,{value:i,hints:V(t),children:l}):u?(0,X.jsx)(f,{format:u,value:l,label:at(e,d,t,n.record,le.labels)}):(0,X.jsx)(`span`,{title:Ge(r,i,void 0,V(t)),children:l}),m=oe(ge,r,V(t));return[{label:V(t)?.label??a(t),title:l,value:m?(0,X.jsx)(s,{shown:m,part:`display`,field:r,value:n.record[t],fallback:p}):p}]})}),ze=async()=>{await v.save()&&se&&l(re,{replace:!0})},K=I?()=>void ce.start({key:t,title:p,etag:n.etag,snapshot:n.record}):void 0,Ve=E===`form`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(R,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:v.saving,disabled:!v.dirty&&v.phase!==`saved`,onClick:()=>void ze(),children:[v.phase===`saved`&&(0,X.jsx)(g,{className:`size-4`}),v.phase===`saved`?q(`saved`):q(`save`)]}),se&&(0,X.jsx)(A,{to:re,className:F(o(),`max-md:min-h-11 md:w-full`),onClick:e=>te(e)&&v.discard(),children:q(`cancel`)}),v.dirty&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:q(`unsavedChanges`)})]}),He=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(He);if(e.length===0)return[];let r=Fr(i,k,Ee),a=i.collapsed?P(Pr(k,i.title),j,M):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||Oe(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,X.jsx)(da,{sections:o}):void 0;return[(0,X.jsx)(Vn,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!_.model||!_.item||r?[]:[(0,X.jsx)(_a,{lines:{..._,model:_.model,item:_.item},editable:E===`form`,saving:v.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!Oe(i.from)?[]:[(0,X.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,X.jsx)(Or,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,X.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,X.jsx)(Qn,{item:i,scope:_e,fallback:i.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(i).flatMap(([e,t])=>He(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,X.jsx)(xr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,X.jsx)(hi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,X.jsx)(Ci,{item:i,model:e,view:d,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,X.jsx)(ha,{item:i,scope:_e},`thread:${a}`)];if(i.kind===`blocks`)return[(0,X.jsx)(ga,{item:i,scope:_e},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,X.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,X.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:h.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&U(t)),s=E===`read`&&i.presentation===`facts`,c=s?St(n.record,o):o;return c.length===0?[]:[(0,X.jsx)(L,{title:i.title,help:We(i.helpWhen,d,O)?i.help:void 0,children:s?(0,X.jsx)(Wn,{facts:c.map(e=>({label:Ie(e).label,value:Ie(e).value,icon:ie(V(e)?.icon)}))}):E===`read`?(0,X.jsx)(Un,{rows:c.map(Ie)}):(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:c.map(Ne)})},i.title)]},Ue=(e,t)=>e.kind===`map`?(0,X.jsx)(xr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,X.jsx)(Qn,{item:e,scope:_e,fallback:e.fallback&&(0,X.jsx)(X.Fragment,{children:Ii(e).map(([e,t])=>Ue(e,t))})},`custom:${t}`):null;return(0,X.jsxs)(`div`,{ref:x,className:`flex flex-1 flex-col`,inert:r,children:[ce.dialogs,(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsxs)(`div`,{className:F(d?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,X.jsx)(zn,{title:p,badge:Me}),v.message&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`notSaved`),error:Error(v.message)})}),v.linesConflict&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(J,{title:q(`linesChanged`),error:Error(q(`linesReloaded`))})}),E!==`form`&&D&&v.dirty&&(0,X.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,X.jsx)(`span`,{children:q(`unsavedKept`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{to:ae,className:o({size:`sm`}),children:q(`continueEditing`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),E===`form`&&v.restored&&(0,X.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,X.jsx)(`span`,{children:q(`unsavedRestored`)}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsx)(R,{size:`sm`,onClick:v.dismissRestored,children:q(`keep`)}),(0,X.jsx)(R,{size:`sm`,onClick:v.discard,children:q(`discard`)})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,X.jsxs)(`div`,{className:`divide-y divide-border`,children:[Se.flatMap(He),z&&(0,X.jsx)(Hn,{tabs:Ce.map((e,t)=>({title:e.title,to:P(k,j,t===0?void 0:e.title),current:e===z}))}),z&&(0,X.jsx)(`div`,{className:`divide-y divide-border`,children:z.items.flatMap(He)},`tab:${z.title}`),we.flatMap(He)]}),(0,X.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:[Ve&&(0,X.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ve}),!r&&(0,X.jsx)(or,{model:e,stored:n,recordKey:t,edit:D?ae:void 0,onDelete:K}),Le===-1&&Re,ve.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ue(e,t):t===Le?(0,X.jsx)(Z.Fragment,{children:Re},`summary`):null),(0,X.jsx)(wn,{title:q(`details`),rows:[Xn(e,`created`),De].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!U(t)||B.includes(t)?[]:[{label:V(t)?.label??a(t),value:Oe(t)?(0,X.jsx)(`span`,{title:Ge(r,n.record[t],void 0,V(t)),children:qe(r,n.record[t],V(t))}):(0,X.jsx)(W,{className:`h-4 w-24`})}]})}),!r&&(0,X.jsx)(Xi,{model:e,recordKey:t,layout:ve})]})]})]})}),Ve&&(0,X.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:Ve})]})};export{xa as RecordPage,Jn as t};
|
|
3
|
+
//# debugId=80d9b9a1-c719-4648-9381-560b5633a2d1
|