@protobase/ui 0.121.0 → 0.121.2

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 (299) hide show
  1. package/dist/account/blocks/personal-mail-block.js +4 -0
  2. package/dist/account/messages.d.ts +2 -2
  3. package/dist/activity-chart/messages.d.ts +2 -2
  4. package/dist/app/change-confirm/messages.d.ts +2 -2
  5. package/dist/app/charts/messages.d.ts +2 -2
  6. package/dist/app/comments/messages.d.ts +2 -2
  7. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  8. package/dist/app/conversation/messages.d.ts +2 -2
  9. package/dist/app/conversation-page/messages.d.ts +2 -2
  10. package/dist/app/create/messages.d.ts +2 -2
  11. package/dist/app/delete/messages.d.ts +2 -2
  12. package/dist/app/displays/messages.d.ts +2 -2
  13. package/dist/app/embedded-list/messages.d.ts +2 -2
  14. package/dist/app/export/builder.js +2 -1
  15. package/dist/app/export/messages.d.ts +2 -2
  16. package/dist/app/field-editor.js +8 -1
  17. package/dist/app/field-errors.js +2 -1
  18. package/dist/app/field-messages.d.ts +2 -2
  19. package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
  20. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  21. package/dist/app/field-types/workflow/cache-field.js +1 -1
  22. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  23. package/dist/app/field-types/workflow/flow-elements.js +2 -2
  24. package/dist/app/field-types/workflow/flow-nodes.js +2 -2
  25. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  26. package/dist/app/field-types/workflow/node-panel.js +2 -2
  27. package/dist/app/field-types/workflow/pins/data-edits.js +1 -1
  28. package/dist/app/field-types/workflow/pins/pin-text.js +1 -1
  29. package/dist/app/field-types/workflow/task-fields.js +2 -2
  30. package/dist/app/field-types/workflow/trigger-fields.js +1 -1
  31. package/dist/app/field-types/workflow/workflow-canvas.js +3 -3
  32. package/dist/app/field-types/workflow/workflow-field.js +1 -1
  33. package/dist/app/field-types/workflow/workflow-graph-editor.js +3 -3
  34. package/dist/app/field-types/workflow-page/insert-value-view.js +3 -3
  35. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  36. package/dist/app/field-types/workflow-page/publish-panel.js +2 -2
  37. package/dist/app/field-types/workflow-page/rerun-panel.js +1 -1
  38. package/dist/app/field-types/workflow-page/run-notice.js +1 -1
  39. package/dist/app/field-types/workflow-page/runs-panel.js +1 -1
  40. package/dist/app/field-types/workflow-page/test-run-panel.js +2 -2
  41. package/dist/app/field-types/workflow-page/use-workflow-page.js +2 -2
  42. package/dist/app/field-types/workflow-page/workbench-bar.js +2 -2
  43. package/dist/app/field-types/workflow-page/workflow-workbench.js +12 -12
  44. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  45. package/dist/app/field-types/workflow-run/run-trace-view.js +4 -4
  46. package/dist/app/field-types/workflow-run/step-card.js +1 -1
  47. package/dist/app/field-types/workflow-run/step-panel.js +1 -1
  48. package/dist/app/focus/messages.d.ts +2 -2
  49. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  50. package/dist/app/gallery/messages.d.ts +2 -2
  51. package/dist/app/hand-order/messages.d.ts +2 -2
  52. package/dist/app/history/messages.d.ts +2 -2
  53. package/dist/app/import/messages.d.ts +2 -2
  54. package/dist/app/list-messages.d.ts +2 -2
  55. package/dist/app/messages.d.ts +2 -2
  56. package/dist/app/meta-gate-messages.d.ts +2 -2
  57. package/dist/app/new-version/messages.d.ts +2 -2
  58. package/dist/app/pages/field-value.d.ts +1 -1
  59. package/dist/app/pages/field-value.js +3 -1
  60. package/dist/app/pages/messages.d.ts +2 -2
  61. package/dist/app/record-chart/messages.d.ts +2 -2
  62. package/dist/app/record-messages.d.ts +2 -2
  63. package/dist/app/record-row/messages.d.ts +2 -2
  64. package/dist/app/related-cards/messages.d.ts +2 -2
  65. package/dist/app/runtime/messages.d.ts +2 -2
  66. package/dist/app/saved/messages.d.ts +2 -2
  67. package/dist/app/searches/messages.d.ts +2 -2
  68. package/dist/app-shell/messages.d.ts +2 -2
  69. package/dist/assistant-dock/messages.d.ts +2 -2
  70. package/dist/auth/messages.d.ts +2 -2
  71. package/dist/calls/messages.d.ts +2 -2
  72. package/dist/chat/messages.d.ts +2 -2
  73. package/dist/data-grid/column-spec.d.ts +1 -1
  74. package/dist/data-grid/messages.d.ts +2 -2
  75. package/dist/filter-panel/messages.d.ts +2 -2
  76. package/dist/format/messages.d.ts +2 -2
  77. package/dist/forms/messages.d.ts +2 -2
  78. package/dist/index.js +1 -1
  79. package/dist/inline-child-table/messages.d.ts +2 -2
  80. package/dist/invitations/messages.d.ts +2 -2
  81. package/dist/live/field-values.js +2 -1
  82. package/dist/live/messages.d.ts +2 -2
  83. package/dist/locale/en.js +9 -1
  84. package/dist/locale/en.json.d.ts +8 -0
  85. package/dist/locale/messages.d.ts +16 -0
  86. package/dist/locale/nl.js +9 -1
  87. package/dist/mailbox/mail-sender-select.d.ts +23 -0
  88. package/dist/mailbox/mail-sender-select.js +81 -0
  89. package/dist/mailbox/mailbox-connect.js +1 -1
  90. package/dist/mailbox/messages.d.ts +2 -2
  91. package/dist/mailbox/sender-options-read.d.ts +14 -0
  92. package/dist/mailbox/sender-options-read.js +31 -0
  93. package/dist/mailbox/sender-options.d.ts +17 -0
  94. package/dist/mailbox/sender-options.js +17 -0
  95. package/dist/mailbox/use-sender-options.d.ts +14 -0
  96. package/dist/mailbox/use-sender-options.js +57 -0
  97. package/dist/mocks/customers.d.ts +1 -1
  98. package/dist/mocks/invoices.d.ts +2 -2
  99. package/dist/mocks/orders.d.ts +3 -3
  100. package/dist/notifications/bell/messages.d.ts +2 -2
  101. package/dist/organizations/messages.d.ts +2 -2
  102. package/dist/package.js +1 -1
  103. package/dist/plugins/messages.d.ts +2 -2
  104. package/dist/primitives/messages.d.ts +2 -2
  105. package/dist/shell/assets/{account-page-DIIa49Sf.js → account-page-BEMlob92.js} +2 -2
  106. package/dist/shell/assets/app-CwxoFZn2.js +34 -0
  107. package/dist/shell/assets/{assistant-shell-CLGyb2ss.js → assistant-shell-D1PLZHeQ.js} +2 -2
  108. package/dist/shell/assets/board-display-BZb6Av24.js +2 -0
  109. package/dist/shell/assets/calendar-display-CNFg47Me.js +2 -0
  110. package/dist/shell/assets/{call-rings-AviIOqM7.js → call-rings-B0cAdcLq.js} +2 -2
  111. package/dist/shell/assets/{calls-C2CUgWkn.js → calls-CJX48uHr.js} +2 -2
  112. package/dist/shell/assets/{circle-alert-DOaXkZQv.js → circle-alert-B-bmotNV.js} +2 -2
  113. package/dist/shell/assets/composed-page-itsBuYQN.js +2 -0
  114. package/dist/shell/assets/{composer-section-BLqTkqi8.js → composer-section-CcOJo5ti.js} +2 -2
  115. package/dist/shell/assets/{connect-route-41MPQMtp.js → connect-route-CFKOOd6G.js} +2 -2
  116. package/dist/shell/assets/{copy-field-Ct-6xn8T.js → copy-field-DOFRIY_Q.js} +2 -2
  117. package/dist/shell/assets/create-route-Dv-SPGqY.js +2 -0
  118. package/dist/shell/assets/{custom-step-container-field-C0uZrHjV.js → custom-step-container-field-Cpk6ImRJ.js} +4 -4
  119. package/dist/shell/assets/embedded-list-DoHDT3Av.js +3 -0
  120. package/dist/shell/assets/en-C_BQKBSV.js +2 -0
  121. package/dist/shell/assets/{export-dialog-BerhgfFO.js → export-dialog-Ivzdiuhz.js} +2 -2
  122. package/dist/shell/assets/export-worker-C46NatsO.js +15 -0
  123. package/dist/shell/assets/{first-organization-page-CKYevHep.js → first-organization-page-in6WzIgy.js} +2 -2
  124. package/dist/shell/assets/{graph-view-CoLu3Uhs.js → graph-view-BRuO-SOE.js} +2 -2
  125. package/dist/shell/assets/{group-donut-B8v2SWzP.js → group-donut-3NIqjraT.js} +2 -2
  126. package/dist/shell/assets/{guest-call-page-DqQMPCVU.js → guest-call-page-NZyVZiKI.js} +3 -3
  127. package/dist/shell/assets/{html-viewer-BntGWVRA.js → html-viewer-C1KycBYl.js} +2 -2
  128. package/dist/shell/assets/{import-dialog-DThTUXFS.js → import-dialog-CyB3vJn7.js} +2 -2
  129. package/dist/shell/assets/{import-table-dialog-C-XIx1Dd.js → import-table-dialog-D8yGy95h.js} +2 -2
  130. package/dist/shell/assets/{index-CI7L8s0t.js → index-CkkBg7C6.js} +1 -1
  131. package/dist/shell/assets/{invitations-page-COFjv2AV.js → invitations-page-BjEW7hIz.js} +2 -2
  132. package/dist/shell/assets/{layout-grid-CvCNKDtn.js → layout-grid-OO8eIGYq.js} +2 -2
  133. package/dist/shell/assets/{legend-item-9nkaAII6.js → legend-item-eNQOaTxV.js} +2 -2
  134. package/dist/shell/assets/{lib-zod-B92j-KH2.js → lib-zod-CxxP7Qhu.js} +2 -2
  135. package/dist/shell/assets/list-page-bIQkpGOc.js +4 -0
  136. package/dist/shell/assets/{maplibre-5GcVztUc.js → maplibre-DV3j-5Y6.js} +2 -2
  137. package/dist/shell/assets/{markdown-content-DVmg_kx3.js → markdown-content-C08v-1FZ.js} +2 -2
  138. package/dist/shell/assets/members-page-B9hyyuVp.js +2 -0
  139. package/dist/shell/assets/{message-content-BpfTrsWh.js → message-content-DLKHIzRa.js} +3 -3
  140. package/dist/shell/assets/messages-NBuAsjFr.js +2 -0
  141. package/dist/shell/assets/nl-DzJ_yv1H.js +2 -0
  142. package/dist/shell/assets/organization-page-DeTS9uAn.js +2 -0
  143. package/dist/shell/assets/organizations-page-qM5TQfyb.js +2 -0
  144. package/dist/shell/assets/parse-worker-COWuolaE.js +35 -0
  145. package/dist/shell/assets/{pending-invitation-row-t63yAwI8.js → pending-invitation-row-9-2Fmy3F.js} +2 -2
  146. package/dist/shell/assets/{period-chart-BVv9kC_E.js → period-chart-UOm7kPWB.js} +2 -2
  147. package/dist/shell/assets/{person-row-CgvcHRmL.js → person-row-DOXM02rY.js} +2 -2
  148. package/dist/shell/assets/public-form-page-Bj9YxgGp.js +2 -0
  149. package/dist/shell/assets/{record-lines-Dts68Cfq.js → record-lines-PZ4g8sb5.js} +2 -2
  150. package/dist/shell/assets/{record-map-BO9rZaxg.js → record-map-CkWjStZn.js} +2 -2
  151. package/dist/shell/assets/{record-opens-Ds9nDyw1.js → record-opens-6vtBiJ2O.js} +2 -2
  152. package/dist/shell/assets/record-page-DrQL98n9.js +3 -0
  153. package/dist/shell/assets/{record-preview-CwySCCRj.js → record-preview-BSqik7HQ.js} +2 -2
  154. package/dist/shell/assets/{records-map-Bq_dBgiT.js → records-map-CXBbBlYG.js} +2 -2
  155. package/dist/shell/assets/render-node-DEyR63E8.js +3 -0
  156. package/dist/shell/assets/reorder-button-CdgrzXlf.js +2 -0
  157. package/dist/shell/assets/{run-trace-view-BtyPPUyt.js → run-trace-view-CqcgX5lE.js} +2 -2
  158. package/dist/shell/assets/{runner-install-field-DvuPCX28.js → runner-install-field-Dm7GhYaF.js} +2 -2
  159. package/dist/shell/assets/{runtime-update-e56Spv--.js → runtime-update-BdhyiFl9.js} +2 -2
  160. package/dist/shell/assets/shared-protobase-ui-CDtJQrEp.js +1 -0
  161. package/dist/shell/assets/{sheet-source-Cenf8A74.js → sheet-source-NKu1Enl2.js} +3 -3
  162. package/dist/shell/assets/sign-in-policy-page-DINzAtyt.js +2 -0
  163. package/dist/shell/assets/start-block-queries-Bc743CdL.js +2 -0
  164. package/dist/shell/assets/step-catalog-B9QbvZP_.js +2 -0
  165. package/dist/shell/assets/{step-panel-DD821ue5.js → step-panel-C5Pnb-Vb.js} +2 -2
  166. package/dist/shell/assets/timeline-display-hbo62z0J.js +2 -0
  167. package/dist/shell/assets/{trash-Ch2JFURM.js → trash-YqRXn8JG.js} +2 -2
  168. package/dist/shell/assets/{update-set-Zch9kB-u.js → update-set-DFWECx_E.js} +2 -2
  169. package/dist/shell/assets/use-calendar-move-D_6TlMr4.js +2 -0
  170. package/dist/shell/assets/{use-display-rows-s-zuk4Lc.js → use-display-rows-1Xjy5pR2.js} +2 -2
  171. package/dist/shell/assets/use-my-invitations-CrSF37dB.js +2 -0
  172. package/dist/shell/assets/{use-paged-search-CxaSlMkh.js → use-paged-search-CtD7Lf-E.js} +2 -2
  173. package/dist/shell/assets/{use-run-trace-CRG2_uVq.js → use-run-trace-5H4UJvB-.js} +2 -2
  174. package/dist/shell/assets/{use-workflow-page-BPZWN9Iv.js → use-workflow-page-dAWuZvWk.js} +2 -2
  175. package/dist/shell/assets/{use-workflow-types-Dk4FOVoz.js → use-workflow-types-Cjkw47Mf.js} +2 -2
  176. package/dist/shell/assets/{workflow-canvas-DBlvFI_n.js → workflow-canvas-BkFimRd2.js} +4 -4
  177. package/dist/shell/assets/{workflow-field-DXiYYH5X.js → workflow-field-BQImywHx.js} +3 -3
  178. package/dist/shell/assets/{workflow-graph-editor-BtNoPI_a.js → workflow-graph-editor-DYBqdH_O.js} +2 -2
  179. package/dist/shell/assets/{workflow-run-field-CztPPLbi.js → workflow-run-field-CyxK0W7w.js} +3 -3
  180. package/dist/shell/assets/workflow-status-field-Bzri4NHN.js +2 -0
  181. package/dist/shell/assets/workflow-workbench-DC2gtXz1.js +4 -0
  182. package/dist/shell/index.html +3 -3
  183. package/dist/shell/protobase.shell.json +2 -2
  184. package/dist/shell/protobase.sw.js +2 -2
  185. package/dist/shell-source-maps/assets/{account-page-DIIa49Sf.js.map → account-page-BEMlob92.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/app-CwxoFZn2.js.map +1 -0
  187. package/dist/shell-source-maps/assets/{assistant-shell-CLGyb2ss.js.map → assistant-shell-D1PLZHeQ.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{board-display-DJJD_jjY.js.map → board-display-BZb6Av24.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{calendar-display-7R7Vz5Vm.js.map → calendar-display-CNFg47Me.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/{call-rings-AviIOqM7.js.map → call-rings-B0cAdcLq.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{calls-C2CUgWkn.js.map → calls-CJX48uHr.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{circle-alert-DOaXkZQv.js.map → circle-alert-B-bmotNV.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{composed-page-DjGZy9C7.js.map → composed-page-itsBuYQN.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{composer-section-BLqTkqi8.js.map → composer-section-CcOJo5ti.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{connect-route-41MPQMtp.js.map → connect-route-CFKOOd6G.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{copy-field-Ct-6xn8T.js.map → copy-field-DOFRIY_Q.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{create-route-CRZSYoTi.js.map → create-route-Dv-SPGqY.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{custom-step-container-field-C0uZrHjV.js.map → custom-step-container-field-Cpk6ImRJ.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/embedded-list-DoHDT3Av.js.map +1 -0
  200. package/dist/shell-source-maps/assets/en-C_BQKBSV.js.map +1 -0
  201. package/dist/shell-source-maps/assets/{export-dialog-BerhgfFO.js.map → export-dialog-Ivzdiuhz.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/export-worker-C46NatsO.js.map +1 -0
  203. package/dist/shell-source-maps/assets/{first-organization-page-CKYevHep.js.map → first-organization-page-in6WzIgy.js.map} +1 -1
  204. package/dist/shell-source-maps/assets/{graph-view-CoLu3Uhs.js.map → graph-view-BRuO-SOE.js.map} +1 -1
  205. package/dist/shell-source-maps/assets/{group-donut-B8v2SWzP.js.map → group-donut-3NIqjraT.js.map} +1 -1
  206. package/dist/shell-source-maps/assets/{guest-call-page-DqQMPCVU.js.map → guest-call-page-NZyVZiKI.js.map} +1 -1
  207. package/dist/shell-source-maps/assets/{html-viewer-BntGWVRA.js.map → html-viewer-C1KycBYl.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/{import-dialog-DThTUXFS.js.map → import-dialog-CyB3vJn7.js.map} +1 -1
  209. package/dist/shell-source-maps/assets/{import-table-dialog-C-XIx1Dd.js.map → import-table-dialog-D8yGy95h.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/{invitations-page-COFjv2AV.js.map → invitations-page-BjEW7hIz.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{layout-grid-CvCNKDtn.js.map → layout-grid-OO8eIGYq.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{legend-item-9nkaAII6.js.map → legend-item-eNQOaTxV.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/lib-zod-CxxP7Qhu.js.map +1 -0
  214. package/dist/shell-source-maps/assets/{list-page-D3nIEwGf.js.map → list-page-bIQkpGOc.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{maplibre-5GcVztUc.js.map → maplibre-DV3j-5Y6.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{markdown-content-DVmg_kx3.js.map → markdown-content-C08v-1FZ.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{members-page-DoRl-b9K.js.map → members-page-B9hyyuVp.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{message-content-BpfTrsWh.js.map → message-content-DLKHIzRa.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{messages-CZQvPUZQ.js.map → messages-NBuAsjFr.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/nl-DzJ_yv1H.js.map +1 -0
  221. package/dist/shell-source-maps/assets/{organization-page-DeaQlPop.js.map → organization-page-DeTS9uAn.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/{organizations-page-Dlosll2b.js.map → organizations-page-qM5TQfyb.js.map} +1 -1
  223. package/dist/shell-source-maps/assets/parse-worker-COWuolaE.js.map +1 -0
  224. package/dist/shell-source-maps/assets/{pending-invitation-row-t63yAwI8.js.map → pending-invitation-row-9-2Fmy3F.js.map} +1 -1
  225. package/dist/shell-source-maps/assets/{period-chart-BVv9kC_E.js.map → period-chart-UOm7kPWB.js.map} +1 -1
  226. package/dist/shell-source-maps/assets/{person-row-CgvcHRmL.js.map → person-row-DOXM02rY.js.map} +1 -1
  227. package/dist/shell-source-maps/assets/{public-form-page-CruNnqqc.js.map → public-form-page-Bj9YxgGp.js.map} +1 -1
  228. package/dist/shell-source-maps/assets/{record-lines-Dts68Cfq.js.map → record-lines-PZ4g8sb5.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/{record-map-BO9rZaxg.js.map → record-map-CkWjStZn.js.map} +1 -1
  230. package/dist/shell-source-maps/assets/{record-opens-Ds9nDyw1.js.map → record-opens-6vtBiJ2O.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{record-page-DJgscks5.js.map → record-page-DrQL98n9.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{record-preview-CwySCCRj.js.map → record-preview-BSqik7HQ.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/{records-map-Bq_dBgiT.js.map → records-map-CXBbBlYG.js.map} +1 -1
  234. package/dist/shell-source-maps/assets/render-node-DEyR63E8.js.map +1 -0
  235. package/dist/shell-source-maps/assets/{reorder-button-BGgoLDx3.js.map → reorder-button-CdgrzXlf.js.map} +1 -1
  236. package/dist/shell-source-maps/assets/{run-trace-view-BtyPPUyt.js.map → run-trace-view-CqcgX5lE.js.map} +1 -1
  237. package/dist/shell-source-maps/assets/{runner-install-field-DvuPCX28.js.map → runner-install-field-Dm7GhYaF.js.map} +1 -1
  238. package/dist/shell-source-maps/assets/{runtime-update-e56Spv--.js.map → runtime-update-BdhyiFl9.js.map} +1 -1
  239. package/dist/shell-source-maps/assets/{sheet-source-Cenf8A74.js.map → sheet-source-NKu1Enl2.js.map} +1 -1
  240. package/dist/shell-source-maps/assets/{sign-in-policy-page-CUiU8ZIN.js.map → sign-in-policy-page-DINzAtyt.js.map} +1 -1
  241. package/dist/shell-source-maps/assets/{start-block-queries-DUvYFyeX.js.map → start-block-queries-Bc743CdL.js.map} +1 -1
  242. package/dist/shell-source-maps/assets/{step-catalog-CKmRa3SA.js.map → step-catalog-B9QbvZP_.js.map} +1 -1
  243. package/dist/shell-source-maps/assets/{step-panel-DD821ue5.js.map → step-panel-C5Pnb-Vb.js.map} +1 -1
  244. package/dist/shell-source-maps/assets/{timeline-display-ChPHZfO_.js.map → timeline-display-hbo62z0J.js.map} +1 -1
  245. package/dist/shell-source-maps/assets/{trash-Ch2JFURM.js.map → trash-YqRXn8JG.js.map} +1 -1
  246. package/dist/shell-source-maps/assets/{update-set-Zch9kB-u.js.map → update-set-DFWECx_E.js.map} +1 -1
  247. package/dist/shell-source-maps/assets/{use-calendar-move-Cl14_xWL.js.map → use-calendar-move-D_6TlMr4.js.map} +1 -1
  248. package/dist/shell-source-maps/assets/{use-display-rows-s-zuk4Lc.js.map → use-display-rows-1Xjy5pR2.js.map} +1 -1
  249. package/dist/shell-source-maps/assets/{use-my-invitations-APXH_Xf1.js.map → use-my-invitations-CrSF37dB.js.map} +1 -1
  250. package/dist/shell-source-maps/assets/{use-paged-search-CxaSlMkh.js.map → use-paged-search-CtD7Lf-E.js.map} +1 -1
  251. package/dist/shell-source-maps/assets/{use-run-trace-CRG2_uVq.js.map → use-run-trace-5H4UJvB-.js.map} +1 -1
  252. package/dist/shell-source-maps/assets/{use-workflow-page-BPZWN9Iv.js.map → use-workflow-page-dAWuZvWk.js.map} +1 -1
  253. package/dist/shell-source-maps/assets/{use-workflow-types-Dk4FOVoz.js.map → use-workflow-types-Cjkw47Mf.js.map} +1 -1
  254. package/dist/shell-source-maps/assets/{workflow-canvas-DBlvFI_n.js.map → workflow-canvas-BkFimRd2.js.map} +1 -1
  255. package/dist/shell-source-maps/assets/{workflow-field-DXiYYH5X.js.map → workflow-field-BQImywHx.js.map} +1 -1
  256. package/dist/shell-source-maps/assets/{workflow-graph-editor-BtNoPI_a.js.map → workflow-graph-editor-DYBqdH_O.js.map} +1 -1
  257. package/dist/shell-source-maps/assets/{workflow-run-field-CztPPLbi.js.map → workflow-run-field-CyxK0W7w.js.map} +1 -1
  258. package/dist/shell-source-maps/assets/workflow-status-field-Bzri4NHN.js.map +1 -0
  259. package/dist/shell-source-maps/assets/{workflow-workbench-CAz04v9t.js.map → workflow-workbench-DC2gtXz1.js.map} +1 -1
  260. package/dist/status/messages.d.ts +2 -2
  261. package/dist/users/messages.d.ts +2 -2
  262. package/package.json +5 -5
  263. package/dist/shell/assets/app-B8KcM2Z-.js +0 -34
  264. package/dist/shell/assets/board-display-DJJD_jjY.js +0 -2
  265. package/dist/shell/assets/calendar-display-7R7Vz5Vm.js +0 -2
  266. package/dist/shell/assets/composed-page-DjGZy9C7.js +0 -2
  267. package/dist/shell/assets/create-route-CRZSYoTi.js +0 -2
  268. package/dist/shell/assets/embedded-list-C3nd1V5o.js +0 -3
  269. package/dist/shell/assets/en-BHrKuf4K.js +0 -2
  270. package/dist/shell/assets/export-worker-CNhkzttC.js +0 -15
  271. package/dist/shell/assets/list-page-D3nIEwGf.js +0 -4
  272. package/dist/shell/assets/members-page-DoRl-b9K.js +0 -2
  273. package/dist/shell/assets/messages-CZQvPUZQ.js +0 -2
  274. package/dist/shell/assets/nl-D11b5T7-.js +0 -2
  275. package/dist/shell/assets/organization-page-DeaQlPop.js +0 -2
  276. package/dist/shell/assets/organizations-page-Dlosll2b.js +0 -2
  277. package/dist/shell/assets/parse-worker-CAcPVcu7.js +0 -35
  278. package/dist/shell/assets/public-form-page-CruNnqqc.js +0 -2
  279. package/dist/shell/assets/record-page-DJgscks5.js +0 -3
  280. package/dist/shell/assets/render-node-zjMYynnA.js +0 -3
  281. package/dist/shell/assets/reorder-button-BGgoLDx3.js +0 -2
  282. package/dist/shell/assets/shared-protobase-ui-QP42FY24.js +0 -1
  283. package/dist/shell/assets/sign-in-policy-page-CUiU8ZIN.js +0 -2
  284. package/dist/shell/assets/start-block-queries-DUvYFyeX.js +0 -2
  285. package/dist/shell/assets/step-catalog-CKmRa3SA.js +0 -2
  286. package/dist/shell/assets/timeline-display-ChPHZfO_.js +0 -2
  287. package/dist/shell/assets/use-calendar-move-Cl14_xWL.js +0 -2
  288. package/dist/shell/assets/use-my-invitations-APXH_Xf1.js +0 -2
  289. package/dist/shell/assets/workflow-status-field-K3DE4tPj.js +0 -2
  290. package/dist/shell/assets/workflow-workbench-CAz04v9t.js +0 -4
  291. package/dist/shell-source-maps/assets/app-B8KcM2Z-.js.map +0 -1
  292. package/dist/shell-source-maps/assets/embedded-list-C3nd1V5o.js.map +0 -1
  293. package/dist/shell-source-maps/assets/en-BHrKuf4K.js.map +0 -1
  294. package/dist/shell-source-maps/assets/export-worker-CNhkzttC.js.map +0 -1
  295. package/dist/shell-source-maps/assets/lib-zod-B92j-KH2.js.map +0 -1
  296. package/dist/shell-source-maps/assets/nl-D11b5T7-.js.map +0 -1
  297. package/dist/shell-source-maps/assets/parse-worker-CAcPVcu7.js.map +0 -1
  298. package/dist/shell-source-maps/assets/render-node-zjMYynnA.js.map +0 -1
  299. package/dist/shell-source-maps/assets/workflow-status-field-K3DE4tPj.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{$c as r,R as i,Ys as a,_ as o,a as s,b as c,c as l,do as u,el as d,fc as f,fl as p,fs as m,gr as h,i as g,is as _,o as v,po as y,ss as b,u as x,uc as S,v as C,y as w}from"./app-B8KcM2Z-.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=d(`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=m(),n=T({queryKey:r.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)(f,{}),` `,k(`loading`)]}):n.error?a(n.error)&&n.error.status===404?(0,j.jsx)(_,{title:k(`notFound`),children:k(`noForm`)}):(0,j.jsx)(_,{title:b(`cannotReach`),children:a(n.error)?n.error.message:b(`noAnswer`)}):(0,j.jsx)(N,{form:n.data})},N=({form:e})=>{let t=m(),{resource:n,view:r}=e,a=e.title??r.names?.singular??p(r.resource);y(a);let[d,f]=(0,O.useState)(()=>v(n,[{title:a,fields:e.fields}])),[_,b]=(0,O.useState)({}),[T,E]=(0,O.useState)(),[D,M]=(0,O.useState)(!1),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(0),L=o(F);if(N)return(0,j.jsx)(u,{title:a,size:`md`,children:(0,j.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:e.thanks})});let R=(e,t)=>{b(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))),f(n=>({...n,[e]:t}))},z=async()=>{M(!0),E(void 0);try{await t.submitForm(e.name,g(n,{},d),await A(t,e.name)),P(!0)}catch(e){let t=C(e);b(t),Object.keys(t).length>0?I(e=>e+1):E(e)}finally{M(!1)}};return(0,j.jsx)(u,{title:a,size:`md`,children:(0,j.jsxs)(`form`,{ref:L,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),z()},children:[e.fields.map(e=>{let t=n.fields[e],a=r.fields[e],o=a?.label??p(e),u=_[e];return(0,j.jsx)(i,{name:e,label:o,help:a?.help,required:l(t),error:u&&w(t,o,u),children:(0,j.jsx)(c,{field:t,hints:a,value:d[e]??(t.type!==`boolean`&&``),stored:void 0,placeholder:s(t)?k(`setByDatabase`):x(t),invalid:!!u,onChange:t=>R(e,t)})},e)}),T!==void 0&&(0,j.jsx)(h,{title:k(`notSent`),error:T}),(0,j.jsx)(S,{variant:`primary`,type:`submit`,loading:D,className:`min-h-10`,children:k(`send`)})]})})};export{M as PublicFormPage};
2
- //# debugId=abb8d9ea-a9c8-4e52-8ba0-bcd96f80f9dc
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/record-map-BO9rZaxg.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/maplibre-5GcVztUc.js","assets/app-B8KcM2Z-.js","assets/vendor-t7Q7QbPu.js","assets/app-DLkpxjgP.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-Dts68Cfq.js","assets/embedded-list-C3nd1V5o.js","assets/update-set-Zch9kB-u.js","assets/layout-grid-CvCNKDtn.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-CwySCCRj.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-BLqTkqi8.js","assets/render-node-zjMYynnA.js","assets/circle-alert-DOaXkZQv.js","assets/page-header-Ddz2r5ic.js","assets/pending-invitation-row-t63yAwI8.js","assets/person-row-CgvcHRmL.js","assets/use-paged-search-CxaSlMkh.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-Ct-6xn8T.js"])))=>i.map(i=>d[i]);
2
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,r as n,t as r}from"./react-CuiNlnus.js";import{$ as i,$c as a,$s as o,Ai as s,An as c,Ar as l,At as u,Ba as d,Bi as f,Bo as p,Br as m,C as h,Ca as g,Ci as _,Cn as v,Co as y,Cs as b,D as x,Da as S,Dr as ee,Dt as C,E as te,Ea as ne,En as re,Er as w,Et as T,Fa as ie,Ft as E,Gc as D,Hi as O,Hn as ae,Ho as k,I as A,Ia as oe,Ic as se,Ii as ce,Io as le,Ir as ue,It as de,Ka as fe,La as pe,Lc as me,Li as he,Lo as ge,Mn as _e,Mt as ve,Ni as ye,Nn as be,Nt as xe,O as Se,Oa as Ce,P as j,Pa as we,Pl as Te,Pn as Ee,Pt as M,Qi as De,Ql as N,R as Oe,Ri as ke,Ro as P,Sc as Ae,Sn as F,So as I,Ss as je,Ti as Me,Tl as Ne,Tt as Pe,Uo as Fe,Us as Ie,Va as Le,Vi as Re,Wc as ze,Wn as Be,Xl as L,Xn as Ve,Ys as He,Z as Ue,Zn as We,_ as Ge,_i as Ke,_o as qe,ac as Je,ar as Ye,as as R,b as Xe,ba as Ze,bi as Qe,ct as z,d as $e,da as et,dc as tt,di as nt,el as B,es as rt,et as it,f as at,fl as V,fn as ot,fs as H,g as U,gl as st,gn as ct,gr as W,h as lt,hr as ut,ia as dt,ic as ft,ir as pt,is as mt,it as ht,iu as gt,k as _t,ki as vt,kn as yt,kr as bt,l as xt,lc as St,m as Ct,mc as wt,nn as Tt,nt as Et,nu as Dt,oc as Ot,os as kt,ot as At,p as jt,pi as Mt,rl as Nt,rt as Pt,s as Ft,sc as G,sl as It,st as Lt,tc as Rt,uc as K,v as zt,vi as Bt,w as Vt,wa as Ht,wi as Ut,wo as Wt,x as Gt,xn as Kt,y as qt,yi as Jt,yn as Yt,yo as Xt,ys as Zt,zc as Qt,zo as $t,zr as q,zt as en}from"./app-B8KcM2Z-.js";import{C as tn,h as nn,i as rn,o as an,r as on,s as sn}from"./vendor-t7Q7QbPu.js";import{Ct as cn,Dt as ln,Et as un,Mt as dn,Tt as fn,_ as pn,a as mn,c as hn,lt as gn,n as _n,ot as vn,pt as yn,rt as bn,s as xn,t as Sn,tt as Cn,yt as wn}from"./embedded-list-C3nd1V5o.js";import{a as Tn,i as En,n as Dn,r as On,t as kn}from"./reorder-button-BGgoLDx3.js";import{a as An,c as jn,d as Mn,f as Nn,i as Pn,l as Fn,m as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un}from"./render-node-zjMYynnA.js";import{t as Wn}from"./trash-Ch2JFURM.js";import{n as Gn,t as Kn}from"./record-sidebar-HqyBXBwn.js";import{t as qn}from"./start-block-queries-DUvYFyeX.js";import{t as Jn}from"./record-opens-Ds9nDyw1.js";import{u as Yn}from"./messages-CZQvPUZQ.js";var Xn={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`}]]};Xn.node;var Zn=ze(Xn),Qn={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`}]]};Qn.node;var $n=ze(Qn),er={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`}]]};er.node;var tr=ze(er),nr={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`}]]};nr.node;var rr=ze(nr),ir={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`}]]};ir.node;var ar=ze(ir),J=e(r(),1),or=({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:[z(`lastEditedBy`),` `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r.name}),` `,r.ago]}):(0,J.jsx)(J.Fragment,{children:z(`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)($t,{people:i,size:`md`}),z(`viewing`,{count:i.length})]}),a]})]}),Y=e(t(),1),sr=`text-base font-semibold text-foreground`,cr=({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:D(`py-8`,r&&`pb-0`),children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-2`,children:[i?(0,J.jsxs)(q,{to:i,replace:!0,"aria-expanded":r,"aria-controls":o,className:D(`inline-flex items-center gap-1.5`,sr),children:[(0,J.jsx)(se,{className:D(`size-4 transition-transform`,r&&`rotate-90`)}),e]}):(0,J.jsx)(`span`,{className:sr,children:e}),n]}),t&&(0,J.jsx)(`p`,{className:D(`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)(A.Provider,{value:2,children:a})})]})},lr=({tabs:e})=>(0,J.jsx)(`nav`,{"aria-label":z(`tabs`),className:`overflow-x-auto py-6`,children:(0,J.jsx)(`span`,{className:Wt.group(`md`),children:e.map(e=>(0,J.jsx)(q,{to:e.to,replace:!0,"aria-current":e.current?`page`:void 0,className:D(Wt.option(e.current,`md`),`whitespace-nowrap`),children:e.title},e.title))})}),ur=({rows:e})=>(0,J.jsx)(`dl`,{className:`border-t border-border`,children:e.map(e=>(0,J.jsxs)(`div`,{className:D(`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))}),dr=({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))}),fr=`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`,pr=({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:z(`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:D(`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:D(`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:fr,children:c}):(0,J.jsx)(`button`,{type:`button`,onClick:r,disabled:!!i||a,title:i,className:fr,children:c})},e)})})]}),mr=e(n(),1),hr=1e3,gr=(e,t,n,r,i)=>{let a=ue(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}},_r=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),vr=(e,t)=>e.sidebar?e.title?(0,J.jsx)(Gn,{title:e.title,children:t}):t:e.title?(0,J.jsx)(j,{title:e.title,children:t}):(0,J.jsx)(`section`,{className:`py-8`,children:t}),yr=({item:e,scope:t,fallback:n})=>{let{components:r}=we(),i=r?.[e.component],a=i&&(0,J.jsx)(pt,{value:t,children:(0,J.jsx)(i,{...Te(e.props??{})})});return n===void 0?vr(e,(0,J.jsx)(Ln,{name:e.component,registered:!!i,fallback:void 0,children:a})):(0,J.jsx)(Ln,{name:e.component,registered:!!i,fallback:n,children:vr(e,a)})},br=({component:e,scope:t,standard:n})=>{let{components:r}=we(),i=r?.[e];return i?(0,J.jsx)(fe,{name:e,fallback:n,children:(0,J.jsx)(xr,{children:(0,J.jsx)(pt,{value:t,children:(0,J.jsx)(i,{})})})}):n},xr=({children:e})=>(p(!1),(0,J.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]`,children:e})),Sr=({value:e,fallback:t})=>{let n=b(),r=n?.state.kind===`signed-in`?n.state.user.id:void 0,{member:i}=O(),a=oe(),o=Re(e,r);return o.length===0||!o.every(e=>i(e))?t:o.map((e,t)=>(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[i(e).name,(0,J.jsx)(Xt,{status:i(e).status,presence:ie(a,e),textShown:o.length===1?`full`:`hover`}),t<o.length-1&&`,`]},e))},X=B(`app/conversation`),Cr=({page:e,scope:t,title:n})=>{let r=e.subtitle===void 0?void 0:t.record[e.subtitle],i=e.members!==void 0;return(0,J.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background px-4`,children:[(0,J.jsx)(`h1`,{className:D(i?`flex`:`hidden md:flex`,`min-w-0 items-center gap-2 truncate font-medium`),children:i?(0,J.jsx)(Sr,{value:t.record[e.members],fallback:n}):n}),typeof r==`string`&&r!==``&&(0,J.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-muted-foreground`,children:r}),(0,J.jsx)(q,{to:{kind:`record`,resource:t.model.name,key:t.key,standard:!0},className:D(tt({variant:`ghost`,size:`sm`}),`ml-auto shrink-0`),children:X(`details`)})]})},wr=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Tr=({page:e,row:t,author:n,time:r,continued:i,member:a})=>{let o=t[e.text]==null?``:String(t[e.text]),s=e.mentions===void 0?[]:wr(t[e.mentions]).map(e=>({name:a(e)?.name})),c=e.edited===void 0?void 0:t[e.edited],l=typeof c==`string`&&(0,J.jsx)(`span`,{title:X(`editedAt`,{time:De(Date.parse(c))}),children:X(`edited`)});return(0,J.jsx)(xe,{author:{id:n.id,name:a(n.id)?.name??n.name},time:r,continued:i,footer:l,children:(0,J.jsx)(Pe,{text:o,mentions:s})})},Er=L(),Dr=(e,t)=>N(Er.eq(e,t)),Or=L(),kr=(e,t)=>({filter:Dr(e.field,t),orderBy:Ie(e.time),pageSize:50}),Ar=(e,t,n,r)=>N(Or.and(Or.eq(e.field,t),Or.eq(n,r))),jr=(e,t)=>typeof e[t]==`string`?e[t]:void 0,Mr=(e,{key:t,sender:n,time:r},i,a=Date.now())=>e.flatMap((o,s)=>{let c=e[s-1],l=jr(o,r),u=c&&jr(c,r),d=l!==void 0&&(u===void 0||!de(u,l)),f=t(o)===i,p=l!==void 0&&u!==void 0&&Date.parse(l)-Date.parse(u)<3e5,m=jn(o[n]),h=!d&&!f&&p&&jn(c[n]).id===m.id;return[...d?[{kind:`day`,key:`day:${t(o)}`,label:E(l,a)}]:[],...f?[{kind:`new`,key:`new:${t(o)}`}]:[],{kind:`message`,key:t(o),row:o,author:m,time:l,continued:h}]}),Nr=(e,{key:t,sender:n},r,i,a)=>{let o=e.findIndex(e=>Number(t(e))>r&&jn(e[n]).id!==i);if(o!==-1&&!(o===0&&a))return t(e[o])},Pr=(e,t)=>{let[n,r]=(0,Y.useState)();if(!n&&e){let e={above:t()};return r(e),e.above}return n?.above},Fr=({page:e,model:t,recordKey:n,me:r,position:i})=>{let{resources:a,views:o}=R(),{member:s}=O(),c=[e.sender],l=ue(t.name,{...kr(e,n),labels:Ve(a,o,t,c)}),u=We(a,t,c,l.items,l.labels).reverse(),d=e=>String(Ht(t,e)),f=Vn(l),p=f===`messages`&&!l.isLoading&&i.ready,m=Pr(p&&u.length>0&&i.openedAt!==void 0&&r!==void 0,()=>Nr(u,{key:d,sender:e.sender},i.openedAt,r,l.hasNextPage));if(f===`error`)return(0,J.jsx)(`div`,{className:`flex-1 p-4`,children:(0,J.jsx)(W,{title:X(`couldNotLoad`),error:l.error,onRetry:An(l)})});if(!p)return(0,J.jsx)(`div`,{className:`flex-1 p-4`,children:(0,J.jsx)(ut,{children:X(`loadingMessages`)})});let h=Mr(u,{key:d,sender:e.sender,time:e.time},m),g=u.at(-1),_=h.findLast(e=>e.kind===`message`&&r!==void 0&&e.author.id===r),v=i.readTo;return(0,J.jsxs)(J.Fragment,{children:[Rn(l)&&(0,J.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,J.jsx)(W,{title:X(`couldNotLoad`),error:l.error,onRetry:An(l)})}),(0,J.jsx)(ve,{length:u.length,followKey:_?.key,empty:e.empty??X(`noMessages`),onLoadEarlier:l.hasNextPage?()=>void l.fetchNextPage():void 0,loadingEarlier:l.isFetchingNextPage,onReadToEnd:v&&g?()=>v(Number(d(g))):void 0,children:h.map(t=>t.kind===`day`?(0,J.jsx)(M,{label:t.label},t.key):t.kind===`new`?(0,J.jsx)(M,{tone:`new`},t.key):(0,J.jsx)(Tr,{page:e,row:t.row,author:t.author,time:t.time,continued:t.continued,member:s},t.key))})]})},Ir=(e,t,n)=>{let r=t.toLocaleLowerCase();return e.filter(e=>e.id!==n&&e.name.toLocaleLowerCase().includes(r)).slice(0,8).map(({id:e,name:t})=>({id:e,name:t}))},Lr=({position:e,model:t,owner:n,recordKey:r,me:i})=>{let a=H(),o=t?.author,s=e!==void 0&&o!==void 0&&i!==void 0,[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(),f=(0,Y.useRef)(void 0),p=(0,Y.useRef)(Promise.resolve()),m=(0,Y.useCallback)(async()=>{if(!s)return;let{items:n}=await a.list(e.resource,{filter:Ar(e,r,o,i),pageSize:1}),[c]=n;if(c)return{key:String(Ht(t,c)),lastRead:Number(c[e.message]??0)}},[a,s,e,t,r,o,i]);(0,Y.useEffect)(()=>{s&&m().then(e=>{f.current=e,l(e?.lastRead??0)},d)},[s,m]);let h=(0,Y.useCallback)(async(t,n)=>{await a.update(e.resource,t.key,{[e.message]:n},`*`),f.current={key:t.key,lastRead:n}},[a,e]),g=(0,Y.useCallback)(async i=>{let o=await a.create(e.resource,{[e.field]:xt(n,r),[e.message]:i}).catch(async e=>{if(!He(e)||e.status!==409)throw e;let t=await m();if(!t)throw e;await h(t,i)});o&&(f.current={key:String(Ht(t,o.record)),lastRead:i})},[a,e,n,r,t,m,h]),_=(0,Y.useCallback)(e=>{p.current=p.current.then(()=>{let t=f.current;if(!(t&&t.lastRead>=e))return t?h(t,e):g(e)}).catch(d)},[h,g]);return{ready:!s||c!==void 0||u!==void 0,openedAt:s?c:void 0,readTo:s&&c!==void 0?_:void 0,error:u}},Rr=({page:e,scope:t})=>{let{resources:n,views:r}=R(),i=f()(t.model,r[t.model.name],t.record,t.key),a=b(),o=a?.state.kind===`signed-in`?a.state.user.id:void 0,s=O(),c=n[e.resource],l=Lr({position:e.readPosition,model:e.readPosition&&n[e.readPosition.resource],owner:t.model,recordKey:t.key,me:o}),u=e.mentions===void 0?void 0:async e=>Ir(s.data??[],e,o);return(0,J.jsx)(xr,{children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,J.jsx)(Cr,{page:e,scope:t,title:i}),(0,J.jsx)(Fr,{page:e,model:c,recordKey:t.key,me:o,position:l}),l.error!==void 0&&(0,J.jsx)(`p`,{className:`shrink-0 px-4 text-sm text-danger-text`,children:X(`positionNotSaved`)}),(0,J.jsx)(`div`,{className:`shrink-0 px-3 pb-3`,children:(0,J.jsx)(In,{resource:e.resource,field:e.text,values:{[e.field]:xt(t.model,t.key)},placeholder:e.placeholder,searchPeople:u,mentions:e.mentions})})]})})},zr=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,Br=(e,t,n)=>gt(()=>{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),Vr=(e,t,n)=>gt(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),Hr=e=>en(e)??ar,Ur=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let a=m(),{go:o}=a,s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=cn(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?mn(e.run,t.record,a):void 0;return{name:e.label,icon:Hr(e.icon),blocked:n,running:c.running===e.name,...ln(e)&&{tone:`danger`},onRun:()=>un(e)?u(e):void c.run(e),...r&&{render:({className:e,children:t,role:n})=>(0,J.jsx)(Je,{to:r,role:n,className:e,children:t})}}}),f=c.actions.some(e=>e.run?.kind===`delete`);return{actions:[...r?[{name:U(`edit`),icon:Tn,render:({className:e,children:t,role:n})=>(0,J.jsx)(q,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:U(`delete`),icon:Wn,tone:`danger`,onRun:i}]:[]],prompt:l&&(0,J.jsx)(fn,{action:l,label:l.label,danger:ln(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)}})}},Wr=e=>{let t=qe(),{actions:n,prompt:r}=Ur(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)(pr,{actions:n})}),t&&(0,mr.createPortal)((0,J.jsx)(Lt,{actions:n,label:U(`recordActions`),className:`inline-flex size-[min(2.75rem,max(44px,13vw))] shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`}),t),r]})},Gr=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}`},Kr=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?ft(`operationFailed`,{index:n+1,label:Gr(r),message:e.message}):ft(`nothingSaved`,{message:e.message})},qr=(e,t)=>new e.constructor({...e.problem,detail:Kr(e,t)}),Jr=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Yr=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:o,lines:s})=>{let c=H(),l=nn(),u=ee(e.name,n),d=lt(r,i),[f]=(0,Y.useState)(()=>o?Br(localStorage,o,t.etag):void 0),[p,m]=(0,Y.useState)(f?.fields??{}),[g,_]=(0,Y.useState)(!!f),[v,y]=(0,Y.useState)(!1),[b,S]=(0,Y.useState)({}),[C,te]=(0,Y.useState)({}),[ne,re]=(0,Y.useState)(0),T=Object.entries(p).filter(([n,r])=>h(e.fields[n],r,t.record[n])),ie=T.length>0,E=ie||!!s?.dirty;(0,Y.useEffect)(()=>{f?.order&&s?.setOrder(f.order)},[]),(0,Y.useEffect)(()=>{if(!o)return;let n=Object.fromEntries(Object.entries(p).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!s?.order;Vr(localStorage,o,r?{etag:t.etag,fields:n,...s?.order&&{order:s.order}}:void 0)},[o,e,p,s?.order,t.etag]);let D=n=>n in p?p[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:x(t.record[n]),O=(n,r)=>{te(e=>Jr(e,n));let i=typeof r==`string`?r!==x(t.record[n]):h(e.fields[n],r,t.record[n]);m(e=>i?{...e,[n]:r}:Jr(e,n))},ae=async()=>{let r=await c.get(e.name,n);l.setQueryData(a.record(e.name,n),r);let i={},o={};for(let[n,a]of Object.entries(p)){let s=e.fields[n];h(s,a,r.record[n])&&(o[n]=a,x(r.record[n])!==x(t.record[n])&&(i[n]=s.type===`file`?Bt(s,r.record[n]):x(r.record[n])))}m(o),S(i)},k=()=>Object.fromEntries(T.map(([t,n])=>[t,_t(e.fields[t],n)])),A=e=>{let t=zt(e);te(t),Object.keys(t).length>0&&re(e=>e+1)},oe=async()=>{try{await u.mutateAsync({patch:k(),etag:t.etag})}catch(e){throw w(e)?await ae():He(e)&&A(e),e}},se=async r=>{let i=ie?[{op:`update`,resource:e.name,key:n,data:k(),etag:t.etag}]:[],o=[...i,...r.ops];try{await c.batchWrite(o)}catch(e){if(w(e))await ae(),await l.invalidateQueries({queryKey:[`list`]}),y(!0);else if(He(e)){let t=e.operation===void 0?-1:e.operation-i.length,n=r.rows[t];t<0?A(e):n&&s?.reject(n,e)}throw He(e)?qr(e,o):e}await Promise.all([l.invalidateQueries({queryKey:a.record(e.name,n)}),l.invalidateQueries({queryKey:[`list`]}),l.invalidateQueries({queryKey:[`page`]}),l.invalidateQueries({queryKey:[`map`]}),l.invalidateQueries({queryKey:[`aggregate`]})]),s?.reset()};return{value:D,change:O,save:()=>d.run(async()=>{let e=s?.plan();e&&e.ops.length>0?await se(e):await oe(),m({}),S({}),te({}),y(!1),_(!1)}),dirty:E,discard:()=>{m({}),S({}),te({}),y(!1),_(!1),s?.reset()},restored:g&&E,dismissRestored:()=>_(!1),linesConflict:v,saving:d.phase===`saving`,phase:d.phase,message:d.message,conflicts:b,errors:C,rejections:ne,keepMine:e=>S(t=>Jr(t,e)),useTheirs:e=>{S(t=>Jr(t,e)),m(t=>Jr(t,e))}}},Z=B(`focus-record`),Xr=({fields:e,onKeepMine:t,onUseTheirs:n})=>(0,J.jsx)(J.Fragment,{children:e.map(({name:e,label:r})=>[(0,J.jsx)(K,{size:`sm`,onClick:()=>t(e),children:Z(`keepMine`,{field:r})},`mine:${e}`),(0,J.jsx)(K,{size:`sm`,onClick:()=>n(e),children:Z(`useTheirs`,{field:r})},`theirs:${e}`)])}),Zr=({record:e,label:t})=>{let{dirty:n,saving:r,save:i}=e,a=Pt(`primary`),o=At()?.size===`compact`,s=(0,J.jsx)(K,{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)(Et,{zone:`secondary`,children:s}):(0,J.jsx)(Et,{zone:`primary`,fallback:!0,children:s})},Qr=({record:e,saved:t,readOnly:n})=>{let r=At()?.size,i=n?Z(`readOnly`):e.saving?Z(`saving`):e.dirty?Z(r===`wide`?`unsaved`:`unsavedShort`):t?Z(`saved`):void 0;return i?(0,J.jsx)(Et,{zone:`state`,fallback:!0,children:(0,J.jsxs)(`span`,{role:`status`,title:n?Z(`readOnlyWhy`):void 0,className:`flex items-center gap-1 truncate`,children:[!n&&!e.dirty&&!e.saving&&(0,J.jsx)(Qt,{className:`size-3.5 text-success-text`,"aria-hidden":!0}),i]})}):null},$r=({model:e,recordKey:t,stored:n,page:r})=>{let o=R().views[e.name],{address:s,go:c}=m(),l=f()(e,o,n.record,t),{state:u}=je(),d=Yr({model:e,stored:n,recordKey:t,mode:`button`,subject:l,draftKey:u.kind===`signed-in`?`${zr(u.user.id,e.name,t)}:focus`:void 0});Rt(d.dirty||d.saving),Zt(d.dirty);let p=nn(),[h,g]=(0,Y.useState)(!1),_=o?.names?.singular??V(e.name),v=kt(e.name),y=On(e),b=s?.kind===`record`&&s.version!==void 0&&s.version!==Number(n.record.version),x=`surface`in r&&(Ce(n.permissions,r.surface)===`read`||e.fields[r.surface]?.readOnly===!0),ee=S(v,`update`)&&n.permissions?.update!==!1&&!x,C=!ee||b,te=S(v,`delete`)&&n.permissions?.delete!==!1,ne=En({model:e,view:o,restore:y,onDeleted:()=>c({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:a.record(e.name,t)})}),{actions:re,prompt:w}=Ur({model:e,stored:n,recordKey:t,onDelete:te?()=>void ne.start({key:t,title:l,etag:n.etag,snapshot:n.record}):void 0}),T=(0,Y.useMemo)(()=>({kind:`record`,resource:e.name,key:t,standard:!0}),[e.name,t]),ie=re.filter(e=>e.tone===`danger`),E=[...re.filter(e=>e.tone!==`danger`),...d.dirty?[{name:Z(`discardChanges`),icon:rr,onRun:()=>g(!0)}]:[],{name:Z(`detailsOf`,{noun:_}),icon:tr,render:({className:e,children:t,role:n})=>(0,J.jsx)(q,{to:T,role:n,className:e,children:t})},...ie],D={model:e,record:n.record,key:t,...n.etag!==void 0&&{etag:n.etag},...n.permissions&&{permissions:n.permissions},readOnly:C,mayUpdate:ee,value:d.value,change:(e,t)=>C?void 0:d.change(e,t),dirty:d.dirty,saving:d.saving,refused:d.message!==void 0,save:async()=>!C&&!!await d.save(),discard:d.discard,details:T},O=`surface`in r?r.surface:void 0,ae=h&&d.dirty&&(0,J.jsx)(it,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>{d.discard(),g(!1)},children:Z(`discardChanges`)}),(0,J.jsx)(K,{size:`sm`,onClick:()=>g(!1),children:Z(`keep`)})]}),children:Z(`discardAsk`)}),k=Object.keys(d.conflicts).length>0,A=O?d.errors[O]:void 0,oe=A&&O?qt(e.fields[O],o?.fields[O]?.label??V(O),A):void 0;return(0,J.jsxs)(Ue.Provider,{value:D,children:[!C&&(0,J.jsx)(Zr,{record:D,label:Z(`save`)}),(0,J.jsx)(Qr,{record:D,saved:d.phase===`saved`,readOnly:C}),(0,J.jsx)(i,{actions:E}),d.message&&!h&&(0,J.jsxs)(it,{level:`refused`,actions:(0,J.jsx)(q,{to:T,className:`text-body font-medium text-primary-text hover:underline`,children:Z(`detailsOf`,{noun:_})}),children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:Z(`notSaved`)}),` `,oe??d.message]}),k&&(0,J.jsx)(it,{level:`conflict`,actions:(0,J.jsx)(Xr,{fields:Object.keys(d.conflicts).map(e=>({name:e,label:o?.fields[e]?.label??V(e)})),onKeepMine:d.keepMine,onUseTheirs:d.useTheirs}),children:Z(`conflict`)}),ae,d.restored&&!h&&(0,J.jsx)(it,{level:`draft`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{size:`sm`,onClick:d.dismissRestored,children:Z(`keep`)}),(0,J.jsx)(K,{size:`sm`,onClick:d.discard,children:Z(`discard`)})]}),children:Z(`restored`)}),O?(0,J.jsx)(ei,{model:e,name:O,stored:n,editor:d,readOnly:C}):(0,J.jsx)(ti,{name:r.component,model:e,stored:n,recordKey:t}),ne.dialogs,w]})},ei=({model:e,name:t,stored:n,editor:r,readOnly:i})=>{let a=R().views[e.name]?.fields[t];if(Ce(n.permissions,t)===`hidden`)throw Error(`The surface's field ${t} is hidden from this reader`);return(0,J.jsx)(`div`,{className:`absolute inset-0`,children:(0,J.jsx)(Xe,{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)})})},ti=({name:e,model:t,stored:n,recordKey:r})=>{let i=we().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)(pt,{value:{model:t,record:n.record,key:r,etag:n.etag,permissions:n.permissions},children:(0,J.jsx)(i,{})})})},ni=({model:e,recordKey:t,stored:n,page:r,standard:i})=>{let a=f()(e,R().views[e.name],n.record,t);return(0,J.jsx)(fe,{name:`surface`in r?r.surface:r.component,fallback:i,resetKey:e,children:(0,J.jsx)(ht,{label:a,children:(0,J.jsx)($r,{model:e,recordKey:t,stored:n,page:r})})})},ri=(0,Y.lazy)(()=>tn(()=>import(`./record-map-BO9rZaxg.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),ii=15,ai=({item:e,record:t})=>{let n=R().maps,r=n?.style,i=pn(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)(ri,{style:r,layers:n?.layers,position:i,zoom:e.zoom??ii},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,J.jsx)(Gn,{title:e.title,children:a}):(0,J.jsx)(j,{title:e.title,children:a})},oi={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},si=(e,t,n)=>{let r=new Map;e.forEach((e,i)=>{for(let a of e){let e=Date.parse(`${String(a.value)}Z`),o=r.get(e)??{at:e,value:null,count:0};o[t[i]]=a[n]??null,o.count=Math.max(o.count,a.count),r.set(e,o)}});let i=Object.fromEntries(t.map(e=>[e,null]));return[...r.values()].sort((e,t)=>e.at-t.at).map(e=>({...i,...e}))},Q=B(`app/record-chart`),ci=L(),li=[`1h`,`24h`,`7d`],ui={"1h":`hour`,"24h":`day`,"7d":`week`},di=({item:e,recordKey:t})=>{let{resources:n,views:r}=R(),[i,a]=(0,Y.useState)(e.range??`1h`),[o,s]=(0,Y.useState)(`average`),c=n[e.resource],u=r[e.resource],d=oi[i],f=N(ci.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:f,...o===`average`?{average:t}:{maximum:t},range:i,granularity:d,timeZone:et()})),m=l(e.resource,p,!!c);if(!c)return null;let h=e.series.map(e=>({kind:o,field:c.fields[e],...u?.fields[e]&&{hints:u.fields[e]}})),g=e.series.map((e,t)=>({key:`s${t}`,label:u?.fields[e]?.label??V(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?si(m.map(e=>e.data.groups),g.map(e=>e.key),o):[],v=(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(y,{label:Q(`measure`),value:o,onChange:s,options:[{value:`average`,label:Q(`average`)},{value:`maximum`,label:Q(`maximum`)}]}),(0,J.jsx)(y,{label:Q(`range`),value:i,onChange:a,options:li.map(e=>({value:e,label:Q(ui[e])}))})]});return(0,J.jsx)(j,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,J.jsx)(`p`,{className:`text-danger-text`,children:Q(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,J.jsx)(G,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Q(`noSamples`)}):(0,J.jsx)(yn,{points:_,measure:h[0],bucket:d,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:u}})})},fi=B(`app/record-trend`),pi=(e,t)=>fi(`total_${t}`,{count:e}),mi=L(),hi={kind:`count`},gi=({item:e,recordKey:t})=>{let n=N(mi.eq(e.field,t)),r=bt(e.resource,{groupBy:e.at,filter:n,granularity:e.granularity,range:e.range,timeZone:et()});return(0,J.jsx)(j,{title:e.title,help:e.help,children:(0,J.jsx)(`div`,{"aria-busy":r.isPending,children:(()=>{if(r.isPending)return(0,J.jsx)(G,{className:`h-[calc(10rem+2rem)] w-full`});if(r.error)return(0,J.jsx)(W,{title:fi(`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:pi(t,e.range)}),(0,J.jsx)(yn,{points:wn(r.data.groups,hi),measure:hi,bucket:e.granularity,type:`bar`})]})})()})})},_i=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],vi=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),yi=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)}},bi=(e,t)=>e.find(e=>e.title===t)??e[0],xi=e=>Ne(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),Si=(e,t,n)=>{if(t&&!xi(t).some(n))return e.find(e=>xi(e).some(n))},Ci={added:[],edits:{},removed:[]},wi=(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},Ti=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return i&&h(i,r,n[t])?[[t,_t(i,r)]]:[]})),Ei=(e,t)=>Object.fromEntries(Object.entries(t).flatMap(([t,n])=>{let r=e.fields[t];return!r||r.type!==`boolean`&&String(n??``).trim()===``?[]:[[t,_t(r,n)]]})),Di=({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=>[g(e,t),t])),c=[...s.keys()],l=wi(c,i),u=t=>Ht(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=Ti(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?[[st(u(e)),n]]:[]})),_=(n,r,i)=>({op:`reorder`,resource:e.name,field:t,keys:n,...r!==1&&{start:r},etags:i}),v=(r,a,o)=>({op:`create`,resource:e.name,data:{...Ei(e,i.edits[r]??{}),[n.field]:n.value,[t]:a},...o&&{ref:o}}),y=e=>Number(e[t])||0,b=p.some((e,t)=>e!==c.filter(e=>p.includes(e))[t]);if(m.every(e=>l.indexOf(e)>=p.length)){b&&o(_(p.map(u),1,h(p,!1)));let e=b?p.length:Math.max(0,...p.map(e=>y(s.get(e))));return m.forEach((t,n)=>o(v(t,e+1+n),t)),a}let x=Math.max(l.length,...r.map(y))+1;p.length>0&&o(_(p.map(u),x,h(p,!1)));let S=e=>`line${m.indexOf(e)+1}`;for(let e of m)o(v(e,l.indexOf(e)+1,S(e)),e);return o(_(l.map(e=>s.has(e)?u(e):{$ref:S(e)}),1,h(p,!0))),a},Oi=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),ki=(e,t)=>{let[n,r]=(0,Y.useState)(Ci),[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(1),s=(0,Y.useMemo)(()=>new Map(e?t.map(t=>[g(e.model,t),t]):[]),[e,t]),c=wi([...s.keys()],n).map(e=>({id:e,stored:s.get(e)})),l=()=>e?Di({...e,stored:t,state:n}):{ops:[],rows:[]},u=l().ops.length>0,d=(0,Y.useMemo)(()=>{let e=wi([...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:Se(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:Oi(t.edits,e)}:{...t,removed:[...t.removed,e]})},setOrder:e=>r(t=>({...t,order:e})),reset:()=>{r(Ci),a(void 0)},reject:(e,t)=>a({id:e,fields:zt(t),message:t.message}),rejection:i,plan:l}},Ai=(e,t)=>{let n=Ne(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}},ji=(e,t,n,r)=>It(e,t).filter(t=>{let i=e.fields[t];return i&&!i.writeOnly&&t!==n&&t!==r&&t!==e.tenant&&!e.primaryKey.includes(t)}),Mi=(e,t)=>{let{resources:n,views:r}=R(),i=(0,Y.useMemo)(()=>Ai(n,r[e.name]),[n,r,e]),a=i?.model,o=i?ji(i.model,r[i.model.name],i.link.name,i.position):[],s=gr(a,i?.link,i?.position,t,a?Ve(n,r,a,o):void 0),c=ki((0,Y.useMemo)(()=>i?{model:i.model,position:i.position,link:{field:i.link.name,value:xt(e,t)}}:void 0,[i,e,t]),s.items);return{item:i?.item,model:a,columns:o,data:s,draft:c}},Ni=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},Pi=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,Fi=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,Ii=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),Li=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,Ri=`protobase:lightbox-details`,zi=e=>gt(()=>e.getItem(Ri)===`true`,!1),Bi=(e,t)=>gt(()=>t?e.setItem(Ri,`true`):e.removeItem(Ri),void 0),$=B(`app/gallery`),Vi=`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`,Hi=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=$(`details`)})=>{let c=(0,Y.useRef)(null),l=(0,Y.useRef)(void 0),u=(0,Y.useId)(),d=k(),[f,p]=(0,Y.useState)(()=>zi(localStorage)),[m,h]=(0,Y.useState)(!1);St(c,!0,i),(0,Y.useEffect)(()=>h(!0),[]);let g=t.length,_=e=>{let t=Ii(n,e,g);t!==n&&r(t)},v=s(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{p(e),Bi(localStorage,e)};return(0,J.jsxs)(`div`,{ref:c,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&Li(e))return e.preventDefault(),x(!f);let t=Fi(e.key);t!==0&&(e.preventDefault(),_(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] outline-none md:flex-row`,children:[(0,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} / ${g}`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,J.jsx)(`button`,{type:`button`,className:D(Vi,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":f,"aria-controls":d?u:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!f),children:(0,J.jsx)($n,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:Vi,"aria-label":$(`close`),onClick:i,children:(0,J.jsx)(wt,{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`&&(l.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{l.current&&=(_(Pi(e.clientX-l.current.x,e.clientY-l.current.y)),void 0)},onPointerCancel:()=>l.current=void 0,children:[v&&(0,J.jsx)(Be,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),g>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:D(Vi,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`previousPhoto`),"aria-disabled":n===0,onClick:()=>_(-1),children:(0,J.jsx)(me,{className:`size-5`,"aria-hidden":!0})}),(0,J.jsx)(`button`,{type:`button`,className:D(Vi,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":$(`nextPhoto`),"aria-disabled":n===g-1,onClick:()=>_(1),children:(0,J.jsx)(se,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&f&&d&&(0,J.jsxs)(`aside`,{id:u,"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}),y]}),(0,J.jsx)(I,{title:o,open:b&&f&&!d&&m,onClose:()=>x(!1),children:(0,J.jsx)(`div`,{className:`pt-3`,children:y})})]})},Ui=(e,t,n)=>{let r=Ne(t?.layout??[]).flatMap(e=>e.kind===`section`&&Ct(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)&&Ct(t?.fields[r]?.when,!1))},Wi=({model:e,view:t,photoKey:n,fields:r})=>{let i=Le(e.name,n),a=(t?.names?.singular??V(e.name)).toLowerCase();if(i.isPending)return(0,J.jsx)(G,{className:`h-4 w-48`});if(i.error)return(0,J.jsx)(W,{title:$(`couldNotLoadOne`,{singular:a}),error:i.error});let o=r.filter(e=>Ce(i.data.permissions,e)!==`hidden`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ur,{rows:o.map(n=>({label:t?.fields[n]?.label??V(n),value:(0,J.jsx)(Kt,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,J.jsx)(q,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:$(`open`,{singular:a})})]})},Gi=e=>s(e,{width:0,height:0})!==void 0,Ki=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return st(n)},qi=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!vt(t)||!Gi(t))return[];let i=r&&Ki(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!vt(e)||!Gi(e))return i;let a=t=>vt(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))]},Ji=L(),Yi=(e,t,n)=>{let r=H(),{resources:i}=R(),o=e.photos?i[e.photos.resource]:void 0,s=e.photos?N(Ji.eq(e.photos.field,n)):``,c=e.photos?.sort??``,l=an({queryKey:a.list(o?.name??``,s,c,500,`gallery`),enabled:o!==void 0,queryFn:async()=>(await r.list(o.name,{filter:s,...c&&{orderBy:c},pageSize:500})).items});return{holder:o,items:qi(e.image===void 0?void 0:t[e.image],l.data??[],e.photos?.image,o),isPending:o!==void 0&&l.isPending,error:l.error}},Xi={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`,``,``,``,``]},Zi=({photo:e,large:t})=>{let n=s(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,J.jsx)(Be,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},Qi=({item:e,record:t,recordKey:n})=>{let{views:r}=R(),i=Yi(e,t,n),a=kt(i.holder?.name??``),[o,s]=(0,Y.useState)();if(i.isPending)return(0,J.jsx)(j,{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)(j,{title:e.title,children:(0,J.jsx)(W,{title:$(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=Ni(c),d=i.holder,f=d&&r[d.name],p=d?Ui(d,f,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],m=d!==void 0&&a.read!==!1&&p.length>0;return(0,J.jsxs)(j,{title:e.title,children:[(0,J.jsx)(`div`,{className:`grid aspect-[4/3] grid-cols-4 grid-rows-2 gap-1.5 overflow-hidden rounded-lg md:aspect-[2/1]`,children:i.items.slice(0,l).map((e,t)=>{let n=t===l-1&&u>0;return(0,J.jsxs)(`button`,{type:`button`,"aria-label":n?$(`showAll`,{count:c}):$(`showPhoto`,{index:t+1,count:c}),onClick:()=>s(t),className:D(`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`,Xi[l][t]),children:[(0,J.jsx)(Zi,{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)(Zn,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,J.jsx)(Hi,{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)(Wi,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&$(`holderDetails`,{singular:f?.names?.singular??V(d.name)})})]})},$i=B(`app/history`),ea=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?$i(`databaseRole`,{role:e.databaseRole}):$i(`database`),ta=(e,t,n)=>{let r=(e.operation===`create`?[]:e.changed).flatMap(r=>{let i=t.fields[r];if(!i||r===t.softDelete)return[];let a=n?.fields[r],o=a?.label??V(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:Bt(i,e.before[r],a),after:Bt(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?$i(`changedThis`):$i(e.operation);return{who:ea(e),verb:i,fields:r}},na=1500,ra=(e,t,n,r)=>{let i=H(),o=on({queryKey:a.history(e,t,n),initialPageParam:``,queryFn:({pageParam:r})=>i.history(e,t,{pageSize:n,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0}),{refetch:s}=o;return(0,Y.useEffect)(()=>{let e=setTimeout(()=>void s(),na);return()=>clearTimeout(e)},[r,s]),{...o,items:o.data?.pages.flatMap(e=>e.items)??[]}},ia=()=>(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))}),aa=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=ta(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:De(o),className:`text-muted-foreground`,children:[`· `,dt(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))})]})},oa=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=ra(t.name,r,e.limit??10,i);return(0,J.jsx)(j,{title:e.title,children:a.isPending?(0,J.jsx)(ia,{}):a.error?(0,J.jsx)(W,{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)(aa,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,J.jsx)(K,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},sa=({comment:e})=>(0,J.jsx)(Pe,{text:e.body,mentions:e.mentions}),ca=(e,t)=>{let n=H(),r=nn();return rn({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:a.comments(e,t)})})},la=B(`app/comments`),ua=({resource:e,recordKey:t})=>{let[n,r]=(0,Y.useState)(C),i=H(),a=pe(),o=ca(e,t),s=(0,Y.useCallback)(n=>i.mentionable(e,t,n),[i,e,t]);Rt(n.text.trim()!==``||o.isPending,`input-lost`);let c=()=>{n.text.trim()===``||o.isPending||o.mutate({body:n.text,mentions:u(n.text,n.picked)},{onSuccess:()=>r(C),onError:e=>a.show({state:`error`,title:la(`couldNotPost`),description:nt(e)})})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(T,{"aria-label":la(`comment`),placeholder:la(`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)(K,{variant:`primary`,size:`sm`,disabled:n.text.trim()===``,loading:o.isPending,onClick:c,children:la(`comment`)})})]})},da=20,fa=(e,t)=>{let n=H(),r=on({queryKey:a.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:da,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},pa=()=>(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))}),ma=({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)(P,{initials:ge(t)||`?`,hue:le(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:De(n),className:`text-muted-foreground`,children:[`· `,dt(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,J.jsx)(sa,{comment:e})]})]})},ha=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=fa(t,n);return(0,J.jsxs)(j,{title:e.title,children:[i.isPending?(0,J.jsx)(pa,{}):i.error?(0,J.jsx)(W,{title:la(`couldNotLoad`),error:i.error}):(0,J.jsxs)(J.Fragment,{children:[i.hasNextPage&&(0,J.jsx)(K,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:la(`showEarlier`)}),i.items.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:la(`noComments`)}):(0,J.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,J.jsx)(ma,{comment:e},e.id))})]}),r&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(ua,{resource:t,recordKey:n})})]})},ga=e=>e.kind===`group`||e.kind===`tab`?e.items:e.kind===`custom`?e.fallback??[]:[],_a=e=>e.kind===`tab`?void 0:e.when,va=e=>e.flatMap(e=>[e,...va(ga(e))]).filter(e=>o(_a(e))),ya=e=>(e.fallback??[]).map((t,n)=>[t,e.fallbackAt?.[n]??n]),ba=(e,t,n,r)=>{let i=0,a=e=>{let a=_a(e);return o(a)?!r&&t[i++]===!0:Ct(a,n)},s=e=>e.flatMap(e=>{let t=a(e);if(e.kind===`custom`&&e.fallback){let n=e.fallback.map(e=>s([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=s(e.items);return t&&n.length>0?[{...e,items:n}]:[]});return s(e)},xa=(e,t,n,r)=>{let i=r?[]:va(e).map(e=>_a(e));return ba(e,Un(i,t),n,r)},Sa=L(),Ca=(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:N(Sa.eq(n,t)),pageSize:1,fields:[n,e.tenant]}},wa=(e,t,n)=>{let r=t?.[e.tenant];if(r!=null&&String(r)!==n)return String(r)},Ta=(e,t)=>{let n=H(),{session:r,organizations:i}=je(),a=(0,Y.useMemo)(()=>i?Ca(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=wa(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},Ea=(e,t,n,r)=>{let i=H(),a=nn(),o=f(),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),l=sn({queries:s.map(e=>{let o=t[e.relation.resource];return c(a,i,o,n[o.name],String(r[e.name]))})}),u=s.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(s.map((e,t)=>[e.name,u[t]])),labels:Object.fromEntries(s.map((e,i)=>{let a=t[e.relation.resource];return[e.name,yt(l[i]?.data,o,a,n[a.name],String(r[e.name]))]}))}},Da=L(),Oa=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let a=new Set(ka(r,i).flatMap(e=>e.kind===`thread`?[`${e.resource}.${e.field}`,...e.calls?[`${e.calls.resource}.${e.calls.field}`]:[]]:e.kind===`related`&&!e.through&&!e.from?[`${e.resource}.${e.field}`]:[])),o=Object.values(t).flatMap(t=>Object.values(t.fields).filter(t=>t.type===`relation`&&t.relation?.resource===e.name&&t.relation.columns.length===1&&t.filterable).filter(e=>e.name!==t.tenant&&!a.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return o.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??V(e.name),a=o.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:a?`${i} (${r?.fields[t]?.label??V(t)})`:i}})},ka=(e,t)=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?ka(e.items,t):e.kind===`custom`&&!t(e.component)?[e,...ka(e.fallback??[],t)]:[e]),Aa=(e,t)=>({kind:`list`,resource:e.resource,filter:N(Da.eq(e.field,t))}),ja=L(),Ma=(e,t,n)=>{let r=H(),i=sn({queries:e.map(e=>{let i=N(ja.eq(e.field,n));return{queryKey:a.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}]})},Na=({model:e,recordKey:t,layout:n})=>{let{resources:r,views:i}=R(),{components:a}=we(),o=Ma(Oa(e,r,i,n,e=>!!a?.[e]),r,t);return o.length===0?null:(0,J.jsx)(Gn,{title:U(`relatedRecords`),children:(0,J.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(q,{to:Aa(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`}):`${ye(n.count)}${n.exact?``:`+`}`,(0,J.jsx)(se,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},Pa=({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)(rt,{dot:!1,className:D(`tabular-nums`,e===0&&`bg-transparent ring-1 ring-border ring-inset`),children:(0,J.jsx)(`span`,{"aria-hidden":!0,children:e.toLocaleString(Nt())})}),(0,J.jsx)(`span`,{className:`sr-only`,children:t?z(`headingCount`,{count:e,...t}):z(`headingCountRecords`,{count:e})})]}),Fa=(e,t,n,r,i)=>{if(!(e.through||t===null)&&ne(n,r,i))return{kind:`create`,resource:e.resource,values:{[e.field]:String(t)}}},Ia=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??zn(`nothingYet`)}),La=(e,t)=>(t?.names?.singular??V(e.name)).toLowerCase(),Ra=({title:e,help:t,count:n,model:r,view:i,filter:a,sort:o,fields:s,button:c,empty:l,add:u})=>{let d=Fe(),{resources:f}=R(),p=o||Ze(r,i),m=Yt(r,{filter:a,sort:p,pageSize:2});if(m.isPending)return(0,J.jsx)(j,{title:e,help:t,count:n,children:(0,J.jsx)(G,{className:`h-24 w-full`})});if(m.error)return(0,J.jsx)(j,{title:e,help:t,count:n,children:(0,J.jsx)(W,{title:zn(`couldNotLoad`),error:m.error})});let[h,g]=m.data.items;if(!h){let a=u&&(0,J.jsxs)(q,{to:u,className:tt({size:`sm`}),children:[(0,J.jsx)(Ae,{className:`size-3.5`}),zn(`add`,{singular:La(r,i)})]});return(0,J.jsx)(j,{title:e,help:t,count:n,actions:a,children:(0,J.jsx)(Ia,{empty:l})})}let _=ct(r,h),v=La(r,i),y=i?.names?.plural??V(r.name),b=s.length>1,x=s.map(e=>(0,J.jsx)(Nn,{scope:_,path:e,labelled:b},e)),S=(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)(q,{to:{kind:`record`,resource:r.name,key:Ht(r,h)},className:tt({size:`sm`}),children:zn(`open`,{singular:v})})]});return(0,J.jsx)(j,{title:e,help:t,count:n,actions:S,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)(q,{to:vn(r,i,d,{filter:a,orderBy:p,display:bn(i,d,{})}),className:`flex items-center gap-1 self-start font-medium text-primary-text hover:underline`,children:[gn(`viewAll`),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:y.toLowerCase()}),(0,J.jsx)(dn,{className:`size-3.5`,"aria-hidden":!0})]})]})})},za=L(),Ba=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},Va=(e,t,n)=>{let{through:r}=e;if(t===null)return null;if(!r)return Ba(N(za.eq(e.field,t)),e.filter);let i=r.key??n[r.resource]?.primaryKey[0],a=Dt(Ba(N(za.eq(r.field,t)),r.filter));return!a.ok||!i?null:Ba(N(za.related(e.field,r.resource,i,a.ast)),e.filter)},Ha=e=>{if(e.some(e=>e===null))return null;if(!e.some(e=>e===void 0))return e.reduce((e,t)=>e+t,0)},Ua=(e,t=!0)=>{let n=H(),{resources:r}=R(),i=e.flatMap(({item:e,value:t})=>{let n=r[e.resource];return n?[{model:n,match:Va(e,t,r)}]:[]}),a=sn({queries:i.map(({model:e,match:r})=>({...ot(n,e,r??``),enabled:t&&r!==null}))});return Ha(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}))},Wa=L(),Ga=({empty:e})=>(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e??U(`nothingYet`)}),Ka=({item:e,value:t,owner:n})=>{let{resources:r,views:i,pages:a}=R(),o=r[e.resource],s=o&&i[o.name],c=Va(e,t,r),[l,u]=Fn(s,`related:${n}:${e.title}`,e.display),d=kt(e.resource),[f,p]=(0,Y.useState)(!1),m=Ua([{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)(Pa,{count:m,names:s?.names}):void 0},g=xn(e,o,r),_=e.columns??It(o,s).filter(t=>t!==e.field),v=t=>c===null?(0,J.jsx)(Ga,{empty:e.empty}):t(c);if(e.presentation===`cards`||e.presentation===`compact`){let t=e.presentation===`compact`?{time:e.time}:void 0,n=t?_.filter(t=>t!==e.time):_,r=e.tone===void 0||n.includes(e.tone)?n:[e.tone,...n];return(0,J.jsx)(j,{...h,children:v(n=>(0,J.jsx)(Mn,{model:o,view:s,filter:n,sort:e.sort??``,fields:r,actions:e.actions??[],button:e.button,limit:e.limit??10,display:e.display,empty:e.empty,compact:t,tone:e.tone}))})}if(e.presentation===`record`)return c===null?(0,J.jsx)(j,{...h,children:(0,J.jsx)(Ga,{empty:e.empty})}):(0,J.jsx)(Ra,{...h,model:o,view:s,filter:c,sort:e.sort??``,fields:_,button:e.button,empty:e.empty,add:Fa(e,t,s,a,d)},c);let y=Yn(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)(kn,{size:`sm`,sorting:f,onChange:p})]}):b;return f&&y?(0,J.jsx)(j,{...h,actions:x,children:(0,J.jsx)(Dn,{model:o,view:s,field:y,filter:N(Wa.eq(e.field,t)),columns:_})}):(0,J.jsx)(j,{...h,actions:x,children:v(t=>(0,J.jsx)(_n,{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))})},qa=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:hn(t,e.from)??null},Ja=({sections:e})=>{let t=Ua(e),{views:n}=R(),r=new Set(e.map(({item:e})=>e.resource)),[i]=r,a=r.size===1?n[i]?.names:void 0;return(0,J.jsx)(Pa,{count:t,names:a})},Ya=(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},Xa=({item:e,scope:t})=>{let{resources:n}=R(),[r]=Un(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:Dr(e.calls.field,t.key),fields:e.calls};return(0,J.jsx)(j,{title:e.title,help:e.help,children:(0,J.jsx)(Bn,{children:(0,J.jsx)(Pn,{model:i,filter:Dr(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})})})},Za=({item:e,scope:t})=>{let n=e.tree,r=e.reads;return(0,J.jsx)(Ye,{value:t,children:(0,J.jsxs)(Tt,{tree:n,plan:r,children:[(0,J.jsx)(qn,{tree:n,plan:r}),(0,J.jsx)(Hn,{node:n,at:``})]})})},Qa=he(()=>tn(()=>import(`./record-lines-Dts68Cfq.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`})),$a=he(()=>tn(()=>import(`./composer-section-BLqTkqi8.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`})),eo=(e,t)=>t===e.tenant||e.primaryKey.includes(t),to=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!eo(e,t.name)&&!t.writeOnly),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:U(`details`),fields:a},...e.history?[{kind:`history`,title:U(`history`)}]:[],...e.comments?[{kind:`comments`,title:U(`comments`)}]:[]]},no=({resource:e,recordKey:t})=>{let{resources:n,views:r}=R(),{address:i}=m(),a=we(),o=n[e],s=d(e,t);if(!o)return(0,J.jsx)(mt,{title:ft(`notFound`),children:ft(`noResource`,{name:e})});if(s.isPending)return(0,J.jsx)(ce,{});if(s.error)return(0,J.jsx)(`div`,{className:`p-8`,children:He(s.error)&&s.error.status===404?(0,J.jsx)(ro,{model:o,recordKey:t}):(0,J.jsx)(W,{title:U(`couldNotLoad`),error:s.error})});let c=(0,J.jsx)(io,{model:o,recordKey:t,stored:s.data,preview:s.isPlaceholderData},s.isPlaceholderData?`preview`:`loaded`),l=i?.kind===`record`&&i.file!==void 0&&!s.isPlaceholderData?v(a,o,s.data.record,i.file):void 0,u={kind:`record`,resource:e,key:t,...(r[e]?.recordOpens!==void 0||r[e]?.record!==void 0)&&{standard:!0}};if(l)return(0,J.jsx)(F,{model:o,record:s.data.record,viewed:l,back:u},l.file.uri);let f=i?.kind===`record`&&i.standard===!0,p=r[e]?.recordOpens;if(p&&!f){if(s.isPlaceholderData)return(0,J.jsx)(ce,{});let e=ke(p,s.data.record);if(e)return(0,J.jsx)(Jn,{to:e})}let h=r[e]?.record;if(!h||f)return c;if(s.isPlaceholderData)return(0,J.jsx)(ce,{});let{record:g,etag:_,permissions:y}=s.data;return`conversation`in h?(0,J.jsx)(Rr,{page:h.conversation,scope:{model:o,record:g,key:t,etag:_,permissions:y}},t):`surface`in h||h.focus?(0,J.jsx)(ni,{model:o,recordKey:t,stored:s.data,page:h,standard:c}):(0,J.jsx)(br,{component:h.component,scope:{model:o,record:g,key:t,etag:_,permissions:y},standard:c})},ro=({model:e,recordKey:t})=>{let n=Ta(e,t);return n.state===`looking`?(0,J.jsx)(ce,{}):n.state===`switching`?(0,J.jsx)(mt,{title:U(`loading`),children:U(`openingElsewhere`)}):n.state===`failed`?(0,J.jsx)(W,{title:U(`couldNotLoad`),error:n.error}):(0,J.jsx)(mt,{title:ft(`notFound`),children:U(`noRecord`)})},io=({model:e,recordKey:t,stored:n,preview:r})=>{let i=R(),{address:o,go:s}=m(),c=i.views[e.name],l=f()(e,c,n.record,t),{state:u}=je(),d=Mi(e,t),p=Yr({model:e,stored:n,recordKey:t,mode:c?.saveFeedback??`toast`,subject:l,draftKey:!r&&u.kind===`signed-in`?zr(u.user.id,e.name,t):void 0,lines:d.draft}),h=nn(),g=H(),v=Ge(p.rejections),y=kt(e.name),b=On(e),x=o?.kind===`record`&&o.version!==void 0,ee=S(y,`update`)&&n.permissions?.update!==!1&&!x,{shown:C,offersEdit:ne,editing:w}=jt(c?.recordMode,ee,o?.kind===`record`&&o.edit===!0);Rt(p.dirty&&C===`form`||p.saving),Zt(p.dirty);let T=o?.kind===`record`?o.open:void 0,ie=o?.kind===`record`&&o.edit===!0,E=o?.kind===`record`?o.tab:void 0,O=o?.kind===`record`&&o.standard===!0,k=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i},...O&&{standard:O}}),A=k(T,!1,E),oe=k(T,!0,E),se=C===`form`&&c?.recordMode!==void 0&&c.recordMode!==`edit`,ce=S(y,`delete`)&&n.permissions?.delete!==!1,le=En({model:e,view:c,restore:b,onDeleted:()=>s({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void h.invalidateQueries({queryKey:a.record(e.name,t)})}),ue=Ea(e,i.resources,i.views,n.record),de=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},fe=Object.values(e.fields).filter(e=>de(e.name)),pe={...n.record,...Object.fromEntries(fe.map(e=>[e.name,Vt(e,p.value(e.name))]))},me=Ea(e,i.resources,i.views,pe),he=(e,t)=>{let n=de(e);if(!n||!Ft(t))return p.change(e,t);h.setQueryData(a.relatedLabel(n.name,t.key),{label:t.label}),p.change(e,xt(n,t.key))},{fields:ge}=we(),ve={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ye=xa(to(e,c,C===`read`),ve,w,r),{before:xe,tabs:Se,after:Te}=yi(ye),M=bi(Se,E),De=e=>w&&(p.errors[e]!==void 0||p.conflicts[e]!==void 0);(0,Y.useEffect)(()=>{if(p.rejections===0)return;let e=Si(Se,M,De);e&&s(k(T,ie,e===Se[0]?void 0:e.title),{replace:!0})},[p.rejections]);let N=ye.flatMap(e=>e.kind===`sidebar`?e.fields:[]),ke=_r(e,`updated`),P=e=>c?.fields[e],Ae=t=>Ce(n.permissions,t)!==`hidden`&&Ct(P(t)?.when,w)&&(C===`form`||!e.fields[t]?.writeOnly),F=e=>!r||Object.hasOwn(n.record,e),I=Ya(e,c,n.record,N,Ae),Ne=I&&(0,J.jsxs)(re,{value:n.record[I],hints:P(I),children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[P(I)?.label??V(I),`: `]}),Bt(e.fields[I],n.record[I],P(I))]}),Pe=r=>{let a=e.fields[r],o=Ce(n.permissions,r);if(!a||o===`hidden`)return null;let s=p.conflicts[r],l=de(r),u=P(r)?.label??V(r),d=p.errors[r],f=C!==`form`||o===`read`;return(0,J.jsx)(Oe,{name:r,label:u,required:C===`form`&&o!==`read`&&te(a),help:$e(P(r),c,w),error:d&&qt(a,u,d),wide:be(ge,a,P(r)),readOnly:Gt(a,P(r),f,!!l),conflict:s===void 0?void 0:{user:{name:U(`someoneElse`),initials:`?`,hue:40},ago:U(`justNow`),theirValue:s||`—`,onKeepMine:()=>p.keepMine(r),onUseTheirs:()=>p.useTheirs(r)},children:F(r)?(0,J.jsx)(Xe,{field:a,hints:P(r),value:p.value(r),stored:n.record[r],relationLabel:me.labels[r],relationTo:me.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:f,invalid:!!p.errors[r],reveal:a.sensitive&&!a.writeOnly?()=>g.reveal(e.name,t,r):void 0,resource:e.name,record:n.record,linkText:P(r)?.format===`url`?Ke(e,c,r,n.record,ue.labels):void 0,onChange:e=>he(r,e)}):(0,J.jsx)(G,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},Fe=r=>{let i=e.fields[r],a=F(r)?i.sensitive?(0,J.jsx)(Xe,{field:i,hints:P(r),value:``,stored:n.record[r],locked:!0,reveal:()=>g.reveal(e.name,t,r),resource:e.name,onChange:e=>p.change(r,e)}):(0,J.jsx)(Kt,{model:e,field:i,value:n.record[r],relationLabel:ue.labels[r],record:n.record,relationLabels:ue.labels}):(0,J.jsx)(G,{className:`h-4 w-32`});return{label:P(r)?.label??V(r),help:$e(P(r),c,w),wide:be(ge,i,P(r)),value:a}},Ie=ye.findIndex(e=>e.kind===`sidebar`),Le=(0,J.jsx)(Kn,{title:U(`summary`),rows:N.flatMap(t=>{let r=e.fields[t];if(!r||!Ae(t))return[];if(!F(t))return[{label:P(t)?.label??V(t),value:(0,J.jsx)(G,{className:`h-4 w-24`})}];let i=n.record[t],a=Ut(r,P(t))&&typeof i==`string`&&i!==``,o=r.type===`json`&&i!=null,s=a?Me(i):o?Qe(i):Bt(r,i,P(t)),l=r.type===`text`&&typeof i==`string`&&i!==``?_(P(t)):void 0,u=r.type===`enum`?(0,J.jsx)(re,{value:i,hints:P(t),children:s}):l?(0,J.jsx)(ae,{format:l,value:s,label:Ke(e,c,t,n.record,ue.labels)}):(0,J.jsx)(`span`,{title:Jt(r,i,void 0,P(t)),children:s}),d=Ee(ge,r,P(t));return[{label:P(t)?.label??V(t),title:s,value:d?(0,J.jsx)(_e,{shown:d,part:`display`,field:r,value:n.record[t],fallback:u}):u}]})}),Re=async()=>{await p.save()&&se&&s(A,{replace:!0})},ze=ce?()=>void le.start({key:t,title:l,etag:n.etag,snapshot:n.record}):void 0,Be=C===`form`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(K,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:p.saving,disabled:!p.dirty&&p.phase!==`saved`,onClick:()=>void Re(),children:[p.phase===`saved`&&(0,J.jsx)(Qt,{className:`size-4`}),p.phase===`saved`?U(`saved`):U(`save`)]}),se&&(0,J.jsx)(q,{to:A,className:D(tt(),`max-md:min-h-11 md:w-full`),onClick:e=>Ot(e)&&p.discard(),children:U(`cancel`)}),p.dirty&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:U(`unsavedChanges`)})]}),L=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(L);if(e.length===0)return[];let r=vi(i,T,De),a=i.collapsed?k(_i(T,i.title),ie,E):void 0,o=i.items.flatMap(e=>e.kind===`related`&&(e.from===void 0||F(e.from))?[{item:e,value:qa(e,n.record,t)}]:[]),s=i.count?(0,J.jsx)(Ja,{sections:o}):void 0;return[(0,J.jsx)(cr,{title:i.title,help:i.help,count:s,open:r,toggle:a,children:e},`group:${i.title}`)]}if(i.kind===`related`&&i.lines)return!d.model||!d.item||r?[]:[(0,J.jsx)(Qa,{lines:{...d,model:d.model,item:d.item},editable:C===`form`,saving:p.saving},`lines:${i.title}`)];if(i.kind===`related`)return i.from!==void 0&&!F(i.from)?[]:[(0,J.jsx)(Ka,{item:i,value:qa(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,J.jsx)(di,{item:i,recordKey:t},`chart:${a}`)];if(i.kind===`trend`)return[(0,J.jsx)(gi,{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)(yr,{item:i,scope:ve,fallback:i.fallback&&(0,J.jsx)(J.Fragment,{children:ya(i).flatMap(([e,t])=>L(e,t))})},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,J.jsx)(ai,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,J.jsx)(Qi,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,J.jsx)(oa,{item:i,model:e,view:c,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`thread`)return[(0,J.jsx)(Xa,{item:i,scope:ve},`thread:${a}`)];if(i.kind===`blocks`)return[(0,J.jsx)(Za,{item:i,scope:ve},`blocks:${a}`)];if(i.kind===`composer`)return r?[]:[(0,J.jsx)($a,{item:i,owner:e,recordKey:t},`composer:${a}`)];if(i.kind===`comments`)return[(0,J.jsx)(ha,{item:i,resource:e.name,recordKey:t,canWrite:u.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&Ae(t)),s=C===`read`&&i.presentation===`facts`,l=s?Mt(n.record,o):o;return l.length===0?[]:[(0,J.jsx)(j,{title:i.title,help:at(i.helpWhen,c,w)?i.help:void 0,children:s?(0,J.jsx)(dr,{facts:l.map(e=>({label:Fe(e).label,value:Fe(e).value,icon:en(P(e)?.icon)}))}):C===`read`?(0,J.jsx)(ur,{rows:l.map(Fe)}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:l.map(Pe)})},i.title)]},Ve=(e,t)=>e.kind===`map`?(0,J.jsx)(ai,{item:e,record:n.record},`map:${t}`):e.kind===`custom`?(0,J.jsx)(yr,{item:e,scope:ve,fallback:e.fallback&&(0,J.jsx)(J.Fragment,{children:ya(e).map(([e,t])=>Ve(e,t))})},`custom:${t}`):null;return(0,J.jsxs)(`div`,{ref:v,className:`flex flex-1 flex-col`,inert:r,children:[le.dialogs,(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsxs)(`div`,{className:D(c?.recordWidth!==`full`&&`mx-auto max-w-[1100px]`,`px-4 pb-8 pt-6 md:px-10 md:py-8`),children:[(0,J.jsx)(or,{title:l,badge:Ne}),p.message&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(W,{title:U(`notSaved`),error:Error(p.message)})}),p.linesConflict&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(W,{title:U(`linesChanged`),error:Error(U(`linesReloaded`))})}),C!==`form`&&ne&&p.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:U(`unsavedKept`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(q,{to:oe,className:tt({size:`sm`}),children:U(`continueEditing`)}),(0,J.jsx)(K,{size:`sm`,onClick:p.discard,children:U(`discard`)})]})]}),C===`form`&&p.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:U(`unsavedRestored`)}),(0,J.jsxs)(`span`,{className:`flex gap-2`,children:[(0,J.jsx)(K,{size:`sm`,onClick:p.dismissRestored,children:U(`keep`)}),(0,J.jsx)(K,{size:`sm`,onClick:p.discard,children:U(`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:[xe.flatMap(L),M&&(0,J.jsx)(lr,{tabs:Se.map((e,t)=>({title:e.title,to:k(T,ie,t===0?void 0:e.title),current:e===M}))}),M&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:M.items.flatMap(L)},`tab:${M.title}`),Te.flatMap(L)]}),(0,J.jsxs)(`aside`,{className:`space-y-4 md:sticky md:top-[var(--pb-sticky-top,0px)] md:max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px))] md:self-start md:overflow-y-auto md:pb-4 md:pt-8`,children:[Be&&(0,J.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Be}),!r&&(0,J.jsx)(Wr,{model:e,stored:n,recordKey:t,edit:ne?oe:void 0,onDelete:ze}),Ie===-1&&Le,ye.map((e,t)=>(e.kind===`custom`||e.kind===`map`)&&e.sidebar&&!r?Ve(e,t):t===Ie?(0,J.jsx)(Y.Fragment,{children:Le},`summary`):null),(0,J.jsx)(Kn,{title:U(`details`),rows:[_r(e,`created`),ke].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!Ae(t)||N.includes(t)?[]:[{label:P(t)?.label??V(t),value:F(t)?(0,J.jsx)(`span`,{title:Jt(r,n.record[t],void 0,P(t)),children:Bt(r,n.record[t],P(t))}):(0,J.jsx)(G,{className:`h-4 w-24`})}]})}),!r&&(0,J.jsx)(Na,{model:e,recordKey:t,layout:ye})]})]})]})}),Be&&(0,J.jsx)(`div`,{className:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20 flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden`,children:Be})]})};export{no as RecordPage,hr as t};
3
- //# debugId=c982c724-b390-4580-86f3-e90d82714127
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-view-CoLu3Uhs.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/react-CuiNlnus.js","assets/app-B8KcM2Z-.js","assets/vendor-t7Q7QbPu.js","assets/app-DLkpxjgP.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{$c as r,$o as i,Ao as a,B as o,Bi as s,Bl as c,Bn as l,Br as u,Bs as d,C as f,Ca as p,Cs as m,D as h,Da as g,Ds as _,Ec as v,En as y,Es as b,F as x,Ft as S,Gc as C,Gn as w,Gs as T,Ho as ee,Hs as E,Ic as te,In as ne,Ir as re,It as ie,Ja as ae,Jl as oe,Jo as D,Ka as se,Ko as ce,Ks as le,La as ue,Ln as de,Ls as fe,M as pe,Ms as me,Mt as he,Nl as ge,Ns as _e,Nt as ve,On as ye,Os as be,Pa as xe,Pl as Se,Ps as Ce,Pt as we,Qi as Te,Qo as O,Qs as Ee,Qt as De,R as Oe,Ra as ke,Rn as Ae,Rs as je,Sc as Me,Si as Ne,Ss as k,Tn as Pe,Ts as A,Uo as Fe,Ur as Ie,Us as Le,V as Re,Vl as ze,Vs as Be,Wc as j,Ws as Ve,Xn as He,Xo as Ue,Xt as We,Ya as Ge,Yo as M,Zi as Ke,Zn as qe,Zo as N,_ as Je,_a as Ye,_n as Xe,_t as Ze,aa as Qe,ac as $e,an as et,ao as tt,as as P,at as nt,b as rt,ba as it,bn as at,cc as F,cn as ot,co as st,cr as ct,cs as lt,da as ut,dc as dt,dl as ft,dn as pt,dr as mt,ea as ht,ec as gt,el as _t,er as vt,es as I,fc as yt,fl as bt,fn as xt,fr as St,fs as Ct,gl as wt,gn as Tt,gr as L,gt as Et,hn as Dt,ho as Ot,hr as R,i as kt,ia as At,in as jt,ir as Mt,ji as Nt,js as Pt,k as Ft,kc as It,ks as Lt,ll as Rt,ln as zt,lr as z,ls as Bt,mr as B,nc as Vt,no as Ht,ns as V,on as H,oo as Ut,or as Wt,os as Gt,pr as Kt,qa as U,qo as qt,qt as Jt,rc as Yt,rl as Xt,rn as Zt,rr as Qt,rs as $t,s as en,sc as W,sl as tn,tc as nn,tn as rn,tr as an,ts as on,uc as G,un as sn,ur as K,v as cn,va as ln,vi as un,vl as dn,vn as fn,wa as pn,wi as mn,ws as hn,wt as gn,xn as _n,xs as q,y as vn,ya as yn,yn as bn,zc as xn,zn as Sn,zr as Cn,zs as wn}from"./app-B8KcM2Z-.js";import{C as Tn,f as En,o as Dn,s as On}from"./vendor-t7Q7QbPu.js";import{C as kn,Ct as An,Dt as jn,Et as Mn,Mt as Nn,O as Pn,Ot as Fn,Q as In,St as Ln,Tt as Rn,X as zn,Z as Bn,_t as Vn,at as Hn,b as Un,ct as Wn,dt as Gn,ft as Kn,gt as qn,it as Jn,k as Yn,kt as Xn,l as Zn,lt as Qn,mt as $n,n as er,nt as tr,o as nr,ot as rr,rt as ir,st as ar,t as or,tt as sr,ut as cr,wt as lr,x as ur,xt as dr,y as fr}from"./embedded-list-C3nd1V5o.js";import{t as pr}from"./circle-alert-DOaXkZQv.js";import{t as mr}from"./page-header-Ddz2r5ic.js";import{n as hr,t as gr}from"./pending-invitation-row-t63yAwI8.js";import{n as _r,t as vr}from"./person-row-CgvcHRmL.js";import{n as yr,t as br}from"./use-paged-search-CxaSlMkh.js";import{n as xr,t as Sr}from"./client-publisher-D39SlIhp.js";import{t as Cr}from"./copy-field-Ct-6xn8T.js";var wr={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};wr.node;var Tr=j(wr),Er={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};Er.node;var Dr=j(Er),Or={name:`key-square`,size:24,node:[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]};Or.node;var kr=j(Or),Ar={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Ar.node;var jr=j(Ar),Mr={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};Mr.node;var Nr=j(Mr),Pr={name:`shield-user`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M6.376 18.91a6 6 0 0 1 11.249.003`,key:`hnjrf2`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}]]};Pr.node;var Fr=j(Pr),Ir={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ir.node;var Lr=j(Ir),Rr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Rr.node;var zr=j(Rr),Br=[`done`,`error`,`running`];T(`TextField`,!1),T(`NumberField`,!1),T(`DateField`,!1),T(`BooleanField`,!1),T(`UrlField`,!1),T(`ChipField`,!1);var Vr=new Set([`TextField`,`NumberField`,`DateField`,`BooleanField`,`UrlField`,`ChipField`]),Hr=e=>typeof e!=`string`&&!e.custom&&Vr.has(e.type),Ur=e=>typeof e==`string`||Hr(e)||!e.custom&&(e.type===`Link`||e.type===`Trans`||e.type===`Text`&&[`span`,`strong`,`em`].includes(String(e.props.as))),Wr=(e,t)=>e===`BooleanField`?t!==!0&&t!==!1:e===`NumberField`||e===`UrlField`?t==null:t==null||t===``,Gr=e=>typeof e==`object`&&e?JSON.stringify(e):String(e),Kr=(e,{locales:t,options:n},r)=>{let i=typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))?Number(e):e;return typeof i==`number`?i.toLocaleString(t??r,n):String(i)},qr=(e,t,n)=>{let r=e instanceof Date?e:typeof e==`string`||typeof e==`number`?new Date(e):void 0;if(!r||Number.isNaN(r.getTime()))return``;if(t.format===`relative`)return n.relative(Math.round((n.now-r.getTime())/1e3));let{showDate:i=!0,showTime:a=!1,options:o}=t,s=t.locales??n.locale;if(i&&a)return r.toLocaleString(s,o);if(a)return r.toLocaleTimeString(s,o);let c=o??(typeof e==`string`&&e.length<=10?{timeZone:`UTC`}:void 0);return r.toLocaleDateString(s,c)},Jr=(e,t,n)=>e?t.valueLabelTrue??n.yes:t.valueLabelFalse??n.no,Yr=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Xr=e=>{let t=e.replace(/^[\u0000- ]+/,``).replace(/[\t\n\r]/g,``),n=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(t)?.[1];return n===void 0?t.startsWith(`/`)||!t.includes(`:`)?e:void 0:Yr.has(`${n.toLowerCase()}:`)?e:void 0},Zr=({layout:e,cardWidth:t})=>({layout:e??`stack`,cardWidth:t??`2/3`}),Qr=e=>e==null||e===``?void 0:String(e),$r=(e,t)=>e<t?-1:+(e>t),ei=({nodes:e,edges:t,key:n,edgeKey:r,fields:i})=>{let a=new Map,o=new Map;for(let t of e){let e=Qr(t[n]);if(e===void 0||a.has(e))continue;let r=i.group===void 0?void 0:t[i.group],s=Qr(r);s!==void 0&&!o.has(s)&&o.set(s,{id:s,value:r}),a.set(e,{id:e,row:t,...s!==void 0&&{group:s}})}let s=t.flatMap(e=>{let t=r.map(t=>Qr(e[t])),n=t.includes(void 0)?void 0:t.length===1?t[0]:JSON.stringify(t),o=Qr(e[i.source]),s=Qr(e[i.target]);return n===void 0||o===void 0||s===void 0||!a.has(o)||!a.has(s)?[]:[{id:n,source:o,target:s,row:e}]});return{groups:[...o.values()].sort((e,t)=>$r(e.id,t.id)),nodes:[...a.values()].sort((e,t)=>$r(e.id,t.id)),edges:s.sort((e,t)=>$r(e.source,t.source)||$r(e.target,t.target)||$r(e.id,t.id))}},J=e(t(),1),Y=e(n(),1),ti=({model:e,items:t,name:n,label:r,variant:i,className:a})=>{let{views:o}=P(),c=An(e.name,void 0),l=s(),[u,d]=(0,J.useState)(!1),f=o[e.name]?.actions?.find(e=>e.name===n);if(!f||f.run?.kind===`link`)return null;let p=t.map(t=>Tt(e,t)),m=p.filter(e=>c.verdictOn(f,e)!==`skip`);if(m.length===0)return null;let h=p.length-m.length,g=dr(`actionCount`,{label:r??f.label,count:m.length}),_=e=>c.runEach(f,m,h,e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{size:`sm`,variant:i??f.variant??`secondary`,className:a,loading:c.running===n,onClick:()=>Mn(f)?d(!0):void _(),children:g}),u&&(0,Y.jsx)(Rn,{action:f,label:g,danger:i===`danger`||i===void 0&&jn(f),records:m.map(e=>e.record),names:m.map(t=>Ln(l(e,o[e.name],t.record,t.key))),onCancel:()=>d(!1),onConfirm:()=>{d(!1),_()},onSubmit:async e=>{d(!1),await _(e)}})]})},ni=({name:e,resource:t,label:n,variant:r,className:i,about:a,onRun:o})=>{let s=ct(),c=lr(t??s?.model.name??``,e,t===void 0||t===s?.model.name?s:void 0,e=>o?.(n??e.label)),[l,u]=(0,J.useState)(!1);if(!c.action)return null;let d=n??c.action.label,f=r??c.action.variant??`secondary`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{size:`sm`,variant:f,className:i,loading:c.running,disabled:!!c.blocked,title:c.blocked,"aria-label":a===void 0?void 0:`${d}: ${a}`,onClick:()=>Mn(c.action)?u(!0):void c.run(),children:d}),l&&(0,Y.jsx)(Rn,{action:c.action,label:d,danger:f===`danger`,records:c.record?[c.record]:[],onCancel:()=>u(!1),onConfirm:()=>{u(!1),c.run()},onSubmit:async e=>{await c.submit(e),u(!1)}})]})},ri=({node:e,className:t})=>{let n=H(e),r=Kt(),i=r?.model;return i&&(n.resource===void 0||n.resource===i.name)?(0,Y.jsx)(ti,{...n,model:i,items:r.items,className:t}):(0,Y.jsx)(ni,{...n,className:t})},ii=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a}=H(e);return(0,Y.jsx)(B,{title:i,description:a,actions:n.actions,className:C(`h-full`,r),children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})})},ai=({children:e,wrap:t=(e,t)=>(0,Y.jsx)(J.Fragment,{children:e},t)})=>{let n=Kt();if(!n)return null;let{model:r,items:i,planned:a}=n;return i.map((n,o)=>{let s=r?{...Tt(r,n),...a&&{planned:a}}:{item:n},c=`key`in s?s.key:o;return t((0,Y.jsx)(Mt,{value:s,row:{index:o,count:i.length},children:e}),c)})},oi=({children:e})=>(0,Y.jsx)(ai,{children:e}),si=({model:e,at:t,filter:n,sort:r,limit:i=12,title:a,description:o,empty:s,actions:c,children:l,className:u})=>{let d=Zt(t),f=bn(e,{filter:n,sort:r,pageSize:i,enabled:!d}),p=d??f,m=d?d.rows:f.data?.items??[];return(0,Y.jsx)(B,{title:a,description:o,actions:c,className:u,children:p.isPending?(0,Y.jsx)(`div`,{className:`flex gap-3`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(W,{className:`h-24 w-56`},t))}):p.error?(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:p.error}):m.length===0?(0,Y.jsx)(R,{children:s??U(`nothingYet`)}):(0,Y.jsx)(`ul`,{className:`relative -mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1`,children:(0,Y.jsx)(mt,{value:{model:e,items:m,...d&&{planned:!0}},children:(0,Y.jsx)(ai,{wrap:(e,t)=>(0,Y.jsx)(`li`,{className:`flex w-60 shrink-0 snap-start flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:e},t),children:l})})})})},ci=({node:e,at:t,children:n,slots:r})=>{let{resource:i,...a}=H(e),o=P().resources[i];return o?(0,Y.jsx)(si,{...a,model:o,...t!==void 0&&{at:t},actions:r.actions,children:n}):null},li=({node:e,slots:t,className:n})=>{let{resource:r,title:i,description:a,actions:o,span:s,className:c,...l}=H(e),{resources:u,views:d}=P(),f=u[r];return f?(0,Y.jsx)(B,{title:i,description:a,actions:t.actions,className:C(`h-full`,n),children:(0,Y.jsx)(Kn,{model:f,view:d[r],...l})}):null},ui=({model:e,query:t,className:n=`mt-4 border-t pt-4`,children:r})=>{let i=fn(e,t),a=i.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(W,{className:`h-4 w-1/2`}),(0,Y.jsx)(W,{className:`h-4 w-1/3`})]}):i.error?(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:i.error}):i.data?(0,Y.jsx)(Mt,{value:i.data,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:r})}):(0,Y.jsx)(R,{children:U(`nothingYet`)});return(0,Y.jsx)(`div`,{className:n,children:a})},di=e=>{if(typeof e!=`string`&&typeof e!=`number`)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},fi=e=>e==null?``:String(e),X=(e,t,n)=>n===0?0:(e-t)/n*100,pi=(e,t,n)=>{let r=new Map;for(let i of e){let e=di(i[t.start]);if(e===void 0)continue;let a=di(i[t.end]),o=Math.max(e,a??n),s=r.get(fi(i[t.lane]))??{value:i[t.lane],bars:new Map};r.set(fi(i[t.lane]),s);let c=s.bars.get(fi(i[t.bar]))??{value:i[t.bar],records:[]};s.bars.set(fi(i[t.bar]),c),c.records.push({record:i,start:e,end:o,open:a===void 0})}return r},mi=e=>{let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.find(e=>e.at(-1).end<=n.start);e?e.push(n):t.push([n])}return t},hi=(e,t,n)=>{let r=pi(e,t,n),i=[...r.values()].flatMap(e=>[...e.bars.values()].flatMap(e=>e.records));if(i.length===0)return{lanes:[],from:n,to:n};let a=Math.min(...i.map(e=>e.start)),o=Math.max(...i.map(e=>e.end)),s=o-a;return{lanes:[...r.entries()].map(([e,n])=>{let r=[...n.bars.entries()].map(([e,r])=>{let i=r.records.sort((e,t)=>e.start-t.start).map(({record:e,start:n,end:r,open:i})=>({record:e,value:e[t.color],start:n,end:r,open:i,left:X(n,a,s),width:X(r,a,s)-X(n,a,s)})),o=i[0].start,c=Math.max(...i.map(e=>e.end));return{key:e,value:r.value,lane:n.value,start:o,end:c,left:X(o,a,s),width:X(c,a,s)-X(o,a,s),segments:i}});return{key:e,value:n.value,rows:mi(r)}}),from:a,to:o}},gi=(e,t)=>{let n=e.end-e.start;return{left:X(t.start,e.start,n),width:n===0?100:(t.end-t.start)/n*100}},_i=6e4,vi=60*_i,Z=24*vi,yi=[5*_i,15*_i,30*_i,vi,3*vi,6*vi,12*vi,Z,2*Z,7*Z,14*Z,30*Z,90*Z,365*Z],bi=365*Z,xi=(e,t,n,r,i)=>Math.floor((t+i)/n)-Math.ceil((e+r)/n)+1,Si=(e,t,n=()=>0)=>{let r=t-e;if(r<=0)return{daily:!1,ticks:[]};let i=n(e),a=n(t),o=yi.find(n=>xi(e,t,n,i,a)<=6)??Math.ceil(r/5/bi)*bi,s=[];for(let c=Math.ceil((e+i)/o)*o;c<=t+a;c+=o){let a=c-n(c-i);a+n(a)===c&&a>=e&&a<=t&&s.push({at:a,left:X(a,e,r)})}return{daily:o>=Z,ticks:s}},Ci=e=>({lane:fi(e.lane),bar:e.key}),wi=(e,t)=>t?e.lanes.find(e=>e.key===t.lane)?.rows.flat().find(e=>e.key===t.bar)??null:null,Ti=(e,t)=>{let n=Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}).formatToParts(e).map(e=>[e.type,e.value]));return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))-Math.floor(e/6e4)*6e4},Ei=e=>e<8?`translate-x-0`:e>92?`-translate-x-full`:`-translate-x-1/2`,Di=({from:e,to:t,dated:n})=>{let r=n?`UTC`:ut(),i=e=>n?0:Ti(e,r),{daily:a,ticks:o}=Si(e,t,i);return(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`relative h-5 min-w-0 flex-1 border-b border-border text-xs text-muted-foreground tabular-nums`,children:o.map(e=>(0,Y.jsx)(`span`,{className:`absolute bottom-1 whitespace-nowrap ${Ei(e.left)}`,style:{left:`${e.left}%`},children:a?ht(e.at+i(e.at)):Qe(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&&dn(a)?{className:on[a],striped:i}:{color:qn(e,t,n===void 0?null:n,-1),striped:i}},ki=e=>({...e.color!==void 0&&{backgroundColor:e.color},...e.striped&&{backgroundImage:`repeating-linear-gradient(-45deg, transparent 0 4px, color-mix(in srgb, var(--background) 55%, transparent) 4px 6px)`}}),Ai=({bar:e,field:t,hints:n})=>e.segments.map((r,i)=>{let a=Oi(t,n,r.value),{left:o,width:s}=gi(e,r);return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:C(`absolute inset-y-0`,a.className),style:{left:`${o}%`,width:`${s}%`,...ki(a)}},i)}),ji=(e,t)=>t?Ke(e):Te(e),Mi=(e,t,n,r,i)=>{let a=e.fields[t.start]?.type===`date`;return U(`timelineRange`,{from:ji(n,a),to:i?U(`timelineNow`):ji(r,a)})},Ni=(e,t,n,r)=>`${un(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??un(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=P().resources[t.fields[r.bar]?.relation?.resource??``],s=ye(o??t,e.key,o!==void 0),c=Pi(e,t,n,r,o?s:void 0),l={onMouseEnter:()=>i.hover(e),onMouseLeave:()=>i.hover(null),onFocus:()=>i.focus(e),onBlur:()=>i.focus(null)},u={left:`${e.left}%`,width:`max(${e.width}%, 4px)`},d=(0,Y.jsx)(Ai,{bar:e,field:t.fields[r.color],hints:n?.fields[r.color]});if(!a)return(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":c,style:u,className:Fi,...l,children:d});let f=a.chosen===e.key;return(0,Y.jsx)($e,{to:a.barTo(e.key),"aria-label":c,"aria-current":f?`true`:void 0,style:u,className:C(Fi,f&&`ring-2 ring-foreground`),...l,children:d})},Li=({shape:e,...t})=>{let{model:n,fields:r}=t,i=n.fields[r.lane];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex sm:pl-40`,children:(0,Y.jsx)(Di,{from:e.from,to:e.to,dated:n.fields[r.start]?.type===`date`})}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3 sm:gap-2`,children:e.lanes.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium sm:w-40 sm:shrink-0 sm:pr-3`,children:(0,Y.jsx)(_n,{model:n,field:i,value:e.value})}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 border-l border-border pl-px`,children:e.rows.map((e,n)=>(0,Y.jsx)(`div`,{className:`relative h-6 overflow-x-clip`,children:e.map(e=>(0,Y.jsx)(Ii,{bar:e,...t},e.key))},n))})]},e.key))})]})},Ri=({model:e,view:t,fields:n,value:r})=>{let i=Oi(e.fields[n.color],t?.fields[n.color],r);return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:C(`inline-block size-3 shrink-0 rounded-sm`,i.className),style:ki(i)})},zi=({values:e,...t})=>{let n=t.model.fields[t.fields.color],r=(n.enumValues??[]).filter(t=>e.has(t));return(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:r.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ri,{...t,value:e}),un(n,e,t.view?.fields[t.fields.color])]},e))})},Bi=({bar:e,...t})=>{let{model:n,view:r,fields:i}=t;if(!e)return(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:U(`timelinePoint`)});let a=e.segments.some(t=>t.open&&t.end===e.end);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:(0,Y.jsx)(_n,{model:n,field:n.fields[i.bar],value:e.value})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:Mi(n,i,e.start,e.end,a)})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:e.segments.map((e,a)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(Ri,{...t,value:e.value}),un(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:i,fields:a,limit:o})=>({queryKey:[...r.list(t.name,n,i,o,`timeline`),a.join(`,`)],queryFn:async()=>{let r=[],s;do{let c=await e.list(t.name,{filter:n||void 0,orderBy:i,pageSize:Math.min(Vi,o-r.length),fields:a,etag:!1,...s&&{pageToken:s}});r.push(...c.items),s=c.nextPageToken||void 0}while(s&&r.length<o);return{rows:r.toReversed(),cut:s!==void 0}}}),Ui=(e,{enabled:t=!0,...n})=>Dn({...Hi(Ct(),e,n),enabled:t,placeholderData:En}),Wi=({model:e,view:t,fields:n,readSort:r,at:i,filter:a,limit:o=d,title:s,description:c,empty:l,actions:u,className:f,choose:p,details:m})=>{let[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),y=e=>e?Ci(e):null,b={hover:e=>g(y(e)),focus:e=>v(y(e))},x=Zt(i),S=Ui(e,{filter:a,sort:r,fields:[...new Set([...Object.values(n),...e.primaryKey])],limit:o,enabled:!x}),w=x??S,T=x?x.rows:S.data?.rows??[],ee=!x&&S.data?.cut===!0,E=hi(T,n,Date.now());return(0,Y.jsxs)(B,{title:s,description:c,actions:u,className:C(`h-full`,f),children:[(()=>{if(w.isPending)return(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Y.jsx)(W,{className:`h-6`},t))});if(w.error)return(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:w.error});if(E.lanes.length===0)return(0,Y.jsx)(R,{children:l??U(`nothingYet`)});let r=new Set(T.map(e=>String(e[n.color])));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(zi,{model:e,view:t,fields:n,values:r}),(0,Y.jsx)(Li,{shape:E,model:e,view:t,fields:n,point:b,...p&&{choose:p}}),ee&&(0,Y.jsx)(R,{children:U(`timelineCut`,{count:T.length})}),(0,Y.jsx)(`div`,{"aria-live":`polite`,children:(0,Y.jsx)(Bi,{bar:wi(E,h)??wi(E,_),model:e,view:t,fields:n})})]})})(),m]})},Gi=(e,t)=>e.type===`integer`?Number(t):t,Ki=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=an(),a=r[e],o=t=>i({[e]:t}),s=n.model.fields[n.fields.bar],c=a===void 0?null:(0,Y.jsx)(Yt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{filter:Vn(s,Gi(s,a),n.filter),sort:n.sort},children:t},a)});return(0,Y.jsx)(Wi,{...n,choose:{barTo:o,chosen:a},details:c})},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}=H(e),{resources:h,views:g}=P(),_=h[o];if(!_)return null;let v={...m,model:_,view:g[_.name],fields:{lane:c,bar:l,start:u,end:d,color:f},readSort:Be(e),sort:E(e),...t!==void 0&&{at:t},actions:n.actions,className:i};return s===void 0?(0,Y.jsx)(Wi,{...v}):(0,Y.jsx)(Ki,{...v,select:s,children:r})},Ji=({node:e,children:t})=>{let n=Ve(e),r=Qt(),{resources:i}=P();if(!n||!r)return t;let a=r.given[n.param],o=n.resource===void 0?void 0:i[n.resource];return a===void 0||!o?null:(0,Y.jsx)(Yt,{name:n.param,children:(0,Y.jsx)(ui,{model:o,query:{key:a},className:``,children:t},a)})},Yi=(0,J.lazy)(()=>Tn(()=>import(`./graph-view-CoLu3Uhs.js`).then(e=>({default:e.GraphView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Xi=(0,Y.jsx)(`div`,{className:`flex h-64 w-full items-center justify-center`,children:(0,Y.jsx)(yt,{})}),Zi=({node:e,at:t,slots:n,children:r,className:i})=>{let a=H(e),o=rn(e,t),s=Qt(),c=o.nodes,l=o.edges,{label:u,group:d,status:f,source:p,target:m}=a,h=(0,J.useMemo)(()=>({label:u,source:p,target:m,...d!==void 0&&{group:d},...f!==void 0&&{status:f}}),[u,p,m,d,f]),g=JSON.stringify([c?.rows,l?.rows,h]),_=(0,J.useMemo)(()=>c&&l&&ei({nodes:c.rows,edges:l.rows,key:c.model.primaryKey[0],edgeKey:l.model.primaryKey,fields:h}),[g]);if(!c||!l||!_)return null;let v=c.error??l.error;if(v&&e.fallback)throw v;if(v)return(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:v});if(c.isPending||l.isPending)return Xi;if(_.nodes.length===0)return(0,Y.jsx)(R,{children:a.empty??U(`nothingYet`)});let y=a.select,b=y!==void 0&&s?{chosen:s.given[y],linkTo:e=>s.linkTo({[y]:e})}:void 0;return(0,Y.jsxs)(`div`,{className:C(`flex flex-col gap-4 lg:flex-row`,i),children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(J.Suspense,{fallback:Xi,children:(0,Y.jsx)(Yi,{shape:_,nodes:c,edges:l,fields:h,props:a,...b&&{select:b},...a.node!==void 0&&{content:n.node}})})}),r.length>0&&b?.chosen!==void 0&&(0,Y.jsx)(`div`,{className:`min-w-0 lg:w-80 lg:shrink-0`,children:(0,Y.jsx)(Ji,{node:e,children:r})})]})},Q=_t(`app/conversation`),Qi=({resource:e,field:t,values:n,placeholder:r,searchPeople:i,mentions:a})=>{let{resources:o}=P(),s=Ct(),c=at(),l=Gt(e),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)();return!o[e]||!g(l,`create`)?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[f!==void 0&&(0,Y.jsx)(L,{title:Q(`notSent`),error:f}),(0,Y.jsx)(gn,{onSend:async(r,i)=>{d(!0),p(void 0);let o=await s.create(e,{...n,[t]:r,...a!==void 0&&{[a]:i}}).then(()=>!0,e=>(p(e),!1));return d(!1),o&&c(e),o},busy:u,placeholder:r,searchPeople:i})]})},$i=({node:e})=>{let{resource:t,field:n,values:r,placeholder:i}=H(e);return(0,Y.jsx)(Qi,{resource:t,field:n,values:r,placeholder:i})},ea=({node:e,children:t,className:n})=>{let{open:r}=H(e);return(0,Y.jsx)(`details`,{open:r,className:C(`[&[open]>summary]:mb-2`,n),children:t})},ta=({children:e,className:t})=>(0,Y.jsx)(`summary`,{className:C(`cursor-pointer font-medium`,t),children:e}),na=({node:e,className:t})=>{let{source:n,emptyText:r}=H(e),i=pt(n);if(i.state===`missing`)return null;if(i.state===`loading`)return(0,Y.jsx)(W,{className:C(`h-24 w-full`,t)});if(i.value===null||i.value===void 0||i.value===``)return r?(0,Y.jsx)(`p`,{className:C(`text-sm text-muted-foreground`,t),children:r}):null;let a=String(i.value),o=Et(a);return o?(0,Y.jsx)(`div`,{className:C(`flex flex-col gap-3`,t),children:o.map((e,t)=>(0,Y.jsx)(Ze,{source:e.lines,path:e.path,split:!0,className:`rounded-md border border-border`},`${t}-${e.path}`))}):(0,Y.jsx)(`pre`,{className:C(`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=>bt(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},aa=({node:e,className:t})=>{let{source:n,label:r,format:i}=H(e),{views:a}=P(),o=pt(n);if(o.state===`missing`)return null;let s=o.state===`loading`?(0,Y.jsx)(W,{className:`h-4 w-24`}):o.state===`plain`?ra(o.value):(0,Y.jsx)(_n,{model:o.model,field:o.field,value:o.value,format:i});if(r===!1)return(0,Y.jsx)(`div`,{className:t,children:s});let c=r??ia(n,o.state===`ready`?a[o.model.name]?.fields[o.field.name]?.label:void 0);return(0,Y.jsxs)(`div`,{className:C(`min-w-0`,t),children:[(0,Y.jsx)(`div`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate`,children:s})]})},oa={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},sa={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},ca={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},la=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,ua=({node:e,children:t,className:n})=>{let{columns:r=2}=H(e),i=e.children,a=i.length>0&&i.every(la);return(0,Y.jsx)(`div`,{className:C(`grid grid-cols-1 gap-4`,a?sa[r]:oa[r],n),children:t.map((e,t)=>{let n=i[t],r=typeof n==`object`?n.props.span:void 0;return(0,Y.jsx)(`div`,{className:C(`min-w-0`,r&&ca[r]),children:e},t)})})},da=({src:e,alt:t,width:n,height:r,className:i})=>(0,Y.jsx)(`img`,{src:e,alt:t??``,width:n,height:r,className:i??`max-w-full`}),fa=({width:e,height:t,space:n,theme:r})=>{let i=e??Math.ceil(n/100)*100;if(i!==0)return{width:String(i),...t!==void 0&&{height:String(t)},theme:r}},pa=e=>({staleTime:1/0,refetchOnWindowFocus:!1,...e!==void 0&&{refetchInterval:e*1e3}}),ma=e=>e instanceof Blob&&e.type.startsWith(`image/`),ha=e=>{let[t,n]=(0,J.useState)();return(0,J.useEffect)(()=>{if(!e)return n(void 0);let t=URL.createObjectURL(e);return n(t),()=>URL.revokeObjectURL(t)},[e]),t},ga=e=>{let[t,n]=(0,J.useState)();return[t!==void 0&&t===e,()=>n(e)]},_a=({name:e,alt:t,width:n,height:i,refresh:a,className:o})=>{let s=Ct(),{theme:c}=ke(),[l,u]=nt(),d=fa({width:n,height:i,space:u,theme:c}),f=Dn({queryKey:r.image(e,d??{}),enabled:d!==void 0,placeholderData:En,...pa(a),queryFn:async()=>{let t=await s.invoke(e,{query:d,cache:`no-store`});if(!ma(t))throw Error(`The function "${e}" answered no picture`);return t}}),p=ha(f.data),[m,h]=ga(p),g={...n!==void 0&&{width:n},...i!==void 0&&{height:i}};return(0,Y.jsx)(`div`,{ref:l,className:C(`min-w-0`,o),children:f.isError||m?t&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t}):p?(0,Y.jsx)(`img`,{src:p,alt:t??``,onError:h,style:g,className:n===void 0?`w-full max-w-full object-contain`:`max-w-full object-contain`}):(0,Y.jsx)(W,{className:`w-full max-w-full`,style:{height:i??160,...n!==void 0&&{width:n}}})})},va=({node:e,className:t})=>{let n=H(e);return n.src===void 0?(0,Y.jsx)(_a,{name:n.function,alt:n.alt,width:n.width,height:n.height,refresh:n.refresh,className:t}):(0,Y.jsx)(da,{src:n.src,alt:n.alt,width:n.width,height:n.height,className:t})},ya=e=>function({node:t,className:n}){let r=H(t),{views:i}=P(),a=pt(r.source);return a.state===`missing`?null:a.state===`loading`?(0,Y.jsx)(W,{className:`inline-block h-3 w-16 align-middle`}):Wr(t.type,a.value)?r.emptyText?(0,Y.jsx)(`span`,{className:n,children:r.emptyText}):null:a.state===`plain`?(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:void 0,hints:void 0,props:r})}):(0,Y.jsx)(`span`,{className:n,children:e({value:a.value,field:a.field,hints:i[a.model.name]?.fields[a.field.name],props:r})})},ba=({value:e,field:t,hints:n})=>t?.type===`enum`&&typeof e==`string`?ft(e,n?.valueLabels):Gr(e),xa=ya(ba),Sa=ya(({value:e,props:t})=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Kr(e,t,Xt())})),Ca=ya(({value:e,props:t})=>{let n=qr(e,t,{locale:Xt(),now:Date.now(),relative:At});return(0,Y.jsx)(`time`,{dateTime:String(e),children:n})}),wa=ya(({value:e,props:t})=>{let n=Jr(e,t,{yes:Nt(`yes`),no:Nt(`no`)});return e?(0,Y.jsx)(w,{label:n,className:`align-middle`}):(0,Y.jsx)(`span`,{className:`text-faint-foreground`,children:n})}),Ta=ya(({value:e,props:t})=>{let n=String(e),r=t.content??n,i=Xr(n);return i===void 0?r:(0,Y.jsx)(`a`,{href:i,className:`font-medium text-primary-text hover:underline`,.../^https?:/i.test(i)&&{target:`_blank`,rel:`noreferrer`},children:r})}),Ea=ya(e=>(0,Y.jsx)(y,{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=H(e),i={...K(z()),params:vt()},a=r.variant?C(dt({variant:r.variant}),n):n??Da,o=e.children.some(e=>typeof e!=`string`||e.trim()!==``)?t:void 0;if(r.to){let e=c(r.to,be(i));return(0,Y.jsx)(Cn,{to:e,className:a,children:o??Ee(e)})}let s=r.href??``;return(0,Y.jsx)(`a`,{href:s,className:a,...s.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:o??s})},ka=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.[t]??null];if(n)return[t,r.type===`boolean`?!!n[t]:h(n[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:h(i)]})),Aa=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return en(r)?r.key===h(n[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:f(i,r,n[t])?[[t,Ft(i,r)]]:[]})),ja=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=P(),u=Ct(),d=ue(),f=at(),p=l[e.name],[m,h]=(0,J.useState)(()=>ka(e,a,t?.record)),[g,_]=(0,J.useState)({}),[v,y]=(0,J.useState)(0),b=Je(v),[x,S]=(0,J.useState)(),[C,w]=(0,J.useState)(!1),[T,ee]=(0,J.useState)(!1);nn(T||C,`input-lost`);let E=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...kt(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:U(`saved`,{label:i??r})}),s()},e=>{let t=cn(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,Y.jsx)(F,{title:i??r,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:s,children:U(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:C,onClick:()=>void E(),children:U(n===`create`?`create`:`save`)})]}),children:(0,Y.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),E()},children:[x!==void 0&&Object.keys(g).length===0&&(0,Y.jsx)(L,{title:U(`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??bt(n),s=g[n];return(0,Y.jsx)(Oe,{name:n,label:o,help:p?.fields[n]?.help,error:s&&vn(r,o,s),children:(0,Y.jsx)(rt,{field:r,hints:p?.fields[n],value:en(i)?i.key:i,stored:t?.record[n],relationLabel:en(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),ee(!0),h(t=>({...t,[n]:e}))}})},n)})]})})},Ma=({model:e,recordKey:t,children:n})=>{let r=fn(e,{key:t});return(0,Y.jsx)(Y.Fragment,{children:n(r.data??void 0)})},Na=({node:e})=>{let t=H(e),n=ct(),{resources:r}=P(),i=r[t.resource??n?.model.name??``],a=Gt(i?.name??``),[o,s]=(0,J.useState)(!1);if(!i||!(t.mode===`create`?g(a,`create`):g(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,Y.jsx)(ja,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,Y.jsx)(Ma,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},Pa=({node:e,children:t,slots:n,className:r})=>{let{title:i,description:a,width:o}=H(e);return(0,Y.jsx)(`div`,{className:C(`flex-1`,r),children:(0,Y.jsxs)(`div`,{className:C(`flex flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,o!==`full`&&`mx-auto max-w-[1200px]`),children:[(0,Y.jsx)(mr,{title:i,subtitle:a,actions:n.actions}),t]})})},Fa=(e,t)=>{let n=z(),r=typeof e==`string`?Wt(n,e):void 0,i=zt(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}=H(e),a=Fa(n,0),o=Fa(r,100);if(a===void 0||o===void 0)return(0,Y.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,Y.jsxs)(`div`,{className:C(`min-w-0`,t),children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[a.toLocaleString(Xt()),` / `,o.toLocaleString(Xt())]})]}),(0,Y.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,Y.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=Zt(t),f=fn(e,{filter:n,sort:r,key:i,enabled:!d}),p=d?Dt(e,d):f,m=e=>p.data?(0,Y.jsx)(Mt,{value:p.data,children:e}):void 0,h=p.isPending?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(W,{className:`h-4 w-1/2`}),(0,Y.jsx)(W,{className:`h-4 w-1/3`})]}):p.error?(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:p.error}):p.data?m((0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l})):(0,Y.jsx)(R,{children:s??U(`nothingYet`)});return(0,Y.jsx)(B,{title:a,description:o,actions:c?m(c):void 0,className:C(`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}=H(e),f=P().resources[a];return f?(0,Y.jsx)(La,{model:f,...t!==void 0&&{at:t},filter:o,sort:s,recordKey:c,title:l,description:u,empty:d,actions:r.actions,className:i,children:n}):null},za=_t(`app/related-cards`),Ba=({children:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1);return(0,J.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,Y.jsx)(`div`,{className:C(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,Y.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,Y.jsx)(G,{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}=P(),a=zt(e,t);if(a.state===`missing`||a.state===`ready`&&Va(a.value))return null;let o=a.state===`loading`?(0,Y.jsx)(W,{className:`h-4 w-24`}):(0,Y.jsx)(_n,{model:a.model,field:a.field,value:a.value}),s=r?(0,Y.jsx)(Ba,{children:o}):o;if(!n)return(0,Y.jsx)(`div`,{className:`min-w-0`,children:s});let c=ia(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:c}),(0,Y.jsx)(`dd`,{className:`mt-0.5`,children:s})]})},Ua=({scope:e,view:t,fields:n,time:r,tone:i,actions:a,button:o,onActed:c})=>{let l=s(),{resources:u}=P(),d=l(e.model,t,e.record,e.key),f=a.length>0||o!==void 0;return(0,Y.jsxs)(`li`,{"data-card":e.key,className:C(`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`,f?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:[i&&(0,Y.jsx)(We,{view:t,field:i,record:e.record}),(0,Y.jsxs)(`div`,{className:C(`flex min-w-0 items-baseline gap-2`,f&&`col-span-2 sm:col-span-1`),children:[(0,Y.jsx)(Cn,{to:{kind:`record`,resource:e.model.name,key:pn(e.model,e.record)},className:`line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline`,children:d}),r&&(0,Y.jsx)(`div`,{className:`ml-auto shrink-0 text-body whitespace-nowrap text-muted-foreground empty:hidden`,children:(0,Y.jsx)(Ha,{scope:e,path:r,labelled:!1})})]}),n.length>0&&(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-y-0.5 text-body text-muted-foreground`,children:n.map(t=>(0,Y.jsx)(`div`,{className:`flex max-w-full min-w-0 items-center whitespace-nowrap empty:hidden [&>div]:truncate [:not(:empty)~&]:before:mx-2 [:not(:empty)~&]:before:content-['·'_/_'']`,children:(0,Y.jsx)(Ha,{scope:e,path:t,labelled:!1})},t))}),f&&(0,Y.jsx)(Mt,{value:e,children:(0,Y.jsxs)(`div`,{className:`col-start-2 flex flex-wrap items-center justify-end gap-2 sm:row-span-2 sm:row-start-1`,children:[o&&(0,Y.jsx)(sr,{button:o,model:e.model,view:t,record:e.record,models:u}),a.map(e=>(0,Y.jsx)(ni,{name:e,about:d,onRun:e=>c?.(e,d)},e))]})})]})},Wa=({scope:e,view:t,fields:n,tone:r,actions:i,button:a,onActed:o})=>{let c=s(),{resources:l}=P(),u=c(e.model,t,e.record,e.key);return(0,Y.jsxs)(`li`,{"data-card":e.key,className:`relative flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[r&&(0,Y.jsx)(We,{view:t,field:r,record:e.record}),(0,Y.jsx)(Cn,{to:{kind:`record`,resource:e.model.name,key:pn(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:u}),n.length>0&&(0,Y.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,Y.jsx)(Ha,{scope:e,path:t,clamped:!0},t))}),(i.length>0||a)&&(0,Y.jsx)(Mt,{value:e,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&(0,Y.jsx)(sr,{button:a,model:e.model,view:t,record:e.record,models:l}),i.map(e=>(0,Y.jsx)(ni,{name:e,about:u,onRun:e=>o?.(e,u)},e))]})})]})},Ga=e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`,Ka=e=>[...e.querySelectorAll(`button`)].find(Ga)??e.querySelector(`a`),qa=(e,t,n)=>{let r=e.indexOf(n),i=e=>t.includes(e);return e.slice(r+1).find(i)??e.slice(0,Math.max(r,0)).findLast(i)},Ja=e=>{let t=e.closest(`section`)?.querySelector(`h2`);return t&&!t.hasAttribute(`tabindex`)&&(t.tabIndex=-1),t},Ya=e=>{let t=(0,J.useRef)(null),n=(0,J.useRef)({current:e,previous:e}),r=(0,J.useRef)(void 0),[i,a]=(0,J.useState)(``),o=(e,n,i)=>{if(r.current=void 0,i.includes(e.key)||!t.current||(a(za(`left`,{action:e.action,title:e.title})),document.activeElement&&document.activeElement!==document.body))return;let o=qa(n,i,e.key),s=o===void 0?void 0:t.current.querySelector(`[data-card="${CSS.escape(o)}"]`);(s?Ka(s):Ja(t.current))?.focus()};return(0,J.useEffect)(()=>{let t=n.current.current;n.current={current:e,previous:t},r.current&&o(r.current,t,e)},[e]),{root:t,acted:(e,t,i)=>{let{current:a,previous:s}=n.current;if(a.includes(e)){r.current={key:e,action:t,title:i};return}o({key:e,action:t,title:i},s,a)},announcement:i}},Xa=({compact:e,limit:t})=>(0,Y.jsx)(`div`,{className:e?`flex flex-col gap-2`:`flex flex-col gap-3`,children:Array.from({length:e?Math.min(t,3):2},(t,n)=>(0,Y.jsx)(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=Fe(),h=cr(),g=t?.names?.plural??bt(e.name),_=r||it(e,t),v=bn(e,{filter:n,sort:_,pageSize:s,enabled:!p}),y=Xe(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?tr(p.total):void 0}:y,C=(0,J.useMemo)(()=>(x??[]).map(t=>Tt(e,t)),[e,x]),w=Ya((0,J.useMemo)(()=>C.map(e=>e.key),[C]));return(0,Y.jsxs)(`div`,{ref:w.root,children:[(()=>{if(b.isPending)return(0,Y.jsx)(Xa,{compact:!!d,limit:s});if(b.error)return(0,Y.jsx)(L,{title:za(`couldNotLoad`),error:b.error});if(C.length===0)return(0,Y.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,Y.jsx)(Ua,{scope:e,view:t,fields:i,time:d.time,tone:f,actions:a,button:o,onActed:n},e.key):(0,Y.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:Wn(C.length,S.data,!1);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u===void 0?(0,Y.jsx)(`ul`,{className:d?`flex flex-col gap-2`:`flex flex-col gap-3`,children:r}):(0,Y.jsx)(Gn,{scroll:h,label:g,share:u,children:r}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p}),(0,Y.jsxs)(Cn,{to:rr(e,t,m,{filter:n,orderBy:_,display:ir(t,m,{preferred:c})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[Qn(`viewAll`),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:g.toLowerCase()}),(0,Y.jsx)(Nn,{className:`size-3.5`,"aria-hidden":!0})]})]})]})})(),(0,Y.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=H(e),{resource:a,filter:o=``,sort:s=``,fields:c,cardActions:l=[],limit:u=10,display:d,title:f,description:p,empty:m}=i,{layout:h,cardWidth:g}=Zr(i),{resources:_,views:v}=P(),[y,b]=jt([t,t===void 0?void 0:`${t}#total`]),S=(0,J.useMemo)(()=>y&&{rows:y,total:b},[y,b]),w=_[a];if(!w)return null;let T=v[w.name];return(0,Y.jsx)(`section`,{className:C(`min-w-0`,r),"aria-label":f,children:(0,Y.jsx)(x,{title:f,help:p,actions:n.actions,children:(0,Y.jsx)(Za,{model:w,view:T,filter:o,sort:s,fields:c??tn(w,T),actions:l,limit:u,display:d,empty:m,carousel:h===`carousel`?Qa[g]:void 0,...S&&{planned:S}})})})},eo=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=P(),o=Ie(i,a,e.name),s=Pn(e.name,t.listOf,!0),c=(t.names?.plural??bt(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,Y.jsx)(L,{title:kn(`couldNotLoadYour`,{plural:c}),error:s.error});if(!s.data)return(0,Y.jsx)(W,{className:`h-24`});let l=Yn(o.model,s.data);return l?(0,Y.jsx)(ur,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??kn(`noneYet`,{plural:c})})},to=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=wt(pn(e,i)),{name:o,chips:s,title:c,body:l}=fr({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,Y.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,Y.jsx)(`h3`,{className:`text-[0.9375rem] font-semibold`,children:(0,Y.jsx)(Cn,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,Y.jsx)(zn,{chips:s})})}),(0,Y.jsx)(ur,{...l})]})},no=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=P(),a=t.searchesOf,o=r[a.resource],s=Un(e.name,!0),c=(t.names?.plural??bt(e.name)).toLowerCase();return o?s.error?(0,Y.jsx)(L,{title:Bn(`couldNotLoadYour`,{plural:c}),error:s.error}):s.data?s.data.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:n??Bn(`noneYet`,{plural:c})}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,Y.jsx)(to,{model:e,view:t,target:o,targetView:i[a.resource],row:n},wt(pn(e,n))))}):(0,Y.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}=H(e),{resources:d,views:f}=P(),p=d[r];if(!p)return null;let m=f[p.name];return(0,Y.jsx)(B,{title:c,description:l,actions:t.actions,className:n,children:m?.searchesOf?(0,Y.jsx)(no,{model:p,view:m,empty:u}):m?.listOf===void 0?(0,Y.jsx)(ur,{model:p,view:m,filter:i,sort:a,limit:o,display:s,empty:u}):(0,Y.jsx)(eo,{model:p,view:m,limit:o,display:s,empty:u})})},io=e=>e.type===`boolean`||e.type===`enum`,ao=({model:e,fields:t,title:n,description:r,stored:i,className:a})=>{let{resources:o,views:s}=P(),c=Gt(e.name),l=Ct(),u=ue(),d=at(),p=s[e.name],[m,h]=(0,J.useState)(i),[_,v]=(0,J.useState)(()=>ka(e,t,i?.record)),[y,b]=(0,J.useState)({}),[x,S]=(0,J.useState)(),[w,T]=(0,J.useState)(!1),ee=(0,J.useRef)(Promise.resolve()),E=(0,J.useRef)(i),te=ka(e,t,void 0),ne=m?g(c,`update`)&&m.permissions?.update!==!1:g(c,`create`),re=t.filter(t=>!io(e.fields[t])),ie=re.some(t=>m?f(e.fields[t],_[t],m.record[t]):_[t]!==te[t]),ae=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{...Tt(e,r.record),etag:r.etag,permissions:r.permissions??n.permissions}}let r=await l.create(e.name,kt(e,o,{...te,...t}));return{...Tt(e,r.record),etag:r.etag}},oe=t=>{let r=ee.current.then(async()=>{T(!0),S(void 0),await ae(t).then(async r=>{E.current=r,h(r),b(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!Object.hasOwn(t,e)))),await d(e.name),u.show({state:`success`,title:U(`saved`,{label:n??U(`settings`)})})},e=>{b(t=>({...t,...cn(e)})),S(e)}),T(!1)});ee.current=r},D=(t,n)=>{v(e=>({...e,[t]:n})),io(e.fields[t])&&oe({[t]:n})};return(0,Y.jsx)(B,{title:n,description:r,className:C(`h-full`,a),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),ie&&oe(Object.fromEntries(re.map(e=>[e,_[e]])))},children:[x!==void 0&&Object.keys(y).length===0&&(0,Y.jsx)(L,{title:U(`notSaved`),error:x}),t.map(t=>{let n=e.fields[t],r=p?.fields[t]?.label??bt(t),i=y[t];return(0,Y.jsx)(Oe,{name:t,label:r,help:p?.fields[t]?.help,error:i&&vn(n,r,i),children:(0,Y.jsx)(rt,{field:n,hints:p?.fields[t],value:_[t],stored:m?.record[t]??te[t],invalid:!!i,locked:!ne||n.readOnly,resource:e.name,onChange:e=>D(t,e)})},t)}),ne&&ie&&(0,Y.jsx)(`div`,{children:(0,Y.jsx)(G,{type:`submit`,variant:`primary`,size:`sm`,loading:w,children:U(`save`)})})]})})},oo=e=>{let t=fn(e.model,{});return t.isPending?(0,Y.jsx)(B,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(W,{className:`h-4 w-1/2`}),(0,Y.jsx)(W,{className:`h-4 w-1/3`})]})}):t.error?(0,Y.jsx)(B,{title:e.title,description:e.description,className:e.className,children:(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:t.error})}):(0,Y.jsx)(ao,{...e,stored:t.data??void 0})},so=({node:e,className:t})=>{let{resource:n,fields:r=[],className:i,...a}=H(e),o=P().resources[n];return o?(0,Y.jsx)(oo,{...a,model:o,fields:r.filter(e=>Object.hasOwn(o.fields,e)),stored:void 0,className:t}):null},co=(e,t)=>lo(e,t?[t]:[]),lo=(e,t)=>{let{resources:n}=P(),r=Ct(),i=JSON.stringify(e),a=(0,J.useMemo)(()=>JSON.parse(i).map(wn),[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=fe(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=>Wt(t,e)),f=sn(l.map((e,t)=>{let n=d[t];return n&&`frame`in n?{scope:n.frame,path:n.path}:{scope:void 0,path:e}})),p=On({queries:u.map(e=>xt(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 je(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}=H(e),[a]=lo([i],z());if(a===void 0)return null;let o=a?t:uo(e,n);return o==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:o}):(0,Y.jsx)(`div`,{className:r,children:o})},po=(e,t)=>e.flatMap(e=>typeof e==`string`?[]:[String(_(e,K(t)).props.when)]),mo=({node:e,children:t,slots:n,className:r})=>{let i=z(),a=lo(po(e.children,i),i),o=a.findIndex(e=>e!==!1);if(o!==-1&&a[o]===void 0)return null;let s=o===-1?uo(e,n):t[o];return s==null?null:r===void 0?(0,Y.jsx)(Y.Fragment,{children:s}):(0,Y.jsx)(`div`,{className:r,children:s})},ho=({children:e})=>(0,Y.jsx)(Y.Fragment,{children:e}),go=`text-2xl font-semibold tracking-tight tabular-nums`,_o=({model:e,at:t,filter:n})=>{let{views:r}=P(),i=Zt(t),a=Xe(e,n,!i),o=i??a;if(o.isPending)return(0,Y.jsx)(W,{className:`h-8 w-16`});if(o.error)return(0,Y.jsx)(`span`,{className:`text-danger-text`,children:U(`couldNotCount`)});let s=i?tr(i):a.data;return(0,Y.jsx)(Cn,{to:$n(r[e.name],e.name,n),className:`${go} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:s.toLocaleString(Xt())})},vo=({field:e,format:t})=>{let n=pt(e);return n.state===`loading`?(0,Y.jsx)(W,{className:`h-8 w-16`}):n.state===`missing`?null:n.state===`plain`?(0,Y.jsx)(`span`,{className:go,children:ra(n.value)}):(0,Y.jsx)(`span`,{className:go,children:(0,Y.jsx)(_n,{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}=H(e),{resources:u}=P(),d=a===void 0?void 0:u[a];return(0,Y.jsxs)(B,{className:C(`relative h-full`,n),bodyClassName:`flex flex-col`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground break-words`,children:r}),(0,Y.jsxs)(`div`,{className:`mt-auto pt-1`,children:[i!==void 0&&(0,Y.jsx)(`span`,{className:go,children:i}),d&&(0,Y.jsx)(_o,{model:d,...t!==void 0&&{at:t},filter:o}),s!==void 0&&(0,Y.jsx)(vo,{field:s,format:c})]}),l&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l})]})},bo=(e,t,n)=>{let r=Fe(),i=Jn(t),[a,o]=(0,J.useState)(()=>Hn(localStorage,i)),s=(0,J.useCallback)(e=>{o(e),ar(localStorage,i,e)},[i]);return[ir(e,r,{picked:a,preferred:n}),s]},xo=({model:e,items:t,columns:n,button:r,title:i,description:a,empty:o,actions:s,className:c})=>{let{resources:l,views:d}=P(),f=d[e.name],{fields:m}=xe(),h=g(Gt(e.name),`update`),{go:_,href:v}=u(),y=Fe(),b=!ee(),x=(0,J.useMemo)(()=>n?.map(me)??tn(e,f),[n,e,f]),S=(0,J.useMemo)(()=>ot(e,f,x,{resources:l,views:d,fieldTypes:m}),[e,f,x,l,d,m]),C=(0,J.useMemo)(()=>y?et(n)(S):S,[y,n,S]),w=(0,J.useMemo)(()=>r?Zn(C,e,f,r,l,b):C,[C,e,f,r,l,b]),T=(0,J.useMemo)(()=>t.map(t=>({...t,id:p(e,t)})),[t,e]),E=(0,J.useMemo)(()=>({total:T.length,rowAt:e=>T[e]}),[T]),te=nr({model:e,view:f,opens:void 0,resources:l,views:d,canUpdate:h}),ne=e=>({href:v(e),onFollow:()=>_(e)});return(0,Y.jsx)(B,{title:i,description:a,actions:s,className:c,children:T.length===0?(0,Y.jsx)(R,{children:o??U(`nothingYet`)}):(0,Y.jsx)(In,{fit:!0,columns:w,source:E,latencyMs:0,onOpenRow:e=>_(te.address(e)),rowLink:e=>ne(te.address(e)),rowActions:te.actions(ne),rowNumbers:!1,selectable:!1})})},So=e=>{let t=Kt();return t?.model?(0,Y.jsx)(xo,{...e,model:t.model,items:t.items}):null},Co=({model:e,view:t,filter:n=``,sort:r=``,columns:i,button:a,bulk:o,limit:s=10,display:c,title:l,description:u,empty:d,actions:f,className:p,chosen:m,planned:h})=>{let[g,_]=bo(t,`page:${e.name}:${l??``}:${n}`,c),v=m?ge:g,y=(0,J.useMemo)(()=>i?.map(me),[i]),b=(0,J.useMemo)(()=>et(i),[i]);return(0,Y.jsxs)(B,{title:l,description:u,actions:(0,Y.jsxs)(Y.Fragment,{children:[!m&&(0,Y.jsx)(or,{view:t,value:v,onChange:_}),f]}),className:C(`h-full`,p),children:[(0,Y.jsx)(er,{model:e,view:t,filter:n,sort:r,columns:y,button:a,bulk:o,limit:s,display:v,empty:d,phoneColumns:b,...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}=H(e),{resources:u,views:d}=P(),[f,p]=jt([t,t===void 0?void 0:`${t}#total`]),m=(0,J.useMemo)(()=>f&&{rows:f,total:p},[f,p]);if(o===void 0)return(0,Y.jsx)(So,{...l,actions:n.actions,className:i});let h=u[o];return h?s===void 0?(0,Y.jsx)(Co,{...l,model:h,view:d[h.name],actions:n.actions,className:i,...m&&{planned:m}}):(0,Y.jsx)(To,{...l,model:h,view:d[h.name],actions:n.actions,className:i,select:s,...m&&{planned:m},children:r}):null},To=({select:e,children:t,...n})=>{let{given:r,linkTo:i}=an(),a=t=>i({[e]:t}),o=r[e],s=o===void 0?null:(0,Y.jsx)(Yt,{name:e,children:(0,Y.jsx)(ui,{model:n.model,query:{key:o},children:t},o)});return(0,Y.jsx)(Co,{...n,chosen:{rowTo:a,key:o,details:s}})},Eo=({node:e,children:t,className:n})=>{let{tab:r,pathOf:i}=yn(),{navigate:a}=Vt(),o=ln(e),s=Ye(o,r),c=e=>i(e===o[0]?.name?void 0:e);return(0,Y.jsxs)(`div`,{className:C(`flex flex-col gap-6`,n),children:[(0,Y.jsxs)(`select`,{"aria-label":U(`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,Y.jsx)(`option`,{value:``,disabled:!0}),o.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.label},e.name))]}),(0,Y.jsx)(`nav`,{"aria-label":U(`tabs`),className:`hidden border-b md:block`,children:(0,Y.jsx)(`ul`,{className:`flex gap-1`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(gt,{to:c(e.name),"aria-current":e===s?`page`:void 0,className:C(`-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,Y.jsx)(J.Fragment,{children:t[o.indexOf(s)]},s.name):(0,Y.jsx)(ae,{children:U(`noTab`,{name:r??``})})]})},Do=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-col gap-6`,children:e}),Oo=e=>e===void 0?1/0:Date.parse(e),ko=(e,t)=>{let n=e=>e.more&&e.items.length>0?Oo(e.items.at(-1).time):-1/0,r=Math.max(n(e),n(t)),i=[],a=0,o=0;for(;a<e.items.length||o<t.items.length;){let n=o>=t.items.length||a<e.items.length&&Oo(e.items[a].time)>=Oo(t.items[o].time)?e.items[a++]:t.items[o++];if(Oo(n.time)<r)break;i.push(n)}return i},Ao=({value:e,hints:t,mark:n})=>{let r=ft(e,t?.valueLabels);return n===`done`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(xn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success-text`}),r]}):n===`running`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(yt,{hidden:!0,className:`size-3.5 shrink-0`}),r]}):n!==`error`&&Ne(t?.valueColors,e)!==`red`?r:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-danger-text`,children:[(0,Y.jsx)(pr,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),r]})},jo=({value:e})=>{let t=typeof e==`string`?ne(e):e;return t===de?(0,Y.jsx)(Sn,{children:String(e)}):(0,Y.jsx)(Ae,{value:t})},Mo=({label:e,children:t})=>(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),No=({call:e,statusHints:t})=>{let[n,r]=(0,J.useState)(!1),i=(0,J.useId)(),a=e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:t,mark:e.state}),o=(0,Y.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.name}),s=e.input!==void 0||e.result!==void 0||e.error!==void 0;return(0,Y.jsxs)(`div`,{"data-tool-call":!0,className:`flex min-w-0 flex-col gap-1 pl-11 text-xs text-muted-foreground`,children:[s?(0,Y.jsxs)(G,{size:`sm`,variant:`ghost`,className:`-ml-2.5 self-start`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[(0,Y.jsx)(te,{"aria-hidden":!0,className:C(`size-3.5 transition-transform`,n&&`rotate-90`)}),o,a]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[o,a]}),n&&(0,Y.jsxs)(`div`,{id:i,className:`grid gap-2`,children:[e.input!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callInput`),children:(0,Y.jsx)(jo,{value:e.input})}),e.result!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callResult`),children:(0,Y.jsx)(jo,{value:e.result})}),e.error!==void 0&&(0,Y.jsx)(Mo,{label:Q(`callError`),children:(0,Y.jsx)(Sn,{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&&ie(s.time,e);if(e!==void 0&&!l&&o.push({kind:`day`,key:`day:${c.kind===`call`?c.key:t(c.row)}`,label:S(e,a)}),c.kind===`call`){o.push(c),s={author:void 0,time:e};continue}let{row:u}=c,d=n===void 0?void 0:Fo(u[n]),f=d?.id??``,p=i===void 0||u[i]==null||u[i]===``?void 0:String(u[i]);o.push({kind:`message`,key:t(u),...d&&{author:d},time:e,text:u[r]==null?``:String(u[r]),...p!==void 0&&{status:p},continued:l&&s?.author===f}),s={author:f,time:e}}return o},Lo=e=>Br.includes(e??``)?e:void 0,Ro=e=>e==null||e===``?void 0:String(e),zo=e=>`call:${JSON.stringify(e)}`,Bo=(e,t,n)=>{let r=Ro(e[n.status]),i=Lo(r),a=n.input===void 0?void 0:e[n.input],o=n.result===void 0?void 0:e[n.result],s=n.error===void 0?void 0:Ro(e[n.error]);return{kind:`call`,key:t,name:String(e[n.name]??``),time:typeof e[n.time]==`string`?e[n.time]:void 0,...r!==void 0&&{status:r},...i!==void 0&&{state:i},...a!=null&&{input:a},...o!=null&&{result:o},...s!==void 0&&{error:s}}},Vo=({planned:e,limit:t,expanded:n,expand:r,own:i})=>{if(!e)return i;let a=n&&!i.error&&i.pages<2&&(i.pages===0||i.hasNextPage),o={items:e.rows,labels:e.labels??{},hasNextPage:e.rows.length>=t,isFetchingNextPage:a,isFetchNextPageError:!1,isLoading:e.isPending};return n&&i.error&&i.pages===0?{...o,error:i.error,fetchNextPage:i.refetch,refetch:i.refetch}:n&&!a?i:{...o,error:e.error,fetchNextPage:r,refetch:r}},Ho=(e,{pageSize:t=50,enabled:n=!0,...r},i)=>{let[a,o]=(0,J.useState)(!1),s=re(e,{...r,pageSize:t,enabled:n&&(!i||a)}),c=s.data?.pages.length??0,{hasNextPage:l,isFetchingNextPage:u,fetchNextPage:d,error:f}=s;return(0,J.useEffect)(()=>{i&&a&&!f&&c===1&&l&&!u&&d()},[i,a,f,c,l,u,d]),Vo({planned:i,limit:t,expanded:a,expand:()=>o(!0),own:{...s,pages:c}})},Uo=(e,t,n)=>{let{views:r}=P(),i=e?.model.name??``,a=Ho(i,{filter:e?.filter,orderBy:e&&Le(e.fields.time),pageSize:t,enabled:e!==void 0},n);return e?{calls:a.items.map(t=>Bo(t,zo(pn(e.model,t)),e.fields)),hasNextPage:a.hasNextPage,isFetchingNextPage:a.isFetchingNextPage,list:a,statusHints:r[i]?.fields[e.fields.status]}:{calls:[],hasNextPage:!1,isFetchingNextPage:!1,list:a,statusHints:void 0}},Wo=e=>e.items.length>0?`messages`:e.error?`error`:e.isLoading?`loading`:`messages`,Go=(e,t)=>e.isLoading?t.loading:t.empty,Ko=e=>e.items.length>0&&!!e.error,qo=e=>e.isFetchNextPageError?()=>void e.fetchNextPage():()=>void e.refetch(),Jo=e=>{for(let t of e)t.hasNextPage&&t.fetchNextPage()},Yo=({model:e,filter:t,sender:n,time:r,text:i,status:a,limit:o=50,empty:s,working:c,calls:l,planned:u})=>{let{resources:d,views:f}=P(),p=m(),h=p?.state.kind===`signed-in`?p.state.user.id:void 0,g=n===void 0?[]:[n],_=He(d,f,e,g),v=Ho(e.name,{filter:t,orderBy:Le(r),pageSize:o,labels:_},u?.messages),y=Uo(l,o,u?.calls),b=Wo(v);if(b===`error`)return(0,Y.jsx)(L,{title:Q(`couldNotLoad`),error:v.error,onRetry:qo(v)});if(b===`loading`)return(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(R,{children:Q(`loadingMessages`)})});let x=qe(d,e,g,v.items,v.labels),S=ko({items:y.calls,more:y.hasNextPage},{items:Po(x,r),more:v.hasNextPage}),C=Io(S,{key:t=>String(pn(e,t)),sender:n,time:r,text:i,status:a}),w=a===void 0?void 0:f[e.name]?.fields[a],T=e.fields[i]!==void 0&&mn(e.fields[i],f[e.name]?.fields[i]),ee=C.findLast(e=>e.kind===`message`&&e.author!==void 0&&e.author.id===h);return(0,Y.jsxs)(Y.Fragment,{children:[Ko(v)&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(L,{title:Q(`couldNotLoad`),error:v.error,onRetry:qo(v)})}),l&&y.list.error&&(0,Y.jsx)(`div`,{className:`shrink-0 p-2`,children:(0,Y.jsx)(L,{title:Q(`couldNotLoadCalls`),error:y.list.error,onRetry:qo(y.list)})}),(0,Y.jsx)(he,{length:S.length,followKey:ee?.key,working:c,empty:Go(y.list,{loading:Q(`loadingMessages`),empty:s??Q(`noMessages`)}),onLoadEarlier:v.hasNextPage||y.hasNextPage?()=>Jo([v,y.list]):void 0,loadingEarlier:v.isFetchingNextPage||y.isFetchingNextPage,children:C.map(e=>e.kind===`day`?(0,Y.jsx)(we,{label:e.label},e.key):e.kind===`call`?(0,Y.jsx)(No,{call:e,statusHints:y.statusHints},e.key):(0,Y.jsx)(ve,{...e.author?{author:e.author}:{alone:!0},time:e.time,continued:e.continued,footer:e.status!==void 0&&(0,Y.jsx)(Ao,{value:e.status,hints:w}),children:T&&e.text!==``?(0,Y.jsx)(Pe,{source:e.text,className:`whitespace-normal`}):e.text},e.key))})]})},Xo=({children:e})=>(0,Y.jsx)(`div`,{className:`flex h-[min(36rem,65dvh)] flex-col rounded-lg border border-border bg-background`,children:e}),Zo=({node:e,at:t,slots:n,className:r})=>{let{title:i,description:a,resource:o,filter:s,sender:c,time:l,text:u,status:d,working:f,calls:p,limit:m,empty:h}=H(e),{resources:g}=P(),[_]=lo(f===void 0?[]:[f],z()),[v,y]=jt([t,t===void 0?void 0:`${t}#calls`]),b=g[o];if(!b)return null;let S=p&&g[p.resource];return(0,Y.jsx)(`section`,{className:C(`flex min-w-0 flex-col`,r),"aria-label":i,children:(0,Y.jsx)(x,{title:i,help:a,actions:n.actions,children:(0,Y.jsx)(Xo,{children:(0,Y.jsx)(Yo,{model:b,filter:s,sender:c,time:l,text:u,status:d,calls:p&&S&&{model:S,filter:p.filter,fields:p},limit:m,empty:h,working:f===void 0?void 0:_===!0,...(v||y)&&{planned:{messages:v,calls:y}}})})})})},Qo=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:t,children:e}),$o=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:C(`flex`,t),children:e}),es=({children:e,className:t})=>(0,Y.jsx)(`div`,{className:C(`flex flex-col`,t),children:e}),ts=({node:e,children:t,className:n})=>{let{as:r=`p`}=H(e);return(0,Y.jsx)(r,{className:n,children:t})},ns=({node:e,children:t})=>{let{source:n}=H(e),r=Lt(K(z()),n),i=(0,J.useMemo)(()=>({items:Array.isArray(r)?r:[]}),[r]);return(0,Y.jsx)(mt,{value:i,children:t})},rs=({node:e,className:t})=>{let{source:n,choices:r,label:i=n,defaultValue:a}=H(e),{values:s,linkTo:c}=an(),l=s[n];return(0,Y.jsxs)(`div`,{className:C(`flex flex-wrap items-center gap-2`,t),children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:i}),r?(0,Y.jsx)(o,{label:i,value:l??``,options:r.map(e=>({value:String(e.id),label:e.name})),link:e=>c({[n]:a!==void 0&&e===String(a)?void 0:e})}):(0,Y.jsx)(`span`,{children:l})]})},is=({model:e,filter:t,perPage:n,more:r,planned:i,expanded:a,expand:o,own:s})=>{if(t===void 0)return{read:{isPending:!1,error:null},list:{model:e,items:[]}};if(i&&!a){let t=i.rows.slice(0,n),a=r&&t.length===n?o:void 0;return{read:i,list:{model:e,items:t,planned:!0,...a&&{loadMore:a}}}}if(i&&!s.error&&s.pages<2&&(s.pages===0||s.hasNextPage))return{read:i,list:{model:e,items:i.rows.slice(0,n),planned:!0,loadMore:()=>{},loadingMore:!0}};let c=r&&s.hasNextPage?()=>void s.fetchNextPage():void 0;return{read:{isPending:s.isPending,error:s.error},list:{model:e,items:s.items,...c&&{loadMore:c,loadingMore:s.isFetchingNextPage}}}},as=({model:e,filter:t,sort:n,perPage:r,more:i,planned:a})=>{let[o,s]=(0,J.useState)(!1),c=re(e.name,{filter:t,orderBy:n,pageSize:r,enabled:t!==void 0&&(!a||o)}),l=c.data?.pages.length??0,{hasNextPage:u,isFetchingNextPage:d,fetchNextPage:f,error:p}=c;return(0,J.useEffect)(()=>{a&&o&&!p&&l===1&&u&&!d&&f()},[a,o,p,l,u,d,f]),is({model:e,filter:t,perPage:r,more:i,planned:a,expanded:o,expand:()=>s(!0),own:{pages:l,items:c.items,hasNextPage:u,isFetchingNextPage:d,isPending:c.isPending,error:p,fetchNextPage:f}})},os=({node:e,at:t,children:n})=>{let r=H(e),i=P().resources[r.reference],a=be(K(z())),o=Zt(t);return i?(0,Y.jsx)(ss,{model:i,...Ce(r,i.primaryKey[0],a),more:r.pagination===`more`,empty:r.empty,...o&&{planned:o},children:n}):null},ss=({empty:e,children:t,...n})=>{let{read:r,list:i}=as(n);return(0,Y.jsx)(St,{read:r,list:i,empty:e,children:t})},cs=({node:e,at:t,children:n})=>{let r=H(e),i=P().resources[r.reference],a=be(K(z())),o=Zt(t);return i?(0,Y.jsx)(ss,{model:i,..._e(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}=P(),s=Zt(t),c=fn(e,{key:n,enabled:!s}),l=s?Dt(e,s):c;if(l.isPending)return(0,Y.jsx)(W,{className:`h-4 w-24`});if(l.error)return(0,Y.jsx)(L,{title:U(`couldNotLoad`),error:l.error});if(!l.data)return null;let u=i.length>0?(0,Y.jsx)(Mt,{value:l.data,children:i}):Rt(e,o[e.name],l.data.record,n);return r===!1?(0,Y.jsx)(`span`,{className:a,children:u}):(0,Y.jsx)(Cn,{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}=H(e),c=P().resources[i],l=Lt(K(z()),a);return c?l==null||l===``?s===void 0?null:(0,Y.jsx)(`span`,{className:r,children:s}):(0,Y.jsx)(ls,{model:c,...t!==void 0&&{at:t},recordKey:String(l),link:o,className:r,children:n}):null},ds=(e,t)=>t.map(t=>Ht(e,t)).join(`, `),$=_t(`users`),fs=({roles:e})=>{let{session:t}=k(),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)([]),o=(0,J.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,J.useEffect)(o,[o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(hr,{title:$(`inviteSomeone`),description:$(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,Y.jsx)(_r,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,Y.jsx)(N,{title:$(`notAcceptedYet`),description:i.length>0?$(`sendingAgain`):$(`nobodyWaiting`),children:i.length>0&&(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,Y.jsx)(gr,{email:n.email,gives:ds(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},ps=({roles:e,onCreated:t})=>{let{session:n}=k(),[r,i]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)([]),{busy:f,error:p,run:m}=Ge(),h=()=>m(async()=>{await n.users.create({email:r.trim(),name:o.trim(),roles:u,...c&&{password:c}}),i(``),s(``),l(``),d([]),t()}),g=!r.trim()||!o.trim()||u.length===0||c!==``&&c.length<12;return(0,Y.jsxs)(N,{title:$(`addAnAccount`),description:$(`addDescription`),children:[(0,Y.jsx)(O,{message:p}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Y.jsx)(a,{"aria-label":$(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,Y.jsx)(a,{"aria-label":$(`name`),placeholder:$(`name`),autoComplete:`off`,value:o,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`})]}),(0,Y.jsx)(a,{"aria-label":$(`password`),type:`password`,autoComplete:`new-password`,placeholder:$(`passwordOptional`,{length:12}),value:c,onChange:e=>l(e.target.value)}),(0,Y.jsx)(_r,{roles:e,selected:u,grantable:new Set(e.map(e=>e.name)),onChange:d}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(G,{type:`submit`,variant:`primary`,loading:f,disabled:g,children:$(`addAccount`)})})]})]})},ms=({user:e,roles:t,self:n})=>{let{session:r}=k(),[i,a]=(0,J.useState)(e),{busy:o,error:s,run:c,setError:l}=Ge(),u=e=>{if(e.length===0)return l($(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,Y.jsx)(vr,{name:i.name,email:i.email,self:n,error:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[i.blocked&&(0,Y.jsx)(I,{tone:`red`,children:$(`blocked`)}),!n&&(i.blocked?(0,Y.jsx)(G,{size:`sm`,loading:o,onClick:()=>d(!1),children:$(`unblock`)}):(0,Y.jsx)(G,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:$(`block`)}))]}),children:(0,Y.jsx)(_r,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},hs=({roles:e,version:t})=>{let{session:n,state:r}=k(),[i,a]=(0,J.useState)(``),o=(0,J.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),s=br(o,i),c=r.kind===`signed-in`?r.user.id:void 0;return(0,Y.jsx)(yr,{title:$(`people`),description:$(`peopleDescription`),searchLabel:$(`findSomeone`),placeholder:$(`emailAddress`),query:i,onQuery:a,list:s,renderRow:n=>(0,Y.jsx)(ms,{user:n,roles:e,self:n.id===c},`${t}/${n.id}`)})},gs=()=>{let{session:e}=k(),[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)();return(0,J.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof A?V(e):$(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},_s=()=>{let{roles:e,error:t}=gs(),[n,r]=(0,J.useState)(0);return(0,Y.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,Y.jsx)(O,{message:t}),(0,Y.jsx)(hs,{roles:e,version:n}),(0,Y.jsx)(fs,{roles:e}),(0,Y.jsx)(ps,{roles:e,onCreated:()=>r(e=>e+1)})]})},vs=({sender:e,busy:t,error:n,onSave:r,onClose:i})=>{let[o,s]=(0,J.useState)(e?.address??``),[c,u]=(0,J.useState)(e?.name??``),[d,f]=(0,J.useState)(e?.signature??``),[p,m]=(0,J.useState)(e?.isDefault??!1);return(0,Y.jsxs)(F,{title:e?e.address:q(`addFromAddress`),description:q(e?`changeFromAddressDescription`:`addFromAddressDescription`),onClose:i,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:i,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:t,disabled:!o.trim(),onClick:()=>r({address:o.trim(),name:c.trim(),signature:d,isDefault:p}),children:q(e?`save`:`addAddress`)})]}),children:[!e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`fromAddress`),(0,Y.jsx)(a,{autoFocus:!0,type:`email`,value:o,maxLength:254,placeholder:q(`fromAddressPlaceholder`),onChange:e=>s(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[q(`fromName`),(0,Y.jsx)(a,{value:c,maxLength:100,placeholder:q(`fromNamePlaceholder`),onChange:e=>u(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{children:q(`defaultFromAddress`)}),(0,Y.jsx)(pe,{checked:p,onChange:m,label:q(`defaultFromAddress`)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[q(`signature`),(0,Y.jsx)(l,{value:d,maxLength:2e3,placeholder:q(`signaturePlaceholder`),onChange:e=>f(e.target.value)})]}),(0,Y.jsx)(O,{message:n})]})},ys=e=>e.signature?q(`ownSignature`):q(`genericSignature`),bs=({senders:{address:e,senders:t},onAdd:n,onUpdate:r,onRemove:i})=>{let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(),d=(0,J.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(q(`noAnswerFromServer`));if(!(e instanceof A))throw e;c(V(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,Y.jsxs)(`div`,{className:`mt-5 border-t pt-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:q(`fromAddresses`)}),(0,Y.jsx)(`p`,{className:`mt-1 mb-3 text-muted-foreground`,children:q(`fromAddressesDescription`)}),(0,Y.jsx)(O,{message:l?void 0:s}),(e||t.length>0)&&(0,Y.jsxs)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:[e&&(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:q(`mailboxOwnAddress`)})]}),f?(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,loading:a,onClick:()=>void m(()=>r(f.id,{isDefault:!1})),children:q(`makeDefault`)}):(0,Y.jsx)(I,{tone:`blue`,children:q(`default`)})]}),t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Tr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.address}),e.name&&(0,Y.jsx)(`bdi`,{className:`block truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:ys(e)})]}),e.isDefault&&(0,Y.jsx)(I,{tone:`blue`,children:q(`default`)}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`change`,sender:e}),children:q(`edit`)}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>u({kind:`remove`,sender:e}),children:q(`remove`)})]},e.id))]}),(0,Y.jsxs)(G,{onClick:()=>u({kind:`add`}),children:[(0,Y.jsx)(Me,{className:`size-3.5`}),q(`addFromAddress`)]}),l?.kind===`add`&&(0,Y.jsx)(vs,{busy:a,error:s,onSave:e=>void h(e),onClose:p}),l?.kind===`change`&&(0,Y.jsx)(vs,{sender:l.sender,busy:a,error:s,onSave:e=>void h(e),onClose:p},l.sender.id),l?.kind===`remove`&&(0,Y.jsx)(F,{title:q(`removeFromAddress`,{address:l.sender.address}),description:q(`removeFromAddressDescription`),onClose:p,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:p,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.sender.id)),children:q(`remove`)})]}),children:(0,Y.jsx)(O,{message:s})})]})},xs=(e,t,n)=>Object.fromEntries(Fn(e,t,{code:`not_linked`}).filter(e=>e.signInOnly).map(({link:e})=>[e.id,Xn(`signInOnly`,{provider:n(e.provider),name:e.name})])),Ss=({links:e})=>{let{session:t,linkPersonalMail:n,signInProviders:r}=k(),{account:i}=t,[a]=(0,J.useState)(qt),o=(0,J.useCallback)(async()=>{let[t,n,r]=await Promise.all([i.linkedPersonalMail(e),i.linkedProviders(),i.mailSenders()]);return{mail:t,providers:n,senders:r}},[i,e]),{data:s,error:c,reload:l}=D(o,q(`couldNotReadMethods`));return s?(0,Y.jsx)(Ue,{title:q(`mailbox`),description:q(`mailboxDescription`),providers:e.map(({id:e,name:t})=>({id:e,name:t})),linked:s.mail,notes:xs(e,s,e=>r.find(t=>t.id===e)?.name??hn(e)),reconnect:!0,onConnect:t=>n(e.find(e=>e.id===t)),error:a&&$t(a,e.length===1?e[0].name:q(`theProvider`)),children:(0,Y.jsx)(bs,{senders:s.senders,onAdd:async e=>{let t=await i.addMailSender(e);return await l(),t},onUpdate:async(e,t)=>{await i.updateMailSender(e,t),await l()},onRemove:async e=>{await i.removeMailSender(e),await l()}})}):(0,Y.jsx)(M,{error:c})},Cs=()=>{let{personalMail:e}=k();return e.length>0?(0,Y.jsx)(Ss,{links:e}):null},ws=e=>xr(e.name)??`An unnamed app`,Ts=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Es=({apps:e,onDisconnect:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(),[o,s]=(0,J.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof A))throw e;a(V(e))}r(!1)};return(0,Y.jsxs)(N,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,Y.jsx)(O,{message:o?void 0:i}),e.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=Sr(e.clientId);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Dr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:ws(e)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,Ke(Date.parse(e.allowedAt)),` · `,Ts(e)]})]}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,Y.jsx)(F,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>s(void 0),children:`Cancel`}),(0,Y.jsx)(G,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,Y.jsx)(O,{message:i})})]})},Ds=(e,t)=>{let n=new URL(`https://claude.ai/customize/connectors`);return n.searchParams.set(`modal`,`add-custom-connector`),t&&n.searchParams.set(`connectorName`,t),n.searchParams.set(`connectorUrl`,e),n.href},Os=({url:e,appName:t})=>(0,Y.jsx)(N,{title:q(`mcpAddress`),description:q(`mcpAddressDescription`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Cr,{value:e,copyLabel:q(`copyMcpAddress`)}),(0,Y.jsxs)(`a`,{href:Ds(e,t),target:`_blank`,rel:`noreferrer`,className:dt(),children:[(0,Y.jsx)(It,{className:`size-3.5`}),q(`addToClaude`)]})]})}),ks=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.connectedApps(),[e]),q(`couldNotReadMethods`));return t?(0,Y.jsx)(Es,{apps:t,onDisconnect:t=>e.disconnectApp(t).then(r)}):(0,Y.jsx)(M,{error:n})},As=({url:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Os,{url:e,appName:P().appName}),(0,Y.jsx)(ks,{})]}),js=()=>{let{mcp:e}=k();return e?(0,Y.jsx)(As,{url:e.url}):null},Ms={30:30,90:90,365:365,never:void 0},Ns={30:`expiresIn30Days`,90:`expiresIn90Days`,365:`expiresInAYear`,never:`neverExpires`},Ps=e=>Ke(Date.parse(e)),Fs=e=>e?q(Date.parse(e)<=Date.now()?`expiredOn`:`expiresOn`,{date:Ps(e)}):q(`neverExpires`),Is=e=>[q(`createdOn`,{date:Ps(e.createdAt)}),Fs(e.expiresAt),e.lastUsedAt?q(`lastUsedOn`,{date:Ps(e.lastUsedAt)}):q(`notUsedYet`),e.organization?q(`actsAsIn`,{role:e.role,organization:e.organization}):q(`actsAs`,{role:e.role})].join(` · `),Ls=({tokens:e,onCreate:t,onRevoke:n})=>{let[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(`90`),[m,h]=(0,J.useState)(),g=()=>{l(void 0),s(void 0),h(void 0)},_=(0,J.useRef)(!1),v=async e=>{if(!_.current){_.current=!0,i(!0),s(void 0);try{l(await e()),h(void 0)}catch(e){if(e instanceof TypeError)return s(q(`noAnswerFromServer`));if(!(e instanceof A))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):s(V(e))}finally{_.current=!1,i(!1)}}},y=()=>v(async()=>{let e=Ms[f];return{kind:`created`,created:await t({name:u.trim(),...e!==void 0&&{expiresInDays:e}})}});return(0,Y.jsxs)(N,{title:q(`accessTokens`),description:q(`accessTokensDescription`),children:[(0,Y.jsx)(O,{message:c?void 0:o}),e.length===0?(0,Y.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:q(`noAccessTokens`)}):(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(kr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`bdi`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:Is(e)})]}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>l({kind:`revoke`,token:e}),children:q(`revoke`)})]},e.id))}),(0,Y.jsxs)(G,{onClick:()=>{d(``),p(`90`),l({kind:`create`})},children:[(0,Y.jsx)(Me,{className:`size-3.5`}),q(`newAccessToken`)]}),c?.kind===`create`&&(0,Y.jsxs)(F,{title:q(`newAccessToken`),description:q(`newAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:g,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:r,disabled:!u.trim(),onClick:()=>void y(),children:q(`createAccessToken`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`name`),(0,Y.jsx)(a,{autoFocus:!0,value:u,maxLength:100,placeholder:q(`accessTokenNamePlaceholder`),onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5 font-medium`,children:[q(`accessTokenExpiry`),(0,Y.jsx)(Re,{value:f,onChange:e=>p(e.target.value),children:Object.keys(Ms).map(e=>(0,Y.jsx)(`option`,{value:e,children:q(Ns[e])},e))})]}),m===`asked`&&(0,Y.jsx)(st,{purpose:`change`,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:q(`confirmedCreateAccessToken`)}),(0,Y.jsx)(O,{message:o})]}),c?.kind===`created`&&(0,Y.jsx)(F,{title:q(`accessTokenCreated`,{name:c.created.personalAccessToken.name}),description:q(`accessTokenCreatedDescription`),onClose:g,actions:(0,Y.jsx)(G,{variant:`primary`,onClick:g,children:q(`done`)}),children:(0,Y.jsx)(Cr,{value:c.created.token,copyLabel:q(`copyAccessToken`)})}),c?.kind===`revoke`&&(0,Y.jsx)(F,{title:q(`revokeAccessToken`,{name:c.token.name}),description:q(`revokeAccessTokenDescription`),onClose:g,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:g,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,loading:r,onClick:()=>void v(async()=>(await n(c.token.id),void 0)),children:q(`revoke`)})]}),children:(0,Y.jsx)(O,{message:o})})]})},Rs=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.personalAccessTokens(),[e]),q(`couldNotReadAccessTokens`));return t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(O,{message:n}),(0,Y.jsx)(Ls,{tokens:t,onCreate:t=>e.createPersonalAccessToken(t).then(e=>(r(),e),async e=>{throw await r(),e}),onRevoke:t=>e.revokePersonalAccessToken(t).finally(r)})]}):(0,Y.jsx)(M,{error:n})},zs=()=>k().personalAccessTokens?(0,Y.jsx)(Rs,{}):null,Bs={revoked:`disconnectedRevoked`,queued:`disconnectedQueued`,not_revoked:`disconnectedNotRevoked`},Vs=e=>e.provider===`google`,Hs=({connections:e,onConnect:t,onDisconnect:n,error:r})=>{let[a,o]=(0,J.useState)(),[s,c]=(0,J.useState)(r),[l,u]=(0,J.useState)(),[d,f]=(0,J.useState)(),p=async(e,t)=>{o(e),c(void 0),f(void 0);try{await t(),u(void 0)}catch(e){if(!(e instanceof A))throw e;c(V(e))}finally{o(void 0)}};return(0,Y.jsxs)(N,{title:q(`connections`),description:q(`connectionsDescription`),children:[(0,Y.jsx)(O,{message:l?void 0:s}),(0,Y.jsx)(i,{message:d}),(0,Y.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Nr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),(0,Y.jsx)(G,{size:`sm`,loading:a===e.key,disabled:a!==void 0,onClick:()=>void p(e.key,()=>t(e)),children:e.accounts.length>0?q(`connectAgain`,{name:e.label}):q(`connect`,{name:e.label})})]}),e.accounts.map(t=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pl-7 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:[q(`connectedOn`,{date:Ke(Date.parse(t.created_at))}),` · `,(0,Y.jsx)(`code`,{className:`text-xs`,children:t.id})]}),t.needs_sign_in?(0,Y.jsx)(I,{tone:`amber`,children:q(`connectionNeedsSignIn`)}):(0,Y.jsx)(I,{tone:`green`,children:q(`connected`)}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>u({connection:e,accountId:t.id}),children:q(`disconnect`)})]}),t.used_by.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:q(`connectionUsedBy`)}),t.used_by.map(e=>(0,Y.jsx)(Jt,{resource:`workflows`,recordKey:e.id,className:`font-medium text-primary-text hover:underline`,children:e.name},e.id))]})]},t.id))]},e.key))}),l&&(0,Y.jsx)(F,{title:q(`disconnectTitle`,{name:l.connection.label}),description:Vs(l.connection)?`${q(`disconnectDescription`)} ${q(`disconnectWholeGrant`)}`:q(`disconnectDescription`),onClose:()=>u(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>u(void 0),children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,loading:a===l.accountId,onClick:()=>void p(l.accountId,async()=>f(q(Bs[await n(l.accountId)]))),children:q(`disconnect`)})]}),children:s&&(0,Y.jsx)(O,{message:s})})]})},Us=()=>{let{session:e,connectAccount:t}=k(),{account:n}=e,[r]=(0,J.useState)(qt),{data:i,error:a,reload:o}=D((0,J.useCallback)(()=>n.workflowConnections(),[n]),q(`couldNotReadMethods`));return i?i.length===0?null:(0,Y.jsx)(Hs,{connections:i,onConnect:t,onDisconnect:e=>n.disconnectAccount(e).finally(o),error:r&&$t(r,q(`theProvider`))}):(0,Y.jsx)(M,{error:a})},Ws=e=>e.code===`LAST_ADMIN`?q(`deleteAccountLastAdmin`):e.code===`ACCOUNT_LOCKED`?q(`deleteAccountLocked`):V(e),Gs=({hasPassword:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(!1),f=(0,J.useId)(),p=async()=>{s(!0),l(void 0),d(!1);try{await t(e?r:void 0)}catch(e){if(!(e instanceof A))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?d(!0):l(Ws(e)),s(!1)}};return(0,Y.jsxs)(F,{title:q(`deleteAccountQuestion`),description:q(`deleteAccountWarning`),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:n,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,type:`submit`,form:f,loading:o,disabled:e&&!r,children:q(`deleteAccountConfirm`)})]}),children:[(0,Y.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`deleteAccountPassword`),(0,Y.jsx)(a,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,invalid:!!c,onChange:e=>i(e.target.value)})]}),(0,Y.jsx)(O,{message:c})]}),u&&(0,Y.jsx)(st,{purpose:`change`,minutes:15,onConfirmed:()=>void p()})]})},Ks=({hasPassword:e,staff:t,onDelete:n})=>{let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(N,{title:q(`deleteAccount`),description:q(t?`deleteAccountStaff`:`deleteAccountDescription`),children:[!t&&(0,Y.jsx)(G,{variant:`danger`,onClick:()=>i(!0),children:q(`deleteAccount`)}),r&&(0,Y.jsx)(Gs,{hasPassword:e,onDelete:n,onClose:()=>i(!1)})]})},qs=()=>{let{session:e,state:t,deleteAccount:n}=k(),{account:r}=e,{data:i,error:a}=D((0,J.useCallback)(()=>r.signInMethods(),[r]),q(`couldNotReadMethods`));return i?(0,Y.jsx)(Ks,{hasPassword:i.account.password,staff:t.kind===`signed-in`&&!!t.staff,onDelete:n}):(0,Y.jsx)(M,{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?q(`deviceThrough`,{device:e.device,provider:e.name}):e.name,$s=(e,t)=>{if(e.staff)return t?q(`staffOf`,{operator:t}):q(`staff`);let{browser:n,system:r}=Zs(e.userAgent);return n&&r?q(`browserOn`,{browser:n,system:r}):r?q(`aBrowserOn`,{system:r}):n??q(`unknownDevice`)},ec=e=>{if(e.staff)return Fr;let{system:t}=Zs(e.userAgent);return t===`iPhone`||t===`Android`?Lr:t===`iPad`?zr:jr},tc=e=>[...e].sort((e,t)=>Number(t.current)-Number(e.current)||t.createdAt.localeCompare(e.createdAt)),nc=(e,t)=>e.kind===`one`?q(`signOutDevice`,{name:$s(e.session,t)}):e.kind===`link`?q(`signOutDevice`,{name:Qs(e.link)}):q(`signOutOthersTitle`),rc=e=>q(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,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.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 A))throw e;l(V(e))}s(!1)},g=e=>{l(void 0),d(e)};return(0,Y.jsxs)(N,{title:q(`devices`),description:q(`devicesDescription`),children:[f.length===0&&n.length===0?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:q(`noDevices`)}):(0,Y.jsxs)(`ul`,{className:`divide-y rounded-md border`,children:[tc(f).map(e=>{let n=ec(e);return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:$s(e,t)}),e.current&&(0,Y.jsx)(I,{tone:`green`,children:q(`thisDevice`)})]}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[q(`signedInFromUntil`,{from:Te(Date.parse(e.createdAt)),until:Te(Date.parse(e.expiresAt))}),!e.staff&&e.ipAddress&&` · ${e.ipAddress}`]})]}),!e.current&&(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`one`,session:e}),children:q(`signOut`)})]},e.token)}),n.map(t=>{let n=e.some(e=>e.current&&t.sessions.includes(e.token));return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(Lr,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`bdi`,{className:`truncate font-medium`,children:Qs(t)}),n&&(0,Y.jsx)(I,{tone:`green`,children:q(`thisDevice`)})]}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:q(`linkedOn`,{date:Te(Date.parse(t.linkedAt))})})]}),!n&&a&&(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>g({kind:`link`,link:t}),children:q(`signOut`)})]},t.id)})]}),p.length>0&&(0,Y.jsx)(G,{className:`mt-3`,onClick:()=>g({kind:`others`}),children:q(`signOutOthers`)}),u&&(0,Y.jsx)(F,{title:nc(u,t),description:rc(u),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>d(void 0),children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,loading:o,onClick:()=>void h(u),children:q(`signOut`)})]}),children:(0,Y.jsx)(O,{message:c})})]})},ac=()=>{let{session:e,staffSignIn:t,deviceLinks:n}=k(),{account:r}=e,i=(0,J.useCallback)(async()=>{let[e,t]=await Promise.all([r.sessions(),n?r.deviceLinks():[]]);return{sessions:e,links:t}},[r,n]),{data:a,error:o,reload:s}=D(i,q(`couldNotReadDevices`));return a?(0,Y.jsx)(ic,{sessions:a.sessions,links:a.links,operator:t,onSignOut:e=>r.revokeSession(e).then(s),onSignOutOthers:()=>r.revokeOtherSessions().then(s),onSignOutLink:e=>r.signOutDeviceLink(e).then(s)}):(0,Y.jsx)(M,{error:o})},oc={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},sc=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(),g=e===`required`&&t.length<=1,_=async e=>{s(!0),l(void 0),h(void 0);try{await e(),d(void 0)}catch(e){if(!(e instanceof A))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(`asked`):l(V(e))}s(!1)};return(0,Y.jsxs)(N,{title:q(`passkeys`),status:e===`required`&&(0,Y.jsx)(I,{tone:`blue`,children:q(`required`)}),description:q(oc[e]),children:[(0,Y.jsx)(O,{message:u?void 0:c}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,Y.jsx)(v,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??q(`passkey`)}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?q(`addedOn`,{date:Ke(Date.parse(e.createdAt))}):q(`addedEarlier`),` · `,e.backedUp?q(`synced`):q(`oneDevice`)]})]}),(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>{p(e.name??``),d({kind:`rename`,passkey:e})},children:q(`rename`)}),(0,Y.jsx)(G,{size:`sm`,variant:`ghost`,disabled:g,title:g?q(`keepLastPasskey`):void 0,onClick:()=>d({kind:`remove`,passkey:e}),children:q(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,Y.jsxs)(G,{loading:o&&!u,onClick:()=>void _(n),children:[(0,Y.jsx)(Me,{className:`size-3.5`}),q(`addPasskey`)]}),m===`asked`&&(0,Y.jsx)(st,{purpose:`change`,withPassword:!0,minutes:15,onConfirmed:()=>h(`done`)}),m===`done`&&(0,Y.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:q(`confirmedAddPasskey`)}),u?.kind===`rename`&&(0,Y.jsxs)(F,{title:q(`renamePasskey`),description:q(`renamePasskeyDescription`),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>d(void 0),children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:o,disabled:!f.trim(),onClick:()=>void _(()=>r(u.passkey.id,f.trim())),children:q(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`name`),(0,Y.jsx)(a,{autoFocus:!0,value:f,maxLength:60,onChange:e=>p(e.target.value)})]}),(0,Y.jsx)(O,{message:c})]}),u?.kind===`remove`&&(0,Y.jsx)(F,{title:q(`removePasskey`),description:q(`removePasskeyDescription`,{name:u.passkey.name??q(`thisPasskey`)}),onClose:()=>d(void 0),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>d(void 0),children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`danger`,loading:o,onClick:()=>void _(()=>i(u.passkey.id)),children:q(`remove`)})]}),children:c&&(0,Y.jsx)(O,{message:c})})]})},cc=()=>{let{account:e}=k().session,t=(0,J.useCallback)(()=>Promise.all([e.signInMethods(),e.passkeys()]),[e]),{data:n,error:r,reload:i}=D(t,q(`couldNotReadMethods`));if(!n)return(0,Y.jsx)(M,{error:r});let[a,o]=n;return(0,Y.jsx)(sc,{rule:a.policy.passkey,passkeys:o,onAdd:()=>e.addPasskey().then(i),onRename:(t,n)=>e.renamePasskey(t,n).then(i),onRemove:t=>e.removePasskey(t).then(i)})},lc=e=>e.code===`PASSWORD_TOO_SHORT`?q(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?q(`passwordTooLong`):V(e),uc=(e,t)=>{if(e.length<12)return q(`useAtLeast`,{length:12});if(e!==t)return q(`passwordsDiffer`)},dc=({hasPassword:e,onSave:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),m=(0,J.useId)(),h=(!e||r)&&o&&c,g=async()=>{let e=uc(o,c);if(p(e),!e){d(!0);try{await t({current:r,next:o})}catch(e){if(!(e instanceof A))throw e;p(lc(e)),d(!1)}}};return(0,Y.jsx)(F,{title:q(e?`changePassword`:`setPassword`),description:q(`atLeast`,{length:12}),onClose:n,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:n,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,type:`submit`,form:m,loading:u,disabled:!h,children:q(`save`)})]}),children:(0,Y.jsxs)(`form`,{id:m,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),g()},children:[e&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`currentPassword`),(0,Y.jsx)(a,{type:`password`,name:`current-password`,autoComplete:`current-password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`newPassword`),(0,Y.jsx)(a,{type:`password`,name:`new-password`,autoComplete:`new-password`,autoFocus:!e,value:o,invalid:!!f,onChange:e=>s(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`repeatPassword`),(0,Y.jsx)(a,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,value:c,invalid:!!f,onChange:e=>l(e.target.value)})]}),e&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:q(`changeSignsOutOthers`)}),(0,Y.jsx)(O,{message:f})]})})},fc=({rule:e,hasPassword:t,staff:n})=>q(n?`passwordStaff`:e===`forbidden`?`passwordForbidden`:t?`passwordIsSet`:`passwordNotSet`),pc=({rule:e,hasPassword:t,staff:n,onChange:r,onSet:a})=>{let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),u=!n&&e===`allowed`;return(0,Y.jsxs)(N,{title:q(`password`),description:fc({rule:e,hasPassword:t,staff:n}),children:[(0,Y.jsx)(i,{message:c?q(`passwordSaved`):void 0}),u&&(0,Y.jsx)(G,{onClick:()=>{l(!1),s(!0)},children:q(t?`changePassword`:`setPassword`)}),o&&(0,Y.jsx)(dc,{hasPassword:t,onClose:()=>s(!1),onSave:async({current:e,next:n})=>{await(t?r(e,n):a(n)),s(!1),l(!0)}})]})},mc=()=>{let{session:e,state:t}=k(),{account:n}=e,{data:r,error:i,reload:a}=D((0,J.useCallback)(()=>n.signInMethods(),[n]),q(`couldNotReadMethods`));return r?(0,Y.jsx)(pc,{rule:r.policy.password,hasPassword:r.account.password,staff:t.kind===`signed-in`&&!!t.staff,onChange:(e,t)=>n.changePassword(e,t).then(a),onSet:e=>n.setPassword(e).then(a)}):(0,Y.jsx)(M,{error:i})},hc=({email:e,change:t,onDone:n,onClose:r})=>{let[i,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(),h=async e=>{f(!0),m(void 0);try{await e()}catch(e){if(!(e instanceof A))throw e;m(V(e))}f(!1)},g=i.trim(),_=()=>h(async()=>{await t.request(g),u(``),c(g)}),v=e=>h(async()=>{await t.confirm(s,e),n()});return s?(0,Y.jsxs)(F,{title:q(`changeEmail`),description:q(`codeSentTo`,{email:s,minutes:10}),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{variant:`ghost`,onClick:()=>{c(void 0),m(void 0)},children:q(`otherAddress`)}),(0,Y.jsx)(G,{variant:`primary`,loading:d,disabled:l.length<6,onClick:()=>void v(l),children:q(`changeEmail`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`code`),(0,Y.jsx)(Ot,{name:`code`,required:!0,autoFocus:!0,value:l,invalid:!!p,onChange:u,onComplete:e=>!d&&void v(e)})]}),(0,Y.jsx)(O,{message:p})]}):(0,Y.jsxs)(F,{title:q(`changeEmail`),description:q(`changeEmailDescription`),onClose:r,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:r,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:d,disabled:!g||g.toLowerCase()===e.toLowerCase(),onClick:()=>void _(),children:q(`sendCode`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`newEmail`),(0,Y.jsx)(a,{type:`email`,autoComplete:`email`,autoFocus:!0,value:i,onChange:e=>o(e.target.value)})]}),(0,Y.jsx)(O,{message:p})]})},gc=({name:e,email:t,onRename:n,emailChange:r,onEmailChanged:i})=>{let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(),g=async()=>{p(!0),h(void 0);try{await n(u.trim()),s(!1)}catch(e){if(!(e instanceof A))throw e;h(V(e))}p(!1)};return(0,Y.jsxs)(N,{title:q(`profile`),description:q(`profileDescription`),children:[(0,Y.jsxs)(`dl`,{className:`mb-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:q(`name`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:e}),(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:q(`email`)}),(0,Y.jsx)(`dd`,{className:`min-w-0 truncate font-medium`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(G,{onClick:()=>{d(e),h(void 0),s(!0)},children:q(`changeName`)}),r&&(0,Y.jsx)(G,{onClick:()=>l(!0),children:q(`changeEmail`)})]}),o&&(0,Y.jsxs)(F,{title:q(`changeName`),description:q(`changeNameDescription`),onClose:()=>s(!1),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:()=>s(!1),children:q(`cancel`)}),(0,Y.jsx)(G,{variant:`primary`,loading:f,disabled:!u.trim()||u.trim()===e,onClick:()=>void g(),children:q(`save`)})]}),children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`name`),(0,Y.jsx)(a,{autoFocus:!0,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,Y.jsx)(O,{message:m})]}),c&&r&&(0,Y.jsx)(hc,{email:t,change:r,onClose:()=>l(!1),onDone:()=>{l(!1),i?.()}})]})},_c=()=>{let{session:e,changeEmail:t}=k(),{data:n,loaded:r,error:i,reload:a}=D((0,J.useCallback)(()=>e.session(),[e]),q(`couldNotReadProfile`));if(!r)return(0,Y.jsx)(M,{error:i});if(!n)return null;let o=t?{request:e.account.requestEmailChange,confirm:e.account.changeEmail}:void 0;return(0,Y.jsx)(gc,{name:n.name,email:n.email,onRename:t=>e.account.updateName(t).then(a),emailChange:o,onEmailChanged:a})},vc=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:o,onClose:s})=>{let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),[m,h]=(0,J.useState)(!1),g=async()=>{d(!0),p(void 0),h(!1);try{await o(i?c:void 0)}catch(e){if(!(e instanceof A))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?h(!0):p(V(e)),d(!1)}};return(0,Y.jsxs)(F,{title:e,description:t,onClose:s,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(G,{onClick:s,children:q(`cancel`)}),(0,Y.jsx)(G,{variant:r?`danger`:`primary`,loading:u,disabled:i&&!c,onClick:()=>void g(),children:n})]}),children:[i&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[q(`yourPassword`),(0,Y.jsx)(a,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:c,invalid:!!f,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&c&&void g()})]}),f&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:f}),m&&(0,Y.jsx)(st,{purpose:`change`,minutes:15,onConfirmed:()=>void g()})]})},yc={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},bc=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,J.useState)(),d=()=>u(void 0),f=n?(0,Y.jsx)(I,{tone:`green`,children:q(`on`)}):t===`required`?(0,Y.jsx)(I,{tone:`amber`,children:q(`required`)}):(0,Y.jsx)(I,{children:q(`off`)}),p=q(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:yc[t]);return l?.kind===`setup`?(0,Y.jsx)(N,{title:q(`twoFactor`),status:f,description:p,children:(0,Y.jsx)(`div`,{className:`max-w-sm`,children:(0,Y.jsx)(tt,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,Y.jsxs)(N,{title:q(`twoFactor`),status:f,description:p,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,Y.jsx)(G,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:q(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,Y.jsx)(G,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:q(`addAuthenticator`)}),n&&r&&(0,Y.jsx)(G,{onClick:()=>u({kind:`new-codes`}),children:q(`newBackupCodes`)}),n&&(0,Y.jsx)(G,{variant:`danger`,disabled:t===`required`,title:t===`required`?q(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:q(`turnOff`)})]}),l?.kind===`turn-off`&&(0,Y.jsx)(vc,{title:q(`turnOffTitle`),description:q(`turnOffDescription`),confirmLabel:q(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,Y.jsx)(vc,{title:q(`newCodesTitle`),description:q(`newCodesDescription`),confirmLabel:q(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,Y.jsx)(F,{title:q(`yourNewCodes`),description:q(`keepCodesSafe`),onClose:d,actions:(0,Y.jsx)(G,{variant:`primary`,onClick:d,children:q(`savedCodes`)}),children:(0,Y.jsx)(Ut,{codes:l.codes})})]})},xc=()=>{let{account:e}=k().session,{data:t,error:n,reload:r}=D((0,J.useCallback)(()=>e.signInMethods(),[e]),q(`couldNotReadMethods`));return t?(0,Y.jsx)(bc,{rule:t.policy.twoFactor,enabled:t.account.twoFactor,authenticatorApp:t.account.authenticatorApp,mail:t.mail,needsPassword:t.account.password,onStartApp:t=>e.startAuthenticatorApp(t),onConfirmApp:t=>e.confirmAuthenticatorApp(t),onEmailedCodes:t=>e.turnOnEmailedCodes(t),onTurnOff:t=>e.turnOffTwoFactor(t),onNewBackupCodes:t=>e.newBackupCodes(t),onChanged:r}):(0,Y.jsx)(M,{error:n})},Sc=({problem:e,fallback:t})=>t===void 0?(0,Y.jsx)(ae,{children:e}):(0,Y.jsxs)(Y.Fragment,{children:[!1,t]}),Cc=({name:e,registered:t,fallback:n,children:r})=>t?(0,Y.jsx)(se,{name:e,fallback:n===void 0?void 0:(0,Y.jsx)(Sc,{problem:U.rich(`couldNotDraw`,{name:e}),fallback:n}),children:r}):(0,Y.jsx)(Sc,{problem:U.rich(`noComponent`,{component:e}),fallback:n}),wc={Page:Pa,Grid:ua,Card:ii,Stat:yo,RecordCard:Ra,Field:aa,Diff:na,Table:wo,CardRow:ci,RecordRow:ro,RecordCards:$a,Chart:li,Timeline:qi,Graph:Zi,Progress:Ia,Image:va,ModalForm:Na,Thread:Zo,Composer:$i,Action:ri,Show:fo,Switch:mo,Match:ho,Link:Oa,Settings:so,Tabs:Eo,Tab:Do,Users:_s,Profile:_c,Password:mc,Passkeys:cc,TwoFactor:xc,ConnectedAccounts:ce,PersonalMail:Cs,Connections:Us,Devices:ac,ConnectedApps:js,PersonalAccessTokens:zs,DeleteAccount:qs,Box:Qo,Row:$o,Column:es,Text:ts,ReferenceManyField:os,ReferenceArrayField:cs,ArrayField:ns,RecordsIterator:oi,ReferenceField:us,SelectInput:rs,Details:ea,Summary:ta,TextField:xa,NumberField:Sa,DateField:Ca,BooleanField:wa,UrlField:Ta,ChipField:Ea},Tc=new Set(`Page.Grid.Card.Stat.RecordCard.Field.Diff.Table.CardRow.RecordRow.RecordCards.Chart.Timeline.Graph.Progress.Image.Thread.Link.Tabs.Settings.Show.Switch.Action.Box.Row.Column.Text.ReferenceField.SelectInput.Details.Summary.TextField.NumberField.DateField.BooleanField.UrlField.ChipField`.split(`.`)),Ec=(e,t,...n)=>e.map((e,r)=>({child:e,...t!==void 0&&{at:Pt(t,...n,r)}})),Dc=({text:e})=>{let t=z(),n=vt(),r={...K(t),params:n};return(0,Y.jsx)(Y.Fragment,{children:ze(e,e=>oe(Lt(r,e)))})},Oc=(e,t)=>e.includes(`{{`)?(0,Y.jsx)(Dc,{text:e},t):(0,Y.jsx)(J.Fragment,{children:e},t),kc=e=>e.map(({child:e,at:t},n)=>typeof e==`string`?Oc(e,n):(0,Y.jsx)(Ic,{node:e,at:t},n)),Ac=e=>{let t=[];for(let n of e){let e=t.at(-1);Ur(n.child)&&e&&Ur(e[0].child)?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return Ur(n.child)?(0,Y.jsx)(`p`,{className:`leading-6`,children:kc(e)},t):(0,Y.jsx)(Ic,{node:n.child,at:n.at},t)})},jc=e=>le(e)||Array.isArray(e)&&e.length>0&&e.every(le),Mc=(e,t)=>Object.fromEntries(Object.entries(e.props).flatMap(([e,n])=>jc(n)?[[e,(0,Y.jsx)(Y.Fragment,{children:Ac(Nc(n,t,e))})]]:[])),Nc=(e,t,n)=>Array.isArray(e)?Ec(e,t,`props`,n):[{child:e,...t!==void 0&&{at:Pt(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])=>le(t)?[[e,e=>({...t,children:[...t.children,...e]})]]:[])),i=b(t,String(e.props.i18nKey),Pc(e.props.values)?e.props.values:{},r);return Array.isArray(i)?i.map(e=>typeof e==`string`||le(e)?e:String(e)):[i]},Ic=({node:e,at:t})=>{let{components:n}=xe(),r=z(),i=vt(),a=lt(),o=(0,J.useMemo)(()=>Bt(_(e,{...K(r),params:i}),a),[e,r,i,a]);if(o.type===`Trans`&&!o.custom)return(0,Y.jsx)(Y.Fragment,{children:kc(Fc(o,a).map(e=>({child:e})))});if(o.custom){let e=n?.[o.type],r=o.children.length>0?(0,Y.jsx)(Ji,{node:o,children:Ac(Ec(o.children,t,`children`))}):void 0;return(0,Y.jsx)(Cc,{name:o.type,registered:!!e,fallback:o.fallback&&(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:e&&(0,Y.jsx)(De,{node:o,...t!==void 0&&{at:t},children:(0,Y.jsx)(e,{...Se(o.props),children:r})})})}let s=wc[o.type];if(!s)return(0,Y.jsx)(ae,{children:U.rich(`unknownBlock`,{type:o.type})});let c=typeof o.props.className==`string`?o.props.className:void 0,l=Ec(o.children,t,`children`),u=(0,Y.jsx)(s,{node:o,at:t,slots:Mc(o,t),className:c,children:o.type===`Text`||o.type===`Link`||o.type===`Summary`?kc(l):Ac(o.type===`Switch`?l.filter(({child:e})=>typeof e!=`string`):l)}),d=c===void 0||Tc.has(o.type)?u:(0,Y.jsx)(`div`,{className:c,children:u});return o.fallback?(0,Y.jsx)(se,{name:o.type,resetKey:o,fallback:(0,Y.jsx)(Y.Fragment,{children:Ac(Ec(o.fallback,t,`fallback`))}),children:d}):d};export{qo as a,Fo as c,Za as d,Ha as f,Yo as i,bo as l,Qi as m,Cc as n,Ko as o,za as p,Xo as r,Wo as s,Ic as t,co as u};
3
- //# debugId=338cc632-9e70-46cb-97e4-f568d30da380
@@ -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{$c as r,Br as i,Ca as a,Ja as o,Jr as s,Js as c,La as l,Pa as u,Ql as d,Wc as f,Xl as p,Xn as m,Ys as h,Zn as g,as as _,bn as v,cc as y,cn as b,ei as x,el as S,fl as C,fs as w,gl as T,gr as E,ll as D,sc as O,uc as k,vi as A,wa as j,zc as M}from"./app-B8KcM2Z-.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-C3nd1V5o.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as B,r as ee,s as V,t as H}from"./messages-CZQvPUZQ.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=f(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=f(G),q=e(t(),1),J=S(`app/delete`),Y=p(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let s=n[a]?.names?.plural??C(a),c=X({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let l={kind:`list`,resource:a,filter:d(Y.eq(o,i))};return{text:c,link:{label:J(`show`,{plural:s}),to:l}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(y,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(k,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(k,{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)(y,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(k,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(k,{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)(y,{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)(k,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(k,{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)(y,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(k,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(y,{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)(k,{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??C(e.name),before:A(e,n[e.name],i),after:A(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:a})=>{let o=w(),s=N(),u=l(),[d,f]=(0,q.useState)(),[p,m]=(0,q.useState)(!1),g=t?.names?.singular??C(e.name),v=t?.names?.plural??C(e.name),{resources:y,views:b}=_(),{href:x,open:S}=i(),T=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:y,views:b,noun:g,...e.primaryKey.length===1&&{key:n.key}}),E=()=>{for(let t of[`page`,`list`,`first-page`,`map`])s.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])s.invalidateQueries({queryKey:[t,e.name]})},D=async(t,n)=>{let r=n??(await o.get(e.name,t.key)).etag;try{await o.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof c))throw e;return e}},O=t=>{E(),f(void 0),n?.(t),u.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&a&&{action:{label:J(`undo`),onClick:()=>{a(t).then(()=>{E(),u.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!h(e))throw e;E(),u.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},k=async(n,r)=>{m(!0);try{if(!await D(n,r))return O(n);let i=(await o.get(e.name,n.key)).record;f({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!h(e))throw e;f(void 0);let t=T(e,n);u.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)}},A=async e=>{try{return await D(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!h(t))throw t;return{title:e.title,message:T(t,e)?.text??t.message}}},j=async e=>{let t=[],n=[],r=0;f({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await A(a);i&&(t.push(i),n.push(a)),r+=1,f({kind:`bulk-running`,done:r,total:e.length})}})),E(),f({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>f(void 0);return{dialogs:d&&(0,Q.jsxs)(Q.Fragment,{children:[d.kind===`confirm`&&(0,Q.jsx)(te,{title:d.target.title,noun:g,busy:p,onCancel:M,onConfirm:()=>void k(d.target,d.target.etag)}),d.kind===`conflict`&&(0,Q.jsx)(ne,{title:d.target.title,changes:d.changes,busy:p,onCancel:M,onReview:()=>{M(),r?.(d.target,d.fresh)},onDeleteAnyway:()=>void k(d.target,`*`)}),d.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:d.targets.length,noun:g,plural:v,onCancel:()=>{M(),d.settle(d.targets)},onConfirm:()=>d.settle(j(d.targets))}),d.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:d.done,total:d.total}),d.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:d.total,failures:d.failures,onClose:M})]}),start:t=>e.softDelete?k(t,t.etag):f({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>f({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=w();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=>T(j(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:i,fields:o,rule:c})=>{let u=w(),d=l(),f=v(),{resources:p,views:h}=_(),y=`${n} asc`,b=P({queryKey:[...r.list(e.name,i,y,500,`hand-order`),o.join(`,`)],queryFn:async()=>{let t=m(p,h,e,o),n=[],r=``;do{let s=await u.search(e.name,{filter:i||void 0,orderBy:y,pageSize:500,labels:t,...r&&{pageToken:r}});n.push(...g(p,e,o,s.items,s.labels).map((t,n)=>({...t,id:a(e,s.items[n])}))),r=s.nextPageToken}while(r);return n}}),[x,S]=(0,q.useState)(),C=(0,q.useRef)(void 0),T=(0,q.useRef)([]),E=(0,q.useRef)(void 0),O=(0,q.useRef)(Promise.resolve()),k=(0,q.useRef)(0),A=(0,q.useRef)(void 0),j=async()=>{let t=C.current,r=T.current;if(T.current=[],!t||r.length===0)return;let i=await u.batchWrite(r),o=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[a(e,t.record),t])),s=z(i.results,t=>a(e,t)),c=L(e,[...o].map(([e,t])=>({...t,before:{[n]:s.get(e)}})),[n]);A.current!==void 0&&d.dismiss(A.current),A.current=d.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(c)}}),C.current&&=C.current.map(e=>{let t=o.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},M=(e,t)=>n=>{C.current=void 0,T.current=[],S(void 0),d.show(B(n,e,{place:`list`,title:t?E.current:void 0}))},N=async()=>{--k.current,!(k.current>0)&&(await f(e.name),!(k.current>0)&&(C.current=void 0,S(void 0)))},F=(n,r)=>{let i=C.current??b.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,c);let a=s(e,i[n]).record,o=i[n].id;R(u,e,t,a).then(n=>{let i=C.current??b.data,s=ce(e,n,D(e,t,a,o));H(i,i.findIndex(e=>e.id===o),r,e=>s(e)??c?.(e))},M(V(`couldNotChange`),!1))},H=(r,a,o,c)=>{if(a===-1||a===o)return;let l=c?U(r,a,o,c):o;a!==l&&(C.current=I(r,a,l),T.current=[...T.current,ee(e,n,i,C.current,l)],S(C.current),k.current+=1,E.current=D(e,t,s(e,r[a]).record,r[a].id),O.current=O.current.then(j).catch(M(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>s(e,t).record),n,r,i);return a.reason!==void 0&&d.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{A.current!==void 0&&d.dismiss(A.current),A.current=void 0,k.current+=1,O.current=O.current.then(async()=>{await u.batchWrite(e),C.current=void 0,T.current=[],S(void 0)}).catch(M(V(`couldNotUndo`),!1)).then(N)};return{rows:x??b.data,loading:b.isPending,error:b.error,move:F}},de=({model:e,view:t,field:n,filter:r,columns:a,sort:s})=>{let{resources:c,views:l}=_(),{fields:d,dropRules:f}=u(),{go:p,href:m}=i(),h=s!==void 0,g=(0,q.useMemo)(()=>b(e,t,a,{resources:c,views:l,fieldTypes:d}).map(e=>h?e:{...e,sortable:!1}),[e,t,a.join(`,`),c,l,d,h]),v=(0,q.useMemo)(()=>x(e,t,g.map(e=>e.id)),[e,t,g]),y=t?.list?.drag?.rule,S=y===void 0?void 0:f?.[y],C=ue({model:e,view:t,field:n,filter:r,fields:v,...S&&{rule:S}}),w=C.rows,T=(0,q.useMemo)(()=>w&&{total:w.length,rowAt:e=>w[e]},[w]);if(y!==void 0&&!S)return(0,Q.jsx)(o,{children:V.rich(`noRule`,{rule:y})});if(C.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(C.error)return(0,Q.jsx)(E,{title:V(`couldNotLoad`),error:C.error});if(!T||T.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let k=t=>p({kind:`record`,resource:e.name,key:j(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:g,source:T,latencyMs:0,onOpenRow:k,rowLink:t=>({href:m({kind:`record`,resource:e.name,key:j(e,t)}),onFollow:()=>k(t)}),...s&&{sort:s.value,onSortChange:s.onChange},rowNumbers:!1,reorder:{label:n=>D(e,t,n,n.id),onMove:C.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(k,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(M,{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=468282c3-c779-4aeb-9de2-2310809f625e
@@ -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,$t as t,Ao as n,At as r,B as ee,Bn as te,Br as i,Bt as a,Co as o,Cr as s,Ct as c,Dr as l,Dt as u,Er as d,Et as f,Fo as p,Ft as m,G as h,Gi as g,H as _,Hi as v,Ht as y,Ia as b,Ir as x,It as S,Jc as C,Ji as w,K as T,Kc as E,Ki as D,Lr as O,Lt as k,Ma as A,Mo as j,Mr as M,Mt as N,N as P,Na as F,No as I,Nr as L,Nt as R,P as z,Po as B,Pt as V,Q as H,Qc as U,R as W,Rr as G,Sr as K,St as q,Tn as J,Tt as Y,U as X,Ua as Z,Ui as Q,Ut as ne,V as re,Va as ie,Vo as ae,Vt as oe,W as se,Wa as ce,Wi as le,Wt as ue,X as de,Xc as fe,Xt as pe,Yc as me,Yi as he,Yt as ge,Zc as _e,Zt as ve,_r as $,_t as ye,ac as be,bt as xe,cc as Se,cr as Ce,dc as we,do as Te,ds as Ee,dt as De,en as Oe,et as ke,fc as Ae,fs as je,ft as Me,go as Ne,gt as Pe,ho as Fe,ht as Ie,it as Le,jr as Re,lo as ze,ma as Be,mt as Ve,n as He,nt as Ue,ot as We,ps as Ge,pt as Ke,qc as qe,qi as Je,qt as Ye,r as Xe,rt as Ze,t as Qe,tl as $e,tt as et,uc as tt,uo as nt,us as rt,ut as it,vo as at,vr as ot,vt as st,wr as ct,wt as lt,xo as ut,xr as dt,xt as ft,yo as pt,yr as mt,yt as ht,z as gt,zr as _t}from"./app-B8KcM2Z-.js";import{h as vt,o as yt}from"./vendor-t7Q7QbPu.js";export{q as ActionCard,ct as ActionInputError,Ee as ApiProvider,O as App,_t as AppLink,B as AppMark,Me as AssistantDock,Te as AuthLayout,at as AvailabilityMark,tt as Button,a as CallMark,ue as CallView,T as Carousel,V as ChatDivider,R as ChatMessage,N as ChatThread,gt as Choices,ze as CodeForm,xe as CompactTable,lt as Composer,Se as Dialog,ye as DiffView,W as Field,ve as FieldBadge,ft as FieldList,ot as FileReadError,e as FocusActions,ke as FocusNotice,Le as FocusPage,et as FocusPanel,Ue as FocusSlot,P as Form,K as HtmlFrame,He as InPlaceForm,n as Input,p as LogoMark,J as Markdown,f as MentionBox,Y as MentionedText,ee as MenuSelect,ut as MenuSurface,Fe as OtpInput,Ve as PartView,y as RecordCall,Ye as RecordLink,Qe as RecordPicker,nt as ResendCodeButton,D as ResponsiveDialog,be as RouteLink,de as SearchPicker,z as Section,o as Segmented,re as Select,c as SidePanel,k as SignInPrompt,Ae as Spinner,pt as StatusMark,Ie as StepList,te as Textarea,pe as ToneEdge,_ as allowDelayMs,we as buttonClass,m as chatDayLabel,ae as closeSidebarEvent,A as definePlugin,F as defineUi,st as diffStats,u as emptyDraft,qe as extensionPointsOf,s as fileNamed,d as isConflict,X as isFramed,I as logoTapEvent,r as mentionedIds,me as mergeUi,ht as parseDiff,Pe as parsePatch,_e as pluginApi,E as pluginsChangedEvent,U as protobaseVersion,S as sameChatDay,$e as showTextsIn,dt as siblingPage,Ne as signedOutEvent,Q as statusRefreshMs,fe as uiFromModule,G as uiReadyEvent,ce as useApiToken,i as useAppAddress,se as useArmedAfterFocus,De as useAssistant,it as useAssistantClient,Ke as useBackendData,je as useClient,t as useComponentReads,Oe as useComponentSelect,Xe as useCreateForm,Re as useFacets,j as useFieldControl,mt as useFileText,We as useFocusPage,H as useFocusRecord,Ze as useFocusZoneFilled,h as useGuardedPress,M as useHistogram,Je as useInbox,Ce as useLayoutRecord,x as useList,ge as useListDisplay,w as useMarkNotificationsRead,v as useMembers,rt as useMeta,le as useOwnStatus,C as usePlugin,b as usePresence,Be as usePushNotifications,yt as useQuery,vt as useQueryClient,ie as useRecord,ne as useRecordCallAddress,oe as useRecordCalls,Ge as useResourceClient,L as useSeries,$ as useSiblingPage,Z as useSignedInUser,g as useStatuses,he as useUnreadNotifications,l 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{Gc as r,Qi as i,Qo as a,Ss as o,Ts as s,Zo as c,es as l,fc as u,ns as d,rl as f,uc as p,xs as m}from"./app-B8KcM2Z-.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:m(`on`)},{value:`forbidden`,label:m(`off`)}],v=()=>[{value:`allowed`,label:m(`optional`)},{value:`required`,label:m(`required`)},{value:`forbidden`,label:m(`off`)}],y=()=>[{method:`password`,label:m(`password`),description:m(`passwordDescription`),rules:_()},{method:`emailCode`,label:m(`emailedSignInCode`),description:m(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:m(`passkeys`),description:m(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:m(`twoFactor`),description:m(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:m(`staffAccess`),description:m(`staffAccessDescription`),rules:[{value:`allowed`,label:m(`on`)},{value:`notify`,label:m(`emailThePerson`)},{value:`forbidden`,label:m(`off`)}]},{method:`platformSignIn`,label:m(`platformSignIn`),description:m(`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:r(`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 m(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return m(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return m(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return m(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return m(`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:m(`platformSignInWith`,{provider:new Intl.ListFormat(f(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:r,notice:a})=>{let[o,s]=(0,g.useState)(e.policy),c=w(e),l=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)})}),r&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),a&&!l&&(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?m(`lastSavedBy`,{name:e.savedBy,time:i(Date.parse(e.savedAt))}):m(`lastSaved`,{time:i(Date.parse(e.savedAt))}):m(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[l&&(0,x.jsx)(p,{onClick:()=>s(e.policy),children:m(`reset`)}),(0,x.jsx)(p,{variant:`primary`,type:`submit`,loading:n,disabled:!l,children:m(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(l,{tone:`neutral`,children:m(`stopped`,{time:i(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(l,{tone:`neutral`,children:m(`ended`,{time:i(Date.parse(e.expiresAt))})}):(0,x.jsx)(l,{tone:`amber`,children:m(`signedInUntil`,{time:i(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,x.jsxs)(c,{title:m(`staffSignIns`),description:m(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(a,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:m(`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:m(`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:i(Date.parse(e.startedAt))}),E(e,r)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=o(),[n,r]=(0,g.useState)(),[i,a]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof s?d(e):m(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:i})},k=()=>{let{session:e}=o(),[t,n]=(0,g.useState)(),[r,i]=(0,g.useState)(!1),[a,c]=(0,g.useState)(),[l,f]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>c(e instanceof s?d(e):m(`couldNotReadPolicy`)))},[e]);let p=async t=>{i(!0),c(void 0),f(void 0);try{n(await e.signInPolicy.save(t)),f(m(`policySaved`))}catch(e){if(!(e instanceof s))throw e;c(d(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:m(`signInPolicy`),subtitle:m(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:r,error:a,notice:l,onSave:e=>void p(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,{}),` `,m(`loading`)]})]})};export{k as SignInPolicyPage};
2
- //# debugId=94894f19-20d1-4ef5-8aaf-2ab700c58138
@@ -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{As as n,Ds as r,Fr as i,Ms as a,Or as o,Pa as s,Uo as c,Us as l,Xn as u,an as d,as as f,ba as p,er as m,fn as h,fs as g,lr as _,mn as v,nr as y,on as b,pn as x,sn as S,sr as C}from"./app-B8KcM2Z-.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-C3nd1V5o.js";import{n as O}from"./record-preview-CwySCCRj.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:o=``,columns:s,button:c,bulk:l=!1,limit:u=10,select:f}=b(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(x(n.client,m,{key:e}))]:[]}let h=n.views[m.name],{fields:g,read:_}=S({...n,model:m,view:h,columns:s?.map(a),button:c,bulk:l,phoneColumns:d(s)});return[A(D(n,{model:m,filter:i,orderBy:o||p(m,h),limit:u,fields:g,read:_}))]},Chart:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=b(e),h=r[a],g=h&&E({model:h,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},r,i);return h&&g?[A(o(n,h.name,g))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=b(e),l=r[a];if(!l)return[];let u=s||p(l,i[l.name]);return[A(v(n,l,{filter:o,sort:u,pageSize:c})),A(h(n,l,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=b(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:a})=>{let{resource:o,filter:s,sender:c,time:d,calls:f,limit:p=50}=b(e);if(t.part===`calls`){let e=f&&r[f.resource];return e?[j(i(n,e.name,{filter:f.filter,orderBy:l(f.time),pageSize:p}))]:[]}let m=r[o];if(!m)return[];let h=u(r,a,m,c===void 0?[]:[c]);return[j(i(n,m.name,{filter:s,orderBy:l(d),pageSize:p,labels:h}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(h(n,i))]:[]},P=(e,t,i)=>(i?.reads??[]).flatMap(i=>{let a=n(t,i.block);if(!a||a.custom)return[];if(i.part===`condition`)return N(a,i,e);if(i.split)return[];let o=M[a.type];return o?o(r(a,{stack:[],params:e.params,...e.root&&{root:e.root}}),i,e):[]}),F=({tree:e,plan:t})=>{let n=g(),r=w(),{resources:i,views:a}=f(),o=s().fields,l=c(),u=m(),d=y(),p=C(_()),h=(0,k.useMemo)(()=>P({client:n,queryClient:r,resources:i,views:a,fieldTypes:o,xs:l,params:u,given:d,...p&&{root:p}},e,t),[n,r,i,a,o,l,u,d,p,e,t]);return(0,k.useEffect)(()=>{for(let e of h)e.start(r)},[h,r]),null};export{F as t};
2
- //# debugId=d4bd8172-7972-4d34-bccb-36bdb95e2d9e