@protobase/ui 0.117.4 → 0.117.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/messages.d.ts +2 -2
- package/dist/app/app.js +40 -34
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/meta-gate-messages.d.ts +2 -2
- package/dist/app/new-version/messages.d.ts +2 -2
- package/dist/app/pages/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-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/router.d.ts +2 -0
- package/dist/app/router.js +23 -10
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/saved/use-favorite.d.ts +1 -1
- package/dist/app/search/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/searches/use-save-search.d.ts +1 -1
- package/dist/app/use-app-address.d.ts +3 -1
- package/dist/app/use-app-address.js +5 -3
- package/dist/app-shell/app-shell.d.ts +3 -1
- package/dist/app-shell/app-shell.js +38 -5
- package/dist/app-shell/drawer.d.ts +10 -2
- package/dist/app-shell/drawer.js +16 -4
- package/dist/app-shell/edge-swipe.d.ts +49 -0
- package/dist/app-shell/edge-swipe.js +39 -0
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/app-shell/top-bar.js +1 -1
- package/dist/app-shell/use-edge-swipe.d.ts +25 -0
- package/dist/app-shell/use-edge-swipe.js +128 -0
- 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/chat/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/invitations/messages.d.ts +2 -2
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/primitives/use-drawer-drag.d.ts +2 -0
- package/dist/primitives/use-drawer-drag.js +18 -6
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-BKgO5U-X.js → account-page-BPtyska2.js} +2 -2
- package/dist/shell/assets/app-DKn-6fgf.js +34 -0
- package/dist/shell/assets/{assistant-shell-DuqVM626.js → assistant-shell-BW59by36.js} +2 -2
- package/dist/shell/assets/{board-display-DddxG38M.js → board-display-uC4sMccF.js} +2 -2
- package/dist/shell/assets/{calendar-display-zLyE7rhF.js → calendar-display-BZhTapxV.js} +2 -2
- package/dist/shell/assets/{call-rings-uudxTLcY.js → call-rings-DwyQO_zl.js} +2 -2
- package/dist/shell/assets/{calls-7JJIY2v0.js → calls-DeHPxZSF.js} +2 -2
- package/dist/shell/assets/{circle-alert-CoX9nLsD.js → circle-alert-mtPRl_1e.js} +2 -2
- package/dist/shell/assets/{composed-page-DnCccgH0.js → composed-page-CqjAO9Zv.js} +2 -2
- package/dist/shell/assets/{composer-section-84NNbJ4X.js → composer-section-D16PrwJe.js} +2 -2
- package/dist/shell/assets/{connect-route-DXEPuBjl.js → connect-route-BHjM-n0c.js} +2 -2
- package/dist/shell/assets/{copy-field-BlooSgn7.js → copy-field-C7SgGBWe.js} +2 -2
- package/dist/shell/assets/{create-route-BNcDypty.js → create-route-CV6sScUu.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-CyvWLsF0.js → custom-step-container-field-DbXZzPJp.js} +2 -2
- package/dist/shell/assets/{embedded-list-B8K84K5b.js → embedded-list-CG1SyUtd.js} +3 -3
- package/dist/shell/assets/{export-dialog-IWSkZoEf.js → export-dialog-CMPyzZa3.js} +2 -2
- package/dist/shell/assets/{graph-view-D6ueoFs9.js → graph-view-CfO5HJXO.js} +2 -2
- package/dist/shell/assets/{group-donut-BnDzQhIS.js → group-donut-UrNllcKD.js} +2 -2
- package/dist/shell/assets/{guest-call-page-IwcmjkTm.js → guest-call-page-CgISSPNH.js} +3 -3
- package/dist/shell/assets/{html-viewer-DjlpP883.js → html-viewer-GgauWEUE.js} +2 -2
- package/dist/shell/assets/{import-dialog-DrDyc76O.js → import-dialog-BppJUUoF.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-DYBhyBp7.js → import-table-dialog-cfWZMJfg.js} +2 -2
- package/dist/shell/assets/{index-fxThWO9s.js → index-C6CE4Yqt.js} +1 -1
- package/dist/shell/assets/{invitations-page-BmkBa0fB.js → invitations-page-Cx960zfb.js} +2 -2
- package/dist/shell/assets/{layout-grid-DGOCHAPH.js → layout-grid-IdJUsNk6.js} +2 -2
- package/dist/shell/assets/{legend-item-DxdIZ1pf.js → legend-item-FRGENXpR.js} +2 -2
- package/dist/shell/assets/{list-page-BhWOEaP6.js → list-page-Di8ApAmU.js} +4 -4
- package/dist/shell/assets/{maplibre-k6sh-ts2.js → maplibre-B0oPa_5e.js} +2 -2
- package/dist/shell/assets/{markdown-content-vMCleJqq.js → markdown-content-CA74ofB3.js} +2 -2
- package/dist/shell/assets/{members-page-NrAKIuOb.js → members-page-UO-o4WSG.js} +2 -2
- package/dist/shell/assets/{messages-Cjox3dPW.js → messages-CjRWJI05.js} +2 -2
- package/dist/shell/assets/{organization-page-HRjNwewQ.js → organization-page-DaGSJbur.js} +2 -2
- package/dist/shell/assets/{organizations-page-D-Is15Iq.js → organizations-page-C5oK_zsd.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-MATld1YG.js → pending-invitation-row-BEvgmW-N.js} +2 -2
- package/dist/shell/assets/{period-chart-xv3RhzW9.js → period-chart-CW2NUL07.js} +2 -2
- package/dist/shell/assets/{person-row-DPsUV5XA.js → person-row-5VQjyq5t.js} +2 -2
- package/dist/shell/assets/{public-form-page-CK0NgO4L.js → public-form-page-CqU7Cg33.js} +2 -2
- package/dist/shell/assets/{record-lines-CDGK7ZyR.js → record-lines-CJgNIVFS.js} +2 -2
- package/dist/shell/assets/{record-map-C8QpQBwW.js → record-map-DHkY7hYE.js} +2 -2
- package/dist/shell/assets/{record-opens-jhy0UcRX.js → record-opens-B0MlYjrH.js} +2 -2
- package/dist/shell/assets/{record-page-BQtAOfUN.js → record-page-whDNzf71.js} +3 -3
- package/dist/shell/assets/{record-preview-Cnz2q7jF.js → record-preview-BUnzkT7g.js} +2 -2
- package/dist/shell/assets/{records-map-Cpt0N4k2.js → records-map-DjcDdJBM.js} +2 -2
- package/dist/shell/assets/{render-node-CQddajXn.js → render-node-DGmdm-wr.js} +3 -3
- package/dist/shell/assets/{reorder-button-2tg9wf42.js → reorder-button-q4oqy3UR.js} +2 -2
- package/dist/shell/assets/{run-trace-view-C8KR_auS.js → run-trace-view-DjtMSojN.js} +2 -2
- package/dist/shell/assets/{runner-install-field-Dfnq3Rqy.js → runner-install-field-Ddxc9XB0.js} +2 -2
- package/dist/shell/assets/{runtime-update-BkP2MEsM.js → runtime-update-CKEA5P-k.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-CbwI3ULn.js → shared-protobase-ui-tTqz9hwW.js} +1 -1
- package/dist/shell/assets/{sheet-source-Bsx98FTk.js → sheet-source-CAIVzfnw.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-hgTJtin9.js → sign-in-policy-page-CdTIudi-.js} +2 -2
- package/dist/shell/assets/{start-block-queries-Cmx56hgU.js → start-block-queries-DjQjQ2Ef.js} +2 -2
- package/dist/shell/assets/{step-catalog-BJyr7gmH.js → step-catalog-Dit0IJvs.js} +2 -2
- package/dist/shell/assets/{step-panel-D-jkWWLs.js → step-panel-9kx6xfm1.js} +2 -2
- package/dist/shell/assets/{timeline-display-FKWlqzyN.js → timeline-display-CoQETrmW.js} +2 -2
- package/dist/shell/assets/{trash-BNguTSbA.js → trash-DJwJPifF.js} +2 -2
- package/dist/shell/assets/{update-set-CaKid6Bl.js → update-set-DPSGWrcI.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-UCTCC4Mu.js → use-calendar-move-CgXeokRh.js} +2 -2
- package/dist/shell/assets/{use-display-rows-BeUN0NEn.js → use-display-rows-DFSNvNWx.js} +2 -2
- package/dist/shell/assets/{use-paged-search-33KMMcrt.js → use-paged-search-B52iaj1D.js} +2 -2
- package/dist/shell/assets/{use-run-trace-Bx9X8OOk.js → use-run-trace-KAufJAqD.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-BiyvMPJr.js → use-workflow-page-171SXJ7G.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-Dv4j1fdw.js → use-workflow-types-ZGEaDrEJ.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-CXQvv_wT.js → workflow-canvas-CCu4twlF.js} +2 -2
- package/dist/shell/assets/{workflow-field-f3yIRcdj.js → workflow-field-BFNHwCjK.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-Dkn-LYZl.js → workflow-graph-editor-DTSyabCd.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-Btst6LE9.js → workflow-run-field-D2fpm1Vk.js} +3 -3
- package/dist/shell/assets/{workflow-status-field-DwvvkBQe.js → workflow-status-field-D_4-8JIF.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-KEqXjmsY.js → workflow-workbench-CN5-OYpd.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-BKgO5U-X.js.map → account-page-BPtyska2.js.map} +1 -1
- package/dist/shell-source-maps/assets/app-DKn-6fgf.js.map +1 -0
- package/dist/shell-source-maps/assets/{assistant-shell-DuqVM626.js.map → assistant-shell-BW59by36.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-DddxG38M.js.map → board-display-uC4sMccF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-zLyE7rhF.js.map → calendar-display-BZhTapxV.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-uudxTLcY.js.map → call-rings-DwyQO_zl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-7JJIY2v0.js.map → calls-DeHPxZSF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-CoX9nLsD.js.map → circle-alert-mtPRl_1e.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-DnCccgH0.js.map → composed-page-CqjAO9Zv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-84NNbJ4X.js.map → composer-section-D16PrwJe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-DXEPuBjl.js.map → connect-route-BHjM-n0c.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-BlooSgn7.js.map → copy-field-C7SgGBWe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-BNcDypty.js.map → create-route-CV6sScUu.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-CyvWLsF0.js.map → custom-step-container-field-DbXZzPJp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-B8K84K5b.js.map → embedded-list-CG1SyUtd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-IWSkZoEf.js.map → export-dialog-CMPyzZa3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-D6ueoFs9.js.map → graph-view-CfO5HJXO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-BnDzQhIS.js.map → group-donut-UrNllcKD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-IwcmjkTm.js.map → guest-call-page-CgISSPNH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-DjlpP883.js.map → html-viewer-GgauWEUE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-DrDyc76O.js.map → import-dialog-BppJUUoF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-DYBhyBp7.js.map → import-table-dialog-cfWZMJfg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-BmkBa0fB.js.map → invitations-page-Cx960zfb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-DGOCHAPH.js.map → layout-grid-IdJUsNk6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-DxdIZ1pf.js.map → legend-item-FRGENXpR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-BhWOEaP6.js.map → list-page-Di8ApAmU.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-k6sh-ts2.js.map → maplibre-B0oPa_5e.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-vMCleJqq.js.map → markdown-content-CA74ofB3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-NrAKIuOb.js.map → members-page-UO-o4WSG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-Cjox3dPW.js.map → messages-CjRWJI05.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-HRjNwewQ.js.map → organization-page-DaGSJbur.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-D-Is15Iq.js.map → organizations-page-C5oK_zsd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-MATld1YG.js.map → pending-invitation-row-BEvgmW-N.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-xv3RhzW9.js.map → period-chart-CW2NUL07.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-DPsUV5XA.js.map → person-row-5VQjyq5t.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-CK0NgO4L.js.map → public-form-page-CqU7Cg33.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-CDGK7ZyR.js.map → record-lines-CJgNIVFS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-C8QpQBwW.js.map → record-map-DHkY7hYE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-jhy0UcRX.js.map → record-opens-B0MlYjrH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-BQtAOfUN.js.map → record-page-whDNzf71.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-Cnz2q7jF.js.map → record-preview-BUnzkT7g.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-Cpt0N4k2.js.map → records-map-DjcDdJBM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-CQddajXn.js.map → render-node-DGmdm-wr.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-2tg9wf42.js.map → reorder-button-q4oqy3UR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-C8KR_auS.js.map → run-trace-view-DjtMSojN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-Dfnq3Rqy.js.map → runner-install-field-Ddxc9XB0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-BkP2MEsM.js.map → runtime-update-CKEA5P-k.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-Bsx98FTk.js.map → sheet-source-CAIVzfnw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-hgTJtin9.js.map → sign-in-policy-page-CdTIudi-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-Cmx56hgU.js.map → start-block-queries-DjQjQ2Ef.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-BJyr7gmH.js.map → step-catalog-Dit0IJvs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-D-jkWWLs.js.map → step-panel-9kx6xfm1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-FKWlqzyN.js.map → timeline-display-CoQETrmW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-BNguTSbA.js.map → trash-DJwJPifF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-CaKid6Bl.js.map → update-set-DPSGWrcI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-UCTCC4Mu.js.map → use-calendar-move-CgXeokRh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-BeUN0NEn.js.map → use-display-rows-DFSNvNWx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-33KMMcrt.js.map → use-paged-search-B52iaj1D.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-Bx9X8OOk.js.map → use-run-trace-KAufJAqD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-BiyvMPJr.js.map → use-workflow-page-171SXJ7G.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-Dv4j1fdw.js.map → use-workflow-types-ZGEaDrEJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-CXQvv_wT.js.map → workflow-canvas-CCu4twlF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-f3yIRcdj.js.map → workflow-field-BFNHwCjK.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-Dkn-LYZl.js.map → workflow-graph-editor-DTSyabCd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-Btst6LE9.js.map → workflow-run-field-D2fpm1Vk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-DwvvkBQe.js.map → workflow-status-field-D_4-8JIF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-KEqXjmsY.js.map → workflow-workbench-CN5-OYpd.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/app-D5KGkwJq.js +0 -34
- package/dist/shell-source-maps/assets/app-D5KGkwJq.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{t}from"./react-CuiNlnus.js";import{vt as n}from"./embedded-list-
|
|
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{vt as n}from"./embedded-list-CG1SyUtd.js";import{d as r,f as i,l as a,t as o,u as s}from"./lib-recharts-B1lKFZ5P.js";import{t as c}from"./legend-item-FRGENXpR.js";var l=e(t(),1),u=(e,t)=>t>0?`${Math.round(e/t*100)}%`:``,d=({active:e,payload:t,measure:r})=>{let i=t?.[0]?.payload;return!e||!i?null:(0,l.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,l.jsx)(`div`,{className:`text-muted-foreground`,children:i.label}),(0,l.jsx)(`div`,{className:`font-semibold tabular-nums`,children:n(i.value,r)})]})},f=({resource:e,view:t,slices:f,measure:p})=>{let m=f.filter(e=>e.value!==null&&e.value>0),h=m.reduce((e,t)=>e+t.value,0);return(0,l.jsxs)(`div`,{className:`flex flex-col items-center gap-4 sm:flex-row sm:items-center`,children:[(0,l.jsx)(`div`,{className:`size-36 shrink-0`,children:(0,l.jsx)(i,{width:`100%`,height:`100%`,children:(0,l.jsxs)(o,{children:[(0,l.jsx)(a,{data:m,dataKey:`value`,nameKey:`label`,innerRadius:`62%`,outerRadius:`100%`,paddingAngle:+(m.length>1),stroke:`var(--background)`,strokeWidth:2,isAnimationActive:!1,children:m.map(e=>(0,l.jsx)(s,{fill:e.color},e.key))}),(0,l.jsx)(r,{content:(0,l.jsx)(d,{measure:p}),isAnimationActive:!1})]})})}),(0,l.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-0.5`,children:f.map(r=>(0,l.jsxs)(c,{resource:e,view:t,filter:r.filter,color:r.color,label:r.label,children:[(0,l.jsx)(`span`,{className:`font-medium tabular-nums`,children:n(r.value,p)}),(0,l.jsx)(`span`,{className:`w-9 text-right text-xs text-muted-foreground tabular-nums`,children:u(r.value??0,h)})]},r.key))})]})};export{f as GroupDonut};
|
|
2
|
+
//# debugId=14acd965-70a0-4640-b511-b2601a0539e8
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/calls-
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ht as r,Kc as i,Na as a,Qs as o,Ut as s,Wt as c,xo as l}from"./app-
|
|
3
|
-
//# debugId=
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/calls-DeHPxZSF.js","assets/app-DKn-6fgf.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/vendor-t7Q7QbPu.js","assets/app-Dq5eubgK.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ht as r,Kc as i,Na as a,Qs as o,Ut as s,Wt as c,xo as l}from"./app-DKn-6fgf.js";import{C as u}from"./vendor-t7Q7QbPu.js";var d=e(t(),1),f=e(n(),1),p=({link:e,systemPath:t,base:n})=>{let[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(),[_,v]=(0,d.useState)(!1),y=(0,d.useCallback)(async n=>{let{guestLobby:r}=await u(async()=>{let{guestLobby:e}=await import(`./calls-DeHPxZSF.js`);return{guestLobby:e}},__vite__mapDeps([0,1,2,3,4,5]));return s(r({systemPath:t}),e,h,n)},[t,e,h]),b=e=>{e.preventDefault(),p.trim()&&g(p.trim())},x=a(n,e);return _?(0,f.jsx)(`p`,{role:`status`,className:`flex min-h-[100dvh] items-center justify-center bg-background p-4 text-sm text-foreground`,children:c(`youLeft`)}):h===void 0?(0,f.jsx)(`main`,{className:`flex min-h-[100dvh] items-center justify-center bg-background p-4`,children:(0,f.jsxs)(`form`,{onSubmit:b,className:`flex w-full max-w-sm flex-col gap-3`,children:[(0,f.jsx)(`p`,{className:`text-sm text-foreground`,children:c(`guestIntro`)}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm text-foreground`,children:[c(`yourName`),(0,f.jsx)(l,{autoFocus:!0,autoComplete:`name`,maxLength:60,value:p,onChange:e=>m(e.target.value)})]}),(0,f.jsx)(o,{type:`submit`,variant:`primary`,disabled:!p.trim(),children:c(`continue`)})]})}):(0,f.jsx)(`main`,{className:`h-[100dvh]`,children:(0,f.jsx)(r,{url:i(t,`socket`),admission:y,name:h,nameOf:()=>c(`someone`),leave:{href:x,onFollow:()=>v(!0)}})})};export{p as GuestCallPage};
|
|
3
|
+
//# debugId=a021248f-3479-49e5-88f6-1d2229896dd5
|
|
@@ -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,Sn as i,_r as a,br as o,hr as s,vr 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{Lr as r,Sn as i,_r as a,br as o,hr as s,vr as c}from"./app-DKn-6fgf.js";var l=e(t(),1),u=e=>window.open(e,`_blank`,`noopener,noreferrer`),d=()=>{let e=c(),{go:t,href:n}=r(),i=(0,l.useCallback)(t=>({kind:`record`,resource:e,key:t.key,file:t.field}),[e]);return{address:(0,l.useCallback)(e=>e.kind===`external`?e.url:new URL(n(i(e.file)),window.location.href).href,[i,n]),follow:(0,l.useCallback)((e,{newTab:r})=>{if(e.kind===`external`){u(e.url);return}let a=i(e.file);if(r){u(n(a));return}t(a)},[i,t,n])}},f=e(n(),1),p=({file:e,siblings:t})=>{let n=a(e),{address:r,follow:c}=d(),l=s(n.data,t,r);if(n.error)throw n.error;return l?(0,f.jsx)(o,{html:l.html,title:e.name,links:l.links,onLink:c}):(0,f.jsx)(i,{name:e.name})};export{p as HtmlViewer};
|
|
2
|
+
//# debugId=0681ab96-1141-4f5a-b934-52935397c04f
|
|
@@ -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,A as i,Ki as a,Qs as o,Wc as s,as as c,ic as l,mo as u,mr as d}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,A as i,Ki as a,Qs as o,Wc as s,as as c,ic as l,mo as u,mr as d}from"./app-DKn-6fgf.js";import{h as f}from"./vendor-t7Q7QbPu.js";import{_ as p,a as m,c as h,d as g,f as _,g as v,h as y,i as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A}from"./sheet-source-CAIVzfnw.js";import{d as j,o as M,s as N}from"./list-page-Di8ApAmU.js";var P=e(n(),1),F=()=>[{value:`create`,label:j(`create`)},{value:`update`,label:j(`update`)},{value:`upsert`,label:j(`upsert`)}],I={create:`createHint`,update:`updateHint`,upsert:`upsertHint`},L=``,R=({flow:e,model:t,resources:n,views:r,canUpdate:i})=>{let a=r[t.name],o=e.head?.headers??[],s=e.head?.sample??[],c=A(e.mode,e.fields,e.columns),d=[{value:L,label:j(`doNotImport`)},...e.fields.map(e=>({value:e.name,label:`${T(a,e.name)}${p(e)?` *`:``}`}))],f=o.map((e,t)=>({value:String(t),label:N(o,t)})),m=y(t);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[i&&(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(`span`,{className:`font-medium`,children:j(`rows`)}),(0,P.jsx)(`div`,{children:(0,P.jsx)(u,{label:j(`whatEachRowDoes`),size:`md`,value:e.mode,options:F(),onChange:e.setMode})}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(I[e.mode])})]}),e.mode!==`create`&&(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(w,{label:j(`findBy`),value:e.match?.field??L,options:[{value:L,label:j(`chooseField`)},...m.map(e=>({value:e.name,label:T(a,e.name)}))],onChange:t=>e.setMatch(t?{field:t,column:e.match?.column??0}:void 0),help:j(`findByHint`)}),(0,P.jsx)(w,{label:j(`foundInColumn`),value:e.match?String(e.match.column):L,options:[{value:L,label:j(`chooseColumn`)},...f],onChange:t=>e.setMatch(t&&e.match?{...e.match,column:Number(t)}:e.match)})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(w,{label:j(`numbers`),value:e.options.decimal,options:[{value:`.`,label:`1,234.56`},{value:`,`,label:`1.234,56`}],onChange:t=>e.setOptions({...e.options,decimal:t})}),(0,P.jsx)(w,{label:j(`dates`),value:e.options.dateOrder,options:[{value:`dmy`,label:j(`dayFirst`)},{value:`mdy`,label:j(`monthFirst`)}],onChange:t=>e.setOptions({...e.options,dateOrder:t}),help:j(`datesHint`)})]}),e.mode!==`update`&&(0,P.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:j(`requiredMarked`)}),(0,P.jsx)(`section`,{"aria-label":j(`columns`),className:`flex flex-col divide-y divide-border border-y`,children:o.map((i,c)=>{let l=e.columns.find(e=>e.column===c),u=l?t.fields[l.field]:void 0,f=u?v(u,n):void 0,p=s.map(e=>M(e.cells[c]??null)).filter(e=>e!==``).slice(0,3),m=N(o,c);return(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`truncate font-medium`,children:m}),(0,P.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:p.length>0?p.join(`, `):j(`emptyInFirstRows`)})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,P.jsx)(w,{label:j(`field`),name:j(`fieldFor`,{name:m}),value:l?.field??L,options:d,onChange:t=>e.mapColumn(c,t||void 0)}),f&&(0,P.jsx)(w,{label:j(`foundBy`),name:j(`pluralFoundBy`,{plural:r[f.name]?.names?.plural??T(a,u.name)}),value:l.matchBy??f.primaryKey[0],options:y(f).map(e=>({value:e.name,label:T(r[f.name],e.name)})),onChange:t=>e.matchColumnBy(c,t)})]})]},c)})}),c.length>0&&(0,P.jsxs)(`p`,{role:`alert`,className:`flex gap-2 rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-warning-text`,children:[(0,P.jsx)(l,{className:`mt-0.5 size-4 shrink-0`}),(0,P.jsx)(`span`,{children:j(`noColumnFills`,{fields:c.map(e=>T(a,e.name)).join(`, `)})})]})]})},z=e(t(),1),B=e=>{let t=i(e),n=new Intl.DateTimeFormat(e).formatToParts(new Date(2026,3,3)).map(e=>e.type);return{decimal:t,dateOrder:n.indexOf(`month`)<n.indexOf(`day`)?`mdy`:`dmy`}},V=e=>/\.json$/i.test(e.name)||e.type.split(`;`)[0].trim().toLowerCase()===`application/json`,H={created:0,updated:0,skipped:0,failed:0,notWritten:[]},U=({model:e,resources:t,views:n,sourceFor:r=O})=>{let i=c(),a=f(),o=n[e.name],[s,l]=(0,z.useState)({kind:`file`,reading:!1}),[u,d]=(0,z.useState)(),[p,m]=(0,z.useState)(),h=p?V(p.file):!1,v=(0,z.useMemo)(()=>S(e,t,{json:h}),[e,t,h]),[b,w]=(0,z.useState)(),[T,E]=(0,z.useState)(),[D,A]=(0,z.useState)(`create`),[j,M]=(0,z.useState)([]),[N,P]=(0,z.useState)(),[F,I]=(0,z.useState)(()=>B()),L=(0,z.useRef)(!1),R=(0,z.useRef)(void 0),U=e=>t=>{d(t),l(e)},W=n=>{d(void 0),l({kind:`file`,reading:!0});let i=r(n);i.sheets().then(r=>{if(m({file:n,source:i,sheets:r}),w(r[0]),r.length<=1)return G(i,r[0],S(e,t,{json:V(n)}));l({kind:`file`,reading:!1})}).catch(U({kind:`file`,reading:!1}))},G=async(t,n,r)=>{l({kind:`file`,reading:!0});let i=await k(t,n);E(i),M(_(i.headers,r,o));let a=y(e)[0],s=a?_(i.headers,[a],o)[0]:void 0;P(a&&s?{field:a.name,column:s.column}:void 0),l({kind:`map`})},K=()=>{p&&(d(void 0),G(p.source,b,v).catch(U({kind:`file`,reading:!1})))},q=(e,t)=>M(n=>{let r=n.filter(n=>n.column!==e&&n.field!==t);return t?[...r,{column:e,field:t}].sort((e,t)=>e.column-t.column):r}),J=(e,t)=>M(n=>n.map(n=>n.column===e?{...n,matchBy:t}:n)),Y=()=>({mode:D,columns:j,match:D===`create`?void 0:N,options:F}),X=()=>({model:e,resources:t,views:n,lookups:C(i)});return{step:s,error:u,file:p?.file,sheets:p?.sheets??[],sheet:b,setSheet:w,head:T,fields:v,mode:D,setMode:A,columns:j,mapColumn:q,matchColumnBy:J,match:N,setMatch:P,options:F,setOptions:I,choose:W,openSheet:K,check:()=>{if(!p)return;d(void 0);let e=new AbortController;R.current=e,l({kind:`checking`,rows:0}),x(p.source,b,Y(),X(),e=>l({kind:`checking`,rows:e}),e.signal).then(t=>{e.signal.aborted||l({kind:`checked`,check:t})}).catch(t=>{e.signal.aborted||U({kind:`map`})(t)})},back:()=>{R.current?.abort(),d(void 0),l({kind:`map`})},start:t=>{if(!p)return;d(void 0),L.current=!1,l({kind:`importing`,progress:H,total:t,cancelling:!1});let n=H;g(p.source,b,Y(),X(),{client:i(e.name),onProgress:e=>{n=e,l({kind:`importing`,progress:e,total:t,cancelling:L.current})},cancelled:()=>L.current}).then(e=>l({kind:`done`,result:e})).catch(e=>l({kind:`done`,result:{...n,cancelled:!1},stopped:e})).finally(()=>{for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`,`aggregate`,`count`])a.invalidateQueries({queryKey:[t,e.name]})})},cancel:()=>{L.current=!0,l(e=>e.kind===`importing`?{...e,cancelling:!0}:e)},stop:()=>R.current?.abort()}},W=e=>e.step.kind===`file`?j(`couldNotReadFile`):j(`couldNotCheck`),G=e=>e.columns.length===0?!1:e.mode===`create`?A(`create`,e.fields,e.columns).length===0:e.match!==void 0,K=({model:e,resources:t,views:n,canUpdate:i,onClose:c,sourceFor:l})=>{let u=U({model:e,resources:t,views:n,sourceFor:l}),f=n[e.name]?.names?.plural??r(e.name),{step:p}=u,g=u.head?.headers??[],_=()=>{p.kind!==`importing`&&(u.stop(),c())},v=(0,P.jsx)(o,{onClick:_,children:j(`cancel`)});return(0,P.jsx)(a,{open:!0,wide:!0,title:j(`importPlural`,{plural:f}),description:u.file&&p.kind!==`file`?u.file.name:void 0,onClose:_,actions:(()=>{switch(p.kind){case`file`:return(0,P.jsxs)(P.Fragment,{children:[v,u.sheets.length>1&&(0,P.jsx)(o,{variant:`primary`,loading:p.reading,onClick:u.openSheet,children:j(`next`)})]});case`map`:return(0,P.jsxs)(P.Fragment,{children:[v,(0,P.jsx)(o,{variant:`primary`,disabled:!G(u),onClick:u.check,children:j(`checkRows`)})]});case`checking`:return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(o,{onClick:u.back,children:j(`back`)}),(0,P.jsx)(o,{variant:`primary`,loading:!0,children:j(`checking`)})]});case`checked`:{let e=p.check.creates+p.check.updates;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(o,{onClick:u.back,children:j(`back`)}),(0,P.jsx)(o,{variant:`primary`,disabled:e===0,onClick:()=>u.start(e),children:j(`importRows`,{count:e.toLocaleString(s()),rows:e})})]})}case`importing`:return(0,P.jsx)(o,{variant:`danger`,disabled:p.cancelling,onClick:u.cancel,children:j(`cancelImport`)});case`done`:return(0,P.jsx)(o,{variant:`primary`,onClick:c,children:j(`done`)})}})(),children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u.error!==void 0&&(0,P.jsx)(d,{title:W(u),error:u.error}),(()=>{switch(p.kind){case`file`:return(0,P.jsx)(m,{file:u.file,sheets:u.sheets,sheet:u.sheet,reading:p.reading,onChoose:u.choose,onSheet:u.setSheet});case`map`:return(0,P.jsx)(R,{flow:u,model:e,resources:t,views:n,canUpdate:i});case`checking`:return(0,P.jsx)(h,{rows:p.rows});case`checked`:return(0,P.jsx)(D,{check:p.check,model:e,resources:t,views:n,columns:u.columns,headers:g,fileName:u.file?.name});case`importing`:return(0,P.jsx)(E,{progress:p.progress,total:p.total,cancelling:p.cancelling});case`done`:return(0,P.jsx)(b,{result:p.result,stopped:p.stopped,headers:g,fileName:u.file?.name})}})()]})})};export{K as ImportDialog};
|
|
2
|
+
//# debugId=69a49514-a053-448a-ab0c-17cf87e4de26
|
package/dist/shell/assets/{import-table-dialog-DYBhyBp7.js → import-table-dialog-cfWZMJfg.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{$s as r,Bc as i,Ir as a,Ki as o,Lr as s,Qs as c,R as l,as as u,ic as d,mr as f,xo as p}from"./app-D5KGkwJq.js";import{h as m}from"./vendor-t7Q7QbPu.js";import{a as h,c as g,d as _,i as v,n as y,o as b,p as x,r as S,t as ee}from"./sheet-source-Bsx98FTk.js";import{a as C,c as w,d as T,h as E,i as D,n as O,o as k,r as te,s as A,t as j}from"./list-page-BhWOEaP6.js";var M=e=>e===null||typeof e==`string`&&e.trim()===``,N=/^-?(0|[1-9]\d*)$/,P=/^-?(0|[1-9]\d*)\.\d+$/,F=/^(\d{4})-(\d{2})-(\d{2})$/,I=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?(Z|[+-]\d{2}:\d{2})?$/,L=e=>{let t=F.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},R=e=>{if(N.test(e))return`whole`;if(P.test(e))return`decimal`;if(/^(true|false)$/i.test(e))return`boolean`;if(L(e))return`date`;let t=I.exec(e);return!t?.[1]||!L(t[1])||Number(t[2])>23||Number(t[3])>59||Number(t[4]??0)>59?`text`:t[5]?`zoned`:`local`},z=e=>typeof e==`boolean`?`boolean`:typeof e==`number`?Number.isInteger(e)?`whole`:`decimal`:typeof e==`string`?R(e.trim()):`json`in e?`json`:e.date.includes(`T`)?`local`:`date`,B=e=>typeof e==`number`?e.toLocaleString(`en-US`,{useGrouping:!1,maximumFractionDigits:100}):e.trim(),V=1e3,H=2147483647n,U={boolean:`boolean`,date:`date`,local:`timestamp`,zoned:`timestamp`,json:`json`},W=()=>{let e=new Set,t=1,n=0,r=!1,i=0,a=a=>{if(a===null||M(a))return;typeof a==`string`&&(i=Math.max(i,a.length));let o=z(a);if(e.add(o),o!==`whole`&&o!==`decimal`)return;let[s=``,c=``]=B(a).replace(`-`,``).split(`.`);if(t=Math.max(t,s.length),n=Math.max(n,c.length),o===`whole`&&!r){let e=BigInt(B(a));r=(e<0n?-e-1n:e)>H}},o=()=>{let e=Math.min(V,Math.max(t,15)+n);return{type:`decimal`,precision:e,scale:Math.min(n,e)}};return{add:a,type:()=>{if(e.has(`json`))return{type:`json`};let t=e.size===1?[...e][0]:void 0;return t===`whole`?r?o():{type:`integer`}:e.size===2&&e.has(`whole`)&&e.has(`decimal`)||t===`decimal`?o():t&&t!==`text`?{type:U[t]}:{type:i>500?`long_text`:`text`}},decimal:o}},G=e=>{switch(e){case`integer`:return[`integer`,`decimal`,`text`,`long_text`];case`decimal`:case`boolean`:case`date`:case`timestamp`:return[e,`text`,`long_text`];case`text`:return[`text`,`long_text`];case`long_text`:case`json`:return[e]}},K=(e,t)=>{let n=e[t],r=e[O];return{table:e=>({label:x(n,e),help:n?.fields[e]?.help}),field:e=>({label:x(r,e),help:r?.fields[e]?.help}),type:e=>r?.fields.type?.valueLabels?.[e]??e}},q=(e,t,n)=>e===`form`?T(`nameForm`,{max:n}):T(e===`reserved_word`?`nameReservedWord`:`nameReservedField`,{name:t}),J=e=>{if(e.trim()===``)return T(`needed`);if(e.trim().length>200)return T(`labelTooLong`,{max:200})},ne=(e,t,n)=>{let r=E(e.name,`table`,n),i={name:r?q(r,e.name,n):t.has(e.name)?T(`nameTaken`,{name:e.name}):void 0,pluralLabel:J(e.pluralLabel),singularLabel:J(e.singularLabel),fields:{}},a=D(e);a.length===0&&(i.noFields=T(`noFields`));let o=new Set;for(let e of a){let t=E(e.name,`field`),n=t?q(t,e.name,63):o.has(e.name)?T(`nameTwice`,{name:e.name}):void 0;o.add(e.name);let r=J(e.label);(n||r)&&(i.fields[e.column]={...n&&{name:n},...r&&{label:r}})}return i},re=e=>!!(e.name||e.pluralLabel||e.singularLabel||e.noFields||Object.keys(e.fields).length>0),Y=e(n(),1),X=``,ie=({field:e,column:t,examples:n,problems:r,texts:i,onChange:a})=>{let o=i.field(`type`),s=i.field(`label`),c=i.field(`name`),u=G(e.inferred.type).map(e=>({value:e,label:i.type(e)})),d=e.include&&e.type===`decimal`;return(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`truncate font-medium`,children:t}),(0,Y.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.length>0?n.join(`, `):T(`emptyInFirstRows`)})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(b,{label:o.label,name:T(`typeFor`,{name:t}),value:e.include?e.type:X,options:[...u,{value:X,label:T(`doNotImport`)}],onChange:e=>a(e===X?{include:!1}:{include:!0,type:e}),help:d?T(`decimalSize`,{precision:e.decimal.precision,scale:e.decimal.scale}):void 0}),e.include&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{label:s.label,error:r?.label,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,"aria-label":T(`labelFor`,{name:t}),value:e.label,onChange:e=>a({label:e.target.value})})}),(0,Y.jsx)(l,{label:c.label,error:r?.name,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,"aria-label":T(`nameFor`,{name:t}),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>a({name:e.target.value})})})]})]})]})},Z=``,ae=({proposal:e,problems:t,texts:n,onChange:r})=>{let i=D(e).filter(e=>e.type===`text`),a=n.table(`plural_label`),o=n.table(`singular_label`),s=n.table(`name`),c=n.table(`title_field`);return(0,Y.jsxs)(`section`,{"aria-label":T(`newTable`),className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Y.jsx)(l,{label:a.label,help:a.help,error:t.pluralLabel,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,value:e.pluralLabel,onChange:e=>r({pluralLabel:e.target.value})})}),(0,Y.jsx)(l,{label:o.label,help:o.help,error:t.singularLabel,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,value:e.singularLabel,onChange:e=>r({singularLabel:e.target.value})})}),(0,Y.jsx)(l,{label:s.label,help:s.help,error:t.name,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>r({name:e.target.value})})}),(0,Y.jsx)(b,{label:c.label,value:e.titleField??Z,options:[{value:Z,label:T(`noTitle`)},...i.map(e=>({value:e.name,label:e.label||e.name}))],onChange:e=>r({titleField:e||void 0}),help:c.help})]})},oe=({flow:e,problems:t,texts:n})=>{let{proposal:r,read:i}=e;return!r||!i?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(ae,{proposal:r,problems:t,texts:n,onChange:e.changeTable}),(0,Y.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:T(`typesFromCells`,{rows:i.rows})}),(0,Y.jsx)(`section`,{"aria-label":T(`columns`),className:`flex flex-col divide-y divide-border border-y`,children:r.fields.map(r=>(0,Y.jsx)(ie,{field:r,column:A(i.headers,r.column),examples:i.sample.map(e=>k(e.cells[r.column]??null)).filter(e=>e!==``).slice(0,3),problems:t.fields[r.column],texts:n,onChange:t=>e.change(r.column,t)},r.column))}),t.noFields&&(0,Y.jsxs)(`p`,{role:`alert`,className:`flex gap-2 rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-warning-text`,children:[(0,Y.jsx)(d,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsx)(`span`,{children:t.noFields})]})]})},Q=e(t(),1),se=5,ce=async(e,t,n,r)=>{let i,a=[],o=[],s=0;for await(let c of e.rows(t)){r?.throwIfAborted();for(let e of c){if(!i){i=e.cells.map(k),a=i.map(()=>W());continue}e.cells.every(w)||(s++,o.length<se&&o.push(e),a.forEach((t,n)=>t.add(e.cells[n]??null)))}n(s)}return{headers:i??[],types:a.map(e=>e.type()),decimals:a.map(e=>e.decimal()),sample:o,rows:s}},$={created:0,updated:0,skipped:0,failed:0,notWritten:[]},le={decimal:`.`,dateOrder:`dmy`,booleanText:!0},ue=({tables:e,resources:t,sourceFor:n=ee})=>{let r=u(),a=m(),{go:o}=s(),c=e.tenant!==void 0,l=c?42:63,d=(0,Q.useMemo)(()=>new Set(c?[]:Object.keys(t)),[c,t]),[f,p]=(0,Q.useState)({kind:`file`,reading:!1}),[h,g]=(0,Q.useState)(),[v,b]=(0,Q.useState)(),[x,S]=(0,Q.useState)(),[w,T]=(0,Q.useState)(),[E,O]=(0,Q.useState)(),[k,A]=(0,Q.useState)(),M=(0,Q.useRef)(!1),N=(0,Q.useRef)(void 0),P=e=>t=>{g(t),p(e)},F=(e,t,n)=>{let r=new AbortController;N.current=r,p({kind:`reading`,rows:0}),ce(t,n,e=>p({kind:`reading`,rows:e}),r.signal).then(t=>{r.signal.aborted||(T(t),O(C(e.name,t,d,l)),p({kind:`fields`}))}).catch(e=>{r.signal.aborted||P({kind:`file`,reading:!1})(e)})},I=e=>{g(void 0),p({kind:`file`,reading:!0});let t=n(e);t.sheets().then(n=>{if(b({file:e,source:t,sheets:n}),S(n[0]),n.length<=1)return F(e,t,n[0]);p({kind:`file`,reading:!1})}).catch(P({kind:`file`,reading:!1}))},L=()=>{v&&(g(void 0),F(v.file,v.source,x))},R=(e,t)=>O(n=>n&&te(n,e,t)),z=e=>O(t=>t&&{...t,...e}),B=async e=>{await a.refetchQueries({queryKey:i.meta});let t=a.getQueryData(i.meta),n=t?.resources[e];if(!t||!n)throw Error(`The server does not serve the new table ${e} yet`);return{model:n,resources:t.resources,views:t.views}},V=async(e,t)=>{if(!v||!w)return;let n={...await B(e),lookups:y(r)},i={mode:`create`,columns:D(t).map(e=>({column:e.column,field:e.name})),options:le};M.current=!1;let a=$;p({kind:`importing`,progress:$,total:w.rows,cancelling:!1});let s=await _(v.source,x,i,n,{client:r(e),onProgress:e=>{a=e,p({kind:`importing`,progress:e,total:w.rows,cancelling:M.current})},cancelled:()=>M.current}).catch(e=>({...a,cancelled:!1,stopped:e})),c=`stopped`in s?s.stopped:void 0;if(c===void 0&&!s.cancelled&&s.notWritten.length===0)return o({kind:`list`,resource:e});p({kind:`done`,result:s,stopped:c})};return{step:f,error:h,file:v?.file,sheets:v?.sheets??[],sheet:x,setSheet:S,read:w,proposal:E,table:k,taken:d,maxTableBytes:l,choose:I,openSheet:L,change:R,changeTable:z,create:()=>{E&&(g(void 0),p({kind:`creating`}),r(e.name).batchWrite(j(e.name,E)).then(({results:e})=>{let[t]=e,n=t?.op===`create`?String(t.record.table_name):E.name;return A(n),V(n,E).catch(e=>p({kind:`done`,result:{...$,cancelled:!1},stopped:e}))},P({kind:`fields`})))},cancel:()=>{M.current=!0,p(e=>e.kind===`importing`?{...e,cancelling:!0}:e)},back:()=>{N.current?.abort(),g(void 0),p({kind:`file`,reading:!1})},stop:()=>N.current?.abort()}},de=e=>e.step.kind===`fields`?T(`couldNotMakeTable`):T(`couldNotReadFile`),fe=({tables:e,resources:t,views:n,onClose:i,sourceFor:s})=>{let l=ue({tables:e,resources:t,sourceFor:s}),u=K(n,e.name),{step:d,proposal:p}=l,m=p?ne(p,l.taken,l.maxTableBytes):void 0,_=l.read?.headers??[],y=d.kind===`creating`||d.kind===`importing`,b=()=>{y||(l.stop(),i())},x=(0,Y.jsx)(c,{onClick:b,children:T(`cancel`)});return(0,Y.jsx)(o,{open:!0,wide:!0,title:T(`tableFromFile`),description:l.file&&d.kind!==`file`?l.file.name:void 0,onClose:b,actions:(()=>{switch(d.kind){case`file`:return(0,Y.jsxs)(Y.Fragment,{children:[x,l.sheets.length>1&&(0,Y.jsx)(c,{variant:`primary`,loading:d.reading,onClick:l.openSheet,children:T(`next`)})]});case`reading`:return(0,Y.jsx)(c,{onClick:l.back,children:T(`back`)});case`fields`:case`creating`:{let e=l.read?.rows??0;return(0,Y.jsxs)(Y.Fragment,{children:[x,(0,Y.jsx)(c,{variant:`primary`,loading:d.kind===`creating`,disabled:!m||re(m),onClick:l.create,children:T(`makeTable`,{rows:e})})]})}case`importing`:return(0,Y.jsx)(c,{variant:`danger`,disabled:d.cancelling,onClick:l.cancel,children:T(`cancelImport`)});case`done`:return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c,{onClick:i,children:T(`done`)}),l.table&&(0,Y.jsx)(a,{to:{kind:`list`,resource:l.table},className:r({variant:`primary`}),children:T(`openTable`)})]})}})(),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l.error!==void 0&&(0,Y.jsx)(f,{title:de(l),error:l.error}),(()=>{switch(d.kind){case`file`:return(0,Y.jsx)(h,{file:l.file,sheets:l.sheets,sheet:l.sheet,reading:d.reading,onChoose:l.choose,onSheet:l.setSheet});case`reading`:return(0,Y.jsx)(g,{rows:d.rows});case`fields`:case`creating`:return m&&(0,Y.jsx)(oe,{flow:l,problems:m,texts:u});case`importing`:return(0,Y.jsx)(S,{progress:d.progress,total:d.total,cancelling:d.cancelling});case`done`:return(0,Y.jsx)(v,{result:d.result,stopped:d.stopped,headers:_,fileName:l.file?.name})}})()]})})};export{fe as ImportTableDialog};
|
|
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{$s as r,Bc as i,Ir as a,Ki as o,Lr as s,Qs as c,R as l,as as u,ic as d,mr as f,xo as p}from"./app-DKn-6fgf.js";import{h as m}from"./vendor-t7Q7QbPu.js";import{a as h,c as g,d as _,i as v,n as y,o as b,p as x,r as S,t as ee}from"./sheet-source-CAIVzfnw.js";import{a as C,c as w,d as T,h as E,i as D,n as O,o as k,r as te,s as A,t as j}from"./list-page-Di8ApAmU.js";var M=e=>e===null||typeof e==`string`&&e.trim()===``,N=/^-?(0|[1-9]\d*)$/,P=/^-?(0|[1-9]\d*)\.\d+$/,F=/^(\d{4})-(\d{2})-(\d{2})$/,I=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?(Z|[+-]\d{2}:\d{2})?$/,L=e=>{let t=F.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},R=e=>{if(N.test(e))return`whole`;if(P.test(e))return`decimal`;if(/^(true|false)$/i.test(e))return`boolean`;if(L(e))return`date`;let t=I.exec(e);return!t?.[1]||!L(t[1])||Number(t[2])>23||Number(t[3])>59||Number(t[4]??0)>59?`text`:t[5]?`zoned`:`local`},z=e=>typeof e==`boolean`?`boolean`:typeof e==`number`?Number.isInteger(e)?`whole`:`decimal`:typeof e==`string`?R(e.trim()):`json`in e?`json`:e.date.includes(`T`)?`local`:`date`,B=e=>typeof e==`number`?e.toLocaleString(`en-US`,{useGrouping:!1,maximumFractionDigits:100}):e.trim(),V=1e3,H=2147483647n,U={boolean:`boolean`,date:`date`,local:`timestamp`,zoned:`timestamp`,json:`json`},W=()=>{let e=new Set,t=1,n=0,r=!1,i=0,a=a=>{if(a===null||M(a))return;typeof a==`string`&&(i=Math.max(i,a.length));let o=z(a);if(e.add(o),o!==`whole`&&o!==`decimal`)return;let[s=``,c=``]=B(a).replace(`-`,``).split(`.`);if(t=Math.max(t,s.length),n=Math.max(n,c.length),o===`whole`&&!r){let e=BigInt(B(a));r=(e<0n?-e-1n:e)>H}},o=()=>{let e=Math.min(V,Math.max(t,15)+n);return{type:`decimal`,precision:e,scale:Math.min(n,e)}};return{add:a,type:()=>{if(e.has(`json`))return{type:`json`};let t=e.size===1?[...e][0]:void 0;return t===`whole`?r?o():{type:`integer`}:e.size===2&&e.has(`whole`)&&e.has(`decimal`)||t===`decimal`?o():t&&t!==`text`?{type:U[t]}:{type:i>500?`long_text`:`text`}},decimal:o}},G=e=>{switch(e){case`integer`:return[`integer`,`decimal`,`text`,`long_text`];case`decimal`:case`boolean`:case`date`:case`timestamp`:return[e,`text`,`long_text`];case`text`:return[`text`,`long_text`];case`long_text`:case`json`:return[e]}},K=(e,t)=>{let n=e[t],r=e[O];return{table:e=>({label:x(n,e),help:n?.fields[e]?.help}),field:e=>({label:x(r,e),help:r?.fields[e]?.help}),type:e=>r?.fields.type?.valueLabels?.[e]??e}},q=(e,t,n)=>e===`form`?T(`nameForm`,{max:n}):T(e===`reserved_word`?`nameReservedWord`:`nameReservedField`,{name:t}),J=e=>{if(e.trim()===``)return T(`needed`);if(e.trim().length>200)return T(`labelTooLong`,{max:200})},ne=(e,t,n)=>{let r=E(e.name,`table`,n),i={name:r?q(r,e.name,n):t.has(e.name)?T(`nameTaken`,{name:e.name}):void 0,pluralLabel:J(e.pluralLabel),singularLabel:J(e.singularLabel),fields:{}},a=D(e);a.length===0&&(i.noFields=T(`noFields`));let o=new Set;for(let e of a){let t=E(e.name,`field`),n=t?q(t,e.name,63):o.has(e.name)?T(`nameTwice`,{name:e.name}):void 0;o.add(e.name);let r=J(e.label);(n||r)&&(i.fields[e.column]={...n&&{name:n},...r&&{label:r}})}return i},re=e=>!!(e.name||e.pluralLabel||e.singularLabel||e.noFields||Object.keys(e.fields).length>0),Y=e(n(),1),X=``,ie=({field:e,column:t,examples:n,problems:r,texts:i,onChange:a})=>{let o=i.field(`type`),s=i.field(`label`),c=i.field(`name`),u=G(e.inferred.type).map(e=>({value:e,label:i.type(e)})),d=e.include&&e.type===`decimal`;return(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`truncate font-medium`,children:t}),(0,Y.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.length>0?n.join(`, `):T(`emptyInFirstRows`)})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(b,{label:o.label,name:T(`typeFor`,{name:t}),value:e.include?e.type:X,options:[...u,{value:X,label:T(`doNotImport`)}],onChange:e=>a(e===X?{include:!1}:{include:!0,type:e}),help:d?T(`decimalSize`,{precision:e.decimal.precision,scale:e.decimal.scale}):void 0}),e.include&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{label:s.label,error:r?.label,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,"aria-label":T(`labelFor`,{name:t}),value:e.label,onChange:e=>a({label:e.target.value})})}),(0,Y.jsx)(l,{label:c.label,error:r?.name,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,"aria-label":T(`nameFor`,{name:t}),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>a({name:e.target.value})})})]})]})]})},Z=``,ae=({proposal:e,problems:t,texts:n,onChange:r})=>{let i=D(e).filter(e=>e.type===`text`),a=n.table(`plural_label`),o=n.table(`singular_label`),s=n.table(`name`),c=n.table(`title_field`);return(0,Y.jsxs)(`section`,{"aria-label":T(`newTable`),className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Y.jsx)(l,{label:a.label,help:a.help,error:t.pluralLabel,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,value:e.pluralLabel,onChange:e=>r({pluralLabel:e.target.value})})}),(0,Y.jsx)(l,{label:o.label,help:o.help,error:t.singularLabel,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,value:e.singularLabel,onChange:e=>r({singularLabel:e.target.value})})}),(0,Y.jsx)(l,{label:s.label,help:s.help,error:t.name,required:!0,children:(0,Y.jsx)(p,{wrapperClassName:`max-sm:min-h-11`,className:`font-mono`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,value:e.name,onChange:e=>r({name:e.target.value})})}),(0,Y.jsx)(b,{label:c.label,value:e.titleField??Z,options:[{value:Z,label:T(`noTitle`)},...i.map(e=>({value:e.name,label:e.label||e.name}))],onChange:e=>r({titleField:e||void 0}),help:c.help})]})},oe=({flow:e,problems:t,texts:n})=>{let{proposal:r,read:i}=e;return!r||!i?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(ae,{proposal:r,problems:t,texts:n,onChange:e.changeTable}),(0,Y.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:T(`typesFromCells`,{rows:i.rows})}),(0,Y.jsx)(`section`,{"aria-label":T(`columns`),className:`flex flex-col divide-y divide-border border-y`,children:r.fields.map(r=>(0,Y.jsx)(ie,{field:r,column:A(i.headers,r.column),examples:i.sample.map(e=>k(e.cells[r.column]??null)).filter(e=>e!==``).slice(0,3),problems:t.fields[r.column],texts:n,onChange:t=>e.change(r.column,t)},r.column))}),t.noFields&&(0,Y.jsxs)(`p`,{role:`alert`,className:`flex gap-2 rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-warning-text`,children:[(0,Y.jsx)(d,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsx)(`span`,{children:t.noFields})]})]})},Q=e(t(),1),se=5,ce=async(e,t,n,r)=>{let i,a=[],o=[],s=0;for await(let c of e.rows(t)){r?.throwIfAborted();for(let e of c){if(!i){i=e.cells.map(k),a=i.map(()=>W());continue}e.cells.every(w)||(s++,o.length<se&&o.push(e),a.forEach((t,n)=>t.add(e.cells[n]??null)))}n(s)}return{headers:i??[],types:a.map(e=>e.type()),decimals:a.map(e=>e.decimal()),sample:o,rows:s}},$={created:0,updated:0,skipped:0,failed:0,notWritten:[]},le={decimal:`.`,dateOrder:`dmy`,booleanText:!0},ue=({tables:e,resources:t,sourceFor:n=ee})=>{let r=u(),a=m(),{go:o}=s(),c=e.tenant!==void 0,l=c?42:63,d=(0,Q.useMemo)(()=>new Set(c?[]:Object.keys(t)),[c,t]),[f,p]=(0,Q.useState)({kind:`file`,reading:!1}),[h,g]=(0,Q.useState)(),[v,b]=(0,Q.useState)(),[x,S]=(0,Q.useState)(),[w,T]=(0,Q.useState)(),[E,O]=(0,Q.useState)(),[k,A]=(0,Q.useState)(),M=(0,Q.useRef)(!1),N=(0,Q.useRef)(void 0),P=e=>t=>{g(t),p(e)},F=(e,t,n)=>{let r=new AbortController;N.current=r,p({kind:`reading`,rows:0}),ce(t,n,e=>p({kind:`reading`,rows:e}),r.signal).then(t=>{r.signal.aborted||(T(t),O(C(e.name,t,d,l)),p({kind:`fields`}))}).catch(e=>{r.signal.aborted||P({kind:`file`,reading:!1})(e)})},I=e=>{g(void 0),p({kind:`file`,reading:!0});let t=n(e);t.sheets().then(n=>{if(b({file:e,source:t,sheets:n}),S(n[0]),n.length<=1)return F(e,t,n[0]);p({kind:`file`,reading:!1})}).catch(P({kind:`file`,reading:!1}))},L=()=>{v&&(g(void 0),F(v.file,v.source,x))},R=(e,t)=>O(n=>n&&te(n,e,t)),z=e=>O(t=>t&&{...t,...e}),B=async e=>{await a.refetchQueries({queryKey:i.meta});let t=a.getQueryData(i.meta),n=t?.resources[e];if(!t||!n)throw Error(`The server does not serve the new table ${e} yet`);return{model:n,resources:t.resources,views:t.views}},V=async(e,t)=>{if(!v||!w)return;let n={...await B(e),lookups:y(r)},i={mode:`create`,columns:D(t).map(e=>({column:e.column,field:e.name})),options:le};M.current=!1;let a=$;p({kind:`importing`,progress:$,total:w.rows,cancelling:!1});let s=await _(v.source,x,i,n,{client:r(e),onProgress:e=>{a=e,p({kind:`importing`,progress:e,total:w.rows,cancelling:M.current})},cancelled:()=>M.current}).catch(e=>({...a,cancelled:!1,stopped:e})),c=`stopped`in s?s.stopped:void 0;if(c===void 0&&!s.cancelled&&s.notWritten.length===0)return o({kind:`list`,resource:e});p({kind:`done`,result:s,stopped:c})};return{step:f,error:h,file:v?.file,sheets:v?.sheets??[],sheet:x,setSheet:S,read:w,proposal:E,table:k,taken:d,maxTableBytes:l,choose:I,openSheet:L,change:R,changeTable:z,create:()=>{E&&(g(void 0),p({kind:`creating`}),r(e.name).batchWrite(j(e.name,E)).then(({results:e})=>{let[t]=e,n=t?.op===`create`?String(t.record.table_name):E.name;return A(n),V(n,E).catch(e=>p({kind:`done`,result:{...$,cancelled:!1},stopped:e}))},P({kind:`fields`})))},cancel:()=>{M.current=!0,p(e=>e.kind===`importing`?{...e,cancelling:!0}:e)},back:()=>{N.current?.abort(),g(void 0),p({kind:`file`,reading:!1})},stop:()=>N.current?.abort()}},de=e=>e.step.kind===`fields`?T(`couldNotMakeTable`):T(`couldNotReadFile`),fe=({tables:e,resources:t,views:n,onClose:i,sourceFor:s})=>{let l=ue({tables:e,resources:t,sourceFor:s}),u=K(n,e.name),{step:d,proposal:p}=l,m=p?ne(p,l.taken,l.maxTableBytes):void 0,_=l.read?.headers??[],y=d.kind===`creating`||d.kind===`importing`,b=()=>{y||(l.stop(),i())},x=(0,Y.jsx)(c,{onClick:b,children:T(`cancel`)});return(0,Y.jsx)(o,{open:!0,wide:!0,title:T(`tableFromFile`),description:l.file&&d.kind!==`file`?l.file.name:void 0,onClose:b,actions:(()=>{switch(d.kind){case`file`:return(0,Y.jsxs)(Y.Fragment,{children:[x,l.sheets.length>1&&(0,Y.jsx)(c,{variant:`primary`,loading:d.reading,onClick:l.openSheet,children:T(`next`)})]});case`reading`:return(0,Y.jsx)(c,{onClick:l.back,children:T(`back`)});case`fields`:case`creating`:{let e=l.read?.rows??0;return(0,Y.jsxs)(Y.Fragment,{children:[x,(0,Y.jsx)(c,{variant:`primary`,loading:d.kind===`creating`,disabled:!m||re(m),onClick:l.create,children:T(`makeTable`,{rows:e})})]})}case`importing`:return(0,Y.jsx)(c,{variant:`danger`,disabled:d.cancelling,onClick:l.cancel,children:T(`cancelImport`)});case`done`:return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c,{onClick:i,children:T(`done`)}),l.table&&(0,Y.jsx)(a,{to:{kind:`list`,resource:l.table},className:r({variant:`primary`}),children:T(`openTable`)})]})}})(),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l.error!==void 0&&(0,Y.jsx)(f,{title:de(l),error:l.error}),(()=>{switch(d.kind){case`file`:return(0,Y.jsx)(h,{file:l.file,sheets:l.sheets,sheet:l.sheet,reading:d.reading,onChoose:l.choose,onSheet:l.setSheet});case`reading`:return(0,Y.jsx)(g,{rows:d.rows});case`fields`:case`creating`:return m&&(0,Y.jsx)(oe,{flow:l,problems:m,texts:u});case`importing`:return(0,Y.jsx)(S,{progress:d.progress,total:d.total,cancelling:d.cancelling});case`done`:return(0,Y.jsx)(v,{result:d.result,stopped:d.stopped,headers:_,fileName:l.file?.name})}})()]})})};export{fe as ImportTableDialog};
|
|
2
|
+
//# debugId=1c7d664c-25f8-4124-8163-268cf322582d
|
|
@@ -1 +1 @@
|
|
|
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"./app-
|
|
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"./app-DKn-6fgf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();
|
|
@@ -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,Ja as i,Ka as a,Wa as o,qa as s,us 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{Ho as r,Ja as i,Ka as a,Wa as o,qa as s,us as c}from"./app-DKn-6fgf.js";import{t as l}from"./page-header-Ddz2r5ic.js";import{n as u,t as d}from"./pending-invitation-row-BEvgmW-N.js";import{n as f}from"./person-row-5VQjyq5t.js";import{assignableOrganizationRoles as p}from"./members-page-UO-o4WSG.js";var m=e(t(),1),h=e(n(),1),g=({current:e,onSent:t})=>{let{session:n,organizations:r}=c(),s=r?.roles??[],[l,d]=(0,m.useState)(`member`),[g,_]=(0,m.useState)([]);return(0,h.jsx)(u,{title:i(`inviteSomeone`),description:i(`inviteDescription`),onInvite:async r=>{let i=await n.organizations.invite(e.organization.id,{email:r,role:l,appRoles:g});return _([]),t(),i},beside:(0,h.jsx)(`select`,{"aria-label":i(`organizationRole`),value:l,onChange:e=>d(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2`,children:p(e).map(e=>(0,h.jsx)(`option`,{value:e,children:a(e)},e))}),children:(0,h.jsx)(f,{roles:s.filter(e=>e.membership),selected:g,grantable:o(s,e),onChange:_})})},_=({invitation:e,organizationId:t,onChanged:n})=>{let{session:r,organizations:i}=c(),o=e.appRoles.map(e=>s(i?.roles??[],e));return(0,h.jsx)(d,{email:e.email,gives:`${a(e.role)}${o.length>0?` · ${o.join(`, `)}`:``}`,expiresAt:e.expiresAt,onResend:async()=>{let i=await r.organizations.resend(t,e);return n(),i},onRevoke:async()=>{await r.organizations.revoke(e.id),n()}})},v=({current:e})=>{let{session:t}=c(),[n,a]=(0,m.useState)([]),o=e?.organization?.id,s=(0,m.useCallback)(()=>{o&&t.organizations.invitations(o).then(e=>a(e.filter(e=>e.status===`pending`)),()=>a([]))},[t,o]);return(0,m.useEffect)(s,[s]),!e?.organization||!o?null:(0,h.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,h.jsx)(l,{title:i(`invitations`),subtitle:i(`peopleInvited`,{organization:e.organization.name})}),(0,h.jsx)(g,{current:e,onSent:s}),(0,h.jsx)(r,{title:i(`notAcceptedYet`),description:n.length>0?i(`sendingAgain`):i(`nobodyWaiting`),children:n.length>0&&(0,h.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(e=>(0,h.jsx)(_,{invitation:e,organizationId:o,onChanged:s},e.id))})})]})};export{v as InvitationsPage};
|
|
2
|
+
//# debugId=b1f7ad33-7dbe-48af-9e55-b15a95d199ec
|
|
@@ -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{Mc as e}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{Mc as e}from"./app-DKn-6fgf.js";var t={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};t.node;var n=e(t);export{n as t};
|
|
2
|
+
//# debugId=0874952c-364e-4d51-bf50-3f61acf2ba5f
|
|
@@ -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{Ir as n}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{Ir as n}from"./app-DKn-6fgf.js";import{mt as r}from"./embedded-list-CG1SyUtd.js";var i=e(t(),1),a=`flex items-center gap-2 rounded-md px-1 py-0.5`,o=({resource:e,view:t,filter:o,color:s,label:c,children:l})=>{let u=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-full`,style:{background:s},"aria-hidden":!0}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate group-hover:text-primary-text`,children:c}),l]});return(0,i.jsx)(`li`,{children:o===void 0?(0,i.jsx)(`div`,{className:a,children:u}):(0,i.jsx)(n,{to:r(t,e,o),className:`group ${a} hover:bg-muted`,children:u})})};export{o as t};
|
|
2
|
+
//# debugId=0544610d-5e94-4dad-b496-c1a995509d0c
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/import-dialog-
|
|
2
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,$s as i,Ai as a,Bc as o,Br as s,C as c,Dc as l,Ec as u,Fl as d,Ft as f,Gn as p,Gr as m,Ir as h,Jc as g,Jn as _,Ki as v,Ks as y,Li as b,Lr as x,Ls as S,M as C,Mc as w,Nc as T,Ni as E,Nl as D,Nn as ee,No as te,O as ne,Oa as re,Po as ie,Qc as ae,Qs as O,Ri as oe,S as se,Sa as k,T as ce,Tn as le,Uc as A,Vc as j,Vi as M,Vl as ue,Wn as N,Ws as P,Xo as de,Xr as fe,Ya as F,Yc as I,Yo as pe,Ys as L,Zc as me,Zo as he,Zr as ge,_o as R,b as _e,ba as ve,bo as ye,da as be,ja as z,ji as xe,jo as Se,jr as Ce,k as we,kc as Te,ki as Ee,kn as De,kt as Oe,li as ke,lt as Ae,mo as je,mr as Me,nc as Ne,ni as Pe,oc as B,oi as Fe,pi as Ie,po as Le,qn as Re,rc as ze,rl as V,rs as H,sl as Be,uc as Ve,un as He,us as Ue,vn as U,vo as We,wa as Ge,wi as Ke,xa as qe,xo as W,yc as Je,zi as Ye,zl as Xe}from"./app-D5KGkwJq.js";import{C as Ze,f as Qe,h as $e,i as G,o as et,s as K}from"./vendor-t7Q7QbPu.js";import{n as tt}from"./view-chart-ChBtewKd.js";import{$ as nt,A as rt,B as it,D as at,E as ot,F as st,G as ct,H as lt,I as ut,J as q,K as dt,L as ft,M as pt,N as mt,O as ht,P as gt,Q as _t,R as vt,T as yt,U as bt,V as xt,W as St,X as Ct,Y as wt,Z as J,b as Tt,d as Et,et as Dt,f as Ot,ft as kt,h as At,i as jt,j as Mt,k as Nt,m as Pt,n as Ft,p as It,pt as Lt,q as Rt,u as zt,v as Bt,w as Vt,x as Ht,xt as Y,y as Ut,z as Wt}from"./embedded-list-B8K84K5b.js";import{a as Gt,i as Kt,n as qt,r as Jt,t as Yt}from"./reorder-button-2tg9wf42.js";import{t as Xt}from"./trash-BNguTSbA.js";import{t as Zt}from"./page-header-Ddz2r5ic.js";import{i as Qt,r as $t,t as en}from"./record-preview-Cnz2q7jF.js";import{c as tn,l as nn}from"./messages-Cjox3dPW.js";import{t as rn}from"./use-display-rows-BeUN0NEn.js";var an=new Set(`all.analyse.analyze.and.any.array.as.asc.asymmetric.both.case.cast.check.collate.column.constraint.create.current_catalog.current_date.current_role.current_time.current_timestamp.current_user.default.deferrable.desc.distinct.do.else.end.except.false.fetch.for.foreign.from.grant.group.having.in.initially.intersect.into.lateral.leading.limit.localtime.localtimestamp.not.null.offset.on.only.or.order.placing.primary.references.returning.select.session_user.some.symmetric.system_user.table.then.to.trailing.true.union.unique.user.using.variadic.when.where.window.with`.split(`.`)),on=/^[a-z][a-z0-9_]*$/,sn=[`id`,`etag`,`organization_id`],cn=e=>on.test(e)&&new TextEncoder().encode(e).length<=63,ln=(e,t,n=63)=>{if(typeof e!=`string`||!cn(e)||new TextEncoder().encode(e).length>n)return`form`;if(an.has(e))return`reserved_word`;if(t===`field`&&sn.includes(e))return`reserved_field`},un={name:`bookmark-check`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]};un.node;var dn=w(un),fn={name:`bookmark-plus`,size:24,node:[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};fn.node;var pn=w(fn),mn={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};mn.node;var hn=w(mn),gn={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};gn.node;var _n=w(gn),vn={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};vn.node;var yn=w(vn),bn=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),xn=(e,t,n)=>(/^[a-z]/.test(e)?e:`${t}_${e}`).slice(0,n).replace(/_+$/,``),Sn=(e,t,n)=>{let r=e;for(let i=2;t.has(r)||an.has(r);i++){let t=`_${i}`;r=`${e.slice(0,n-t.length).replace(/_+$/,``)}${t}`}return r},Cn=e=>e<26?String.fromCharCode(97+e):Cn(Math.floor(e/26)-1)+Cn(e%26),wn=e=>{let t=new Set(sn);return e.map((e,n)=>{let r=bn(e),i=Sn(r===``?`column_${Cn(n)}`:xn(r,`column`,63),t,63);return t.add(i),i})},Tn=(e,t=[],n=63)=>{let r=bn(e.replace(/\.(csv|tsv|txt|xlsx|json)$/i,``));if(r!==``)return Sn(xn(r,`table`,n),new Set(t),n)},X=e(n(),1),En=`inline-flex h-6 items-center gap-1 rounded-full border border-primary-border bg-primary-soft pl-2.5 pr-1.5 text-xs font-medium text-primary-text`,Dn=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,X.jsxs)(`div`,{className:i?`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1 [&>*]:shrink-0`:`flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full border border-border-strong bg-muted px-2.5 text-xs font-medium text-foreground`,children:[(0,X.jsx)(hn,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,X.jsxs)(`span`,{className:En,children:[e.label,(0,X.jsx)(`button`,{type:`button`,"aria-label":q(`remove`,{label:e.label}),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,X.jsx)(Ne,{className:`size-3`})})]},e.key)),e.length>0&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:q(`clearAll`)})]}),On=({value:e,presets:t=Rt,onChange:n})=>(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=dt(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:q(`unknownPreset`,{id:t}),onClick:()=>n(e===t?void 0:t),className:T(`h-7 rounded-md border px-2.5 text-body font-medium transition-colors`,!r&&`border-dashed text-danger-text`,e===t?`border-primary-border bg-primary-soft text-primary-text`:`border-border-strong bg-background text-muted-foreground hover:bg-muted`),children:r??q(`unsupported`,{id:t})},t)})}),kn=(e,t)=>e.onSearch?e.options:e.options.filter(e=>xt(e.label,t)),An=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,Z=e(t(),1),jn=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,Z.useId)(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(-1),p=r||c,m=kn(e,o),h=(0,Z.useRef)(e.onSearch);h.current=e.onSearch,(0,Z.useEffect)(()=>()=>h.current?.(``),[]);let g=t=>{s(t),f(-1),e.onSearch?.(t)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-8 cursor-text flex-wrap items-center gap-1 rounded-md border border-border-strong bg-background px-2 py-1 shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,onClick:()=>a.current?.focus(),children:[(0,X.jsx)(B,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,X.jsx)(ee,{label:it(e,t),onRemove:()=>n(t)},t)),(0,X.jsx)(`input`,{ref:a,autoFocus:r,role:`combobox`,"aria-label":e.label,"aria-expanded":p,"aria-controls":`${i}-options`,"aria-autocomplete":`list`,"aria-activedescendant":m[d]?`${i}-${d}`:void 0,placeholder:t.length>0?``:q(`searchIn`,{label:e.label}),className:`h-6 min-w-16 flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground`,value:o,onChange:e=>g(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),f(An(d,m.length,e.key));return}if(e.key===`Enter`&&m[d]){e.preventDefault(),n(m[d].value);return}if(e.key===`Backspace`&&o===``&&t.length>0){n(t[t.length-1]);return}e.key===`Escape`&&o!==``&&(e.stopPropagation(),g(``))},onFocus:()=>u(!0),onBlur:()=>{u(!1),f(-1),!r&&o!==``&&g(``)}})]}),p&&(0,X.jsxs)(`ul`,{id:`${i}-options`,role:`listbox`,"aria-label":e.label,"aria-multiselectable":!0,className:T(`flex max-h-60 flex-col gap-px overflow-y-auto`,!r&&`rounded-md border bg-background p-1 shadow-sm`),children:[m.map((e,r)=>{let a=t.includes(e.value);return(0,X.jsxs)(`li`,{id:`${i}-${r}`,role:`option`,"aria-selected":a,tabIndex:-1,className:T(`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 hover:bg-muted`,r===d&&`bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.value),children:[(0,X.jsx)(`span`,{className:T(`inline-flex size-4 shrink-0 items-center justify-center rounded border`,a?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background`),children:a&&(0,X.jsx)(l,{className:`size-3`,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:E(e.count)})]},e.value)}),m.length===0&&(0,X.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})]})},Mn=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,Z.useState)(``),a=e.options.filter(e=>xt(e.label,r));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,X.jsx)(W,{wrapperClassName:`mb-1 h-7`,leading:(0,X.jsx)(B,{className:`size-3.5`}),placeholder:q(`searchIn`,{label:e.label}),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,X.jsx)(F,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:E(e.count)})]},e.value)),a.length===0&&(0,X.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})},Nn=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,Z.useState)(r),[s,c]=(0,Z.useState)({width:n}),l=(0,Z.useRef)(null),d=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{if(!a||!l.current)return;let e=l.current.getBoundingClientRect(),t=document.documentElement.clientWidth,r=Math.min(n,R(t));c({width:r,right:e.left+r>t?e.right-We(e.right,r,t):void 0})},[a,n]);let f=ye(a,l,d,s);return(0,Z.useEffect)(()=>{if(!a)return;let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]),(0,X.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:T(`inline-flex h-8 items-center gap-1.5 rounded-md border bg-background px-2.5 font-medium shadow-sm transition-colors hover:bg-muted`,t>0?`border-primary-border text-primary-text`:`border-border-strong text-foreground`),children:[e,t>0&&(0,X.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[0.6875rem] leading-4 text-primary-foreground`,children:t}),(0,X.jsx)(u,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,X.jsx)(`div`,{ref:d,className:T(`absolute top-full z-30 mt-1.5 rounded-lg border bg-background p-3 shadow-pop`,s.right===void 0&&`left-0`),style:{...s,...f},children:typeof i==`function`?i(()=>o(!1)):i})]})},Pn=({title:e,children:t})=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),Fn=({items:e,onPick:t,close:n})=>{let r=(0,Z.useRef)([]);return(0,Z.useEffect)(()=>r.current[0]?.focus(),[]),(0,X.jsx)(`ul`,{role:`menu`,"aria-label":q(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=Oe(t.key,r.current.indexOf(document.activeElement),e.length);i!==void 0&&(t.preventDefault(),r.current[i]?.focus())},className:`-mx-3 -my-3`,children:e.map((e,i)=>(0,X.jsx)(`li`,{role:`none`,children:(0,X.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:Ae,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},In=({items:e,onPick:t})=>e.length===0?null:(0,X.jsx)(Nn,{label:q(`moreFilters`),activeCount:0,children:n=>(0,X.jsx)(Fn,{items:e,onPick:t,close:n})}),Ln=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},Rn=(e,t,n)=>n===t?0:(e-t)/(n-t),zn=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],Bn=1e3,Vn=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,Z.useState)(),u=c??t??[r,i],d=Math.max(...o),f=()=>{c&&(l(void 0),n(c[0]===r&&c[1]===i?void 0:c))},p=oe(c,Bn);return(0,Z.useEffect)(()=>{p&&f()},[p]),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,X.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,X.jsx)(`span`,{className:T(`flex-1 rounded-t-sm`,Ln(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,X.jsxs)(`div`,{className:`relative h-4`,children:[(0,X.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,X.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${Rn(u[0],r,i)*100}%`,right:`${100-Rn(u[1],r,i)*100}%`}})]})]}),(0,X.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,X.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":q(t===0?`minimum`:`maximum`,{label:e.label}),min:r,max:i,step:a,value:u[t],onChange:e=>l(zn(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:s(u[0])}),(0,X.jsx)(`span`,{children:s(u[1])})]})]})},Hn=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],Un=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},Wn=(e,t)=>{let n=[...e.facets.map(e=>({key:`facet:${e.id}`,label:e.label,secondary:e.secondary})),...(e.ranges??[]).map(e=>({key:`range:${e.id}`,label:e.label,secondary:e.secondary})),...e.datePresets?[{key:`date`,label:q(`date`),secondary:e.dateSecondary}]:[],...(e.toggles??[]).map(e=>({key:`toggle:${e.id}`,label:e.label,secondary:e.secondary}))],r=new Set,i=[];for(let e of n)!e.secondary||t.includes(e.key)?r.add(e.key):i.push({key:e.key,label:e.label});return{shown:r,more:i}},Gn=({label:e,checked:t,onChange:n})=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(C,{checked:t,onChange:n,label:e})]}),Kn=(e,t)=>e.some(e=>e.length>0)||!!t,qn=({groups:e,trailing:t})=>{if(!Kn(e,t))return null;let n=e.filter(e=>e.length>0);return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,X.jsxs)(Z.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,X.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},Jn=(e,t,n)=>{let[r,i]=(0,Z.useState)(t??Wt);return[e??r,e=>{i(e),n?.(e)}]},Yn=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=Jn(n,r,i),f=vt(e,u),p=Hn(f),[m,h]=(0,Z.useState)(()=>p),[g,_]=(0,Z.useState)();(0,Z.useEffect)(()=>h(e=>Un(e,p)),[p.join(`,`)]);let v=(0,X.jsx)(Dn,{chips:f,lockedLabels:a,onRemove:e=>d(lt(u,e)),onClear:()=>d(Wt)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(St(u,e.id,t));return e.combobox?(0,X.jsx)(jn,{config:e,selected:n,onToggle:r,inline:t}):(0,X.jsx)(Mn,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,X.jsx)(Vn,{config:e,value:u.ranges?.[e.id],onChange:t=>d(bt(u,e.id,t))}),S=e.datePresets&&(0,X.jsx)(On,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,X.jsx)(Gn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(ct(u,e.id))},e.id));if(t===`panel`)return(0,X.jsxs)(`aside`,{className:s?`flex w-full flex-col gap-1`:`flex w-64 shrink-0 flex-col gap-1 overflow-y-auto rounded-lg border bg-background px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,X.jsx)(`h2`,{className:`font-semibold`,children:q(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,X.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,X.jsx)(Pn,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,X.jsx)(Pn,{title:e.label,children:x(e)},e.id)),S&&(0,X.jsx)(Pn,{title:q(`date`),children:S}),C.length>0&&(0,X.jsx)(Pn,{title:q(`showOnly`),children:C})]});let{shown:w,more:T}=Wn(e,m),E=e=>{h(t=>Un(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,X.jsx)(Nn,{label:e.label,activeCount:(u.facets[e.id]??[]).length,width:e.combobox?280:void 0,defaultOpen:o===e.id||g===`facet:${e.id}`,children:y(e,!0)},e.id)),...b.filter(e=>w.has(`range:${e.id}`)).map(e=>(0,X.jsx)(Nn,{label:e.label,activeCount:+!!u.ranges?.[e.id],width:280,defaultOpen:o===e.id||g===`range:${e.id}`,children:x(e)},`range:${e.id}`)),...S&&w.has(`date`)?[(0,X.jsx)(Z.Fragment,{children:S},`date`)]:[]],ee=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,X.jsx)(Gn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(ct(u,e.id))})},e.id)),te=[c?[(0,X.jsx)(Z.Fragment,{children:c},`leading`)]:[],D,ee,T.length>0?[(0,X.jsx)(In,{items:T,onPick:E},`more`)]:[]];return!Kn(te,l)&&f.length===0&&!a?.length?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(qn,{groups:te,trailing:l}),v]})},Q=j(`app/export`),Xn=()=>new DOMException(Q(`cancelled`),`AbortError`),Zn=async({client:e,resource:t,filters:n,orderBy:r,plan:i,labels:a,limit:o,port:s,sink:c,signal:l,onProgress:u})=>{let d=i.columns.map(e=>e.name),f=0;try{await c.write(await s.send({kind:`start`,plan:i,locale:A()}));for(let[i,p]of n.entries()){let m=``;do{let h=await e.search(t,{filter:p,orderBy:r,pageSize:500,pageToken:m,fields:d,labels:a});if(l.aborted)throw Xn();let g=h.items.slice(0,o-f);if(await c.write(await s.send({kind:`page`,records:g,labels:h.labels??{}})),f+=g.length,u(f),m=h.nextPageToken,f>=o)return await Qn(s,c),{rows:f,truncated:g.length<h.items.length||m!==``||i+1<n.length}}while(m!==``)}return await Qn(s,c),{rows:f,truncated:!1}}catch(e){throw await c.abort(),e}finally{s.close()}},Qn=async(e,t)=>{await t.write(await e.send({kind:`finish`})),await t.close()},$n=1048575,er=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
-
`,tr=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,nr=`http://schemas.openxmlformats.org/package/2006/relationships`;`${er}`,`${er}${nr}${tr}`,`${er}${nr}${tr}${tr}`,new TextEncoder;var rr=D(),ir=e=>e?.export!==!1,ar=e=>Object.values(e.fields).flatMap(e=>e.sensitive?[]:[e.name]),or=(e,t)=>{let n=new Set(ar(e));return g(e,t).filter(e=>n.has(e))},sr=(e,t,n)=>Object.fromEntries(Ie(e,t,[],n).map(e=>[e.id,e.header])),cr=(e,t,n)=>{let r=sr(e,t,n);return n.flatMap(n=>{let i=e.fields[n];return i?[{name:n,header:r[n],field:i,hints:t?.fields[n]??{}}]:[]})},lr=(e,t)=>{let n=e?.export?e.export.maxRows??1/0:1/0;return Math.min(n,t===`xlsx`?$n:1/0)},ur=e=>e.primaryKey.length===1,dr=(e,t)=>{let[n]=e.primaryKey;if(!n||e.primaryKey.length!==1)throw Error(`Not implemented: selected rows are exported by a single-field key`);let r=[];for(let e=0;e<t.length;e+=500)r.push(d(rr.in(n,t.slice(e,e+500))));return r},fr=e=>{if(e.kind!==`counting`)return e.kind===`exact`?e.rows:Math.max(e.rows,10001)},pr=j(`app/import`),mr=e=>typeof e==`object`&&!!e&&`date`in e,hr=e=>typeof e==`object`&&!!e&&`json`in e,gr=e=>e===null||typeof e==`string`&&e.trim()===``,_r=e=>e===null?``:mr(e)?e.date.replace(`T`,` `):hr(e)?JSON.stringify(e.json):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),vr=e=>e<26?String.fromCharCode(65+e):vr(Math.floor(e/26)-1)+vr(e%26),yr=(e,t)=>e[t]?.trim()?e[t]:pr(`column`,{letters:vr(t)}),br=(e,t,n,r)=>{let i=wn(t.headers),a=t.headers.map((e,n)=>({column:n,include:!0,name:i[n],label:yr(t.headers,n).trim(),type:t.types[n].type,inferred:t.types[n],decimal:t.decimals[n]}));return{name:Tn(e,n,r)??``,pluralLabel:e.replace(/\.[^.]+$/,``).trim(),singularLabel:``,titleField:a.find(e=>e.type===`text`)?.name,fields:a}},xr=e=>e.fields.filter(e=>e.include),Sr=(e,t,n)=>{let r=e.fields.find(e=>e.column===t),i=e.fields.map(e=>e.column===t?{...e,...n}:e),a=i.find(e=>e.column===t),o=r?.name===e.titleField,s=a.include&&a.type===`text`;return o?{...e,fields:i,titleField:s?a.name:void 0}:{...e,fields:i}},Cr=`user_table_fields`,wr=`table`,Tr=(e,t)=>{let n=xr(t).map((e,t)=>({op:`create`,resource:Cr,data:{table_id:{$ref:wr},name:e.name,label:e.label.trim(),type:e.type,position:t+1,...e.type===`decimal`&&{precision:e.decimal.precision,scale:e.decimal.scale}}})),r=t.titleField?[{op:`update`,resource:e,key:{$ref:wr},etag:`*`,data:{title_field:t.titleField}}]:[];return[{op:`create`,resource:e,ref:wr,data:{name:t.name,singular_label:t.singularLabel.trim(),plural_label:t.pluralLabel.trim()}},...n,...r]},Er=(e,t)=>{let n=new Map(t.map(e=>[e.value,e.count]));return e.map(([e,t])=>({value:e,label:t,...n.get(e)!==void 0&&{count:n.get(e)}}))},Dr=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],Or=D(),kr=(e,t,n)=>{let r=H(),[i,a]=(0,Z.useState)({}),o=e=>!!e?.search?.length&&e.primaryKey.length===1,s=e=>{let n=t[e.name];return[e.primaryKey[0],...n?.titleFrom?n.titleFrom.fields:[I(e,n)]]},c=(e,r)=>{let i=t[e.name],a=String(r[e.primaryKey[0]]);return[a,i?.titleFrom?n(e,i,r,a):String(r[I(e,i)])]},l=K({queries:e.map(({id:e,target:t})=>{let n=(i[e]??``).trim();return{queryKey:[`reference-search`,e,t?.name??``,n],enabled:o(t)&&n!==``,placeholderData:Qe,queryFn:async()=>(await r.list(t.name,{filter:d(Or.search(n)),fields:s(t),pageSize:20})).items}})});return e.map(({id:e,target:t},n)=>{if(!o(t))return{};let r=t=>a(n=>({...n,[e]:t}));return(i[e]??``).trim()===``?{onSearch:r}:{onSearch:r,matches:(l[n]?.data??[]).map(e=>c(t,e))}})},Ar=24,jr=({model:e,resources:t,views:n,view:i,state:a,extras:s,titleOf:c})=>{let l=H(),u=$e(),d=st(i,e),f=e=>i?.fields[e]?.label??r(e),m=n=>{let r=e.fields[n];return r?.type===`relation`&&r.relation?t[r.relation.resource]:void 0},h=e=>!!(e&&n[e.name]?.titleFrom),g=d.facets.flatMap(e=>(e.flags?e.options.map(e=>e.value):[e.id]).map(t=>({group:e.id,field:t}))),_=K({queries:g.map(({group:t,field:r})=>{let i=ut(d,{...a,facets:{...a.facets,[t]:[]}},s),c=m(r),u=c?.primaryKey.length===1&&!h(c)?I(c,n[c.name]):void 0;return{queryKey:o.facets(e.name,r,i),queryFn:()=>l.facets(e.name,r,{filter:i,limit:50,...u&&{label:u}})}})}),v=(e,t)=>_[g.findIndex(n=>n.group===e&&n.field===t)]?.data,y=e=>(v(e,e)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),b=K({queries:d.facets.map(t=>{let r=m(t.id),i=Dr(y(t.id),a.facets[t.id]??[]);return{queryKey:o.labels(`facet:${e.name}.${t.id}`,i.join(`,`)),enabled:!!r&&!h(r)&&i.length>0,queryFn:async()=>[...await Re(u,l,r,i,n[r.name])]}})}),x=K({queries:d.facets.map(t=>{let r=m(t.id),i=r&&h(r)?N(r,n[r.name]):void 0,s=[...new Set([...y(t.id),...a.facets[t.id]??[]])];return{queryKey:o.labels(`facet-title:${e.name}.${t.id}`,s.join(`,`)),enabled:i!==void 0&&s.length>0,queryFn:async()=>[...await p(l,r,i,s)]}})}),S=(e,t)=>{let r=m(e);return(x[t]?.data??[]).map(([e,t])=>[e,c(r,n[r.name],t,e)])},C=kr(d.facets.map(e=>({id:e.id,target:e.combobox?m(e.id):void 0})),n,c),w=d.ranges??[],T=K({queries:w.map(t=>{let n=ut(d,bt(a,t.id,void 0),s),r=gt(i,t.id)?Ar:1;return{queryKey:o.histogram(e.name,t.id,r,n),queryFn:()=>l.histogram(e.name,t.id,{filter:n,buckets:r})}})});return{facets:d.facets.map((t,n)=>{if(t.flags){let e=t.options.map(({value:e})=>({value:e,label:f(e),count:v(t.id,e)?.find(e=>String(e.value)===`true`)?.count??0}));return{...t,options:e}}let r=e.fields[t.id],a=(v(t.id,t.id)??[]).flatMap(e=>e.label===void 0?[]:[[String(e.value),e.label]]),o=r?.type===`enum`?(r.enumValues??[]).map(e=>[e,ae(e,i?.fields[t.id]?.valueLabels)]):[],s=new Map([...o,...a,...b[n]?.data??[],...S(t.id,n)]),c=(v(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[{value:String(e.value),label:s.get(String(e.value))??String(e.value),count:e.count}]),l=C[n];return{...t,label:f(t.id),options:l.matches?Er(l.matches,c):c,...s.size>0&&{labels:Object.fromEntries(s)},...l.onSearch&&{onSearch:l.onSearch}}}),ranges:w.flatMap((e,t)=>{let n=T[t]?.data;return!n||n.min===null||n.max===null?[]:[{...e,label:f(e.id),min:Math.floor(n.min),max:Math.ceil(n.max),step:Math.max(1,Math.round((n.max-n.min)/100)),histogram:gt(i,e.id)?n.buckets.map(e=>e.count):[],format:mt(i,e.id)}]}),...d.dateField&&{datePresets:d.datePresets??!0,dateField:d.dateField,dateKind:d.dateKind,...d.dateSecondary&&{dateSecondary:!0}},toggles:d.toggles?.map(e=>({...e,label:f(e.id)}))}},Mr=b(()=>Ze(()=>import(`./import-dialog-DrDyc76O.js`).then(e=>e.ImportDialog),__vite__mapDeps([0,1,2,3,4,5,6]))),Nr=b(()=>Ze(()=>import(`./import-table-dialog-DYBhyBp7.js`).then(e=>e.ImportTableDialog),__vite__mapDeps([7,1,2,3,4,5,6]))),Pr=({model:e})=>{let{resources:t,views:n}=de(),r=he(e.name),i=he(Cr),[a,o]=(0,Z.useState)(!1),s=n[e.name]?.import;return s===!1||!k(r,`create`)||s===`table`&&!k(i,`create`)?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{onClick:()=>o(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(ze,{className:`size-3.5`}),pr(s===`table`?`fromFile`:`import`)]}),a&&s===`table`&&(0,X.jsx)(Nr,{tables:e,resources:t,views:n,onClose:()=>o(!1)}),a&&s!==`table`&&(0,X.jsx)(Mr,{model:e,resources:t,views:n,canUpdate:k(r,`update`),onClose:()=>o(!1)})]})},Fr=()=>{let e=new Worker(new URL(`/assets/export-worker-CHLq663S.js`,``+import.meta.url),{type:`module`,name:`protobase-export`}),t=[];return e.onmessage=e=>t.shift()?.resolve(e.data.bytes),e.onerror=e=>{e.preventDefault();let n=Error(Q(`couldNotBuild`,{message:e.message}));for(let e of t.splice(0))e.reject(n)},{send:n=>new Promise((r,i)=>{t.push({resolve:r,reject:i}),e.postMessage(n)}),close:()=>e.terminate()}},Ir={xlsx:{mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,extension:`.xlsx`,description:`workbook`},csv:{mime:`text/csv`,extension:`.csv`,description:`csvFile`}},Lr=/[\\/:*?"<>|\u0000-\u001f]/g,Rr=(e,t,n=new Date)=>{let r=[n.getFullYear(),String(n.getMonth()+1).padStart(2,`0`),String(n.getDate()).padStart(2,`0`)].join(`-`);return`${e.replace(Lr,` `).trim()} ${r}${Ir[t].extension}`},zr=8e6,Br=(e,t)=>{let n=new Blob([],{type:Ir[t].mime}),r=[],i=0,a=()=>{n=new Blob([n,...r],{type:Ir[t].mime}),r=[],i=0};return{write:async e=>{e.length!==0&&(r.push(e),i+=e.length,i>=zr&&a())},close:async()=>{a();let t=URL.createObjectURL(n),r=document.createElement(`a`);r.href=t,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)},abort:async()=>{r=[],n=new Blob([])}}},Vr=()=>globalThis.showSaveFilePicker,Hr=()=>typeof Vr()==`function`,Ur=async(e,t)=>{let n=Vr();if(!n)throw Error(`This browser cannot save a file as it is built`);let r=Ir[t],i;try{i=await n({suggestedName:e,types:[{description:Q(r.description),accept:{[r.mime]:[r.extension]}}]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}let a=await i.createWritable();return{write:async e=>{e.length>0&&await a.write(e)},close:()=>a.close(),abort:()=>a.abort()}},Wr=b(()=>Ze(()=>import(`./export-dialog-IWSkZoEf.js`).then(e=>e.ExportDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Gr=b(()=>Ze(()=>import(`./export-dialog-IWSkZoEf.js`).then(e=>e.ExportProgressDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Kr=(e,t)=>Hr()?Ur(e,t):Promise.resolve(Br(e,t)),qr=(e,t)=>{let n=t[e.primaryKey[0]];return typeof n==`object`&&n&&`id`in n?n.id:n},Jr=({model:e,view:t,resources:n,views:r,plural:i,filter:a,orderBy:s,createPort:c=Fr,createSink:l=Kr})=>{let u=H(),d=z(),[f,p]=(0,Z.useState)({kind:`closed`}),m=(0,Z.useRef)(void 0),h=(0,Z.useRef)(void 0),g=et({queryKey:o.exportCount(e.name,a),enabled:f.kind===`settings`,queryFn:async()=>{let t=await u.list(e.name,{filter:a||void 0,pageSize:1,count:`exact`,fields:e.primaryKey});return t.totalSize===void 0?{kind:`estimate`,rows:t.totalSizeEstimate}:{kind:`exact`,rows:t.totalSize}}}).data??{kind:`counting`},v=(e,t=h.current)=>{let n=h.current;n&&n===t&&(h.current=void 0,n.settle(e?[]:n.rows))},y=(t=[])=>(v(!1),p({kind:`settings`,selected:ur(e)?t.map(t=>qr(e,t)):[]}),new Promise(e=>{h.current={rows:t,settle:e}})),b=()=>{p({kind:`closed`}),v(!1)},x=async(o,f)=>{let y=Rr(i,o.format),b=await l(y,o.format);if(!b)return;let x=h.current,C=lr(t,o.format),w=o.scope===`selected`?f.length:fr(g),T=w===void 0?void 0:Math.min(w,C),D=new AbortController;m.current=D,p({kind:`running`,done:0,total:T});try{let l=await Zn({client:u,resource:e.name,filters:o.scope===`selected`?dr(e,f):[a],orderBy:s,plan:{format:o.format,mode:o.mode,name:i,columns:cr(e,t,o.columns)},labels:o.mode===`shown`?_(n,r,e,o.columns):{},limit:C,port:c(),sink:b,signal:D.signal,onProgress:e=>D.signal.aborted||p({kind:`running`,done:e,total:T})});d.show({state:`success`,title:Q(`exported`,{count:E(l.rows),plural:i}),description:l.truncated?Q(`truncated`,{name:y,count:E(l.rows)}):y}),v(!0,x)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(!S(e))throw e;d.show({state:`error`,title:Q(`couldNotExport`,{plural:i}),description:e.message})}finally{m.current=void 0,p(e=>e.kind===`running`?{kind:`closed`}:e),v(!1,x)}},C=()=>{m.current?.abort(),b()},w=ar(e),T=sr(e,t,w);return{open:y,dialogs:f.kind===`settings`?(0,X.jsx)(Wr,{plural:i,view:t,fields:w.map(e=>({name:e,label:T[e]})),initialColumns:or(e,t),count:g,selected:f.selected.length>0?f.selected.length:void 0,open:!0,onExport:e=>void x(e,f.selected),onClose:b}):f.kind===`running`?(0,X.jsx)(Gr,{plural:i,done:f.done,total:f.total,onCancel:C}):null}},Yr=({state:e,onClearSearch:t,onClearFilters:n,create:r})=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8 text-center text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:e.message}),(e.clearSearch||e.clearFilters||e.create&&r)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[e.clearSearch&&(0,X.jsx)(O,{onClick:t,children:Y(`clearSearch`)}),e.clearFilters&&(0,X.jsx)(O,{onClick:n,children:Y(`clearFilters`)}),e.create&&r]})]}),Xr=({plural:e,search:t,filtered:n,scoped:r,canCreate:i})=>t?{message:Y(`noMatchSearch`,{plural:e,search:t}),clearSearch:!0,clearFilters:n,create:!1}:n?{message:Y(`noMatchFilters`,{plural:e}),clearSearch:!1,clearFilters:!0,create:!1}:r?{message:Y(`noMatch`,{plural:e}),clearSearch:!1,clearFilters:!1,create:!1}:{message:Y(`noneYet`,{plural:e}),clearSearch:!1,clearFilters:!1,create:i},Zr=(e,t)=>{},Qr=({windowMs:e=1e3,comebacks:t=2,onHold:n=Zr}={})=>{let r,i=[],a;return(o,s)=>{if(a?.among.has(o))return a.value;if(a&&(a=void 0,i=[]),o===r||(r=o,i=i.filter(t=>s-t.at<=e),i.push({value:o,at:s,comeback:i.some(e=>e.value===o)}),i.filter(e=>e.comeback).length<t))return o;let c=new Set(i.slice(-2*t).map(e=>e.value));return a={value:Math.min(...c),among:c},n(a.value,[...c]),a.value}},$r=e=>Math.max(1,Math.floor((e+12)/252)),ei=(e,t)=>Math.max(0,(e-(t-1)*12)/t),ti=(e,t,n,r)=>({start:e*n,end:Math.max(0,Math.min(r,(t+1)*n)-1)}),ni=(e,t,n)=>{let r=e/t.rowHeight;return t.columns===n.columns?r*n.rowHeight:Math.floor(Math.floor(r)*t.columns/n.columns)*n.rowHeight},ri=(e,t)=>{let n=e/t.rowHeight;return Math.floor(n)*t.columns+n%1},ii=(e,t)=>Math.floor(Math.floor(e)/t)+e%1,ai=8,oi=(e,t,n)=>{let r=e.get(t);if(r!==void 0&&r>=n)return e;let i=new Map(e);i.delete(t),i.set(t,n);for(let e of i.keys()){if(i.size<=ai)break;i.delete(e)}return i},si=({source:e,label:t,initialIndex:n,onScrollIndex:r,minHeight:i,children:a})=>{let{total:o}=e,[s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(0),u=$r(c),d=ei(c,u),[f,p]=(0,Z.useState)(()=>new Map),m=Math.ceil(Math.max(i(d),f.get(d)??0)),h=m+12,g={columns:u,rowHeight:h},_=(0,Z.useRef)({layout:g,top:0}),v=_.current.top>0&&(_.current.layout.columns!==u||_.current.layout.rowHeight!==h),y=e=>v?ni(_.current.top,_.current.layout,g):e,b=d>0&&f.has(d),x=nt({total:Math.ceil(o/u),rowHeight:h,initialIndex:ii(s,u),settle:y,ready:b,onScroll:e=>r(ri(e,g))});(0,Z.useLayoutEffect)(()=>{v&&x.scrollTo(x.top),_.current={layout:g,top:x.started()?x.top:0}});let S=ti(x.first,x.last,u,o),C=Qt({total:o,rowAt:e.rowAt,loadRows:e.loadRows,cachedRows:e.cachedRows,revision:e.revision,latencyMs:0},S.start,S.end),[w]=(0,Z.useState)(()=>Qr());(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(!e)return;let t=()=>l(w(e.clientWidth,performance.now())),n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[w]);let T=(0,Z.useRef)(d);T.current=d;let[E]=(0,Z.useState)(()=>new ResizeObserver(e=>{let t=Math.max(...e.map(e=>e.borderBoxSize[0]?.blockSize??e.contentRect.height)),n=T.current;p(e=>oi(e,n,t))}));(0,Z.useLayoutEffect)(()=>()=>E.disconnect(),[E]),(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(b||d===0||!e)return;let t=[...e.querySelectorAll(`:scope > li[aria-posinset]`)];if(t.length===0)return;let n=Math.max(...t.map(e=>e.getBoundingClientRect().height));p(e=>oi(e,d,n))});let D=(0,Z.useCallback)(e=>{if(e)return E.observe(e),()=>E.unobserve(e)},[E]);return(0,X.jsx)(`ul`,{ref:x.ref,className:`relative min-w-0 flex-auto`,"aria-label":t,style:{height:x.geometry.contentHeight},children:x.rows.flatMap(({index:e,offset:t})=>Array.from({length:u},(n,r)=>{let i=e*u+r;if(i>=o)return[];let s=C(i),c={top:t,left:r*(d+12),width:d,minHeight:m};return s?(0,X.jsx)(`li`,{ref:D,"aria-posinset":i+1,"aria-setsize":o,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:a(s)},s.id):(0,X.jsx)(`li`,{"aria-hidden":!0,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:(0,X.jsx)(L,{className:`h-full rounded-lg`})},`skeleton-${i}`)}))})},ci=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,li=e=>e*.75,ui=44,di=({model:e,view:t,display:n,list:i,empty:a})=>{let o=t?.names?.plural??r(e.name),s=n.card===void 0&&(n.image!==void 0||n.photos!==void 0);return i.isLoading?(0,X.jsx)(`div`,{"aria-busy":!0,className:`min-h-0 flex-1 overflow-hidden ${ci}`,children:Array.from({length:6},(e,t)=>(0,X.jsx)(L,{className:`h-24`},t))}):i.error?(0,X.jsx)(Me,{title:ke(`couldNotLoadRows`),error:i.error}):!i.source||i.source.total===0?a??(0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:ke(`noneMatch`,{plural:o.toLowerCase()})}):(0,X.jsx)(si,{source:i.source,label:o,initialIndex:i.initialIndex,onScrollIndex:i.onScrollIndex,minHeight:e=>(s?li(e):0)+ui,children:r=>(0,X.jsx)(Vt,{model:e,view:t,display:n,row:m(e,r)})})},fi=`protobase:list-places`,pi=50,mi=(e,t)=>`${e} ${t}`,hi=e=>{if(typeof e!=`object`||!e)return!1;let{entry:t,url:n,place:r}=e;return typeof t==`string`&&typeof n==`string`&&typeof r==`number`&&Number.isFinite(r)&&r>=0},gi=e=>ue(()=>{let t=e.getItem(fi);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(hi):[]},[]),_i=e=>{let t=new Map(gi(e).map(e=>[mi(e.entry,e.url),e]));return{placeOf:(e,n)=>{let r=t.get(mi(e,n));return r?r.place:[...t.values()].findLast(e=>e.url===n)?.place??0},save:(e,n,r)=>{let i=mi(e,n);t.delete(i),t.set(i,{entry:e,url:n,place:r});for(let e of[...t.keys()].slice(0,Math.max(0,t.size-pi)))t.delete(e)},persist:()=>ue(()=>e.setItem(fi,JSON.stringify([...t.values()])),void 0)}},vi={getItem:()=>null,setItem:()=>{}},yi,bi=()=>yi??=_i(ue(()=>window.sessionStorage,void 0)??vi),xi=()=>{let{entry:e,path:t,params:n}=P(),r=`${t}?${n.toString()}`,i=bi();(0,Z.useEffect)(()=>{let e=()=>i.persist(),t=()=>document.visibilityState===`hidden`&&i.persist();return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),i.persist()}},[i]);let a=(0,Z.useCallback)(t=>i.save(e,r,t),[i,e,r]);return{initialIndex:i.placeOf(e,r),remember:a}},Si=e=>e.reduce((e,t)=>e+t.count,0),Ci=e=>{let t=Math.floor(e.length/2),n=Si(e.slice(0,t)),r=Si(e.slice(e.length-t));return n===0?0:(r-n)/n*100},wi=j(`activity-chart`),Ti=({title:e,defaultGranularity:t=`day`,data:n,granularity:r,onGranularityChange:i,periodLabel:a,className:o})=>{let[s,c]=(0,Z.useState)(t),l=r??s,u=i??c,d=Ci(n),f=n.map(({at:e,count:t})=>({at:e,value:t,count:t}));return(0,X.jsxs)(`section`,{className:T(`rounded-lg border bg-background px-4 pb-2 pt-3`,o),children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e}),(0,X.jsx)(`span`,{className:`font-semibold tabular-nums`,children:E(Si(n))}),(0,X.jsxs)(`span`,{className:T(`text-xs font-medium tabular-nums`,d>=0?`text-success-text`:`text-danger-text`),children:[d>=0?`+`:`−`,Math.abs(d).toFixed(1),`%`]}),(0,X.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:a??`last ${l===`day`?`30 days`:`12 weeks`}`})]}),(0,X.jsx)(je,{value:l,onChange:u,options:[{value:`day`,label:wi(`day`)},{value:`week`,label:wi(`week`)}]})]}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(Lt,{points:f,measure:{kind:`count`},bucket:l,type:`bar`,compact:!0})})]})},Ei={"7d":`last 7 days`,"30d":`last 30 days`,"90d":`last 90 days`,"1y":`last year`,all:`all time`},Di=({resource:e,chart:t,title:n,filter:r})=>{let[i,a]=(0,Z.useState)(t.granularity===`week`?`week`:`day`),o=i===`week`?`90d`:t.range,s=Ce(e,{field:t.field,range:o,granularity:i,filter:r,timeZone:be()}).data?.points.map(e=>({at:Date.parse(`${e.bucket}Z`),count:e.count}))??[];return(0,X.jsx)(Ti,{title:n,data:s,granularity:i,onGranularityChange:a,periodLabel:i===`week`?`last 12 weeks`:Ei[o]})},Oi=(e,t,n)=>{let i=e.sum??e.average;if(i===void 0)return n;let a=t?.fields[i]?.label??r(i);return e.sum===void 0?y(`average`,{label:a}):`${a}`},ki=({model:e,view:t,chart:n,plural:i,filter:a})=>{let o=t?.fields[n.groupBy]?.label??r(n.groupBy);return(0,X.jsxs)(`section`,{className:`rounded-lg border bg-background px-4 pb-3 pt-3`,"aria-label":`${Oi(n,t,i)} by ${o.toLowerCase()}`,children:[(0,X.jsxs)(`h2`,{className:`mb-2 font-semibold`,children:[Oi(n,t,i),` by `,o.toLowerCase()]}),(0,X.jsx)(kt,{model:e,view:t,groupBy:n.groupBy,type:n.type,sum:n.sum,average:n.average,limit:n.limit,filter:a})]})},Ai=({value:e,onCommit:t,placeholder:n,className:r})=>{let[i,a]=(0,Z.useState)(e);return(0,Z.useEffect)(()=>a(e),[e]),(0,Z.useEffect)(()=>{if(i===e)return;let n=setTimeout(()=>t(i),350);return()=>clearTimeout(n)},[i,e,t]),(0,X.jsx)(W,{wrapperClassName:T(`min-w-0 flex-1 sm:w-72 sm:flex-initial`,r),leading:(0,X.jsx)(B,{className:`size-4`}),placeholder:n,"aria-label":Y(`search`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&t(i)})},ji=(e,t,n,i,a)=>{let o=n?.list?.relatedColumns??[];if(o.length===0)return e;let s=new Map(e.map(e=>[e.id,e]));return g(t,n).flatMap(e=>{let t=s.get(e);if(t)return[t];let n=o.find(t=>t.name===e),c=n&&i[n.resource];if(!n||!c)return[];let l=n.label??r(n.name);return[{id:n.name,header:l,kind:`text`,width:160,minWidth:Ke(l,!1),sortable:!1,render:e=>(0,X.jsx)(yt,{column:n,records:e[n.name]??[],target:c,view:a[c.name],Card:Vt})}]})},Mi=({model:e,view:t,target:n,children:i})=>{let a=ht(e.name,t.listOf,!0),o=t.names?.plural??r(e.name),s=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,X.jsx)(Zt,{title:o,subtitle:t.help}),e]});if(a.error)return s((0,X.jsx)(Me,{title:at(`couldNotLoadYour`,{plural:o.toLowerCase()}),error:a.error}));if(!a.data)return s((0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(L,{className:`h-24`},t))}));let c=Nt(n,a.data);return c?i(c):s((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:at(`noneYet`,{plural:o.toLowerCase()})}))},Ni=({title:e,chips:t,label:n,required:r,initial:i=``,busy:a,onSave:o,onClose:s})=>{let c=(0,Z.useId)(),[l,u]=(0,Z.useState)(i),d=`${c}-form`;return(0,X.jsx)(v,{open:!0,title:e,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{onClick:s,children:J(`cancel`)}),(0,X.jsx)(O,{type:`submit`,form:d,variant:`primary`,loading:a,children:J(`save`)})]}),children:(0,X.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o(l.trim()===``?null:l.trim())},children:[t.length>0&&(0,X.jsx)(wt,{chips:t}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:n}),!r&&(0,X.jsx)(`span`,{id:`${c}-hint`,className:`text-xs text-muted-foreground`,children:J(`optional`)})]}),(0,X.jsx)(W,{id:c,value:l,required:r,pattern:r?`.*\\S.*`:void 0,"aria-describedby":r?void 0:`${c}-hint`,autoFocus:!0,autoComplete:`off`,onChange:e=>u(e.target.value)})]})]})})},$=D(),Pi={start:0,end:0},Fi=(e,t)=>$.and(t,{kind:`present`,field:e.field,span:Pi}),Ii=e=>{switch(e.kind){case`and`:case`or`:return{...e,args:e.args.map(Ii)};case`not`:return Li(e.arg);case`search`:case`present`:case`isNull`:case`related`:return e;default:return Fi(e,e)}},Li=e=>{switch(e.kind){case`and`:return $.or(...e.args.map(Li));case`or`:return $.and(...e.args.map(Li));case`not`:return Ii(e.arg);case`search`:case`present`:case`isNull`:case`related`:return $.not(e);default:return Fi(e,$.not(e))}},Ri=e=>{let t=Xe(e);if(!t.ok)throw Error(`The filter cannot be read: ${t.errors.map(e=>e.message).join(`; `)}`);return t.ast},zi=e=>e.kind===`and`||e.kind===`or`?e.args.some(zi):e.kind===`not`?zi(e.arg):e.kind===`related`,Bi=(e,t)=>![Ri(e),Ri(t)].some(e=>e&&zi(e)),Vi=(e,t)=>{let n=Ri(e);if(!n)return null;let r=Ri(t),i=$.not(Ii(n));return d(r?$.and(r,i):i)},Hi=(e,t)=>Vi(t,e),Ui=e=>e.key.startsWith(`extra:`)?`extra:${e.label}`:e.key,Wi=(e,t)=>{let n=new Map(e.map(e=>[Ui(e),e])),r=new Map(t.map(e=>[Ui(e),e])),i=e.filter(e=>!r.has(Ui(e))).map(e=>({kind:`removed`,label:e.label})),a=t.flatMap(e=>{let t=n.get(Ui(e));return t&&t.label!==e.label?[{kind:`changed`,label:e.label,before:t.label}]:[]}),o=t.filter(e=>!n.has(Ui(e))).map(e=>({kind:`added`,label:e.label}));return[...i,...a,...o]},Gi=(e,t,n,r)=>{let i=e-t;if(i===0)return J(`asMany`,{plural:r});let a=Math.abs(i)===1?n:r;return i>0?J(`more`,{count:i,noun:a}):J(`fewer`,{count:-i,noun:a})},Ki=12,qi={added:{word:`added`,className:`text-success-text`},removed:{word:`removed`,className:`text-danger-text`},changed:{word:`changed`,className:`text-primary-text`}},Ji=({changes:e})=>(0,X.jsx)(`ul`,{"aria-label":J(`filterChanges`),className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`grid grid-cols-[72px_1fr] gap-3 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`font-medium ${qi[e.kind].className}`,children:J(qi[e.kind].word)}),e.kind===`changed`?(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,X.jsx)(`span`,{className:`font-medium`,children:e.label})]}):(0,X.jsx)(`span`,{className:e.kind===`removed`?`text-muted-foreground line-through`:`font-medium`,children:e.label})]},`${e.kind}:${e.label}`))}),Yi=(e,t)=>{let n=et({...He(H(),e,t??``),enabled:t!==null});return t===null?0:n.data},Xi=(e,t,n)=>`${e} ${e===1?t:n}`,Zi=({model:e,view:t,title:n,filter:r,total:i,plural:a})=>{let o=t?.list?.displays?.find(e=>e.kind===`cards`);return(0,X.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`h3`,{className:`font-semibold`,children:[n,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,i??`…`,`)`]})]}),i!==void 0&&i>Ki&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`firstOf`,{limit:Ki,total:i})}),r===null||i===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noPlural`,{plural:a})}):(0,X.jsx)(Ft,{model:e,view:t,filter:r,sort:Ee(e,t),limit:Ki,display:o?.name??`table`,row:!0,link:!1,empty:`No ${a}.`})]})},Qi=({model:e,view:t,before:n,after:i})=>{let a=(0,Z.useMemo)(()=>Vi(n,i),[n,i]),o=(0,Z.useMemo)(()=>Hi(n,i),[n,i]),s=Yi(e,a),c=Yi(e,o),l=(t?.names?.singular??r(e.name)).toLowerCase(),u=(t?.names?.plural??r(e.name)).toLowerCase();return(0,X.jsxs)(X.Fragment,{children:[s!==void 0&&c!==void 0?(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-semibold`,children:Gi(s,c,l,u)}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,J(`addedRemoved`,{added:Xi(s,l,u),removed:c})]})]}):(0,X.jsx)(L,{className:`h-4 w-48`}),(0,X.jsx)(Zi,{model:e,view:t,title:J(`added`),filter:a,total:s,plural:u}),(0,X.jsx)(Zi,{model:e,view:t,title:J(`removed`),filter:o,total:c,plural:u})]})},$i=({model:e,view:t,title:n,before:r,after:i,saveNewLabel:a,updating:o,creating:s,onUpdate:c,onSaveNew:l,onCancel:u})=>{let d=Wi(rt(e,r),rt(e,i));return(0,X.jsx)(v,{open:!0,wide:!0,title:n,onClose:u,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{onClick:u,children:J(`cancel`)}),(0,X.jsx)(O,{loading:s,disabled:o,onClick:l,children:a}),(0,X.jsx)(O,{variant:`primary`,loading:o,disabled:s,onClick:c,children:J(`update`)})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d.length>0&&(0,X.jsx)(Ji,{changes:d}),Bi(r,i)?(0,X.jsx)(Qi,{model:e,view:t,before:r,after:i}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noRecordsDiff`)})]})})},ea=()=>{let{address:e,set:t}=x();return{key:e?.kind===`list`?e.savedSearch:void 0,open:e=>t({savedSearch:e})}},ta=e=>e instanceof Error?e.message:J(`somethingWrong`),na=(e,t)=>{let n=de(),i=H(),a=z(),o=U(),{href:s,open:c}=x(),l=ea(),{resource:u}=e,d=n.resources[u],f=n.views[u]?.searchesOf,p=n.permissions[u],m=d!==void 0&&f!==void 0&&p!==void 0&&k(p,`create`)&&k(p,`delete`),h=n.signIn?.[u]?.signIn,g=Tt(u,m),_=e=>V(M(d,e)),v=f&&g.data?.find(e=>e[f.filter]===t),y=v||l.key===void 0||!p||!k(p,`update`)?void 0:g.data?.find(e=>_(e)===l.key),b=n.views[u]?.names,S=b?.plural??`saved searches`,C=f?.name===void 0?void 0:d?.fields[f.name],w=G({mutationFn:e=>i.create(u,{[f.filter]:t,...f.name&&{[f.name]:e}}),onSuccess:e=>{l.open(_(e.record)),a.show({state:`success`,title:J(`searchSaved`),action:{label:J(`openPlural`,{plural:S}),href:s({kind:`list`,resource:u}),onNavigate:c}})},onError:e=>a.show({state:`error`,title:J(`couldNotSave`),description:ta(e)}),onSettled:()=>o(u)}),T=G({mutationFn:e=>i.remove(u,_(e)),onError:e=>a.show({state:`error`,title:J(`couldNotTakeOff`),description:ta(e)}),onSettled:()=>o(u)}),E=G({mutationFn:e=>i.update(u,_(e),{[f.filter]:t},e.etag??`*`),onSuccess:()=>a.show({state:`success`,title:J(`searchUpdated`)}),onError:e=>a.show({state:`error`,title:J(`couldNotUpdate`),description:ta(e)}),onSettled:()=>o(u)}),D=w.isPending||T.isPending||E.isPending;return{mode:m?`save`:h?`sign-in`:void 0,prompt:h,saved:v!==void 0,opened:y&&{filter:String(y[f.filter]??``),name:f.name&&typeof y[f.name]==`string`&&y[f.name]!==``?String(y[f.name]):void 0},noun:(b?.singular??r(u)).toLowerCase(),naming:C&&{label:n.views[u]?.fields[C.name]?.label??r(C.name),required:!C.nullable},ready:g.data!==void 0&&!D,updating:E.isPending,creating:w.isPending,remove:()=>v&&T.mutate(v),saveNew:(e,t)=>w.mutate(e,t),update:e=>y&&E.mutate(y,e)}},ra=({model:e,view:t,search:n,filter:r,chips:i,className:a})=>{let o=na(n,r),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)();if(!o.mode)return null;let m=n.label??J(`saveSearch`);if(o.mode===`sign-in`)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:[(0,X.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),m]}),(0,X.jsx)(f,{as:`dialog`,prompt:o.prompt,open:s,onClose:()=>c(!1)})]});let h=e=>{u(!1),o.naming?p(e):o.saveNew(null)},g=d!==void 0&&o.naming&&(0,X.jsx)(Ni,{title:d,chips:i,label:o.naming.label,required:o.naming.required,busy:o.creating,onSave:e=>o.saveNew(e,{onSuccess:()=>p(void 0)}),onClose:()=>p(void 0)}),_=o.opened;if(_){let n=J(`saveAsNew`,{noun:o.noun});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-haspopup":`dialog`,"aria-disabled":!o.ready,onClick:()=>o.ready&&u(!0),children:[(0,X.jsx)(_n,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`max-w-60 truncate`,children:J(`updateName`,{name:_.name??o.noun})})]}),(0,X.jsxs)(O,{className:a,"aria-haspopup":o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&h(n),children:[(0,X.jsx)(pn,{className:`size-3.5`,"aria-hidden":!0}),n]}),l&&(0,X.jsx)($i,{model:e,view:t,title:_.name?J(`updateNameQuestion`,{name:_.name}):J(`updateNounQuestion`,{noun:o.noun}),before:_.filter,after:r,saveNewLabel:n,updating:o.updating,creating:o.creating,onUpdate:()=>o.update({onSuccess:()=>u(!1)}),onSaveNew:()=>h(n),onCancel:()=>u(!1)}),g]})}let v=o.saved?dn:Te;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-pressed":o.saved,"aria-haspopup":!o.saved&&o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&(o.saved?o.remove():h(m)),children:[(0,X.jsx)(v,{className:o.saved?`size-3.5 text-primary`:`size-3.5`,"aria-hidden":!0}),m]}),g]})},ia=e=>e instanceof Error?e.message:J(`somethingWrong`),aa=({model:e,view:t,name:n,value:i,onChange:a})=>{let o=(0,Z.useId)(),s=e.fields[n],c=t.fields[n],l=c?.label??r(n);if(s?.type===`boolean`)return(0,X.jsx)(C,{checked:i===!0,onChange:a,label:l});if(s?.type!==`enum`)throw Error(`Not implemented: "${n}" is ${s?.type??`unknown`}, and a saved search's controls are enums or booleans`);return(0,X.jsxs)(`label`,{htmlFor:o,className:`flex items-center gap-2 text-muted-foreground`,children:[l,(0,X.jsx)(`select`,{id:o,value:String(i??``),onChange:e=>a(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2 text-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,children:(s.enumValues??[]).map(e=>(0,X.jsx)(`option`,{value:e,children:ae(e,c?.valueLabels)},e))})]})},oa=(e,t,n)=>Object.entries(n).map(([n,i])=>`${t.fields[n]?.label??r(n)}: ${e.fields[n]?.type===`boolean`?J(i===!0?`on`:`off`):ae(String(i),t.fields[n]?.valueLabels)}`).join(`, `),sa=({model:e,view:t,recordKey:n,title:r,row:i,fields:a})=>{let o=H(),s=z(),c=U(),l=G({mutationFn:t=>o.update(e.name,n,t,i.etag??`*`),onSuccess:(n,i)=>s.show({state:`success`,title:J(`saved`,{title:r}),description:oa(e,t,i)}),onError:e=>s.show({state:`error`,title:J(`couldNotChange`),description:ia(e)}),onSettled:()=>c(e.name)});return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:a.map(n=>(0,X.jsx)(aa,{model:e,view:t,name:n,value:l.isPending&&n in(l.variables??{})?l.variables[n]:i[n],onChange:e=>l.mutate({[n]:e})},n))})},ca=e=>e instanceof Error?e.message:J(`somethingWrong`),la=({model:e,view:t,of:n,target:i,targetView:a,row:o,recordKey:s,canRename:c,onDelete:l})=>{let u=H(),d=z(),f=U(),[p,m]=(0,Z.useState)(!1),{name:g,chips:_,title:v,body:y}=Ut({model:e,of:n,target:i,targetView:a,row:o,recordKey:s}),b=G({mutationFn:t=>u.update(e.name,s,{[n.name]:t},o.etag??`*`),onSuccess:()=>m(!1),onError:e=>d.show({state:`error`,title:J(`couldNotRename`),description:ca(e)}),onSettled:()=>f(e.name)}),x=n.name===void 0?void 0:e.fields[n.name];return(0,X.jsxs)(`section`,{"aria-label":v,className:`flex flex-col gap-3 rounded-lg border bg-surface p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,X.jsx)(h,{to:{kind:`record`,resource:e.name,key:s},className:`hover:underline`,children:g??(0,X.jsx)(Ct,{chips:_})})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.controls&&(0,X.jsx)(sa,{model:e,view:t,recordKey:s,title:v,row:o,fields:n.controls}),c&&x&&(0,X.jsx)(O,{variant:`ghost`,"aria-label":J(`renameTitle`,{title:v}),"aria-haspopup":`dialog`,onClick:()=>m(!0),children:(0,X.jsx)(Gt,{className:`size-3.5`,"aria-hidden":!0})}),l&&(0,X.jsx)(O,{variant:`ghost`,"aria-label":J(`deleteTitle`,{title:v}),onClick:()=>l(v),children:(0,X.jsx)(Xt,{className:`size-3.5`,"aria-hidden":!0})})]})]}),p&&x&&(0,X.jsx)(Ni,{title:J(`renameTitle`,{title:v}),chips:_,label:t.fields[x.name]?.label??r(x.name),required:!x.nullable,initial:g,busy:b.isPending,onSave:e=>b.mutate(e),onClose:()=>m(!1)}),(0,X.jsx)(Ht,{...y})]})},ua=({model:e,view:t})=>{let{resources:n,views:i}=de(),a=t.searchesOf,o=n[a.resource],s=i[a.resource],c=Tt(e.name,!0),l=he(e.name),u=Kt({model:e,view:t}),d=t.names?.plural??r(e.name),f=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[u.dialogs,(0,X.jsx)(Zt,{title:d,subtitle:t.help}),e]});if(!o)return f((0,X.jsx)(pe,{title:J(`notFound`),children:J.rich(`noResource`,{resource:a.resource})}));if(c.error)return f((0,X.jsx)(Me,{title:J(`couldNotLoadYour`,{plural:d.toLowerCase()}),error:c.error}));if(!c.data)return f((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,X.jsx)(L,{className:`h-56`},t))}));if(c.data.length===0){let e=(s?.names?.plural??r(o.name)).toLowerCase();return f((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:J.rich(`noSavedYet`,{plural:d.toLowerCase(),list:(0,X.jsx)(h,{to:{kind:`list`,resource:o.name},className:`font-medium text-primary-text hover:underline`,children:e})})}))}return f((0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c.data.map(n=>{let r=V(M(e,n)),i=k(l,`delete`)?e=>void u.start({key:r,title:e,etag:n.etag,snapshot:n}):void 0;return(0,X.jsx)(la,{model:e,view:t,of:a,target:o,targetView:s,row:n,recordKey:r,canRename:k(l,`update`),onDelete:i},r)})}))},da=({field:e,hints:t,resource:n,stored:r,onSave:i,close:a})=>{let[o,s]=(0,Z.useState)(()=>ne(e,r)),l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=!t?.widget&&(e.type===`boolean`||e.type===`enum`);(0,Z.useEffect)(()=>{l.current?.querySelector(`input, select, textarea, button, [tabindex]`)?.focus()},[]);let f=(t,n,s=o)=>{u.current||(u.current=!0,t&&c(e,s,r)&&i(we(e,s)),a(n))};return(0,X.jsx)(`div`,{ref:l,className:`w-full min-w-0`,onKeyDown:e=>{se(e.target)||(e.key===`Enter`?(e.preventDefault(),f(!0)):e.key===`Tab`?(e.preventDefault(),f(!0,e.shiftKey?-1:1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(!1)))},onBlur:e=>{!l.current?.contains(e.relatedTarget)&&!se(e.relatedTarget)&&f(!0)},children:(0,X.jsx)(_e,{field:e,hints:t,value:o,stored:r,resource:n,onChange:e=>{s(e),d&&f(!0,void 0,e)}})})},fa=j(`app/list-edit`),pa=e=>{let t=H(),n=$e(),r=z(),[i,a]=(0,Z.useState)(new Map),s=(0,Z.useRef)(i),c=(0,Z.useRef)(new Map),l=(e,t)=>{s.current=new Map(s.current).set(e,{...s.current.get(e),...t}),a(s.current)},u=async(i,a,c)=>{let u=M(e,i),d=String(s.current.get(i.id)?.etag??i.etag);try{let r=await t.update(e.name,u,{[a]:c},d);l(i.id,{[a]:r.record[a],etag:r.etag}),n.setQueryData(o.record(e.name,V(u)),r),n.invalidateQueries({queryKey:[`page`,e.name]}),n.invalidateQueries({queryKey:[`list`,e.name]}),n.invalidateQueries({queryKey:[`map`,e.name]}),n.invalidateQueries({queryKey:[`count`,e.name]})}catch(n){if(!S(n))throw l(i.id,{[a]:i[a]}),n;let o=n.status===412,s=o?await t.get(e.name,u):void 0;l(i.id,s?{[a]:s.record[a],etag:s.etag}:{[a]:i[a]});let c=n.errors.find(e=>e.field===a)?.message??n.message;r.show({state:`error`,title:fa(o?`changedBySomeoneElse`:`couldNotSave`),description:c})}};return{patches:i,save:(e,t,n)=>{l(e.id,{[t]:n});let r=(c.current.get(e.id)??Promise.resolve()).then(()=>u(e,t,n));return c.current.set(e.id,r.catch(()=>void 0)),r}}},ma=(e,t,n)=>{let r=pa(e),i=t?.list?.editable??[];return{editor:i.length>0&&k(n,`update`)?{editable:(t,n)=>i.includes(n)&&e.fields[n]!==void 0&&ce(e.fields[n])&&Ge(t,`update`),render:(n,i,a)=>(0,X.jsx)(da,{field:e.fields[i],hints:t?.fields[i],resource:e.name,stored:n[i],onSave:e=>void r.save(n,i,e),close:a})}:void 0,patches:r.patches}},ha=D(),ga=e=>e.find(e=>e.kind===`search`),_a=({address:e})=>{let{resources:t,views:n,signIn:i}=de(),a=t[e.resource],o=i?.[e.resource];if(!a)return o?(0,X.jsx)(f,{as:`page`,prompt:o.signIn}):(0,X.jsx)(pe,{title:y(`notFound`),children:y(`noResource`,{name:e.resource})});let c=Be(n[e.resource],e.list);if(e.list!==void 0&&!c)return(0,X.jsx)(pe,{title:y(`notFound`),children:Y(`noList`,{name:e.list})});if(c?.searchesOf)return(0,X.jsx)(ua,{model:a,view:c});let l=s(t,n,e.resource,e.list);if(c&&l.listOf){let t=l.model;return(0,X.jsx)(Mi,{model:a,view:c,target:t,children:n=>(0,X.jsx)(va,{model:t,address:e,scope:n,heading:{title:c.names?.plural??r(a.name),subtitle:c.help}})})}return(0,X.jsx)(va,{model:a,address:e})},va=({model:e,address:t,scope:n,heading:o})=>{let s=de(),{set:c,listTo:l,go:u,href:d}=x(),f=e.name,p=Be(s.views[f],t.list),_=(0,Z.useMemo)(()=>st(p,e),[p,e]),{fields:v}=re(),y=(0,Z.useMemo)(()=>ji(le(De(Ie(e,p),e,p,v),e,s.resources,s.views),e,p,s.resources,s.views),[e,p,v,s.resources,s.views]),b=t.filter,S=(0,Z.useMemo)(()=>ft(_,b),[_,b]),C=S.ok?S.state:Wt,w=S.ok?S.extras:[],{orderBy:T,filterLayout:E}=t,D=te(),ee=ie(),[ne,ae]=(0,Z.useState)(!1),oe=n?[...w,n]:w,se=Ye(),ce=jr({model:e,resources:s.resources,views:s.views,view:p,state:C,extras:oe,titleOf:se}),A=n?ut(_,C,oe):S.ok?b:``,j=(0,Z.useMemo)(()=>ge(e,p,y.map(e=>e.id)),[e,p,y]),ue=(0,Z.useMemo)(()=>ot(p,s.resources,s.views,j),[p,s.resources,s.views,j]),N=$t({resources:s.resources,views:s.views,model:e,columns:j,filter:A,orderBy:T,related:ue}),P=Pe(e,p,t.display),F=he(f),I=n?void 0:nn(e,F),[pe,L]=(0,Z.useState)(!1),R=pe&&I!==void 0,_e=!P&&!R&&tn(p,I,T,A),ye=R||P?.kind!==`map`;Se(ye);let be=rn(e,N.page,N.key,P?.kind===`custom`),z=xi(),Ce=me(e,p),we=e=>({key:e.id,title:String(typeof e[Ce]==`object`?e[Ce].name:e[Ce]??e.id),etag:typeof e.etag==`string`?e.etag:void 0,snapshot:e}),Te=p?.names?.singular??r(f),Ee=ma(e,p,F),{state:Oe}=Ue(),ke=Jt(e),Ae=Kt({model:e,view:p,restore:ke,onReview:e=>u({kind:`record`,resource:f,key:e.key})}),je=jt(e),Ne=p?.actions.some(e=>e.run?.kind===`delete`)??!1,B=(e,t=w)=>c({filter:ut(_,e,t)}),Re=ga(w),ze=e=>{let t=w.filter(e=>e.kind!==`search`);B(C,e?[...t,ha.search(e)]:t)},V=p?.names?.plural??r(f),H=P?.kind===`calendar`||P?.kind===`timeline`||P?.kind===`board`&&Fe(e)?void 0:P,He=H&&(0,X.jsx)(Et,{model:e,view:p,display:H,orderBy:T,onChange:e=>c({orderBy:e})}),U=e.search?.length?(0,X.jsx)(Ai,{value:Re?.kind===`search`?Re.text:``,onCommit:ze,placeholder:Y(`searchPlural`,{plural:V}),className:D?void 0:`min-h-11`}):null,We=(0,X.jsx)(Yn,{layout:E,config:ce,value:C,onChange:B,leading:E===`bar`?He:void 0,trailing:U}),Ke=E===`bar`?We:(0,X.jsx)(qn,{groups:[He?[He]:[]],trailing:U}),W=vt(ce,C),Xe=(0,X.jsx)(Dn,{scroll:!0,chips:W,onRemove:e=>B(lt(C,e)),onClear:()=>B(Wt)}),Ze=H&&(0,X.jsx)(Pn,{title:Y(`sort`),children:(0,X.jsx)(Et,{model:e,view:p,display:H,orderBy:T,onChange:e=>c({orderBy:e}),className:`min-h-11 w-full`})}),Qe=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(O,{className:`min-h-11`,onClick:()=>ae(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(yn,{className:`size-3.5`}),W.length>0?Y(`filtersCount`,{count:W.length}):Y(`filters`)]}),U??(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:Xe})]}),U&&Xe,(0,X.jsx)(Le,{title:Y(`filters`),open:ne,onClose:()=>ae(!1),children:(0,X.jsx)(Yn,{layout:`panel`,fullWidth:!0,config:ce,value:C,onChange:B,leading:Ze})})]}),$e=!n&&qe(p,s.pages,F)&&(0,X.jsxs)(h,{to:{kind:`create`,resource:f},className:i({variant:`primary`}),children:[(0,X.jsx)(Ve,{className:`size-3.5`}),Y(`newRecord`,{singular:Te})]}),G=p?.saveSearch&&!n&&S.ok&&b&&(0,X.jsx)(ra,{model:e,view:p,search:p.saveSearch,filter:b,chips:pt(e,p,b,Mt(ce))}),et=!n&&(0,X.jsx)(Pr,{model:e}),K=Jr({model:e,view:p,resources:s.resources,views:s.views,plural:V,filter:A,orderBy:T}),nt=ir(p)&&(0,X.jsxs)(O,{onClick:()=>K.open(),...!D&&{"aria-label":Y(`export`),title:Y(`export`)},children:[(0,X.jsx)(Je,{className:`size-3.5`}),D&&Y(`export`)]}),rt=I&&!_e&&(0,X.jsx)(Yt,{sorting:R,onChange:L,iconOnly:!D}),it=t=>!R&&(0,X.jsx)(zt,{view:p,choices:fe(e,p,ee),value:P?.name??`table`,onChange:e=>c({display:e}),menu:t}),at=en(e),ct=t=>{at(m(e,t).record),u({kind:`record`,resource:f,key:M(e,t)})},q=async e=>{let t=e.map(we),n=await Ae.startBulk(t);return e.filter((e,r)=>n.includes(t[r]))},dt=N.source?(0,X.jsx)(_t,{columns:y,source:N.source,sort:a(T),onSortChange:e=>c({orderBy:xe(e)}),onOpenRow:ct,rowLink:t=>({href:d({kind:`record`,resource:f,key:M(e,t)}),onFollow:()=>ct(t)}),cellEditor:Ee.editor,rowPatches:Ee.patches,initialScrollIndex:z.initialIndex,onScrollIndex:z.remember,rowActions:[{label:Y(`openRecord`,{singular:Te}),onSelect:ct},...je.rowActions,...k(F,`delete`)&&!Ne?[{label:Y(`delete`),destructive:!0,available:e=>Ge(e,`delete`),onSelect:e=>void Ae.start(we(e))}]:[]],bulkActions:[...ir(p)&&ur(e)?[{label:e=>Y(`exportCount`,{count:e}),onRun:e=>K.open(e)}]:[],...je.bulkActions,...k(F,`delete`)?[{label:e=>Y(`deleteCount`,{count:e}),destructive:!0,onRun:e=>q(e)}]:[]],rowNumbers:!1,pinKey:Oe.kind===`signed-in`?Dt(Oe.user.id,ve(f,t.list)):void 0,scroll:`parent`,className:`flex-1`}):(0,X.jsx)(`div`,{"aria-busy":!0,className:`flex-1 rounded-lg border bg-surface`}),mt={...N,initialIndex:z.initialIndex,onScrollIndex:z.remember},ht=Xr({plural:V,search:Re?.kind===`search`?Re.text:``,filtered:W.length>0,scoped:!!n||w.some(e=>e.kind!==`search`),canCreate:!!$e}),gt=(0,X.jsx)(Yr,{state:ht,onClearSearch:()=>ze(``),onClearFilters:()=>B(Wt),create:$e}),yt=R?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`dragToSort`)}),(0,X.jsx)(qt,{model:e,view:p,field:I,filter:``,columns:g(e,p)})]}):_e?(0,X.jsx)(qt,{model:e,view:p,field:I,filter:``,columns:g(e,p),sort:{value:a(T),onChange:e=>c({orderBy:xe(e)})}}):P?P.kind===`cards`?(0,X.jsx)(di,{model:e,view:p,display:P,list:mt,empty:gt},N.key.join(` `)):P.kind===`map`?(0,X.jsx)(At,{model:e,view:p,display:P,filter:A,orderBy:T,fields:j,at:t.map,onMove:e=>c({map:e}),flush:!0}):P.kind===`board`?(0,X.jsx)(Ot,{model:e,view:p,display:P,fields:j,filter:A,orderBy:T}):P.kind===`calendar`?(0,X.jsx)(It,{model:e,view:p,display:P,fields:j,filter:A,at:t.calendar,linkTo:e=>l({calendar:e})}):P.kind===`timeline`?(0,X.jsx)(Pt,{model:e,view:p,display:P,fields:j,filter:A,at:t.timeline,linkTo:e=>l({timeline:e})}):(0,X.jsx)(Bt,{display:P,list:be}):N.source?.total===0&&!N.error?gt:dt;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[Ae.dialogs,K.dialogs,je.prompt,(0,X.jsx)(Zt,{title:o?.title??V,subtitle:o?o.subtitle:p?.help,subtitleBelow:!0,actions:(0,X.jsxs)(X.Fragment,{children:[it(!D),rt,G,et,nt,$e]})}),!S.ok&&(0,X.jsx)(Me,{title:Y(`unreadableFilter`),error:Error(S.errors.map(e=>e.message).join(`; `))}),N.error&&!P&&!R&&(0,X.jsx)(Me,{title:Y(`couldNotLoadRows`),error:N.error}),p?.chart&&!R&&(tt(p.chart)?(0,X.jsx)(ki,{model:e,view:p,chart:p.chart,plural:V,filter:A}):(0,X.jsx)(Di,{resource:f,chart:p.chart,title:Y(`created`,{plural:V}),filter:A})),!R&&(D?Ke:Qe),D&&E===`panel`&&!R?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,X.jsx)(`div`,{className:ye?`sticky top-[calc(var(--pb-sticky-top,0px)+1rem)] flex max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px)-2rem)] shrink-0 self-start`:`flex shrink-0`,children:We}),yt]}):yt]})};export{_a as ListPage,br as a,gr as c,pr as d,fr as f,ln as h,xr as i,mr as l,Q as m,Cr as n,_r as o,lr as p,Sr as r,yr as s,Tr as t,hr as u};
|
|
4
|
-
//# debugId=
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/import-dialog-BppJUUoF.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-DKn-6fgf.js","assets/vendor-t7Q7QbPu.js","assets/app-Dq5eubgK.css","assets/sheet-source-CAIVzfnw.js","assets/import-table-dialog-cfWZMJfg.js","assets/export-dialog-CMPyzZa3.js","assets/embedded-list-CG1SyUtd.js","assets/update-set-DPSGWrcI.js","assets/layout-grid-IdJUsNk6.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-BUnzkT7g.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"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,$s as i,Ai as a,Bc as o,Br as s,C as c,Dc as l,Ec as u,Fl as d,Ft as f,Gn as p,Gr as m,Ir as h,Jc as g,Jn as _,Ki as v,Ks as y,Li as b,Lr as x,Ls as S,M as C,Mc as w,Nc as T,Ni as E,Nl as D,Nn as ee,No as te,O as ne,Oa as re,Po as ie,Qc as ae,Qs as O,Ri as oe,S as se,Sa as k,T as ce,Tn as le,Uc as A,Vc as j,Vi as M,Vl as ue,Wn as N,Ws as P,Xo as de,Xr as fe,Ya as F,Yc as I,Yo as pe,Ys as L,Zc as me,Zo as he,Zr as ge,_o as R,b as _e,ba as ve,bo as ye,da as be,ja as z,ji as xe,jo as Se,jr as Ce,k as we,kc as Te,ki as Ee,kn as De,kt as Oe,li as ke,lt as Ae,mo as je,mr as Me,nc as Ne,ni as Pe,oc as B,oi as Fe,pi as Ie,po as Le,qn as Re,rc as ze,rl as V,rs as H,sl as Be,uc as Ve,un as He,us as Ue,vn as U,vo as We,wa as Ge,wi as Ke,xa as qe,xo as W,yc as Je,zi as Ye,zl as Xe}from"./app-DKn-6fgf.js";import{C as Ze,f as Qe,h as $e,i as G,o as et,s as K}from"./vendor-t7Q7QbPu.js";import{n as tt}from"./view-chart-ChBtewKd.js";import{$ as nt,A as rt,B as it,D as at,E as ot,F as st,G as ct,H as lt,I as ut,J as q,K as dt,L as ft,M as pt,N as mt,O as ht,P as gt,Q as _t,R as vt,T as yt,U as bt,V as xt,W as St,X as Ct,Y as wt,Z as J,b as Tt,d as Et,et as Dt,f as Ot,ft as kt,h as At,i as jt,j as Mt,k as Nt,m as Pt,n as Ft,p as It,pt as Lt,q as Rt,u as zt,v as Bt,w as Vt,x as Ht,xt as Y,y as Ut,z as Wt}from"./embedded-list-CG1SyUtd.js";import{a as Gt,i as Kt,n as qt,r as Jt,t as Yt}from"./reorder-button-q4oqy3UR.js";import{t as Xt}from"./trash-DJwJPifF.js";import{t as Zt}from"./page-header-Ddz2r5ic.js";import{i as Qt,r as $t,t as en}from"./record-preview-BUnzkT7g.js";import{c as tn,l as nn}from"./messages-CjRWJI05.js";import{t as rn}from"./use-display-rows-DFSNvNWx.js";var an=new Set(`all.analyse.analyze.and.any.array.as.asc.asymmetric.both.case.cast.check.collate.column.constraint.create.current_catalog.current_date.current_role.current_time.current_timestamp.current_user.default.deferrable.desc.distinct.do.else.end.except.false.fetch.for.foreign.from.grant.group.having.in.initially.intersect.into.lateral.leading.limit.localtime.localtimestamp.not.null.offset.on.only.or.order.placing.primary.references.returning.select.session_user.some.symmetric.system_user.table.then.to.trailing.true.union.unique.user.using.variadic.when.where.window.with`.split(`.`)),on=/^[a-z][a-z0-9_]*$/,sn=[`id`,`etag`,`organization_id`],cn=e=>on.test(e)&&new TextEncoder().encode(e).length<=63,ln=(e,t,n=63)=>{if(typeof e!=`string`||!cn(e)||new TextEncoder().encode(e).length>n)return`form`;if(an.has(e))return`reserved_word`;if(t===`field`&&sn.includes(e))return`reserved_field`},un={name:`bookmark-check`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]};un.node;var dn=w(un),fn={name:`bookmark-plus`,size:24,node:[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};fn.node;var pn=w(fn),mn={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};mn.node;var hn=w(mn),gn={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};gn.node;var _n=w(gn),vn={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};vn.node;var yn=w(vn),bn=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``),xn=(e,t,n)=>(/^[a-z]/.test(e)?e:`${t}_${e}`).slice(0,n).replace(/_+$/,``),Sn=(e,t,n)=>{let r=e;for(let i=2;t.has(r)||an.has(r);i++){let t=`_${i}`;r=`${e.slice(0,n-t.length).replace(/_+$/,``)}${t}`}return r},Cn=e=>e<26?String.fromCharCode(97+e):Cn(Math.floor(e/26)-1)+Cn(e%26),wn=e=>{let t=new Set(sn);return e.map((e,n)=>{let r=bn(e),i=Sn(r===``?`column_${Cn(n)}`:xn(r,`column`,63),t,63);return t.add(i),i})},Tn=(e,t=[],n=63)=>{let r=bn(e.replace(/\.(csv|tsv|txt|xlsx|json)$/i,``));if(r!==``)return Sn(xn(r,`table`,n),new Set(t),n)},X=e(n(),1),En=`inline-flex h-6 items-center gap-1 rounded-full border border-primary-border bg-primary-soft pl-2.5 pr-1.5 text-xs font-medium text-primary-text`,Dn=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,X.jsxs)(`div`,{className:i?`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1 [&>*]:shrink-0`:`flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full border border-border-strong bg-muted px-2.5 text-xs font-medium text-foreground`,children:[(0,X.jsx)(hn,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,X.jsxs)(`span`,{className:En,children:[e.label,(0,X.jsx)(`button`,{type:`button`,"aria-label":q(`remove`,{label:e.label}),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,X.jsx)(Ne,{className:`size-3`})})]},e.key)),e.length>0&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:q(`clearAll`)})]}),On=({value:e,presets:t=Rt,onChange:n})=>(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=dt(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:q(`unknownPreset`,{id:t}),onClick:()=>n(e===t?void 0:t),className:T(`h-7 rounded-md border px-2.5 text-body font-medium transition-colors`,!r&&`border-dashed text-danger-text`,e===t?`border-primary-border bg-primary-soft text-primary-text`:`border-border-strong bg-background text-muted-foreground hover:bg-muted`),children:r??q(`unsupported`,{id:t})},t)})}),kn=(e,t)=>e.onSearch?e.options:e.options.filter(e=>xt(e.label,t)),An=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,Z=e(t(),1),jn=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,Z.useId)(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(-1),p=r||c,m=kn(e,o),h=(0,Z.useRef)(e.onSearch);h.current=e.onSearch,(0,Z.useEffect)(()=>()=>h.current?.(``),[]);let g=t=>{s(t),f(-1),e.onSearch?.(t)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-8 cursor-text flex-wrap items-center gap-1 rounded-md border border-border-strong bg-background px-2 py-1 shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,onClick:()=>a.current?.focus(),children:[(0,X.jsx)(B,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,X.jsx)(ee,{label:it(e,t),onRemove:()=>n(t)},t)),(0,X.jsx)(`input`,{ref:a,autoFocus:r,role:`combobox`,"aria-label":e.label,"aria-expanded":p,"aria-controls":`${i}-options`,"aria-autocomplete":`list`,"aria-activedescendant":m[d]?`${i}-${d}`:void 0,placeholder:t.length>0?``:q(`searchIn`,{label:e.label}),className:`h-6 min-w-16 flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground`,value:o,onChange:e=>g(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),f(An(d,m.length,e.key));return}if(e.key===`Enter`&&m[d]){e.preventDefault(),n(m[d].value);return}if(e.key===`Backspace`&&o===``&&t.length>0){n(t[t.length-1]);return}e.key===`Escape`&&o!==``&&(e.stopPropagation(),g(``))},onFocus:()=>u(!0),onBlur:()=>{u(!1),f(-1),!r&&o!==``&&g(``)}})]}),p&&(0,X.jsxs)(`ul`,{id:`${i}-options`,role:`listbox`,"aria-label":e.label,"aria-multiselectable":!0,className:T(`flex max-h-60 flex-col gap-px overflow-y-auto`,!r&&`rounded-md border bg-background p-1 shadow-sm`),children:[m.map((e,r)=>{let a=t.includes(e.value);return(0,X.jsxs)(`li`,{id:`${i}-${r}`,role:`option`,"aria-selected":a,tabIndex:-1,className:T(`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 hover:bg-muted`,r===d&&`bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.value),children:[(0,X.jsx)(`span`,{className:T(`inline-flex size-4 shrink-0 items-center justify-center rounded border`,a?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background`),children:a&&(0,X.jsx)(l,{className:`size-3`,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:E(e.count)})]},e.value)}),m.length===0&&(0,X.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})]})},Mn=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,Z.useState)(``),a=e.options.filter(e=>xt(e.label,r));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,X.jsx)(W,{wrapperClassName:`mb-1 h-7`,leading:(0,X.jsx)(B,{className:`size-3.5`}),placeholder:q(`searchIn`,{label:e.label}),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,X.jsx)(F,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:E(e.count)})]},e.value)),a.length===0&&(0,X.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:q(`noMatches`)})]})},Nn=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,Z.useState)(r),[s,c]=(0,Z.useState)({width:n}),l=(0,Z.useRef)(null),d=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{if(!a||!l.current)return;let e=l.current.getBoundingClientRect(),t=document.documentElement.clientWidth,r=Math.min(n,R(t));c({width:r,right:e.left+r>t?e.right-We(e.right,r,t):void 0})},[a,n]);let f=ye(a,l,d,s);return(0,Z.useEffect)(()=>{if(!a)return;let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]),(0,X.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:T(`inline-flex h-8 items-center gap-1.5 rounded-md border bg-background px-2.5 font-medium shadow-sm transition-colors hover:bg-muted`,t>0?`border-primary-border text-primary-text`:`border-border-strong text-foreground`),children:[e,t>0&&(0,X.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[0.6875rem] leading-4 text-primary-foreground`,children:t}),(0,X.jsx)(u,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,X.jsx)(`div`,{ref:d,className:T(`absolute top-full z-30 mt-1.5 rounded-lg border bg-background p-3 shadow-pop`,s.right===void 0&&`left-0`),style:{...s,...f},children:typeof i==`function`?i(()=>o(!1)):i})]})},Pn=({title:e,children:t})=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),Fn=({items:e,onPick:t,close:n})=>{let r=(0,Z.useRef)([]);return(0,Z.useEffect)(()=>r.current[0]?.focus(),[]),(0,X.jsx)(`ul`,{role:`menu`,"aria-label":q(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=Oe(t.key,r.current.indexOf(document.activeElement),e.length);i!==void 0&&(t.preventDefault(),r.current[i]?.focus())},className:`-mx-3 -my-3`,children:e.map((e,i)=>(0,X.jsx)(`li`,{role:`none`,children:(0,X.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:Ae,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},In=({items:e,onPick:t})=>e.length===0?null:(0,X.jsx)(Nn,{label:q(`moreFilters`),activeCount:0,children:n=>(0,X.jsx)(Fn,{items:e,onPick:t,close:n})}),Ln=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},Rn=(e,t,n)=>n===t?0:(e-t)/(n-t),zn=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],Bn=1e3,Vn=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,Z.useState)(),u=c??t??[r,i],d=Math.max(...o),f=()=>{c&&(l(void 0),n(c[0]===r&&c[1]===i?void 0:c))},p=oe(c,Bn);return(0,Z.useEffect)(()=>{p&&f()},[p]),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,X.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,X.jsx)(`span`,{className:T(`flex-1 rounded-t-sm`,Ln(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,X.jsxs)(`div`,{className:`relative h-4`,children:[(0,X.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,X.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${Rn(u[0],r,i)*100}%`,right:`${100-Rn(u[1],r,i)*100}%`}})]})]}),(0,X.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,X.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":q(t===0?`minimum`:`maximum`,{label:e.label}),min:r,max:i,step:a,value:u[t],onChange:e=>l(zn(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:s(u[0])}),(0,X.jsx)(`span`,{children:s(u[1])})]})]})},Hn=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],Un=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},Wn=(e,t)=>{let n=[...e.facets.map(e=>({key:`facet:${e.id}`,label:e.label,secondary:e.secondary})),...(e.ranges??[]).map(e=>({key:`range:${e.id}`,label:e.label,secondary:e.secondary})),...e.datePresets?[{key:`date`,label:q(`date`),secondary:e.dateSecondary}]:[],...(e.toggles??[]).map(e=>({key:`toggle:${e.id}`,label:e.label,secondary:e.secondary}))],r=new Set,i=[];for(let e of n)!e.secondary||t.includes(e.key)?r.add(e.key):i.push({key:e.key,label:e.label});return{shown:r,more:i}},Gn=({label:e,checked:t,onChange:n})=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(C,{checked:t,onChange:n,label:e})]}),Kn=(e,t)=>e.some(e=>e.length>0)||!!t,qn=({groups:e,trailing:t})=>{if(!Kn(e,t))return null;let n=e.filter(e=>e.length>0);return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,X.jsxs)(Z.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,X.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},Jn=(e,t,n)=>{let[r,i]=(0,Z.useState)(t??Wt);return[e??r,e=>{i(e),n?.(e)}]},Yn=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=Jn(n,r,i),f=vt(e,u),p=Hn(f),[m,h]=(0,Z.useState)(()=>p),[g,_]=(0,Z.useState)();(0,Z.useEffect)(()=>h(e=>Un(e,p)),[p.join(`,`)]);let v=(0,X.jsx)(Dn,{chips:f,lockedLabels:a,onRemove:e=>d(lt(u,e)),onClear:()=>d(Wt)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(St(u,e.id,t));return e.combobox?(0,X.jsx)(jn,{config:e,selected:n,onToggle:r,inline:t}):(0,X.jsx)(Mn,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,X.jsx)(Vn,{config:e,value:u.ranges?.[e.id],onChange:t=>d(bt(u,e.id,t))}),S=e.datePresets&&(0,X.jsx)(On,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,X.jsx)(Gn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(ct(u,e.id))},e.id));if(t===`panel`)return(0,X.jsxs)(`aside`,{className:s?`flex w-full flex-col gap-1`:`flex w-64 shrink-0 flex-col gap-1 overflow-y-auto rounded-lg border bg-background px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,X.jsx)(`h2`,{className:`font-semibold`,children:q(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,X.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,X.jsx)(Pn,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,X.jsx)(Pn,{title:e.label,children:x(e)},e.id)),S&&(0,X.jsx)(Pn,{title:q(`date`),children:S}),C.length>0&&(0,X.jsx)(Pn,{title:q(`showOnly`),children:C})]});let{shown:w,more:T}=Wn(e,m),E=e=>{h(t=>Un(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,X.jsx)(Nn,{label:e.label,activeCount:(u.facets[e.id]??[]).length,width:e.combobox?280:void 0,defaultOpen:o===e.id||g===`facet:${e.id}`,children:y(e,!0)},e.id)),...b.filter(e=>w.has(`range:${e.id}`)).map(e=>(0,X.jsx)(Nn,{label:e.label,activeCount:+!!u.ranges?.[e.id],width:280,defaultOpen:o===e.id||g===`range:${e.id}`,children:x(e)},`range:${e.id}`)),...S&&w.has(`date`)?[(0,X.jsx)(Z.Fragment,{children:S},`date`)]:[]],ee=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,X.jsx)(Gn,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(ct(u,e.id))})},e.id)),te=[c?[(0,X.jsx)(Z.Fragment,{children:c},`leading`)]:[],D,ee,T.length>0?[(0,X.jsx)(In,{items:T,onPick:E},`more`)]:[]];return!Kn(te,l)&&f.length===0&&!a?.length?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(qn,{groups:te,trailing:l}),v]})},Q=j(`app/export`),Xn=()=>new DOMException(Q(`cancelled`),`AbortError`),Zn=async({client:e,resource:t,filters:n,orderBy:r,plan:i,labels:a,limit:o,port:s,sink:c,signal:l,onProgress:u})=>{let d=i.columns.map(e=>e.name),f=0;try{await c.write(await s.send({kind:`start`,plan:i,locale:A()}));for(let[i,p]of n.entries()){let m=``;do{let h=await e.search(t,{filter:p,orderBy:r,pageSize:500,pageToken:m,fields:d,labels:a});if(l.aborted)throw Xn();let g=h.items.slice(0,o-f);if(await c.write(await s.send({kind:`page`,records:g,labels:h.labels??{}})),f+=g.length,u(f),m=h.nextPageToken,f>=o)return await Qn(s,c),{rows:f,truncated:g.length<h.items.length||m!==``||i+1<n.length}}while(m!==``)}return await Qn(s,c),{rows:f,truncated:!1}}catch(e){throw await c.abort(),e}finally{s.close()}},Qn=async(e,t)=>{await t.write(await e.send({kind:`finish`})),await t.close()},$n=1048575,er=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
+
`,tr=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,nr=`http://schemas.openxmlformats.org/package/2006/relationships`;`${er}`,`${er}${nr}${tr}`,`${er}${nr}${tr}${tr}`,new TextEncoder;var rr=D(),ir=e=>e?.export!==!1,ar=e=>Object.values(e.fields).flatMap(e=>e.sensitive?[]:[e.name]),or=(e,t)=>{let n=new Set(ar(e));return g(e,t).filter(e=>n.has(e))},sr=(e,t,n)=>Object.fromEntries(Ie(e,t,[],n).map(e=>[e.id,e.header])),cr=(e,t,n)=>{let r=sr(e,t,n);return n.flatMap(n=>{let i=e.fields[n];return i?[{name:n,header:r[n],field:i,hints:t?.fields[n]??{}}]:[]})},lr=(e,t)=>{let n=e?.export?e.export.maxRows??1/0:1/0;return Math.min(n,t===`xlsx`?$n:1/0)},ur=e=>e.primaryKey.length===1,dr=(e,t)=>{let[n]=e.primaryKey;if(!n||e.primaryKey.length!==1)throw Error(`Not implemented: selected rows are exported by a single-field key`);let r=[];for(let e=0;e<t.length;e+=500)r.push(d(rr.in(n,t.slice(e,e+500))));return r},fr=e=>{if(e.kind!==`counting`)return e.kind===`exact`?e.rows:Math.max(e.rows,10001)},pr=j(`app/import`),mr=e=>typeof e==`object`&&!!e&&`date`in e,hr=e=>typeof e==`object`&&!!e&&`json`in e,gr=e=>e===null||typeof e==`string`&&e.trim()===``,_r=e=>e===null?``:mr(e)?e.date.replace(`T`,` `):hr(e)?JSON.stringify(e.json):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),vr=e=>e<26?String.fromCharCode(65+e):vr(Math.floor(e/26)-1)+vr(e%26),yr=(e,t)=>e[t]?.trim()?e[t]:pr(`column`,{letters:vr(t)}),br=(e,t,n,r)=>{let i=wn(t.headers),a=t.headers.map((e,n)=>({column:n,include:!0,name:i[n],label:yr(t.headers,n).trim(),type:t.types[n].type,inferred:t.types[n],decimal:t.decimals[n]}));return{name:Tn(e,n,r)??``,pluralLabel:e.replace(/\.[^.]+$/,``).trim(),singularLabel:``,titleField:a.find(e=>e.type===`text`)?.name,fields:a}},xr=e=>e.fields.filter(e=>e.include),Sr=(e,t,n)=>{let r=e.fields.find(e=>e.column===t),i=e.fields.map(e=>e.column===t?{...e,...n}:e),a=i.find(e=>e.column===t),o=r?.name===e.titleField,s=a.include&&a.type===`text`;return o?{...e,fields:i,titleField:s?a.name:void 0}:{...e,fields:i}},Cr=`user_table_fields`,wr=`table`,Tr=(e,t)=>{let n=xr(t).map((e,t)=>({op:`create`,resource:Cr,data:{table_id:{$ref:wr},name:e.name,label:e.label.trim(),type:e.type,position:t+1,...e.type===`decimal`&&{precision:e.decimal.precision,scale:e.decimal.scale}}})),r=t.titleField?[{op:`update`,resource:e,key:{$ref:wr},etag:`*`,data:{title_field:t.titleField}}]:[];return[{op:`create`,resource:e,ref:wr,data:{name:t.name,singular_label:t.singularLabel.trim(),plural_label:t.pluralLabel.trim()}},...n,...r]},Er=(e,t)=>{let n=new Map(t.map(e=>[e.value,e.count]));return e.map(([e,t])=>({value:e,label:t,...n.get(e)!==void 0&&{count:n.get(e)}}))},Dr=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],Or=D(),kr=(e,t,n)=>{let r=H(),[i,a]=(0,Z.useState)({}),o=e=>!!e?.search?.length&&e.primaryKey.length===1,s=e=>{let n=t[e.name];return[e.primaryKey[0],...n?.titleFrom?n.titleFrom.fields:[I(e,n)]]},c=(e,r)=>{let i=t[e.name],a=String(r[e.primaryKey[0]]);return[a,i?.titleFrom?n(e,i,r,a):String(r[I(e,i)])]},l=K({queries:e.map(({id:e,target:t})=>{let n=(i[e]??``).trim();return{queryKey:[`reference-search`,e,t?.name??``,n],enabled:o(t)&&n!==``,placeholderData:Qe,queryFn:async()=>(await r.list(t.name,{filter:d(Or.search(n)),fields:s(t),pageSize:20})).items}})});return e.map(({id:e,target:t},n)=>{if(!o(t))return{};let r=t=>a(n=>({...n,[e]:t}));return(i[e]??``).trim()===``?{onSearch:r}:{onSearch:r,matches:(l[n]?.data??[]).map(e=>c(t,e))}})},Ar=24,jr=({model:e,resources:t,views:n,view:i,state:a,extras:s,titleOf:c})=>{let l=H(),u=$e(),d=st(i,e),f=e=>i?.fields[e]?.label??r(e),m=n=>{let r=e.fields[n];return r?.type===`relation`&&r.relation?t[r.relation.resource]:void 0},h=e=>!!(e&&n[e.name]?.titleFrom),g=d.facets.flatMap(e=>(e.flags?e.options.map(e=>e.value):[e.id]).map(t=>({group:e.id,field:t}))),_=K({queries:g.map(({group:t,field:r})=>{let i=ut(d,{...a,facets:{...a.facets,[t]:[]}},s),c=m(r),u=c?.primaryKey.length===1&&!h(c)?I(c,n[c.name]):void 0;return{queryKey:o.facets(e.name,r,i),queryFn:()=>l.facets(e.name,r,{filter:i,limit:50,...u&&{label:u}})}})}),v=(e,t)=>_[g.findIndex(n=>n.group===e&&n.field===t)]?.data,y=e=>(v(e,e)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),b=K({queries:d.facets.map(t=>{let r=m(t.id),i=Dr(y(t.id),a.facets[t.id]??[]);return{queryKey:o.labels(`facet:${e.name}.${t.id}`,i.join(`,`)),enabled:!!r&&!h(r)&&i.length>0,queryFn:async()=>[...await Re(u,l,r,i,n[r.name])]}})}),x=K({queries:d.facets.map(t=>{let r=m(t.id),i=r&&h(r)?N(r,n[r.name]):void 0,s=[...new Set([...y(t.id),...a.facets[t.id]??[]])];return{queryKey:o.labels(`facet-title:${e.name}.${t.id}`,s.join(`,`)),enabled:i!==void 0&&s.length>0,queryFn:async()=>[...await p(l,r,i,s)]}})}),S=(e,t)=>{let r=m(e);return(x[t]?.data??[]).map(([e,t])=>[e,c(r,n[r.name],t,e)])},C=kr(d.facets.map(e=>({id:e.id,target:e.combobox?m(e.id):void 0})),n,c),w=d.ranges??[],T=K({queries:w.map(t=>{let n=ut(d,bt(a,t.id,void 0),s),r=gt(i,t.id)?Ar:1;return{queryKey:o.histogram(e.name,t.id,r,n),queryFn:()=>l.histogram(e.name,t.id,{filter:n,buckets:r})}})});return{facets:d.facets.map((t,n)=>{if(t.flags){let e=t.options.map(({value:e})=>({value:e,label:f(e),count:v(t.id,e)?.find(e=>String(e.value)===`true`)?.count??0}));return{...t,options:e}}let r=e.fields[t.id],a=(v(t.id,t.id)??[]).flatMap(e=>e.label===void 0?[]:[[String(e.value),e.label]]),o=r?.type===`enum`?(r.enumValues??[]).map(e=>[e,ae(e,i?.fields[t.id]?.valueLabels)]):[],s=new Map([...o,...a,...b[n]?.data??[],...S(t.id,n)]),c=(v(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[{value:String(e.value),label:s.get(String(e.value))??String(e.value),count:e.count}]),l=C[n];return{...t,label:f(t.id),options:l.matches?Er(l.matches,c):c,...s.size>0&&{labels:Object.fromEntries(s)},...l.onSearch&&{onSearch:l.onSearch}}}),ranges:w.flatMap((e,t)=>{let n=T[t]?.data;return!n||n.min===null||n.max===null?[]:[{...e,label:f(e.id),min:Math.floor(n.min),max:Math.ceil(n.max),step:Math.max(1,Math.round((n.max-n.min)/100)),histogram:gt(i,e.id)?n.buckets.map(e=>e.count):[],format:mt(i,e.id)}]}),...d.dateField&&{datePresets:d.datePresets??!0,dateField:d.dateField,dateKind:d.dateKind,...d.dateSecondary&&{dateSecondary:!0}},toggles:d.toggles?.map(e=>({...e,label:f(e.id)}))}},Mr=b(()=>Ze(()=>import(`./import-dialog-BppJUUoF.js`).then(e=>e.ImportDialog),__vite__mapDeps([0,1,2,3,4,5,6]))),Nr=b(()=>Ze(()=>import(`./import-table-dialog-cfWZMJfg.js`).then(e=>e.ImportTableDialog),__vite__mapDeps([7,1,2,3,4,5,6]))),Pr=({model:e})=>{let{resources:t,views:n}=de(),r=he(e.name),i=he(Cr),[a,o]=(0,Z.useState)(!1),s=n[e.name]?.import;return s===!1||!k(r,`create`)||s===`table`&&!k(i,`create`)?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{onClick:()=>o(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(ze,{className:`size-3.5`}),pr(s===`table`?`fromFile`:`import`)]}),a&&s===`table`&&(0,X.jsx)(Nr,{tables:e,resources:t,views:n,onClose:()=>o(!1)}),a&&s!==`table`&&(0,X.jsx)(Mr,{model:e,resources:t,views:n,canUpdate:k(r,`update`),onClose:()=>o(!1)})]})},Fr=()=>{let e=new Worker(new URL(`/assets/export-worker-CHLq663S.js`,``+import.meta.url),{type:`module`,name:`protobase-export`}),t=[];return e.onmessage=e=>t.shift()?.resolve(e.data.bytes),e.onerror=e=>{e.preventDefault();let n=Error(Q(`couldNotBuild`,{message:e.message}));for(let e of t.splice(0))e.reject(n)},{send:n=>new Promise((r,i)=>{t.push({resolve:r,reject:i}),e.postMessage(n)}),close:()=>e.terminate()}},Ir={xlsx:{mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,extension:`.xlsx`,description:`workbook`},csv:{mime:`text/csv`,extension:`.csv`,description:`csvFile`}},Lr=/[\\/:*?"<>|\u0000-\u001f]/g,Rr=(e,t,n=new Date)=>{let r=[n.getFullYear(),String(n.getMonth()+1).padStart(2,`0`),String(n.getDate()).padStart(2,`0`)].join(`-`);return`${e.replace(Lr,` `).trim()} ${r}${Ir[t].extension}`},zr=8e6,Br=(e,t)=>{let n=new Blob([],{type:Ir[t].mime}),r=[],i=0,a=()=>{n=new Blob([n,...r],{type:Ir[t].mime}),r=[],i=0};return{write:async e=>{e.length!==0&&(r.push(e),i+=e.length,i>=zr&&a())},close:async()=>{a();let t=URL.createObjectURL(n),r=document.createElement(`a`);r.href=t,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)},abort:async()=>{r=[],n=new Blob([])}}},Vr=()=>globalThis.showSaveFilePicker,Hr=()=>typeof Vr()==`function`,Ur=async(e,t)=>{let n=Vr();if(!n)throw Error(`This browser cannot save a file as it is built`);let r=Ir[t],i;try{i=await n({suggestedName:e,types:[{description:Q(r.description),accept:{[r.mime]:[r.extension]}}]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}let a=await i.createWritable();return{write:async e=>{e.length>0&&await a.write(e)},close:()=>a.close(),abort:()=>a.abort()}},Wr=b(()=>Ze(()=>import(`./export-dialog-CMPyzZa3.js`).then(e=>e.ExportDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Gr=b(()=>Ze(()=>import(`./export-dialog-CMPyzZa3.js`).then(e=>e.ExportProgressDialog),__vite__mapDeps([8,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Kr=(e,t)=>Hr()?Ur(e,t):Promise.resolve(Br(e,t)),qr=(e,t)=>{let n=t[e.primaryKey[0]];return typeof n==`object`&&n&&`id`in n?n.id:n},Jr=({model:e,view:t,resources:n,views:r,plural:i,filter:a,orderBy:s,createPort:c=Fr,createSink:l=Kr})=>{let u=H(),d=z(),[f,p]=(0,Z.useState)({kind:`closed`}),m=(0,Z.useRef)(void 0),h=(0,Z.useRef)(void 0),g=et({queryKey:o.exportCount(e.name,a),enabled:f.kind===`settings`,queryFn:async()=>{let t=await u.list(e.name,{filter:a||void 0,pageSize:1,count:`exact`,fields:e.primaryKey});return t.totalSize===void 0?{kind:`estimate`,rows:t.totalSizeEstimate}:{kind:`exact`,rows:t.totalSize}}}).data??{kind:`counting`},v=(e,t=h.current)=>{let n=h.current;n&&n===t&&(h.current=void 0,n.settle(e?[]:n.rows))},y=(t=[])=>(v(!1),p({kind:`settings`,selected:ur(e)?t.map(t=>qr(e,t)):[]}),new Promise(e=>{h.current={rows:t,settle:e}})),b=()=>{p({kind:`closed`}),v(!1)},x=async(o,f)=>{let y=Rr(i,o.format),b=await l(y,o.format);if(!b)return;let x=h.current,C=lr(t,o.format),w=o.scope===`selected`?f.length:fr(g),T=w===void 0?void 0:Math.min(w,C),D=new AbortController;m.current=D,p({kind:`running`,done:0,total:T});try{let l=await Zn({client:u,resource:e.name,filters:o.scope===`selected`?dr(e,f):[a],orderBy:s,plan:{format:o.format,mode:o.mode,name:i,columns:cr(e,t,o.columns)},labels:o.mode===`shown`?_(n,r,e,o.columns):{},limit:C,port:c(),sink:b,signal:D.signal,onProgress:e=>D.signal.aborted||p({kind:`running`,done:e,total:T})});d.show({state:`success`,title:Q(`exported`,{count:E(l.rows),plural:i}),description:l.truncated?Q(`truncated`,{name:y,count:E(l.rows)}):y}),v(!0,x)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(!S(e))throw e;d.show({state:`error`,title:Q(`couldNotExport`,{plural:i}),description:e.message})}finally{m.current=void 0,p(e=>e.kind===`running`?{kind:`closed`}:e),v(!1,x)}},C=()=>{m.current?.abort(),b()},w=ar(e),T=sr(e,t,w);return{open:y,dialogs:f.kind===`settings`?(0,X.jsx)(Wr,{plural:i,view:t,fields:w.map(e=>({name:e,label:T[e]})),initialColumns:or(e,t),count:g,selected:f.selected.length>0?f.selected.length:void 0,open:!0,onExport:e=>void x(e,f.selected),onClose:b}):f.kind===`running`?(0,X.jsx)(Gr,{plural:i,done:f.done,total:f.total,onCancel:C}):null}},Yr=({state:e,onClearSearch:t,onClearFilters:n,create:r})=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8 text-center text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:e.message}),(e.clearSearch||e.clearFilters||e.create&&r)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[e.clearSearch&&(0,X.jsx)(O,{onClick:t,children:Y(`clearSearch`)}),e.clearFilters&&(0,X.jsx)(O,{onClick:n,children:Y(`clearFilters`)}),e.create&&r]})]}),Xr=({plural:e,search:t,filtered:n,scoped:r,canCreate:i})=>t?{message:Y(`noMatchSearch`,{plural:e,search:t}),clearSearch:!0,clearFilters:n,create:!1}:n?{message:Y(`noMatchFilters`,{plural:e}),clearSearch:!1,clearFilters:!0,create:!1}:r?{message:Y(`noMatch`,{plural:e}),clearSearch:!1,clearFilters:!1,create:!1}:{message:Y(`noneYet`,{plural:e}),clearSearch:!1,clearFilters:!1,create:i},Zr=(e,t)=>{},Qr=({windowMs:e=1e3,comebacks:t=2,onHold:n=Zr}={})=>{let r,i=[],a;return(o,s)=>{if(a?.among.has(o))return a.value;if(a&&(a=void 0,i=[]),o===r||(r=o,i=i.filter(t=>s-t.at<=e),i.push({value:o,at:s,comeback:i.some(e=>e.value===o)}),i.filter(e=>e.comeback).length<t))return o;let c=new Set(i.slice(-2*t).map(e=>e.value));return a={value:Math.min(...c),among:c},n(a.value,[...c]),a.value}},$r=e=>Math.max(1,Math.floor((e+12)/252)),ei=(e,t)=>Math.max(0,(e-(t-1)*12)/t),ti=(e,t,n,r)=>({start:e*n,end:Math.max(0,Math.min(r,(t+1)*n)-1)}),ni=(e,t,n)=>{let r=e/t.rowHeight;return t.columns===n.columns?r*n.rowHeight:Math.floor(Math.floor(r)*t.columns/n.columns)*n.rowHeight},ri=(e,t)=>{let n=e/t.rowHeight;return Math.floor(n)*t.columns+n%1},ii=(e,t)=>Math.floor(Math.floor(e)/t)+e%1,ai=8,oi=(e,t,n)=>{let r=e.get(t);if(r!==void 0&&r>=n)return e;let i=new Map(e);i.delete(t),i.set(t,n);for(let e of i.keys()){if(i.size<=ai)break;i.delete(e)}return i},si=({source:e,label:t,initialIndex:n,onScrollIndex:r,minHeight:i,children:a})=>{let{total:o}=e,[s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(0),u=$r(c),d=ei(c,u),[f,p]=(0,Z.useState)(()=>new Map),m=Math.ceil(Math.max(i(d),f.get(d)??0)),h=m+12,g={columns:u,rowHeight:h},_=(0,Z.useRef)({layout:g,top:0}),v=_.current.top>0&&(_.current.layout.columns!==u||_.current.layout.rowHeight!==h),y=e=>v?ni(_.current.top,_.current.layout,g):e,b=d>0&&f.has(d),x=nt({total:Math.ceil(o/u),rowHeight:h,initialIndex:ii(s,u),settle:y,ready:b,onScroll:e=>r(ri(e,g))});(0,Z.useLayoutEffect)(()=>{v&&x.scrollTo(x.top),_.current={layout:g,top:x.started()?x.top:0}});let S=ti(x.first,x.last,u,o),C=Qt({total:o,rowAt:e.rowAt,loadRows:e.loadRows,cachedRows:e.cachedRows,revision:e.revision,latencyMs:0},S.start,S.end),[w]=(0,Z.useState)(()=>Qr());(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(!e)return;let t=()=>l(w(e.clientWidth,performance.now())),n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[w]);let T=(0,Z.useRef)(d);T.current=d;let[E]=(0,Z.useState)(()=>new ResizeObserver(e=>{let t=Math.max(...e.map(e=>e.borderBoxSize[0]?.blockSize??e.contentRect.height)),n=T.current;p(e=>oi(e,n,t))}));(0,Z.useLayoutEffect)(()=>()=>E.disconnect(),[E]),(0,Z.useLayoutEffect)(()=>{let e=x.ref.current;if(b||d===0||!e)return;let t=[...e.querySelectorAll(`:scope > li[aria-posinset]`)];if(t.length===0)return;let n=Math.max(...t.map(e=>e.getBoundingClientRect().height));p(e=>oi(e,d,n))});let D=(0,Z.useCallback)(e=>{if(e)return E.observe(e),()=>E.unobserve(e)},[E]);return(0,X.jsx)(`ul`,{ref:x.ref,className:`relative min-w-0 flex-auto`,"aria-label":t,style:{height:x.geometry.contentHeight},children:x.rows.flatMap(({index:e,offset:t})=>Array.from({length:u},(n,r)=>{let i=e*u+r;if(i>=o)return[];let s=C(i),c={top:t,left:r*(d+12),width:d,minHeight:m};return s?(0,X.jsx)(`li`,{ref:D,"aria-posinset":i+1,"aria-setsize":o,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:a(s)},s.id):(0,X.jsx)(`li`,{"aria-hidden":!0,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:(0,X.jsx)(L,{className:`h-full rounded-lg`})},`skeleton-${i}`)}))})},ci=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,li=e=>e*.75,ui=44,di=({model:e,view:t,display:n,list:i,empty:a})=>{let o=t?.names?.plural??r(e.name),s=n.card===void 0&&(n.image!==void 0||n.photos!==void 0);return i.isLoading?(0,X.jsx)(`div`,{"aria-busy":!0,className:`min-h-0 flex-1 overflow-hidden ${ci}`,children:Array.from({length:6},(e,t)=>(0,X.jsx)(L,{className:`h-24`},t))}):i.error?(0,X.jsx)(Me,{title:ke(`couldNotLoadRows`),error:i.error}):!i.source||i.source.total===0?a??(0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:ke(`noneMatch`,{plural:o.toLowerCase()})}):(0,X.jsx)(si,{source:i.source,label:o,initialIndex:i.initialIndex,onScrollIndex:i.onScrollIndex,minHeight:e=>(s?li(e):0)+ui,children:r=>(0,X.jsx)(Vt,{model:e,view:t,display:n,row:m(e,r)})})},fi=`protobase:list-places`,pi=50,mi=(e,t)=>`${e} ${t}`,hi=e=>{if(typeof e!=`object`||!e)return!1;let{entry:t,url:n,place:r}=e;return typeof t==`string`&&typeof n==`string`&&typeof r==`number`&&Number.isFinite(r)&&r>=0},gi=e=>ue(()=>{let t=e.getItem(fi);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(hi):[]},[]),_i=e=>{let t=new Map(gi(e).map(e=>[mi(e.entry,e.url),e]));return{placeOf:(e,n)=>{let r=t.get(mi(e,n));return r?r.place:[...t.values()].findLast(e=>e.url===n)?.place??0},save:(e,n,r)=>{let i=mi(e,n);t.delete(i),t.set(i,{entry:e,url:n,place:r});for(let e of[...t.keys()].slice(0,Math.max(0,t.size-pi)))t.delete(e)},persist:()=>ue(()=>e.setItem(fi,JSON.stringify([...t.values()])),void 0)}},vi={getItem:()=>null,setItem:()=>{}},yi,bi=()=>yi??=_i(ue(()=>window.sessionStorage,void 0)??vi),xi=()=>{let{entry:e,path:t,params:n}=P(),r=`${t}?${n.toString()}`,i=bi();(0,Z.useEffect)(()=>{let e=()=>i.persist(),t=()=>document.visibilityState===`hidden`&&i.persist();return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),i.persist()}},[i]);let a=(0,Z.useCallback)(t=>i.save(e,r,t),[i,e,r]);return{initialIndex:i.placeOf(e,r),remember:a}},Si=e=>e.reduce((e,t)=>e+t.count,0),Ci=e=>{let t=Math.floor(e.length/2),n=Si(e.slice(0,t)),r=Si(e.slice(e.length-t));return n===0?0:(r-n)/n*100},wi=j(`activity-chart`),Ti=({title:e,defaultGranularity:t=`day`,data:n,granularity:r,onGranularityChange:i,periodLabel:a,className:o})=>{let[s,c]=(0,Z.useState)(t),l=r??s,u=i??c,d=Ci(n),f=n.map(({at:e,count:t})=>({at:e,value:t,count:t}));return(0,X.jsxs)(`section`,{className:T(`rounded-lg border bg-background px-4 pb-2 pt-3`,o),children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e}),(0,X.jsx)(`span`,{className:`font-semibold tabular-nums`,children:E(Si(n))}),(0,X.jsxs)(`span`,{className:T(`text-xs font-medium tabular-nums`,d>=0?`text-success-text`:`text-danger-text`),children:[d>=0?`+`:`−`,Math.abs(d).toFixed(1),`%`]}),(0,X.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:a??`last ${l===`day`?`30 days`:`12 weeks`}`})]}),(0,X.jsx)(je,{value:l,onChange:u,options:[{value:`day`,label:wi(`day`)},{value:`week`,label:wi(`week`)}]})]}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(Lt,{points:f,measure:{kind:`count`},bucket:l,type:`bar`,compact:!0})})]})},Ei={"7d":`last 7 days`,"30d":`last 30 days`,"90d":`last 90 days`,"1y":`last year`,all:`all time`},Di=({resource:e,chart:t,title:n,filter:r})=>{let[i,a]=(0,Z.useState)(t.granularity===`week`?`week`:`day`),o=i===`week`?`90d`:t.range,s=Ce(e,{field:t.field,range:o,granularity:i,filter:r,timeZone:be()}).data?.points.map(e=>({at:Date.parse(`${e.bucket}Z`),count:e.count}))??[];return(0,X.jsx)(Ti,{title:n,data:s,granularity:i,onGranularityChange:a,periodLabel:i===`week`?`last 12 weeks`:Ei[o]})},Oi=(e,t,n)=>{let i=e.sum??e.average;if(i===void 0)return n;let a=t?.fields[i]?.label??r(i);return e.sum===void 0?y(`average`,{label:a}):`${a}`},ki=({model:e,view:t,chart:n,plural:i,filter:a})=>{let o=t?.fields[n.groupBy]?.label??r(n.groupBy);return(0,X.jsxs)(`section`,{className:`rounded-lg border bg-background px-4 pb-3 pt-3`,"aria-label":`${Oi(n,t,i)} by ${o.toLowerCase()}`,children:[(0,X.jsxs)(`h2`,{className:`mb-2 font-semibold`,children:[Oi(n,t,i),` by `,o.toLowerCase()]}),(0,X.jsx)(kt,{model:e,view:t,groupBy:n.groupBy,type:n.type,sum:n.sum,average:n.average,limit:n.limit,filter:a})]})},Ai=({value:e,onCommit:t,placeholder:n,className:r})=>{let[i,a]=(0,Z.useState)(e);return(0,Z.useEffect)(()=>a(e),[e]),(0,Z.useEffect)(()=>{if(i===e)return;let n=setTimeout(()=>t(i),350);return()=>clearTimeout(n)},[i,e,t]),(0,X.jsx)(W,{wrapperClassName:T(`min-w-0 flex-1 sm:w-72 sm:flex-initial`,r),leading:(0,X.jsx)(B,{className:`size-4`}),placeholder:n,"aria-label":Y(`search`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&t(i)})},ji=(e,t,n,i,a)=>{let o=n?.list?.relatedColumns??[];if(o.length===0)return e;let s=new Map(e.map(e=>[e.id,e]));return g(t,n).flatMap(e=>{let t=s.get(e);if(t)return[t];let n=o.find(t=>t.name===e),c=n&&i[n.resource];if(!n||!c)return[];let l=n.label??r(n.name);return[{id:n.name,header:l,kind:`text`,width:160,minWidth:Ke(l,!1),sortable:!1,render:e=>(0,X.jsx)(yt,{column:n,records:e[n.name]??[],target:c,view:a[c.name],Card:Vt})}]})},Mi=({model:e,view:t,target:n,children:i})=>{let a=ht(e.name,t.listOf,!0),o=t.names?.plural??r(e.name),s=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,X.jsx)(Zt,{title:o,subtitle:t.help}),e]});if(a.error)return s((0,X.jsx)(Me,{title:at(`couldNotLoadYour`,{plural:o.toLowerCase()}),error:a.error}));if(!a.data)return s((0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(L,{className:`h-24`},t))}));let c=Nt(n,a.data);return c?i(c):s((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:at(`noneYet`,{plural:o.toLowerCase()})}))},Ni=({title:e,chips:t,label:n,required:r,initial:i=``,busy:a,onSave:o,onClose:s})=>{let c=(0,Z.useId)(),[l,u]=(0,Z.useState)(i),d=`${c}-form`;return(0,X.jsx)(v,{open:!0,title:e,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{onClick:s,children:J(`cancel`)}),(0,X.jsx)(O,{type:`submit`,form:d,variant:`primary`,loading:a,children:J(`save`)})]}),children:(0,X.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o(l.trim()===``?null:l.trim())},children:[t.length>0&&(0,X.jsx)(wt,{chips:t}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:n}),!r&&(0,X.jsx)(`span`,{id:`${c}-hint`,className:`text-xs text-muted-foreground`,children:J(`optional`)})]}),(0,X.jsx)(W,{id:c,value:l,required:r,pattern:r?`.*\\S.*`:void 0,"aria-describedby":r?void 0:`${c}-hint`,autoFocus:!0,autoComplete:`off`,onChange:e=>u(e.target.value)})]})]})})},$=D(),Pi={start:0,end:0},Fi=(e,t)=>$.and(t,{kind:`present`,field:e.field,span:Pi}),Ii=e=>{switch(e.kind){case`and`:case`or`:return{...e,args:e.args.map(Ii)};case`not`:return Li(e.arg);case`search`:case`present`:case`isNull`:case`related`:return e;default:return Fi(e,e)}},Li=e=>{switch(e.kind){case`and`:return $.or(...e.args.map(Li));case`or`:return $.and(...e.args.map(Li));case`not`:return Ii(e.arg);case`search`:case`present`:case`isNull`:case`related`:return $.not(e);default:return Fi(e,$.not(e))}},Ri=e=>{let t=Xe(e);if(!t.ok)throw Error(`The filter cannot be read: ${t.errors.map(e=>e.message).join(`; `)}`);return t.ast},zi=e=>e.kind===`and`||e.kind===`or`?e.args.some(zi):e.kind===`not`?zi(e.arg):e.kind===`related`,Bi=(e,t)=>![Ri(e),Ri(t)].some(e=>e&&zi(e)),Vi=(e,t)=>{let n=Ri(e);if(!n)return null;let r=Ri(t),i=$.not(Ii(n));return d(r?$.and(r,i):i)},Hi=(e,t)=>Vi(t,e),Ui=e=>e.key.startsWith(`extra:`)?`extra:${e.label}`:e.key,Wi=(e,t)=>{let n=new Map(e.map(e=>[Ui(e),e])),r=new Map(t.map(e=>[Ui(e),e])),i=e.filter(e=>!r.has(Ui(e))).map(e=>({kind:`removed`,label:e.label})),a=t.flatMap(e=>{let t=n.get(Ui(e));return t&&t.label!==e.label?[{kind:`changed`,label:e.label,before:t.label}]:[]}),o=t.filter(e=>!n.has(Ui(e))).map(e=>({kind:`added`,label:e.label}));return[...i,...a,...o]},Gi=(e,t,n,r)=>{let i=e-t;if(i===0)return J(`asMany`,{plural:r});let a=Math.abs(i)===1?n:r;return i>0?J(`more`,{count:i,noun:a}):J(`fewer`,{count:-i,noun:a})},Ki=12,qi={added:{word:`added`,className:`text-success-text`},removed:{word:`removed`,className:`text-danger-text`},changed:{word:`changed`,className:`text-primary-text`}},Ji=({changes:e})=>(0,X.jsx)(`ul`,{"aria-label":J(`filterChanges`),className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`grid grid-cols-[72px_1fr] gap-3 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`font-medium ${qi[e.kind].className}`,children:J(qi[e.kind].word)}),e.kind===`changed`?(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,X.jsx)(`span`,{className:`font-medium`,children:e.label})]}):(0,X.jsx)(`span`,{className:e.kind===`removed`?`text-muted-foreground line-through`:`font-medium`,children:e.label})]},`${e.kind}:${e.label}`))}),Yi=(e,t)=>{let n=et({...He(H(),e,t??``),enabled:t!==null});return t===null?0:n.data},Xi=(e,t,n)=>`${e} ${e===1?t:n}`,Zi=({model:e,view:t,title:n,filter:r,total:i,plural:a})=>{let o=t?.list?.displays?.find(e=>e.kind===`cards`);return(0,X.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`h3`,{className:`font-semibold`,children:[n,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,i??`…`,`)`]})]}),i!==void 0&&i>Ki&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`firstOf`,{limit:Ki,total:i})}),r===null||i===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noPlural`,{plural:a})}):(0,X.jsx)(Ft,{model:e,view:t,filter:r,sort:Ee(e,t),limit:Ki,display:o?.name??`table`,row:!0,link:!1,empty:`No ${a}.`})]})},Qi=({model:e,view:t,before:n,after:i})=>{let a=(0,Z.useMemo)(()=>Vi(n,i),[n,i]),o=(0,Z.useMemo)(()=>Hi(n,i),[n,i]),s=Yi(e,a),c=Yi(e,o),l=(t?.names?.singular??r(e.name)).toLowerCase(),u=(t?.names?.plural??r(e.name)).toLowerCase();return(0,X.jsxs)(X.Fragment,{children:[s!==void 0&&c!==void 0?(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`font-semibold`,children:Gi(s,c,l,u)}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,J(`addedRemoved`,{added:Xi(s,l,u),removed:c})]})]}):(0,X.jsx)(L,{className:`h-4 w-48`}),(0,X.jsx)(Zi,{model:e,view:t,title:J(`added`),filter:a,total:s,plural:u}),(0,X.jsx)(Zi,{model:e,view:t,title:J(`removed`),filter:o,total:c,plural:u})]})},$i=({model:e,view:t,title:n,before:r,after:i,saveNewLabel:a,updating:o,creating:s,onUpdate:c,onSaveNew:l,onCancel:u})=>{let d=Wi(rt(e,r),rt(e,i));return(0,X.jsx)(v,{open:!0,wide:!0,title:n,onClose:u,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{onClick:u,children:J(`cancel`)}),(0,X.jsx)(O,{loading:s,disabled:o,onClick:l,children:a}),(0,X.jsx)(O,{variant:`primary`,loading:o,disabled:s,onClick:c,children:J(`update`)})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d.length>0&&(0,X.jsx)(Ji,{changes:d}),Bi(r,i)?(0,X.jsx)(Qi,{model:e,view:t,before:r,after:i}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noRecordsDiff`)})]})})},ea=()=>{let{address:e,set:t}=x();return{key:e?.kind===`list`?e.savedSearch:void 0,open:e=>t({savedSearch:e})}},ta=e=>e instanceof Error?e.message:J(`somethingWrong`),na=(e,t)=>{let n=de(),i=H(),a=z(),o=U(),{href:s,open:c}=x(),l=ea(),{resource:u}=e,d=n.resources[u],f=n.views[u]?.searchesOf,p=n.permissions[u],m=d!==void 0&&f!==void 0&&p!==void 0&&k(p,`create`)&&k(p,`delete`),h=n.signIn?.[u]?.signIn,g=Tt(u,m),_=e=>V(M(d,e)),v=f&&g.data?.find(e=>e[f.filter]===t),y=v||l.key===void 0||!p||!k(p,`update`)?void 0:g.data?.find(e=>_(e)===l.key),b=n.views[u]?.names,S=b?.plural??`saved searches`,C=f?.name===void 0?void 0:d?.fields[f.name],w=G({mutationFn:e=>i.create(u,{[f.filter]:t,...f.name&&{[f.name]:e}}),onSuccess:e=>{l.open(_(e.record)),a.show({state:`success`,title:J(`searchSaved`),action:{label:J(`openPlural`,{plural:S}),href:s({kind:`list`,resource:u}),onNavigate:c}})},onError:e=>a.show({state:`error`,title:J(`couldNotSave`),description:ta(e)}),onSettled:()=>o(u)}),T=G({mutationFn:e=>i.remove(u,_(e)),onError:e=>a.show({state:`error`,title:J(`couldNotTakeOff`),description:ta(e)}),onSettled:()=>o(u)}),E=G({mutationFn:e=>i.update(u,_(e),{[f.filter]:t},e.etag??`*`),onSuccess:()=>a.show({state:`success`,title:J(`searchUpdated`)}),onError:e=>a.show({state:`error`,title:J(`couldNotUpdate`),description:ta(e)}),onSettled:()=>o(u)}),D=w.isPending||T.isPending||E.isPending;return{mode:m?`save`:h?`sign-in`:void 0,prompt:h,saved:v!==void 0,opened:y&&{filter:String(y[f.filter]??``),name:f.name&&typeof y[f.name]==`string`&&y[f.name]!==``?String(y[f.name]):void 0},noun:(b?.singular??r(u)).toLowerCase(),naming:C&&{label:n.views[u]?.fields[C.name]?.label??r(C.name),required:!C.nullable},ready:g.data!==void 0&&!D,updating:E.isPending,creating:w.isPending,remove:()=>v&&T.mutate(v),saveNew:(e,t)=>w.mutate(e,t),update:e=>y&&E.mutate(y,e)}},ra=({model:e,view:t,search:n,filter:r,chips:i,className:a})=>{let o=na(n,r),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)();if(!o.mode)return null;let m=n.label??J(`saveSearch`);if(o.mode===`sign-in`)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:[(0,X.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),m]}),(0,X.jsx)(f,{as:`dialog`,prompt:o.prompt,open:s,onClose:()=>c(!1)})]});let h=e=>{u(!1),o.naming?p(e):o.saveNew(null)},g=d!==void 0&&o.naming&&(0,X.jsx)(Ni,{title:d,chips:i,label:o.naming.label,required:o.naming.required,busy:o.creating,onSave:e=>o.saveNew(e,{onSuccess:()=>p(void 0)}),onClose:()=>p(void 0)}),_=o.opened;if(_){let n=J(`saveAsNew`,{noun:o.noun});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-haspopup":`dialog`,"aria-disabled":!o.ready,onClick:()=>o.ready&&u(!0),children:[(0,X.jsx)(_n,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`max-w-60 truncate`,children:J(`updateName`,{name:_.name??o.noun})})]}),(0,X.jsxs)(O,{className:a,"aria-haspopup":o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&h(n),children:[(0,X.jsx)(pn,{className:`size-3.5`,"aria-hidden":!0}),n]}),l&&(0,X.jsx)($i,{model:e,view:t,title:_.name?J(`updateNameQuestion`,{name:_.name}):J(`updateNounQuestion`,{noun:o.noun}),before:_.filter,after:r,saveNewLabel:n,updating:o.updating,creating:o.creating,onUpdate:()=>o.update({onSuccess:()=>u(!1)}),onSaveNew:()=>h(n),onCancel:()=>u(!1)}),g]})}let v=o.saved?dn:Te;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(O,{className:a,"aria-pressed":o.saved,"aria-haspopup":!o.saved&&o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&(o.saved?o.remove():h(m)),children:[(0,X.jsx)(v,{className:o.saved?`size-3.5 text-primary`:`size-3.5`,"aria-hidden":!0}),m]}),g]})},ia=e=>e instanceof Error?e.message:J(`somethingWrong`),aa=({model:e,view:t,name:n,value:i,onChange:a})=>{let o=(0,Z.useId)(),s=e.fields[n],c=t.fields[n],l=c?.label??r(n);if(s?.type===`boolean`)return(0,X.jsx)(C,{checked:i===!0,onChange:a,label:l});if(s?.type!==`enum`)throw Error(`Not implemented: "${n}" is ${s?.type??`unknown`}, and a saved search's controls are enums or booleans`);return(0,X.jsxs)(`label`,{htmlFor:o,className:`flex items-center gap-2 text-muted-foreground`,children:[l,(0,X.jsx)(`select`,{id:o,value:String(i??``),onChange:e=>a(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2 text-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,children:(s.enumValues??[]).map(e=>(0,X.jsx)(`option`,{value:e,children:ae(e,c?.valueLabels)},e))})]})},oa=(e,t,n)=>Object.entries(n).map(([n,i])=>`${t.fields[n]?.label??r(n)}: ${e.fields[n]?.type===`boolean`?J(i===!0?`on`:`off`):ae(String(i),t.fields[n]?.valueLabels)}`).join(`, `),sa=({model:e,view:t,recordKey:n,title:r,row:i,fields:a})=>{let o=H(),s=z(),c=U(),l=G({mutationFn:t=>o.update(e.name,n,t,i.etag??`*`),onSuccess:(n,i)=>s.show({state:`success`,title:J(`saved`,{title:r}),description:oa(e,t,i)}),onError:e=>s.show({state:`error`,title:J(`couldNotChange`),description:ia(e)}),onSettled:()=>c(e.name)});return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:a.map(n=>(0,X.jsx)(aa,{model:e,view:t,name:n,value:l.isPending&&n in(l.variables??{})?l.variables[n]:i[n],onChange:e=>l.mutate({[n]:e})},n))})},ca=e=>e instanceof Error?e.message:J(`somethingWrong`),la=({model:e,view:t,of:n,target:i,targetView:a,row:o,recordKey:s,canRename:c,onDelete:l})=>{let u=H(),d=z(),f=U(),[p,m]=(0,Z.useState)(!1),{name:g,chips:_,title:v,body:y}=Ut({model:e,of:n,target:i,targetView:a,row:o,recordKey:s}),b=G({mutationFn:t=>u.update(e.name,s,{[n.name]:t},o.etag??`*`),onSuccess:()=>m(!1),onError:e=>d.show({state:`error`,title:J(`couldNotRename`),description:ca(e)}),onSettled:()=>f(e.name)}),x=n.name===void 0?void 0:e.fields[n.name];return(0,X.jsxs)(`section`,{"aria-label":v,className:`flex flex-col gap-3 rounded-lg border bg-surface p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,X.jsx)(h,{to:{kind:`record`,resource:e.name,key:s},className:`hover:underline`,children:g??(0,X.jsx)(Ct,{chips:_})})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.controls&&(0,X.jsx)(sa,{model:e,view:t,recordKey:s,title:v,row:o,fields:n.controls}),c&&x&&(0,X.jsx)(O,{variant:`ghost`,"aria-label":J(`renameTitle`,{title:v}),"aria-haspopup":`dialog`,onClick:()=>m(!0),children:(0,X.jsx)(Gt,{className:`size-3.5`,"aria-hidden":!0})}),l&&(0,X.jsx)(O,{variant:`ghost`,"aria-label":J(`deleteTitle`,{title:v}),onClick:()=>l(v),children:(0,X.jsx)(Xt,{className:`size-3.5`,"aria-hidden":!0})})]})]}),p&&x&&(0,X.jsx)(Ni,{title:J(`renameTitle`,{title:v}),chips:_,label:t.fields[x.name]?.label??r(x.name),required:!x.nullable,initial:g,busy:b.isPending,onSave:e=>b.mutate(e),onClose:()=>m(!1)}),(0,X.jsx)(Ht,{...y})]})},ua=({model:e,view:t})=>{let{resources:n,views:i}=de(),a=t.searchesOf,o=n[a.resource],s=i[a.resource],c=Tt(e.name,!0),l=he(e.name),u=Kt({model:e,view:t}),d=t.names?.plural??r(e.name),f=e=>(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[u.dialogs,(0,X.jsx)(Zt,{title:d,subtitle:t.help}),e]});if(!o)return f((0,X.jsx)(pe,{title:J(`notFound`),children:J.rich(`noResource`,{resource:a.resource})}));if(c.error)return f((0,X.jsx)(Me,{title:J(`couldNotLoadYour`,{plural:d.toLowerCase()}),error:c.error}));if(!c.data)return f((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,X.jsx)(L,{className:`h-56`},t))}));if(c.data.length===0){let e=(s?.names?.plural??r(o.name)).toLowerCase();return f((0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:J.rich(`noSavedYet`,{plural:d.toLowerCase(),list:(0,X.jsx)(h,{to:{kind:`list`,resource:o.name},className:`font-medium text-primary-text hover:underline`,children:e})})}))}return f((0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c.data.map(n=>{let r=V(M(e,n)),i=k(l,`delete`)?e=>void u.start({key:r,title:e,etag:n.etag,snapshot:n}):void 0;return(0,X.jsx)(la,{model:e,view:t,of:a,target:o,targetView:s,row:n,recordKey:r,canRename:k(l,`update`),onDelete:i},r)})}))},da=({field:e,hints:t,resource:n,stored:r,onSave:i,close:a})=>{let[o,s]=(0,Z.useState)(()=>ne(e,r)),l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=!t?.widget&&(e.type===`boolean`||e.type===`enum`);(0,Z.useEffect)(()=>{l.current?.querySelector(`input, select, textarea, button, [tabindex]`)?.focus()},[]);let f=(t,n,s=o)=>{u.current||(u.current=!0,t&&c(e,s,r)&&i(we(e,s)),a(n))};return(0,X.jsx)(`div`,{ref:l,className:`w-full min-w-0`,onKeyDown:e=>{se(e.target)||(e.key===`Enter`?(e.preventDefault(),f(!0)):e.key===`Tab`?(e.preventDefault(),f(!0,e.shiftKey?-1:1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f(!1)))},onBlur:e=>{!l.current?.contains(e.relatedTarget)&&!se(e.relatedTarget)&&f(!0)},children:(0,X.jsx)(_e,{field:e,hints:t,value:o,stored:r,resource:n,onChange:e=>{s(e),d&&f(!0,void 0,e)}})})},fa=j(`app/list-edit`),pa=e=>{let t=H(),n=$e(),r=z(),[i,a]=(0,Z.useState)(new Map),s=(0,Z.useRef)(i),c=(0,Z.useRef)(new Map),l=(e,t)=>{s.current=new Map(s.current).set(e,{...s.current.get(e),...t}),a(s.current)},u=async(i,a,c)=>{let u=M(e,i),d=String(s.current.get(i.id)?.etag??i.etag);try{let r=await t.update(e.name,u,{[a]:c},d);l(i.id,{[a]:r.record[a],etag:r.etag}),n.setQueryData(o.record(e.name,V(u)),r),n.invalidateQueries({queryKey:[`page`,e.name]}),n.invalidateQueries({queryKey:[`list`,e.name]}),n.invalidateQueries({queryKey:[`map`,e.name]}),n.invalidateQueries({queryKey:[`count`,e.name]})}catch(n){if(!S(n))throw l(i.id,{[a]:i[a]}),n;let o=n.status===412,s=o?await t.get(e.name,u):void 0;l(i.id,s?{[a]:s.record[a],etag:s.etag}:{[a]:i[a]});let c=n.errors.find(e=>e.field===a)?.message??n.message;r.show({state:`error`,title:fa(o?`changedBySomeoneElse`:`couldNotSave`),description:c})}};return{patches:i,save:(e,t,n)=>{l(e.id,{[t]:n});let r=(c.current.get(e.id)??Promise.resolve()).then(()=>u(e,t,n));return c.current.set(e.id,r.catch(()=>void 0)),r}}},ma=(e,t,n)=>{let r=pa(e),i=t?.list?.editable??[];return{editor:i.length>0&&k(n,`update`)?{editable:(t,n)=>i.includes(n)&&e.fields[n]!==void 0&&ce(e.fields[n])&&Ge(t,`update`),render:(n,i,a)=>(0,X.jsx)(da,{field:e.fields[i],hints:t?.fields[i],resource:e.name,stored:n[i],onSave:e=>void r.save(n,i,e),close:a})}:void 0,patches:r.patches}},ha=D(),ga=e=>e.find(e=>e.kind===`search`),_a=({address:e})=>{let{resources:t,views:n,signIn:i}=de(),a=t[e.resource],o=i?.[e.resource];if(!a)return o?(0,X.jsx)(f,{as:`page`,prompt:o.signIn}):(0,X.jsx)(pe,{title:y(`notFound`),children:y(`noResource`,{name:e.resource})});let c=Be(n[e.resource],e.list);if(e.list!==void 0&&!c)return(0,X.jsx)(pe,{title:y(`notFound`),children:Y(`noList`,{name:e.list})});if(c?.searchesOf)return(0,X.jsx)(ua,{model:a,view:c});let l=s(t,n,e.resource,e.list);if(c&&l.listOf){let t=l.model;return(0,X.jsx)(Mi,{model:a,view:c,target:t,children:n=>(0,X.jsx)(va,{model:t,address:e,scope:n,heading:{title:c.names?.plural??r(a.name),subtitle:c.help}})})}return(0,X.jsx)(va,{model:a,address:e})},va=({model:e,address:t,scope:n,heading:o})=>{let s=de(),{set:c,listTo:l,go:u,href:d}=x(),f=e.name,p=Be(s.views[f],t.list),_=(0,Z.useMemo)(()=>st(p,e),[p,e]),{fields:v}=re(),y=(0,Z.useMemo)(()=>ji(le(De(Ie(e,p),e,p,v),e,s.resources,s.views),e,p,s.resources,s.views),[e,p,v,s.resources,s.views]),b=t.filter,S=(0,Z.useMemo)(()=>ft(_,b),[_,b]),C=S.ok?S.state:Wt,w=S.ok?S.extras:[],{orderBy:T,filterLayout:E}=t,D=te(),ee=ie(),[ne,ae]=(0,Z.useState)(!1),oe=n?[...w,n]:w,se=Ye(),ce=jr({model:e,resources:s.resources,views:s.views,view:p,state:C,extras:oe,titleOf:se}),A=n?ut(_,C,oe):S.ok?b:``,j=(0,Z.useMemo)(()=>ge(e,p,y.map(e=>e.id)),[e,p,y]),ue=(0,Z.useMemo)(()=>ot(p,s.resources,s.views,j),[p,s.resources,s.views,j]),N=$t({resources:s.resources,views:s.views,model:e,columns:j,filter:A,orderBy:T,related:ue}),P=Pe(e,p,t.display),F=he(f),I=n?void 0:nn(e,F),[pe,L]=(0,Z.useState)(!1),R=pe&&I!==void 0,_e=!P&&!R&&tn(p,I,T,A),ye=R||P?.kind!==`map`;Se(ye);let be=rn(e,N.page,N.key,P?.kind===`custom`),z=xi(),Ce=me(e,p),we=e=>({key:e.id,title:String(typeof e[Ce]==`object`?e[Ce].name:e[Ce]??e.id),etag:typeof e.etag==`string`?e.etag:void 0,snapshot:e}),Te=p?.names?.singular??r(f),Ee=ma(e,p,F),{state:Oe}=Ue(),ke=Jt(e),Ae=Kt({model:e,view:p,restore:ke,onReview:e=>u({kind:`record`,resource:f,key:e.key})}),je=jt(e),Ne=p?.actions.some(e=>e.run?.kind===`delete`)??!1,B=(e,t=w)=>c({filter:ut(_,e,t)}),Re=ga(w),ze=e=>{let t=w.filter(e=>e.kind!==`search`);B(C,e?[...t,ha.search(e)]:t)},V=p?.names?.plural??r(f),H=P?.kind===`calendar`||P?.kind===`timeline`||P?.kind===`board`&&Fe(e)?void 0:P,He=H&&(0,X.jsx)(Et,{model:e,view:p,display:H,orderBy:T,onChange:e=>c({orderBy:e})}),U=e.search?.length?(0,X.jsx)(Ai,{value:Re?.kind===`search`?Re.text:``,onCommit:ze,placeholder:Y(`searchPlural`,{plural:V}),className:D?void 0:`min-h-11`}):null,We=(0,X.jsx)(Yn,{layout:E,config:ce,value:C,onChange:B,leading:E===`bar`?He:void 0,trailing:U}),Ke=E===`bar`?We:(0,X.jsx)(qn,{groups:[He?[He]:[]],trailing:U}),W=vt(ce,C),Xe=(0,X.jsx)(Dn,{scroll:!0,chips:W,onRemove:e=>B(lt(C,e)),onClear:()=>B(Wt)}),Ze=H&&(0,X.jsx)(Pn,{title:Y(`sort`),children:(0,X.jsx)(Et,{model:e,view:p,display:H,orderBy:T,onChange:e=>c({orderBy:e}),className:`min-h-11 w-full`})}),Qe=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(O,{className:`min-h-11`,onClick:()=>ae(!0),"aria-haspopup":`dialog`,children:[(0,X.jsx)(yn,{className:`size-3.5`}),W.length>0?Y(`filtersCount`,{count:W.length}):Y(`filters`)]}),U??(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:Xe})]}),U&&Xe,(0,X.jsx)(Le,{title:Y(`filters`),open:ne,onClose:()=>ae(!1),children:(0,X.jsx)(Yn,{layout:`panel`,fullWidth:!0,config:ce,value:C,onChange:B,leading:Ze})})]}),$e=!n&&qe(p,s.pages,F)&&(0,X.jsxs)(h,{to:{kind:`create`,resource:f},className:i({variant:`primary`}),children:[(0,X.jsx)(Ve,{className:`size-3.5`}),Y(`newRecord`,{singular:Te})]}),G=p?.saveSearch&&!n&&S.ok&&b&&(0,X.jsx)(ra,{model:e,view:p,search:p.saveSearch,filter:b,chips:pt(e,p,b,Mt(ce))}),et=!n&&(0,X.jsx)(Pr,{model:e}),K=Jr({model:e,view:p,resources:s.resources,views:s.views,plural:V,filter:A,orderBy:T}),nt=ir(p)&&(0,X.jsxs)(O,{onClick:()=>K.open(),...!D&&{"aria-label":Y(`export`),title:Y(`export`)},children:[(0,X.jsx)(Je,{className:`size-3.5`}),D&&Y(`export`)]}),rt=I&&!_e&&(0,X.jsx)(Yt,{sorting:R,onChange:L,iconOnly:!D}),it=t=>!R&&(0,X.jsx)(zt,{view:p,choices:fe(e,p,ee),value:P?.name??`table`,onChange:e=>c({display:e}),menu:t}),at=en(e),ct=t=>{at(m(e,t).record),u({kind:`record`,resource:f,key:M(e,t)})},q=async e=>{let t=e.map(we),n=await Ae.startBulk(t);return e.filter((e,r)=>n.includes(t[r]))},dt=N.source?(0,X.jsx)(_t,{columns:y,source:N.source,sort:a(T),onSortChange:e=>c({orderBy:xe(e)}),onOpenRow:ct,rowLink:t=>({href:d({kind:`record`,resource:f,key:M(e,t)}),onFollow:()=>ct(t)}),cellEditor:Ee.editor,rowPatches:Ee.patches,initialScrollIndex:z.initialIndex,onScrollIndex:z.remember,rowActions:[{label:Y(`openRecord`,{singular:Te}),onSelect:ct},...je.rowActions,...k(F,`delete`)&&!Ne?[{label:Y(`delete`),destructive:!0,available:e=>Ge(e,`delete`),onSelect:e=>void Ae.start(we(e))}]:[]],bulkActions:[...ir(p)&&ur(e)?[{label:e=>Y(`exportCount`,{count:e}),onRun:e=>K.open(e)}]:[],...je.bulkActions,...k(F,`delete`)?[{label:e=>Y(`deleteCount`,{count:e}),destructive:!0,onRun:e=>q(e)}]:[]],rowNumbers:!1,pinKey:Oe.kind===`signed-in`?Dt(Oe.user.id,ve(f,t.list)):void 0,scroll:`parent`,className:`flex-1`}):(0,X.jsx)(`div`,{"aria-busy":!0,className:`flex-1 rounded-lg border bg-surface`}),mt={...N,initialIndex:z.initialIndex,onScrollIndex:z.remember},ht=Xr({plural:V,search:Re?.kind===`search`?Re.text:``,filtered:W.length>0,scoped:!!n||w.some(e=>e.kind!==`search`),canCreate:!!$e}),gt=(0,X.jsx)(Yr,{state:ht,onClearSearch:()=>ze(``),onClearFilters:()=>B(Wt),create:$e}),yt=R?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`dragToSort`)}),(0,X.jsx)(qt,{model:e,view:p,field:I,filter:``,columns:g(e,p)})]}):_e?(0,X.jsx)(qt,{model:e,view:p,field:I,filter:``,columns:g(e,p),sort:{value:a(T),onChange:e=>c({orderBy:xe(e)})}}):P?P.kind===`cards`?(0,X.jsx)(di,{model:e,view:p,display:P,list:mt,empty:gt},N.key.join(` `)):P.kind===`map`?(0,X.jsx)(At,{model:e,view:p,display:P,filter:A,orderBy:T,fields:j,at:t.map,onMove:e=>c({map:e}),flush:!0}):P.kind===`board`?(0,X.jsx)(Ot,{model:e,view:p,display:P,fields:j,filter:A,orderBy:T}):P.kind===`calendar`?(0,X.jsx)(It,{model:e,view:p,display:P,fields:j,filter:A,at:t.calendar,linkTo:e=>l({calendar:e})}):P.kind===`timeline`?(0,X.jsx)(Pt,{model:e,view:p,display:P,fields:j,filter:A,at:t.timeline,linkTo:e=>l({timeline:e})}):(0,X.jsx)(Bt,{display:P,list:be}):N.source?.total===0&&!N.error?gt:dt;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[Ae.dialogs,K.dialogs,je.prompt,(0,X.jsx)(Zt,{title:o?.title??V,subtitle:o?o.subtitle:p?.help,subtitleBelow:!0,actions:(0,X.jsxs)(X.Fragment,{children:[it(!D),rt,G,et,nt,$e]})}),!S.ok&&(0,X.jsx)(Me,{title:Y(`unreadableFilter`),error:Error(S.errors.map(e=>e.message).join(`; `))}),N.error&&!P&&!R&&(0,X.jsx)(Me,{title:Y(`couldNotLoadRows`),error:N.error}),p?.chart&&!R&&(tt(p.chart)?(0,X.jsx)(ki,{model:e,view:p,chart:p.chart,plural:V,filter:A}):(0,X.jsx)(Di,{resource:f,chart:p.chart,title:Y(`created`,{plural:V}),filter:A})),!R&&(D?Ke:Qe),D&&E===`panel`&&!R?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,X.jsx)(`div`,{className:ye?`sticky top-[calc(var(--pb-sticky-top,0px)+1rem)] flex max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px)-2rem)] shrink-0 self-start`:`flex shrink-0`,children:We}),yt]}):yt]})};export{_a as ListPage,br as a,gr as c,pr as d,fr as f,ln as h,xr as i,mr as l,Q as m,Cr as n,_r as o,lr as p,Sr as r,yr as s,Tr as t,hr as u};
|
|
4
|
+
//# debugId=e2f00a40-994c-4972-a9d4-624703842f04
|
|
@@ -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{Mc as r,Vc as i,Vl as a,mo 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{Mc as r,Vc as i,Vl as a,mo as o}from"./app-DKn-6fgf.js";import{i as s,n as c,r as l,t as u}from"./lib-maplibre-gl-CFGgq6sa.js";import{n as d,o as f,t as p}from"./lib-vis.gl-react-maplibre-1cv426UN.js";import{t as m}from"./lib-pmtiles-G7iEFxNu.js";var h={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};h.node;var g=r(h),_=e(t(),1),v=`protobase:map-layer`,y=(e,t)=>e.find(e=>e.id===t),b=e=>a(()=>e.getItem(v),null),x=(e,t)=>a(()=>t===void 0?e.removeItem(v):e.setItem(v,t),void 0),S=i(`app/map`),C=e(n(),1),w=``,T=({layers:e,below:t})=>{let[n,r]=(0,_.useState)(()=>b(localStorage)),{current:i}=f();if(!e||e.length===0)return null;let a=y(e,n),s=e=>{let t=e===w?void 0:e;x(localStorage,t),r(t??null)},c=t&&i?.getLayer(t)?t:void 0;return(0,C.jsxs)(C.Fragment,{children:[a&&(0,C.jsx)(d,{id:`map-layer-${a.id}`,type:`raster`,tiles:[a.tiles],tileSize:256,attribution:a.attribution,maxzoom:a.maxzoom??22,...a.bounds&&{bounds:a.bounds},children:(0,C.jsx)(p,{id:`map-layer-${a.id}`,type:`raster`,...c&&{beforeId:c}})},a.id),(0,C.jsx)(`div`,{className:`absolute left-2.5 top-2.5 z-10 rounded-md shadow`,children:(0,C.jsx)(o,{label:S(`mapLayer`),value:a?.id??w,onChange:s,options:[{value:w,label:S(`map`)},...e.map(e=>({value:e.id,label:e.label}))]})})]})};l(u),c(`pmtiles`,new m().tile);var E=s;export{T as n,g as r,E as t};
|
|
2
|
+
//# debugId=74a0f6bf-e5e4-44bb-9d7d-a3199c5806ee
|
|
@@ -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{L as r,Nc as i}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{L as r,Nc as i}from"./app-DKn-6fgf.js";import{t as a}from"./lib-dompurify-Dr60P-Rn.js";import{t as o}from"./lib-marked-Bg9_sE-m.js";var s=e(t(),1),c=(e,t)=>t===0?e:Math.min(6,Math.max(t+1,e+t-1)),l={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},u=e=>e.replace(/[&<>"']/g,e=>l[e]),d=/^([a-z][a-z0-9+.-]*):/i,f=new Set([`http`,`https`,`mailto`,`tel`]),p=new Set([`http`,`https`]),m=/[\u0000-\u0020\u007f]/g,h=(e,t)=>{let n=d.exec(e.replace(m,``))?.[1]?.toLowerCase();if(n!==void 0&&!t.has(n))return null;try{return encodeURI(e).replace(/%25/g,`%`)}catch(e){if(e instanceof URIError)return null;throw e}},g=e=>e?` title="${u(e)}"`:``,_=({inLink:e=!1})=>new o({gfm:!0,breaks:!0,renderer:{html:({text:e,block:t})=>t?`<p>${u(e)}</p>`:u(e),link({href:t,title:n,tokens:r}){let i=this.parser.parseInline(r),a=e?null:h(t,f);return a===null?i:`<a href="${u(a)}"${g(n)} target="_blank" rel="noopener noreferrer nofollow">${i}</a>`},image({href:t,title:n,text:r}){let i=e?null:h(t,p);return i===null?u(r):`<img src="${u(i)}" alt="${u(r)}"${g(n)} loading="lazy">`}}}),v={inLink:_({inLink:!0}),page:_({})},y=(e,{inLink:t=!1,headingsUnder:n=0}={})=>{let r=t?v.inLink:v.page,i=r.lexer(e);return r.walkTokens(i,e=>{e.type===`heading`&&(e.depth=c(e.depth,n))}),r.parser(i)},b=e(n(),1),x=i(`break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,`[&_p]:my-2 [&_ul]:my-2 [&_ol]:my-2 [&_pre]:my-2 [&_blockquote]:my-2 [&_table]:my-2 [&_hr]:my-3`,`[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h2]:mt-4 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold`,`[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:font-semibold [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:font-semibold [&_h5]:font-semibold [&_h6]:font-semibold`,`[&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li:has(>input)]:list-none [&_li>input]:mr-1.5 [&_li>input]:-ml-5 [&_li>input]:align-middle`,`[&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 hover:[&_a]:text-primary-hover`,`[&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]`,`[&_pre]:whitespace-pre-wrap [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0`,`[&_blockquote]:border-l-2 [&_blockquote]:border-border-strong [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground`,`[&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold`,`[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1 [&_td]:[overflow-wrap:anywhere]`,`[&_hr]:border-border [&_img]:inline [&_img]:max-w-full [&_img]:rounded [&_del]:text-muted-foreground`),S=i(`[&_*]:my-0 [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold [&_ul]:list-inside [&_ol]:list-inside [&_pre]:whitespace-pre-wrap [&_code]:font-mono [&_code]:text-[0.9em]`),C=({source:e,inLink:t=!1,className:n})=>{let o=r(),c=(0,s.useMemo)(()=>a.sanitize(y(e,{inLink:t,headingsUnder:o}),{ADD_ATTR:[`target`]}),[e,t,o]);return(0,b.jsx)(`div`,{className:i(t?S:x,n),dangerouslySetInnerHTML:{__html:c}})};export{C as MarkdownContent};
|
|
2
|
+
//# debugId=80ef8a1f-077f-4d27-8610-55b8363ce105
|