@protobase/ui 0.118.1 → 0.119.1

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.
Files changed (260) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/charts/messages.d.ts +2 -2
  3. package/dist/app/comments/messages.d.ts +2 -2
  4. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  5. package/dist/app/create/messages.d.ts +2 -2
  6. package/dist/app/delete/messages.d.ts +2 -2
  7. package/dist/app/displays/messages.d.ts +2 -2
  8. package/dist/app/export/messages.d.ts +2 -2
  9. package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
  10. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  11. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  12. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  13. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  14. package/dist/app/file-viewers/messages.d.ts +2 -2
  15. package/dist/app/focus/messages.d.ts +2 -2
  16. package/dist/app/hand-order/messages.d.ts +2 -2
  17. package/dist/app/import/messages.d.ts +2 -2
  18. package/dist/app/list-messages.d.ts +2 -2
  19. package/dist/app/messages.d.ts +2 -2
  20. package/dist/app/meta-gate-messages.d.ts +2 -2
  21. package/dist/app/opened-address.d.ts +9 -0
  22. package/dist/app/opened-address.js +14 -0
  23. package/dist/app/pages/messages.d.ts +2 -2
  24. package/dist/app/record-chart/messages.d.ts +2 -2
  25. package/dist/app/record-messages.d.ts +2 -2
  26. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  27. package/dist/app/record-opens.d.ts +1 -6
  28. package/dist/app/record-opens.js +2 -12
  29. package/dist/app/record-page.js +2 -1
  30. package/dist/app/record-row/messages.d.ts +2 -2
  31. package/dist/app/related-cards/messages.d.ts +2 -2
  32. package/dist/app/runtime/messages.d.ts +2 -2
  33. package/dist/app/saved/messages.d.ts +2 -2
  34. package/dist/app/saved/use-favorite.d.ts +1 -1
  35. package/dist/app/search/search-model.d.ts +7 -3
  36. package/dist/app/search/search-model.js +13 -6
  37. package/dist/app/searches/messages.d.ts +2 -2
  38. package/dist/app/searches/use-save-search.d.ts +1 -1
  39. package/dist/app-shell/messages.d.ts +2 -2
  40. package/dist/assistant-dock/messages.d.ts +2 -2
  41. package/dist/auth/auth-messages.d.ts +2 -0
  42. package/dist/auth/auth-messages.js +3 -1
  43. package/dist/auth/messages.d.ts +2 -2
  44. package/dist/filter-panel/messages.d.ts +2 -2
  45. package/dist/forms/messages.d.ts +2 -2
  46. package/dist/invitations/messages.d.ts +2 -2
  47. package/dist/locale/en.js +4 -1
  48. package/dist/locale/en.json.d.ts +3 -0
  49. package/dist/locale/messages.d.ts +6 -0
  50. package/dist/locale/nl.js +4 -1
  51. package/dist/mocks/customers.d.ts +1 -1
  52. package/dist/mocks/invoices.d.ts +1 -1
  53. package/dist/mocks/orders.d.ts +3 -3
  54. package/dist/notifications/bell/messages.d.ts +2 -2
  55. package/dist/organizations/first-organization-page.js +5 -7
  56. package/dist/organizations/messages.d.ts +2 -2
  57. package/dist/organizations/my-invitation-row.d.ts +6 -2
  58. package/dist/organizations/my-invitation-row.js +8 -3
  59. package/dist/organizations/new-organization-form.js +3 -2
  60. package/dist/organizations/organizations-page.js +4 -6
  61. package/dist/organizations/use-action.d.ts +10 -1
  62. package/dist/organizations/use-action.js +25 -15
  63. package/dist/organizations/use-join-invitation.d.ts +9 -0
  64. package/dist/organizations/use-join-invitation.js +25 -0
  65. package/dist/package.js +1 -1
  66. package/dist/plugins/messages.d.ts +2 -2
  67. package/dist/primitives/button.d.ts +4 -2
  68. package/dist/primitives/button.js +23 -15
  69. package/dist/shell/assets/{account-page-D9hXd-u3.js → account-page-BXnceUQo.js} +2 -2
  70. package/dist/shell/assets/app-D3BCcbgE.js +34 -0
  71. package/dist/shell/assets/{assistant-shell-DDkCxLNG.js → assistant-shell-DKf9TfL2.js} +2 -2
  72. package/dist/shell/assets/board-display-DJkQwIfT.js +2 -0
  73. package/dist/shell/assets/calendar-display-BKyuHAAF.js +2 -0
  74. package/dist/shell/assets/{call-rings-B5rBD5EL.js → call-rings-D_kQbFd3.js} +2 -2
  75. package/dist/shell/assets/{calls-z1AEvYOC.js → calls-D6jSGMCo.js} +2 -2
  76. package/dist/shell/assets/{circle-alert-C_1i142n.js → circle-alert-ytReRN_c.js} +2 -2
  77. package/dist/shell/assets/{composed-page--UJ8tsC0.js → composed-page-CbNBBioS.js} +2 -2
  78. package/dist/shell/assets/{composer-section-tfrO2pIi.js → composer-section-cg-cdFZx.js} +2 -2
  79. package/dist/shell/assets/{connect-route-rVNQDWcE.js → connect-route-hMUPiAft.js} +2 -2
  80. package/dist/shell/assets/{copy-field-D9agQmK0.js → copy-field-BoXXafL7.js} +2 -2
  81. package/dist/shell/assets/create-route-BePHRkTZ.js +2 -0
  82. package/dist/shell/assets/{custom-step-container-field-BanmPoI-.js → custom-step-container-field-B3bsPeCV.js} +4 -4
  83. package/dist/shell/assets/embedded-list-6lQyJozS.js +3 -0
  84. package/dist/shell/assets/{en-BrEwbNhJ.js → en-dURxhEht.js} +2 -2
  85. package/dist/shell/assets/{export-dialog-g69vJ8j2.js → export-dialog-BUbdSkkU.js} +2 -2
  86. package/dist/shell/assets/export-worker-DfIG4xQy.js +15 -0
  87. package/dist/shell/assets/first-organization-page-BhQOFT5P.js +2 -0
  88. package/dist/shell/assets/{graph-view-DXDcn-Fx.js → graph-view-DZHMI-UQ.js} +2 -2
  89. package/dist/shell/assets/{group-donut-B3bCn83A.js → group-donut-Cu5Ny3gq.js} +2 -2
  90. package/dist/shell/assets/{guest-call-page-rAD4EXPd.js → guest-call-page-DlAkbaRH.js} +3 -3
  91. package/dist/shell/assets/{html-viewer-BxhCE5h2.js → html-viewer-DrSS-WnU.js} +2 -2
  92. package/dist/shell/assets/{import-dialog-adjnDUuk.js → import-dialog-Dk_31-PT.js} +2 -2
  93. package/dist/shell/assets/import-table-dialog-vL-juOMH.js +2 -0
  94. package/dist/shell/assets/{index-BBHelxJ2.js → index-CTmZ8-B4.js} +1 -1
  95. package/dist/shell/assets/invitations-page-CfTEdorg.js +2 -0
  96. package/dist/shell/assets/{layout-grid-B3Php1Rf.js → layout-grid-CTlIrnH5.js} +2 -2
  97. package/dist/shell/assets/{legend-item-BbV6BD6w.js → legend-item-CqkLpsWb.js} +2 -2
  98. package/dist/shell/assets/list-page-Czg2Jaxx.js +4 -0
  99. package/dist/shell/assets/{maplibre-D4xk_BLC.js → maplibre-Bd79IbdT.js} +2 -2
  100. package/dist/shell/assets/{markdown-content-CnNrPGcY.js → markdown-content-BGl9PFVi.js} +2 -2
  101. package/dist/shell/assets/members-page-CEB-Wkl8.js +2 -0
  102. package/dist/shell/assets/messages-Ce8dRRRN.js +2 -0
  103. package/dist/shell/assets/{nl-Dto12ewP.js → nl-B0dpIbbz.js} +2 -2
  104. package/dist/shell/assets/organization-page-CTxtblmm.js +2 -0
  105. package/dist/shell/assets/organizations-page-DeNhUQDU.js +2 -0
  106. package/dist/shell/assets/parse-worker-VaelBbE0.js +35 -0
  107. package/dist/shell/assets/{pending-invitation-row-D_vU7ynw.js → pending-invitation-row-BMp0ZxE8.js} +2 -2
  108. package/dist/shell/assets/{period-chart-DPlEbvX7.js → period-chart-BDqtO8mc.js} +2 -2
  109. package/dist/shell/assets/{person-row-DMY-aQjx.js → person-row-DRqtbPma.js} +2 -2
  110. package/dist/shell/assets/public-form-page-XgK3-Nzh.js +2 -0
  111. package/dist/shell/assets/{record-lines-SeXhFNSm.js → record-lines-DdN5hlI_.js} +2 -2
  112. package/dist/shell/assets/{record-map-BiLFEqYi.js → record-map-sOmjX80D.js} +2 -2
  113. package/dist/shell/assets/{record-opens-Ct9iF9FZ.js → record-opens-DLfbC3xo.js} +2 -2
  114. package/dist/shell/assets/record-page-BntRofCL.js +3 -0
  115. package/dist/shell/assets/{record-preview-J1o4Sqs-.js → record-preview-QMV2lW2j.js} +2 -2
  116. package/dist/shell/assets/{records-map-Cwdig5mb.js → records-map-DgTxGcbC.js} +2 -2
  117. package/dist/shell/assets/render-node-CkL5Sgl_.js +3 -0
  118. package/dist/shell/assets/reorder-button-8yWv8J72.js +2 -0
  119. package/dist/shell/assets/{run-trace-view-1fk6kU1U.js → run-trace-view-BPvPw3Ko.js} +2 -2
  120. package/dist/shell/assets/{runner-install-field-C_hTvogl.js → runner-install-field-CKP8E9ZO.js} +2 -2
  121. package/dist/shell/assets/{runtime-update-8hRmQkq-.js → runtime-update-DGbf2Nmm.js} +2 -2
  122. package/dist/shell/assets/shared-protobase-ui-DN-uvpOy.js +1 -0
  123. package/dist/shell/assets/{sheet-source-CD5hImgE.js → sheet-source-cKJfUaud.js} +3 -3
  124. package/dist/shell/assets/sign-in-policy-page-Bty4Ih1x.js +2 -0
  125. package/dist/shell/assets/start-block-queries-x-gNbPt1.js +2 -0
  126. package/dist/shell/assets/step-catalog-CCAXc8kn.js +2 -0
  127. package/dist/shell/assets/{step-panel-BVdV2FNT.js → step-panel-jmfh86YA.js} +2 -2
  128. package/dist/shell/assets/timeline-display-CtxOHPoJ.js +2 -0
  129. package/dist/shell/assets/{trash-5PpoeP3R.js → trash-CFCBxAWq.js} +2 -2
  130. package/dist/shell/assets/{update-set-BnRA9YhA.js → update-set-BYNQUWVp.js} +2 -2
  131. package/dist/shell/assets/use-calendar-move-BytgRG51.js +2 -0
  132. package/dist/shell/assets/{use-display-rows-ERQ-vbki.js → use-display-rows-DGw9J73C.js} +2 -2
  133. package/dist/shell/assets/use-my-invitations-BcMFAcXl.js +2 -0
  134. package/dist/shell/assets/{use-paged-search-CcEitpWG.js → use-paged-search-CKcKKO6y.js} +2 -2
  135. package/dist/shell/assets/{use-run-trace-CV461SQS.js → use-run-trace-BRwbwZcf.js} +2 -2
  136. package/dist/shell/assets/{use-workflow-page-peSmP1Jq.js → use-workflow-page-DsD276W-.js} +2 -2
  137. package/dist/shell/assets/{use-workflow-types-xM8CZO96.js → use-workflow-types-Bn24Chp-.js} +2 -2
  138. package/dist/shell/assets/{workflow-canvas-CkKd9u0-.js → workflow-canvas-BKd_Yd0v.js} +4 -4
  139. package/dist/shell/assets/{workflow-field-WovRhNaT.js → workflow-field-DyBaV6m5.js} +3 -3
  140. package/dist/shell/assets/{workflow-graph-editor-DRZ2UtBp.js → workflow-graph-editor-B8RJ52_E.js} +2 -2
  141. package/dist/shell/assets/{workflow-run-field-CrBAVhOq.js → workflow-run-field-CzluYhjs.js} +3 -3
  142. package/dist/shell/assets/workflow-status-field-_umgNjK4.js +2 -0
  143. package/dist/shell/assets/workflow-workbench-CqOI36Oy.js +4 -0
  144. package/dist/shell/index.html +3 -3
  145. package/dist/shell/protobase.shell.json +2 -2
  146. package/dist/shell/protobase.sw.js +2 -2
  147. package/dist/shell-source-maps/assets/{account-page-D9hXd-u3.js.map → account-page-BXnceUQo.js.map} +1 -1
  148. package/dist/shell-source-maps/assets/app-D3BCcbgE.js.map +1 -0
  149. package/dist/shell-source-maps/assets/{assistant-shell-DDkCxLNG.js.map → assistant-shell-DKf9TfL2.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{board-display-plYPsh6z.js.map → board-display-DJkQwIfT.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{calendar-display-B3kFBd2k.js.map → calendar-display-BKyuHAAF.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{call-rings-B5rBD5EL.js.map → call-rings-D_kQbFd3.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{calls-z1AEvYOC.js.map → calls-D6jSGMCo.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{circle-alert-C_1i142n.js.map → circle-alert-ytReRN_c.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{composed-page--UJ8tsC0.js.map → composed-page-CbNBBioS.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{composer-section-tfrO2pIi.js.map → composer-section-cg-cdFZx.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{connect-route-rVNQDWcE.js.map → connect-route-hMUPiAft.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{copy-field-D9agQmK0.js.map → copy-field-BoXXafL7.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{create-route-C4xN9aXd.js.map → create-route-BePHRkTZ.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{custom-step-container-field-BanmPoI-.js.map → custom-step-container-field-B3bsPeCV.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{embedded-list-B_e_Quer.js.map → embedded-list-6lQyJozS.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/en-dURxhEht.js.map +1 -0
  163. package/dist/shell-source-maps/assets/{export-dialog-g69vJ8j2.js.map → export-dialog-BUbdSkkU.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/export-worker-DfIG4xQy.js.map +1 -0
  165. package/dist/shell-source-maps/assets/first-organization-page-BhQOFT5P.js.map +1 -0
  166. package/dist/shell-source-maps/assets/{graph-view-DXDcn-Fx.js.map → graph-view-DZHMI-UQ.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{group-donut-B3bCn83A.js.map → group-donut-Cu5Ny3gq.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{guest-call-page-rAD4EXPd.js.map → guest-call-page-DlAkbaRH.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{html-viewer-BxhCE5h2.js.map → html-viewer-DrSS-WnU.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{import-dialog-adjnDUuk.js.map → import-dialog-Dk_31-PT.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{import-table-dialog-yV9UTlBY.js.map → import-table-dialog-vL-juOMH.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{invitations-page-FKTUQL8J.js.map → invitations-page-CfTEdorg.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{layout-grid-B3Php1Rf.js.map → layout-grid-CTlIrnH5.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{legend-item-BbV6BD6w.js.map → legend-item-CqkLpsWb.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{list-page-CNhV2TuF.js.map → list-page-Czg2Jaxx.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{maplibre-D4xk_BLC.js.map → maplibre-Bd79IbdT.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{markdown-content-CnNrPGcY.js.map → markdown-content-BGl9PFVi.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{members-page-CnxFoeyp.js.map → members-page-CEB-Wkl8.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{messages-BHPGrBhJ.js.map → messages-Ce8dRRRN.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/nl-B0dpIbbz.js.map +1 -0
  181. package/dist/shell-source-maps/assets/{organization-page-B6k9pMkb.js.map → organization-page-CTxtblmm.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/organizations-page-DeNhUQDU.js.map +1 -0
  183. package/dist/shell-source-maps/assets/parse-worker-VaelBbE0.js.map +1 -0
  184. package/dist/shell-source-maps/assets/{pending-invitation-row-D_vU7ynw.js.map → pending-invitation-row-BMp0ZxE8.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{period-chart-DPlEbvX7.js.map → period-chart-BDqtO8mc.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{person-row-DMY-aQjx.js.map → person-row-DRqtbPma.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{public-form-page-DTgXLDpt.js.map → public-form-page-XgK3-Nzh.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{record-lines-SeXhFNSm.js.map → record-lines-DdN5hlI_.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{record-map-BiLFEqYi.js.map → record-map-sOmjX80D.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/record-opens-DLfbC3xo.js.map +1 -0
  191. package/dist/shell-source-maps/assets/{record-page-TxDSHcMe.js.map → record-page-BntRofCL.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{record-preview-J1o4Sqs-.js.map → record-preview-QMV2lW2j.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{records-map-Cwdig5mb.js.map → records-map-DgTxGcbC.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{render-node-BpHo-wre.js.map → render-node-CkL5Sgl_.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{reorder-button-CBOmzmhg.js.map → reorder-button-8yWv8J72.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{run-trace-view-1fk6kU1U.js.map → run-trace-view-BPvPw3Ko.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{runner-install-field-C_hTvogl.js.map → runner-install-field-CKP8E9ZO.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{runtime-update-8hRmQkq-.js.map → runtime-update-DGbf2Nmm.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/{sheet-source-CD5hImgE.js.map → sheet-source-cKJfUaud.js.map} +1 -1
  200. package/dist/shell-source-maps/assets/{sign-in-policy-page-BQ8ck7Ar.js.map → sign-in-policy-page-Bty4Ih1x.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{start-block-queries-4uvupY9E.js.map → start-block-queries-x-gNbPt1.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/{step-catalog-B2eQNTOp.js.map → step-catalog-CCAXc8kn.js.map} +1 -1
  203. package/dist/shell-source-maps/assets/{step-panel-BVdV2FNT.js.map → step-panel-jmfh86YA.js.map} +1 -1
  204. package/dist/shell-source-maps/assets/{timeline-display-BxihBkFH.js.map → timeline-display-CtxOHPoJ.js.map} +1 -1
  205. package/dist/shell-source-maps/assets/{trash-5PpoeP3R.js.map → trash-CFCBxAWq.js.map} +1 -1
  206. package/dist/shell-source-maps/assets/{update-set-BnRA9YhA.js.map → update-set-BYNQUWVp.js.map} +1 -1
  207. package/dist/shell-source-maps/assets/{use-calendar-move-Bu9MSBcs.js.map → use-calendar-move-BytgRG51.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/{use-display-rows-ERQ-vbki.js.map → use-display-rows-DGw9J73C.js.map} +1 -1
  209. package/dist/shell-source-maps/assets/use-my-invitations-BcMFAcXl.js.map +1 -0
  210. package/dist/shell-source-maps/assets/{use-paged-search-CcEitpWG.js.map → use-paged-search-CKcKKO6y.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{use-run-trace-CV461SQS.js.map → use-run-trace-BRwbwZcf.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{use-workflow-page-peSmP1Jq.js.map → use-workflow-page-DsD276W-.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{use-workflow-types-xM8CZO96.js.map → use-workflow-types-Bn24Chp-.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{workflow-canvas-CkKd9u0-.js.map → workflow-canvas-BKd_Yd0v.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{workflow-field-WovRhNaT.js.map → workflow-field-DyBaV6m5.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{workflow-graph-editor-DRZ2UtBp.js.map → workflow-graph-editor-B8RJ52_E.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{workflow-run-field-CrBAVhOq.js.map → workflow-run-field-CzluYhjs.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/workflow-status-field-_umgNjK4.js.map +1 -0
  219. package/dist/shell-source-maps/assets/{workflow-workbench-D8vU7ifz.js.map → workflow-workbench-CqOI36Oy.js.map} +1 -1
  220. package/dist/status/messages.d.ts +2 -2
  221. package/dist/users/messages.d.ts +2 -2
  222. package/package.json +5 -5
  223. package/dist/shell/assets/app-D6luJ1k4.js +0 -34
  224. package/dist/shell/assets/board-display-plYPsh6z.js +0 -2
  225. package/dist/shell/assets/calendar-display-B3kFBd2k.js +0 -2
  226. package/dist/shell/assets/create-route-C4xN9aXd.js +0 -2
  227. package/dist/shell/assets/embedded-list-B_e_Quer.js +0 -3
  228. package/dist/shell/assets/export-worker-DuHOhIiP.js +0 -15
  229. package/dist/shell/assets/first-organization-page-Cijgw9tC.js +0 -2
  230. package/dist/shell/assets/import-table-dialog-yV9UTlBY.js +0 -2
  231. package/dist/shell/assets/invitations-page-FKTUQL8J.js +0 -2
  232. package/dist/shell/assets/list-page-CNhV2TuF.js +0 -4
  233. package/dist/shell/assets/members-page-CnxFoeyp.js +0 -2
  234. package/dist/shell/assets/messages-BHPGrBhJ.js +0 -2
  235. package/dist/shell/assets/organization-page-B6k9pMkb.js +0 -2
  236. package/dist/shell/assets/organizations-page-D33Ruydz.js +0 -2
  237. package/dist/shell/assets/parse-worker-BRxyLV_D.js +0 -35
  238. package/dist/shell/assets/public-form-page-DTgXLDpt.js +0 -2
  239. package/dist/shell/assets/record-page-TxDSHcMe.js +0 -3
  240. package/dist/shell/assets/render-node-BpHo-wre.js +0 -3
  241. package/dist/shell/assets/reorder-button-CBOmzmhg.js +0 -2
  242. package/dist/shell/assets/shared-protobase-ui-Tq2sgl9G.js +0 -1
  243. package/dist/shell/assets/sign-in-policy-page-BQ8ck7Ar.js +0 -2
  244. package/dist/shell/assets/start-block-queries-4uvupY9E.js +0 -2
  245. package/dist/shell/assets/step-catalog-B2eQNTOp.js +0 -2
  246. package/dist/shell/assets/timeline-display-BxihBkFH.js +0 -2
  247. package/dist/shell/assets/use-calendar-move-Bu9MSBcs.js +0 -2
  248. package/dist/shell/assets/use-my-invitations-CnAvjXV0.js +0 -2
  249. package/dist/shell/assets/workflow-status-field-DgjtbjlH.js +0 -2
  250. package/dist/shell/assets/workflow-workbench-D8vU7ifz.js +0 -4
  251. package/dist/shell-source-maps/assets/app-D6luJ1k4.js.map +0 -1
  252. package/dist/shell-source-maps/assets/en-BrEwbNhJ.js.map +0 -1
  253. package/dist/shell-source-maps/assets/export-worker-DuHOhIiP.js.map +0 -1
  254. package/dist/shell-source-maps/assets/first-organization-page-Cijgw9tC.js.map +0 -1
  255. package/dist/shell-source-maps/assets/nl-Dto12ewP.js.map +0 -1
  256. package/dist/shell-source-maps/assets/organizations-page-D33Ruydz.js.map +0 -1
  257. package/dist/shell-source-maps/assets/parse-worker-BRxyLV_D.js.map +0 -1
  258. package/dist/shell-source-maps/assets/record-opens-Ct9iF9FZ.js.map +0 -1
  259. package/dist/shell-source-maps/assets/use-my-invitations-CnAvjXV0.js.map +0 -1
  260. package/dist/shell-source-maps/assets/workflow-status-field-DgjtbjlH.js.map +0 -1
@@ -1,2 +0,0 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Gs as r,Jc as i,R as a,Yc as o,_ as s,a as c,b as l,c as u,cc as d,cs as f,es as p,i as m,lo as h,mr as g,o as _,oc as v,rs as y,sl as b,so as x,u as S,v as C,y as w}from"./app-D6luJ1k4.js";import{o as T}from"./vendor-t7Q7QbPu.js";import{n as E,t as D}from"./lib-altcha-lib-BK1uKcxH.js";var O=e(t(),1),k=o(`forms`),A=async(e,t)=>{let n=await e.formChallenge(t),r=await E({challenge:n,deriveKey:D});if(!r)throw Error(k(`checkTooLong`));return{challenge:n,solution:{counter:r.counter,derivedKey:r.derivedKey}}},j=e(n(),1),M=({name:e})=>{let t=f(),n=T({queryKey:i.publicForm(e),queryFn:()=>t.form(e)});return n.isPending?(0,j.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,j.jsx)(d,{}),` `,k(`loading`)]}):n.error?r(n.error)&&n.error.status===404?(0,j.jsx)(p,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(p,{title:y(`cannotReach`),children:r(n.error)?n.error.message:y(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=f(),{resource:n,view:r}=e,i=e.title??r.names?.singular??b(r.resource);h(i);let[o,d]=(0,O.useState)(()=>_(n,[{title:i,fields:e.fields}])),[p,y]=(0,O.useState)({}),[T,E]=(0,O.useState)(),[D,M]=(0,O.useState)(!1),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(0),L=s(F);if(N)return(0,j.jsx)(x,{title:i,size:`md`,children:(0,j.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:e.thanks})});let R=(e,t)=>{y(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),d(n=>({...n,[e]:t}))},z=async()=>{M(!0),E(void 0);try{await t.submitForm(e.name,m(n,{},o),await A(t,e.name)),P(!0)}catch(e){let t=C(e);y(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(x,{title:i,size:`md`,children:(0,j.jsxs)(`form`,{ref:L,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),z()},children:[e.fields.map(e=>{let t=n.fields[e],i=r.fields[e],s=i?.label??b(e),d=p[e];return(0,j.jsx)(a,{name:e,label:s,help:i?.help,required:u(t),error:d&&w(t,s,d),children:(0,j.jsx)(l,{field:t,hints:i,value:o[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:c(t)?k(`setByDatabase`):S(t),invalid:!!d,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(g,{title:k(`notSent`),error:T}),(0,j.jsx)(v,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
2
- //# debugId=d38172c3-a6d5-42f7-833c-dca95fbd7cd1
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-BiLFEqYi.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-D4xk_BLC.js","assets/app-D6luJ1k4.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.css","assets/lib-maplibre-gl-CFGgq6sa.js","assets/lib-maplibre-gl-DBE96hFo.css","assets/lib-vis.gl-react-maplibre-1cv426UN.js","assets/lib-pmtiles-G7iEFxNu.js","assets/lib-fflate-HbhbPPwS.js","assets/record-lines-SeXhFNSm.js","assets/embedded-list-B_e_Quer.js","assets/update-set-BnRA9YhA.js","assets/layout-grid-B3Php1Rf.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-J1o4Sqs-.js","assets/lib-dnd-kit-core-xi-7xL_N.js","assets/lib-dnd-kit-utilities-Bvr0fWXF.js","assets/lib-dnd-kit-accessibility-AUTLnqh4.js","assets/lib-dnd-kit-sortable-CNDSKqCD.js","assets/composer-section-tfrO2pIi.js","assets/render-node-BpHo-wre.js","assets/circle-alert-C_1i142n.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-D_vU7ynw.js","assets/person-row-DMY-aQjx.js","assets/use-paged-search-CcEitpWG.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-D9agQmK0.js"])))=>i.map(i=>d[i]);
2
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,r as n,t as r}from"./react-CuiNlnus.js";import{$ as i,Aa as a,An as o,Bc as s,Bn as c,C as l,Ca as u,Ci as d,D as f,Di as p,Dl as m,Dn as h,Dr as g,Dt as _,E as v,Et as y,Fc as b,Fi as x,Fo as ee,Gl as S,Gs as C,Ha as te,Hn as w,I as ne,Ia as T,Io as E,Jc as D,Ji as O,Jn as k,La as re,Li as ie,Lr as A,Lt as ae,Mc as j,Mn as oe,Mo as se,Na as ce,Nc as le,No as ue,O as de,Oi as fe,On as pe,Or as me,Ot as he,P as M,Pi as ge,Po as _e,Pr as ve,Qc as ye,R as be,Ro as xe,Rr as Se,Sa as Ce,Si as we,Tr as Te,Tt as Ee,Ul as N,Vc as P,Xo as De,Yc as F,Yl as Oe,Ys as I,Z as ke,Zl as L,Zs as Ae,_ as je,_i as Me,_n as R,ac as Ne,b as Pe,ba as Fe,bn as Ie,bo as Le,cs as z,ct as B,d as Re,di as ze,dl as Be,ea as Ve,ec as V,en as He,es as Ue,et as We,f as Ge,g as H,ga as Ke,gi as qe,h as Je,hi as Ye,hs as Xe,it as Ze,ji as Qe,jn as $e,k as et,l as tt,li as nt,m as rt,mn as it,mr as U,nc as at,nl as ot,nr as st,ns as ct,nt as lt,oc as W,ot as ut,p as dt,po as ft,rc as G,rr as pt,rt as mt,s as ht,sa as gt,sc as _t,sl as K,st as vt,tc as yt,ts as q,uc as bt,un as xt,v as St,vc as Ct,vi as wt,vl as Tt,vo as Et,vs as Dt,w as Ot,wa as kt,wn as At,wr as jt,x as Mt,xi as Nt,xn as Pt,y as Ft,ya as It,yn as Lt,yo as Rt,zo as zt}from"./app-D6luJ1k4.js";import{C as Bt,h as Vt,i as Ht,o as Ut,r as Wt,s as Gt}from"./vendor-t7Q7QbPu.js";import{Ct as Kt,Dt as qt,Et as Jt,Mt as Yt,Tt as Xt,_ as Zt,a as Qt,c as $t,lt as en,n as tn,ot as nn,pt as rn,rt as an,s as on,t as sn,tt as cn,yt as ln}from"./embedded-list-B_e_Quer.js";import{a as un,i as dn,n as fn,r as pn,t as mn}from"./reorder-button-CBOmzmhg.js";import{a as hn,c as gn,i as _n,l as vn,n as yn,o as bn,r as xn,s as Sn,t as Cn}from"./render-node-BpHo-wre.js";import{t as wn}from"./trash-5PpoeP3R.js";import{n as Tn,t as En}from"./record-sidebar-HqyBXBwn.js";import{t as Dn}from"./start-block-queries-4uvupY9E.js";import{n as On,t as kn}from"./record-opens-Ct9iF9FZ.js";import{u as An}from"./messages-BHPGrBhJ.js";var jn={name:`images`,size:24,node:[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]};jn.node;var Mn=s(jn),Nn={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};Nn.node;var Pn=s(Nn),Fn={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};Fn.node;var In=s(Fn),Ln={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Ln.node;var Rn=s(Ln),zn={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};zn.node;var Bn=s(zn),J=e(r(),1),Vn=({collection:e,title:t,badge:n,lastEditedBy:r,presence:i=[],actions:a})=>(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 border-b border-border pb-6 md:flex-row md:items-end md:justify-between md:gap-6`,children:[(0,J.jsxs)(`div`,{children:[e&&(0,J.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-foreground md:text-2xl`,children:t}),n]}),r&&(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:r.name?(0,J.jsxs)(J.Fragment,{children:[B(`lastEditedBy`),` `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,J.jsx)(J.Fragment,{children:B(`lastUpdated`,{ago:r.ago})})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[i.length>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(ee,{people:i,size:`md`}),B(`viewing`,{count:i.length})]}),a]})]}),Y=e(t(),1),Hn=`text-base font-semibold text-foreground`,Un=({title:e,help:t,count:n,open:r,toggle:i,children:a})=>{let o=(0,Y.useId)();return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:P(`py-8`,r&&`pb-0`),children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,J.jsxs)(A,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:P(`inline-flex items-center gap-1.5`,Hn),children:[(0,J.jsx)(j,{className:P(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,J.jsx)(`span`,{className:Hn,children:e}),n]}),t&&(0,J.jsx)(`p`,{className:P(`mt-1 max-w-xl leading-6 text-muted-foreground`,i&&`pl-5.5`),children:t})]}),r&&(0,J.jsx)(`div`,{id:o,className:`divide-y divide-border`,children:(0,J.jsx)(ne.Provider,{value:2,children:a})})]})},Wn=({tabs:e})=>(0,J.jsx)(`nav`,{"aria-label":B(`tabs`),className:`overflow-x-auto py-6`,children:(0,J.jsx)(`span`,{className:Le.group(`md`),children:e.map(e=>(0,J.jsx)(A,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:P(Le.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),Gn=({rows:e})=>(0,J.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,J.jsxs)(`div`,{className:P(`grid gap-x-4 border-b border-border py-2.5`,e.wide?`grid-cols-1 gap-y-1.5`:`grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`),children:[(0,J.jsxs)(`dt`,{className:`min-w-0 text-muted-foreground`,children:[e.label,e.help&&(0,J.jsx)(`span`,{className:`mt-0.5 block text-xs text-faint-foreground`,children:e.help})]}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words text-foreground`,children:e.value})]},e.label))}),Kn=({facts:e})=>(0,J.jsx)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-5 sm:flex sm:flex-wrap sm:gap-x-10`,children:e.map(({label:e,value:t,icon:n})=>(0,J.jsxs)(`div`,{title:e,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{className:`size-5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:e})]}):e}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words text-base font-semibold text-foreground`,children:t})]},e))}),qn=`flex min-h-11 items-center gap-2 rounded-md border border-border-strong px-3 text-left hover:bg-surface disabled:cursor-default disabled:opacity-60 md:min-h-0 md:w-full md:items-start md:gap-3 md:rounded-none md:border-0 md:px-4 md:py-3`,Jn=({actions:e})=>(0,J.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:[(0,J.jsx)(`h2`,{className:`hidden border-b border-border px-4 py-2.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground md:block`,children:B(`actions`)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2 p-2 md:block md:divide-y md:divide-border md:p-0`,children:e.map(({name:e,description:t,icon:n,onRun:r,blocked:i,running:a,tone:o,render:s})=>{let c=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{className:P(`size-4 shrink-0 md:mt-0.5`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:P(`block font-medium`,o===`danger`?`text-danger-text`:`text-foreground`),children:e}),t&&(0,J.jsx)(`span`,{className:`mt-0.5 hidden text-xs leading-snug text-muted-foreground md:block`,children:t})]})]});return(0,J.jsx)(`li`,{children:s?s({className:qn,children:c}):(0,J.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:qn,children:c})},e)})})]}),Yn=e(n(),1),Xn=1e3,Zn=(e,t,n,r,i)=>{let a=ve(e?.name??``,{enabled:!!(e&&t),filter:t?`${t.name} = "${r}"`:void 0,pageSize:500,labels:i,...n&&e?.fields[n]?.sortable&&{orderBy:`${n} asc`}}),o=(0,Y.useMemo)(()=>n?[...a.items].sort((e,t)=>Number(e[n])-Number(t[n])):a.items,[a.data,n]),s=a.hasNextPage&&a.items.length<1e3;return(0,Y.useEffect)(()=>{s&&!a.isFetchingNextPage&&a.fetchNextPage()},[s,a.isFetchingNextPage]),{items:o,labels:a.labels,loading:(a.isPending||s)&&!!e,complete:!a.hasNextPage}},Qn=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),$n=(e,t)=>e.sidebar?e.title?(0,J.jsx)(Tn,{title:e.title,children:t}):t:e.title?(0,J.jsx)(M,{title:e.title,children:t}):(0,J.jsx)(`section`,{className:`py-8`,children:t}),er=({item:e,scope:t,fallback:n})=>{let{components:r}=a(),i=r?.[e.component],o=i&&(0,J.jsx)(st,{value:t,children:(0,J.jsx)(i,{...m(e.props??{})})});return n===void 0?$n(e,(0,J.jsx)(yn,{name:e.component,registered:!!i,fallback:void 0,children:o})):(0,J.jsx)(yn,{name:e.component,registered:!!i,fallback:n,children:$n(e,o)})},tr=({component:e,scope:t,standard:n})=>{let{components:r}=a(),i=r?.[e];return i?(0,J.jsx)(te,{name:e,fallback:n,children:(0,J.jsx)(nr,{children:(0,J.jsx)(st,{value:t,children:(0,J.jsx)(i,{})})})}):n},nr=({children:e})=>(E(!1),(0,J.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),rr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,ir=(e,t,n)=>L(()=>{let r=e.getItem(t);if(r===null)return;let i=JSON.parse(r);if(i&&i.etag===n&&typeof i.fields==`object`&&i.fields!==null)return{etag:n,fields:i.fields,...Array.isArray(i.order)&&{order:i.order.map(String)}}},void 0),ar=(e,t,n)=>L(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),or=e=>ae(e)??Bn,sr=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=Se(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=Kt(e.name,s,t=>t.run?.kind===`delete`&&o({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,Y.useState)(),d=c.actions.map(e=>{let n=c.blocked(e),r=e.run?.kind===`link`&&!n?Qt(e.run,t.record,a):void 0;return{name:e.label,icon:or(e.icon),blocked:n,running:c.running===e.name,...qt(e)&&{tone:`danger`},onRun:()=>Jt(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,J.jsx)(yt,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:H(`edit`),icon:un,render:({className:e,children:t,role:n})=>(0,J.jsx)(A,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:H(`delete`),icon:wn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,J.jsx)(Xt,{action:l,label:l.label,danger:qt(l),records:[t.record],onCancel:()=>u(void 0),onConfirm:()=>{u(void 0),c.run(l)},onSubmit:async e=>{await c.submit(l,e),u(void 0)}})}},cr=e=>{let t=ft(),{actions:n,prompt:r}=sr(e);return n.length===0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:t?`max-md:hidden`:void 0,children:(0,J.jsx)(Jn,{actions:n})}),t&&(0,Yn.createPortal)((0,J.jsx)(vt,{actions:n,label:H(`recordActions`),className:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`}),t),r]})},lr=e=>{let t=typeof e.resource==`string`?e.resource:e.resource.toModel().name;return e.op===`reorder`?`reorder ${t} by ${e.field}`:`${e.op} ${t}`},ur=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?V(`operationFailed`,{index:n+1,label:lr(r),message:e.message}):V(`nothingSaved`,{message:e.message})},dr=(e,t)=>new e.constructor({...e.problem,detail:ur(e,t)}),fr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),pr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=z(),c=Vt(),u=Te(e.name,n),d=Je(r,i),[p]=(0,Y.useState)(()=>a?ir(localStorage,a,t.etag):void 0),[m,h]=(0,Y.useState)(p?.fields??{}),[g,_]=(0,Y.useState)(!!p),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)({}),[ee,S]=(0,Y.useState)({}),[te,w]=(0,Y.useState)(0),ne=Object.entries(m).filter(([n,r])=>l(e.fields[n],r,t.record[n])),T=ne.length>0,E=T||!!o?.dirty;(0,Y.useEffect)(()=>{p?.order&&o?.setOrder(p.order)},[]),(0,Y.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(m).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.order;ar(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,m,o?.order,t.etag]);let O=n=>n in m?m[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:f(t.record[n]),k=(n,r)=>{S(e=>fr(e,n));let i=typeof r==`string`?r!==f(t.record[n]):l(e.fields[n],r,t.record[n]);h(e=>i?{...e,[n]:r}:fr(e,n))},re=async()=>{let r=await s.get(e.name,n);c.setQueryData(D.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(m)){let s=e.fields[n];l(s,o,r.record[n])&&(a[n]=o,f(r.record[n])!==f(t.record[n])&&(i[n]=s.type===`file`?qe(s,r.record[n]):f(r.record[n])))}h(a),x(i)},ie=()=>Object.fromEntries(ne.map(([t,n])=>[t,et(e.fields[t],n)])),A=e=>{let t=St(e);S(t),Object.keys(t).length>0&&w(e=>e+1)},ae=async()=>{try{await u.mutateAsync({patch:ie(),etag:t.etag})}catch(e){throw jt(e)?await re():C(e)&&A(e),e}},j=async r=>{let i=T?[{op:`update`,resource:e.name,key:n,data:ie(),etag:t.etag}]:[],a=[...i,...r.ops];try{await s.batchWrite(a)}catch(e){if(jt(e))await re(),await c.invalidateQueries({queryKey:[`list`]}),y(!0);else if(C(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?A(e):n&&o?.reject(n,e)}throw C(e)?dr(e,a):e}await Promise.all([c.invalidateQueries({queryKey:D.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]}),c.invalidateQueries({queryKey:[`aggregate`]})]),o?.reset()};return{value:O,change:k,save:()=>d.run(async()=>{let e=o?.plan();e&&e.ops.length>0?await j(e):await ae(),h({}),x({}),S({}),y(!1),_(!1)}),dirty:E,discard:()=>{h({}),x({}),S({}),y(!1),_(!1),o?.reset()},restored:g&&E,dismissRestored:()=>_(!1),linesConflict:v,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:b,errors:ee,rejections:te,keepMine:e=>x(t=>fr(t,e)),useTheirs:e=>{x(t=>fr(t,e)),h(t=>fr(t,e))}}},X=F(`focus-record`),mr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,J.jsx)(J.Fragment,{children:e.map(({name:e,label:r})=>[(0,J.jsx)(W,{size:`sm`,onClick:()=>t(e),children:X(`keepMine`,{field:r})},`mine:${e}`),(0,J.jsx)(W,{size:`sm`,onClick:()=>n(e),children:X(`useTheirs`,{field:r})},`theirs:${e}`)])}),hr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=mt(`primary`),o=ut()?.size===`compact`,s=(0,J.jsx)(W,{variant:!a||n?`primary`:`secondary`,loading:r,"aria-disabled":!n,className:`max-md:min-h-11`,onClick:()=>void(n&&!r&&i()),children:t});return o&&!n?null:a?(0,J.jsx)(lt,{zone:`secondary`,children:s}):(0,J.jsx)(lt,{zone:`primary`,fallback:!0,children:s})},gr=({record:e,saved:t,readOnly:n})=>{let r=ut()?.size,i=n?X(`readOnly`):e.saving?X(`saving`):e.dirty?X(r===`wide`?`unsaved`:`unsavedShort`):t?X(`saved`):void 0;return i?(0,J.jsx)(lt,{zone:`state`,fallback:!0,children:(0,J.jsxs)(`span`,{role:`status`,title:n?X(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,J.jsx)(b,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},_r=({model:e,recordKey:t,stored:n,page:r})=>{let a=q().views[e.name],{address:o,go:s}=Se(),c=ie()(e,a,n.record,t),{state:l}=Dt(),d=pr({model:e,stored:n,recordKey:t,mode:`button`,subject:c,draftKey:l.kind===`signed-in`?`${rr(l.user.id,e.name,t)}:focus`:void 0});Ae(d.dirty||d.saving),Xe(d.dirty);let f=Vt(),[p,m]=(0,Y.useState)(!1),h=a?.names?.singular??K(e.name),g=ct(e.name),_=pn(e),v=o?.kind===`record`&&o.version!==void 0&&o.version!==Number(n.record.version),y=`surface`in r&&(kt(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),b=u(g,`update`)&&n.permissions?.update!==!1&&!y,x=!b||v,ee=u(g,`delete`)&&n.permissions?.delete!==!1,S=dn({model:e,view:a,restore:_,onDeleted:()=>s({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void f.invalidateQueries({queryKey:D.record(e.name,t)})}),{actions:C,prompt:te}=sr({model:e,stored:n,recordKey:t,onDelete:ee?()=>void S.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0}),w=(0,Y.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),ne=C.filter(e=>e.tone===`danger`),T=[...C.filter(e=>e.tone!==`danger`),...d.dirty?[{name:X(`discardChanges`),icon:Rn,onRun:()=>m(!0)}]:[],{name:X(`detailsOf`,{noun:h}),icon:In,render:({className:e,children:t,role:n})=>(0,J.jsx)(A,{to:w,role:n,className:e,children:t})},...ne],E={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:x,mayUpdate:b,value:d.value,change:(e,t)=>x?void 0:d.change(e,t),dirty:d.dirty,saving:d.saving,refused:d.message!==void 0,save:async()=>!x&&!!await d.save(),discard:d.discard,details:w},O=`surface`in r?r.surface:void 0,k=p&&d.dirty&&(0,J.jsx)(We,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(W,{size:`sm`,variant:`danger`,onClick:()=>{d.discard(),m(!1)},children:X(`discardChanges`)}),(0,J.jsx)(W,{size:`sm`,onClick:()=>m(!1),children:X(`keep`)})]}),children:X(`discardAsk`)}),re=Object.keys(d.conflicts).length>0,ae=O?d.errors[O]:void 0,j=ae&&O?Ft(e.fields[O],a?.fields[O]?.label??K(O),ae):void 0;return(0,J.jsxs)(ke.Provider,{value:E,children:[!x&&(0,J.jsx)(hr,{record:E,label:X(`save`)}),(0,J.jsx)(gr,{record:E,saved:d.phase===`saved`,readOnly:x}),(0,J.jsx)(i,{actions:T}),d.message&&!p&&(0,J.jsxs)(We,{level:`refused`,actions:(0,J.jsx)(A,{to:w,className:`text-body font-medium text-primary-text hover:underline`,children:X(`detailsOf`,{noun:h})}),children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:X(`notSaved`)}),` `,j??d.message]}),re&&(0,J.jsx)(We,{level:`conflict`,actions:(0,J.jsx)(mr,{fields:Object.keys(d.conflicts).map(e=>({name:e,label:a?.fields[e]?.label??K(e)})),onKeepMine:d.keepMine,onUseTheirs:d.useTheirs}),children:X(`conflict`)}),k,d.restored&&!p&&(0,J.jsx)(We,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(W,{size:`sm`,onClick:d.dismissRestored,children:X(`keep`)}),(0,J.jsx)(W,{size:`sm`,onClick:d.discard,children:X(`discard`)})]}),children:X(`restored`)}),O?(0,J.jsx)(vr,{model:e,name:O,stored:n,editor:d,readOnly:x}):(0,J.jsx)(yr,{name:r.component,model:e,stored:n,recordKey:t}),S.dialogs,te]})},vr=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=q().views[e.name]?.fields[t];if(kt(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,J.jsx)(`div`,{className:`absolute inset-0`,children:(0,J.jsx)(Pe,{field:e.fields[t],hints:a,value:r.value(t),stored:n.record[t],locked:i,invalid:!!r.errors[t],resource:e.name,onChange:e=>r.change(t,e)})})},yr=({name:e,model:t,stored:n,recordKey:r})=>{let i=a().components?.[e];if(!i)throw Error(`No component is registered as ${e}`);return(0,J.jsx)(`div`,{className:`absolute inset-0`,children:(0,J.jsx)(st,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,J.jsx)(i,{})})})},br=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=ie()(e,q().views[e.name],n.record,t);return(0,J.jsx)(te,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,J.jsx)(Ze,{label:a,children:(0,J.jsx)(_r,{model:e,recordKey:t,stored:n,page:r})})})},xr=(0,Y.lazy)(()=>Bt(()=>import(`./record-map-BiLFEqYi.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Sr=15,Cr=({item:e,record:t})=>{let n=q().maps,r=n?.style,i=Zt(t,e);if(!r||!i)return null;let a=(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,J.jsx)(Y.Suspense,{fallback:null,children:(0,J.jsx)(xr,{style:r,layers:n?.layers,position:i,zoom:e.zoom??Sr},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,J.jsx)(Tn,{title:e.title,children:a}):(0,J.jsx)(M,{title:e.title,children:a})},wr={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},Tr=(e,t,n)=>{let r=new Map;e.forEach((e,i)=>{for(let a of e){let e=Date.parse(`${String(a.value)}Z`),o=r.get(e)??{at:e,value:null,count:0};o[t[i]]=a[n]??null,o.count=Math.max(o.count,a.count),r.set(e,o)}});let i=Object.fromEntries(t.map(e=>[e,null]));return[...r.values()].sort((e,t)=>e.at-t.at).map(e=>({...i,...e}))},Z=F(`app/record-chart`),Er=N(),Dr=[`1h`,`24h`,`7d`],Or={"1h":`hour`,"24h":`day`,"7d":`week`},kr=({item:e,recordKey:t})=>{let{resources:n,views:r}=q(),[i,a]=(0,Y.useState)(e.range??`1h`),[o,s]=(0,Y.useState)(`average`),c=n[e.resource],l=r[e.resource],u=wr[i],d=S(Er.eq(e.field,t)),f=e.series.map(t=>({groupBy:e.at,filter:d,...o===`average`?{average:t}:{maximum:t},range:i,granularity:u,timeZone:gt()})),p=me(e.resource,f,!!c);if(!c)return null;let m=e.series.map(e=>({kind:o,field:c.fields[e],...l?.fields[e]&&{hints:l.fields[e]}})),h=e.series.map((e,t)=>({key:`s${t}`,label:l?.fields[e]?.label??K(e),color:`var(--chart-${t+1})`,measure:m[t]})),g=p.every(e=>e.data)?Tr(p.map(e=>e.data.groups),h.map(e=>e.key),o):[],_=(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(Rt,{label:Z(`measure`),value:o,onChange:s,options:[{value:`average`,label:Z(`average`)},{value:`maximum`,label:Z(`maximum`)}]}),(0,J.jsx)(Rt,{label:Z(`range`),value:i,onChange:a,options:Dr.map(e=>({value:e,label:Z(Or[e])}))})]});return(0,J.jsx)(M,{title:e.title,help:e.help,actions:_,children:p.some(e=>e.error)?(0,J.jsx)(`p`,{className:`text-danger-text`,children:Z(`couldNotLoad`)}):p.some(e=>e.isPending)?(0,J.jsx)(G,{className:`h-40 w-full`}):g.every(e=>e.count===0)?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`noSamples`)}):(0,J.jsx)(rn,{points:g,measure:m[0],bucket:u,type:`line`,series:h,...h.length>1&&{resource:e.resource,view:l}})})},Ar=F(`app/record-trend`),jr=(e,t)=>Ar(`total_${t}`,{count:e}),Mr=N(),Nr={kind:`count`},Pr=({item:e,recordKey:t})=>{let n=S(Mr.eq(e.field,t)),r=g(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:gt()});return(0,J.jsx)(M,{title:e.title,help:e.help,children:(0,J.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,J.jsx)(G,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,J.jsx)(U,{title:Ar(`couldNotLoad`),error:r.error,onRetry:()=>void r.refetch()});let t=r.data.groups.reduce((e,t)=>e+t.count,0);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mb-3 leading-5 text-foreground`,children:jr(t,e.range)}),(0,J.jsx)(rn,{points:ln(r.data.groups,Nr),measure:Nr,bucket:e.granularity,type:`bar`})]})})()})})},Fr=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],Ir=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),Lr=e=>{let t=e.findIndex(e=>e.kind===`tab`);if(t===-1)return{before:e,tabs:[],after:[]};let n=[];for(let r of e.slice(t)){if(r.kind!==`tab`)break;n.push(r)}return{before:e.slice(0,t),tabs:n,after:e.slice(t+n.length)}},Rr=(e,t)=>e.find(e=>e.title===t)??e[0],zr=e=>Tt(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),Br=(e,t,n)=>{if(t&&!zr(t).some(n))return e.find(e=>zr(e).some(n))},Vr={added:[],edits:{},removed:[]},Hr=(e,t)=>{let n=[...e.filter(e=>!t.removed.includes(e)),...t.added];return t.order?[...t.order.filter(e=>n.includes(e)),...n.filter(e=>!t.order.includes(e))]:n},Ur=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&l(i,r,n[t])?[[t,et(i,r)]]:[]})),Wr=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,et(r,n)]]})),Gr=({model:e,position:t,link:n,stored:r,state:i})=>{let a={ops:[],rows:[]},o=(e,t)=>{a.ops.push(e),a.rows.push(t)},s=new Map(r.map(t=>[It(e,t),t])),c=[...s.keys()],l=Hr(c,i),u=t=>Fe(e,s.get(t)),d=e=>{let t=s.get(e).etag;return typeof t==`string`?t:void 0};for(let t of i.removed){if(!s.has(t))continue;let n=d(t);o({op:`delete`,resource:e.name,key:u(t),...n&&{etag:n}},t)}let f=new Set;for(let[t,n]of Object.entries(i.edits)){if(!s.has(t)||i.removed.includes(t))continue;let r=Ur(e,n,s.get(t));if(Object.keys(r).length===0)continue;let a=d(t);o({op:`update`,resource:e.name,key:u(t),data:r,...a&&{etag:a}},t),f.add(t)}let p=l.filter(e=>s.has(e)),m=l.filter(e=>!s.has(e)),h=(e,t)=>Object.fromEntries(e.flatMap(e=>{let n=t||f.has(e)?`*`:d(e);return n?[[Be(u(e)),n]]:[]})),g=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),_=(r,a,o)=>({op:`create`,resource:e.name,data:{...Wr(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),v=e=>Number(e[t])||0,y=p.some((e,t)=>e!==c.filter(e=>p.includes(e))[t]);if(m.every(e=>l.indexOf(e)>=p.length)){y&&o(g(p.map(u),1,h(p,!1)));let e=y?p.length:Math.max(0,...p.map(e=>v(s.get(e))));return m.forEach((t,n)=>o(_(t,e+1+n),t)),a}let b=Math.max(l.length,...r.map(v))+1;p.length>0&&o(g(p.map(u),b,h(p,!1)));let x=e=>`line${m.indexOf(e)+1}`;for(let e of m)o(_(e,l.indexOf(e)+1,x(e)),e);return o(g(l.map(e=>s.has(e)?u(e):{$ref:x(e)}),1,h(p,!0))),a},Kr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),qr=(e,t)=>{let[n,r]=(0,Y.useState)(Vr),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(1),s=(0,Y.useMemo)(()=>new Map(e?t.map(t=>[It(e.model,t),t]):[]),[e,t]),c=Hr([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Gr({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,d=(0,Y.useMemo)(()=>{let e=Hr([...s.keys()],n).filter(e=>s.has(e)),t=[...s.keys()].filter(t=>e.includes(t));return n.order!==void 0&&e.some((e,n)=>e!==t[n])?e:void 0},[s,n]),f=(t,r)=>{let i=n.edits[t];if(i&&r in i)return i[r];let a=e?.model.fields[r],o=s.get(t)?.[r];return a?[`boolean`,`file`].includes(a.type)?o:de(a,o):o},p=e=>a(t=>t?.id===e?void 0:t);return{shown:c,dirty:u,order:d,value:f,change:(e,t,n)=>{p(e),r(r=>({...r,edits:{...r.edits,[e]:{...r.edits[e],[t]:n}}}))},add:()=>{let e=`new:${o.current++}`;return r(t=>({...t,added:[...t.added,e]})),e},remove:e=>{p(e),r(t=>t.added.includes(e)?{...t,added:t.added.filter(t=>t!==e),edits:Kr(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Vr),a(void 0)},reject:(e,t)=>a({id:e,fields:St(t),message:t.message}),rejection:i,plan:l}},Jr=(e,t)=>{let n=Tt(t?.layout??[]).find(e=>e.kind===`related`&&e.lines===!0);if(n?.kind!==`related`)return;let r=e[n.resource],i=r?.fields[n.field],a=r?.position?.field;if(r&&i&&a&&r.position?.within===n.field)return{item:n,model:r,link:i,position:a}},Yr=(e,t,n,r)=>ot(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Xr=(e,t)=>{let{resources:n,views:r}=q(),i=(0,Y.useMemo)(()=>Jr(n,r[e.name]),[n,r,e]),a=i?.model,o=i?Yr(i.model,r[i.model.name],i.link.name,i.position):[],s=Zn(a,i?.link,i?.position,t,a?k(n,r,a,o):void 0),c=qr((0,Y.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:tt(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Zr=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Qr=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,$r=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,ei=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),ti=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,ni=`protobase:lightbox-details`,ri=e=>L(()=>e.getItem(ni)===`true`,!1),ii=(e,t)=>L(()=>t?e.setItem(ni,`true`):e.removeItem(ni),void 0),Q=F(`app/gallery`),ai=`flex size-10 shrink-0 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,oi=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=Q(`details`)})=>{let s=(0,Y.useRef)(null),c=(0,Y.useRef)(void 0),l=(0,Y.useId)(),u=xe(),[d,f]=(0,Y.useState)(()=>ri(localStorage)),[p,m]=(0,Y.useState)(!1);Ne(s,!0,i),(0,Y.useEffect)(()=>m(!0),[]);let h=t.length,g=e=>{let t=ei(n,e,h);t!==n&&r(t)},_=fe(t[n],{width:1600,height:1200}),v=a?.(n),y=v!==void 0,b=e=>{f(e),ii(localStorage,e)};return(0,J.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(y&&ti(e))return e.preventDefault(),b(!d);let t=$r(e.key);t!==0&&(e.preventDefault(),g(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,J.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3 pt-[calc(0.75rem+var(--pb-safe-top))]`,children:[(0,J.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y&&(0,J.jsx)(`button`,{type:`button`,className:P(ai,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>b(!d),children:(0,J.jsx)(Pn,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:ai,"aria-label":Q(`close`),onClick:i,children:(0,J.jsx)(bt,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,J.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-[calc(0.75rem+var(--pb-safe-bottom))] md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(g(Qr(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[_&&(0,J.jsx)(w,{image:_,className:`max-h-full max-w-full select-none object-contain`},_.url),h>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:P(ai,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":Q(`previousPhoto`),"aria-disabled":n===0,onClick:()=>g(-1),children:(0,J.jsx)(le,{className:`size-5`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:P(ai,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":Q(`nextPhoto`),"aria-disabled":n===h-1,onClick:()=>g(1),children:(0,J.jsx)(j,{className:`size-5`,"aria-hidden":!0})})]})]})]}),y&&d&&u&&(0,J.jsxs)(`aside`,{id:l,"aria-label":o,className:`min-h-dvh w-[360px] shrink-0 border-l border-border bg-background p-5 pt-[calc(1.25rem+var(--pb-safe-top))] text-foreground`,children:[(0,J.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:o}),v]}),(0,J.jsx)(Et,{title:o,open:y&&d&&!u&&p,onClose:()=>b(!1),children:(0,J.jsx)(`div`,{className:`pt-3`,children:v})})]})},si=(e,t,n)=>{let r=Tt(t?.layout??[]).flatMap(e=>e.kind===`section`&&rt(e.when,!1)?e.fields:[]);return(r.length>0?[...new Set(r)]:Object.keys(e.fields).filter(t=>t!==e.tenant&&!e.primaryKey.includes(t))).filter(r=>e.fields[r]&&!e.fields[r].sensitive&&!n.includes(r)&&rt(t?.fields[r]?.when,!1))},ci=({model:e,view:t,photoKey:n,fields:r})=>{let i=re(e.name,n),a=(t?.names?.singular??K(e.name)).toLowerCase();if(i.isPending)return(0,J.jsx)(G,{className:`h-4 w-48`});if(i.error)return(0,J.jsx)(U,{title:Q(`couldNotLoadOne`,{singular:a}),error:i.error});let o=r.filter(e=>kt(i.data.permissions,e)!==`hidden`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Gn,{rows:o.map(n=>({label:t?.fields[n]?.label??K(n),value:(0,J.jsx)(Lt,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,J.jsx)(A,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:Q(`open`,{singular:a})})]})},li=e=>fe(e,{width:0,height:0})!==void 0,ui=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return Be(n)},di=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!p(t)||!li(t))return[];let i=r&&ui(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!p(e)||!li(e))return i;let a=t=>p(t.file)&&t.file.uri===e.uri,o=i.find(a)?.key;return[{file:e,...o!==void 0&&{key:o}},...i.filter(e=>!a(e))]},fi=N(),pi=(e,t,n)=>{let r=z(),{resources:i}=q(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?S(fi.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Ut({queryKey:D.list(a?.name??``,o,s,500,`gallery`),enabled:a!==void 0,queryFn:async()=>(await r.list(a.name,{filter:o,...s&&{orderBy:s},pageSize:500})).items});return{holder:a,items:di(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},mi={1:[`md:col-span-4 md:row-span-2`],2:[`md:col-span-2 md:row-span-2`,`md:col-span-2 md:row-span-2`],3:[`md:col-span-2 md:row-span-2`,`md:col-span-2`,`md:col-span-2`],5:[`md:col-span-2 md:row-span-2`,``,``,``,``]},hi=({photo:e,large:t})=>{let n=fe(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,J.jsx)(w,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},gi=({item:e,record:t,recordKey:n})=>{let{views:r}=q(),i=pi(e,t,n),a=ct(i.holder?.name??``),[o,s]=(0,Y.useState)();if(i.isPending)return(0,J.jsx)(M,{title:e.title,children:(0,J.jsx)(G,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,J.jsx)(M,{title:e.title,children:(0,J.jsx)(U,{title:Q(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=Zr(c),d=i.holder,f=d&&r[d.name],p=d?si(d,f,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],m=d!==void 0&&a.read!==!1&&p.length>0;return(0,J.jsxs)(M,{title:e.title,children:[(0,J.jsx)(`div`,{className:`grid aspect-[4/3] grid-cols-4 grid-rows-2 gap-1.5 overflow-hidden rounded-lg md:aspect-[2/1]`,children:i.items.slice(0,l).map((e,t)=>{let n=t===l-1&&u>0;return(0,J.jsxs)(`button`,{type:`button`,"aria-label":n?Q(`showAll`,{count:c}):Q(`showPhoto`,{index:t+1,count:c}),onClick:()=>s(t),className:P(`group/tile relative overflow-hidden bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,t===0?`col-span-4 row-span-2`:`max-md:hidden`,mi[l][t]),children:[(0,J.jsx)(hi,{photo:e.file,large:t===0}),n&&(0,J.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${u}`}),t===0&&c>1&&(0,J.jsxs)(`span`,{className:`absolute bottom-2 right-2 flex items-center gap-1.5 rounded-full bg-background/85 px-2.5 py-1 text-xs font-medium tabular-nums text-foreground md:hidden`,"aria-hidden":!0,children:[(0,J.jsx)(Mn,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,J.jsx)(oi,{title:e.title,photos:i.items.map(e=>e.file),index:o,onIndex:s,onClose:()=>s(void 0),details:e=>{let t=i.items[e]?.key;return m&&t!==void 0?(0,J.jsx)(ci,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&Q(`holderDetails`,{singular:f?.names?.singular??K(d.name)})})]})},_i=F(`app/history`),vi=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?_i(`databaseRole`,{role:e.databaseRole}):_i(`database`),yi=(e,t,n)=>{let r=(e.operation===`create`?[]:e.changed).flatMap(r=>{let i=t.fields[r];if(!i||r===t.softDelete)return[];let a=n?.fields[r],o=a?.label??K(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:qe(i,e.before[r],a),after:qe(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?_i(`changedThis`):_i(e.operation);return{who:vi(e),verb:i,fields:r}},bi=1500,xi=(e,t,n,r)=>{let i=z(),a=Wt({queryKey:D.history(e,t,n),initialPageParam:``,queryFn:({pageParam:r})=>i.history(e,t,{pageSize:n,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0}),{refetch:o}=a;return(0,Y.useEffect)(()=>{let e=setTimeout(()=>void o(),bi);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},Si=()=>(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,J.jsx)(G,{className:`h-4 w-full`},t))}),Ci=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=yi(e,t,n),o=Date.parse(e.at);return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,J.jsxs)(`time`,{dateTime:e.at,title:O(o),className:`text-muted-foreground`,children:[`· `,Ve(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,J.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,J.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},wi=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=xi(t.name,r,e.limit??10,i);return(0,J.jsx)(M,{title:e.title,children:a.isPending?(0,J.jsx)(Si,{}):a.error?(0,J.jsx)(U,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,J.jsx)(Ci,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,J.jsx)(W,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},Ti=({comment:e})=>(0,J.jsx)(Ee,{text:e.body,mentions:e.mentions}),Ei=(e,t)=>{let n=z(),r=Vt();return Ht({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:D.comments(e,t)})})},$=F(`app/comments`),Di=({resource:e,recordKey:t})=>{let[n,r]=(0,Y.useState)(_),i=z(),a=ce(),o=Ei(e,t),s=(0,Y.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Ae(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:he(n.text,n.picked)},{onSuccess:()=>r(_),onError:e=>a.show({state:`error`,title:$(`couldNotPost`),description:nt(e)})})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(y,{"aria-label":$(`comment`),placeholder:$(`placeholder`),value:n,onChange:r,searchPeople:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,J.jsx)(`div`,{children:(0,J.jsx)(W,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:$(`comment`)})})]})},Oi=20,ki=(e,t)=>{let n=z(),r=Wt({queryKey:D.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:Oi,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},Ai=()=>(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,J.jsx)(G,{className:`h-4 w-full`},t))}),ji=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,J.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,J.jsx)(_e,{initials:ue(t)||`?`,hue:se(e.author.id),size:`md`,className:`ring-0`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,J.jsxs)(`time`,{dateTime:e.createdAt,title:O(n),className:`text-muted-foreground`,children:[`· `,Ve(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,J.jsx)(Ti,{comment:e})]})]})},Mi=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=ki(t,n);return(0,J.jsxs)(M,{title:e.title,children:[i.isPending?(0,J.jsx)(Ai,{}):i.error?(0,J.jsx)(U,{title:$(`couldNotLoad`),error:i.error}):(0,J.jsxs)(J.Fragment,{children:[i.hasNextPage&&(0,J.jsx)(W,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:$(`showEarlier`)}),i.items.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:$(`noComments`)}):(0,J.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,J.jsx)(ji,{comment:e},e.id))})]}),r&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(Di,{resource:t,recordKey:n})})]})},Ni=e=>e.kind===`group`||e.kind===`tab`?e.items:e.kind===`custom`?e.fallback??[]:[],Pi=e=>e.kind===`tab`?void 0:e.when,Fi=e=>e.flatMap(e=>[e,...Fi(Ni(e))]).filter(e=>I(Pi(e))),Ii=e=>(e.fallback??[]).map((t,n)=>[t,e.fallbackAt?.[n]??n]),Li=(e,t,n,r)=>{let i=0,a=e=>{let a=Pi(e);return I(a)?!r&&t[i++]===!0:rt(a,n)},o=e=>e.flatMap(e=>{let t=a(e);if(e.kind===`custom`&&e.fallback){let n=e.fallback.map(e=>o([e])),r=n.flatMap((e,t)=>e.length>0?[t]:[]);return t?[{...e,fallback:n.flat(),fallbackAt:r}]:[]}if(e.kind!==`group`&&e.kind!==`tab`)return t?[e]:[];let n=o(e.items);return t&&n.length>0?[{...e,items:n}]:[]});return o(e)},Ri=(e,t,n,r)=>{let i=r?[]:Fi(e).map(e=>Pi(e));return Li(e,bn(i,t),n,r)},zi=N(),Bi=(e,t)=>{let[n,...r]=e.primaryKey;if(!(!e.tenantAcross||e.tenant===void 0||n===void 0||r.length>0||!e.fields[n]?.filterable))return{filter:S(zi.eq(n,t)),pageSize:1,fields:[n,e.tenant]}},Vi=(e,t,n)=>{let r=t?.[e.tenant];if(r!=null&&String(r)!==n)return String(r)},Hi=(e,t)=>{let n=z(),{session:r,organizations:i}=Dt(),a=(0,Y.useMemo)(()=>i?Bi(e,t):void 0,[i,e,t]),[o,s]=(0,Y.useState)(a?{state:`looking`}:{state:`missing`});return(0,Y.useEffect)(()=>{a&&(async()=>{let[t,i]=await Promise.all([n.list(e.name,a),r.organizations.current()]),o=Vi(e,t.items[0],i.organization?.id);if(o===void 0)return s({state:`missing`});s({state:`switching`}),await r.organizations.switchTo(o),window.location.reload()})().catch(e=>s({state:`failed`,error:e}))},[n,r,e,a]),o},Ui=(e,t,n,r)=>{let i=z(),a=Vt(),o=ie(),s=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),c=Gt({queries:s.map(e=>{let o=t[e.relation.resource];return pe(a,i,o,n[o.name],String(r[e.name]))})}),l=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,l[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,h(c[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Wi=N(),Gi=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let a=new Set(Ki(r,i).flatMap(e=>e.kind===`thread`?[`${e.resource}.${e.field}`,...e.calls?[`${e.calls.resource}.${e.calls.field}`]:[]]:e.kind===`related`&&!e.through&&!e.from?[`${e.resource}.${e.field}`]:[])),o=Object.values(t).flatMap(t=>Object.values(t.fields).filter(t=>t.type===`relation`&&t.relation?.resource===e.name&&t.relation.columns.length===1&&t.filterable).filter(e=>e.name!==t.tenant&&!a.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return o.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??K(e.name),a=o.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:a?`${i} (${r?.fields[t]?.label??K(t)})`:i}})},Ki=(e,t)=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Ki(e.items,t):e.kind===`custom`&&!t(e.component)?[e,...Ki(e.fallback??[],t)]:[e]),qi=(e,t)=>({kind:`list`,resource:e.resource,filter:S(Wi.eq(e.field,t))}),Ji=N(),Yi=(e,t,n)=>{let r=z(),i=Gt({queries:e.map(e=>{let i=S(Ji.eq(e.field,n));return{queryKey:D.list(e.resource,i,``,1,`incoming`),queryFn:async()=>{let n=await r.list(e.resource,{filter:i,pageSize:1,count:`exact`,fields:t[e.resource].primaryKey});return{count:n.totalSize??n.totalSizeEstimate,exact:n.totalSize!==void 0}}}})});return e.flatMap((e,t)=>{let n=i[t];return n.error?[]:[{relation:e,count:n.data}]})},Xi=({model:e,recordKey:t,layout:n})=>{let{resources:r,views:i}=q(),{components:o}=a(),s=Yi(Gi(e,r,i,n,e=>!!o?.[e]),r,t);return s.length===0?null:(0,J.jsx)(Tn,{title:H(`relatedRecords`),children:(0,J.jsx)(`ul`,{className:`-mx-2`,children:s.map(({relation:e,count:n})=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(A,{to:qi(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,J.jsx)(G,{className:`h-4 w-6`}):`${Qe(n.count)}${n.exact?``:`+`}`,(0,J.jsx)(j,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},Zi=({count:e,names:t})=>e===null?null:e===void 0?(0,J.jsx)(G,{className:`inline-block h-5 w-7 rounded-full`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(De,{dot:!1,className:P(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,J.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(ye())})}),(0,J.jsx)(`span`,{className:`sr-only`,children:t?B(`headingCount`,{count:e,...t}):B(`headingCountRecords`,{count:e})})]}),Qi=(e,t,n,r,i)=>{if(!(e.through||t===null)&&Ce(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},$i=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??vn(`nothingYet`)}),ea=(e,t)=>(t?.names?.singular??K(e.name)).toLowerCase(),ta=({title:e,help:t,count:n,model:r,view:i,filter:a,sort:o,fields:s,button:c,empty:l,add:u})=>{let d=zt(),{resources:f}=q(),p=o||Ke(r,i),m=R(r,{filter:a,sort:p,pageSize:2});if(m.isPending)return(0,J.jsx)(M,{title:e,help:t,count:n,children:(0,J.jsx)(G,{className:`h-24 w-full`})});if(m.error)return(0,J.jsx)(M,{title:e,help:t,count:n,children:(0,J.jsx)(U,{title:vn(`couldNotLoad`),error:m.error})});let[h,g]=m.data.items;if(!h){let a=u&&(0,J.jsxs)(A,{to:u,className:_t({size:`sm`}),children:[(0,J.jsx)(Ct,{className:`size-3.5`}),vn(`add`,{singular:ea(r,i)})]});return(0,J.jsx)(M,{title:e,help:t,count:n,actions:a,children:(0,J.jsx)($i,{empty:l})})}let _=it(r,h),v=ea(r,i),y=i?.names?.plural??K(r.name),b=s.length>1,x=s.map(e=>(0,J.jsx)(gn,{scope:_,path:e,labelled:b},e)),ee=(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c&&(0,J.jsx)(cn,{button:c,model:r,view:i,record:h,models:f}),(0,J.jsx)(A,{to:{kind:`record`,resource:r.name,key:Fe(r,h)},className:_t({size:`sm`}),children:vn(`open`,{singular:v})})]});return(0,J.jsx)(M,{title:e,help:t,count:n,actions:ee,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[b?(0,J.jsx)(`dl`,{className:`flex flex-col gap-4`,children:x}):x,g&&(0,J.jsxs)(A,{to:nn(r,i,d,{filter:a,orderBy:p,display:an(i,d,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[en(`viewAll`),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:y.toLowerCase()}),(0,J.jsx)(Yt,{className:`size-3.5`,"aria-hidden":!0})]})]})})},na=N(),ra=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},ia=(e,t,n)=>{let{through:r}=e;if(t===null)return null;if(!r)return ra(S(na.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=Oe(ra(S(na.eq(r.field,t)),r.filter));return!a.ok||!i?null:ra(S(na.related(e.field,r.resource,i,a.ast)),e.filter)},aa=e=>{if(e.some(e=>e===null))return null;if(!e.some(e=>e===void 0))return e.reduce((e,t)=>e+t,0)},oa=(e,t=!0)=>{let n=z(),{resources:r}=q(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:ia(e,t,r)}]:[]}),a=Gt({queries:i.map(({model:e,match:r})=>({...xt(n,e,r??``),enabled:t&&r!==null}))});return aa(i.map(({match:e},t)=>{if(e===null)return 0;let n=a[t];return n.isError?null:n.isSuccess?n.data??null:void 0}))},sa=N(),ca=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??H(`nothingYet`)}),la=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=q(),o=r[e.resource],s=o&&i[o.name],c=ia(e,t,r),[l,u]=hn(s,`related:${n}:${e.title}`,e.display),d=ct(e.resource),[f,p]=(0,Y.useState)(!1),m=oa([{item:e,value:t}],!!(e.hideEmpty||e.count));if(!o||e.hideEmpty&&(m===void 0||m===0))return null;let h={title:e.title,help:e.help,count:e.count?(0,J.jsx)(Zi,{count:m,names:s?.names}):void 0},g=on(e,o,r),_=e.columns??ot(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,J.jsx)(ca,{empty:e.empty}):t(c);if(e.presentation===`cards`||e.presentation===`compact`){let t=e.presentation===`compact`?{time:e.time}:void 0,n=t?_.filter(t=>t!==e.time):_,r=e.tone===void 0||n.includes(e.tone)?n:[e.tone,...n];return(0,J.jsx)(M,{...h,children:v(n=>(0,J.jsx)(Sn,{model:o,view:s,filter:n,sort:e.sort??``,fields:r,actions:e.actions??[],button:e.button,limit:e.limit??10,display:e.display,empty:e.empty,compact:t,tone:e.tone}))})}if(e.presentation===`record`)return c===null?(0,J.jsx)(M,{...h,children:(0,J.jsx)(ca,{empty:e.empty})}):(0,J.jsx)(ta,{...h,model:o,view:s,filter:c,sort:e.sort??``,fields:_,button:e.button,empty:e.empty,add:Qi(e,t,s,a,d)},c);let y=An(e,o,d),b=(0,J.jsx)(sn,{view:s,value:l,onChange:u}),x=y?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!f&&b,(0,J.jsx)(mn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,J.jsx)(M,{...h,actions:x,children:(0,J.jsx)(fn,{model:o,view:s,field:y,filter:S(sa.eq(e.field,t)),columns:_})}):(0,J.jsx)(M,{...h,actions:x,children:v(t=>(0,J.jsx)(tn,{model:o,view:s,filter:t,sort:e.sort??``,columns:_,limit:e.limit??10,display:l,empty:e.empty,opens:g,button:e.button},t))})},ua=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:$t(t,e.from)??null},da=({sections:e})=>{let t=oa(e),{views:n}=q(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,J.jsx)(Zi,{count:t,names:a})},fa=(e,t,n,r,i)=>{let a=e.fields.status?.type===`enum`&&!r.includes(`status`)?`status`:void 0,o=t?.titleBadge??a;if(o===void 0||!e.fields[o]||!i(o))return;let s=n[o];if(s!=null&&s!==``)return o},pa=N(),ma=(e,t)=>S(pa.eq(e,t)),ha=({item:e,scope:t})=>{let{resources:n}=q(),[r]=bn(e.working===void 0?[]:[e.working],t),i=n[e.resource];if(!i)return null;let a=e.calls&&n[e.calls.resource],o=e.calls&&a&&{model:a,filter:ma(e.calls.field,t.key),fields:e.calls};return(0,J.jsx)(M,{title:e.title,help:e.help,children:(0,J.jsx)(xn,{children:(0,J.jsx)(_n,{model:i,filter:ma(e.field,t.key),sender:e.sender,time:e.time,text:e.text,status:e.status,calls:o,limit:e.limit,empty:e.empty,working:e.working===void 0?void 0:r===!0})})})},ga=({item:e,scope:t})=>{let n=e.tree,r=e.reads;return(0,J.jsx)(pt,{value:t,children:(0,J.jsxs)(He,{tree:n,plan:r,children:[(0,J.jsx)(Dn,{tree:n,plan:r}),(0,J.jsx)(Cn,{node:n,at:``})]})})},_a=x(()=>Bt(()=>import(`./record-lines-SeXhFNSm.js`).then(e=>e.RecordLines),__vite__mapDeps([12,1,2,4,5,6,13,14,15,16,17,18,19,20,21,22,23,24,25])),()=>(0,J.jsx)(G,{className:`h-32 w-full rounded-lg`})),va=x(()=>Bt(()=>import(`./composer-section-tfrO2pIi.js`).then(e=>e.ComposerSection),__vite__mapDeps([26,1,2,4,5,6,27,13,14,15,16,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34])),()=>(0,J.jsx)(G,{className:`h-24 w-full rounded-lg`})),ya=(e,t)=>t===e.tenant||e.primaryKey.includes(t),ba=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!ya(e,t.name)&&!t.writeOnly),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:H(`details`),fields:a},...e.history?[{kind:`history`,title:H(`history`)}]:[],...e.comments?[{kind:`comments`,title:H(`comments`)}]:[]]},xa=({resource:e,recordKey:t})=>{let{resources:n,views:r}=q(),{address:i}=Se(),o=a(),s=n[e],c=T(e,t);if(!s)return(0,J.jsx)(Ue,{title:V(`notFound`),children:V(`noResource`,{name:e})});if(c.isPending)return(0,J.jsx)(ge,{});if(c.error)return(0,J.jsx)(`div`,{className:`p-8`,children:C(c.error)&&c.error.status===404?(0,J.jsx)(Sa,{model:s,recordKey:t}):(0,J.jsx)(U,{title:H(`couldNotLoad`),error:c.error})});let l=(0,J.jsx)(Ca,{model:s,recordKey:t,stored:c.data,preview:c.isPlaceholderData},c.isPlaceholderData?`preview`:`loaded`),u=i?.kind===`record`&&i.file!==void 0&&!c.isPlaceholderData?Pt(o,s,c.data.record,i.file):void 0,d={kind:`record`,resource:e,key:t,...(r[e]?.recordOpens!==void 0||r[e]?.record!==void 0)&&{standard:!0}};if(u)return(0,J.jsx)(Ie,{model:s,record:c.data.record,viewed:u,back:d},u.file.uri);let f=i?.kind===`record`&&i.standard===!0,p=r[e]?.recordOpens;if(p&&!f){if(c.isPlaceholderData)return(0,J.jsx)(ge,{});let e=On(p,c.data.record);if(e)return(0,J.jsx)(kn,{to:e})}let m=r[e]?.record;if(!m||f)return l;if(c.isPlaceholderData)return(0,J.jsx)(ge,{});if(`surface`in m||m.focus)return(0,J.jsx)(br,{model:s,recordKey:t,stored:c.data,page:m,standard:l});let{record:h,etag:g,permissions:_}=c.data;return(0,J.jsx)(tr,{component:m.component,scope:{model:s,record:h,key:t,etag:g,permissions:_},standard:l})},Sa=({model:e,recordKey:t})=>{let n=Hi(e,t);return n.state===`looking`?(0,J.jsx)(ge,{}):n.state===`switching`?(0,J.jsx)(Ue,{title:H(`loading`),children:H(`openingElsewhere`)}):n.state===`failed`?(0,J.jsx)(U,{title:H(`couldNotLoad`),error:n.error}):(0,J.jsx)(Ue,{title:V(`notFound`),children:H(`noRecord`)})},Ca=({model:e,recordKey:t,stored:n,preview:r})=>{let i=q(),{address:s,go:l}=Se(),f=i.views[e.name],p=ie()(e,f,n.record,t),{state:m}=Dt(),h=Xr(e,t),g=pr({model:e,stored:n,recordKey:t,mode:f?.saveFeedback??`toast`,subject:p,draftKey:!r&&m.kind===`signed-in`?rr(m.user.id,e.name,t):void 0,lines:h.draft}),_=Vt(),y=z(),x=je(g.rejections),ee=ct(e.name),S=pn(e),C=s?.kind===`record`&&s.version!==void 0,te=u(ee,`update`)&&n.permissions?.update!==!1&&!C,{shown:w,offersEdit:ne,editing:T}=dt(f?.recordMode,te,s?.kind===`record`&&s.edit===!0);Ae(g.dirty&&w===`form`||g.saving),Xe(g.dirty);let E=s?.kind===`record`?s.open:void 0,O=s?.kind===`record`&&s.edit===!0,k=s?.kind===`record`?s.tab:void 0,re=s?.kind===`record`&&s.standard===!0,j=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...re&&{standard:re}}),se=j(E,!1,k),ce=j(E,!0,k),le=w===`form`&&f?.recordMode!==void 0&&f.recordMode!==`edit`,ue=u(ee,`delete`)&&n.permissions?.delete!==!1,de=dn({model:e,view:f,restore:S,onDeleted:()=>l({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void _.invalidateQueries({queryKey:D.record(e.name,t)})}),fe=Ui(e,i.resources,i.views,n.record),pe=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},me=Object.values(e.fields).filter(e=>pe(e.name)),he={...n.record,...Object.fromEntries(me.map(e=>[e.name,Ot(e,g.value(e.name))]))},ge=Ui(e,i.resources,i.views,he),_e=(e,t)=>{let n=pe(e);if(!n||!ht(t))return g.change(e,t);_.setQueryData(D.relatedLabel(n.name,t.key),{label:t.label}),g.change(e,tt(n,t.key))},{fields:ve}=a(),ye={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},xe=Ri(ba(e,f,w===`read`),ye,T,r),{before:Ce,tabs:Te,after:Ee}=Lr(xe),N=Rr(Te,k),De=e=>T&&(g.errors[e]!==void 0||g.conflicts[e]!==void 0);(0,Y.useEffect)(()=>{if(g.rejections===0)return;let e=Br(Te,N,De);e&&l(j(E,O,e===Te[0]?void 0:e.title),{replace:!0})},[g.rejections]);let F=xe.flatMap(e=>e.kind===`sidebar`?e.fields:[]),Oe=Qn(e,`updated`),I=e=>f?.fields[e],ke=t=>kt(n.permissions,t)!==`hidden`&&rt(I(t)?.when,T)&&(w===`form`||!e.fields[t]?.writeOnly),L=e=>!r||Object.hasOwn(n.record,e),R=fa(e,f,n.record,F,ke),Ne=R&&(0,J.jsxs)(At,{value:n.record[R],hints:I(R),children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[I(R)?.label??K(R),`: `]}),qe(e.fields[R],n.record[R],I(R))]}),Fe=r=>{let a=e.fields[r],o=kt(n.permissions,r);if(!a||o===`hidden`)return null;let s=g.conflicts[r],c=pe(r),l=I(r)?.label??K(r),u=g.errors[r],d=w!==`form`||o===`read`;return(0,J.jsx)(be,{name:r,label:l,required:w===`form`&&o!==`read`&&v(a),help:Re(I(r),f,T),error:u&&Ft(a,l,u),wide:$e(ve,a,I(r)),readOnly:Mt(a,I(r),d,!!c),conflict:s===void 0?void 0:{user:{name:H(`someoneElse`),initials:`?`,hue:40},ago:H(`justNow`),theirValue:s||`—`,onKeepMine:()=>g.keepMine(r),onUseTheirs:()=>g.useTheirs(r)},children:L(r)?(0,J.jsx)(Pe,{field:a,hints:I(r),value:g.value(r),stored:n.record[r],relationLabel:ge.labels[r],relationTo:ge.addresses[r],relationPicker:c&&{target:c,view:i.views[c.name]},locked:d,invalid:!!g.errors[r],reveal:a.sensitive&&!a.writeOnly?()=>y.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:I(r)?.format===`url`?Ye(e,f,r,n.record,fe.labels):void 0,onChange:e=>_e(r,e)}):(0,J.jsx)(G,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},Ie=r=>{let i=e.fields[r],a=L(r)?i.sensitive?(0,J.jsx)(Pe,{field:i,hints:I(r),value:``,stored:n.record[r],locked:!0,reveal:()=>y.reveal(e.name,t,r),resource:e.name,onChange:e=>g.change(r,e)}):(0,J.jsx)(Lt,{model:e,field:i,value:n.record[r],relationLabel:fe.labels[r],record:n.record,relationLabels:fe.labels}):(0,J.jsx)(G,{className:`h-4 w-32`});return{label:I(r)?.label??K(r),help:Re(I(r),f,T),wide:$e(ve,i,I(r)),value:a}},Le=xe.findIndex(e=>e.kind===`sidebar`),B=(0,J.jsx)(En,{title:H(`summary`),rows:F.flatMap(t=>{let r=e.fields[t];if(!r||!ke(t))return[];if(!L(t))return[{label:I(t)?.label??K(t),value:(0,J.jsx)(G,{className:`h-4 w-24`})}];let i=n.record[t],a=we(r,I(t))&&typeof i==`string`&&i!==``,s=r.type===`json`&&i!=null,l=a?d(i):s?wt(i):qe(r,i,I(t)),u=r.type===`text`&&typeof i==`string`&&i!==``?Nt(I(t)):void 0,p=r.type===`enum`?(0,J.jsx)(At,{value:i,hints:I(t),children:l}):u?(0,J.jsx)(c,{format:u,value:l,label:Ye(e,f,t,n.record,fe.labels)}):(0,J.jsx)(`span`,{title:Me(r,i,void 0,I(t)),children:l}),m=oe(ve,r,I(t));return[{label:I(t)?.label??K(t),title:l,value:m?(0,J.jsx)(o,{shown:m,part:`display`,field:r,value:n.record[t],fallback:p}):p}]})}),Be=async()=>{await g.save()&&le&&l(se,{replace:!0})},Ve=ue?()=>void de.start({key:t,title:p,etag:n.etag,snapshot:n.record}):void 0,V=w===`form`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(W,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:g.saving,disabled:!g.dirty&&g.phase!==`saved`,onClick:()=>void Be(),children:[g.phase===`saved`&&(0,J.jsx)(b,{className:`size-4`}),g.phase===`saved`?H(`saved`):H(`save`)]}),le&&(0,J.jsx)(A,{to:se,className:P(_t(),`max-md:min-h-11 md:w-full`),onClick:e=>at(e)&&g.discard(),children:H(`cancel`)}),g.dirty&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:H(`unsavedChanges`)})]}),He=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(He);if(e.length===0)return[];let r=Ir(i,E,De),a=i.collapsed?j(Fr(E,i.title),O,k):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||L(e.from))?[{item:e,value:ua(e,n.record,t)}]:[]),s=i.count?(0,J.jsx)(da,{sections:o}):void 0;return[(0,J.jsx)(Un,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!h.model||!h.item||r?[]:[(0,J.jsx)(_a,{lines:{...h,model:h.model,item:h.item},editable:w===`form`,saving:g.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!L(i.from)?[]:[(0,J.jsx)(la,{item:i,value:ua(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,J.jsx)(kr,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,J.jsx)(Pr,{item:i,recordKey:t},`trend:${a}`)];if(r&&(i.kind===`custom`||i.kind===`map`||i.kind===`gallery`||i.kind===`blocks`))return[];if(i.kind===`custom`)return i.sidebar?[]:[(0,J.jsx)(er,{item:i,scope:ye,fallback:i.fallback&&(0,J.jsx)(J.Fragment,{children:Ii(i).flatMap(([e,t])=>He(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,J.jsx)(Cr,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,J.jsx)(gi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,J.jsx)(wi,{item:i,model:e,view:f,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,J.jsx)(ha,{item:i,scope:ye},`thread:${a}`)];if(i.kind===`blocks`)return[(0,J.jsx)(ga,{item:i,scope:ye},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,J.jsx)(va,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,J.jsx)(Mi,{item:i,resource:e.name,recordKey:t,canWrite:m.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&ke(t)),s=w===`read`&&i.presentation===`facts`,c=s?ze(n.record,o):o;return c.length===0?[]:[(0,J.jsx)(M,{title:i.title,help:Ge(i.helpWhen,f,T)?i.help:void 0,children:s?(0,J.jsx)(Kn,{facts:c.map(e=>({label:Ie(e).label,value:Ie(e).value,icon:ae(I(e)?.icon)}))}):w===`read`?(0,J.jsx)(Gn,{rows:c.map(Ie)}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:c.map(Fe)})},i.title)]},Ue=(e,t)=>e.kind===`map`?(0,J.jsx)(Cr,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,J.jsx)(er,{item:e,scope:ye,fallback:e.fallback&&(0,J.jsx)(J.Fragment,{children:Ii(e).map(([e,t])=>Ue(e,t))})},`custom:${t}`):null;return(0,J.jsxs)(`div`,{ref:x,className:`flex flex-1 flex-col`,inert:r,children:[de.dialogs,(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsxs)(`div`,{className:P(f?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,J.jsx)(Vn,{title:p,badge:Ne}),g.message&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(U,{title:H(`notSaved`),error:Error(g.message)})}),g.linesConflict&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(U,{title:H(`linesChanged`),error:Error(H(`linesReloaded`))})}),w!==`form`&&ne&&g.dirty&&(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,J.jsx)(`span`,{children:H(`unsavedKept`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(A,{to:ce,className:_t({size:`sm`}),children:H(`continueEditing`)}),(0,J.jsx)(W,{size:`sm`,onClick:g.discard,children:H(`discard`)})]})]}),w===`form`&&g.restored&&(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,J.jsx)(`span`,{children:H(`unsavedRestored`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(W,{size:`sm`,onClick:g.dismissRestored,children:H(`keep`)}),(0,J.jsx)(W,{size:`sm`,onClick:g.discard,children:H(`discard`)})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,J.jsxs)(`div`,{className:`divide-y divide-border`,children:[Ce.flatMap(He),N&&(0,J.jsx)(Wn,{tabs:Te.map((e,t)=>({title:e.title,to:j(E,O,t===0?void 0:e.title),current:e===N}))}),N&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:N.items.flatMap(He)},`tab:${N.title}`),Ee.flatMap(He)]}),(0,J.jsxs)(`aside`,{className:`space-y-4 md:sticky md:top-[var(--pb-sticky-top,0px)] md:max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px))] md:self-start md:overflow-y-auto md:pb-4 md:pt-8`,children:[V&&(0,J.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:V}),!r&&(0,J.jsx)(cr,{model:e,stored:n,recordKey:t,edit:ne?ce:void 0,onDelete:Ve}),Le===-1&&B,xe.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ue(e,t):t===Le?(0,J.jsx)(Y.Fragment,{children:B},`summary`):null),(0,J.jsx)(En,{title:H(`details`),rows:[Qn(e,`created`),Oe].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!ke(t)||F.includes(t)?[]:[{label:I(t)?.label??K(t),value:L(t)?(0,J.jsx)(`span`,{title:Me(r,n.record[t],void 0,I(t)),children:qe(r,n.record[t],I(t))}):(0,J.jsx)(G,{className:`h-4 w-24`})}]})}),!r&&(0,J.jsx)(Xi,{model:e,recordKey:t,layout:xe})]})]})]})}),V&&(0,J.jsx)(`div`,{className:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20 flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden`,children:V})]})};export{xa as RecordPage,Xn as t};
3
- //# debugId=13c43487-70c7-4247-a508-9cb139f547af
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-DXDcn-Fx.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-D6luJ1k4.js","assets/vendor-t7Q7QbPu.js","assets/app-xwgcmboV.css","assets/lib-xyflow-system-hojcPWkY.js","assets/lib-d3-interpolate-C7dFwq8w.js","assets/lib-d3-color-B6XHLQii.js","assets/lib-d3-selection-C1a5EtaJ.js","assets/lib-d3-drag-CUJR_Vab.js","assets/lib-d3-dispatch-Bjkn7q4t.js","assets/lib-d3-zoom-DuEhbOrX.js","assets/lib-d3-transition-CUMO2iZu.js","assets/lib-d3-timer-CduGpaSm.js","assets/lib-d3-ease-ouQSXgQM.js","assets/lib-xyflow-react-CuNAzocq.js","assets/lib-classcat-otpLnDWv.js","assets/lib-zustand-r6mNROKr.js","assets/lib-use-sync-external-store-D4s7MiFL.js","assets/lib-xyflow-react-DLioOiRN.css","assets/use-elk-u1Ql5AOs.js","assets/lib-elkjs-ylMkguT9.js"])))=>i.map(i=>d[i]);
2
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$n as r,$o as i,$s as a,$t as o,Aa as s,As as c,At as l,B as u,Bc as d,Bs as f,C as p,Ca as m,Cn as h,Cs as g,D as _,Dl as v,Ds as y,El as b,En as x,Eo as S,F as C,Fc as w,Fn as T,Fs as E,Ga as D,Go as O,Gt as ee,Ha as te,Ho as ne,Hs as re,In as ie,Is as ae,Jc as oe,Ji as se,Jn as ce,Jo as k,Js as le,Jt as ue,Ko as de,Li as fe,Ln as pe,Lr as me,Ls as he,M as ge,Mc as _e,Mt as ve,Na as ye,Nl as be,Ns as xe,Nt as Se,Os as Ce,Pa as we,Pl as Te,Pn as Ee,Pr as De,Ps as Oe,Pt as ke,Qa as Ae,Qc as je,Qn as Me,Qo as A,Qs as Ne,R as Pe,Rn as Fe,Ro as Ie,Rr as Le,Rs as Re,Sc as ze,Si as Be,Ss as Ve,Tc as He,Ts as Ue,Ua as j,Un as We,Uo as Ge,V as Ke,Vc as M,Vl as qe,Vr as Je,Vs as Ye,Wa as Xe,Wo as N,Xi as Ze,Xo as P,Xs as Qe,Xt as $e,Yc as et,Yn as tt,Yo as nt,Zo as rt,Zs as it,_ as at,_n as ot,_s as F,_t as st,as as ct,at as lt,b as ut,ba as dt,bi as ft,bs as pt,cc as mt,cn as ht,cr as I,cs as gt,dl as _t,do as vt,dr as yt,ea as bt,fr as L,ga as xt,gi as St,gn as Ct,gt as wt,ha as Tt,hn as Et,i as Dt,ic as R,il as Ot,in as z,io as kt,ir as At,is as jt,jt as Mt,k as Nt,ki as Pt,ks as Ft,ln as It,lr as Lt,ma as Rt,mn as zt,mr as B,nl as Bt,nn as Vt,no as Ht,nr as Ut,ns as Wt,oc as V,ol as Gt,on as Kt,or as qt,pa as Jt,pl as Yt,pn as Xt,pr as H,qi as Zt,qo as U,rc as W,rn as Qt,s as $t,sa as en,sc as tn,sl as nn,sn as rn,sr as G,ta as an,tc as on,tn as sn,to as cn,tr as ln,ts as K,un,ur as dn,v as fn,vc as pn,vn as mn,vs as q,wn as hn,ws as gn,wt as _n,xs as J,y as vn,ya as yn,yn as bn,ys as xn,zo as Sn,zs as Cn}from"./app-D6luJ1k4.js";import{C as wn,f as Tn,o as En,s as Dn}from"./vendor-t7Q7QbPu.js";import{C as On,Ct as kn,Dt as An,Et as jn,Mt as Mn,O as Nn,Ot as Pn,Q as Fn,St as In,Tt as Ln,X as Rn,Z as zn,_t as Bn,at as Vn,b as Hn,ct as Un,dt as Wn,ft as Gn,gt as Kn,it as qn,k as Jn,kt as Yn,l as Xn,lt as Zn,mt as Qn,n as $n,nt as er,o as tr,ot as nr,rt as rr,st as ir,t as ar,tt as or,ut as sr,wt as cr,x as lr,xt as ur,y as dr}from"./embedded-list-B_e_Quer.js";import{t as fr}from"./circle-alert-C_1i142n.js";import{t as pr}from"./page-header-Ddz2r5ic.js";import{n as mr,t as hr}from"./pending-invitation-row-D_vU7ynw.js";import{n as gr,t as _r}from"./person-row-DMY-aQjx.js";import{n as vr,t as yr}from"./use-paged-search-CcEitpWG.js";import{n as br,t as xr}from"./client-publisher-D39SlIhp.js";import{t as Sr}from"./copy-field-D9agQmK0.js";var Cr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Cr.node;var wr=d(Cr),Tr={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Tr.node;var Er=d(Tr),Dr={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Dr.node;var Or=d(Dr),kr={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};kr.node;var Ar=d(kr),jr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};jr.node;var Mr=d(jr),Nr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Nr.node;var Pr=d(Nr),Fr={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Fr.node;var Ir=d(Fr),Lr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Lr.node;var Rr=d(Lr),zr=[`done`,`error`,`running`];Ye(`TextField`,!1),Ye(`NumberField`,!1),Ye(`DateField`,!1),Ye(`BooleanField`,!1),Ye(`UrlField`,!1),Ye(`ChipField`,!1);var Br=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Vr=e=>typeof e!=`string`&&!e.custom&&Br.has(e.type),Hr=e=>typeof e==`string`||Vr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Ur=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Wr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Gr=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},Kr=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},qr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Jr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Yr=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:Jr.has(`${n.toLowerCase()}:`)?e:void 0},Xr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Zr=e=>e==null||e===``?void 0:String(e),Qr=(e,t)=>e<t?-1:+(e>t),$r=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Zr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Zr(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>Zr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Zr(e[i.source]),s=Zr(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>Qr(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>Qr(e.id,t.id)),edges:s.sort((e,t)=>Qr(e.source,t.source)||Qr(e.target,t.target)||Qr(e.id,t.id))}},Y=e(t(),1),X=e(n(),1),ei=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=K(),s=kn(e.name,void 0),c=fe(),[l,u]=(0,Y.useState)(!1),d=o[e.name]?.actions?.find(e=>e.name===n);if(!d||d.run?.kind===`link`)return null;let f=t.map(t=>zt(e,t)),p=f.filter(e=>s.verdictOn(d,e)!==`skip`);if(p.length===0)return null;let m=f.length-p.length,h=ur(`actionCount`,{label:r??d.label,count:p.length}),g=e=>s.runEach(d,p,m,e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{size:`sm`,variant:i??d.variant??`secondary`,className:a,loading:s.running===n,onClick:()=>jn(d)?u(!0):void g(),children:h}),l&&(0,X.jsx)(Ln,{action:d,label:h,danger:i===`danger`||i===void 0&&An(d),records:p.map(e=>e.record),names:p.map(t=>In(c(e,o[e.name],t.record,t.key))),onCancel:()=>u(!1),onConfirm:()=>{u(!1),g()},onSubmit:async e=>{u(!1),await g(e)}})]})},ti=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=qt(),c=cr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,Y.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>jn(c.action)?u(!0):void c.run(),children:d}),l&&(0,X.jsx)(Ln,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ni=({node:e,className:t})=>{let n=z(e),r=yt(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,X.jsx)(ei,{...n,model:i,items:r.items,className:t}):(0,X.jsx)(ti,{...n,className:t})},ri=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=z(e);return(0,X.jsx)(L,{title:i,description:a,actions:n.actions,className:M(`h-full`,r),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ii=({children:e,wrap:t=(e,t)=>(0,X.jsx)(Y.Fragment,{children:e},t)})=>{let n=yt();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...zt(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,X.jsx)(Ut,{value:s,row:{index:o,count:i.length},children:e}),c)})},ai=({children:e})=>(0,X.jsx)(ii,{children:e}),oi=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=sn(t),f=ot(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,X.jsx)(L,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,X.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-24 w-56`},t))}):p.error?(0,X.jsx)(B,{title:j(`couldNotLoad`),error:p.error}):m.length===0?(0,X.jsx)(H,{children:s??j(`nothingYet`)}):(0,X.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,X.jsx)(Lt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,X.jsx)(ii,{wrap:(e,t)=>(0,X.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:l})})})})},si=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=z(e),o=K().resources[i];return o?(0,X.jsx)(oi,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},ci=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=z(e),{resources:u,views:d}=K(),f=u[r];return f?(0,X.jsx)(L,{title:i,description:a,actions:t.actions,className:M(`h-full`,n),children:(0,X.jsx)(Gn,{model:f,view:d[r],...l})}):null},li=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=Ct(e,t),a=i.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(W,{className:`h-4 w-1/2`}),(0,X.jsx)(W,{className:`h-4 w-1/3`})]}):i.error?(0,X.jsx)(B,{title:j(`couldNotLoad`),error:i.error}):i.data?(0,X.jsx)(Ut,{value:i.data,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,X.jsx)(H,{children:j(`nothingYet`)});return(0,X.jsx)(`div`,{className:n,children:a})},ui=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},di=e=>e==null?``:String(e),fi=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=ui(i[t.start]);if(e===void 0)continue;let a=ui(i[t.end]),o=Math.max(e,a??n),s=r.get(di(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(di(i[t.lane]),s);let c=s.bars.get(di(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(di(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},hi=(e,t,n)=>{let r=pi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:fi(n,a,s),width:fi(r,a,s)-fi(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:fi(o,a,s),width:fi(c,a,s)-fi(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:fi(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:fi(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:di(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:en(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,X.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?Ze(e.at+i(e.at)):an(e.at,r)},e.at))})},Oi=(e,t,n)=>{let r=String(n),i=t?.waitingValues?.includes(r)??!1,a=t?.valueColors&&Object.hasOwn(t.valueColors,r)?t.valueColors[r]:void 0;return a!==void 0&&Yt(a)?{className:rt[a],striped:i}:{color:Kn(e,t,n===void 0?null:n,-1),striped:i}},ki=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:M(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?Zt(e):se(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return j(`timelineRange`,{from:ji(n,a),to:i?j(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${St(t.fields[r.color],e.value,n?.fields[r.color])}: ${Mi(t,r,e.start,e.end,e.open)}`,Pi=(e,t,n,r,i)=>{let a=e.segments.some(t=>t.open&&t.end===e.end);return[`${i??St(t.fields[r.bar],e.value,n?.fields[r.bar])}: ${Mi(t,r,e.start,e.end,a)}`,...e.segments.map(e=>Ni(e,t,n,r))].join(`; `)},Fi=`absolute inset-y-0 flex overflow-hidden rounded-sm ring-offset-1 ring-offset-background outline-none hover:ring-2 hover:ring-border-strong focus-visible:ring-2 focus-visible:ring-primary`,Ii=({bar:e,model:t,view:n,fields:r,point:i,choose:a})=>{let o=K().resources[t.fields[r.bar]?.relation?.resource??``],s=x(o??t,e.key,o!==void 0),c=Pi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,X.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,X.jsx)(on,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:M(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,X.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,X.jsx)(bn,{model:n,field:i,value:e.value})}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,X.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,X.jsx)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:M(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Ri,{...t,value:e}),St(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:(0,X.jsx)(bn,{model:n,field:n.fields[i.bar],value:e.value})}),(0,X.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(Ri,{...t,value:e.value}),St(n.fields[i.color],e.value,r?.fields[i.color]),`: `,Mi(n,i,e.start,e.end,e.open)]},a))})]})},Vi=500,Hi=(e,t,{filter:n=``,sort:r,fields:i,limit:a})=>({queryKey:[...oe.list(t.name,n,r,a,`timeline`),i.join(`,`)],queryFn:async()=>{let o=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:r,pageSize:Math.min(Vi,a-o.length),fields:i,etag:!1,...s&&{pageToken:s}});o.push(...c.items),s=c.nextPageToken||void 0}while(s&&o.length<a);return{rows:o.toReversed(),cut:s!==void 0}}}),Ui=(e,{enabled:t=!0,...n})=>En({...Hi(gt(),e,n),enabled:t,placeholderData:Tn}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=ae,title:s,description:c,empty:l,actions:u,className:d,choose:f,details:p})=>{let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),v=e=>e?Ci(e):null,y={hover:e=>h(v(e)),focus:e=>_(v(e))},b=sn(i),x=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!b}),S=b??x,C=b?b.rows:x.data?.rows??[],w=!b&&x.data?.cut===!0,T=hi(C,n,Date.now());return(0,X.jsxs)(L,{title:s,description:c,actions:u,className:M(`h-full`,d),children:[(()=>{if(S.isPending)return(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,X.jsx)(W,{className:`h-6`},t))});if(S.error)return(0,X.jsx)(B,{title:j(`couldNotLoad`),error:S.error});if(T.lanes.length===0)return(0,X.jsx)(H,{children:l??j(`nothingYet`)});let r=new Set(C.map(e=>String(e[n.color])));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,X.jsx)(Li,{shape:T,model:e,view:t,fields:n,point:y,...f&&{choose:f}}),w&&(0,X.jsx)(H,{children:j(`timelineCut`,{count:C.length})}),(0,X.jsx)(`div`,{"aria-live":`polite`,children:(0,X.jsx)(Bi,{bar:wi(T,m)??wi(T,g),model:e,view:t,fields:n})})]})})(),p]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:i,linkTo:o}=r(),s=i[e],c=t=>o({[e]:t}),l=n.model.fields[n.fields.bar],u=s===void 0?null:(0,X.jsx)(a,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{filter:Bn(l,Gi(l,s),n.filter),sort:n.sort},children:t},s)});return(0,X.jsx)(Wi,{...n,choose:{barTo:c,chosen:s},details:u})},qi=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,lane:c,bar:l,start:u,end:d,color:f,children:p,...m}=z(e),{resources:h,views:g}=K(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:he(e),sort:Re(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,X.jsx)(Wi,{...v}):(0,X.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=f(e),r=ln(),{resources:i}=K();if(!n||!r)return t;let o=r.given[n.param],s=n.resource===void 0?void 0:i[n.resource];return o===void 0||!s?null:(0,X.jsx)(a,{name:n.param,children:(0,X.jsx)(li,{model:s,query:{key:o},className:``,children:t},o)})},Yi=(0,Y.lazy)(()=>wn(()=>import(`./graph-view-DXDcn-Fx.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Xi=(0,X.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,X.jsx)(mt,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=z(e),s=o(e,t),c=ln(),l=s.nodes,u=s.edges,{label:d,group:f,status:p,source:m,target:h}=a,g=(0,Y.useMemo)(()=>({label:d,source:m,target:h,...f!==void 0&&{group:f},...p!==void 0&&{status:p}}),[d,m,h,f,p]),_=JSON.stringify([l?.rows,u?.rows,g]),v=(0,Y.useMemo)(()=>l&&u&&$r({nodes:l.rows,edges:u.rows,key:l.model.primaryKey[0],edgeKey:u.model.primaryKey,fields:g}),[_]);if(!l||!u||!v)return null;let y=l.error??u.error;if(y&&e.fallback)throw y;if(y)return(0,X.jsx)(B,{title:j(`couldNotLoad`),error:y});if(l.isPending||u.isPending)return Xi;if(v.nodes.length===0)return(0,X.jsx)(H,{children:a.empty??j(`nothingYet`)});let b=a.select,x=b!==void 0&&c?{chosen:c.given[b],linkTo:e=>c.linkTo({[b]:e})}:void 0;return(0,X.jsxs)(`div`,{className:M(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:Xi,children:(0,X.jsx)(Yi,{shape:v,nodes:l,edges:u,fields:g,props:a,...x&&{select:x},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&x?.chosen!==void 0&&(0,X.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,X.jsx)(Ji,{node:e,children:r})})]})},Q=et(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r})=>{let{resources:i}=K(),a=gt(),o=mn(),s=Wt(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)();return!i[e]||!m(s,`create`)?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[u!==void 0&&(0,X.jsx)(B,{title:Q(`notSent`),error:u}),(0,X.jsx)(_n,{onSend:async r=>{l(!0),d(void 0);let i=await a.create(e,{...n,[t]:r}).then(()=>!0,e=>(d(e),!1));return l(!1),i&&o(e),i},busy:c,placeholder:r})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=z(e);return(0,X.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=z(e);return(0,X.jsx)(`details`,{open:r,className:M(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,X.jsx)(`summary`,{className:M(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=z(e),i=It(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,X.jsx)(W,{className:M(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,X.jsx)(`p`,{className:M(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=wt(a);return o?(0,X.jsx)(`div`,{className:M(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,X.jsx)(st,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,X.jsx)(`pre`,{className:M(`overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-background p-3 font-mono text-[0.6875rem] leading-[18px]`,t),children:a})},ra=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),ia=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>nn(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=z(e),{views:a}=K(),o=It(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,X.jsx)(W,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,X.jsx)(bn,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,X.jsx)(`div`,{className:t,children:s});let c=r??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:M(`min-w-0`,t),children:[(0,X.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=z(e),i=e.children,a=i.length>0&&i.every(la);return(0,X.jsx)(`div`,{className:M(`grid grid-cols-1 gap-4`,a?sa[r]:oa[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,X.jsx)(`div`,{className:M(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,X.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),fa=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=e=>{let[t,n]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},ga=e=>{let[t,n]=(0,Y.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:r,refresh:i,className:a})=>{let o=gt(),{theme:s}=we(),[c,l]=lt(),u=fa({width:n,height:r,space:l,theme:s}),d=En({queryKey:oe.image(e,u??{}),enabled:u!==void 0,placeholderData:Tn,...pa(i),queryFn:async()=>{let t=await o.invoke(e,{query:u,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),f=ha(d.data),[p,m]=ga(f),h={...n!==void 0&&{width:n},...r!==void 0&&{height:r}};return(0,X.jsx)(`div`,{ref:c,className:M(`min-w-0`,a),children:d.isError||p?t&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t}):f?(0,X.jsx)(`img`,{src:f,alt:t??``,onError:m,style:h,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,X.jsx)(W,{className:`w-full max-w-full`,style:{height:r??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=z(e);return n.src===void 0?(0,X.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,X.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=z(t),{views:i}=K(),a=It(r.source);return a.state===`missing`?null:a.state===`loading`?(0,X.jsx)(W,{className:`inline-block h-3 w-16 align-middle`}):Ur(t.type,a.value)?r.emptyText?(0,X.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,X.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?Gt(e,n?.valueLabels):Wr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,X.jsx)(`span`,{className:`tabular-nums`,children:Gr(e,t,je())})),Ca=ya(({value:e,props:t})=>{let n=Kr(e,t,{locale:je(),now:Date.now(),relative:bt});return(0,X.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=qr(e,t,{yes:Pt(`yes`),no:Pt(`no`)});return e?(0,X.jsx)(We,{label:n,className:`align-middle`}):(0,X.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Yr(n);return i===void 0?r:(0,X.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),Ea=ya(e=>(0,X.jsx)(hn,{value:e.value,hints:e.hints,children:ba(e)})),Da=`font-medium text-primary-text hover:underline`,Oa=({node:e,children:t,className:n})=>{let r=z(e),i={...I(G()),params:Me()},a=r.variant?M(tn({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=be(r.to,gn(i));return(0,X.jsx)(me,{to:e,className:a,children:o??le(e)})}let s=r.href??``;return(0,X.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},ka=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:_(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:_(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return $t(r)?r.key===_(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:p(i,r,n[t])?[[t,Nt(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=K(),u=gt(),d=ye(),f=mn(),p=l[e.name],[m,h]=(0,Y.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,Y.useState)({}),[v,y]=(0,Y.useState)(0),b=at(v),[x,S]=(0,Y.useState)(),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1);it(T||C,`input-lost`);let D=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...Dt(e,c,m),...o}):u.update(e.name,t.key,Aa(e,m,t.record),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:j(`saved`,{label:i??r})}),s()},e=>{let t=fn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,X.jsx)(R,{title:i??r,onClose:s,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:s,children:j(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:C,onClick:()=>void D(),children:j(n===`create`?`create`:`save`)})]}),children:(0,X.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),D()},children:[x!==void 0&&Object.keys(g).length===0&&(0,X.jsx)(B,{title:j(`notSaved`),error:x}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??nn(n),s=g[n];return(0,X.jsx)(Pe,{name:n,label:o,help:p?.fields[n]?.help,error:s&&vn(r,o,s),children:(0,X.jsx)(ut,{field:r,hints:p?.fields[n],value:$t(i)?i.key:i,stored:t?.record[n],relationLabel:$t(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),E(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=Ct(e,{key:t});return(0,X.jsx)(X.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=z(e),n=qt(),{resources:r}=K(),i=r[t.resource??n?.model.name??``],a=Wt(i?.name??``),[o,s]=(0,Y.useState)(!1);if(!i||!(t.mode===`create`?m(a,`create`):m(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,X.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,X.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=z(e);return(0,X.jsx)(`div`,{className:M(`flex-1`,r),children:(0,X.jsxs)(`div`,{className:M(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,X.jsx)(pr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=G(),r=typeof e==`string`?At(n,e):void 0,i=rn(r&&`frame`in r?r.frame:void 0,r&&`path`in r?r.path:``);return typeof e==`number`?e:e===void 0?t:r&&`item`in r?Number(r.item):i.state===`ready`?Number(i.value):i.state===`loading`?void 0:NaN},Ia=({node:e,className:t})=>{let{value:n,max:r,label:i}=z(e),a=Fa(n,0),o=Fa(r,100);if(a===void 0||o===void 0)return(0,X.jsx)(W,{className:`h-6 w-full`});if(!Number.isFinite(a)||!Number.isFinite(o))return null;let s=o>0?Math.min(1,Math.max(0,a/o)):0;return(0,X.jsxs)(`div`,{className:M(`min-w-0`,t),children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(je()),` / `,o.toLocaleString(je())]})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":o,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:s>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${s*100}%`}})})]})},La=({model:e,at:t,filter:n,sort:r,recordKey:i,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=sn(t),f=Ct(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Xt(e,d):f,m=e=>p.data?(0,X.jsx)(Ut,{value:p.data,children:e}):void 0,h=p.isPending?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(W,{className:`h-4 w-1/2`}),(0,X.jsx)(W,{className:`h-4 w-1/3`})]}):p.error?(0,X.jsx)(B,{title:j(`couldNotLoad`),error:p.error}):p.data?m((0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,X.jsx)(H,{children:s??j(`nothingYet`)});return(0,X.jsx)(L,{title:a,description:o,actions:c?m(c):void 0,className:M(`h-full`,u),children:h})},Ra=({node:e,at:t,children:n,slots:r,className:i})=>{let{resource:a,filter:o,sort:s,recordKey:c,title:l,description:u,empty:d}=z(e),f=K().resources[a];return f?(0,X.jsx)(La,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},za=et(`app/related-cards`),Ba=({children:e})=>{let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,X.jsx)(`div`,{className:M(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,X.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,X.jsx)(V,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:za(n?`showLess`:`showMore`)})]})},Va=e=>e==null||e===``,Ha=({scope:e,path:t,labelled:n=!0,clamped:r=!1})=>{let{views:i}=K(),a=rn(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,X.jsx)(W,{className:`h-4 w-24`}):(0,X.jsx)(bn,{model:a.model,field:a.field,value:a.value}),s=r?(0,X.jsx)(Ba,{children:o}):o;if(!n)return(0,X.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,X.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:s})=>{let c=fe(),{resources:l}=K(),u=c(e.model,t,e.record,e.key),d=a.length>0||o!==void 0;return(0,X.jsxs)(`li`,{"data-card":e.key,className:M(`relative grid min-w-0 items-center gap-x-4 gap-y-1 rounded-lg border border-border bg-surface px-4 py-2.5`,d?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,X.jsx)(ue,{view:t,field:i,record:e.record}),(0,X.jsxs)(`div`,{className:M(`flex min-w-0 items-baseline gap-2`,d&&`col-span-2 sm:col-span-1`),children:[(0,X.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:dt(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:u}),r&&(0,X.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,X.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,X.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,X.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),d&&(0,X.jsx)(Ut,{value:e,children:(0,X.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,X.jsx)(or,{button:o,model:e.model,view:t,record:e.record,models:l}),a.map(e=>(0,X.jsx)(ti,{name:e,about:u,onRun:e=>s?.(e,u)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let s=fe(),{resources:c}=K(),l=s(e.model,t,e.record,e.key);return(0,X.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,X.jsx)(ue,{view:t,field:r,record:e.record}),(0,X.jsx)(me,{to:{kind:`record`,resource:e.model.name,key:dt(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:l}),n.length>0&&(0,X.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,X.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,X.jsx)(Ut,{value:e,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,X.jsx)(or,{button:a,model:e.model,view:t,record:e.record,models:c}),i.map(e=>(0,X.jsx)(ti,{name:e,about:l,onRun:e=>o?.(e,l)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=e=>{let t=(0,Y.useRef)(null),n=(0,Y.useRef)({current:e,previous:e}),r=(0,Y.useRef)(void 0),[i,a]=(0,Y.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(t.current))?.focus()};return(0,Y.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},Xa=({compact:e,limit:t})=>(0,X.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,X.jsx)(W,{className:e?`h-17.5 w-full max-sm:h-24`:`h-24 w-full`},n))}),Za=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,button:o,limit:s,display:c,empty:l,carousel:u,compact:d,tone:f,planned:p})=>{let m=Sn(),h=sr(),g=t?.names?.plural??nn(e.name),_=r||xt(e,t),v=ot(e,{filter:n,sort:_,pageSize:s,enabled:!p}),y=Et(e,n,!p),b=p?p.rows:{isPending:v.isPending,error:v.error},x=p?p.rows.rows:v.data?.items,S=p?{data:p.total&&!p.total.isPending&&!p.total.error?er(p.total):void 0}:y,C=(0,Y.useMemo)(()=>(x??[]).map(t=>zt(e,t)),[e,x]),w=Ya((0,Y.useMemo)(()=>C.map(e=>e.key),[C]));return(0,X.jsxs)(`div`,{ref:w.root,children:[(()=>{if(b.isPending)return(0,X.jsx)(Xa,{compact:!!d,limit:s});if(b.error)return(0,X.jsx)(B,{title:za(`couldNotLoad`),error:b.error});if(C.length===0)return(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:l??za(`nothingYet`)});let r=C.map(e=>{let n=(t,n)=>w.acted(e.key,t,n);return d?(0,X.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,X.jsx)(Wa,{scope:e,view:t,fields:i,tone:f,actions:a,button:o,onActed:n},e.key)}),p=S.data===void 0?void 0:Un(C.length,S.data,!1);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,X.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,X.jsx)(Wn,{scroll:h,label:g,share:u,children:r}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p}),(0,X.jsxs)(me,{to:nr(e,t,m,{filter:n,orderBy:_,display:rr(t,m,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Zn(`viewAll`),` `,(0,X.jsx)(`span`,{className:`sr-only`,children:g.toLowerCase()}),(0,X.jsx)(Mn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:w.announcement})]})},Qa={"1/4":1/4,"1/3":1/3,"1/2":1/2,"2/3":2/3},$a=({node:e,at:t,slots:n,className:r})=>{let i=z(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=Xr(i),{resources:_,views:v}=K(),[y,b]=Vt([t,t===void 0?void 0:`${t}#total`]),x=(0,Y.useMemo)(()=>y&&{rows:y,total:b},[y,b]),S=_[a];if(!S)return null;let w=v[S.name];return(0,X.jsx)(`section`,{className:M(`min-w-0`,r),"aria-label":f,children:(0,X.jsx)(C,{title:f,help:p,actions:n.actions,children:(0,X.jsx)(Za,{model:S,view:w,filter:o,sort:s,fields:c??Bt(S,w),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...x&&{planned:x}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=K(),o=Je(i,a,e.name),s=Nn(e.name,t.listOf,!0),c=(t.names?.plural??nn(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,X.jsx)(B,{title:On(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,X.jsx)(W,{className:`h-24`});let l=Jn(o.model,s.data);return l?(0,X.jsx)(lr,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??On(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=_t(dt(e,i)),{name:o,chips:s,title:c,body:l}=dr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,X.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,X.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,X.jsx)(me,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,X.jsx)(Rn,{chips:s})})}),(0,X.jsx)(lr,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=K(),a=t.searchesOf,o=r[a.resource],s=Hn(e.name,!0),c=(t.names?.plural??nn(e.name)).toLowerCase();return o?s.error?(0,X.jsx)(B,{title:zn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n??zn(`noneYet`,{plural:c})}):(0,X.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,X.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},_t(dt(e,n))))}):(0,X.jsx)(W,{className:`h-40`}):null},ro=({node:e,slots:t,className:n})=>{let{resource:r,filter:i=``,sort:a,limit:o,display:s,title:c,description:l,empty:u}=z(e),{resources:d,views:f}=K(),p=d[r];if(!p)return null;let m=f[p.name];return(0,X.jsx)(L,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,X.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,X.jsx)(lr,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,X.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=K(),c=Wt(e.name),l=gt(),u=ye(),d=mn(),f=s[e.name],[h,g]=(0,Y.useState)(i),[_,v]=(0,Y.useState)(()=>ka(e,t,i?.record)),[y,b]=(0,Y.useState)({}),[x,S]=(0,Y.useState)(),[C,w]=(0,Y.useState)(!1),T=(0,Y.useRef)(Promise.resolve()),E=(0,Y.useRef)(i),D=ka(e,t,void 0),O=h?m(c,`update`)&&h.permissions?.update!==!1:m(c,`create`),ee=t.filter(t=>!io(e.fields[t])),te=ee.some(t=>h?p(e.fields[t],_[t],h.record[t]):_[t]!==D[t]),ne=async t=>{let n=E.current;if(n){let r=await l.update(e.name,n.key,Aa(e,t,n.record),n.etag??`*`);return{...zt(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,Dt(e,o,{...D,...t}));return{...zt(e,r.record),etag:r.etag}},re=t=>{let r=T.current.then(async()=>{w(!0),S(void 0),await ne(t).then(async r=>{E.current=r,g(r),b(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:j(`saved`,{label:n??j(`settings`)})})},e=>{b(t=>({...t,...fn(e)})),S(e)}),w(!1)});T.current=r},ie=(t,n)=>{v(e=>({...e,[t]:n})),io(e.fields[t])&&re({[t]:n})};return(0,X.jsx)(L,{title:n,description:r,className:M(`h-full`,a),children:(0,X.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),te&&re(Object.fromEntries(ee.map(e=>[e,_[e]])))},children:[x!==void 0&&Object.keys(y).length===0&&(0,X.jsx)(B,{title:j(`notSaved`),error:x}),t.map(t=>{let n=e.fields[t],r=f?.fields[t]?.label??nn(t),i=y[t];return(0,X.jsx)(Pe,{name:t,label:r,help:f?.fields[t]?.help,error:i&&vn(n,r,i),children:(0,X.jsx)(ut,{field:n,hints:f?.fields[t],value:_[t],stored:h?.record[t]??D[t],invalid:!!i,locked:!O||n.readOnly,resource:e.name,onChange:e=>ie(t,e)})},t)}),O&&te&&(0,X.jsx)(`div`,{children:(0,X.jsx)(V,{type:`submit`,variant:`primary`,size:`sm`,loading:C,children:j(`save`)})})]})})},oo=e=>{let t=Ct(e.model,{});return t.isPending?(0,X.jsx)(L,{title:e.title,description:e.description,className:e.className,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(W,{className:`h-4 w-1/2`}),(0,X.jsx)(W,{className:`h-4 w-1/3`})]})}):t.error?(0,X.jsx)(L,{title:e.title,description:e.description,className:e.className,children:(0,X.jsx)(B,{title:j(`couldNotLoad`),error:t.error})}):(0,X.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=z(e),o=K().resources[n];return o?(0,X.jsx)(oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=K(),r=gt(),i=JSON.stringify(e),a=(0,Y.useMemo)(()=>JSON.parse(i).map(E),[i]),o=e=>t.some(t=>`item`in t?typeof t.item==`object`&&t.item!==null&&Object.hasOwn(t.item,e):Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=xe(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=l.map(e=>At(t,e)),f=ht(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=Dn({queries:u.map(e=>un(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=l.indexOf(n),r=d[e];if(r&&`item`in r){t[n]=r.item;continue}let i=f[e];if(i.state===`loading`)return;i.state===`ready`&&(t[n]=i.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(p[r].isPending)return;else t[n]=p[r].data??0}return Oe(e,t)})},uo=(e,t)=>typeof e.props.fallback==`string`?e.props.fallback:t.fallback,fo=({node:e,children:t,slots:n,className:r})=>{let{when:i}=z(e),[a]=lo([i],G());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:o}):(0,X.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(g(e,I(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=G(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(e,n):t[o];return s==null?null:r===void 0?(0,X.jsx)(X.Fragment,{children:s}):(0,X.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,X.jsx)(X.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=K(),i=sn(t),a=Et(e,n,!i),o=i??a;if(o.isPending)return(0,X.jsx)(W,{className:`h-8 w-16`});if(o.error)return(0,X.jsx)(`span`,{className:`text-danger-text`,children:j(`couldNotCount`)});let s=i?er(i):a.data;return(0,X.jsx)(me,{to:Qn(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(je())})},vo=({field:e,format:t})=>{let n=It(e);return n.state===`loading`?(0,X.jsx)(W,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,X.jsx)(`span`,{className:go,children:ra(n.value)}):(0,X.jsx)(`span`,{className:go,children:(0,X.jsx)(bn,{model:n.model,field:n.field,value:n.value,format:t})})},yo=({node:e,at:t,className:n})=>{let{label:r,value:i,resource:a,filter:o,field:s,format:c,description:l}=z(e),{resources:u}=K(),d=a===void 0?void 0:u[a];return(0,X.jsxs)(L,{className:M(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,X.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:go,children:i}),d&&(0,X.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,X.jsx)(vo,{field:s,format:c})]}),l&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=Sn(),i=qn(t),[a,o]=(0,Y.useState)(()=>Vn(localStorage,i)),s=(0,Y.useCallback)(e=>{o(e),ir(localStorage,i,e)},[i]);return[rr(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:c,className:l})=>{let{resources:u,views:d}=K(),f=d[e.name],{fields:p}=s(),h=m(Wt(e.name),`update`),{go:g,href:_}=Le(),v=Sn(),y=!Ie(),b=(0,Y.useMemo)(()=>n?.map(Ce)??Bt(e,f),[n,e,f]),x=(0,Y.useMemo)(()=>Kt(e,f,b,{resources:u,views:d,fieldTypes:p}),[e,f,b,u,d,p]),S=(0,Y.useMemo)(()=>v?Qt(n)(x):x,[v,n,x]),C=(0,Y.useMemo)(()=>r?Xn(S,e,f,r,u,y):S,[S,e,f,r,u,y]),w=(0,Y.useMemo)(()=>t.map(t=>({...t,id:yn(e,t)})),[t,e]),T=(0,Y.useMemo)(()=>({total:w.length,rowAt:e=>w[e]}),[w]),E=tr({model:e,view:f,opens:void 0,resources:u,views:d,canUpdate:h}),D=e=>({href:_(e),onFollow:()=>g(e)});return(0,X.jsx)(L,{title:i,description:a,actions:c,className:l,children:w.length===0?(0,X.jsx)(H,{children:o??j(`nothingYet`)}):(0,X.jsx)(Fn,{fit:!0,columns:C,source:T,latencyMs:0,onOpenRow:e=>g(E.address(e)),rowLink:e=>D(E.address(e)),rowActions:E.actions(D),rowNumbers:!1,selectable:!1})})},So=e=>{let t=yt();return t?.model?(0,X.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?b:g,y=(0,Y.useMemo)(()=>i?.map(Ce),[i]),x=(0,Y.useMemo)(()=>Qt(i),[i]);return(0,X.jsxs)(L,{title:l,description:u,actions:(0,X.jsxs)(X.Fragment,{children:[!m&&(0,X.jsx)(ar,{view:t,value:v,onChange:_}),f]}),className:M(`h-full`,p),children:[(0,X.jsx)($n,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:x,...m&&{rowTo:m.rowTo,chosenKey:m.key},...h&&{planned:h}}),m?.details]})},wo=({node:e,at:t,slots:n,children:r,className:i})=>{let{className:a,resource:o,select:s,children:c,...l}=z(e),{resources:u,views:d}=K(),[f,p]=Vt([t,t===void 0?void 0:`${t}#total`]),m=(0,Y.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,X.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,X.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,X.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:i,linkTo:o}=r(),s=t=>o({[e]:t}),c=i[e],l=c===void 0?null:(0,X.jsx)(a,{name:e,children:(0,X.jsx)(li,{model:n.model,query:{key:c},children:t},c)});return(0,X.jsx)(Co,{...n,chosen:{rowTo:s,key:c,details:l}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=Tt(),{navigate:a}=Ne(),o=Rt(e),s=Jt(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,X.jsxs)(`div`,{className:M(`flex flex-col gap-6`,n),children:[(0,X.jsxs)(`select`,{"aria-label":j(`tabs`),value:s?.name??``,onChange:e=>a(c(e.target.value)),className:`h-9 rounded-md border border-border-strong bg-background px-2 font-medium md:hidden`,children:[!s&&(0,X.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,X.jsx)(`nav`,{"aria-label":j(`tabs`),className:`hidden border-b md:block`,children:(0,X.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Qe,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:M(`-mb-px inline-flex h-9 items-center whitespace-nowrap border-b-2 px-3 font-medium transition-colors`,e===s?`border-foreground text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:e.label})},e.name))})}),s?(0,X.jsx)(Y.Fragment,{children:t[o.indexOf(s)]},s.name):(0,X.jsx)(Xe,{children:j(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=Gt(e,t?.valueLabels);return n===`done`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(w,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(mt,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&ft(t?.valueColors,e)!==`red`?r:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,X.jsx)(fr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?Ee(e):e;return t===T?(0,X.jsx)(pe,{children:String(e)}):(0,X.jsx)(ie,{value:t})},Mo=({label:e,children:t})=>(0,X.jsxs)(`div`,{className:`grid gap-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,X.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,X.jsxs)(V,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,X.jsx)(_e,{"aria-hidden":!0,className:M(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,X.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,X.jsx)(Mo,{label:Q(`callInput`),children:(0,X.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,X.jsx)(Mo,{label:Q(`callResult`),children:(0,X.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,X.jsx)(Mo,{label:Q(`callError`),children:(0,X.jsx)(pe,{children:e.error})})]})]})},Po=(e,t)=>e.map(e=>({kind:`message`,row:e,time:typeof e[t]==`string`?e[t]:void 0})),Fo=e=>{if(typeof e==`object`&&e&&`id`in e){let{id:t,name:n}=e;return{id:String(t),...typeof n==`string`&&{name:n}}}return{id:String(e??``),...typeof e==`string`&&{name:e}}},Io=(e,{key:t,sender:n,text:r,status:i},a=Date.now())=>{let o=[],s;for(let c of[...e].reverse()){let e=c.time,l=s?.time!==void 0&&e!==void 0&&ke(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:Se(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:Fo(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},Lo=e=>zr.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:Ro(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},Vo=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,Y.useState)(!1),s=De(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,Y.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=K(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&Cn(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(dt(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:u,planned:d})=>{let{resources:f,views:p}=K(),m=xn(),g=m?.state.kind===`signed-in`?m.state.user.id:void 0,_=n===void 0?[]:[n],v=ce(f,p,e,_),y=Ho(e.name,{filter:t,orderBy:Cn(r),pageSize:o,labels:v},d?.messages),b=Uo(u,o,d?.calls),x=Wo(y);if(x===`error`)return(0,X.jsx)(B,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)});if(x===`loading`)return(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(H,{children:Q(`loadingMessages`)})});let S=tt(f,e,_,y.items,y.labels),C=ko({items:b.calls,more:b.hasNextPage},{items:Po(S,r),more:y.hasNextPage}),w=Io(C,{key:t=>String(dt(e,t)),sender:n,time:r,text:i,status:a}),T=a===void 0?void 0:p[e.name]?.fields[a],E=e.fields[i]!==void 0&&Be(e.fields[i],p[e.name]?.fields[i]),D=w.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===g);return(0,X.jsxs)(X.Fragment,{children:[Ko(y)&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(B,{title:Q(`couldNotLoad`),error:y.error,onRetry:qo(y)})}),u&&b.list.error&&(0,X.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,X.jsx)(B,{title:Q(`couldNotLoadCalls`),error:b.list.error,onRetry:qo(b.list)})}),(0,X.jsx)(l,{length:C.length,followKey:D?.key,working:c,empty:Go(b.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:y.hasNextPage||b.hasNextPage?()=>Jo([y,b.list]):void 0,loadingEarlier:y.isFetchingNextPage||b.isFetchingNextPage,children:w.map(e=>e.kind===`day`?(0,X.jsx)(ve,{label:e.label},e.key):e.kind===`call`?(0,X.jsx)(No,{call:e,statusHints:b.statusHints},e.key):(0,X.jsx)(Mt,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,X.jsx)(Ao,{value:e.status,hints:T}),children:E&&e.text!==``?(0,X.jsx)(h,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,X.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=z(e),{resources:g}=K(),[_]=lo(f===void 0?[]:[f],G()),[v,y]=Vt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let x=p&&g[p.resource];return(0,X.jsx)(`section`,{className:M(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,X.jsx)(C,{title:i,help:a,actions:n.actions,children:(0,X.jsx)(Xo,{children:(0,X.jsx)(Yo,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&x&&{model:x,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},Qo=({children:e,className:t})=>(0,X.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,X.jsx)(`div`,{className:M(`flex`,t),children:e}),es=({children:e,className:t})=>(0,X.jsx)(`div`,{className:M(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=z(e);return(0,X.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=z(e),r=Ue(I(G()),n),i=(0,Y.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,X.jsx)(Lt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:i,label:a=n,defaultValue:o}=z(e),{values:s,linkTo:c}=r(),l=s[n];return(0,X.jsxs)(`div`,{className:M(`flex flex-wrap items-center gap-2`,t),children:[(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:a}),i?(0,X.jsx)(u,{label:a,value:l??``,options:i.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:o!==void 0&&e===String(o)?void 0:e})}):(0,X.jsx)(`span`,{children:l})]})},is=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,Y.useState)(!1),c=De(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,Y.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),is({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},os=({node:e,at:t,children:n})=>{let r=z(e),i=K().resources[r.reference],a=gn(I(G())),o=sn(t);return i?(0,X.jsx)(ss,{model:i,...c(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,X.jsx)(dn,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=z(e),i=K().resources[r.reference],a=gn(I(G())),o=sn(t);return i?(0,X.jsx)(ss,{model:i,...Ft(r,i.primaryKey[0],a),more:!1,empty:r.empty,...o&&{planned:o},children:n}):null},ls=({model:e,at:t,recordKey:n,link:r=`edit`,children:i,className:a})=>{let{views:o}=K(),s=sn(t),c=Ct(e,{key:n,enabled:!s}),l=s?Xt(e,s):c;if(l.isPending)return(0,X.jsx)(W,{className:`h-4 w-24`});if(l.error)return(0,X.jsx)(B,{title:j(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,X.jsx)(Ut,{value:l.data,children:i}):Ot(e,o[e.name],l.data.record,n);return r===!1?(0,X.jsx)(`span`,{className:a,children:u}):(0,X.jsx)(me,{to:{kind:`record`,resource:e.name,key:n},className:a??`font-medium text-primary-text hover:underline`,children:u})},us=({node:e,at:t,children:n,className:r})=>{let{reference:i,source:a,link:o,empty:s}=z(e),c=K().resources[i],l=Ue(I(G()),a);return c?l==null||l===``?s===void 0?null:(0,X.jsx)(`span`,{className:r,children:s}):(0,X.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>Ae(e,t)).join(`, `),$=et(`users`),fs=({roles:e})=>{let{session:t}=q(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,Y.useEffect)(o,[o]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(mr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,X.jsx)(gr,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,X.jsx)(U,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,X.jsx)(hr,{email:n.email,gives:ds(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},ps=({roles:e,onCreated:t})=>{let{session:n}=q(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)([]),{busy:d,error:f,run:p}=D(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,X.jsxs)(U,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,X.jsx)(k,{message:f}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(S,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,X.jsx)(S,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,X.jsx)(S,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(gr,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,X.jsx)(`div`,{children:(0,X.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=q(),[i,a]=(0,Y.useState)(e),{busy:o,error:s,run:c,setError:l}=D(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,X.jsx)(_r,{name:i.name,email:i.email,self:n,error:s,actions:(0,X.jsxs)(X.Fragment,{children:[i.blocked&&(0,X.jsx)(P,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,X.jsx)(V,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,X.jsx)(V,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,X.jsx)(gr,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=q(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=yr(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,X.jsx)(vr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,X.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=q(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)();return(0,Y.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof J?A(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,Y.useState)(0);return(0,X.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,X.jsx)(k,{message:t}),(0,X.jsx)(hs,{roles:e,version:n}),(0,X.jsx)(fs,{roles:e}),(0,X.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[a,o]=(0,Y.useState)(e?.address??``),[s,c]=(0,Y.useState)(e?.name??``),[l,u]=(0,Y.useState)(e?.signature??``),[d,f]=(0,Y.useState)(e?.isDefault??!1);return(0,X.jsxs)(R,{title:e?e.address:F(`addFromAddress`),description:F(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:i,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:t,disabled:!a.trim(),onClick:()=>r({address:a.trim(),name:s.trim(),signature:l,isDefault:d}),children:F(e?`save`:`addAddress`)})]}),children:[!e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`fromAddress`),(0,X.jsx)(S,{autoFocus:!0,type:`email`,value:a,maxLength:254,placeholder:F(`fromAddressPlaceholder`),onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[F(`fromName`),(0,X.jsx)(S,{value:s,maxLength:100,placeholder:F(`fromNamePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:F(`defaultFromAddress`)}),(0,X.jsx)(ge,{checked:d,onChange:f,label:F(`defaultFromAddress`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[F(`signature`),(0,X.jsx)(Fe,{value:l,maxLength:2e3,placeholder:F(`signaturePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsx)(k,{message:n})]})},ys=e=>e.signature?F(`ownSignature`):F(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=t.find(e=>e.isDefault),p=()=>{u(void 0),c(void 0)},m=async e=>{if(!d.current){d.current=!0,o(!0),c(void 0);try{await e(),u(void 0)}catch(e){if(e instanceof TypeError)return c(F(`noAnswerFromServer`));if(!(e instanceof J))throw e;c(A(e))}finally{d.current=!1,o(!1)}}},h=e=>m(async()=>{let t=e.name||null,i=e.signature.trim()?e.signature:null;if(l?.kind===`change`)return r(l.sender.id,{name:t,signature:i,isDefault:e.isDefault});let a=await n({address:e.address,...t&&{name:t},...i&&{signature:i}});e.isDefault&&await r(a.id,{isDefault:!0})});return(0,X.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:F(`fromAddresses`)}),(0,X.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:F(`fromAddressesDescription`)}),(0,X.jsx)(k,{message:l?void 0:s}),(e||t.length>0)&&(0,X.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:F(`mailboxOwnAddress`)})]}),f?(0,X.jsx)(V,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void m(()=>r(f.id,{isDefault:!1})),children:F(`makeDefault`)}):(0,X.jsx)(P,{tone:`blue`,children:F(`default`)})]}),t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(wr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,X.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,X.jsx)(P,{tone:`blue`,children:F(`default`)}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`change`,sender:e}),children:F(`edit`)}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`remove`,sender:e}),children:F(`remove`)})]},e.id))]}),(0,X.jsxs)(V,{onClick:()=>u({kind:`add`}),children:[(0,X.jsx)(pn,{className:`size-3.5`}),F(`addFromAddress`)]}),l?.kind===`add`&&(0,X.jsx)(vs,{busy:a,error:s,onSave:e=>void h(e),onClose:p}),l?.kind===`change`&&(0,X.jsx)(vs,{sender:l.sender,busy:a,error:s,onSave:e=>void h(e),onClose:p},l.sender.id),l?.kind===`remove`&&(0,X.jsx)(R,{title:F(`removeFromAddress`,{address:l.sender.address}),description:F(`removeFromAddressDescription`),onClose:p,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:p,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.sender.id)),children:F(`remove`)})]}),children:(0,X.jsx)(k,{message:s})})]})},xs=(e,t,n)=>Object.fromEntries(Pn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Yn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=q(),{account:a}=t,[o]=(0,Y.useState)(Ge),s=(0,Y.useCallback)(async()=>{let[t,n,r]=await Promise.all([a.linkedPersonalMail(e),a.linkedProviders(),a.mailSenders()]);return{mail:t,providers:n,senders:r}},[a,e]),{data:c,error:l,reload:u}=N(s,F(`couldNotReadMethods`));return c?(0,X.jsx)(de,{title:F(`mailbox`),description:F(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:c.mail,notes:xs(e,c,e=>r.find(t=>t.id===e)?.name??pt(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:o&&i(o,e.length===1?e[0].name:F(`theProvider`)),children:(0,X.jsx)(bs,{senders:c.senders,onAdd:async e=>{let t=await a.addMailSender(e);return await u(),t},onUpdate:async(e,t)=>{await a.updateMailSender(e,t),await u()},onRemove:async e=>{await a.removeMailSender(e),await u()}})}):(0,X.jsx)(O,{error:l})},Cs=()=>{let{personalMail:e}=q();return e.length>0?(0,X.jsx)(Ss,{links:e}):null},ws=e=>br(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof J))throw e;a(A(e))}r(!1)};return(0,X.jsxs)(U,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,X.jsx)(k,{message:o?void 0:i}),e.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=xr(e.clientId);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,Zt(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,X.jsx)(R,{title:`Disconnect ${ws(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>s(void 0),children:`Cancel`}),(0,X.jsx)(V,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,X.jsx)(k,{message:i})})]})},Ds=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},Os=({url:e,appName:t})=>(0,X.jsx)(U,{title:F(`mcpAddress`),description:F(`mcpAddressDescription`),children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Sr,{value:e,copyLabel:F(`copyMcpAddress`)}),(0,X.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:tn(),children:[(0,X.jsx)(He,{className:`size-3.5`}),F(`addToClaude`)]})]})}),ks=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=N((0,Y.useCallback)(()=>e.connectedApps(),[e]),F(`couldNotReadMethods`));return t?(0,X.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,X.jsx)(O,{error:n})},As=({url:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Os,{url:e,appName:K().appName}),(0,X.jsx)(ks,{})]}),js=()=>{let{mcp:e}=q();return e?(0,X.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>Zt(Date.parse(e)),Fs=e=>e?F(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):F(`neverExpires`),Is=e=>[F(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?F(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):F(`notUsedYet`),e.organization?F(`actsAsIn`,{role:e.role,organization:e.organization}):F(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`90`),[p,m]=(0,Y.useState)(),h=()=>{c(void 0),o(void 0),m(void 0)},g=(0,Y.useRef)(!1),_=async e=>{if(!g.current){g.current=!0,i(!0),o(void 0);try{c(await e()),m(void 0)}catch(e){if(e instanceof TypeError)return o(F(`noAnswerFromServer`));if(!(e instanceof J))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):o(A(e))}finally{g.current=!1,i(!1)}}},v=()=>_(async()=>{let e=Ms[d];return{kind:`created`,created:await t({name:l.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,X.jsxs)(U,{title:F(`accessTokens`),description:F(`accessTokensDescription`),children:[(0,X.jsx)(k,{message:s?void 0:a}),e.length===0?(0,X.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:F(`noAccessTokens`)}):(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Or,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>c({kind:`revoke`,token:e}),children:F(`revoke`)})]},e.id))}),(0,X.jsxs)(V,{onClick:()=>{u(``),f(`90`),c({kind:`create`})},children:[(0,X.jsx)(pn,{className:`size-3.5`}),F(`newAccessToken`)]}),s?.kind===`create`&&(0,X.jsxs)(R,{title:F(`newAccessToken`),description:F(`newAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:h,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:r,disabled:!l.trim(),onClick:()=>void v(),children:F(`createAccessToken`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`name`),(0,X.jsx)(S,{autoFocus:!0,value:l,maxLength:100,placeholder:F(`accessTokenNamePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[F(`accessTokenExpiry`),(0,X.jsx)(Ke,{value:d,onChange:e=>f(e.target.value),children:Object.keys(Ms).map(e=>(0,X.jsx)(`option`,{value:e,children:F(Ns[e])},e))})]}),p===`asked`&&(0,X.jsx)(kt,{purpose:`change`,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:F(`confirmedCreateAccessToken`)}),(0,X.jsx)(k,{message:a})]}),s?.kind===`created`&&(0,X.jsx)(R,{title:F(`accessTokenCreated`,{name:s.created.personalAccessToken.name}),description:F(`accessTokenCreatedDescription`),onClose:h,actions:(0,X.jsx)(V,{variant:`primary`,onClick:h,children:F(`done`)}),children:(0,X.jsx)(Sr,{value:s.created.token,copyLabel:F(`copyAccessToken`)})}),s?.kind===`revoke`&&(0,X.jsx)(R,{title:F(`revokeAccessToken`,{name:s.token.name}),description:F(`revokeAccessTokenDescription`),onClose:h,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:h,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,loading:r,onClick:()=>void _(async()=>(await n(s.token.id),void 0)),children:F(`revoke`)})]}),children:(0,X.jsx)(k,{message:a})})]})},Rs=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=N((0,Y.useCallback)(()=>e.personalAccessTokens(),[e]),F(`couldNotReadAccessTokens`));return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{message:n}),(0,X.jsx)(Ls,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,X.jsx)(O,{error:n})},zs=()=>q().personalAccessTokens?(0,X.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(r),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=async(e,t)=>{a(e),s(void 0),d(void 0);try{await t(),l(void 0)}catch(e){if(!(e instanceof J))throw e;s(A(e))}finally{a(void 0)}};return(0,X.jsxs)(U,{title:F(`connections`),description:F(`connectionsDescription`),children:[(0,X.jsx)(k,{message:c?void 0:o}),(0,X.jsx)(nt,{message:u}),(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Mr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,X.jsx)(V,{size:`sm`,loading:i===e.key,disabled:i!==void 0,onClick:()=>void f(e.key,()=>t(e)),children:e.accounts.length>0?F(`connectAgain`,{name:e.label}):F(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[F(`connectedOn`,{date:Zt(Date.parse(t.created_at))}),` · `,(0,X.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,X.jsx)(P,{tone:`amber`,children:F(`connectionNeedsSignIn`)}):(0,X.jsx)(P,{tone:`green`,children:F(`connected`)}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>l({connection:e,accountId:t.id}),children:F(`disconnect`)})]}),t.used_by.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:F(`connectionUsedBy`)}),t.used_by.map(e=>(0,X.jsx)(ee,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),c&&(0,X.jsx)(R,{title:F(`disconnectTitle`,{name:c.connection.label}),description:Vs(c.connection)?`${F(`disconnectDescription`)} ${F(`disconnectWholeGrant`)}`:F(`disconnectDescription`),onClose:()=>l(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>l(void 0),children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,loading:i===c.accountId,onClick:()=>void f(c.accountId,async()=>d(F(Bs[await n(c.accountId)]))),children:F(`disconnect`)})]}),children:o&&(0,X.jsx)(k,{message:o})})]})},Us=()=>{let{session:e,connectAccount:t}=q(),{account:n}=e,[r]=(0,Y.useState)(Ge),{data:a,error:o,reload:s}=N((0,Y.useCallback)(()=>n.workflowConnections(),[n]),F(`couldNotReadMethods`));return a?a.length===0?null:(0,X.jsx)(Hs,{connections:a,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(s),error:r&&i(r,F(`theProvider`))}):(0,X.jsx)(O,{error:o})},Ws=e=>e.code===`LAST_ADMIN`?F(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?F(`deleteAccountLocked`):A(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(!1),d=(0,Y.useId)(),f=async()=>{o(!0),c(void 0),u(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof J))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?u(!0):c(Ws(e)),o(!1)}};return(0,X.jsxs)(R,{title:F(`deleteAccountQuestion`),description:F(`deleteAccountWarning`),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:n,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,type:`submit`,form:d,loading:a,disabled:e&&!r,children:F(`deleteAccountConfirm`)})]}),children:[(0,X.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`deleteAccountPassword`),(0,X.jsx)(S,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!s,onChange:e=>i(e.target.value)})]}),(0,X.jsx)(k,{message:s})]}),l&&(0,X.jsx)(kt,{purpose:`change`,minutes:15,onConfirmed:()=>void f()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(U,{title:F(`deleteAccount`),description:F(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,X.jsx)(V,{variant:`danger`,onClick:()=>i(!0),children:F(`deleteAccount`)}),r&&(0,X.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=q(),{account:r}=e,{data:i,error:a}=N((0,Y.useCallback)(()=>r.signInMethods(),[r]),F(`couldNotReadMethods`));return i?(0,X.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,X.jsx)(O,{error:a})},Js=[[/Edg(e|A|iOS)?\//,`Edge`],[/OPR\/|Opera/,`Opera`],[/SamsungBrowser\//,`Samsung Internet`],[/Firefox\/|FxiOS\//,`Firefox`],[/Chrome\/|CriOS\//,`Chrome`],[/Safari\//,`Safari`]],Ys=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/CrOS/,`ChromeOS`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/Linux/,`Linux`]],Xs=(e,t)=>e.find(([e])=>e.test(t))?.[1],Zs=e=>e?{browser:Xs(Js,e),system:Xs(Ys,e)}:{},Qs=e=>e.device?F(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?F(`staffOf`,{operator:t}):F(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?F(`browserOn`,{browser:n,system:r}):r?F(`aBrowserOn`,{system:r}):n??F(`unknownDevice`)},ec=e=>{if(e.staff)return Pr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Ir:t===`iPad`?Rr:Ar},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?F(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?F(`signOutDevice`,{name:Qs(e.link)}):F(`signOutOthersTitle`),rc=e=>F(e.kind===`one`?`signOutDeviceDescription`:e.kind===`link`?`signOutLinkedDeviceDescription`:`signOutOthersDescription`),ic=({sessions:e,operator:t,links:n=[],onSignOut:r,onSignOutOthers:i,onSignOutLink:a})=>{let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=e.filter(e=>!n.some(t=>t.sessions.includes(e.token))),p=e.filter(e=>!e.current),m=e=>e.kind===`one`?r(e.session.token):e.kind===`link`?a(e.link.id):i(),h=async e=>{s(!0),l(void 0);try{await m(e),d(void 0)}catch(e){if(!(e instanceof J))throw e;l(A(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,X.jsxs)(U,{title:F(`devices`),description:F(`devicesDescription`),children:[f.length===0&&n.length===0?(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:F(`noDevices`)}):(0,X.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(f).map(e=>{let n=ec(e);return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,X.jsx)(P,{tone:`green`,children:F(`thisDevice`)})]}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[F(`signedInFromUntil`,{from:se(Date.parse(e.createdAt)),until:se(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:F(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(Ir,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,X.jsx)(P,{tone:`green`,children:F(`thisDevice`)})]}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:F(`linkedOn`,{date:se(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:F(`signOut`)})]},t.id)})]}),p.length>0&&(0,X.jsx)(V,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:F(`signOutOthers`)}),u&&(0,X.jsx)(R,{title:nc(u,t),description:rc(u),onClose:()=>d(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>d(void 0),children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,loading:o,onClick:()=>void h(u),children:F(`signOut`)})]}),children:(0,X.jsx)(k,{message:c})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=q(),{account:r}=e,i=(0,Y.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=N(i,F(`couldNotReadDevices`));return a?(0,X.jsx)(ic,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,X.jsx)(O,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(),h=e===`required`&&t.length<=1,g=async e=>{o(!0),c(void 0),m(void 0);try{await e(),u(void 0)}catch(e){if(!(e instanceof J))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(`asked`):c(A(e))}o(!1)};return(0,X.jsxs)(U,{title:F(`passkeys`),status:e===`required`&&(0,X.jsx)(P,{tone:`blue`,children:F(`required`)}),description:F(oc[e]),children:[(0,X.jsx)(k,{message:l?void 0:s}),t.length>0&&(0,X.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,X.jsx)(ze,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??F(`passkey`)}),(0,X.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?F(`addedOn`,{date:Zt(Date.parse(e.createdAt))}):F(`addedEarlier`),` · `,e.backedUp?F(`synced`):F(`oneDevice`)]})]}),(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{f(e.name??``),u({kind:`rename`,passkey:e})},children:F(`rename`)}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,disabled:h,title:h?F(`keepLastPasskey`):void 0,onClick:()=>u({kind:`remove`,passkey:e}),children:F(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,X.jsxs)(V,{loading:a&&!l,onClick:()=>void g(n),children:[(0,X.jsx)(pn,{className:`size-3.5`}),F(`addPasskey`)]}),p===`asked`&&(0,X.jsx)(kt,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>m(`done`)}),p===`done`&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:F(`confirmedAddPasskey`)}),l?.kind===`rename`&&(0,X.jsxs)(R,{title:F(`renamePasskey`),description:F(`renamePasskeyDescription`),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>u(void 0),children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:a,disabled:!d.trim(),onClick:()=>void g(()=>r(l.passkey.id,d.trim())),children:F(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`name`),(0,X.jsx)(S,{autoFocus:!0,value:d,maxLength:60,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(k,{message:s})]}),l?.kind===`remove`&&(0,X.jsx)(R,{title:F(`removePasskey`),description:F(`removePasskeyDescription`,{name:l.passkey.name??F(`thisPasskey`)}),onClose:()=>u(void 0),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>u(void 0),children:F(`cancel`)}),(0,X.jsx)(V,{variant:`danger`,loading:a,onClick:()=>void g(()=>i(l.passkey.id)),children:F(`remove`)})]}),children:s&&(0,X.jsx)(k,{message:s})})]})},cc=()=>{let{account:e}=q().session,t=(0,Y.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=N(t,F(`couldNotReadMethods`));if(!n)return(0,X.jsx)(O,{error:r});let[a,o]=n;return(0,X.jsx)(sc,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?F(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?F(`passwordTooLong`):A(e),uc=(e,t)=>{if(e.length<12)return F(`useAtLeast`,{length:12});if(e!==t)return F(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),p=(0,Y.useId)(),m=(!e||r)&&a&&s,h=async()=>{let e=uc(a,s);if(f(e),!e){u(!0);try{await t({current:r,next:a})}catch(e){if(!(e instanceof J))throw e;f(lc(e)),u(!1)}}};return(0,X.jsx)(R,{title:F(e?`changePassword`:`setPassword`),description:F(`atLeast`,{length:12}),onClose:n,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:n,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,type:`submit`,form:p,loading:l,disabled:!m,children:F(`save`)})]}),children:(0,X.jsxs)(`form`,{id:p,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[e&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`currentPassword`),(0,X.jsx)(S,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`newPassword`),(0,X.jsx)(S,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:a,invalid:!!d,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`repeatPassword`),(0,X.jsx)(S,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:s,invalid:!!d,onChange:e=>c(e.target.value)})]}),e&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:F(`changeSignsOutOthers`)}),(0,X.jsx)(k,{message:d})]})})},fc=({rule:e,hasPassword:t,staff:n})=>F(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=!n&&e===`allowed`;return(0,X.jsxs)(U,{title:F(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,X.jsx)(nt,{message:s?F(`passwordSaved`):void 0}),l&&(0,X.jsx)(V,{onClick:()=>{c(!1),o(!0)},children:F(t?`changePassword`:`setPassword`)}),a&&(0,X.jsx)(dc,{hasPassword:t,onClose:()=>o(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):i(n)),o(!1),c(!0)}})]})},mc=()=>{let{session:e,state:t}=q(),{account:n}=e,{data:r,error:i,reload:a}=N((0,Y.useCallback)(()=>n.signInMethods(),[n]),F(`couldNotReadMethods`));return r?(0,X.jsx)(pc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,X.jsx)(O,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(),m=async e=>{d(!0),p(void 0);try{await e()}catch(e){if(!(e instanceof J))throw e;p(A(e))}d(!1)},h=i.trim(),g=()=>m(async()=>{await t.request(h),l(``),s(h)}),_=e=>m(async()=>{await t.confirm(o,e),n()});return o?(0,X.jsxs)(R,{title:F(`changeEmail`),description:F(`codeSentTo`,{email:o,minutes:10}),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{variant:`ghost`,onClick:()=>{s(void 0),p(void 0)},children:F(`otherAddress`)}),(0,X.jsx)(V,{variant:`primary`,loading:u,disabled:c.length<6,onClick:()=>void _(c),children:F(`changeEmail`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`code`),(0,X.jsx)(vt,{name:`code`,required:!0,autoFocus:!0,value:c,invalid:!!f,onChange:l,onComplete:e=>!u&&void _(e)})]}),(0,X.jsx)(k,{message:f})]}):(0,X.jsxs)(R,{title:F(`changeEmail`),description:F(`changeEmailDescription`),onClose:r,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:r,children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:u,disabled:!h||h.toLowerCase()===e.toLowerCase(),onClick:()=>void g(),children:F(`sendCode`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`newEmail`),(0,X.jsx)(S,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(k,{message:f})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=async()=>{f(!0),m(void 0);try{await n(l.trim()),o(!1)}catch(e){if(!(e instanceof J))throw e;m(A(e))}f(!1)};return(0,X.jsxs)(U,{title:F(`profile`),description:F(`profileDescription`),children:[(0,X.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:F(`name`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:F(`email`)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(V,{onClick:()=>{u(e),m(void 0),o(!0)},children:F(`changeName`)}),r&&(0,X.jsx)(V,{onClick:()=>c(!0),children:F(`changeEmail`)})]}),a&&(0,X.jsxs)(R,{title:F(`changeName`),description:F(`changeNameDescription`),onClose:()=>o(!1),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:()=>o(!1),children:F(`cancel`)}),(0,X.jsx)(V,{variant:`primary`,loading:d,disabled:!l.trim()||l.trim()===e,onClick:()=>void h(),children:F(`save`)})]}),children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`name`),(0,X.jsx)(S,{autoFocus:!0,value:l,maxLength:100,onChange:e=>u(e.target.value)})]}),(0,X.jsx)(k,{message:p})]}),s&&r&&(0,X.jsx)(hc,{email:t,change:r,onClose:()=>c(!1),onDone:()=>{c(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=q(),{data:n,loaded:r,error:i,reload:a}=N((0,Y.useCallback)(()=>e.session(),[e]),F(`couldNotReadProfile`));if(!r)return(0,X.jsx)(O,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,X.jsx)(gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},vc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(),[p,m]=(0,Y.useState)(!1),h=async()=>{u(!0),f(void 0),m(!1);try{await a(i?s:void 0)}catch(e){if(!(e instanceof J))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?m(!0):f(A(e)),u(!1)}};return(0,X.jsxs)(R,{title:e,description:t,onClose:o,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{onClick:o,children:F(`cancel`)}),(0,X.jsx)(V,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void h(),children:n})]}),children:[i&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[F(`yourPassword`),(0,X.jsx)(S,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:s,invalid:!!d,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s&&void h()})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d}),p&&(0,X.jsx)(kt,{purpose:`change`,minutes:15,onConfirmed:()=>void h()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,Y.useState)(),d=()=>u(void 0),f=n?(0,X.jsx)(P,{tone:`green`,children:F(`on`)}):t===`required`?(0,X.jsx)(P,{tone:`amber`,children:F(`required`)}):(0,X.jsx)(P,{children:F(`off`)}),p=F(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,X.jsx)(U,{title:F(`twoFactor`),status:f,description:p,children:(0,X.jsx)(`div`,{className:`max-w-sm`,children:(0,X.jsx)(cn,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,X.jsxs)(U,{title:F(`twoFactor`),status:f,description:p,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,X.jsx)(V,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:F(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,X.jsx)(V,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:F(`addAuthenticator`)}),n&&r&&(0,X.jsx)(V,{onClick:()=>u({kind:`new-codes`}),children:F(`newBackupCodes`)}),n&&(0,X.jsx)(V,{variant:`danger`,disabled:t===`required`,title:t===`required`?F(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:F(`turnOff`)})]}),l?.kind===`turn-off`&&(0,X.jsx)(vc,{title:F(`turnOffTitle`),description:F(`turnOffDescription`),confirmLabel:F(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,X.jsx)(vc,{title:F(`newCodesTitle`),description:F(`newCodesDescription`),confirmLabel:F(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,X.jsx)(R,{title:F(`yourNewCodes`),description:F(`keepCodesSafe`),onClose:d,actions:(0,X.jsx)(V,{variant:`primary`,onClick:d,children:F(`savedCodes`)}),children:(0,X.jsx)(Ht,{codes:l.codes})})]})},xc=()=>{let{account:e}=q().session,{data:t,error:n,reload:r}=N((0,Y.useCallback)(()=>e.signInMethods(),[e]),F(`couldNotReadMethods`));return t?(0,X.jsx)(bc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,X.jsx)(O,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,X.jsx)(Xe,{children:e}):(0,X.jsxs)(X.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,X.jsx)(te,{name:e,fallback:n===void 0?void 0:(0,X.jsx)(Sc,{problem:j.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,X.jsx)(Sc,{problem:j.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ri,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:si,RecordRow:ro,RecordCards:$a,Chart:ci,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ni,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:ne,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:ai,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:y(t,...n,r)}})),Dc=({text:e})=>{let t=G(),n=Me(),r={...I(t),params:n};return(0,X.jsx)(X.Fragment,{children:Te(e,e=>qe(Ue(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,X.jsx)(Dc,{text:e},t):(0,X.jsx)(Y.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,X.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Hr(n.child)&&e&&Hr(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Hr(n.child)?(0,X.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,X.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>re(e)||Array.isArray(e)&&e.length>0&&e.every(re),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,X.jsx)(X.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:y(t,`props`,n)}}],Pc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fc=(e,t)=>{let n=Pc(e.props.components)?e.props.components:{},r=Object.fromEntries(Object.entries(n).flatMap(([e,t])=>re(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=Ve(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||re(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=s(),r=G(),i=Me(),a=jt(),o=(0,Y.useMemo)(()=>ct(g(e,{...I(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,X.jsx)(X.Fragment,{children:kc(Fc(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,X.jsx)(Ji,{node:o,children:Ac(Ec(o.children,t,`children`))}):void 0;return(0,X.jsx)(Cc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,X.jsx)(X.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:e&&(0,X.jsx)($e,{node:o,...t!==void 0&&{at:t},children:(0,X.jsx)(e,{...v(o.props),children:r})})})}let c=wc[o.type];if(!c)return(0,X.jsx)(Xe,{children:j.rich(`unknownBlock`,{type:o.type})});let l=typeof o.props.className==`string`?o.props.className:void 0,u=Ec(o.children,t,`children`),d=(0,X.jsx)(c,{node:o,at:t,slots:Mc(o,t),className:l,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?kc(u):Ac(o.type===`Switch`?u.filter(({child:e})=>typeof e!=`string`):u)}),f=l===void 0||Tc.has(o.type)?d:(0,X.jsx)(`div`,{className:l,children:d});return o.fallback?(0,X.jsx)(te,{name:o.type,resetKey:o,fallback:(0,X.jsx)(X.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:f}):f};export{bo as a,Ha as c,Yo as i,za as l,Cc as n,co as o,Xo as r,Za as s,Ic as t,Qi as u};
3
- //# debugId=691e8fb0-ade3-460a-829c-de4d14a46bcc
@@ -1,2 +0,0 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Aa as r,Bc as i,Fc as a,Gl as o,Gs as s,Jc as c,Jn as l,Kr as u,Na as d,Qr as f,Rr as p,Ul as m,Wa as h,Ws as g,Yc as _,Yn as v,ba as y,cs as b,dl as x,gi as S,ic as C,il as w,mr as T,oc as E,on as D,rc as O,sl as k,ts as A,vn as j,ya as M}from"./app-D6luJ1k4.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-B_e_Quer.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as ee,r as B,s as V,t as H}from"./messages-BHPGrBhJ.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=i(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=i(G),q=e(t(),1),J=_(`app/delete`),Y=m(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:s}=e;if(!t[a])return;let c=n[a]?.names?.plural??k(a),l=X({blockingPlural:c,noun:r});if(!s||i===void 0)return{text:l};let u={kind:`list`,resource:a,filter:o(Y.eq(s,i))};return{text:l,link:{label:J(`show`,{plural:c}),to:u}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(C,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(E,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,Q.jsx)(C,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(E,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(C,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(E,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(C,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(E,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(C,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(E,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??k(e.name),before:S(e,n[e.name],i),after:S(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=b(),o=N(),c=d(),[l,u]=(0,q.useState)(),[f,m]=(0,q.useState)(!1),h=t?.names?.singular??k(e.name),_=t?.names?.plural??k(e.name),{resources:v,views:y}=A(),{href:x,open:S}=p(),C=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:v,views:y,noun:h,...e.primaryKey.length===1&&{key:n.key}}),w=()=>{for(let t of[`page`,`list`,`first-page`,`map`])o.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])o.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await a.get(e.name,t.key)).etag;try{await a.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof g))throw e;return e}},E=t=>{w(),u(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&i&&{action:{label:J(`undo`),onClick:()=>{i(t).then(()=>{w(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!s(e))throw e;w(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},D=async(n,r)=>{m(!0);try{if(!await T(n,r))return E(n);let i=(await a.get(e.name,n.key)).record;u({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!s(e))throw e;u(void 0);let t=C(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:x(t.link.to),onNavigate:S}}})}finally{m(!1)}},O=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!s(t))throw t;return{title:e.title,message:C(t,e)?.text??t.message}}},j=async e=>{let t=[],n=[],r=0;u({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await O(a);i&&(t.push(i),n.push(a)),r+=1,u({kind:`bulk-running`,done:r,total:e.length})}})),w(),u({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>u(void 0);return{dialogs:l&&(0,Q.jsxs)(Q.Fragment,{children:[l.kind===`confirm`&&(0,Q.jsx)(te,{title:l.target.title,noun:h,busy:f,onCancel:M,onConfirm:()=>void D(l.target,l.target.etag)}),l.kind===`conflict`&&(0,Q.jsx)(ne,{title:l.target.title,changes:l.changes,busy:f,onCancel:M,onReview:()=>{M(),r?.(l.target,l.fresh)},onDeleteAnyway:()=>void D(l.target,`*`)}),l.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:l.targets.length,noun:h,plural:_,onCancel:()=>{M(),l.settle(l.targets)},onConfirm:()=>l.settle(j(l.targets))}),l.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:l.done,total:l.total}),l.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:l.total,failures:l.failures,onClose:M})]}),start:t=>e.softDelete?D(t,t.etag):u({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>u({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=b();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>x(y(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return H(`dependsOn`,{record:n,other:o.title});let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?H(`dependsOn`,{record:s.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let o=b(),s=d(),f=j(),{resources:p,views:m}=A(),h=`${n} asc`,g=P({queryKey:[...c.list(e.name,r,h,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=l(p,m,e,i),n=[],a=``;do{let s=await o.search(e.name,{filter:r||void 0,orderBy:h,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(...v(p,e,i,s.items,s.labels).map((t,n)=>({...t,id:M(e,s.items[n])}))),a=s.nextPageToken}while(a);return n}}),[_,y]=(0,q.useState)(),x=(0,q.useRef)(void 0),S=(0,q.useRef)([]),C=(0,q.useRef)(void 0),T=(0,q.useRef)(Promise.resolve()),E=(0,q.useRef)(0),D=(0,q.useRef)(void 0),O=async()=>{let t=x.current,r=S.current;if(S.current=[],!t||r.length===0)return;let i=await o.batchWrite(r),a=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[M(e,t.record),t])),c=z(i.results,t=>M(e,t)),l=L(e,[...a].map(([e,t])=>({...t,before:{[n]:c.get(e)}})),[n]);D.current!==void 0&&s.dismiss(D.current),D.current=s.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(l)}}),x.current&&=x.current.map(e=>{let t=a.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},k=(e,t)=>n=>{x.current=void 0,S.current=[],y(void 0),s.show(ee(n,e,{place:`list`,title:t?C.current:void 0}))},N=async()=>{--E.current,!(E.current>0)&&(await f(e.name),!(E.current>0)&&(x.current=void 0,y(void 0)))},F=(n,r)=>{let i=x.current??g.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,a);let s=u(e,i[n]).record,c=i[n].id;R(o,e,t,s).then(n=>{let i=x.current??g.data,o=ce(e,n,w(e,t,s,c));H(i,i.findIndex(e=>e.id===c),r,e=>o(e)??a?.(e))},k(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let c=s?U(i,a,o,s):o;a!==c&&(x.current=I(i,a,c),S.current=[...S.current,B(e,n,r,x.current,c)],y(x.current),E.current+=1,C.current=w(e,t,u(e,i[a]).record,i[a].id),T.current=T.current.then(O).catch(k(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>u(e,t).record),n,r,i);return a.reason!==void 0&&s.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{D.current!==void 0&&s.dismiss(D.current),D.current=void 0,E.current+=1,T.current=T.current.then(async()=>{await o.batchWrite(e),x.current=void 0,S.current=[],y(void 0)}).catch(k(V(`couldNotUndo`),!1)).then(N)};return{rows:_??g.data,loading:g.isPending,error:g.error,move:F}},de=({model:e,view:t,field:n,filter:i,columns:a,sort:o})=>{let{resources:s,views:c}=A(),{fields:l,dropRules:u}=r(),{go:d,href:m}=p(),g=o!==void 0,_=(0,q.useMemo)(()=>D(e,t,a,{resources:s,views:c,fieldTypes:l}).map(e=>g?e:{...e,sortable:!1}),[e,t,a.join(`,`),s,c,l,g]),v=(0,q.useMemo)(()=>f(e,t,_.map(e=>e.id)),[e,t,_]),b=t?.list?.drag?.rule,x=b===void 0?void 0:u?.[b],S=ue({model:e,view:t,field:n,filter:i,fields:v,...x&&{rule:x}}),C=S.rows,E=(0,q.useMemo)(()=>C&&{total:C.length,rowAt:e=>C[e]},[C]);if(b!==void 0&&!x)return(0,Q.jsx)(h,{children:V.rich(`noRule`,{rule:b})});if(S.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(O,{className:`h-4 w-full`},t))});if(S.error)return(0,Q.jsx)(T,{title:V(`couldNotLoad`),error:S.error});if(!E||E.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let k=t=>d({kind:`record`,resource:e.name,key:y(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:_,source:E,latencyMs:0,onOpenRow:k,rowLink:t=>({href:m({kind:`record`,resource:e.name,key:y(e,t)}),onFollow:()=>k(t)}),...o&&{sort:o.value,onSortChange:o.onChange},rowNumbers:!1,reorder:{label:n=>w(e,t,n,n.id),onMove:S.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(E,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(a,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
2
- //# debugId=813a6ce6-860a-454b-9d6d-16b2ffa912eb
@@ -1 +0,0 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{$ as e,Ao as t,Ar as n,At as r,B as ee,Ba as te,Bi as i,Bt as a,Cn as o,Ct as s,Dt as c,Eo as l,Et as u,Fr as d,Ft as f,G as p,Gc as m,Gi as h,Gt as g,H as _,Hc as v,Hi as y,Ht as b,Ir as x,Jt as S,K as C,Kc as w,La as T,Lo as E,Lr as D,Ma as O,Mt as k,N as A,Nt as j,Oa as M,Oo as N,Ot as P,P as F,Pr as I,Pt as L,Q as R,Qt as z,R as B,Ri as V,Rn as H,Rr as U,Rt as W,Sr as G,St as K,Tr as q,Tt as J,U as Y,Uc as X,Ui as Z,V as Q,Vi as ne,Vt as re,W as ie,Wc as ae,Wi as oe,X as se,Xc as ce,Yt as le,Zt as ue,_o as $,_r as de,_t as fe,ao as pe,br as me,bt as he,cc as ge,cs as _e,do as ve,dt as ye,et as be,fo as xe,ft as Se,gr as Ce,gt as we,ho as Te,hr as Ee,ht as De,ic as Oe,it as ke,jo as Ae,jr as je,jt as Me,ka as Ne,ko as Pe,kr as Fe,ls as Ie,mo as Le,mt as Re,n as ze,nt as Be,oc as Ve,oo as He,or as Ue,os as We,ot as Ge,pt as Ke,qc as qe,qt as Je,r as Ye,rt as Xe,sc as Ze,so as Qe,ss as $e,t as et,tc as tt,tt as nt,ua as rt,ut as it,vt as at,wr as ot,wt as st,xr as ct,xt as lt,yo as ut,yr as dt,yt as ft,z as pt,za as mt,zi as ht,zt as gt}from"./app-D6luJ1k4.js";import{h as _t,o as vt}from"./vendor-t7Q7QbPu.js";export{K as ActionCard,G as ActionInputError,$e as ApiProvider,d as App,D as AppLink,t as AppMark,Se as AssistantDock,Qe as AuthLayout,Le as AvailabilityMark,Ve as Button,W as CallMark,b as CallView,C as Carousel,k as ChatDivider,Me as ChatMessage,r as ChatThread,pt as Choices,pe as CodeForm,he as CompactTable,st as Composer,Oe as Dialog,fe as DiffView,B as Field,le as FieldBadge,lt as FieldList,Ce as FileReadError,e as FocusActions,be as FocusNotice,ke as FocusPage,nt as FocusPanel,Be as FocusSlot,A as Form,me as HtmlFrame,ze as InPlaceForm,l as Input,Ae as LogoMark,o as Markdown,u as MentionBox,J as MentionedText,ee as MenuSelect,$ as MenuSurface,ve as OtpInput,Re as PartView,a as RecordCall,g as RecordLink,et as RecordPicker,He as ResendCodeButton,y as ResponsiveDialog,tt as RouteLink,se as SearchPicker,F as Section,ut as Segmented,Q as Select,s as SidePanel,f as SignInPrompt,ge as Spinner,Te as StatusMark,De as StepList,H as Textarea,S as ToneEdge,_ as allowDelayMs,Ze as buttonClass,j as chatDayLabel,E as closeSidebarEvent,M as definePlugin,Ne as defineUi,at as diffStats,c as emptyDraft,ct as fileNamed,ot as isConflict,Y as isFramed,Pe as logoTapEvent,P as mentionedIds,ae as mergeUi,ft as parseDiff,we as parsePatch,w as pluginApi,v as pluginsChangedEvent,qe as protobaseVersion,L as sameChatDay,ce as showTextsIn,dt as siblingPage,xe as signedOutEvent,ht as statusRefreshMs,m as uiFromModule,x as uiReadyEvent,te as useApiToken,U as useAppAddress,ie as useArmedAfterFocus,ye as useAssistant,it as useAssistantClient,Ke as useBackendData,_e as useClient,ue as useComponentReads,z as useComponentSelect,Ye as useCreateForm,Fe as useFacets,N as useFieldControl,de as useFileText,Ge as useFocusPage,R as useFocusRecord,Xe as useFocusZoneFilled,p as useGuardedPress,n as useHistogram,Z as useInbox,Ue as useLayoutRecord,I as useList,Je as useListDisplay,oe as useMarkNotificationsRead,V as useMembers,We as useMeta,i as useOwnStatus,X as usePlugin,O as usePresence,rt as usePushNotifications,vt as useQuery,_t as useQueryClient,T as useRecord,re as useRecordCallAddress,gt as useRecordCalls,Ie as useResourceClient,je as useSeries,Ee as useSiblingPage,mt as useSignedInUser,ne as useStatuses,h as useUnreadNotifications,q as useUpdateRecord};
@@ -1,2 +0,0 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ji as r,Jo as i,Qc as a,Qo as o,Vc as s,Xo as c,_s as l,cc as u,oc as d,qo as f,vs as p,xs as m}from"./app-D6luJ1k4.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:l(`on`)},{value:`forbidden`,label:l(`off`)}],v=()=>[{value:`allowed`,label:l(`optional`)},{value:`required`,label:l(`required`)},{value:`forbidden`,label:l(`off`)}],y=()=>[{method:`password`,label:l(`password`),description:l(`passwordDescription`),rules:_()},{method:`emailCode`,label:l(`emailedSignInCode`),description:l(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:l(`passkeys`),description:l(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:l(`twoFactor`),description:l(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:l(`staffAccess`),description:l(`staffAccessDescription`),rules:[{value:`allowed`,label:l(`on`)},{value:`notify`,label:l(`emailThePerson`)},{value:`forbidden`,label:l(`off`)}]},{method:`platformSignIn`,label:l(`platformSignIn`),description:l(`platformSignInDescription`),rules:_()}],b=(e,t)=>{let n=y().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},x=e(n(),1),S=({row:e,value:t,onChange:n})=>(0,x.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:s(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),C=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return l(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return l(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return l(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return l(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return l(`appliesAs`,{rule:b(e,r[e])})},w=({operator:e,platformProviders:t=[]})=>y().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t.length>0?[{...n,label:l(`platformSignInWith`,{provider:new Intl.ListFormat(a(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:i,notice:a})=>{let[o,s]=(0,g.useState)(e.policy),c=w(e),u=c.some(({method:t})=>o[t]!==e.policy[t]);return(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(o)},children:[(0,x.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:c.map(t=>{let n=C(t,o,e);return(0,x.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,x.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,x.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,x.jsx)(S,{row:t,value:o[t.method],onChange:e=>s({...o,[t.method]:e})})]},t.method)})}),i&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:i}),a&&!u&&(0,x.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:a}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?l(`lastSavedBy`,{name:e.savedBy,time:r(Date.parse(e.savedAt))}):l(`lastSaved`,{time:r(Date.parse(e.savedAt))}):l(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[u&&(0,x.jsx)(d,{onClick:()=>s(e.policy),children:l(`reset`)}),(0,x.jsx)(d,{variant:`primary`,type:`submit`,loading:n,disabled:!u,children:l(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(c,{tone:`neutral`,children:l(`stopped`,{time:r(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(c,{tone:`neutral`,children:l(`ended`,{time:r(Date.parse(e.expiresAt))})}):(0,x.jsx)(c,{tone:`amber`,children:l(`signedInUntil`,{time:r(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:a=Date.now()})=>(0,x.jsxs)(f,{title:l(`staffSignIns`),description:l(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(i,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:l(`noStaffSignIns`)}),e&&e.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:l(`as`)}),(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,x.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:r(Date.parse(e.startedAt))}),E(e,a)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=p(),[n,r]=(0,g.useState)(),[i,a]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof m?o(e):l(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:i})},k=()=>{let{session:e}=p(),[t,n]=(0,g.useState)(),[r,i]=(0,g.useState)(!1),[a,s]=(0,g.useState)(),[c,d]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>s(e instanceof m?o(e):l(`couldNotReadPolicy`)))},[e]);let f=async t=>{i(!0),s(void 0),d(void 0);try{n(await e.signInPolicy.save(t)),d(l(`policySaved`))}catch(e){if(!(e instanceof m))throw e;s(o(e))}i(!1)};return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(h,{title:l(`signInPolicy`),subtitle:l(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:r,error:a,notice:c,onSave:e=>void f(e)},t.savedAt??`default`),t.operator&&(0,x.jsx)(O,{operator:t.operator})]}):a?(0,x.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(u,{}),` `,l(`loading`)]})]})};export{k as SignInPolicyPage};
2
- //# debugId=50f1c93b-02b4-48fc-a7c6-645b7e9acdca
@@ -1,2 +0,0 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t}from"./react-CuiNlnus.js";import{Aa as n,Cs as r,Er as i,Es as a,Jn as o,Nr as s,Os as c,Qn as l,an as u,ar as d,cs as f,dn as p,er as m,fn as h,ga as g,in as _,rn as v,sr as y,ts as b,un as x,zo as S,zs as C}from"./app-D6luJ1k4.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-B_e_Quer.js";import{n as O}from"./record-preview-J1o4Sqs-.js";var k=e(t(),1),A=e=>({queryKey:e.queryKey,start:t=>t.prefetchQuery(e)}),j=e=>({queryKey:e.queryKey,start:t=>t.prefetchInfiniteQuery(e)}),M={Table:(e,t,n)=>{let{resource:r,filter:i=``,sort:a=``,columns:o,button:s,bulk:l=!1,limit:d=10,select:f}=_(e),m=r===void 0?void 0:n.resources[r];if(!m)return[];if(t.part===`chosen`){let e=f===void 0?void 0:n.given[f];return e?[A(p(n.client,m,{key:e}))]:[]}let h=n.views[m.name],{fields:y,read:b}=u({...n,model:m,view:h,columns:o?.map(c),button:s,bulk:l,phoneColumns:v(o)});return[A(D(n,{model:m,filter:i,orderBy:a||g(m,h),limit:d,fields:y,read:b}))]},Chart:(e,t,{client:n,resources:r,views:a})=>{let{resource:o,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=_(e),h=r[o],g=h&&E({model:h,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},r,a);return h&&g?[A(i(n,h.name,g))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=_(e),l=r[a];if(!l)return[];let u=s||g(l,i[l.name]);return[A(h(n,l,{filter:o,sort:u,pageSize:c})),A(x(n,l,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=_(e),l=i[o];if(!l)return[];let u=a[l.name];return u?.searchesOf||u?.listOf!==void 0?[]:[A(O({queryClient:r,client:n,resources:i,views:a,model:l,...T(l,u,{filter:s,sort:c})}))]},Thread:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:c,sender:l,time:u,calls:d,limit:f=50}=_(e);if(t.part===`calls`){let e=d&&r[d.resource];return e?[j(s(n,e.name,{filter:d.filter,orderBy:C(d.time),pageSize:f}))]:[]}let p=r[a];if(!p)return[];let m=o(r,i,p,l===void 0?[]:[l]);return[j(s(n,p.name,{filter:c,orderBy:C(u),pageSize:f,labels:m}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(x(n,i))]:[]},P=(e,t,n)=>(n?.reads??[]).flatMap(n=>{let i=a(t,n.block);if(!i||i.custom)return[];if(n.part===`condition`)return N(i,n,e);if(n.split)return[];let o=M[i.type];return o?o(r(i,{stack:[],params:e.params,...e.root&&{root:e.root}}),n,e):[]}),F=({tree:e,plan:t})=>{let r=f(),i=w(),{resources:a,views:o}=b(),s=n().fields,c=S(),u=l(),p=m(),h=d(y()),g=(0,k.useMemo)(()=>P({client:r,queryClient:i,resources:a,views:o,fieldTypes:s,xs:c,params:u,given:p,...h&&{root:h}},e,t),[r,i,a,o,s,c,u,p,h,e,t]);return(0,k.useEffect)(()=>{for(let e of g)e.start(i)},[g,i]),null};export{F as t};
2
- //# debugId=38bafba9-63d1-451c-ae89-b68a7a0a5f3b