@protobase/ui 0.121.10 → 0.121.12

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 (321) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/activity-chart/messages.d.ts +2 -2
  3. package/dist/app/app.js +3 -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/confirm-sign-in-messages.d.ts +2 -2
  7. package/dist/app/conversation/message-composer.d.ts +5 -1
  8. package/dist/app/conversation/message-composer.js +10 -3
  9. package/dist/app/conversation/messages.d.ts +2 -2
  10. package/dist/app/conversation/thread-state.d.ts +1 -1
  11. package/dist/app/conversation-page/conversation-header.js +1 -1
  12. package/dist/app/conversation-page/conversation-message.js +1 -1
  13. package/dist/app/conversation-page/conversation-messages.js +1 -1
  14. package/dist/app/conversation-page/conversation-page.d.ts +5 -4
  15. package/dist/app/conversation-page/conversation-page.js +22 -6
  16. package/dist/app/conversation-page/message-editor.js +1 -1
  17. package/dist/app/conversation-page/message-ops.d.ts +3 -1
  18. package/dist/app/conversation-page/message-ops.js +7 -1
  19. package/dist/app/conversation-page/messages.d.ts +2 -2
  20. package/dist/app/conversation-page/reply-labels.js +1 -1
  21. package/dist/app/conversation-page/thread-panel.js +1 -1
  22. package/dist/app/conversation-page/use-message-writes.js +1 -1
  23. package/dist/app/create/messages.d.ts +2 -2
  24. package/dist/app/custom-section.d.ts +1 -1
  25. package/dist/app/delete/messages.d.ts +2 -2
  26. package/dist/app/displays/list-cards.d.ts +1 -1
  27. package/dist/app/displays/messages.d.ts +2 -2
  28. package/dist/app/embedded-list/messages.d.ts +2 -2
  29. package/dist/app/export/export-worker.js +1 -1
  30. package/dist/app/export/messages.d.ts +2 -2
  31. package/dist/app/field-messages.d.ts +2 -2
  32. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  33. package/dist/app/field-types/widget-part.d.ts +1 -1
  34. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  35. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  36. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  37. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  38. package/dist/app/file-viewers/messages.d.ts +2 -2
  39. package/dist/app/focus/messages.d.ts +2 -2
  40. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  41. package/dist/app/gallery/messages.d.ts +2 -2
  42. package/dist/app/hand-order/messages.d.ts +2 -2
  43. package/dist/app/history/messages.d.ts +2 -2
  44. package/dist/app/import/messages.d.ts +2 -2
  45. package/dist/app/list-messages.d.ts +2 -2
  46. package/dist/app/list-page.js +1 -1
  47. package/dist/app/main.js +1 -1
  48. package/dist/app/messages.d.ts +2 -2
  49. package/dist/app/meta-gate-messages.d.ts +2 -2
  50. package/dist/app/new-version/messages.d.ts +2 -2
  51. package/dist/app/pages/custom-boundary.d.ts +1 -1
  52. package/dist/app/pages/custom-chosen.d.ts +1 -1
  53. package/dist/app/pages/messages.d.ts +2 -2
  54. package/dist/app/record-chart/messages.d.ts +2 -2
  55. package/dist/app/record-lines.js +1 -1
  56. package/dist/app/record-messages.d.ts +2 -2
  57. package/dist/app/record-page.js +1 -1
  58. package/dist/app/record-row/messages.d.ts +2 -2
  59. package/dist/app/related-cards/messages.d.ts +2 -2
  60. package/dist/app/runtime/messages.d.ts +2 -2
  61. package/dist/app/saved/saved-list.d.ts +1 -1
  62. package/dist/app/saved/use-favorite.d.ts +1 -1
  63. package/dist/app/searches/messages.d.ts +2 -2
  64. package/dist/app/searches/use-save-search.d.ts +1 -1
  65. package/dist/app/use-nav-recent.d.ts +2 -2
  66. package/dist/app/use-nav-recent.js +5 -4
  67. package/dist/app-shell/messages.d.ts +2 -2
  68. package/dist/app-shell/nav.d.ts +5 -3
  69. package/dist/app-shell/record-marks.d.ts +1 -1
  70. package/dist/app-shell/record-marks.js +5 -3
  71. package/dist/app-shell/sidebar-records.d.ts +1 -1
  72. package/dist/app-shell/sidebar-records.js +6 -1
  73. package/dist/assistant-dock/messages.d.ts +2 -2
  74. package/dist/auth/messages.d.ts +2 -2
  75. package/dist/calls/messages.d.ts +2 -2
  76. package/dist/chat/composer.d.ts +3 -1
  77. package/dist/chat/composer.js +6 -2
  78. package/dist/chat/messages.d.ts +2 -2
  79. package/dist/compact-table/messages.d.ts +2 -2
  80. package/dist/data/api-provider.d.ts +33 -0
  81. package/dist/data/meta-data.d.ts +4 -0
  82. package/dist/data/use-live-updates.d.ts +5 -2
  83. package/dist/data/use-live-updates.js +25 -3
  84. package/dist/data/use-meta.js +1 -0
  85. package/dist/data-grid/messages.d.ts +2 -2
  86. package/dist/filter-panel/messages.d.ts +2 -2
  87. package/dist/index.d.ts +5 -1
  88. package/dist/index.js +5 -1
  89. package/dist/invitations/messages.d.ts +2 -2
  90. package/dist/locale/en.js +7 -2
  91. package/dist/locale/en.json.d.ts +5 -0
  92. package/dist/locale/messages.d.ts +10 -0
  93. package/dist/locale/nl.js +7 -2
  94. package/dist/locale/texts-gate.d.ts +1 -1
  95. package/dist/mailbox/messages.d.ts +2 -2
  96. package/dist/mentions/messages.d.ts +2 -2
  97. package/dist/mocks/orders.d.ts +2 -2
  98. package/dist/notifications/bell/messages.d.ts +2 -2
  99. package/dist/organizations/messages.d.ts +2 -2
  100. package/dist/package.js +1 -1
  101. package/dist/plugins/before-sign-in.d.ts +1 -1
  102. package/dist/plugins/messages.d.ts +2 -2
  103. package/dist/plugins/plugin-api.exports.js +5 -1
  104. package/dist/primitives/messages.d.ts +2 -2
  105. package/dist/record-view/messages.d.ts +2 -2
  106. package/dist/relay/count-unread.d.ts +12 -0
  107. package/dist/relay/count-unread.js +34 -0
  108. package/dist/relay/relay-context.d.ts +17 -0
  109. package/dist/relay/relay-context.js +23 -0
  110. package/dist/relay/relay-provider.d.ts +11 -0
  111. package/dist/relay/relay-provider.js +58 -0
  112. package/dist/relay/relay-store.d.ts +31 -0
  113. package/dist/relay/relay-store.js +77 -0
  114. package/dist/relay/typing-line.d.ts +11 -0
  115. package/dist/relay/typing-line.js +30 -0
  116. package/dist/relay/typing.d.ts +37 -0
  117. package/dist/relay/typing.js +78 -0
  118. package/dist/relay/unread.d.ts +30 -0
  119. package/dist/relay/unread.js +35 -0
  120. package/dist/relay/use-relay-marks.d.ts +11 -0
  121. package/dist/relay/use-relay-marks.js +53 -0
  122. package/dist/relay/use-typing-sender.d.ts +11 -0
  123. package/dist/relay/use-typing-sender.js +32 -0
  124. package/dist/relay/use-unread-counts.d.ts +9 -0
  125. package/dist/relay/use-unread-counts.js +61 -0
  126. package/dist/relay/use-view-channel.d.ts +7 -0
  127. package/dist/relay/use-view-channel.js +21 -0
  128. package/dist/shell/assets/{account-page-K162oV2K.js → account-page-BsAc4o17.js} +2 -2
  129. package/dist/shell/assets/app-Bb88M0VJ.js +36 -0
  130. package/dist/shell/assets/{assistant-shell-BudITySr.js → assistant-shell-CdVAnpMe.js} +2 -2
  131. package/dist/shell/assets/board-display-DKT7398I.js +2 -0
  132. package/dist/shell/assets/calendar-display-0c2dGTmG.js +2 -0
  133. package/dist/shell/assets/{call-rings-pKCPyD1-.js → call-rings-BV5na0xp.js} +2 -2
  134. package/dist/shell/assets/{calls-CLQwaemL.js → calls-n9IoOXzL.js} +2 -2
  135. package/dist/shell/assets/{circle-alert-05wFSlkE.js → circle-alert-kISSXwIV.js} +2 -2
  136. package/dist/shell/assets/{composed-page-D3_OTQB4.js → composed-page-hn7I0Ulk.js} +2 -2
  137. package/dist/shell/assets/{composer-section-BoFYW5rp.js → composer-section-Cb1kOpwt.js} +2 -2
  138. package/dist/shell/assets/{connect-route-D0m9ozLK.js → connect-route-l21XyxhS.js} +2 -2
  139. package/dist/shell/assets/{copy-field-DjAdwdDh.js → copy-field-D22CFeg3.js} +2 -2
  140. package/dist/shell/assets/create-route-CSe9DhbY.js +2 -0
  141. package/dist/shell/assets/{custom-step-container-field-DTCgqZMO.js → custom-step-container-field-C5l4j0FI.js} +4 -4
  142. package/dist/shell/assets/embedded-list-DjvOszEj.js +3 -0
  143. package/dist/shell/assets/en-DnsB2haa.js +2 -0
  144. package/dist/shell/assets/{export-dialog-BVmThgqO.js → export-dialog-Bh3TSYyL.js} +2 -2
  145. package/dist/shell/assets/export-worker-DbK8hf_0.js +15 -0
  146. package/dist/shell/assets/{first-organization-page-B986-W2g.js → first-organization-page-BtfoRENE.js} +2 -2
  147. package/dist/shell/assets/{graph-view-BEerNiMa.js → graph-view-C4fwqz7Q.js} +2 -2
  148. package/dist/shell/assets/{group-donut-DgttsF8V.js → group-donut-Bcnc0EaM.js} +2 -2
  149. package/dist/shell/assets/{guest-call-page-CKEva7eV.js → guest-call-page-D09z7u-V.js} +3 -3
  150. package/dist/shell/assets/{html-viewer-FMIvHlJ9.js → html-viewer-BtwOBvDg.js} +2 -2
  151. package/dist/shell/assets/{import-dialog-CjFrTZBf.js → import-dialog-Dwx_yEfS.js} +2 -2
  152. package/dist/shell/assets/{import-table-dialog-CoTd03ud.js → import-table-dialog-T3V3RoDY.js} +2 -2
  153. package/dist/shell/assets/{index-BrTE5pLB.js → index-DvNpfiwE.js} +1 -1
  154. package/dist/shell/assets/invitations-page-X90SMPsK.js +2 -0
  155. package/dist/shell/assets/{layout-grid-o1f0ZIIR.js → layout-grid-Bp_eP5eU.js} +2 -2
  156. package/dist/shell/assets/{legend-item-CamCYS1J.js → legend-item-CEZ-8FXv.js} +2 -2
  157. package/dist/shell/assets/list-page-BUtWO_Zd.js +4 -0
  158. package/dist/shell/assets/{maplibre-DVBhKlXN.js → maplibre-Cv3xuTP_.js} +2 -2
  159. package/dist/shell/assets/{markdown-content-CfblNnhw.js → markdown-content-jO-R6jpp.js} +2 -2
  160. package/dist/shell/assets/members-page-BZyldmfB.js +2 -0
  161. package/dist/shell/assets/{message-content--7TsRUEK.js → message-content-DJEa6jyY.js} +2 -2
  162. package/dist/shell/assets/messages-BIP4feL2.js +2 -0
  163. package/dist/shell/assets/nl-Ce2dHlet.js +2 -0
  164. package/dist/shell/assets/organization-page-CjQ7oJk4.js +2 -0
  165. package/dist/shell/assets/organizations-page-2cKqhNJh.js +2 -0
  166. package/dist/shell/assets/parse-worker-MvbeuzYJ.js +35 -0
  167. package/dist/shell/assets/{pending-invitation-row-By5UWOua.js → pending-invitation-row-Cef2WdTI.js} +2 -2
  168. package/dist/shell/assets/{period-chart-C3ZV_QjX.js → period-chart-BPq3Knz8.js} +2 -2
  169. package/dist/shell/assets/{person-row-Dvc6wiac.js → person-row-BLVor9QR.js} +2 -2
  170. package/dist/shell/assets/public-form-page-CMaHcrdf.js +2 -0
  171. package/dist/shell/assets/record-lines-jznjVtIQ.js +2 -0
  172. package/dist/shell/assets/{record-map-M24QGWvA.js → record-map-9KEjeN_F.js} +2 -2
  173. package/dist/shell/assets/{record-opens-CNOaCrB0.js → record-opens-CQLXpqJS.js} +2 -2
  174. package/dist/shell/assets/record-page-JFlxtSyg.js +3 -0
  175. package/dist/shell/assets/{record-preview-Bk9A5TNd.js → record-preview-CUs7j-lh.js} +2 -2
  176. package/dist/shell/assets/{records-map-D1JVIHvn.js → records-map-CLF98-H0.js} +2 -2
  177. package/dist/shell/assets/render-node-DoB1k2WS.js +3 -0
  178. package/dist/shell/assets/reorder-button-Cg-WKutS.js +2 -0
  179. package/dist/shell/assets/{run-trace-view-CBYw9RPI.js → run-trace-view-CmujelWd.js} +2 -2
  180. package/dist/shell/assets/{runner-install-field--7xa6MIJ.js → runner-install-field-wpoIgnks.js} +2 -2
  181. package/dist/shell/assets/{runtime-update-DWO9xR0h.js → runtime-update-BaNRaM6l.js} +2 -2
  182. package/dist/shell/assets/shared-protobase-ui-630Rm7Jd.js +1 -0
  183. package/dist/shell/assets/sheet-source-7m5PMllh.js +3 -0
  184. package/dist/shell/assets/sign-in-policy-page-GgyC3l_6.js +2 -0
  185. package/dist/shell/assets/start-block-queries-B8K1ZsVK.js +2 -0
  186. package/dist/shell/assets/step-catalog-Dktva0VF.js +2 -0
  187. package/dist/shell/assets/{step-panel-xClc_YhC.js → step-panel-CjUWMleA.js} +2 -2
  188. package/dist/shell/assets/timeline-display-CCPZ8VKv.js +2 -0
  189. package/dist/shell/assets/{trash-DTqja_Bl.js → trash-BfIEK322.js} +2 -2
  190. package/dist/shell/assets/{update-set-g33TLRML.js → update-set-Drag3hOc.js} +2 -2
  191. package/dist/shell/assets/use-calendar-move-fM4kqYZF.js +2 -0
  192. package/dist/shell/assets/{use-display-rows-sN3JfCRy.js → use-display-rows-CEB1AStC.js} +2 -2
  193. package/dist/shell/assets/use-my-invitations-DxoZihem.js +2 -0
  194. package/dist/shell/assets/{use-paged-search-DrjHdSz7.js → use-paged-search-tHTP8FRX.js} +2 -2
  195. package/dist/shell/assets/{use-run-trace-DFLNmghw.js → use-run-trace-b8SpFDRU.js} +2 -2
  196. package/dist/shell/assets/{use-workflow-page-Cfztiqhc.js → use-workflow-page-oeKIRs_g.js} +2 -2
  197. package/dist/shell/assets/{use-workflow-types-BFToPBTN.js → use-workflow-types-D1TLbN3E.js} +2 -2
  198. package/dist/shell/assets/{workflow-canvas-D7hU35fr.js → workflow-canvas-CJQ0Ll0M.js} +4 -4
  199. package/dist/shell/assets/{workflow-field-D7X0A1GO.js → workflow-field-CpGs8ZXh.js} +3 -3
  200. package/dist/shell/assets/{workflow-graph-editor-16CoiFFG.js → workflow-graph-editor-CLlL2jNQ.js} +2 -2
  201. package/dist/shell/assets/{workflow-run-field-DJLolq5e.js → workflow-run-field-R43RqM3Z.js} +3 -3
  202. package/dist/shell/assets/workflow-status-field-BaytFzWg.js +2 -0
  203. package/dist/shell/assets/workflow-workbench-DYClQZZ1.js +4 -0
  204. package/dist/shell/index.html +3 -3
  205. package/dist/shell/protobase.shell.json +2 -2
  206. package/dist/shell/protobase.sw.js +2 -2
  207. package/dist/shell-source-maps/assets/{account-page-K162oV2K.js.map → account-page-BsAc4o17.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/app-Bb88M0VJ.js.map +1 -0
  209. package/dist/shell-source-maps/assets/{assistant-shell-BudITySr.js.map → assistant-shell-CdVAnpMe.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/{board-display-Bs4z3PwA.js.map → board-display-DKT7398I.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{calendar-display-tHm1Uuwv.js.map → calendar-display-0c2dGTmG.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{call-rings-pKCPyD1-.js.map → call-rings-BV5na0xp.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{calls-CLQwaemL.js.map → calls-n9IoOXzL.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{circle-alert-05wFSlkE.js.map → circle-alert-kISSXwIV.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{composed-page-D3_OTQB4.js.map → composed-page-hn7I0Ulk.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{composer-section-BoFYW5rp.js.map → composer-section-Cb1kOpwt.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{connect-route-D0m9ozLK.js.map → connect-route-l21XyxhS.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{copy-field-DjAdwdDh.js.map → copy-field-D22CFeg3.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{create-route-CZDGdfY8.js.map → create-route-CSe9DhbY.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{custom-step-container-field-DTCgqZMO.js.map → custom-step-container-field-C5l4j0FI.js.map} +1 -1
  221. package/dist/shell-source-maps/assets/{embedded-list-wbLEr5-r.js.map → embedded-list-DjvOszEj.js.map} +1 -1
  222. package/dist/shell-source-maps/assets/en-DnsB2haa.js.map +1 -0
  223. package/dist/shell-source-maps/assets/{export-dialog-BVmThgqO.js.map → export-dialog-Bh3TSYyL.js.map} +1 -1
  224. package/dist/shell-source-maps/assets/export-worker-DbK8hf_0.js.map +1 -0
  225. package/dist/shell-source-maps/assets/{first-organization-page-B986-W2g.js.map → first-organization-page-BtfoRENE.js.map} +1 -1
  226. package/dist/shell-source-maps/assets/{graph-view-BEerNiMa.js.map → graph-view-C4fwqz7Q.js.map} +1 -1
  227. package/dist/shell-source-maps/assets/{group-donut-DgttsF8V.js.map → group-donut-Bcnc0EaM.js.map} +1 -1
  228. package/dist/shell-source-maps/assets/{guest-call-page-CKEva7eV.js.map → guest-call-page-D09z7u-V.js.map} +1 -1
  229. package/dist/shell-source-maps/assets/{html-viewer-FMIvHlJ9.js.map → html-viewer-BtwOBvDg.js.map} +1 -1
  230. package/dist/shell-source-maps/assets/{import-dialog-CjFrTZBf.js.map → import-dialog-Dwx_yEfS.js.map} +1 -1
  231. package/dist/shell-source-maps/assets/{import-table-dialog-CoTd03ud.js.map → import-table-dialog-T3V3RoDY.js.map} +1 -1
  232. package/dist/shell-source-maps/assets/{invitations-page-Ds817tOV.js.map → invitations-page-X90SMPsK.js.map} +1 -1
  233. package/dist/shell-source-maps/assets/{layout-grid-o1f0ZIIR.js.map → layout-grid-Bp_eP5eU.js.map} +1 -1
  234. package/dist/shell-source-maps/assets/{legend-item-CamCYS1J.js.map → legend-item-CEZ-8FXv.js.map} +1 -1
  235. package/dist/shell-source-maps/assets/{list-page-CHdsbqR8.js.map → list-page-BUtWO_Zd.js.map} +1 -1
  236. package/dist/shell-source-maps/assets/{maplibre-DVBhKlXN.js.map → maplibre-Cv3xuTP_.js.map} +1 -1
  237. package/dist/shell-source-maps/assets/{markdown-content-CfblNnhw.js.map → markdown-content-jO-R6jpp.js.map} +1 -1
  238. package/dist/shell-source-maps/assets/{members-page-CCLPZ9sH.js.map → members-page-BZyldmfB.js.map} +1 -1
  239. package/dist/shell-source-maps/assets/{message-content--7TsRUEK.js.map → message-content-DJEa6jyY.js.map} +1 -1
  240. package/dist/shell-source-maps/assets/{messages-BaKJKIHo.js.map → messages-BIP4feL2.js.map} +1 -1
  241. package/dist/shell-source-maps/assets/nl-Ce2dHlet.js.map +1 -0
  242. package/dist/shell-source-maps/assets/{organization-page-DE4U9Xbi.js.map → organization-page-CjQ7oJk4.js.map} +1 -1
  243. package/dist/shell-source-maps/assets/{organizations-page-DcRX2C5D.js.map → organizations-page-2cKqhNJh.js.map} +1 -1
  244. package/dist/shell-source-maps/assets/parse-worker-MvbeuzYJ.js.map +1 -0
  245. package/dist/shell-source-maps/assets/{pending-invitation-row-By5UWOua.js.map → pending-invitation-row-Cef2WdTI.js.map} +1 -1
  246. package/dist/shell-source-maps/assets/{period-chart-C3ZV_QjX.js.map → period-chart-BPq3Knz8.js.map} +1 -1
  247. package/dist/shell-source-maps/assets/{person-row-Dvc6wiac.js.map → person-row-BLVor9QR.js.map} +1 -1
  248. package/dist/shell-source-maps/assets/{public-form-page-C2K3mhKj.js.map → public-form-page-CMaHcrdf.js.map} +1 -1
  249. package/dist/shell-source-maps/assets/{record-lines-DLM3i7dN.js.map → record-lines-jznjVtIQ.js.map} +1 -1
  250. package/dist/shell-source-maps/assets/{record-map-M24QGWvA.js.map → record-map-9KEjeN_F.js.map} +1 -1
  251. package/dist/shell-source-maps/assets/{record-opens-CNOaCrB0.js.map → record-opens-CQLXpqJS.js.map} +1 -1
  252. package/dist/shell-source-maps/assets/record-page-JFlxtSyg.js.map +1 -0
  253. package/dist/shell-source-maps/assets/{record-preview-Bk9A5TNd.js.map → record-preview-CUs7j-lh.js.map} +1 -1
  254. package/dist/shell-source-maps/assets/{records-map-D1JVIHvn.js.map → records-map-CLF98-H0.js.map} +1 -1
  255. package/dist/shell-source-maps/assets/render-node-DoB1k2WS.js.map +1 -0
  256. package/dist/shell-source-maps/assets/{reorder-button-CrDVuiOd.js.map → reorder-button-Cg-WKutS.js.map} +1 -1
  257. package/dist/shell-source-maps/assets/{run-trace-view-CBYw9RPI.js.map → run-trace-view-CmujelWd.js.map} +1 -1
  258. package/dist/shell-source-maps/assets/{runner-install-field--7xa6MIJ.js.map → runner-install-field-wpoIgnks.js.map} +1 -1
  259. package/dist/shell-source-maps/assets/{runtime-update-DWO9xR0h.js.map → runtime-update-BaNRaM6l.js.map} +1 -1
  260. package/dist/shell-source-maps/assets/{sheet-source-DKZ31RE_.js.map → sheet-source-7m5PMllh.js.map} +1 -1
  261. package/dist/shell-source-maps/assets/{sign-in-policy-page-B-m5Pcyb.js.map → sign-in-policy-page-GgyC3l_6.js.map} +1 -1
  262. package/dist/shell-source-maps/assets/{start-block-queries-OldcFqiL.js.map → start-block-queries-B8K1ZsVK.js.map} +1 -1
  263. package/dist/shell-source-maps/assets/{step-catalog-N67Ej6Fl.js.map → step-catalog-Dktva0VF.js.map} +1 -1
  264. package/dist/shell-source-maps/assets/{step-panel-xClc_YhC.js.map → step-panel-CjUWMleA.js.map} +1 -1
  265. package/dist/shell-source-maps/assets/{timeline-display-DwR4-qO_.js.map → timeline-display-CCPZ8VKv.js.map} +1 -1
  266. package/dist/shell-source-maps/assets/{trash-DTqja_Bl.js.map → trash-BfIEK322.js.map} +1 -1
  267. package/dist/shell-source-maps/assets/{update-set-g33TLRML.js.map → update-set-Drag3hOc.js.map} +1 -1
  268. package/dist/shell-source-maps/assets/{use-calendar-move-BaNKG9_2.js.map → use-calendar-move-fM4kqYZF.js.map} +1 -1
  269. package/dist/shell-source-maps/assets/{use-display-rows-sN3JfCRy.js.map → use-display-rows-CEB1AStC.js.map} +1 -1
  270. package/dist/shell-source-maps/assets/{use-my-invitations-BIsBGgmc.js.map → use-my-invitations-DxoZihem.js.map} +1 -1
  271. package/dist/shell-source-maps/assets/{use-paged-search-DrjHdSz7.js.map → use-paged-search-tHTP8FRX.js.map} +1 -1
  272. package/dist/shell-source-maps/assets/{use-run-trace-DFLNmghw.js.map → use-run-trace-b8SpFDRU.js.map} +1 -1
  273. package/dist/shell-source-maps/assets/{use-workflow-page-Cfztiqhc.js.map → use-workflow-page-oeKIRs_g.js.map} +1 -1
  274. package/dist/shell-source-maps/assets/{use-workflow-types-BFToPBTN.js.map → use-workflow-types-D1TLbN3E.js.map} +1 -1
  275. package/dist/shell-source-maps/assets/{workflow-canvas-D7hU35fr.js.map → workflow-canvas-CJQ0Ll0M.js.map} +1 -1
  276. package/dist/shell-source-maps/assets/{workflow-field-D7X0A1GO.js.map → workflow-field-CpGs8ZXh.js.map} +1 -1
  277. package/dist/shell-source-maps/assets/{workflow-graph-editor-16CoiFFG.js.map → workflow-graph-editor-CLlL2jNQ.js.map} +1 -1
  278. package/dist/shell-source-maps/assets/{workflow-run-field-DJLolq5e.js.map → workflow-run-field-R43RqM3Z.js.map} +1 -1
  279. package/dist/shell-source-maps/assets/workflow-status-field-BaytFzWg.js.map +1 -0
  280. package/dist/shell-source-maps/assets/{workflow-workbench-DErE_AKt.js.map → workflow-workbench-DYClQZZ1.js.map} +1 -1
  281. package/dist/status/messages.d.ts +2 -2
  282. package/dist/users/messages.d.ts +2 -2
  283. package/package.json +5 -5
  284. package/dist/shell/assets/app-vx5mZ2uE.js +0 -34
  285. package/dist/shell/assets/board-display-Bs4z3PwA.js +0 -2
  286. package/dist/shell/assets/calendar-display-tHm1Uuwv.js +0 -2
  287. package/dist/shell/assets/create-route-CZDGdfY8.js +0 -2
  288. package/dist/shell/assets/embedded-list-wbLEr5-r.js +0 -3
  289. package/dist/shell/assets/en-0TxR0Vfb.js +0 -2
  290. package/dist/shell/assets/export-worker-AFqbgGzG.js +0 -15
  291. package/dist/shell/assets/invitations-page-Ds817tOV.js +0 -2
  292. package/dist/shell/assets/list-page-CHdsbqR8.js +0 -4
  293. package/dist/shell/assets/members-page-CCLPZ9sH.js +0 -2
  294. package/dist/shell/assets/messages-BaKJKIHo.js +0 -2
  295. package/dist/shell/assets/nl-mDiTKi5y.js +0 -2
  296. package/dist/shell/assets/organization-page-DE4U9Xbi.js +0 -2
  297. package/dist/shell/assets/organizations-page-DcRX2C5D.js +0 -2
  298. package/dist/shell/assets/parse-worker-C5wWzRYH.js +0 -35
  299. package/dist/shell/assets/public-form-page-C2K3mhKj.js +0 -2
  300. package/dist/shell/assets/record-lines-DLM3i7dN.js +0 -2
  301. package/dist/shell/assets/record-page-DVmkJFmF.js +0 -3
  302. package/dist/shell/assets/render-node-C-yLArnA.js +0 -3
  303. package/dist/shell/assets/reorder-button-CrDVuiOd.js +0 -2
  304. package/dist/shell/assets/shared-protobase-ui-DGEYEBZj.js +0 -1
  305. package/dist/shell/assets/sheet-source-DKZ31RE_.js +0 -3
  306. package/dist/shell/assets/sign-in-policy-page-B-m5Pcyb.js +0 -2
  307. package/dist/shell/assets/start-block-queries-OldcFqiL.js +0 -2
  308. package/dist/shell/assets/step-catalog-N67Ej6Fl.js +0 -2
  309. package/dist/shell/assets/timeline-display-DwR4-qO_.js +0 -2
  310. package/dist/shell/assets/use-calendar-move-BaNKG9_2.js +0 -2
  311. package/dist/shell/assets/use-my-invitations-BIsBGgmc.js +0 -2
  312. package/dist/shell/assets/workflow-status-field-weFyKOIV.js +0 -2
  313. package/dist/shell/assets/workflow-workbench-DErE_AKt.js +0 -4
  314. package/dist/shell-source-maps/assets/app-vx5mZ2uE.js.map +0 -1
  315. package/dist/shell-source-maps/assets/en-0TxR0Vfb.js.map +0 -1
  316. package/dist/shell-source-maps/assets/export-worker-AFqbgGzG.js.map +0 -1
  317. package/dist/shell-source-maps/assets/nl-mDiTKi5y.js.map +0 -1
  318. package/dist/shell-source-maps/assets/parse-worker-C5wWzRYH.js.map +0 -1
  319. package/dist/shell-source-maps/assets/record-page-DVmkJFmF.js.map +0 -1
  320. package/dist/shell-source-maps/assets/render-node-C-yLArnA.js.map +0 -1
  321. package/dist/shell-source-maps/assets/workflow-status-field-weFyKOIV.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lib-sentry-browser-BoddUTMM.js","assets/rolldown-runtime-DFwUHQ4A.js","assets/lib-sentry-core-CKUQogx-.js","assets/lib-sentry-conventions-CEhiYCma.js","assets/lib-sentry-browser-utils-CoRYOaCJ.js","assets/list-page-BUtWO_Zd.js","assets/react-CuiNlnus.js","assets/vendor-t7Q7QbPu.js","assets/view-chart-ChBtewKd.js","assets/embedded-list-DjvOszEj.js","assets/update-set-Drag3hOc.js","assets/layout-grid-Bp_eP5eU.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-CUs7j-lh.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/reorder-button-Cg-WKutS.js","assets/messages-BIP4feL2.js","assets/trash-BfIEK322.js","assets/page-header-Ddz2r5ic.js","assets/use-display-rows-CEB1AStC.js","assets/list-page-GUjJKojE.css","assets/record-page-JFlxtSyg.js","assets/render-node-DoB1k2WS.js","assets/circle-alert-kISSXwIV.js","assets/pending-invitation-row-Cef2WdTI.js","assets/person-row-BLVor9QR.js","assets/use-paged-search-tHTP8FRX.js","assets/client-publisher-D39SlIhp.js","assets/copy-field-D22CFeg3.js","assets/record-sidebar-HqyBXBwn.js","assets/start-block-queries-B8K1ZsVK.js","assets/record-opens-CQLXpqJS.js","assets/create-route-CSe9DhbY.js","assets/composed-page-hn7I0Ulk.js","assets/account-page-BsAc4o17.js","assets/sign-in-policy-page-GgyC3l_6.js","assets/organization-page-CjQ7oJk4.js","assets/first-organization-page-BtfoRENE.js","assets/use-my-invitations-DxoZihem.js","assets/organizations-page-2cKqhNJh.js","assets/members-page-BZyldmfB.js","assets/invitations-page-X90SMPsK.js","assets/connect-route-l21XyxhS.js","assets/public-form-page-CMaHcrdf.js","assets/lib-altcha-lib-BK1uKcxH.js","assets/guest-call-page-D09z7u-V.js","assets/assistant-shell-CdVAnpMe.js","assets/call-rings-BV5na0xp.js","assets/runtime-update-BaNRaM6l.js","assets/workflow-field-CpGs8ZXh.js","assets/use-run-trace-b8SpFDRU.js","assets/workflows-Bey4jszG.js","assets/lib-ajv-BPyvefs9.js","assets/lib-fast-deep-equal-BGljVuDb.js","assets/lib-json-schema-traverse-DxXzBYGi.js","assets/lib-fast-uri-DriPOqOU.js","assets/lib-jsonata-Cu4QFOo8.js","assets/use-workflow-types-D1TLbN3E.js","assets/use-workflow-page-oeKIRs_g.js","assets/workflow-run-field-R43RqM3Z.js","assets/workflow-status-field-BaytFzWg.js","assets/lib-zod-CxxP7Qhu.js","assets/custom-step-container-field-C5l4j0FI.js","assets/runner-install-field-wpoIgnks.js","assets/markdown-content-jO-R6jpp.js","assets/lib-dompurify-Dr60P-Rn.js","assets/lib-marked-Bg9_sE-m.js","assets/safe-html-CmkqDcA6.js","assets/html-viewer-BtwOBvDg.js","assets/message-content-DJEa6jyY.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,r as t}from"./rolldown-runtime-DFwUHQ4A.js";import{i as n,n as r,r as i,t as a}from"./react-CuiNlnus.js";import{A as o,C as s,D as c,E as l,M as u,O as d,S as f,T as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,j as C,k as w,l as T,m as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as ne,v as re,w as ie,x as ae,y as oe}from"./vendor-t7Q7QbPu.js";var j=e(n(),1),M=e(i(),1),se=r(),ce=t({default:()=>le}),le={},ue=(e,t)=>{try{return e()}catch(e){if(!(e instanceof DOMException))throw e;return t}},de=e=>e.addEventListener(`touchstart`,fe,{passive:!0}),fe=()=>{},N=(e,t,n,r)=>({code:e,message:t,hint:n,span:r}),pe=(e,t)=>{let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=e[r-1]===t[a-1]?0:1;i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+o)}n=i}return n[t.length]},me=(e,t)=>{let n=e.toLowerCase(),r=t.map(e=>({candidate:e,score:pe(n,e.toLowerCase())})).sort((e,t)=>e.score-t.score)[0];return r&&r.score<=Math.max(2,Math.floor(e.length/3))?r.candidate:void 0},he=(e,t)=>Object.hasOwn(e.fields,t)?e.fields[t]:Object.values(e.fields).find(e=>e.aliases.includes(t)),ge=(e,t,n)=>{if(t.path.length>1){e.errors.push(N(`unsupported-traversal`,`Traversal into "${t.path.join(`.`)}" is not supported yet`,`Filter on fields of this resource only`,t.span));return}let r=t.path[0],i=he(e.model,r);if(!i){let i=Object.values(e.model.fields).filter(e=>e[n]).map(e=>e.name),a=me(r,i);e.errors.push(N(`unknown-field`,`Unknown field "${r}"`,a?`Did you mean "${a}"?`:`Available fields: ${i.join(`, `)}`,t.span));return}if(!i[n]){let r=n===`filterable`?`filterable`:`sortable`;e.errors.push(N(n===`filterable`?`not-filterable`:`not-sortable`,`Field "${i.name}" is not ${r}`,`Mark it with .${r}() in data.ts`,t.span));return}return i},_e={in:{params:[{name:`field`,type:`field`}],rest:{name:`value`,type:`any`}},search:{params:[{name:`text`,type:`string`}]},similar:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`text`,type:`string`}]},regex:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`pattern`,type:`string`}]},isNull:{params:[{name:`field`,type:`field`}]},related:{params:[{name:`field`,type:`field`},{name:`key`,type:`field`}],rest:{name:`filter`,type:`any`}},now:{params:[],returns:`timestamp`}},ve={extensions:{arithmetic:`now-offset`,durationUnits:!0}},ye=e=>{switch(e.type){case`text`:return`string`;case`integer`:case`bigint`:return`integer`;case`boolean`:case`timestamp`:case`enum`:return e.type;default:return`any`}},be=e=>({fields:Object.fromEntries(Object.values(e.fields).map(e=>[e.name,{type:ye(e),filterable:e.filterable,sortable:e.sortable,aliases:e.aliases,...e.enumValues&&{values:e.enumValues}}])),functions:_e}),xe=(e,t,n,r)=>{e.errors.push(N(`unsupported`,t,n,r))},Se=(e,t)=>t.kind===`member`?{kind:`field`,path:t.path,span:t.span}:xe(e,`Only fields can be compared`,`Put a field name on the left, for example total > 100`,t.span),Ce=(e,t)=>{switch(t.kind){case`member`:return{kind:`string`,value:t.path.join(`.`),span:t.span};case`call`:return t.name===`now`&&t.args.length===0?{kind:`now`,span:t.span}:xe(e,`${t.name}() cannot be used as a value`,`Only now() is a value function`,t.span);case`binary`:{let n=t.left;return n.kind===`call`&&n.name===`now`&&n.args.length===0&&t.right.kind===`duration`?{kind:`now`,offset:{sign:t.op,duration:t.right},span:t.span}:xe(e,`Arithmetic is only supported as now() +/- duration`,`Write now() - 30d`,t.span)}default:return t}},we=(e,t)=>(`kind`in t&&[`member`,`call`,`binary`].includes(t.kind)?void 0:t)||(t.kind===`member`?{kind:`string`,value:t.path.join(`.`),span:t.span}:xe(e,`Expected a literal value`,`Use strings, numbers, true/false, durations or timestamps`,t.span)),Te=e=>{switch(e.kind){case`member`:return e.path.join(`.`);case`string`:case`timestamp`:return e.kind,e.value;case`number`:return e.raw;case`boolean`:return String(e.value);case`duration`:return`${e.amount}${e.unit}`;default:return``}},Ee=e=>[`sequence`,`and`,`or`,`not`,`compare`,`has`,`present`,`global`,`call`].includes(e.kind),De=e=>{let[t,n,r,...i]=e;if(!(i.length>0)&&!(t&&t.kind!==`string`)&&!(n&&(n.kind!==`number`||!Number.isSafeInteger(n.value)||n.value<1))&&!(r&&r.kind!==`string`))return{...t?.kind===`string`&&{orderBy:t.value},...n?.kind===`number`&&{limit:n.value},...r?.kind===`string`&&{pageToken:r.value}}},Oe=(e,t,n,r)=>{let[,i,...a]=t.args,o=`related(field, resource.field, (filter), "order_by", limit, "page_token"), each after the field optional`;if(!n||i?.kind!==`member`||i.path.length!==2)return r(o);let s=a[0]&&Ee(a[0])?a[0]:void 0,c=De(s?a.slice(1):a);if(!c)return r(o);let l={kind:`related`,field:n,resource:i.path[0],key:i.path[1],...c,span:t.span};if(!s)return l;let u=je(e,s);return u&&{...l,filter:u}},ke=(e,t)=>{let[n,r,...i]=t.args,a=n?.kind===`member`?Se(e,n):void 0,o=e=>e?.kind===`string`?e.value:void 0,s=n=>{e.errors.push(N(`invalid-arguments`,`Invalid arguments to ${t.name}()`,`Usage: ${n}`,t.span))};switch(t.name){case`in`:{let n=t.args.slice(1).map(t=>we(e,t));return!a||n.length===0?s(`in(field, value1, value2, ...)`):n.every(e=>e)?{kind:`in`,field:a,values:n,span:t.span}:void 0}case`search`:return o(n)!==void 0&&!r?{kind:`search`,text:o(n),span:t.span}:s(`search("text")`);case`similar`:return a&&o(r)!==void 0&&i.length===0?{kind:`similar`,field:a,text:o(r),span:t.span}:s(`similar(field, "text")`);case`regex`:return a&&o(r)!==void 0&&i.length===0?{kind:`regex`,field:a,pattern:o(r),span:t.span}:s(`regex(field, "pattern")`);case`isNull`:return a&&!r?{kind:`isNull`,field:a,span:t.span}:s(`isNull(field)`);case`related`:return Oe(e,t,a,s);default:e.errors.push(N(`unknown-function`,`Unknown function "${t.name}"`,`Available functions: ${Object.keys(_e).join(`, `)}`,t.span));return}},Ae=e=>e.every(e=>e)?e:void 0,je=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=Ae(t.args.map(t=>je(e,t)));return n&&{kind:t.kind===`or`?`or`:`and`,args:n,span:t.span}}case`not`:{let n=je(e,t.arg);return n&&{kind:`not`,arg:n,span:t.span}}case`compare`:{let n=Se(e,t.left),r=Ce(e,t.right);return n&&r&&{kind:`compare`,op:t.op,field:n,value:r,span:t.span}}case`has`:{let n=Se(e,t.left),r=we(e,t.right);return n&&r&&{kind:`has`,field:n,value:r,span:t.span}}case`present`:{let n=Se(e,t.left);return n&&{kind:`present`,field:n,span:t.span}}case`global`:return{kind:`search`,text:Te(t.value),span:t.span};case`call`:return ke(e,t)}},Me=(e,t={})=>{let n=C(e,{...ve,...t}),r={errors:[]},i=n.ast&&je(r,n.ast),a=[...n.errors,...r.errors].sort((e,t)=>e.span.start-t.span.start);return a.length===0?{ok:!0,ast:i,errors:[]}:{ok:!1,ast:i,errors:a}},Ne=(e,t)=>t===2?e%4==0&&(e%100!=0||e%400==0)?29:28:[4,6,9,11].includes(t)?30:31,Pe=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r>=1&&r<=12&&i>=1&&i<=Ne(n,r)},Fe=e=>{let t=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[2]),Number(t[3]),Number(t[4])],[a,o]=[Number(t[5]??0),Number(t[6]??0)];return Pe(t[1])&&n<=23&&r<=59&&i<=59&&a<=23&&o<=59},Ie=(e,t)=>({message:e,hint:t}),Le=-(2n**63n),Re=2n**63n-1n,ze=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Be=e=>e.kind===`number`?e.raw:e.kind===`string`?e.value:void 0,Ve=(e,t=`Write ${e} values like the examples in the docs`)=>Ie(`Expected ${e}`,t),He=e=>{let t=Be(e),n=t===void 0?NaN:Number(t);if(t===void 0||t.trim()===``||!Number.isSafeInteger(n))return Ve(`a whole number`,`Use an integer such as 42, or a bigint field for larger values`)},Ue=e=>{let t=Be(e);if(t===void 0||!/^-?\d+$/.test(t)||BigInt(t)<Le||BigInt(t)>Re)return Ve(`a 64-bit integer`,`Use plain digits such as 9007199254740993 (no exponent or fraction)`)},We=e=>{let t=Be(e);if(t===void 0||!/^-?\d+(\.\d+)?$/.test(t))return Ve(`a decimal number`,`Use plain digits such as 100.50, or quote it: "100.50" (no exponent)`)},Ge=(e,t)=>{if(t.kind===`now`)return e.type===`date`||e.type===`timestamp`?void 0:Ie(`now() only works with date and timestamp fields`,`Field "${e.name}" is ${e.type}`);switch(e.type){case`text`:return t.kind===`string`?void 0:Ve(`a quoted string`,`Wrap the text in double quotes`);case`integer`:return He(t);case`bigint`:return Ue(t);case`decimal`:return We(t);case`boolean`:return t.kind===`boolean`?void 0:Ve(`true or false`);case`date`:return t.kind===`string`&&Pe(t.value)?void 0:Ve(`a date`,`Quote a calendar date: "2012-04-21"`);case`timestamp`:return t.kind===`timestamp`||t.kind===`string`&&Fe(t.value)?void 0:Ve(`an RFC-3339 timestamp`,`Use 2012-04-21T11:30:00Z, or now() - 7d`);case`uuid`:return t.kind===`string`&&ze.test(t.value)?void 0:Ve(`a uuid`,`Quote a uuid like "0b5a4f0e-6f2a-4a3c-9d4e-1f2a3b4c5d6e"`);case`enum`:return t.kind===`string`&&e.enumValues?.includes(t.value)?void 0:Ie(`Invalid enum value`,`Allowed values: ${(e.enumValues??[]).join(`, `)}`);case`currency`:return t.kind===`string`&&/^[A-Z]{3}$/.test(t.value)?void 0:Ve(`an ISO 4217 currency code`,`Use three capital letters, for example "EUR"`);case`country`:return t.kind===`string`&&/^[A-Z]{2}$/.test(t.value)?void 0:Ve(`an ISO 3166-1 country code`,`Use two capital letters, for example "NL"`);case`mail_sender`:return t.kind===`string`?void 0:Ve(`a mail address`,`Quote the address: "billing@example.com"`);case`relation`:return t.kind===`string`||t.kind===`number`&&Number.isSafeInteger(t.value)?void 0:Ve(`a record key`,`Use the related record key: 42 or "abc"`);case`json`:case`file`:return Ie(`${e.type} fields cannot be compared`,`Use field:value on json fields, or isNull(field)`)}},Ke=[`=`,`!=`],qe=[`=`,`!=`,`<`,`<=`,`>`,`>=`],Je=e=>{switch(e){case`text`:case`integer`:case`bigint`:case`decimal`:case`date`:case`timestamp`:return qe;case`json`:case`file`:return[];default:return Ke}},Ye=e=>e===`json`||e===`file`,Xe=e=>N(`unsupported-traversal`,`related() only works in a list's filter, ANDed with the rest`,`Put it at the top of the filter or of a subfilter, joined with AND`,e),Ze=(e,t,n)=>{let r=Ge(t,n);return r&&e.errors.push(N(`invalid-value`,r.message,r.hint,n.span)),!r},Qe=(e,t,n,r)=>{e.errors.push(N(`operator-not-allowed`,t,n,r))},$e=(e,t)=>(e===`=`||e===`!=`)&&t.kind===`string`&&t.value.includes(`*`),et=(e,t)=>{let n=ge(e,t.field,`filterable`);if(!n)return;let r=Je(n.type);if(!r.includes(t.op)){Qe(e,`Operator "${t.op}" is not supported for ${n.type} fields`,r.length?`Supported: ${r.join(` `)}`:`Use field:value on json fields, or isNull(field)`,t.span);return}if($e(t.op,t.value)&&n.type!==`text`){e.errors.push(N(`wildcard-not-allowed`,`Wildcards are only supported on text fields, not ${n.type}`,`Remove the "*" or filter a text field`,t.value.span));return}if($e(t.op,t.value)||Ze(e,n,t.value))return{...t,field:n}},tt=(e,t)=>{let n=ge(e,t.field,`filterable`);if(n){if(n.type!==`json`){Qe(e,`":" is only supported on json fields, not ${n.type}`,`Use = on ${n.type} fields, or field:* to test for a value`,t.span);return}return{...t,field:n}}},nt=(e,t)=>{let n=ge(e,t.field,`filterable`);if(n){if(Ye(n.type)){Qe(e,`in() is not supported for ${n.type} fields`,`Use field:value on json fields`,t.span);return}return t.values.map(t=>Ze(e,n,t)).every(Boolean)?{...t,field:n}:void 0}},rt=(e,t,n)=>{let r=ge(e,n,`filterable`);if(r&&r.type!==`text`){Qe(e,`${t}() only works on text fields, not ${r.type}`,`Field "${r.name}" is ${r.type}`,n.span);return}return r},it=(e,t)=>{switch(t.kind){case`and`:case`or`:{let n=t.args.map(t=>it(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=it(e,t.arg);return n&&{...t,arg:n}}case`compare`:return et(e,t);case`has`:return tt(e,t);case`in`:return nt(e,t);case`search`:if(e.model.search?.length)return t;e.errors.push(N(`no-search-fields`,`This resource has no search fields`,`Declare them with .search((r) => [r.title]) in data.ts`,t.span));return;case`present`:case`isNull`:{let n=ge(e,t.field,`filterable`);return n&&{...t,field:n}}case`similar`:case`regex`:{let n=rt(e,t.kind,t.field);return n&&{...t,field:n}}case`related`:e.errors.push(Xe(t.span));return}},at=(e,t)=>{let n={model:e,errors:[]},r=it(n,t);return!r||n.errors.length>0?{ok:!1,errors:[...n.errors].sort((e,t)=>e.span.start-t.span.start)}:{ok:!0,filter:r}},ot=(e,t)=>`path`in e?{kind:`member`,path:e.path,span:e.span}:{kind:`member`,path:[e.name],field:{name:e.name,spec:{type:ye(e)}},span:t},st=(e,t,n)=>({kind:`call`,name:e,args:t,span:n}),ct=(e,t)=>({kind:`string`,value:e,span:t}),lt=({orderBy:e,limit:t,pageToken:n,span:r})=>{if(e===void 0&&t===void 0)return[];let i=ct(e??``,r);if(t===void 0)return[i];let a={kind:`number`,value:t,raw:String(t),span:r};return n===void 0?[i,a]:[i,a,ct(n,r)]},ut=e=>{if(e.kind!==`now`)return e;let t={kind:`call`,name:`now`,args:[],span:e.span};return e.offset?{kind:`binary`,op:e.offset.sign,left:t,right:e.offset.duration,span:e.span}:t},dt=(e,t={})=>{let n=e=>dt(e,t);switch(e.kind){case`and`:case`or`:return{kind:e.kind,args:e.args.map(n),span:e.span};case`not`:return{kind:`not`,arg:n(e.arg),span:e.span};case`compare`:return{kind:`compare`,op:e.op,left:ot(e.field,e.span),right:ut(e.value),span:e.span};case`has`:return{kind:`has`,left:ot(e.field,e.span),right:e.value,span:e.span};case`present`:return{kind:`present`,left:ot(e.field,e.span),span:e.span};case`in`:return t.expand?{kind:`or`,args:e.values.map(t=>({kind:`compare`,op:`=`,left:ot(e.field,e.span),right:t,span:e.span})),span:e.span}:st(`in`,[ot(e.field,e.span),...e.values],e.span);case`search`:return st(`search`,[ct(e.text,e.span)],e.span);case`similar`:return st(`similar`,[ot(e.field,e.span),ct(e.text,e.span)],e.span);case`regex`:return st(`regex`,[ot(e.field,e.span),ct(e.pattern,e.span)],e.span);case`isNull`:return t.expand?{kind:`not`,arg:{kind:`present`,left:ot(e.field,e.span),span:e.span},span:e.span}:st(`isNull`,[ot(e.field,e.span)],e.span);case`related`:return{kind:`call`,name:`related`,args:[ot(e.field,e.span),{kind:`member`,path:[e.resource,e.key],span:e.span},...e.filter?[n(e.filter)]:[],...lt(e)],span:e.span}}},ft=(e,t)=>{let n=at(e,t);if(!n.ok&&n.errors.some(e=>e.code===`unsupported-traversal`))return n;let r=w(dt(t),be(e));return r.ok?at(e,t):{ok:!1,errors:r.errors}},pt=/^[\d\s+\-().\/]+$/,mt=e=>pt.test(e)?e.replace(/\D/g,``):``,ht=e=>{let t=e.split(/\s+/).filter(Boolean).map(e=>({text:e,digits:mt(e),whole:!1})),n=t.length>1?mt(e.trim()):``;return n?[{text:e.trim(),digits:n,whole:!0},...t]:t},gt=(e,t,n)=>e==null?!1:n===`digitsEnd`?t.digits!==``&&String(e).replace(/\D/g,``).endsWith(t.digits):!t.whole&&String(e).toLowerCase().includes(t.text.toLowerCase()),_t=(e,t,n)=>(e.search??[]).filter(r=>gt(t[r],n,e.searchMatch?.[r])),vt=(e,t,n)=>{let r=ht(n),i=r.filter(e=>!e.whole),a=r.find(e=>e.whole);return a&&_t(e,t,a).length>0?!0:i.length>0&&i.every(n=>_t(e,t,n).length>0)},yt=(e,t,n,r)=>{for(let i of ht(n)){let n=_t(e,t,i);if(n.length>0&&!n.some(e=>r.includes(e)))return n[0]}},bt=e=>u(dt(e)),xt=e=>e.map(e=>({path:e.path.path,direction:e.direction,span:e.span})),St=e=>e.replace(/([^\s,])(\s+)(asc|desc)(?=\s|,|$)/gi,(e,t,n,r)=>`${t}${n}${r.toLowerCase()}`),Ct=e=>{let t=d(St(e)),n=t.items.map(e=>({path:{kind:`field`,path:e.path,span:e.span},direction:e.direction,span:e.span}));return t.ok?{ok:!0,items:n,errors:[]}:{ok:!1,items:n,errors:t.errors}},wt=(e,t)=>{let n=t.filter(e=>e.path.path.length>1).map(e=>N(`unsupported-traversal`,`Traversal into "${e.path.path.join(`.`)}" is not supported yet`,`Sort on fields of this resource only`,e.path.span));if(n.length>0)return{ok:!1,errors:n};let r=c(xt(t),be(e));return r.ok?{ok:!0,sort:r.items.map(e=>[e.path[0],e.direction])}:{ok:!1,errors:r.errors}},Tt=e=>{let t=/^(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)([smhdw])$/.exec(e);if(!t)throw Error(`Invalid duration "${e}", expected for example 30d or 1.5h`);return{kind:`duration`,amount:Number(t[1]),unit:t[2],span:{start:0,end:0}}},Et={start:0,end:0},Dt=e=>({kind:`field`,path:e.split(`.`),span:Et}),Ot=e=>{if(typeof e==`string`)return{kind:`string`,value:e,span:Et};if(typeof e==`boolean`)return{kind:`boolean`,value:e,span:Et};if(!Number.isFinite(e))throw Error(`Filter numbers must be finite`);return{kind:`number`,value:e,raw:String(e),span:Et}},kt=e=>typeof e==`object`?e:Ot(e),At=(e,t)=>{if(t.length===0)throw Error(`where.${e} needs at least one filter`);return t.length===1?t[0]:{kind:e,args:t,span:Et}},jt=()=>{let e=e=>(t,n)=>({kind:`compare`,op:e,field:Dt(t),value:kt(n),span:Et}),t=e=>t=>({kind:`now`,offset:{sign:e,duration:Tt(t)},span:Et});return{eq:e(`=`),ne:e(`!=`),lt:e(`<`),lte:e(`<=`),gt:e(`>`),gte:e(`>=`),between:(t,n,r)=>At(`and`,[e(`>=`)(t,n),e(`<=`)(t,r)]),has:(e,t)=>({kind:`has`,field:Dt(e),value:Ot(t),span:Et}),present:e=>({kind:`present`,field:Dt(e),span:Et}),in:(e,t)=>({kind:`in`,field:Dt(e),values:t.map(Ot),span:Et}),isNull:e=>({kind:`isNull`,field:Dt(e),span:Et}),search:e=>({kind:`search`,text:e,span:Et}),similar:(e,t)=>({kind:`similar`,field:Dt(e),text:t,span:Et}),regex:(e,t)=>({kind:`regex`,field:Dt(e),pattern:t,span:Et}),related:(e,t,n,r,i)=>({kind:`related`,field:Dt(e),resource:t,key:n,...r&&{filter:r},...i,span:Et}),and:(...e)=>At(`and`,e),or:(...e)=>At(`or`,e),not:e=>({kind:`not`,arg:e,span:Et}),now:()=>({kind:`now`,span:Et}),ago:t(`-`),fromNow:t(`+`)}},Mt=jt(),Nt=`[A-Za-z_][A-Za-z0-9_]*`,Pt=`${Nt}(?:\\.${Nt})*`,Ft=`@(?:root|params)(?:\\.${Pt})?|@index|@first|@last|(?:\\.\\./)*(?:this(?:\\.${Pt})?|\\./${Pt}|${Pt})`,It=RegExp(`^(?:${Ft})$`),Lt=/\{\{\s*([^{}]*?)\s*\}\}/g,Rt=e=>{if(!It.test(e))return;if(e.startsWith(`@`)){let[t,...n]=e.slice(1).split(`.`);return{kind:`data`,variable:t,names:n}}let t=e,n=0;for(;t.startsWith(`../`);)t=t.slice(3),n+=1;return t===`this`?{kind:`context`,up:n,explicit:!0,names:[]}:t.startsWith(`this.`)?{kind:`context`,up:n,explicit:!0,names:t.slice(5).split(`.`)}:t.startsWith(`./`)?{kind:`context`,up:n,explicit:!0,names:t.slice(2).split(`.`)}:{kind:`context`,up:n,explicit:n>0,names:t.split(`.`)}},zt=e=>[...e.matchAll(Lt)].map(e=>e[1]),Bt=(e,t)=>e.replace(Lt,(e,n)=>t(n)),Vt=e=>{let t=/^\{\{\s*([^{}]*?)\s*\}\}$/.exec(e);return t&&Rt(t[1])?t[1]:void 0},Ht=(e,t)=>{let n=Rt(t);if(!(!n||n.kind!==`context`||n.up>0))return n.names.reduce((e,t)=>typeof e==`object`&&e&&Object.hasOwn(e,t)?e[t]:void 0,e)},Ut=zt,Wt=e=>e.kind===`page`?void 0:Vt(e.resource),Gt=e=>e.kind===`list`&&e.filter!==void 0?Vt(e.filter):void 0,Kt=e=>{if(e.kind===`page`)return[...e.tab===void 0?[]:[e.tab],...Object.values(e.params??{})];let t=Wt(e)===void 0?[]:[e.resource];return e.kind===`record`?[...t,...(Array.isArray(e.key)?e.key:[e.key]).filter(e=>typeof e==`string`),...[e.tab,e.run,e.panel].filter(e=>e!==void 0)]:e.kind===`list`?[...t,...[e.filter,e.orderBy].filter(e=>e!==void 0)]:[...t,...Object.values(e.values??{})]},qt=e=>[...new Set(Kt(e).flatMap(Ut))],Jt=e=>[...new Set(Ut(e))],Yt=Jt,Xt=Bt,Zt=e=>e==null?``:String(e),Qt=(e,t)=>Xt(e,e=>Zt(t(e))),$t=/(["'])\{\{\s*([^{}]*?)\s*\}\}\1|\{\{\s*([^{}]*?)\s*\}\}/g,en=e=>typeof e==`string`&&e!==``&&!/^[\w.:+-]+$/.test(e)?JSON.stringify(e):Zt(e),tn=/(?:[=<>:,]|!=)\s*$/,nn=(e,t)=>e.replace($t,(n,r,i,a,o)=>{if(r)return`${r}${Zt(t(i)).replace(/\\/g,`\\\\`).replaceAll(r,`\\${r}`)}${r}`;let s=t(a);return tn.test(e.slice(0,o))?en(s):Zt(s)}),rn=(e,t)=>{if(e.kind===`page`)return{...e,...e.tab!==void 0&&{tab:Qt(e.tab,t)},...e.params&&{params:Object.fromEntries(Object.entries(e.params).map(([e,n])=>[e,Qt(n,t)]))}};let n=Wt(e)===void 0?e.resource:Qt(e.resource,t);if(e.kind===`record`){let r=e=>typeof e==`string`?Qt(e,t):e;return{...e,resource:n,key:Array.isArray(e.key)?e.key.map(r):r(e.key),...e.tab!==void 0&&{tab:Qt(e.tab,t)},...e.run!==void 0&&{run:Qt(e.run,t)},...e.panel!==void 0&&{panel:Qt(e.panel,t)}}}return e.kind===`create`?{...e,resource:n,...e.values&&{values:Object.fromEntries(Object.entries(e.values).map(([e,n])=>[e,Qt(n,t)]))}}:{...e,resource:n,...e.filter!==void 0&&{filter:nn(e.filter,t)},...e.orderBy!==void 0&&{orderBy:Qt(e.orderBy,t)}}},an=(e,t={})=>rn(e,e=>Ht(t,e)),on=e=>e.kind===`list`&&e.filter!==void 0?[...new Set([...e.filter.matchAll($t)].flatMap(e=>e[3]===void 0?[]:[e[3]]))]:[],sn=/(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/g,cn=/^(["'])\{\{\s*[^{}]*?\s*\}\}\1$/,ln=e=>[...new Set([...e.matchAll(sn)].flatMap(([e])=>cn.test(e)?[]:Ut(e)))],un=e=>/^([a-z][a-z0-9+.-]*:|\/\/)/i.test(e),dn=e=>un(e)?void 0:`href "${e}" points inside the app; give the link \`to\` instead, an address such as { kind: 'record', resource: 'orders', key: '{{order_id}}' }`,fn=Vt,pn=`{{host}}`,mn=(e,t)=>`href`in t?fn(t.href)?void 0:dn(t.href):e.includes(`{{host}}`)?`the label names ${pn}, which only a link with an href has`:void 0,hn=Symbol(`protobase.ref`),gn=e=>Object.defineProperty({name:e},hn,{value:!0}),_n=e=>typeof e==`object`&&!!e&&e[hn]===!0,vn=(e,t)=>new Proxy({},{get:(n,r)=>{if(typeof r!=`symbol`){if(t&&!t.includes(r))throw Error(`Unknown field "${r}"`);return e(r)}}}),yn=e=>({$field:e}),bn=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$field==`string`,xn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Sn=e=>_n(e)?yn(e.name):Array.isArray(e)?e.map(Sn):xn(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Sn(t)])):e,Cn=e=>bn(e)?e.$field:Array.isArray(e)?e.map(Cn):xn(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Cn(t)])):e,wn=e=>bn(e)?[e.$field]:Array.isArray(e)?e.flatMap(wn):xn(e)?Object.values(e).flatMap(wn):[],Tn=({label:e,icon:t})=>({...e!==void 0&&{label:e},...t!==void 0&&{icon:t}}),En=`table`,Dn=(e,t)=>{if(!e.custom)throw Error(`${t} takes a component declared with component(...), not the built-in block ${e.blockName}`);return e.blockName},On={cards:(e,t={})=>({kind:`cards`,name:t.name??`cards`,...Tn(t),...e.image&&{image:e.image.name},...e.title&&{title:e.title.name},...e.subtitle&&{subtitle:e.subtitle.name},...e.amount&&{amount:e.amount.map(e=>e.name)},...e.badge&&{badge:e.badge.name},...e.code&&{code:e.code.name},...e.meta&&{meta:e.meta.map(e=>e.name)},...e.footer&&{footer:e.footer.map(e=>e.name)},...e.flags&&{flags:e.flags.map(e=>e.name)},...e.dots&&{dots:e.dots.map(e=>e.name)},...t.card&&{card:Dn(t.card,`d.cards card`)},...t.photos&&{photos:{...t.photos}},...t.favorite&&{favorite:{...t.favorite}}}),map:(e,t={})=>({kind:`map`,name:t.name??`map`,...Tn(t),latitude:e.latitude.name,longitude:e.longitude.name,...t.cards!==void 0&&{cards:t.cards},...e.approximate&&{approximate:e.approximate.name},...e.exact&&{exact:e.exact.name},...e.radius&&{radius:e.radius.name},...t.defaultRadius!==void 0&&{defaultRadius:t.defaultRadius},...e.area&&{area:e.area.name}}),board:(e,t={})=>({kind:`board`,name:t.name??`board`,...Tn(t),by:e.by.name,...e.title&&{title:e.title.name},...e.subtitle&&{subtitle:e.subtitle.name},...e.badge&&{badge:e.badge.name},...e.meta&&{meta:e.meta.map(e=>e.name)}}),calendar:(e,t={})=>({kind:`calendar`,name:t.name??`calendar`,...Tn(t),start:e.start.name,...e.end&&{end:e.end.name},...e.title&&{title:e.title.name}}),timeline:(e,t={})=>({kind:`timeline`,name:t.name??`timeline`,...Tn(t),start:e.start.name,...e.end&&{end:e.end.name},...e.group&&{group:e.group.name},...e.title&&{title:e.title.name}}),custom:(e,t)=>({kind:`custom`,name:t.name,label:t.label,...Tn({icon:t.icon}),component:Dn(e,`d.custom`),fields:t.fields.map(e=>e.name),...t.props&&{props:Sn(t.props)}})},kn=/^[a-z][a-zA-Z0-9-]*$/,An=e=>{let t=(e.displays??[]).map(e=>e.name);return[...t.filter(e=>!kn.test(e)).map(e=>`display name "${e}" must start with a lowercase letter and hold only letters, digits and dashes`),...t.filter(e=>e===En).map(()=>`"${En}" is the list's own display; give the display another name`),...t.filter((e,n)=>t.indexOf(e)!==n).map(e=>`display "${e}" is defined twice`),...(e.displays??[]).flatMap(t=>t.kind===`map`&&t.cards!==void 0&&!e.displays.some(e=>e.kind===`cards`&&e.name===t.cards)?[`display "${t.name}" names cards "${t.cards}", which is not a cards display of the list`]:[]),...(e.displays??[]).flatMap(t=>t.kind===`cards`?(t.dots??[]).filter(t=>!e.relatedColumns?.some(e=>e.name===t)).map(e=>`display "${t.name}" shows dots of "${e}", which is not a related column of the list`):[]),...(e.displays??[]).flatMap(e=>e.kind===`map`?jn(e).map(t=>`display "${e.name}": ${t}`):[]),...e.default===void 0||e.default===`table`||t.includes(e.default)?[]:[`default "${e.default}" is not one of the displays (${[En,...t].join(`, `)})`]]},jn=e=>{let{approximate:t,exact:n,radius:r,defaultRadius:i,area:a}=e;return t!==void 0&&n!==void 0?[`name approximate or exact, not both`]:[...(r!==void 0||i!==void 0||a!==void 0)&&t===void 0&&n===void 0?[`an area around approximate positions needs the approximate or exact field`]:[],...i===void 0||Number.isFinite(i)&&i>0?[]:[`defaultRadius ${i} is not a number of metres above 0`]]},Mn=(e,t,n)=>{let r=Object.hasOwn(t.fields,e.by)?t.fields[e.by]:void 0;return r?r.type===`enum`?r.filterable?typeof n==`object`?Nn(e.by,r.enumValues??[],n,t):[]:[`"${e.by}" on ${t.name} is not filterable, and each column of the board filters by its value`]:[`"${e.by}" on ${t.name} is ${r.type}, not an enum, whose values are the board's columns`]:[]},Nn=(e,t,{set:n=e,columns:r},i)=>{let a=r?.filter(e=>!t.includes(e))??[];if(a.length>0)return a.map(t=>`drag.board takes cards in column "${t}", which is no value of "${e}"`);let o=Object.hasOwn(i.fields,n)?i.fields[n]:void 0;return o?o.readOnly?[`drag.board sets "${n}", which is read-only`]:o.type===`enum`?(r??t).filter(e=>!o.enumValues?.includes(e)).map(e=>`drag.board sets "${n}" to "${e}", which is no value of "${n}"`):[]:[`drag.board sets "${n}", which ${i.name} does not have`]},Pn=(e,t)=>{let n=e=>Object.hasOwn(t.fields,e)?t.fields[e]:void 0,r=n(e.start),i=e.end===void 0?void 0:n(e.end);if(!r)return[];if(r.type!==`date`&&r.type!==`timestamp`)return[`start "${e.start}" on ${t.name} is ${r.type}, not a date or timestamp`];let a=n=>`${n===e.start?`start`:`end`} "${n}" on ${t.name} is not filterable, and the ${e.kind} filters by it for the days it shows`;return[...r.filterable?[]:[a(e.start)],...i&&i.type!==r.type?[`end "${e.end}" on ${t.name} is ${i.type}, not ${r.type} like start "${e.start}"`]:[],...i&&i.type===r.type&&!i.filterable?[a(e.end)]:[]]},Fn=e=>e.kind===`map`?[e.latitude,e.longitude,e.approximate,e.exact,e.radius,e.area].filter(e=>e!==void 0):e.kind===`custom`?[...e.fields,...wn(e.props)]:e.kind===`board`?[e.by,e.title,e.subtitle,e.badge,...e.meta??[]].filter(e=>e!==void 0):e.kind===`calendar`?[e.start,e.end,e.title].filter(e=>e!==void 0):e.kind===`timeline`?[e.start,e.end,e.group,e.title].filter(e=>e!==void 0):[e.image,e.title,e.subtitle,...e.amount??[],e.badge,e.code,...e.meta??[],...e.footer??[],...e.flags??[]].filter(e=>e!==void 0),In=/^[a-z0-9][a-z0-9_-]*$/,Ln=e=>{if(!e.startsWith(`/-/forms/`))return;let t=e.slice(9);return In.test(t)?{name:t}:void 0},Rn=e=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Rn(e.items):e.kind===`custom`?[e,...Rn(e.fallback??[])]:[e]),zn=(e,t)=>{if(t===void 0)return e;let n=e?.lists?.find(e=>e.name===t);if(!e||!n)return;let{list:r,chart:i,help:a,nav:o,lists:s,names:c,...l}=e,{name:u,...d}=n;return{...l,...d}},Bn=[`neutral`,`info`,`success`,`warning`,`danger`],Vn=20,Hn=(e,t)=>{let n=Me(t);if(!n.ok)return n.errors;if(!n.ast)return[];let r=ft(e,n.ast);return r.ok?[]:r.errors},Un=(e,t)=>{let n=Ct(t);if(!n.ok)return n.errors;let r=wt(e,n.items);return r.ok?[]:r.errors},Wn=(e,t)=>[...e.status===void 0||Object.hasOwn(t.fields,e.status)?[]:[`status field "${e.status}" does not exist`],...e.status===void 0&&e.pulse!==void 0?[`pulse needs a status field`]:[],...Object.entries(e.tones??{}).filter(([,e])=>!Bn.includes(e)).map(([e,t])=>`tone "${t}" for "${e}" is not one of ${Bn.join(`, `)}`),...e.limit===void 0||Number.isInteger(e.limit)&&e.limit>=1&&e.limit<=Vn?[]:[`limit must be a whole number from 1 to ${Vn}`],...e.filter===void 0?[]:Hn(t,e.filter).map(e=>`filter: ${e.message}`),...e.orderBy===void 0?[]:Un(t,e.orderBy).map(e=>`orderBy: ${e.message}`),...e.marks===void 0||typeof e.marks==`string`&&e.marks!==``?[]:[`marks needs the name of a hook in the project UI's marks`],...[`typing`,`unread`].flatMap(t=>e[t]===void 0||e[t]===!0?[]:[`${t} is true or left out`])],Gn=`members`,Kn=(e,t)=>{if(!e||!(`conversation`in e))return[];let{subtitle:n,members:r}=e.conversation;return[...n===void 0||Object.hasOwn(t.fields,n)?[]:[`conversation subtitle names field "${n}", which the resource does not have`],...r===void 0||Object.hasOwn(t.fields,r)?[]:[`conversation members names field "${r}", which the resource does not have`]]},qn=e=>{if(e&&`conversation`in e&&e.conversation.members!==void 0)return{titleFrom:{rule:Gn,fields:[e.conversation.members]}}},Jn=[`neutral`,`blue`,`green`,`amber`,`red`,`violet`],Yn=e=>Jn.includes(e),Xn=e=>`${e}/workflows/types`,Zn=(e,t)=>`${e}/workflows/runners/${encodeURIComponent(t)}/registration`,Qn=e=>`${e}/workflows/runs`,$n=`after`,er=`revision`,tr=(e,t,n)=>{let r=`${Qn(e)}/${encodeURIComponent(t)}/trace`;return!n||n.after===0?r:`${r}?${new URLSearchParams({[$n]:String(n.after),[er]:n.revision})}`},nr=e=>{if(!Array.isArray(e))return String(e);let t=e;return t.length===1?String(t[0]):t.map(e=>encodeURIComponent(String(e))).join(`,`)},rr=e(l(),1),ir=(e,t)=>{let n=Object.entries(e.imports).flatMap(([e,n])=>{let r=t.imports[e];return r===void 0?[e]:n.filter(e=>e!==`*`&&!r.includes(e)).map(t=>`${t} from ${e}`)}),r=e.extensionPoints.filter(e=>!t.extensionPoints.includes(e)).map(e=>`the extension point ${e}`);return[...n,...r]},ar=e=>{try{return new rr.default.Comparator(e),!0}catch(e){if(e instanceof TypeError)return!1;throw e}},or=(e,t)=>{let n=t.trim().split(/\s+/);if(rr.default.valid(e)!==null&&t.trim()!==``&&n.every(ar))return rr.default.satisfies(e,t,{includePrerelease:!0})},sr=(e,t)=>{if(e.api!==t.api)return`it is built for plugin API ${e.api}, and this app has plugin API ${t.api}`;if(e.protobase!==void 0){let n=or(t.version,e.protobase);if(n===void 0)return`its Protobase range "${e.protobase}" is not one this app reads, such as >=0.12.0`;if(!n)return`it needs Protobase ${e.protobase}, and this app runs ${t.version}`}let n=ir(e,t);if(n.length>0)return`it uses what this app does not have: ${n.join(`, `)}`},cr=`[Filtered]`,lr=/authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i,ur=new Set([`url`,`query_string`,`from`,`to`]),dr=12,fr=e=>e.replace(/(^|&)([^=&]*)=([^&]*)/g,(e,t,n)=>lr.test(n)?`${t}${n}=${cr}`:e),pr=e=>{let t=e.indexOf(`?`);if(t===-1)return e;let n=e.indexOf(`#`,t),r=n===-1?e.slice(t+1):e.slice(t+1,n);return`${e.slice(0,t+1)}${fr(r)}${n===-1?``:e.slice(n)}`},mr=(e,t,n)=>lr.test(e)?cr:typeof t==`string`&&ur.has(e)?e===`query_string`?fr(t):pr(t):hr(t,n+1),hr=(e,t)=>t>dr||typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`?[e[0],mr(e[0],e[1],t)]:hr(e,t+1)):Object.fromEntries(Object.entries(e).map(([e,n])=>[e,mr(e,n,t)])),gr=e=>hr(e,0),_r=`protobase-app`,vr=[`unknown-field`,`not-filterable`,`not-sortable`,`unsupported-traversal`,`invalid-traversal`],yr=e=>e.replace(/(["']?)\{\{\s*[^{}]*?\s*\}\}\1/g,(e,t)=>t?`${t}x${t}`:`0`),br=(e,t)=>{let n=ln(t);if(n.length>0)return n.map(e=>`filter: "{{${e}}}" sits inside a longer quoted value; quote it alone, such as title = "{{${e}}}"`);let r=Me(yr(t));if(!r.ok)return r.errors.map(e=>`filter: ${e.message}`);if(!r.ast)return[];let i=ft(e,r.ast);return i.ok?[]:i.errors.filter(e=>vr.includes(e.code)).map(e=>`filter: ${e.message}`)},xr=(e,t)=>{if(qt({kind:`list`,resource:e.name,orderBy:t}).length>0)return[];let n=Ct(t);if(!n.ok)return n.errors.map(e=>`orderBy: ${e.message}`);let r=wt(e,n.items);return r.ok?[]:r.errors.map(e=>`orderBy: ${e.message}`)},Sr=(e,{models:t,pages:n,source:r,placeholderError:i,createPages:a,filterFromRecord:o})=>{let s=qt(e).flatMap(e=>{if(i){let t=i(e);return t===void 0?[]:[t]}return r?Object.hasOwn(r.fields,e)?[]:[`"{{${e}}}" is not a field of ${r.name}`]:[`"{{${e}}}" takes a value from the record, but the link sits on none`]}),c=o===!0&&Gt(e)!==void 0;if(e.kind!==`page`&&Wt(e)!==void 0){if(!(e.kind===`list`?e.filter!==void 0&&!c||e.orderBy!==void 0:e.kind===`create`&&e.values!==void 0))return s;let t=o?`no order or values, and a filter only as one field, such as filter: '{{filter}}'`:`no filter, order or values`;return[...s,`a link whose resource comes from the record ("${e.resource}") names ${t}`]}switch(e.kind){case`page`:return n&&!n.has(e.page)?[...s,`unknown page "${e.page}"`]:s;case`list`:case`record`:case`create`:{let n=Object.hasOwn(t,e.resource)?t[e.resource]:void 0;return n?e.kind===`create`&&a?.has(e.resource)?s:e.kind===`create`?[...s,...Object.keys(e.values??{}).filter(e=>!Object.hasOwn(n.fields,e)).map(t=>`values: unknown field "${t}" on ${e.resource}`)]:e.kind===`list`?[...s,...e.filter&&!c?br(n,e.filter):[],...e.orderBy?xr(n,e.orderBy):[]]:s:[`unknown resource "${e.resource}"`]}default:return[`an address's kind is list, record, create or page, not "${String(e.kind)}"`]}},Cr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wr=`a row button is { label, to } or { label, href }, such as { label: 'Open', to: { kind: 'record', resource: 'tasks', key: '{{id}}' } } or { label: 'Report', href: '{{report_url}}' }, or a list of them`,Tr=e=>Array.isArray(e)?e:[e],Er=e=>{let t=e.href;return t===void 0?{to:e.to}:{href:t}},Dr=e=>{let t=Er(e);return[...new Set([...Jt(e.label),...`href`in t?Jt(t.href):qt(t.to)])]},Or=e=>[...new Set(Tr(e).flatMap(Dr))],kr=(e,t,n)=>e.flatMap(e=>Object.hasOwn(t.fields,e)?[]:[`${n}: "{{${e}}}" is not a field of ${t.name}`]),Ar=(e,t,n)=>{if(!Cr(e))return[wr];if(typeof e.label!=`string`||e.label.trim()===``)return[`a row button needs a label`];if(e.to!==void 0&&e.href!==void 0)return["a row button opens an address in `to` or an outside page in `href`, not both"];let r=kr(Jt(e.label),t,`label`);if(e.href!==void 0){let n=typeof e.href==`string`?fn(e.href):void 0;return n===void 0?[...r,`href: a row button's href is the one field that holds the page's https URL, such as '{{report_url}}'`]:[...r,...kr([n],t,`href`)]}return!Cr(e.to)||typeof e.to.kind!=`string`?["a row button needs an address in `to`, such as { kind: 'record', resource: 'tasks', key: '{{id}}' }, or an outside page in `href`"]:[...r,...Sr(e.to,{...n,source:t,filterFromRecord:!0}).map(e=>`to: ${e}`)]},jr=(e,t,n)=>Array.isArray(e)?e.length===0?[`a row button list needs at least one choice`]:e.flatMap((e,r)=>Ar(e,t,n).map(e=>`choice ${r+1}: ${e}`)):Ar(e,t,n),Mr=(e,t,n)=>{if(!Array.isArray(e))return jr(e,t,n).length===0?e:void 0;let r=Tr(e).filter(e=>Ar(e,t,n).length===0);return r.length===0?void 0:r},Nr={messages:[],replying:!1},Pr=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?t:e)},Fr=(e,t,n)=>{let r=e.find(e=>e.id===t);return Pr(e,r?{...r,parts:Pr(r.parts,n)}:{id:t,from:`assistant`,parts:[n]})},Ir=(e,t)=>{switch(t.type){case`state`:return t.state;case`message`:return{...e,messages:Pr(e.messages,t.message)};case`part`:return{...e,messages:Fr(e.messages,t.messageId,t.part)};case`patch`:{let{replying:n=e.replying,status:r=e.status,placeholder:i=e.placeholder}=t;return{messages:e.messages,replying:n,...r!=null&&{status:r},...i!=null&&{placeholder:i}}}}},Lr=e=>{if(!(e instanceof DOMException&&e.name===`AbortError`))throw e},Rr=async(e,t,n)=>{let r=p({onEvent:e=>t(e.data)}),i=new TextDecoder,a=e.getReader();for(n?.addEventListener(`abort`,()=>void a.cancel().catch(Lr),{once:!0});;){let{done:e,value:t}=await a.read();if(e)break;r.feed(i.decode(t,{stream:!0}))}r.feed(`${i.decode()}\n\n`)},zr=[`en`,`nl`],Br=e=>zr.includes(e),Vr=e=>e.map(e=>e.split(`-`)[0].toLowerCase()).find(Br)??`en`,Hr=e=>e.charAt(0).toUpperCase()+e.slice(1),P=e=>Hr(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e),Ur=(e,t)=>t?.[e]??e,Wr=[`name`,`title`,`number`,`sku`,`email`,`code`,`description`],Gr=e=>e?.type===`text`&&!e.sensitive,Kr=(e,t)=>t?.title??Wr.find(t=>Gr(e.fields[t]))??Object.values(e.fields).find(Gr)?.name??e.primaryKey[0],qr=(e,t)=>t?.title??t?.list?.columns.find(t=>e.fields[t]?.type===`text`)??Kr(e),Jr=(e,t,n,r)=>{let i=qr(e,t),a=n[i];return a==null?r:e.fields[i]?.type===`enum`?Ur(String(a),t?.fields[i]?.valueLabels):String(a)},Yr=`protobase-api-origin`,Xr={fingerprint:`fingerprint`,shellVersion:`shell_version`},Zr=`/api/mobile/release`,Qr=`/api/mobile/releases`,$r=({fingerprint:e,shellVersion:t})=>new URLSearchParams({[Xr.fingerprint]:e,[Xr.shellVersion]:t}).toString(),ei=`/api/auth`,ti=`second-step`,ni={ios:`capacitor://localhost`,android:`https://localhost`},ri={database:`protobase-push`,store:`registration`,key:`current`},ii=`protobase.sw.js`,ai=`token`,oi=(e,t)=>`${e}?${new URLSearchParams({[ai]:t})}`,si=(e,t)=>`${e}/notifications/devices${t===void 0?``:`/${encodeURIComponent(t)}`}`,ci=`app`,li=e=>`${e}/files`,ui=(e,t,n)=>`${e}/${t}/${n}`,di=e=>{let t=/^([a-z][a-z0-9-]*):([A-Za-z0-9_-][^?#]*)/.exec(e);return t?{provider:t[1],path:t[2]}:void 0},fi=e=>`${e}${e.includes(`?`)?`&`:`?`}via=${ci}`,pi=/^[^\s\u0000-\u001f\u007f-\u009f]+$/,mi=e=>{if(typeof e!=`string`||e.length>2048||!pi.test(e)||!URL.canParse(e))return;let t=new URL(e);if(t.protocol===`https:`||t.protocol===`http:`)return t.href},hi=/^[A-Za-z0-9_-]{1,64}$/,gi=(e,t)=>{let n=`${e}/notifications/history`;if(t===void 0)return n;if(typeof t==`string`)return`${n}/${t}`;if(!hi.test(t.read))throw Error(`A history entry id is letters, digits, "_" and "-" only`);return`${n}/${t.read}/read`},_i=(e,t)=>`${e}/status${t===void 0?``:`/${t}`}`,vi=/\p{Cc}/u,yi=e=>{if(vi.test(e))return`A status is one line of text, without control characters`;if([...e].length>100)return`A status is at most 100 characters`},bi=(e,t=Date.now())=>{if(e&&!(e.clearsAt!==null&&Date.parse(e.clearsAt)<=t)&&(e.availability!==`automatic`||e.text!==null))return e},xi=(e,t)=>t?.list?.columns??Object.values(e.fields).filter(e=>!e.writeOnly).slice(0,6).map(e=>e.name),Si={json:[`json`],members:[`json`],workflow:[`json`],workflow_run:[`uuid`],workflow_status:[`enum`],custom_step_container:[`json`],runner_install:[`uuid`]},Ci=(e,t)=>`${e}/calls/guests${t?`/${t}`:``}`,wi=`$rings`,Ti=`decline`,Ei=(e,t)=>{let n=`${e}/calls/rings`;return t===void 0?n:`${n}/${encodeURIComponent(t.decline)}/${Ti}`},Di=`calls`,Oi=`en`,ki,Ai=()=>ki??Oi,ji=()=>Oi,Mi=e=>{Oi=e},Ni=e=>{ki=e},Pi=(e=globalThis.navigator?.languages??[])=>Vr(e),Fi={en:`en-GB`,nl:`nl-NL`},Ii=()=>Fi[Ai()],Li={en:()=>s(()=>import(`./en-DnsB2haa.js`).then(e=>e.default),[]),nl:()=>s(()=>import(`./nl-Ce2dHlet.js`).then(e=>e.default),[])},Ri={},zi=new Map,Bi=(e,t)=>{Ri[e]=t},Vi=e=>Ri[e]!==void 0,Hi=e=>{if(Vi(e))return Promise.resolve();let t=zi.get(e)??Li[e]().then(t=>Bi(e,t));return zi.set(e,t),t},Ui=async e=>{await Hi(e),Mi(e)},Wi=e=>{let t=Ri[e];if(!t)throw Error(`The ${e} texts are not loaded: await loadTexts('${e}') first`);return t},Gi={lower:e=>e.join(``).toLowerCase()},Ki=new Map,qi=(e,t)=>{let n=Ai(),r=`${n}\0${e}\0${t}`,i=Ki.get(r);if(i)return i;let a=Wi(n)[e][t];if(a===void 0)throw Error(`No text ${e}.${t} in ${n}`);let o=new ie(a,Ii());return Ki.set(r,o),o},F=e=>{let t=(t,n)=>qi(e,t).format({...n,...Gi});return t.rich=(t,n)=>{let r=qi(e,t).format({...n,...Gi});return Array.isArray(r)?(0,j.createElement)(j.Fragment,null,...r):r},t},I={meta:[`meta`],activeRole:[`session`,`active-role`],organizations:[`session`,`organizations`],organizationMembers:e=>[`session`,`members`,e],myInvitations:[`session`,`my-invitations`],sourceMeta:(e,t)=>[`source-meta`,e,t.join(`,`)],sourceMetas:e=>[`source-meta`,e],list:(e,t,n,r,i)=>[`list`,e,t,n,r,i],page:(e,t,n,r,i)=>[`page`,e,t,n,r,i],pages:(e,t,n)=>[`page`,e,t,n],navRecent:(e,t,n,r)=>[`list`,e,t,n,r,`nav-recent`],startRecord:(e,t,n,r)=>[`list`,e,t,n,`start-record`,r],reactionsOf:(e,t)=>[`list`,e,t,`reactions-of`],attachmentsOf:(e,t)=>[`list`,e,t,`attachments-of`],first:(e,t,n)=>[`first-page`,e,t,n],record:(e,t)=>[`record`,e,t],image:(e,t)=>[`image`,e,t],recordPreview:(e,t)=>[`record-preview`,e,t],history:(e,t,n)=>[`record`,e,t,`history`,n],comments:(e,t)=>[`record`,e,t,`comments`],facets:(e,t,n)=>[`facets`,e,t,n],series:(e,t,n,r,i)=>[`series`,e,t,n,r,i],aggregate:(e,t)=>[`aggregate`,e,t],histogram:(e,t,n,r)=>[`histogram`,e,t,n,r],map:(e,t,n,r,i)=>[`map`,e,t,n,r,i],relatedLabel:(e,t)=>[`related-label`,e,t],titleRow:(e,t,n)=>[`title-row`,e,t,n],labels:(e,t)=>[`labels`,e,t],pickedLabels:(e,t)=>[`picked-labels`,e,t],count:(e,t)=>[`count`,e,t],planRead:(e,t)=>[`plan`,e[0],e,t],exportCount:(e,t)=>[`list`,e,t,`export-count`],firstRecord:(e,t,n)=>[`first-record`,e,t,n],pathValue:(e,t,n)=>[`path-value`,e,t,n],inbox:[`inbox`],inboxUnread:[`inbox`,`unread`],inboxPages:[`inbox`,`pages`],members:e=>[`members`,e],statuses:e=>[`statuses`,e],ownStatus:e=>[`statuses`,e,`own`],rings:[`call-rings`],recordCalls:(e,t)=>[`record-calls`,e,t],workflowTypes:[`workflow-types`],workflowRunTrace:e=>[`workflow-run-trace`,e],publicForm:e=>[`public-form`,e]},Ji=(e,t)=>t.has(e[1])||e[0]===`plan`&&e[2].some(e=>t.has(e)),Yi=e=>{let t=e?.session();if(t)return(e?.queries(`user:${t.user.id}`)?.state.queries.find(e=>JSON.stringify(e.queryKey)===JSON.stringify(I.meta)))?.state.data},Xi=e=>Yi(e)?.plugins??[],Zi={name:`@protobase/ui`,version:`0.121.12`,description:`The Protobase admin app and the React hooks and components for custom UI.`,license:`Apache-2.0`,repository:{type:`git`,url:`git+https://github.com/PrototeamHQ/protobase.git`,directory:`packages/ui`},homepage:`https://docs.protobase.net`,type:`module`,protobase:{pluginApi:1},sideEffects:[`*.css`,`./dist/app/main.js`],engines:{node:`>=22.12.0`},exports:{".":`./src/index.ts`,"./theme.css":`./src/theme.css`,"./styles.css":`./src/styles.css`,"./unstable/*":{types:[`./src/*.ts`,`./src/*.tsx`],default:`./src/*`}},types:`./src/index.ts`,files:[`dist`],scripts:{build:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`,prepack:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`},publishConfig:{access:`public`,exports:{".":`./dist/index.js`,"./theme.css":`./dist/theme.css`,"./styles.css":`./dist/styles.css`,"./unstable/*":`./dist/*.js`},types:`./dist/index.d.ts`},dependencies:{"@dnd-kit/core":`^6.3.1`,"@dnd-kit/sortable":`^10.0.0`,"@protobase/client":`workspace:*`,"@protobase/layout":`workspace:*`,"@protobase/schema":`workspace:*`,"@protobase/workflows":`workspace:*`,"@sentry/browser":`^11.7.0`,"@tanstack/react-query":`^5.104.1`,"@tanstack/react-table":`^9.2.6`,"@xyflow/react":`^12.12.1`,"altcha-lib":`^2.6.0`,dompurify:`^3.4.17`,elkjs:`0.12.1`,fflate:`^0.8.3`,"intl-messageformat":`^12.1.4`,"lucide-react":`^1.52.0`,"maplibre-gl":`^6.14.0`,marked:`^18.1.1`,papaparse:`^5.7.0`,pmtiles:`^4.5.0`,react:`^19.3.0`,"react-dom":`^19.3.0`,"react-map-gl":`^8.1.3`,recharts:`^3.10.1`,tailwindcss:`^4.3.3`,thumbhash:`^0.1.1`,uqr:`^0.1.3`},devDependencies:{"@types/papaparse":`^5.5.2`}},Qi=Zi.protobase.pluginApi,$i=Zi.version,ea=`session`,ta=`queries`,na=e=>`user:${e.user.id}`,ra=async(e,t)=>{let[n,r]=await Promise.all([e.read(ea),e.read(ta)]),i=n?.buster===t?n.value:void 0,a=r?.buster===t&&i&&r.value.owner===na(i)?r.value:void 0,o=[...n&&!i?[ea]:[],...r&&!a?[ta]:[]];return o.length>0&&await e.remove(o),{session:()=>i,queries:e=>a?.owner===e?a:void 0,saveSession:n=>(a&&a.owner!==na(n)&&(a=void 0),i=n,e.write(ea,{buster:t,value:n})),saveQueries:n=>(a=n,e.write(ta,{buster:t,value:n})),clear:()=>(i=void 0,a=void 0,e.remove([ea,ta]))}},ia=(0,j.createContext)(void 0),aa=ia.Provider,oa=()=>(0,j.useContext)(ia),sa=`protobase-start-cache`,ca=`records`,la=(e=indexedDB)=>{let t,n=()=>t??=new Promise((t,n)=>{let r=e.open(sa,1);r.onupgradeneeded=()=>r.result.createObjectStore(ca),r.onerror=()=>n(r.error),r.onsuccess=()=>t(r.result)}),r=async(e,t)=>{let r=await n();return new Promise((n,i)=>{let a=r.transaction(ca,e),o=t(a.objectStore(ca));a.oncomplete=()=>n(o?.result),a.onabort=()=>i(a.error??new DOMException(`The start cache transaction was aborted`,`AbortError`))})};return{read:e=>r(`readonly`,t=>t.get(e)),write:async(e,t)=>void await r(`readwrite`,n=>n.put(t,e)),remove:async e=>void await r(`readwrite`,t=>{for(let n of e)t.delete(n)})}},ua=async()=>{if(typeof indexedDB<`u`)try{return await ra(la(),$i)}catch(e){if(e instanceof DOMException)return;throw e}},da=F(`plugins`),fa=e=>typeof e==`string`&&e.trim()!==``,pa=e=>Array.isArray(e)&&e.every(fa),ma=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(pa),ha=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:da(`notObject`)};let{name:t,version:n,api:r,protobase:i,imports:a,extensionPoints:o,entry:s,css:c}=e;return fa(t)?Number.isInteger(r)?i!==void 0&&!fa(i)?{problem:da(`badVersions`)}:!ma(a)||!pa(o)?{problem:da(`noUses`)}:fa(s)?c!==void 0&&!fa(c)?{problem:da(`badStylesheet`)}:n!==void 0&&!fa(n)?{problem:da(`badVersion`)}:{manifest:{name:t,api:r,imports:a,extensionPoints:o,entry:s,...i!==void 0&&{protobase:i},...n!==void 0&&{version:n},...c!==void 0&&{css:c}}}:{problem:da(`noModule`)}:{problem:da(`noApi`)}:{problem:da(`noName`)}},ga=/^[A-Z][A-Za-z0-9]*$/,_a=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,va=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&ga.test(e[0])&&_a(e[1]));if(n.length===0)return t;for(let[e,r]of n)if(t.components&&Object.hasOwn(t.components,e)&&t.components[e]!==r)throw Error(`The component "${e}" is exported by name and given in components as another one; keep the export`);return{...t,components:{...t.components,...Object.fromEntries(n)}}},L=e(a(),1),ya=class extends Error{name=`UiConflictError`},ba=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?va(e):e,xa=(e,t)=>[...(e.extends??[]).map(ba).flatMap((e,n)=>xa(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Sa=(e,t,n)=>{let r={},i=new Map;for(let{ui:a,label:o}of t)for(let[t,s]of Object.entries(n(a)??{})){if(Object.hasOwn(r,t)&&r[t]!==s)throw new ya(`${e} "${t}" is defined twice, by ${i.get(t)} and by ${o}; rename one of them`);r[t]=s,i.set(t,i.get(t)??o)}return r},Ca=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,L.jsx)(e,{},t)),wa=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,L.jsx)(t,{...n,children:e}),t),Ta=(...e)=>{let t=e.flatMap((e,t)=>xa(e,e.name??`UI config ${t+1}`)),n=Sa(`The component`,t,e=>e.components),r=Sa(`The action handler`,t,e=>e.actions),i=Sa(`The field type`,t,e=>e.fields),a=Sa(`The file viewer`,t,e=>e.fileViewers),o=Sa(`The drop rule`,t,e=>e.dropRules),s=Sa(`The board drop`,t,e=>e.boardDrops),c=Sa(`The title rule`,t,e=>e.titles),l=Sa(`The marks hook`,t,e=>e.marks),u=Ca(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),d=Ca(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),f=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,p=t.findLast(({ui:e})=>e.shell?.bell)?.ui.shell?.bell,m=t.findLast(({ui:e})=>e.presence)?.ui.presence,h=wa(t.flatMap(({ui:e})=>e.beforeSignIn?[e.beforeSignIn]:[])),g=e.at(-1)?.name;return{...g&&{name:g},components:n,actions:r,...Object.keys(i).length>0&&{fields:i},...Object.keys(a).length>0&&{fileViewers:a},...Object.keys(o).length>0&&{dropRules:o},...Object.keys(s).length>0&&{boardDrops:s},...Object.keys(c).length>0&&{titles:c},...Object.keys(l).length>0&&{marks:l},...(u||d||f||p)&&{shell:{...u&&{actions:u},...d&&{rightPanel:d},...f&&{logo:f},...p&&{bell:p}}},...m&&{presence:m},...h&&{beforeSignIn:h}}},Ea=(0,j.createContext)(null),Da=Ea.Provider,Oa=()=>{let e=(0,j.useContext)(Ea);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},ka=(e,t,n)=>{let r=n=>(0,L.jsx)(Da,{value:e,children:(0,L.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},Aa=(e,t,n)=>({of:n.of,display:ka(e,n.display,`fields.${t}.display`),...n.editor&&{editor:ka(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:ka(e,n.cell,`fields.${t}.cell`)}}),ja=(e,t)=>{let n=Ta({...va(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,ka(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,Aa(e,t,n)])),a=n.fileViewers&&Object.fromEntries(Object.entries(n.fileViewers).map(([t,n])=>[t,{component:ka(e,n.component,`fileViewers.${t}`)}])),o=n.shell&&{...n.shell.actions&&{actions:ka(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:ka(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:ka(e,n.shell.logo,`shell.logo`)},...n.shell.bell&&{bell:ka(e,n.shell.bell,`shell.bell`)}},s=n.beforeSignIn&&ka(e,n.beforeSignIn,`beforeSignIn`);return{name:e.name,components:r,...n.actions&&{actions:n.actions},...n.dropRules&&{dropRules:n.dropRules},...n.boardDrops&&{boardDrops:n.boardDrops},...n.titles&&{titles:n.titles},...n.marks&&{marks:n.marks},...i&&{fields:i},...a&&{fileViewers:a},...o&&{shell:o},...s&&{beforeSignIn:s}}},Ma={pluginApi:1,exports:`ActionCard.ActionInputError.ApiProvider.App.AppLink.AppMark.AssistantDock.AuthLayout.AvailabilityMark.Button.CallMark.CallView.Carousel.ChatDivider.ChatMessage.ChatThread.Choices.CodeForm.CompactTable.Composer.Dialog.DiffView.Field.FieldBadge.FieldList.FileReadError.FocusActions.FocusNotice.FocusPage.FocusPanel.FocusSlot.Form.HtmlFrame.InPlaceForm.Input.LogoMark.Markdown.MentionBox.MentionedText.MenuSelect.MenuSurface.OtpInput.PartView.RecordCall.RecordLink.RecordPicker.ResendCodeButton.ResponsiveDialog.RouteLink.SearchPicker.Section.Segmented.Select.SidePanel.SignInPrompt.Spinner.StatusMark.StepList.Textarea.ToneEdge.TypingLine.allowDelayMs.buttonClass.chatDayLabel.closeSidebarEvent.definePlugin.defineUi.diffStats.emptyDraft.extensionPointsOf.fileNamed.isConflict.isFramed.logoTapEvent.mentionedIds.menuItemClass.mergeUi.parseDiff.parsePatch.pluginApi.pluginsChangedEvent.protobaseVersion.sameChatDay.showTextsIn.siblingPage.signedOutEvent.statusRefreshMs.uiFromModule.uiReadyEvent.useApiToken.useAppAddress.useArmedAfterFocus.useAssistant.useAssistantClient.useBackendData.useClient.useComponentReads.useComponentSelect.useCreateForm.useFacets.useFieldControl.useFileText.useFocusPage.useFocusRecord.useFocusZoneFilled.useGuardedPress.useHistogram.useInbox.useLayoutRecord.useList.useListDisplay.useMarkNotificationsRead.useMembers.useMeta.useOwnStatus.usePlugin.usePopoverMenu.usePresence.usePushNotifications.useQuery.useQueryClient.useRecord.useRecordCallAddress.useRecordCalls.useResourceClient.useSeries.useSiblingPage.useSignedInUser.useStatuses.useToast.useTypers.useTypingSender.useUnreadNotifications.useUpdateRecord.useViewChannel`.split(`.`)},Na=[`components`,`actions`,`fields`,`fileViewers`,`dropRules`,`boardDrops`,`titles`,`marks`,`shell.actions`,`shell.rightPanel`,`shell.logo`,`shell.bell`,`beforeSignIn`],Pa=(e,t)=>t.split(`.`).reduce((e,t)=>e?.[t],e),Fa=e=>e!=null&&(typeof e!=`object`||Object.keys(e).length!==0),Ia=e=>Na.filter(t=>Fa(Pa(e,t))),La={imports:{react:Object.keys(j),"react/jsx-runtime":Object.keys(L),"react-dom":Object.keys(M),"@protobase/ui":Ma.exports},extensionPoints:Na},Ra={readJson:async e=>{let t=await fetch(e,{cache:`no-cache`,credentials:`same-origin`});return t.ok?{json:await t.json()}:{status:t.status}},addStylesheet:e=>{if([...document.querySelectorAll(`link[rel="stylesheet"]`)].some(t=>t.href===e))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},importModule:e=>s(()=>import(e),[])},za={api:Qi,version:$i,...La},Ba=e=>e instanceof Error?e.message:String(e),Va=async(e,t,n,r=za)=>{let i=new URL(e.url,n).href,a=(e,t)=>({kind:`off`,url:i,...t&&{name:t},reason:e}),o;try{let n=await t.readJson(i);if(`status`in n)return a(da(`answered`,{status:n.status}));let s=ha(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=sr(c,r);if(l)return a(l,o);c.css&&t.addStylesheet(new URL(c.css,i).href);let u=await t.importModule(new URL(c.entry,i).href),d={name:o,...c.version&&{version:c.version},url:i,settings:e.settings??{}};return{kind:`loaded`,plugin:d,ui:ja(d,u)}}catch(e){return a(da(`couldNotLoad`,{reason:Ba(e)}),o)}},Ha=`protobase:plugins-changed`,Ua=(e,t=()=>window.location.href)=>{let n=new Map,r=new Map,i=new Set,a=0;return{load:i=>{let a=JSON.stringify(i),o=n.get(a);if(o)return o;let s=Va(i,e,t());return n.set(a,s),s.then(e=>r.set(a,e)),s},loaded:e=>r.get(JSON.stringify(e)),forget:()=>{n.clear(),r.clear(),a+=1;for(let e of i)e()},revision:()=>a,subscribe:e=>(i.add(e),()=>void i.delete(e))}},Wa=(e,t,n)=>Promise.race([Promise.all(t.map(t=>e.load(t))),new Promise(e=>setTimeout(e,n))]).then(()=>void 0),Ga=(0,j.createContext)(null),Ka=({loader:e=Ra,source:t,children:n})=>{let r=(0,j.useMemo)(()=>t??Ua(e),[t,e]);return(0,j.useEffect)(()=>{let e=()=>r.forget();return window.addEventListener(Ha,e),()=>window.removeEventListener(Ha,e)},[r]),(0,L.jsx)(Ga.Provider,{value:r,children:n})},qa=()=>{let e=(0,j.useContext)(Ga);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},Ja=1e4,Ya=[],Xa=(e,t)=>{let n=(0,j.useSyncExternalStore)(t.subscribe,t.revision,t.revision),r=JSON.stringify(e),i=`${r}#${n}`,[a,o]=(0,j.useState)(()=>Za(e,t,i)??{key:`[]`,loads:Ya,settled:!0});return(0,j.useEffect)(()=>{if(e.length===0)return;let n=!0,a=!1,s=e.map(()=>void 0),c=()=>{if(!n)return;let t=s.filter(e=>e!==void 0),c=a||t.length===e.length;o(e=>e.refs===r&&e.settled&&!c?e:{key:i,refs:r,loads:t,settled:c})},l=setTimeout(()=>{a=!0,c()},Ja);return e.forEach((e,n)=>{t.load(e).then(e=>{s[n]=e,c()})}),()=>{n=!1,clearTimeout(l)}},[i,t]),e.length===0?{loads:Ya,settled:!0}:a.key===i||a.refs===r&&a.settled?a:Za(e,t,i)??{loads:Ya,settled:!1}},Za=(e,t,n)=>{if(e.length===0)return;let r=e.map(e=>t.loaded(e));return r.every(e=>e!==void 0)?{key:n,refs:JSON.stringify(e),loads:r,settled:!0}:void 0},Qa=`protobase.liveUpdate.page`,$a=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`),eo=(e,t,n)=>{let r=n.state,i=typeof r?.protobaseEntry==`string`?r.protobaseEntry:void 0;e.setItem(Qa,JSON.stringify({url:`${t.pathname}${t.search}${t.hash}`,entry:i}))},to=e=>e.removeItem(Qa),no=e=>e.getItem(Qa)!==null,ro=(e,t)=>{let n=e.getItem(Qa);if(n===null)return;to(e);let r;try{r=JSON.parse(n)}catch(e){if(e instanceof SyntaxError)return;throw e}if(typeof r!=`object`||!r)return;let{url:i,entry:a}=r;$a(i)&&t.replaceState(typeof a==`string`?{protobaseEntry:a}:null,``,i)},io=()=>{let e=ue(()=>window.sessionStorage,void 0);return e&&{keep:()=>eo(e,window.location,window.history),forget:()=>to(e)}},R=(...e)=>e.filter(Boolean).join(` `),ao=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function oo(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:ao(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var so=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},co=e=>{let t=so(e);return t.charAt(0).toUpperCase()+t.slice(1)},lo=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),uo={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function fo(e){return e!=null}function po(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??uo.width,a=e.size??e.height??uo.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?lo(...c):lo(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??uo[`stroke-width`])*Number(e.size??e.width??uo.width)/Number(t.size??t.width??uo.width):t.strokeWidth??uo[`stroke-width`];return[`svg`,{...Object.entries(uo).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&fo(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&fo(t.width)&&{[r(`width`)]:t.width},...`height`in t&&fo(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function mo(e,t={}){return po(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var ho=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},go=(0,j.createContext)({}),_o=()=>(0,j.useContext)(go),vo=(0,j.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=_o()??{},y=!!c||ho(d),[b,x,S=[]]=mo(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:lo(v,s),hasA11yProp:y,attributes:d});return(0,j.createElement)(b,{ref:f,...x},[...S.map(([e,t])=>(0,j.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function z(e,t=[],n=[]){let r=typeof e==`string`?oo(e,t,n):e,i=(0,j.forwardRef)(({className:e,...t},n)=>(0,j.createElement)(vo,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=co(r.name)),i}var yo={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};yo.node;var bo=z(yo),xo={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};xo.node;var So=z(xo),Co={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};Co.node;var wo=z(Co),To={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};To.node;var Eo=z(To),Do={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Do.node;var Oo=z(Do),ko={name:`bath`,size:24,node:[[`path`,{d:`M10 4 8 6`,key:`1rru8s`}],[`path`,{d:`M17 19v2`,key:`ts1sot`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`M7 19v2`,key:`12npes`}],[`path`,{d:`M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5`,key:`14ym8i`}]]};ko.node;var Ao=z(ko),jo={name:`bed`,size:24,node:[[`path`,{d:`M2 4v16`,key:`vw9hq8`}],[`path`,{d:`M2 8h18a2 2 0 0 1 2 2v10`,key:`1dgv2r`}],[`path`,{d:`M2 17h20`,key:`18nfp3`}],[`path`,{d:`M6 8v9`,key:`1yriud`}]]};jo.node;var Mo=z(jo),No={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};No.node;var Po=z(No),Fo={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Fo.node;var Io=z(Fo),Lo={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};Lo.node;var Ro=z(Lo),zo={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};zo.node;var Bo=z(zo),Vo={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};Vo.node;var Ho=z(Vo),Uo={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};Uo.node;var Wo=z(Uo),Go={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};Go.node;var Ko=z(Go),qo={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};qo.node;var Jo=z(qo),Yo={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Yo.node;var Xo=z(Yo),Zo={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Zo.node;var Qo=z(Zo),$o={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};$o.node;var es=z($o),ts={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};ts.node;var ns=z(ts),rs={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};rs.node;var is=z(rs),as={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};as.node;var os=z(as),ss={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};ss.node;var cs=z(ss),ls={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};ls.node;var us=z(ls),ds={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};ds.node;var fs=z(ds),ps={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ps.node;var ms=z(ps),hs={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};hs.node;var gs=z(hs),_s={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};_s.node;var vs=z(_s),ys={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};ys.node;var bs=z(ys),xs={name:`door-open`,size:24,node:[[`path`,{d:`M10 21H2`,key:`1sthdo`}],[`path`,{d:`M10 3H7a2 2 0 00-2 2v16`,key:`15gt7x`}],[`path`,{d:`M14 12h.01`,key:`1jfl7z`}],[`path`,{d:`M19 21V5a2 2 0 00-1.675-1.974l-6.163-1.013A1 1 0 0010 3v18a1 1 0 001.124.992z`,key:`tyvg9a`}],[`path`,{d:`M22 21h-3`,key:`1ec3tr`}]]};xs.node;var Ss=z(xs),Cs={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Cs.node;var ws=z(Cs),Ts={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};Ts.node;var Es=z(Ts),Ds={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Ds.node;var Os=z(Ds),ks={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};ks.node;var As=z(ks),js={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};js.node;var Ms=z(js),Ns={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ns.node;var Ps=z(Ns),Fs={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Fs.node;var Is=z(Fs),Ls={name:`face-slightly-smiling-plus`,size:24,node:[[`path`,{d:`M13.267 2.08a10 10 0 108.653 8.653`,key:`1wbpyh`}],[`path`,{d:`M15 10V9`,key:`4dkmfx`}],[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M16.472 15a6 6 0 01-8.943 0`,key:`7qomzy`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M9 10V9`,key:`1lazqi`}]],aliases:[`smile-plus`]};Ls.node;var Rs=z(Ls),zs={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};zs.node;var Bs=z(zs),Vs={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Vs.node;var Hs=z(Vs),Us={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};Us.node;var Ws=z(Us),Gs={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};Gs.node;var Ks=z(Gs),qs={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};qs.node;var Js=z(qs),Ys={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 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-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ys.node;var Xs=z(Ys),Zs={name:`land-plot`,size:24,node:[[`path`,{d:`m12 8 6-3-6-3v10`,key:`mvpnpy`}],[`path`,{d:`m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12`,key:`ek95tt`}],[`path`,{d:`m6.49 12.85 11.02 6.3`,key:`1kt42w`}],[`path`,{d:`M17.51 12.85 6.5 19.15`,key:`v55bdg`}]]};Zs.node;var Qs=z(Zs),$s={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};$s.node;var ec=z($s),tc={name:`leaf`,size:24,node:[[`path`,{d:`M11 20a10 10 0 0010-10 25.9 25.9 0 00-1.04-7.281 1 1 0 00-1.755-.325C15.833 5.5 13 5.5 9.8 6.1A7 7 0 0011 20`,key:`1wjnjv`}],[`path`,{d:`M2 21a5 5 0 012.911-4.544C7.613 15.212 8.351 15.24 11 13`,key:`c1ejpn`}]]};tc.node;var nc=z(tc),rc={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};rc.node;var ic=z(rc),ac={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};ac.node;var oc=z(ac),sc={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};sc.node;var cc=z(sc),lc={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};lc.node;var uc=z(lc),dc={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};dc.node;var fc=z(dc),pc={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};pc.node;var mc=z(pc),hc={name:`memory-stick`,size:24,node:[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]};hc.node;var gc=z(hc),_c={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};_c.node;var vc=z(_c),yc={name:`mic-off`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]};yc.node;var bc=z(yc),xc={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};xc.node;var Sc=z(xc),Cc={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Cc.node;var wc=z(Cc),Tc={name:`monitor-up`,size:24,node:[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]};Tc.node;var Ec=z(Tc),Dc={name:`monitor-x`,size:24,node:[[`path`,{d:`m14.5 12.5-5-5`,key:`1jahn5`}],[`path`,{d:`m9.5 12.5 5-5`,key:`1k2t7b`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]};Dc.node;var Oc=z(Dc),kc={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};kc.node;var Ac=z(kc),jc={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};jc.node;var Mc=z(jc),Nc={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Nc.node;var Pc=z(Nc),Fc={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Fc.node;var Ic=z(Fc),Lc={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Lc.node;var Rc=z(Lc),zc={name:`phone-incoming`,size:24,node:[[`path`,{d:`M16 2v6h6`,key:`1mfrl5`}],[`path`,{d:`m22 2-6 6`,key:`6f0sa0`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};zc.node;var Bc=z(zc),Vc={name:`phone-off`,size:24,node:[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]};Vc.node;var Hc=z(Vc),Uc={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};Uc.node;var Wc=z(Uc),Gc={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Gc.node;var Kc=z(Gc),qc={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};qc.node;var Jc=z(qc),Yc={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Yc.node;var Xc=z(Yc),Zc={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Zc.node;var Qc=z(Zc),$c={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};$c.node;var el=z($c),tl={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};tl.node;var nl=z(tl),rl={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};rl.node;var il=z(rl),al={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};al.node;var ol=z(al),sl={name:`ruler-dimension-line`,size:24,node:[[`path`,{d:`M10 15v-3`,key:`1pjskw`}],[`path`,{d:`M14 15v-3`,key:`1o1mqj`}],[`path`,{d:`M18 15v-3`,key:`cws6he`}],[`path`,{d:`M2 8V4`,key:`3jv1jz`}],[`path`,{d:`M22 6H2`,key:`1iqbfk`}],[`path`,{d:`M22 8V4`,key:`16f4ou`}],[`path`,{d:`M6 15v-3`,key:`1ij1qe`}],[`rect`,{x:`2`,y:`12`,width:`20`,height:`8`,rx:`2`,key:`1tqiko`}]]};sl.node;var cl=z(sl),ll={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};ll.node;var ul=z(ll),dl={name:`send-horizontal`,size:24,node:[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]],aliases:[`send-horizonal`]};dl.node;var fl=z(dl),pl={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};pl.node;var ml=z(pl),hl={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};hl.node;var gl=z(hl),_l={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};_l.node;var vl=z(_l),yl={name:`shield-check`,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:`m9 12 2 2 4-4`,key:`dzmm74`}]]};yl.node;var bl=z(yl),xl={name:`shopping-cart`,size:24,node:[[`path`,{d:`m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18`,key:`uebgi3`}],[`path`,{d:`M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25`,key:`1j7c9p`}],[`circle`,{cx:`18`,cy:`20`,r:`2`,key:`t9985n`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};xl.node;var Sl=z(xl),Cl={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Cl.node;var wl=z(Cl),Tl={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Tl.node;var El=z(Tl),Dl={name:`sun-moon`,size:24,node:[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715`,key:`xlf6rm`}],[`path`,{d:`M16 12a4 4 0 0 0-4-4`,key:`6vsxu`}],[`path`,{d:`m19 5-1.256 1.256`,key:`1yg6a6`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}]]};Dl.node;var Ol=z(Dl),kl={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};kl.node;var Al=z(kl),jl={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};jl.node;var Ml=z(jl),Nl={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Nl.node;var Pl=z(Nl),Fl={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Fl.node;var Il=z(Fl),Ll={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Ll.node;var Rl=z(Ll),zl={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};zl.node;var Bl=z(zl),Vl={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Vl.node;var Hl=z(Vl),Ul={name:`user-plus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};Ul.node;var Wl=z(Ul),Gl={name:`user-round-cog`,size:24,node:[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`user-cog-2`]};Gl.node;var Kl=z(Gl),ql={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};ql.node;var Jl=z(ql),Yl={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Yl.node;var Xl=z(Yl),Zl={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Zl.node;var Ql=z(Zl),$l={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};$l.node;var eu=z($l),tu={name:`wallet`,size:24,node:[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]};tu.node;var nu=z(tu),ru={name:`warehouse`,size:24,node:[[`path`,{d:`M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11`,key:`pb2vm6`}],[`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z`,key:`doq5xv`}],[`path`,{d:`M6 13h12`,key:`yf64js`}],[`path`,{d:`M6 17h12`,key:`1jwigz`}]]};ru.node;var iu=z(ru),au={name:`wifi-off`,size:24,node:[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};au.node;var ou=z(au),su={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};su.node;var cu=z(su),lu={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};lu.node;var uu=z(lu),du=F(`primitives`),fu=({className:e,hidden:t=!1})=>(0,L.jsx)(cc,{...t?{"aria-hidden":!0}:{"aria-label":du(`loading`)},className:R(`size-4 animate-spin`,e)}),pu={primary:`bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm`,secondary:`bg-background text-foreground border border-border-strong hover:bg-muted shadow-sm`,ghost:`text-muted-foreground hover:bg-muted hover:text-foreground`,danger:`bg-background text-danger-text border border-border-strong hover:bg-danger-soft shadow-sm`},mu={sm:`h-7 px-2.5 text-body gap-1.5`,md:`h-8 px-3 text-body gap-2`,icon:`size-7 text-body`},hu=({variant:e=`secondary`,size:t=`md`}={})=>R(`inline-flex shrink-0 items-center justify-center rounded-md font-medium transition-colors aria-disabled:cursor-not-allowed aria-disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:opacity-60 disabled:cursor-default`,pu[e],mu[t]),B=({variant:e=`secondary`,size:t=`md`,loading:n,busyLabel:r,className:i,children:a,disabled:o,...s})=>{let c=(0,L.jsxs)(`button`,{type:`button`,disabled:o||n,"aria-busy":n||void 0,className:R(hu({variant:e,size:t}),i),...s,children:[n&&(0,L.jsx)(fu,{hidden:!0,className:`size-3.5`}),n&&r!==void 0?r:a]});return r===void 0?c:(0,L.jsxs)(L.Fragment,{children:[c,(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:n&&r})]})},gu=`data-pb-scroll-locked`,_u=()=>{let{body:e,documentElement:t}=document,n=e.style.overflow,r=t.hasAttribute(gu);return window.innerWidth>t.clientWidth&&t.setAttribute(gu,``),e.style.overflow=`hidden`,()=>{e.style.overflow=n,r||t.removeAttribute(gu)}},vu=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,yu=[],bu=(e,t,n)=>{let r=(0,j.useRef)(n);r.current=n,(0,j.useEffect)(()=>{if(!t||!e.current)return;let n=e.current,i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=_u(),o={};yu.push(o);let s=()=>[...n.querySelectorAll(vu)];(s()[0]??n).focus();let c=e=>{if(yu.at(-1)!==o)return;if(e.key===`Escape`)return r.current();if(e.key!==`Tab`)return;let t=s();if(t.length===0)return e.preventDefault();let i=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===i?(e.preventDefault(),a.focus()):!e.shiftKey&&document.activeElement===a?(e.preventDefault(),i.focus()):n.contains(document.activeElement)||(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{document.removeEventListener(`keydown`,c),yu.splice(yu.indexOf(o),1),a(),i?.focus()}},[t,e])},xu=({title:e,description:t,onClose:n,actions:r,children:i,wide:a=!1,name:o})=>{let s=(0,j.useRef)(null);return bu(s,!0,n),(0,M.createPortal)((0,L.jsx)(`div`,{"data-dialog":o??``,className:`fixed inset-0 z-[90] flex items-center justify-center bg-backdrop/30 p-4 pb-[calc(1rem+var(--pb-safe-bottom))] pl-[calc(1rem+var(--pb-safe-left))] pr-[calc(1rem+var(--pb-safe-right))] pt-[calc(1rem+var(--pb-safe-top))]`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,L.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,className:R(`outline-none max-h-[min(90vh,100%)] w-full overflow-y-auto rounded-lg border bg-background p-4 shadow-pop sm:p-5`,a?`max-w-3xl`:`max-w-md`),children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t}),i&&(0,L.jsx)(`div`,{className:`mt-4`,children:i}),(0,L.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:r})]})}),document.body)},Su=({className:e,style:t})=>(0,L.jsx)(`span`,{"data-placeholder":!0,className:R(`block h-3 rounded bg-muted`,wu,e),style:t}),Cu=`[animation:pb-reveal_1ms_180ms_backwards]`,wu=`[animation:pb-reveal_1ms_180ms_backwards,pb-shimmer_1.4s_180ms_ease-in-out_infinite] motion-reduce:[animation:pb-reveal_1ms_180ms_backwards]`,V=F(`app-shell`),Tu=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Eu=({parts:e,onNavigate:t,trailing:n})=>{let r=e.at(-1),i=r!==void 0&&(typeof r==`string`||!r.above);return(0,L.jsxs)(`nav`,{"aria-label":V(`breadcrumb`),className:`flex min-w-0 items-center gap-1.5`,children:[e.map((r,i)=>{let a=i===e.length-1,{label:o,href:s,loading:c,above:l}=typeof r==`string`?{label:r,href:void 0,loading:!1,above:!1}:r,u=c?(0,L.jsx)(Su,{className:`w-24`}):o,d=a&&!l,f=R(`truncate`,d?`font-semibold max-md:text-mobile-title max-md:font-bold`:`text-muted-foreground`);return(0,L.jsxs)(`span`,{className:R(`min-w-0 items-center gap-1.5`,d?`flex`:`hidden md:flex`),children:[i>0&&(0,L.jsx)(ns,{className:`hidden size-3.5 shrink-0 text-faint-foreground md:block`}),s?(0,L.jsx)(`a`,{href:s,"aria-current":d?`page`:void 0,"aria-label":c?o:void 0,"aria-busy":c||void 0,onClick:e=>{t&&Tu(e)&&(e.preventDefault(),t(s))},className:R(f,`rounded-sm hover:text-foreground hover:underline`),children:u}):(0,L.jsx)(`span`,{className:f,"aria-label":c?o:void 0,"aria-busy":c||void 0,children:u}),d&&n]},`${i}-${o}`)}),!i&&n]})},Du=({to:e,onClick:t,...n})=>{let{href:r,onFollow:i,newTab:a}=e;return(0,L.jsx)(`a`,{href:r,...a&&{target:`_blank`,rel:`noreferrer`},onClick:e=>{t?.(e),i&&!e.defaultPrevented&&Tu(e)&&(e.preventDefault(),i())},...n})},H=F(`app`),Ou=(0,j.createContext)([]),ku=({name:e,children:t})=>{let n=(0,j.useContext)(Ou),r=(0,j.useMemo)(()=>[...n,e],[n,e]);return(0,L.jsx)(Ou.Provider,{value:r,children:t})},Au=()=>(0,j.useContext)(Ou),ju=(e,t,n)=>{let r=new URL(e,`http://local`),i=new URL(t,`http://local`);return r.pathname!==i.pathname||[...n].some(e=>e.params.some(e=>r.searchParams.get(e)!==i.searchParams.get(e)))},Mu=(e,{replace:t=!1,keepScroll:n=!1}={})=>({kind:`link`,full:e,replace:t,keepScroll:n}),Nu=(e,t)=>t(e.full,e.replace,e.keepScroll),Pu=`protobase:page-places`,Fu=50,Iu=e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`number`&&Number.isFinite(e[1])&&e[1]>=0,Lu=e=>ue(()=>{let t=e.getItem(Pu);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(Iu):[]},[]),Ru=e=>{let t=new Map(Lu(e));return{placeOf:e=>t.get(e)??0,save:(e,n)=>{t.delete(e),t.set(e,Math.max(0,Math.round(n)));for(let e of[...t.keys()].slice(0,Math.max(0,t.size-Fu)))t.delete(e)},persist:()=>ue(()=>e.setItem(Pu,JSON.stringify([...t])),void 0)}},zu=3e3,Bu=e=>{let t=0,n=()=>(window.scrollTo({top:e,behavior:`instant`}),t=window.scrollY,t>=e-1);if(n())return()=>{};let r=new ResizeObserver(()=>n()&&a()),i=()=>Math.abs(window.scrollY-t)>1&&a(),a=()=>{r.disconnect(),clearTimeout(o),window.removeEventListener(`scroll`,i)},o=setTimeout(a,zu);return r.observe(document.body),window.addEventListener(`scroll`,i,{passive:!0}),a},Vu=(0,j.createContext)(null),Hu=()=>{let e=(0,j.useContext)(Vu);if(!e)throw Error(`useRouter must be used inside Router`);return e},Uu=()=>`${window.location.pathname}${window.location.search}`,Wu=e=>new URL(e,`http://local`).pathname,Gu=()=>window.history.state??{},Ku=()=>Gu().protobaseIndex??0,qu=()=>Math.random().toString(36).slice(2),Ju=()=>{let e=Gu();if(e.protobaseEntry)return e.protobaseEntry;let t=qu();return window.history.replaceState({...e,protobaseEntry:t},``),t},Yu={getItem:()=>null,setItem:()=>{}},Xu=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,j.useState)(()=>({url:t??Uu(),entry:r?qu():Ju()})),[o]=(0,j.useState)(()=>Ru(r?Yu:ue(()=>window.sessionStorage,void 0)??Yu)),s=(0,j.useRef)(new Map),c=()=>[...s.current.values()].some(e=>e.kind===`input-lost`),l=(0,j.useRef)(i);l.current=i;let u=(0,j.useRef)(new Map);u.current.set(i.entry,i.url);let d=(0,j.useRef)(r?0:Ku()),f=(0,j.useRef)(!1),p=(0,j.useRef)(!1),m=(0,j.useRef)(void 0),h=(0,j.useRef)(!1),[g,_]=(0,j.useState)(),v=(0,j.useCallback)(()=>o.save(l.current.entry,window.scrollY),[o]);(0,j.useLayoutEffect)(()=>Bu(o.placeOf(i.entry)),[o,i.entry]),(0,j.useLayoutEffect)(()=>{if(r)return;window.history.scrollRestoration=`manual`,window.history.replaceState({...Gu(),protobaseIndex:d.current,protobaseEntry:l.current.entry},``);let e=()=>{v(),o.persist()},t=()=>document.visibilityState===`hidden`&&e();window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t);let n=()=>{let e=Ku();if(f.current){f.current=!1,d.current=e,m.current!==void 0&&window.history.go(m.current),m.current=void 0;return}let t=e-d.current;if(!p.current&&s.current.size>0&&ju(l.current.url,Uu(),s.current.values())){f.current=!0,window.history.go(-t),_({kind:`history`,delta:t,inputLost:c()});return}p.current=!1,d.current=e,v(),a({url:Uu(),entry:Ju()})};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t)}},[r,v,o]);let y=(0,j.useCallback)((e,t,n=!1)=>{let i=t?l.current.entry:qu();if(!r){d.current+=+!t;let n=Gu(),r=t?{protobasePrevious:n.protobasePrevious,protobasePreviousEntry:n.protobasePreviousEntry}:{protobasePrevious:l.current.url,protobasePreviousEntry:l.current.entry};window.history[t?`replaceState`:`pushState`]({protobaseIndex:d.current,protobaseEntry:i,...r},``,e)}v(),n&&o.save(i,window.scrollY),u.current.set(i,e),a({url:e,entry:i})},[r,v,o]),b=(0,j.useCallback)((t,n)=>{let r=Mu(`${e}${t}`,n);if(s.current.size>0&&ju(l.current.url,r.full,s.current.values()))return _({...r,inputLost:c()});Nu(r,y)},[e,y]),x=(0,j.useCallback)(t=>{if(r)return!1;let n=Gu(),i=(n.protobasePreviousEntry&&u.current.get(n.protobasePreviousEntry))??n.protobasePrevious;return i!==void 0&&Wu(i)===Wu(`${e}${t}`)},[r,e]),S=(0,j.useCallback)(e=>{if(x(e))return window.history.back();b(e)},[x,b]),C=(0,j.useCallback)((e=`draft-kept`,t=[])=>{let n=Symbol(`guard`);return s.current.set(n,{kind:e,params:t}),()=>void s.current.delete(n)},[]),w=(0,j.useCallback)(()=>{if(s.current.size>0)return _({kind:`reload`,inputLost:c()});window.location.reload()},[]),T=(0,j.useCallback)(()=>h.current,[]),E=(0,j.useCallback)(()=>s.current.size>0,[]),D=()=>{if(g){if(_(void 0),g.kind===`link`)return Nu(g,y);if(g.kind===`reload`)return h.current=!0,window.location.reload();p.current=!0,f.current?m.current=g.delta:window.history.go(g.delta)}},O=(0,j.useMemo)(()=>{let t=new URL(i.url,`http://local`);return{path:t.pathname.slice(e.length)||`/`,params:t.searchParams,basePath:e,entry:i.entry,navigate:b,back:S,backIsHistory:x,registerGuard:C,reload:w,reloadConfirmed:T,holdsChanges:E}},[i,e,b,S,x,C,w,T,E]);return(0,L.jsxs)(Vu.Provider,{value:O,children:[n,g?.kind===`reload`&&(0,L.jsx)(xu,{title:H(`reloadTitle`),description:H(g.inputLost?`reloadInputLost`:`reloadDraftKept`),onClose:()=>_(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>_(void 0),children:H(`keepEditing`)}),(0,L.jsx)(B,{variant:`primary`,onClick:D,children:H(`reload`)})]})}),g&&g.kind!==`reload`&&(0,L.jsx)(xu,{title:H(`leaveTitle`),description:H(g.inputLost?`leaveInputLost`:`leaveDescription`),onClose:()=>_(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>_(void 0),children:H(`stay`)}),(0,L.jsx)(B,{variant:`primary`,onClick:D,children:H(`leave`)})]})})]})},Zu=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Hu();return(0,L.jsx)(Du,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Qu=(e,t=`draft-kept`)=>{let{registerGuard:n,reloadConfirmed:r}=Hu(),i=Au();(0,j.useEffect)(()=>e?n(t,i):void 0,[e,t,i,n]),(0,j.useEffect)(()=>{if(!e)return;let t=e=>{r()||e.preventDefault()};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e,r])},$u=[`always`,`editing`,`reading`],ed=e=>e!==void 0&&!$u.includes(e),U={list:`list`,filter:`filter`,orderBy:`order_by`,display:`display`,filterLayout:`layout`,map:`map`,calendar:`calendar`,timeline:`timeline`,savedSearch:`saved_search`,create:`new`,edit:`edit`,open:`open`,tab:`tab`,standard:`standard`,call:`call`,version:`version`,run:`run`,panel:`panel`,file:`file`,thread:`thread`},td=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],nd=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,rd=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,id=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return rd(n,90)&&rd(r,180)&&rd(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},ad=e=>`${e.scale},${e.day}`,od=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=t.slice(1).map(Number),a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},sd=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&od(i)?{scale:r,day:i}:void 0},cd=e=>{let t=new URLSearchParams;for(let n of td){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(U[n],r)}e.map&&t.set(U.map,nd(e.map)),e.calendar&&t.set(U.calendar,ad(e.calendar)),e.timeline&&t.set(U.timeline,ad(e.timeline));let n=t.toString();return n?`?${n}`:``},ld=e=>{let t=new URLSearchParams;e.edit&&t.set(U.edit,`true`);for(let n of e.open??[])t.append(U.open,n);e.tab&&t.set(U.tab,e.tab),e.standard&&t.set(U.standard,`true`),e.call&&t.set(U.call,e.call),e.version!==void 0&&t.set(U.version,String(e.version)),e.run&&t.set(U.run,e.run),e.panel&&t.set(U.panel,e.panel),e.file&&t.set(U.file,e.file),e.thread&&t.set(U.thread,e.thread);let n=t.toString();return n?`?${n}`:``},ud=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}${e.tab?`/${encodeURIComponent(e.tab)}`:``}${fd(e.params)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${U.create}${fd(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(nr(e.key))}${ld(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${cd(e)}`}},dd=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},fd=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},pd=e=>e!==null&&/^[1-9]\d{0,8}$/.test(e)?Number(e):void 0,md=e=>e===`bar`||e===`panel`?e:void 0,hd=(e,t)=>{let n=new URL(e,`http://app`),r=dd(n.pathname);if(!r||r.length===0||r.length>2)return;let[i,a]=r;if(i===`-`)return;if(t.has(i)){let e=Object.fromEntries([...n.searchParams].filter(([,e])=>e!==``));return{kind:`page`,page:i,...a!==void 0&&{tab:a},...Object.keys(e).length>0&&{params:e}}}if(a===U.create){let e=Object.fromEntries([...n.searchParams].filter(([,e])=>e!==``));return{kind:`create`,resource:i,...Object.keys(e).length>0&&{values:e}}}if(a!==void 0){let e=[...new Set(n.searchParams.getAll(U.open).filter(e=>e!==``))],t=n.searchParams.get(U.tab)||void 0,r=n.searchParams.get(U.standard)===`true`,o=n.searchParams.get(U.call)===`join`,s=pd(n.searchParams.get(U.version)),c=n.searchParams.get(U.run)||void 0,l=n.searchParams.get(U.panel)||void 0,u=n.searchParams.get(U.file)||void 0,d=n.searchParams.get(U.thread)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(U.edit)===`true`&&{edit:!0},...e.length>0&&{open:e},...t&&{tab:t},...r&&{standard:r},...o&&{call:`join`},...s!==void 0&&{version:s},...c&&{run:c},...l&&{panel:l},...u&&{file:u},...d&&{thread:d}}}let o=n.searchParams,s=o.get(U.list)||void 0,c=o.get(U.display)||void 0,l=o.get(U.filter)??void 0,u=o.get(U.orderBy)||void 0,d=md(o.get(U.filterLayout)),f=id(o.get(U.map)),p=sd(o.get(U.calendar),[`month`,`week`]),m=sd(o.get(U.timeline),[`week`,`month`,`quarter`]),h=o.get(U.savedSearch)||void 0;return{kind:`list`,resource:i,...s&&{list:s},...c&&{display:c},...l!==void 0&&{filter:l},...u&&{orderBy:u},...d&&{filterLayout:d},...f&&{map:f},...p&&{calendar:p},...m&&{timeline:m},...h&&{savedSearch:h}}},gd={signature:`sig`},_d=e=>{let t=e.startsWith(`?`)?e.slice(1):e;return new URLSearchParams(t).has(gd.signature)?{oauthQuery:t}:{}},vd=`/-/sign-in`,yd={step:`step`,next:`next`},bd=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],xd=e=>bd.includes(e),Sd=e=>{if(!e?.startsWith(`/`))return;let t=new URL(e,`http://local`);if(t.origin===`http://local`&&t.pathname!==`/-/sign-in`)return`${t.pathname}${t.search}`},Cd=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(yd.step,e);let r=Sd(t);r&&r!==`/`&&n.set(yd.next,r);let i=n.toString();return i?`${vd}?${i}`:vd},wd=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(yd.step),r=Sd(t.get(yd.next));return{step:xd(n)?n:`sign-in`,...r&&{next:r}}},Td=e=>typeof e==`string`?e:e&&bt(e),Ed=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},Dd=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),Od=(e={})=>({filter:Td(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:Ed(e.labels)?.join(`,`),...Dd(e.photos),count:e.count,limit_per:e.limitPer&&`${e.limitPer.field}:${e.limitPer.count}`,etag:e.etag===!1?`false`:void 0}),kd=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``},Ad=e=>e.startsWith(`/`)&&!e.startsWith(`//`),jd=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&Ad(n)},Md=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,Nd=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,Ad(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),Pd=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,jd(n)?Nd(n,t):n])),Fd=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>jd(e)?Nd(e,t):e)])),Id=class extends Error{problem;constructor(e){super(e.detail??e.title),this.problem=e,this.name=`ApiError`}get status(){return this.problem.status}get slug(){return this.problem.type.split(`:`).at(-1)??``}get operation(){return this.problem.operation??this.errors.find(e=>e.operation!==void 0)?.operation}get blockedBy(){return this.problem.blockedBy}get existing(){return this.problem.existing}get errors(){return this.problem.errors??[]}get filterErrors(){return this.slug===`invalid-filter`?this.errors:[]}},Ld=class extends Id{constructor(e){super(e),this.name=`PreconditionFailedError`}},Rd=e=>e instanceof Id,zd=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Bd=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=zd(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Ld(n):new Id(n)},Vd=(e=`/api/v1`)=>e.replace(/\/[^/]*$/,``),Hd=(e={})=>{let t=e.baseUrl??`/api/v1`,n=Vd(t),r=e.fetch??((e,t)=>fetch(e,t));return async({method:i,path:a,query:o=``,body:s,headers:c,accept:l=[],system:u,raw:d,via:f,signal:p,cache:m})=>{let h=async l=>{let h=await e.token?.({refresh:l});return(f??r)(`${u?n:t}${a}${o}`,{method:i,headers:{...s!==void 0&&{"content-type":`application/json`},...h&&{authorization:`Bearer ${h}`},...e.headers?.(),...c},body:d??(s===void 0?void 0:JSON.stringify(s)),...p&&{signal:p},...m&&{cache:m}})},g=await h(!1);g.status===401&&e.token&&(g=await h(!0),g.status===401&&e.onUnauthenticated?.());let _=g.headers.get(`x-meta-version`);if(_&&e.onMetaVersion?.(_),!g.ok&&!l.includes(g.status))throw await Bd(g);return g}},Ud=(e,t)=>{if(!URL.canParse(t))return{link:e,api:t};let n=new URL(t);return{link:new URL(e,n).href,api:`${n.origin}${n.pathname.replace(/\/$/,``)}`}},Wd=(e,t)=>{if(!e.url.startsWith(`/`)&&!/^https?:\/\//i.test(e.url))return e.url;let n=di(e.uri);if(!n)return e.url;let{link:r,api:i}=Ud(e.url,t),a=li(i);return r.startsWith(`${a}/`)?fi(r):fi(ui(a,n.provider,n.path))},Gd=e=>new Headers(e.trim().split(/[\r\n]+/).filter(Boolean).map(e=>{let t=e.indexOf(`:`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),Kd=e=>(t,n={})=>new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(n.method??`GET`,String(t)),new Headers(n.headers).forEach((e,t)=>a.setRequestHeader(t,e)),a.responseType=`blob`,a.upload.onprogress=t=>e(t.loaded,t.lengthComputable?t.total:t.loaded),a.onload=()=>{let e=a.status===204||a.status===304;r(new Response(e?null:a.response,{status:a.status,statusText:a.statusText,headers:Gd(a.getAllResponseHeaders())}))},a.onerror=()=>i(TypeError(`Network request failed`)),a.onabort=()=>i(new DOMException(`The upload was aborted`,`AbortError`)),n.signal?.addEventListener(`abort`,()=>a.abort()),a.send(n.body)}),qd=e=>Math.min(3e4,1e3*2**e),Jd=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Yd=(e,t,n=qd)=>{let r=new AbortController,{signal:i}=r,a,o=0,s=e=>{o=0,a=e.cursor,e.type===`resync`&&t.onResync(),e.type===`changes`&&t.onChanges(e.changes)},c=async()=>{let t=await e({method:`GET`,path:`/live`,query:kd({after:a}),headers:{accept:`text/event-stream`},system:!0,signal:i});if(!t.body)throw Error(`The server answered the live stream without a body`);await Rr(t.body,e=>s(JSON.parse(e)),i)};return(async()=>{for(;!i.aborted;){let e=await c().then(()=>void 0,e=>e);if(i.aborted)return;t.onRetry?.(e),await Jd(n(o++),i)}})(),()=>r.abort()},Xd=e=>{let t=new Set,n,r=e=>{for(let n of[...t])e(n)};return i=>{let a={...i};return t.add(a),n??=e({onChanges:e=>r(t=>t.onChanges(e)),onResync:()=>r(e=>e.onResync()),onRetry:e=>r(t=>t.onRetry?.(e))}),()=>{!t.delete(a)||t.size>0||(n?.(),n=void 0)}}},Zd=new TextEncoder,Qd=new TextDecoder,$d=4,ef=(e,t)=>{let n=Zd.encode(JSON.stringify(e)),r=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=new Uint8Array($d+n.length+r.length);return new DataView(i.buffer).setUint32(0,n.length),i.set(n,$d),i.set(r,$d+n.length),i.buffer},tf=e=>{let t=$d+new DataView(e).getUint32(0);return{...JSON.parse(Qd.decode(new Uint8Array(e,$d,t-$d))),payload:e.slice(t)}},nf=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),rf=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ChannelRefusal`}},af=5e3,of=1,sf=`protobase.channels`,cf=({url:e,token:t,socket:n,retryDelay:r,onOpen:i,onDown:a,onMessage:o})=>{let s,c=!1,l=0,u=0,d,f=0,p,m,h=new Map,g=()=>{for(let{reject:e}of h.values())e(new rf(`disconnected`,`The connection dropped before the server answered`));h.clear()},_=async e=>{let n=await t?.();s===e&&e.readyState===of&&n!==void 0&&n!==d&&(d=n,e.send(JSON.stringify({type:`token`,token:n})))},v=async()=>{let u=await t?.();if(!c||s)return;d=u;let y=n(e(),u===void 0?[sf]:[sf,`bearer.${u}`]);s=y,y.binaryType=`arraybuffer`,y.onopen=()=>{l=0,f=Date.now(),p=setInterval(()=>{if(Date.now()-f>1e4)return y.close();y.send(JSON.stringify({type:`ping`})),_(y)},af),i()},y.onmessage=({data:e})=>{if(f=Date.now(),typeof e!=`string`&&!(e instanceof ArrayBuffer))return;let t=typeof e==`string`?JSON.parse(e):tf(e);if(t.type!==`reply`)return o(t);let n=h.get(t.ref);h.delete(t.ref),t.ok?n?.resolve(t):n?.reject(new rf(t.error.code,t.error.message))},y.onclose=()=>{s===y&&(clearInterval(p),s=void 0,g(),c&&(a(),m=setTimeout(()=>{m=void 0,v()},r(l++))))}},y=(e,t)=>s?.readyState===of&&(s.send(t===void 0?JSON.stringify(e):ef(e,t)),!0);return{start:()=>{c=!0,!s&&m===void 0&&v()},stop:()=>{c=!1,clearTimeout(m),m=void 0,clearInterval(p);let e=s;s=void 0,g(),e?.close(1e3)},request:(e,t)=>new Promise((n,r)=>{let i=String(++u);if(!y({...e,ref:i},t))return r(new rf(`disconnected`,`The connection is down`));h.set(i,{resolve:n,reject:r})}),post:y}},lf=e=>{if(!(e instanceof rf&&e.code===`disconnected`))throw e},uf=()=>new rf(`not-joined`,`The channel is not joined yet`),df=e=>{let t=new Map,n=new Map,r=(e,t)=>{e.status=t;for(let n of e.statusListeners)n(t)},i=(e,t)=>{let n=[...e.presence.values()];for(let r of e.presenceListeners)r(n,t)},a=e=>{t.delete(e),t.size===0&&c.stop()},o=e=>{let i=`${e.resource}/${e.key}`;c.request({type:`join`,resource:e.resource,key:e.key}).then(o=>{if(t.get(i)===e){if(e.holders===0)return c.post({type:`leave`,channel:o.channel}),a(i);e.name=o.channel,n.set(e.name,e),r(e,{state:`joined`}),e.tracked&&c.request({type:`track`,channel:e.name,state:e.tracked.state}).catch(lf)}}).catch(n=>{if(t.get(i)===e&&e.holders===0&&n instanceof rf)return a(i);if(!(n instanceof rf)||n.code===`disconnected`)return lf(n);r(e,{state:`refused`,error:{code:n.code,message:n.message}})})},s=e=>{if(e.type===`pong`||e.type===`reply`||e.type===`error`)return;let t=n.get(e.channel);if(t){if(e.type===`presence`)return t.presence=new Map(e.entries.map(e=>[e.id,e])),i(t);if(e.type===`presence_diff`){for(let n of e.leaves)t.presence.delete(n.id);for(let n of[...e.joins,...e.updates])t.presence.set(n.id,n);return i(t,{joins:e.joins,updates:e.updates,leaves:e.leaves})}if(e.type===`broadcast`){let{event:n,payload:r,user:i,server:a}=e;for(let e of t.eventListeners.get(n)??[])e({event:n,payload:r,user:i,...a&&{server:a}});return}n.delete(e.channel),t.presence.clear(),i(t),r(t,{state:`closed`,error:e.error})}},c=cf({...e,onOpen:()=>{for(let[e,n]of t)n.status.state===`joining`&&(n.holders===0?a(e):o(n))},onDown:()=>{n.clear();for(let e of t.values())e.status.state===`joined`&&r(e,{state:`joining`})},onMessage:s}),l=(e,t)=>{--t.holders,!(t.holders>0)&&(t.tracked=void 0,t.status.state!==`joining`&&(t.name!==void 0&&(n.delete(t.name),c.post({type:`leave`,channel:t.name})),a(e)))},u=(e,t)=>{let n=!1,r=new Set,i=(e,t)=>{e.add(t);let n=()=>{e.delete(t),r.delete(n)};return r.add(n),n},a=()=>t.status.state===`joined`?t.name:void 0;return{status:()=>t.status,onStatus:e=>i(t.statusListeners,e),presence:()=>[...t.presence.values()],onPresence:e=>i(t.presenceListeners,e),track:async e=>{t.tracked={state:e};let n=a();n!==void 0&&await c.request({type:`track`,channel:n,state:e})},untrack:async()=>{t.tracked=void 0;let e=a();e!==void 0&&await c.request({type:`untrack`,channel:e})},send:async(e,t,{self:n,ack:r}={})=>{let i=a();if(i===void 0)throw uf();let o=nf(t)?t:void 0,s={type:`send`,channel:i,event:e,...o===void 0&&{payload:t},...n&&{self:n}};if(r){await c.request({...s,ack:r},o);return}if(!c.post(s,o))throw new rf(`disconnected`,`The connection is down`)},on:(e,n)=>{let r=t.eventListeners.get(e)??new Set;return t.eventListeners.set(e,r),i(r,n)},leave:()=>{if(!n){n=!0;for(let e of[...r])e();l(e,t)}}}};return{channel:(e,n)=>{let r=nr(n),i=`${e}/${r}`,a=t.get(i);if(a)return a.holders+=1,u(i,a);let s={resource:e,key:r,status:{state:`joining`},presence:new Map,holders:1,statusListeners:new Set,presenceListeners:new Set,eventListeners:new Map};return t.set(i,s),c.start(),o(s),u(i,s)}}},ff=({joinRef:e,ref:t,topic:n,event:r,payload:i})=>JSON.stringify([e,t,n,r,i]),pf=e=>{try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},mf=e=>{let t=pf(e);if(!Array.isArray(t)||t.length!==5)return;let[n,r,i,a,o]=t;if(typeof i==`string`&&typeof a==`string`&&typeof o==`object`&&o)return{joinRef:typeof n==`string`?n:null,ref:typeof r==`string`?r:null,topic:i,event:a,payload:o}},hf=e=>{let t=e.response??{};return e.status===`ok`?{ok:!0}:{ok:!1,reason:typeof t.reason==`string`?t.reason:`error`}},gf=class extends Error{reason;constructor(e){super(`The relay refused it: ${e}`),this.reason=e,this.name=`RelayRefusal`}},_f=3e4,vf=1,yf=(e,t)=>`${e.replace(/\/+$/,``)}/websocket?vsn=2.0.0&ticket=${encodeURIComponent(t)}`,bf=({ticket:e,socket:t,retryDelay:n,final:r,onOpen:i,onDown:a,onEnded:o,onFrame:s})=>{let c,l=!1,u=!1,d=!1,f=0,p=0,m,h,g,_=new Map,v=()=>{for(let{reject:e}of _.values())e(new gf(`disconnected`));_.clear()},y=()=>{g=setTimeout(()=>{g=void 0,x()},n(f++))},b=(e,t,n,r,i)=>{let a=String(++p);return e.send(ff({joinRef:i,ref:a,topic:t,event:n,payload:r})),a},x=async()=>{if(!l||c||u)return;u=!0;let n=await e().then(e=>({answer:e}),e=>({error:e}));if(u=!1,!l||c)return;if(`error`in n)return r(n.error)?(l=!1,o(n.error)):y();let p=t(yf(n.answer.url,n.answer.ticket));c=p,p.onopen=()=>{f=0,m=void 0,h=setInterval(()=>{if(m!==void 0)return p.close();m=b(p,`phoenix`,`heartbeat`,{},null)},_f);let e=d;d=!0,i(n.answer.channels,e)},p.onmessage=({data:e})=>{if(typeof e!=`string`)return;let t=mf(e);if(!t)return;if(t.event!==`phx_reply`)return s(t);t.ref===m&&(m=void 0);let n=t.ref===null?void 0:_.get(t.ref);if(!n)return;_.delete(t.ref);let r=hf(t.payload);r.ok?n.resolve():n.reject(new gf(r.reason))},p.onclose=()=>{c===p&&(clearInterval(h),c=void 0,v(),l&&(a(),y()))}};return{start:()=>{l=!0,g===void 0&&x()},stop:()=>{l=!1,d=!1,clearTimeout(g),g=void 0,clearInterval(h);let e=c;c=void 0,v(),e?.close(1e3)},wake:()=>{l&&g!==void 0&&(clearTimeout(g),g=void 0,f=0,x())},request:(e,t,n,r=null)=>new Promise((i,a)=>{if(c?.readyState!==vf)return a(new gf(`disconnected`));_.set(b(c,e,t,n,r),{resolve:i,reject:a})})}},xf=`relay`,Sf=e=>{if(!(e instanceof gf))throw e},Cf=e=>typeof e.kind==`string`&&typeof e.resource==`string`&&typeof e.key==`string`&&typeof e.channel==`string`,wf=e=>typeof e.event==`string`&&typeof e.payload==`object`&&e.payload!==null&&typeof e.from?.user==`string`,Tf=e=>{let t=new Set,n=new Set,r=new Map,i=new Map,a=`connecting`,o=`online`,s=0,c=e=>{for(let n of[...t])e(n)},l=e=>{a=e,c(t=>t.onStatus?.(e))},u=e=>{let t=i.get(e);f.request(e,`phx_join`,t?{viewing:t}:{},String(++s)).then(()=>void n.add(e)).catch(Sf)},d=e=>{if(e.event===`phx_close`||e.event===`phx_error`)return void n.delete(e.topic);if(e.event===`change`){Cf(e.payload)&&c(t=>t.onNotice?.(e.payload));return}if(e.event===`client_event`){wf(e.payload)&&c(t=>t.onEvent?.(e.payload));return}c(t=>t.onPublished?.({channel:e.topic,event:e.event,payload:e.payload}))},f=bf({...e,onOpen:(e,t)=>{n.clear(),f.request(xf,`phx_join`,{},String(++s)).then(()=>{if(n.add(xf),o===`away`)return f.request(xf,`presence`,{status:o})}).catch(Sf);for(let t of new Set([...e,...r.keys()]))u(t);l(`open`),t&&c(e=>e.onResync?.())},onDown:()=>{n.clear(),l(`connecting`)},onEnded:()=>l(`ended`),onFrame:d}),p=e=>{if(!n.has(e))throw new gf(`not_joined`)};return{follow:e=>{let r={...e};return t.add(r),f.start(),()=>{!t.delete(r)||t.size>0||(f.stop(),n.clear(),a=`connecting`)}},status:()=>a,joined:e=>n.has(e),join:e=>(r.set(e,(r.get(e)??0)+1),a===`open`&&!n.has(e)&&u(e),()=>{let t=(r.get(e)??1)-1;t>0?r.set(e,t):r.delete(e)}),send:async(e,t,n)=>{p(e),await f.request(e,t,n)},direct:async(e,t,n)=>{p(xf),await f.request(xf,t,{to:e,payload:n})},view:(e,t)=>{t?i.set(e,t):i.delete(e),n.has(e)&&f.request(e,`interest`,t?{viewing:t}:{}).catch(Sf)},reconnect:()=>f.wake(),presence:e=>{e!==o&&(o=e,n.has(`relay`)&&f.request(xf,`presence`,{status:e}).catch(Sf))}}},Ef=async e=>(await e({method:`POST`,path:`/relay/ticket`,body:{},system:!0,cache:`no-store`})).json(),Df=e=>Rd(e)&&e.status>=400&&e.status<500&&e.status!==408&&e.status!==429,Of=({send:e,socketUrl:t,socket:n})=>({open:async(r,i)=>{let a=`/functions/${encodeURIComponent(r)}`,{token:o,expires_at:s}=await(await e({method:`POST`,path:a,system:!0,body:{target:i}})).json(),c=n(t(oi(a,o)),[]);return c.binaryType=`arraybuffer`,{socket:c,expiresAt:new Date(s)}}}),kf=e=>({register:async t=>(await e({method:`POST`,path:si(``),system:!0,body:t})).json(),remove:async t=>{await e({method:`DELETE`,path:si(``,t),system:!0})}}),Af=e=>({own:async()=>(await(await e({method:`GET`,path:_i(``),system:!0})).json()).status,set:async t=>(await(await e({method:`PUT`,path:_i(``),system:!0,body:t})).json()).status,clear:async()=>{await e({method:`DELETE`,path:_i(``),system:!0})},people:async()=>(await(await e({method:`GET`,path:_i(``,`people`),system:!0})).json()).statuses}),jf=e=>async(t,n)=>(await e({method:`GET`,path:tr(``,t,n),system:!0})).json(),Mf=e=>async()=>(await e({method:`GET`,path:Xn(``),system:!0})).json(),Nf=e=>async t=>(await e({method:`POST`,path:Zn(``,t),system:!0})).json(),Pf=e=>({list:async({cursor:t,limit:n}={})=>{let r=new URLSearchParams({...t!==void 0&&{cursor:t},...n!==void 0&&{limit:String(n)}}),i=r.size>0?`?${r}`:``;return(await e({method:`GET`,path:gi(``),query:i,system:!0})).json()},unread:async()=>(await(await e({method:`GET`,path:gi(``,`unread`),system:!0})).json()).count,markRead:async t=>{await e({method:`POST`,path:gi(``,{read:t}),body:{},system:!0})},markAllRead:async t=>{await e({method:`POST`,path:gi(``,`read`),body:{upTo:t},system:!0})}}),Ff=e=>Math.min(3e4,1e3*2**e),If=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Lf=(e,t,n=Ff)=>({calls:async(n,r)=>(await(await e({method:`GET`,path:t(n,r)})).json()).items,watchCalls:(r,i,a)=>{let o=new AbortController,{signal:s}=o,c=0,l=async()=>{let n=await e({method:`GET`,path:t(r,i),query:`?watch=true`,headers:{accept:`text/event-stream`},signal:s});if(!n.body)throw Error(`The server answered the calls stream without a body`);await Rr(n.body,e=>{c=0,a.onCalls(JSON.parse(e).items)},s)};return(async()=>{for(;!s.aborted;){let e=await l().then(()=>void 0,e=>e);if(s.aborted)return;a.onRetry?.(e),await If(n(c++),s)}})(),()=>o.abort()}}),Rf=e=>({list:async()=>(await(await e({method:`GET`,path:Ei(``),system:!0})).json()).items,decline:async t=>{await e({method:`POST`,path:Ei(``,{decline:t}),system:!0,body:{}})}}),zf=e=>({allowed:async()=>(await(await e({method:`GET`,path:Ci(``,`organization`),system:!0})).json()).allowed,setAllowed:async t=>{await e({method:`PUT`,path:Ci(``,`organization`),system:!0,body:{allowed:t}})}}),Bf=4e3,Vf=e=>typeof e==`string`?e:e.toModel().name,Hf=(e=`/api/v1`,t)=>{let n=new URL(`${e.replace(/\/[^/]*$/,``)}${t}`,globalThis.location?.href);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()},Uf=(e,t)=>`/${Vf(e)}/${nr(t)}`,Wf=(e,t)=>`${Uf(e,t)}:calls`,Gf=(e,t,n)=>({items:e.items.map(e=>Pd(e,n)),nextPageToken:e.next_page_token,totalSizeEstimate:e.total_size_estimate,...e.prev_page_token!==void 0&&{prevPageToken:e.prev_page_token},...e.total_size!==void 0&&{totalSize:e.total_size},...e.labels!==void 0&&{labels:e.labels},...e.photos!==void 0&&{photos:Fd(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),Kf=({created_at:e,...t})=>({...t,createdAt:e}),qf=e=>e.headers.get(`etag`)??``,Jf=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:Pd(r,t),etag:qf(e),...n&&{permissions:n}}},Yf=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:Pd(e.record,t)}:e.op===`reorder`||e.op===`move`?{...e,records:e.records.map(e=>({...e,record:Pd(e.record,t)}))}:e)}),Xf=(e={})=>{let t=Hd(e),n=Md(e.baseUrl),r=async(e,r)=>{let i=Od(r),a=await t({method:`POST`,path:`/${Vf(e)}:search`,body:{...i,fields:r?.fields,labels:Ed(r?.labels)}});return Gf(await a.json(),a,n)},i=async(e,i)=>{let a=kd(Od(i));if(a.length>Bf)return r(e,i);let o=await t({method:`GET`,path:`/${Vf(e)}`,query:a});return Gf(await o.json(),o,n)},a=async(e,r)=>Jf(await t({method:`GET`,path:Uf(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${Vf(e)}`,body:r});return{record:Pd(await i.json(),n),etag:qf(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>Jf(await t({method:`PATCH`,path:Uf(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:Uf(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${Uf(e,r)}:undelete`});return{record:Pd(await i.json(),n),etag:qf(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${Uf(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>Jf(await t({method:`POST`,path:`${Uf(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=kd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${Uf(e,n)}:history`,query:a})).json();return{items:o.items.map(({database_role:e,...t})=>({...t,databaseRole:e})),nextPageToken:o.next_page_token}},p=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=kd({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${Uf(e,n)}:comments`,query:a})).json();return{items:o.items.map(Kf),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>Kf(await(await t({method:`POST`,path:`${Uf(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${Uf(e,n)}:mentionable`,query:kd({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:nr(e),i=e.map(e=>({...e,resource:Vf(e.resource),...`key`in e&&{key:r(e.key)},...e.op===`reorder`&&{keys:e.keys.map(r)},...e.op===`move`&&{after:e.after&&r(e.after),...e.before!==void 0&&{before:e.before&&r(e.before)}}}));return Yf(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${Vf(e)}:facets`,query:kd({field:n,filter:Td(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${Vf(e)}:aggregate`,query:kd({group_by:n.groupBy,filter:Td(n.filter)||void 0,sum:n.sum,average:n.average,maximum:n.maximum,limit:n.limit,label:n.label,granularity:n.granularity,range:n.range,from:n.from,to:n.to,time_zone:n.timeZone,split_by:n.splitBy,split_limit:n.splitLimit,split_label:n.splitLabel})})).json();return{groupBy:r.group_by,granularity:r.granularity,timeZone:r.time_zone,groups:r.groups,...r.split_by!==void 0&&{splitBy:r.split_by,splits:r.splits}}},y=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${Vf(e)}:series`,query:kd({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:Td(n.filter)||void 0})})).json();return{field:r.field,granularity:r.granularity,timeZone:r.time_zone,points:r.points}},b=async(e,n,r={})=>(await t({method:`GET`,path:`/${Vf(e)}:histogram`,query:kd({field:n,buckets:r.buckets,filter:Td(r.filter)||void 0})})).json(),x=async(e,n)=>{let r=await(await t({method:`POST`,path:`/${Vf(e)}:batchAggregates`,body:{facets:(n.facets??[]).map(e=>({...e,filter:Td(e.filter)||void 0})),histograms:(n.histograms??[]).map(e=>({...e,filter:Td(e.filter)||void 0})),series:(n.series??[]).map(({timeZone:e,filter:t,...n})=>({...n,time_zone:e,filter:Td(t)||void 0}))}})).json();return{facets:r.facets.map(e=>e.facets),histograms:r.histograms,series:r.series.map(e=>({field:e.field,granularity:e.granularity,timeZone:e.time_zone,points:e.points}))}},S=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${Vf(e)}:map`,query:kd({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:Td(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:Ed(r.labels)?.join(`,`),...Dd(r.photos)})})).json();return{items:i.items.map(e=>Pd(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:Fd(i.photos,n)}}},C=async(e,r)=>{let i=await t({method:`GET`,path:`/${Vf(e)}:seek`,query:kd({...Od(r),position:r.position})});return Gf(await i.json(),i,n)},w=async(e,{signal:n}={})=>{let r=await t({method:`GET`,path:`/meta`,system:!0,headers:e?{"if-none-match":e}:void 0,accept:[304],...n&&{signal:n}});return r.status===304?{status:`unchanged`}:{status:`modified`,meta:await r.json(),etag:qf(r)}},T=async(e,{method:n,body:r,path:i=``,query:a,headers:o,cache:s}={})=>{let c=await t({method:n??(r===void 0?`GET`:`POST`),path:`/functions/${encodeURIComponent(e)}${i}`,query:a?`?${new URLSearchParams(a)}`:``,body:r,headers:o,system:!0,...s&&{cache:s}});if(c.status===204)return;let l=c.headers.get(`content-type`);return l?.includes(`json`)?c.json():!l||l.startsWith(`text/`)?c.text():c.blob()},E=async(e,n,r,{onProgress:i,signal:a}={})=>{let o=`name`in r&&typeof r.name==`string`?r.name:void 0,s=i&&typeof XMLHttpRequest<`u`?Kd(i):void 0,c=await(await t({method:`POST`,path:`/${Vf(e)}:upload`,query:`?${new URLSearchParams({field:n,...o!==void 0&&{name:o}})}`,raw:r,headers:{"content-type":r.type||`application/octet-stream`},...s&&{via:s},...a&&{signal:a}})).json();return i?.(r.size,r.size),c},D=e=>`/forms/${encodeURIComponent(e)}`,O=async e=>(await t({method:`GET`,path:D(e),system:!0})).json(),k=async e=>(await t({method:`GET`,path:`${D(e)}:challenge`,system:!0})).json(),A=async(e,n,r)=>{await t({method:`POST`,path:D(e),body:{values:n,proof:r},system:!0})},ee=Xd(e=>Yd(t,e)),te=e.webSocket??((e,t)=>new WebSocket(e,t)),{channel:ne}=df({url:()=>Hf(e.baseUrl,`/channels`),...e.token&&{token:()=>e.token({refresh:!1})},socket:te,retryDelay:e=>Math.min(3e4,1e3*2**e)}),re=Tf({ticket:()=>Ef(t),socket:e=>te(e,[]),retryDelay:e=>Math.min(3e4,1e3*2**e),final:Df}),ie=Of({send:t,socketUrl:t=>Hf(e.baseUrl,t),socket:te}),ae=kf(t),oe=Pf(t),{calls:j,watchCalls:M}=Lf(t,Wf),se=Af(t),ce=Mf(t),le=jf(t),ue=Nf(t);return{list:i,search:r,get:a,create:o,update:s,remove:c,undelete:l,generate:d,reveal:u,history:f,comments:p,comment:m,mentionable:h,batchWrite:g,facets:_,aggregate:v,series:y,histogram:b,batchAggregates:x,map:S,seek:C,meta:w,invoke:T,upload:E,form:O,formChallenge:k,submitForm:A,live:ee,channel:ne,relay:re,bridges:ie,devices:ae,notifications:oe,status:se,calls:j,watchCalls:M,rings:Rf(t),callGuests:zf(t),workflowTypes:ce,workflowRunTrace:le,runnerRegistration:ue,functionSocketUrl:(t,n)=>Hf(e.baseUrl,`/functions/${encodeURIComponent(t)}${n?`?${new URLSearchParams(n)}`:``}`),fileReadUrl:(t,n)=>Wd(n,Vd(e.baseUrl))}},Zf=e=>typeof e==`string`?e:e.toModel().name,Qf=(e,t)=>{let n=n=>t(Zf(n))??e;return{list:(e,t)=>n(e).list(e,t),search:(e,t)=>n(e).search(e,t),get:(e,t)=>n(e).get(e,t),create:(e,t)=>n(e).create(e,t),update:(e,t,r,i)=>n(e).update(e,t,r,i),remove:(e,t,r)=>n(e).remove(e,t,r),undelete:(e,t)=>n(e).undelete(e,t),generate:(e,t,r)=>n(e).generate(e,t,r),reveal:(e,t,r)=>n(e).reveal(e,t,r),history:(e,t,r)=>n(e).history(e,t,r),comments:(e,t,r)=>n(e).comments(e,t,r),comment:(e,t,r)=>n(e).comment(e,t,r),mentionable:(e,t,r)=>n(e).mentionable(e,t,r),batchWrite:t=>{let r=[...new Set(t.map(e=>n(e.resource)))];return r.length>1?Promise.reject(Error(`A batch writes to one API, but these writes are for ${[...new Set(t.map(e=>Zf(e.resource)))].join(`, `)}, which different APIs serve`)):(r[0]??e).batchWrite(t)},facets:(e,t,r)=>n(e).facets(e,t,r),aggregate:(e,t)=>n(e).aggregate(e,t),series:(e,t)=>n(e).series(e,t),histogram:(e,t,r)=>n(e).histogram(e,t,r),batchAggregates:(e,t)=>n(e).batchAggregates(e,t),map:(e,t)=>n(e).map(e,t),seek:(e,t)=>n(e).seek(e,t),meta:(t,n)=>e.meta(t,n),fileReadUrl:(e,t)=>n(e).fileReadUrl(e,t),invoke:(t,n)=>e.invoke(t,n),functionSocketUrl:(t,n)=>e.functionSocketUrl(t,n),upload:(e,t,r,i)=>n(e).upload(e,t,r,i),form:t=>e.form(t),formChallenge:t=>e.formChallenge(t),submitForm:(t,n,r)=>e.submitForm(t,n,r),live:t=>e.live(t),channel:(t,n)=>e.channel(t,n),relay:e.relay,bridges:e.bridges,devices:e.devices,notifications:e.notifications,status:e.status,rings:e.rings,callGuests:e.callGuests,calls:(e,t)=>n(e).calls(e,t),watchCalls:(e,t,r)=>n(e).watchCalls(e,t,r),workflowTypes:()=>n(`workflows`).workflowTypes(),workflowRunTrace:(e,t)=>n(`workflow_runs`).workflowRunTrace(e,t),runnerRegistration:e=>n(`workflow_runners`).runnerRegistration(e)}},$f=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),ep=Symbol(`recorded`),tp=[],np=0,rp=0,ip=e=>{if(rp===0)throw Error(`A record block's children are a function of its record only inside a typed layout: layout(), recordLayout() or defineTemplate()`);np+=1;let t=np;tp.push(t);try{return{scope:t,built:e(t)}}finally{tp.pop()}},ap=new WeakMap,op=(e,t)=>{ap.set(e,t)},sp=(e,t)=>{let n=ap.get(e);n!==void 0&&ap.set(t,n)},cp=/^\d+[smhdw]$/,lp=class e{offset;constructor(e){this.offset=e}plus(t){return new e({sign:`+`,duration:up(t)})}minus(t){return new e({sign:`-`,duration:up(t)})}toString(){return this.offset?`now() ${this.offset.sign} ${this.offset.duration}`:`now()`}},up=e=>{if(!cp.test(e))throw Error(`"${e}" is not a duration: write a number and s, m, h, d or w, such as '7d'`);return e},dp=class{text;op;constructor(e,t){this.text=e,this.op=t}and(e){return fp(`and`,this,e)}or(e){return fp(`or`,this,e)}toString(){return this.text}},fp=(e,t,n)=>{let r=t=>t.op===`term`||t.op===e?t.text:`(${t.text})`;return new dp(`${r(t)} ${e.toUpperCase()} ${r(n)}`,e)},pp=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&ep in e,mp=e=>`{{~${e[ep].scope}~${e[ep].path.join(`.`)}}}`,hp=({path:e,scope:t})=>`~~${t}~${e.join(`.`)}~~`,gp=e=>{if(pp(e))return mp(e);if(e instanceof lp)return e.toString();if(e instanceof Date)return JSON.stringify(e.toISOString());if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`||e===null)return String(e);throw Error(`${String(e)} cannot be a filter value: compare with text, a number, true or false, null, now() or a recorded field`)},_p=e=>new dp(e,`term`),vp=e=>({eq:t=>_p(t===null?`isNull(${e})`:`${e} = ${gp(t)}`),ne:t=>_p(t===null?`NOT isNull(${e})`:`${e} != ${gp(t)}`),lt:t=>_p(`${e} < ${gp(t)}`),le:t=>_p(`${e} <= ${gp(t)}`),gt:t=>_p(`${e} > ${gp(t)}`),ge:t=>_p(`${e} >= ${gp(t)}`),in:t=>_p(`in(${e}, ${t.map(gp).join(`, `)})`),contains:t=>_p(`${e}:${gp(t)}`),isNull:()=>_p(`isNull(${e})`)}),yp=new Set(Object.keys(vp(``))),bp=(e=[],t=tp.at(-1)??0)=>new Proxy({},{get:(n,r)=>{if(r===ep)return{path:e,scope:t};if(r===Symbol.toPrimitive||r===`toString`||r===`toJSON`)return()=>mp({[ep]:{path:e,scope:t}});if(typeof r!=`symbol`)return yp.has(r)?vp(hp({path:e,scope:t}))[r]:bp([...e,r],t)},has:(e,t)=>t===ep}),xp=(e=[])=>new Proxy({},{get:(t,n)=>{if(typeof n!=`symbol`)return yp.has(n)&&e.length>0?vp(e.join(`.`))[n]:xp([...e,n])}}),Sp=`Layouts are static data, sent to the browser as JSON: use <Action name="..."> for behaviour, or register a custom component for React code.`,Cp=e=>typeof e==`function`?`a function`:typeof e==`number`?String(e):typeof e!=`object`||!e?`a ${typeof e}`:`a ${e.constructor?.name??`object without prototype`}`,wp=e=>{let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Tp=(e,t)=>{if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(pp(e))return mp(e);if(e instanceof dp||e instanceof lp)return e.toString();if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map((e,n)=>Tp(e,`${t.slice(0,-1)}[${n}]>`));if(typeof e==`object`&&wp(e)){let n=Object.fromEntries(Object.entries(e).flatMap(([e,n])=>n===void 0?[]:[[e,Tp(n,`${t.slice(0,-1)}.${e}>`)]]));return sp(e,n),n}throw Error(`${t} is ${Cp(e)}. ${Sp}`)},Ep=(e,t)=>{if(e==null||typeof e==`boolean`)return[];if(typeof e==`string`)return[e];if(pp(e))return[mp(e)];if(typeof e==`number`&&Number.isFinite(e))return[String(e)];if(Array.isArray(e))return e.flatMap(e=>Ep(e,t));if($f(e))return e.type===`Fragment`&&!e.custom?e.children:[e];throw Error(`${t} has a child that is ${Cp(e)}. ${Sp}`)},Dp=e=>typeof e==`function`&&typeof e.blockName==`string`,Op=[`RecordCard`,`CardRow`,`ReferenceField`,`RecordsIterator`],kp=[`filter`,`edgeFilter`,`animated`,`dashed`,`dotted`],Ap=(e,t)=>{let n={...t};for(let t of kp){let r=n[t];if(typeof r==`function`){let i=r(xp());if(!(i instanceof dp))throw Error(`<${e} ${t}> is an arrow that gives no condition: write (f) => f.status.eq('open'), or the ${t} as AIP-160 text`);n[t]=i.text}else if(typeof r==`object`&&r&&!(r instanceof dp))throw Error(`<${e} ${t}> is an object: write the ${t} as an arrow, (f) => f.status.eq('open'), or as AIP-160 text`)}if(n.sort!==void 0){if(!Array.isArray(n.sort)||!n.sort.every(e=>typeof e==`string`))throw Error(`<${e} sort> takes a list of fields, each with asc or desc if it likes: sort={['next_run_at asc']}`);n.sort=n.sort.join(`, `)}return n},jp=(e,t,n)=>{if(typeof t!=`function`)return{children:Ep(t,n)};if(!Op.includes(e))throw Error(`<${e}> takes elements as children; only ${Op.join(`, `)} take a function of their record`);let{scope:r,built:i}=ip(e=>Ep(t(bp([],e)),n));return{children:i,scope:r}},Mp={Graph:`node`},Np=new Set([`Graph`]),Pp=(e,t,n)=>{let r=`<${e} ${t}>`,i=e=>{let[t]=e;return e.length===1&&typeof t==`object`?t:{type:`Box`,props:{},children:e}};if(typeof n!=`function`)return{value:n===void 0||$f(n)?n:i(Ep(n,r))};let{scope:a,built:o}=ip(e=>Ep(n(bp([],e)),r));return{value:i(o),scope:a}},Fp=(e,t)=>{if(typeof e==`string`)throw Error(`<${e}> is an HTML element, not a layout block: use the blocks from @protobase/layout or a custom component`);if(!Dp(e))throw Error(`<${typeof e==`function`&&e.name?e.name:`unknown`}> is not a layout block. Components in a layout are declared with component('Name') and implemented in the app; ${Sp}`);let n=e.blockName,{children:r,...i}=t,a=!e.custom&&Np.has(n),{fallback:o,...s}=i,c=a?s:i,l=e.custom?c:Ap(n,c),u=e.custom?void 0:Mp[n],d=u===void 0?void 0:Pp(n,u,l[u]);u!==void 0&&(l[u]=d.value);let f=e.custom?{children:Ep(r,`<${n}>`)}:jp(n,r,`<${n}>`),p={type:n,props:Object.fromEntries(Object.entries(l).flatMap(([e,t])=>t===void 0?[]:[[e,Tp(t,`<${n} ${e}>`)]])),children:f.children},m=f.scope??d?.scope;return m!==void 0&&op(p,m),e.custom&&(p.custom=!0),e.fallback&&(p.fallback=e.fallback),a&&o!==void 0&&(p.fallback=Ep(o,`<${n} fallback>`)),e.reads&&(p.reads=e.reads),p},Ip=(e,t,n,r)=>{let i=Object.assign(e=>Fp(i,e),{blockName:e,custom:t,...n&&{fallback:n},...r&&{reads:r}});return i},Lp=e=>Ip(e,!1),Rp=e=>Lp(e);Rp(`ReferenceManyField`),Rp(`ReferenceArrayField`),Lp(`ArrayField`),Rp(`RecordsIterator`),Rp(`ReferenceField`);var zp=e=>`${e} desc`,Bp=new Set([`Table`,`Timeline`,`Graph`]),Vp=e=>e===`Graph`?`nodes`:`resource`,Hp=e=>Array.isArray(e)?e:[e],Up=e=>typeof e==`string`?e:void 0,Wp=e=>{if(!e.custom){let t=Bp.has(e.type)?Up(e.props.select):void 0;return t===void 0?void 0:{param:t,resource:Up(e.props[Vp(e.type)])}}let t=e.reads&&Hp(e.reads).find(e=>e.select!==void 0),n=t&&Up(e.props[t.select]);return n===void 0?void 0:{param:n,resource:Up(e.props[t.resource])}},Gp={stack:[]},Kp=e=>typeof e==`string`?e:void 0,qp=(e,t)=>({stack:[...e.stack,t],...e.root!==void 0&&{root:e.root}}),Jp=(e,t)=>({...e,list:t}),Yp=(e,t)=>{let n=Qp(e),r=Wp(e);if(r)return qp(t,{resource:r.resource,repeated:!1,block:n});if(e.custom)return t;switch(e.type){case`RecordCard`:case`CardRow`:return qp(t,{resource:Kp(e.props.resource),repeated:e.type===`CardRow`,block:n});case`ReferenceField`:return qp(t,{resource:Kp(e.props.reference),repeated:!1,block:n});case`ReferenceManyField`:case`ReferenceArrayField`:return Jp(t,{resource:Kp(e.props.reference),items:!1,block:n});case`ArrayField`:return Jp(t,{items:!0,block:n});case`RecordsIterator`:return t.list?qp(t,{...t.list.resource!==void 0&&{resource:t.list.resource},repeated:!0,...t.list.items&&{item:!0},block:t.list.block}):t;default:return t}},Xp=(e,t)=>e.custom?t:e.type===`RecordCard`?Yp(e,t):e.type===`Graph`?qp(t,{resource:Kp(e.props.nodes),repeated:!0,block:Qp(e)}):t,Zp=e=>!e.custom&&e.type===`Graph`?[`nodes`]:[`resource`,`reference`,`name`,`source`],Qp=e=>`<${e.type}${Zp(e).map(t=>typeof e.props[t]==`string`?` ${t}="${e.props[t]}"`:``).join(``)}>`,$p=e=>$f(e)||Array.isArray(e)&&e.length>0&&e.every($f),em=(e,t,n={path:Qp(e),scope:Gp})=>{let r=Yp(e,n.scope),i=Xp(e,n.scope),a=e.children.flatMap(e=>{if(typeof e==`string`)return[e];let i=em(e,t,{path:`${n.path} › ${Qp(e)}`,scope:r});return i?[i]:[]}),o=Object.fromEntries(Object.entries(e.props).flatMap(([e,r])=>{if(!$p(r))return[[e,r]];let a=(Array.isArray(r)?r:[r]).flatMap(r=>em(r,t,{path:`${n.path} ${e}={${Qp(r)}}`,scope:i})??[]);return a.length===0?[]:[[e,Array.isArray(r)?a:a[0]]]})),s=e.fallback?.flatMap(e=>{if(typeof e==`string`)return[e];let r=em(e,t,{path:`${n.path} fallback={${Qp(e)}}`,scope:n.scope});return r?[r]:[]});return t({...e,props:o,children:a,...s&&{fallback:s}},n)},tm=(e,t,n={path:Qp(e),scope:Gp})=>{t(e,n);let r=Yp(e,n.scope),i=Xp(e,n.scope);for(let i of e.children)typeof i!=`string`&&tm(i,t,{path:`${n.path} › ${Qp(i)}`,scope:r});for(let[r,a]of Object.entries(e.props))if($p(a))for(let e of Array.isArray(a)?a:[a])tm(e,t,{path:`${n.path} ${r}={${Qp(e)}}`,scope:i});for(let r of e.fallback??[])typeof r!=`string`&&tm(r,t,{path:`${n.path} fallback={${Qp(r)}}`,scope:n.scope})};Ip(`SelectInput`,!1);var nm=e=>{let t=new Map;return tm(e,e=>{e.custom||e.type!==`SelectInput`||typeof e.props.source!=`string`||t.has(e.props.source)||t.set(e.props.source,e.props)}),t},rm=(e,t)=>t!==void 0&&t!==``&&(e.choices===void 0||e.choices.some(e=>String(e.id)===t))?t:e.defaultValue===void 0?void 0:String(e.defaultValue),im=(e,t={})=>{let n={};for(let[r,i]of nm(e)){let e=rm(i,Object.hasOwn(t,r)?t[r]:void 0);e!==void 0&&(n[r]=e)}return n},W=e=>({kind:e}),G=e=>({kind:e,required:!0}),am={title:W(`shown`),description:W(`shown`),actions:W(`elements`)},om={resource:G(`text`),filter:W(`text`),sort:W(`text`)},sm={resource:`resource`,filter:`filter`,sort:`sort`},cm={sort:W(`sort`),filter:W(`filter`),perPage:W(`integer`)},lm={source:G(`text`),emptyText:W(`text`)},um={locales:W(`locales`),options:W(`intlOptions`)},dm={Page:{children:!0,props:{title:G(`shown`),description:W(`shown`),actions:W(`elements`),width:W(`pageWidth`)}},Grid:{children:!0,props:{columns:W(`columns`),span:W(`span`)}},Card:{children:!0,props:{...am,span:W(`span`)}},Stat:{children:!1,props:{label:G(`shown`),value:W(`scalar`),resource:W(`text`),filter:W(`text`),field:W(`text`),format:W(`format`),description:W(`shown`),span:W(`span`)},reads:{resource:`resource`,filter:`filter`}},RecordCard:{children:!0,props:{...om,...am,recordKey:W(`text`),empty:W(`shown`),span:W(`span`)},reads:sm},Field:{children:!1,props:{source:G(`text`),label:W(`label`),format:W(`format`)}},Diff:{children:!1,props:lm},Table:{children:!0,reads:sm,props:{...om,resource:W(`text`),...am,columns:W(`tableColumns`),button:W(`rowButton`),bulk:W(`boolean`),limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`),select:W(`text`)}},SelectInput:{children:!1,props:{source:G(`text`),choices:W(`choices`),label:W(`shown`),defaultValue:W(`scalar`)}},CardRow:{children:!0,props:{...om,...am,limit:W(`integer`),empty:W(`shown`),span:W(`span`)},reads:sm},RecordRow:{children:!1,props:{...om,...am,limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`)},reads:sm},RecordCards:{children:!1,reads:{...sm,fields:`fields`},props:{...om,...am,layout:W(`cardsLayout`),cardWidth:W(`cardWidth`),fields:W(`texts`),cardActions:W(`texts`),limit:W(`integer`),display:W(`text`),empty:W(`shown`),span:W(`span`)}},Chart:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...am,resource:G(`text`),filter:W(`text`),groupBy:G(`text`),splitBy:W(`text`),type:W(`chartType`),sum:W(`text`),average:W(`text`),granularity:W(`bucket`),range:W(`range`),limit:W(`integer`),empty:W(`shown`),span:W(`span`)}},Timeline:{children:!0,reads:{resource:`resource`,filter:`filter`},props:{...am,resource:G(`text`),filter:W(`text`),lane:G(`text`),bar:G(`text`),start:G(`text`),end:G(`text`),color:G(`text`),limit:W(`integer`),empty:W(`shown`),span:W(`span`),select:W(`text`)}},Graph:{children:!0,reads:[{resource:`nodes`,filter:`filter`,fields:[`label`,`group`,`status`,`x`,`y`],select:`select`},{resource:`edges`,filter:`edgeFilter`,fields:[`source`,`target`,`edgeLabel`,`edgeStatus`]}],props:{nodes:G(`text`),edges:G(`text`),source:G(`text`),target:G(`text`),label:G(`text`),group:W(`text`),status:W(`text`),node:W(`elements`),filter:W(`text`),edgeFilter:W(`text`),edgeLabel:W(`text`),edgeStatus:W(`text`),animated:W(`text`),dashed:W(`text`),dotted:W(`text`),layout:W(`graphLayout`),direction:W(`graphDirection`),x:W(`text`),y:W(`text`),select:W(`text`),empty:W(`shown`)}},Progress:{children:!1,props:{value:G(`amount`),max:W(`amount`),label:W(`shown`),span:W(`span`)}},ModalForm:{children:!1,props:{mode:G(`mode`),label:G(`shown`),fields:G(`texts`),resource:W(`text`),recordKey:W(`text`),title:W(`shown`),values:W(`values`),variant:W(`variant`)}},Thread:{children:!1,reads:{resource:`resource`,filter:`filter`},props:{...am,resource:G(`text`),filter:W(`text`),sender:W(`text`),time:G(`text`),text:G(`text`),status:W(`text`),working:W(`text`),calls:W(`toolCalls`),limit:W(`integer`),empty:W(`shown`),span:W(`span`)}},Composer:{children:!1,props:{resource:G(`text`),field:G(`text`),values:W(`values`),placeholder:W(`text`),span:W(`span`)}},Image:{children:!1,props:{function:W(`text`),src:W(`text`),alt:W(`text`),width:W(`integer`),height:W(`integer`),refresh:W(`integer`)}},Action:{children:!1,props:{name:G(`text`),resource:W(`text`),label:W(`shown`),variant:W(`variant`)}},ReferenceManyField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{reference:G(`text`),target:G(`text`),source:W(`text`),...cm,empty:W(`shown`),pagination:W(`pagination`)}},ReferenceArrayField:{children:!0,reads:{resource:`reference`,filter:`filter`,sort:`sort`},props:{source:G(`text`),reference:G(`text`),...cm,empty:W(`shown`)}},ArrayField:{children:!0,props:{source:G(`text`)}},RecordsIterator:{children:!0,props:{}},ReferenceField:{children:!0,reads:{resource:`reference`},props:{source:G(`text`),reference:G(`text`),link:W(`referenceLink`),empty:W(`shown`)}},Show:{children:!0,props:{when:G(`text`),fallback:W(`content`)}},Switch:{children:!0,props:{fallback:W(`content`)}},Match:{children:!0,props:{when:G(`text`)}},Link:{children:!0,props:{href:W(`text`),to:W(`address`),variant:W(`variant`)}},Tabs:{children:!0,props:{}},Tab:{children:!0,props:{name:G(`text`),label:G(`shown`)}},Settings:{children:!1,props:{resource:G(`text`),fields:W(`texts`),title:W(`shown`),description:W(`shown`),span:W(`span`)}},Users:{children:!1,props:{}},Profile:{children:!1,props:{}},Password:{children:!1,props:{}},Passkeys:{children:!1,props:{}},TwoFactor:{children:!1,props:{}},ConnectedAccounts:{children:!1,props:{}},PersonalMail:{children:!1,props:{}},Connections:{children:!1,props:{}},Devices:{children:!1,props:{}},ConnectedApps:{children:!1,props:{}},PersonalAccessTokens:{children:!1,props:{}},DeleteAccount:{children:!1,props:{}},Box:{children:!0,props:{}},Email:{children:!0,props:{}},Button:{children:!0,props:{href:G(`text`)}},Divider:{children:!1,props:{}},Row:{children:!0,props:{}},Column:{children:!0,props:{}},Text:{children:!0,props:{as:W(`textAs`)}},Trans:{children:!1,props:{i18nKey:G(`text`),values:W(`transValues`),components:W(`transComponents`)}},Details:{children:!0,props:{open:W(`boolean`)}},Summary:{children:!0,props:{}},TextField:{children:!1,props:lm},NumberField:{children:!1,props:{...lm,...um}},DateField:{children:!1,props:{...lm,...um,showDate:W(`boolean`),showTime:W(`boolean`),format:W(`dateFormat`)}},BooleanField:{children:!1,props:{...lm,valueLabelTrue:W(`text`),valueLabelFalse:W(`text`)}},UrlField:{children:!1,props:{...lm,content:W(`text`)}},ChipField:{children:!1,props:lm}},fm=Object.fromEntries(Object.entries(dm).map(([e,t])=>[e,{...t,props:{...t.props,className:W(`text`)}}])),pm=[`relative`,`absolute`,`compact`,`percent`,`badge`,`code`],mm=[`primary`,`secondary`,`danger`,`ghost`],hm=[`bar`,`line`,`donut`],gm=[`hour`,`day`,`week`,`month`,`year`],_m=[`7d`,`30d`,`90d`,`1y`,`all`],vm=[`stack`,`carousel`],ym=[`1/4`,`1/3`,`1/2`,`2/3`],bm=[`column`,`full`],xm=[`p`,`span`,`strong`,`em`,`h1`,`h2`,`h3`,`h4`],Sm=e=>[t=>typeof t==`string`&&e.includes(t),e.join(`, `)];pm.join(`, `),mm.join(`, `),Sm(hm),Sm(gm),Sm(_m),Sm(vm),Sm(ym),Sm(bm),Sm(xm),Sm([`relative`]),Sm([`layered`,`force`]),Sm([`down`,`right`]);var Cm=e=>`${e} desc`,wm=/(["'])\{\{\s*([^{}]*?)\s*\}\}\1|\{\{\s*([^{}]*?)\s*\}\}/g,Tm=e=>{let t=[],n=``,r=0;for(let i of e.matchAll(wm)){n+=e.slice(r,i.index);let a=i[1]!==void 0;t.push({path:a?i[2]:i[3],start:n.length,quoted:a}),n+=a?`${i[1]}x${i[1]}`:`0`,r=i.index+i[0].length}return{text:n+e.slice(r),slots:t}},Em=(e,t,n)=>{let r=[],i=e[t],a=n.split(`.`);for(let[o,s]of a.entries()){if(!i)return{ok:!1,message:`unknown resource "${t}"`};let c=Object.hasOwn(i.fields,s)?i.fields[s]:void 0;if(!c)return{ok:!1,message:`unknown field "${a.slice(0,o+1).join(`.`)}" on ${i.name}`};if(r.push({model:i,field:c}),o===a.length-1)break;if(c.type!==`relation`||!c.relation)return{ok:!1,message:`"${a.slice(0,o+1).join(`.`)}" is not a relation, so "${n}" cannot go through it`};t=c.relation.resource,i=e[t]}return{ok:!0,steps:r}},Dm=e=>`${String(e.props.start)} asc`,Om=e=>`${String(e.props.start)} desc`,km=2e4,Am=e=>typeof e==`object`&&!!e&&e.kind===`member`,jm=e=>Am(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(jm),Mm=e=>Am(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(Mm):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Mm(t)])),Nm=new Set([`string`,`number`,`boolean`,`duration`,`timestamp`]),Pm=e=>Nm.has(e.kind),Fm=e=>{let[t,...n]=e.args;if(t&&Am(t)){if(e.name===`isNull`&&n.length===0)return{kind:`not`,arg:{kind:`present`,left:t,span:e.span},span:e.span};if(e.name===`in`&&n.length!==0&&n.every(Pm))return{kind:`or`,args:n.map(n=>({kind:`compare`,op:`=`,left:t,right:n,span:e.span})),span:e.span}}},Im=e=>Array.isArray(e)?e.map(Im):typeof e!=`object`||!e?e:(e.kind===`call`?Fm(e):void 0)||Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Im(t)])),Lm=new Set([`isNull`,`in`,`now`]),Rm=e=>Array.isArray(e)?e.flatMap(Rm):typeof e!=`object`||!e?[]:[...e.kind===`call`?[e.name]:[],...Object.values(e).flatMap(Rm)],zm={extensions:{arithmetic:`now-offset`,durationUnits:!0}},Bm=e=>{let t=C(e,zm);if(!t.ok)return{ok:!1,message:t.errors.map(e=>e.message).join(`; `)};if(!t.ast)return{ok:!1,message:`the condition is empty`};let n=Rm(t.ast).find(e=>!Lm.has(e));return n===void 0?{ok:!0,ast:t.ast,paths:[...new Set(jm(t.ast))]}:{ok:!1,message:`${n}() only works in a list's filter, which the API reads; a condition can call isNull(), in() and now()`}},Vm={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5},Hm=(e,t)=>{if(Array.isArray(e))return e.map(e=>Hm(e,t));if(typeof e!=`object`||!e)return e;let n=e;if(n.kind===`call`&&n.name===`now`)return{kind:`string`,value:new Date(t).toISOString()};if(n.kind===`binary`&&n.left?.kind===`call`&&n.left.name===`now`&&n.right?.kind===`duration`){let e=(n.right.amount??0)*Vm[n.right.unit??`s`];return{kind:`string`,value:new Date(n.op===`-`?t-e:t+e).toISOString()}}return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Hm(n,t)]))},Um=(e,t,n=Date.now())=>e.ast!==void 0&&o(Mm(Im(Hm(e.ast,n))),t),Wm=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},Gm=[`animated`,`dashed`,`dotted`],Km=e=>Bm(Tm(e).text),qm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Jm=e=>typeof e==`number`||typeof e==`boolean`?String(e):`"${String(e).replace(/\\/g,`\\\\`).replaceAll(`"`,`\\"`)}"`,Ym=e=>{if(typeof e==`string`)return e;if(qm(e))return e.order===`DESC`?`${e.field} desc`:String(e.field)},Xm=e=>{if(typeof e==`string`)return e;if(!qm(e))return;let t=Object.entries(e).map(([e,t])=>t===null?`isNull(${e})`:`${e} = ${Jm(t)}`);return t.length===0?void 0:t.join(` AND `)},Zm=(...e)=>{let t=e.filter(e=>e!==void 0&&e.trim()!==``);return t.length<=1?t[0]:t.map(e=>`(${e})`).join(` AND `)},Qm=(e,t,n)=>t==null?void 0:Zm(`${e} = ${Jm(t)}`,Xm(n)),$m=(e,t,n)=>{let r=Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):[];return r.length===0?void 0:Zm(`in(${e}, ${r.map(Jm).join(`, `)})`,Xm(n))},eh=(e,t,n)=>({filter:Qm(e.target,n(e.source??`this.id`),e.filter),sort:Ym(e.sort)??zp(t),perPage:e.perPage??25}),th=(e,t,n)=>({filter:$m(t,n(e.source),e.filter),sort:Ym(e.sort)??zp(t),perPage:e.perPage??500}),nh=e=>e.part===void 0?e.block:`${e.block}#${e.part}`,rh=e=>typeof e==`string`?e:e.name,ih=e=>typeof e==`string`?void 0:e.priority,ah=({title:e,badge:t})=>e?0:t?1:2,oh=(e,t)=>e.map((e,n)=>({name:rh(e),given:ih(e),derived:ah(t(rh(e))),index:n})).sort((e,t)=>e.given!==void 0&&t.given!==void 0?e.given-t.given||e.index-t.index:e.given===void 0?t.given===void 0?e.derived-t.derived||e.index-t.index:1:-1).map(({name:e})=>e),sh=(e,t)=>{let n=e.filter(e=>ih(e)!==void 0),r=n.length>0?n:e,i=new Set(oh(r,t).slice(0,3));return e.map(rh).filter(e=>i.has(e))},ch=e=>{let t=e.custom?e.reads:fm[e.type]?.reads;return t?Array.isArray(t)?t.map(e=>({reads:e,part:e.resource})):[{reads:t}]:[]},lh=(e,t)=>{if(t===``)return e;let n=e;for(let e of t.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(typeof n!=`object`||!n||!Object.hasOwn(n,t))return;n=n[t]}return $f(n)?n:void 0},uh=(e,...t)=>e+t.map(e=>`/${String(e).replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`).join(``),dh=e=>typeof e==`object`&&!!e,fh=(e,t)=>t.reduce((e,t)=>dh(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),ph=(e,t)=>{let n=Rt(t);if(!n)return;if(n.kind===`data`){if(n.variable===`root`)return e.root===void 0?void 0:fh(e.root,n.names);if(n.variable===`params`)return e.params&&Object.hasOwn(e.params,n.names[0])?e.params[n.names[0]]:void 0;let t=e.stack.findLast(e=>e.row!==void 0)?.row;return t?n.variable===`index`?t.index:n.variable===`first`?t.index===0:t.index===t.count-1:void 0}let r=[...e.root===void 0?[]:[e.root],...e.stack.map(e=>e.record)];if(n.explicit){let e=r[r.length-1-n.up];return e===void 0?void 0:fh(e,n.names)}let[i,...a]=n.names,o=r.findLast(e=>dh(e)&&Object.hasOwn(e,i));return dh(o)?fh(o[i],a):void 0},mh=e=>t=>ph(e,t),hh=e=>e===void 0?null:typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null?e:Zt(e),gh=(e,t)=>Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=typeof n==`string`?Vt(n):void 0;return[e,r===void 0?yh(n,t):hh(t(r))]})),_h=[`title`,`description`,`empty`,`label`,`recordKey`],vh=[`filter`,`when`,`working`,`edgeFilter`,`animated`,`dashed`,`dotted`],yh=(e,t)=>typeof e==`string`?Xt(e,e=>Zt(t(e))):Array.isArray(e)?e.map(e=>yh(e,t)):dh(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,yh(n,t)])):e,bh=(e,t)=>{if(e.custom||!JSON.stringify(e.props).includes(`{{`))return e;let n=mh(t),r={...e.props};for(let e of _h)typeof r[e]==`string`&&(r[e]=Xt(r[e],e=>Zt(n(e))));for(let e of _h){let n=r[e];$f(n)&&n.type===`Trans`&&(r[e]=bh(n,t))}for(let e of vh)typeof r[e]==`string`&&(r[e]=nn(r[e],n));return dh(r.filter)&&(r.filter=gh(r.filter,n)),r.values!==void 0&&(r.values=yh(r.values,n)),dh(r.calls)&&typeof r.calls.filter==`string`&&(r.calls={...r.calls,filter:nn(r.calls.filter,n)}),{...e,props:r}},xh=(e,t)=>{if(!e.custom||!e.reads)return e;let n=mh(t),r={...e.props},i=new Set(Hp(e.reads).flatMap(({filter:e})=>e===void 0?[]:[e]));for(let t of i){let i=e.props[t];typeof i==`string`?r[t]=nn(i,n):dh(i)&&(r[t]=gh(i,n))}return{...e,props:r}},Sh=new Set([1,2,3,4,5,6]),Ch=8,wh=(e,t)=>{for(let n of e){Sh.has(n.type)&&n.value!==void 0&&t.values.add(n.value),n.type===Ch&&n.value!==void 0&&t.tags.add(n.value);for(let e of Object.values(n.options??{}))wh(e.value,t);n.children&&wh(n.children,t)}},Th=(e,t)=>{let n={values:new Set,tags:new Set};return wh(new ie(e,t).getAst(),n),{values:[...n.values],tags:[...n.tags]}},Eh=new Map,Dh=(e,t,n={},r={})=>{let i=e?.messages[t];if(i===void 0||!e)return t;let a=`${e.locale}\u0000${i}`,o=Eh.get(a);return o||(o=new ie(i,e.locale),Eh.set(a,o)),o.format({...n,...r})},Oh=(e,t,n={})=>{let r=Dh(e,t,n,Object.fromEntries((e?.messages[t]?Th(e.messages[t],e.locale).tags:[]).map(e=>[e,e=>e.join(``)])));return Array.isArray(r)?r.join(``):r};Ip(`Trans`,!1);var kh=e=>$f(e)&&e.type===`Trans`&&!e.custom,Ah=(e,t)=>e.filter===void 0?e:{...e,filter:nn(e.filter,mh({stack:[],...t}))},jh=(e,t)=>{let n=new Map(t.reads.map(e=>[nh(e),e])),r=[e.resource];for(let t=e.split&&n.get(e.split.parent);t;t=t.split&&n.get(t.split.parent))r.push(t.resource);return r},Mh=(e,t,n)=>{if(!e.split)return t;let r=ph(n,e.split.source);if(r==null||r===``)return[];let i=e.kind===`aggregate`?`value`:e.split.field,a=new Set((Array.isArray(r)?r:[r]).map(String));return t.filter(e=>a.has(String(e[i])))},Nh=(e,t)=>({...e,fields:Object.fromEntries(Object.entries(e.fields).map(([e,n])=>{if(!n.relation||Object.hasOwn(t,n.relation.resource))return[e,n];let{relation:r,...i}=n;return[e,i]}))}),Ph=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>Ph(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>Ph(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind!==`related`)return[e];if(!Object.hasOwn(t,e.resource)||e.through&&!Object.hasOwn(t,e.through.resource))return[];let{columns:n,button:r,...i}=e,a=n?.filter(n=>Em(t,e.resource,n).ok),o=a&&a.length>0?{...i,columns:a}:i,s=r===void 0?void 0:Mr(r,t[e.resource],{models:t,pages:new Set});return[s===void 0?o:{...o,button:s}]},Fh=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||Sr(e.run.to,{models:n,pages:new Set,source:t}).length===0,Ih=(e,t)=>({...e,layout:e.layout.flatMap(e=>Ph(e,t)),actions:e.actions.filter(n=>Fh(n,t[e.resource],t))}),Lh=(e,t)=>{let n=e.resources.filter(e=>t.resources.includes(e.name)),r=Object.fromEntries(n.map(e=>[e.name,e])),i=n.map(e=>Nh(e,r)),a=Object.fromEntries(i.map(e=>[e.name,e]));return{resources:i,views:e.views.filter(e=>Object.hasOwn(a,e.resource)).map(e=>Ih(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},Rh=class extends TypeError{constructor(e){super(`The server could not be reached`,e),this.name=`NetworkError`}},zh=e=>async(t,n)=>{try{return await e(t,n)}catch(e){throw e instanceof TypeError?new Rh({cause:e}):e}},K=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},q=(e,t)=>new K(e?.message||t,e?.status??500,e?.code),Bh=e=>new Date(e).toISOString(),Vh=e=>({updateName:async t=>{let{error:n}=await e.updateUser({name:t});if(n)throw q(n,`Could not change your name`)},changePassword:async(t,n)=>{let{error:r}=await e.changePassword({currentPassword:t,newPassword:n,revokeOtherSessions:!0});if(r)throw q(r,`Could not change your password`)},setPassword:async t=>{let{error:n}=await e.$fetch(`/account/set-password`,{method:`POST`,body:{newPassword:t}});if(n)throw q(n,`Could not set your password`)},requestEmailChange:async t=>{let{error:n}=await e.$fetch(`/email-otp/request-email-change`,{method:`POST`,body:{newEmail:t}});if(n)throw q(n,`Could not send the code`)},changeEmail:async(t,n)=>{let{error:r}=await e.$fetch(`/email-otp/change-email`,{method:`POST`,body:{newEmail:t,otp:n}});if(r)throw q(r,`Could not change your address`)},sessions:async()=>{let[t,n]=await Promise.all([e.listSessions(),e.getSession()]);if(t.error||!t.data)throw q(t.error,`Could not read your devices`);let r=n.data?.session.token;return t.data.map(e=>{let t=e.impersonatedBy;return{token:e.token,current:e.token===r,...e.userAgent&&{userAgent:e.userAgent},...e.ipAddress&&{ipAddress:e.ipAddress},createdAt:Bh(e.createdAt),updatedAt:Bh(e.updatedAt),expiresAt:Bh(e.expiresAt),...t&&{staff:t}}})},revokeSession:async t=>{let{error:n}=await e.revokeSession({token:t});if(n)throw q(n,`Could not sign out the device`)},revokeOtherSessions:async()=>{let{error:t}=await e.revokeOtherSessions();if(t)throw q(t,`Could not sign out your other devices`)},deviceLinks:async()=>{let{data:t,error:n}=await e.$fetch(`/account/device-links`,{method:`GET`});if(n||!t)throw q(n,`Could not read your devices`);return t.links},signOutDeviceLink:async t=>{let{error:n}=await e.$fetch(`/account/device-links/sign-out`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not sign out the device`)}}),Hh=e=>({signInMethods:async()=>{let{data:t,error:n}=await e.$fetch(`/account/sign-in-methods`);if(n||!t)throw q(n,`Could not read your sign-in methods`);return t},passkeys:async()=>{let{data:t,error:n}=await e.passkey.listUserPasskeys();if(n||!t)throw q(n,`Could not read your passkeys`);return t.map(e=>({id:e.id,backedUp:e.backedUp,...e.name&&{name:e.name},...e.createdAt&&{createdAt:new Date(e.createdAt).toISOString()}}))},addPasskey:async t=>{let{error:n}=await e.passkey.addPasskey(t?{name:t}:{});if(n)throw q(n,`Could not add the passkey`)},renamePasskey:async(t,n)=>{let{error:r}=await e.passkey.updatePasskey({id:t,name:n});if(r)throw q(r,`Could not rename the passkey`)},removePasskey:async t=>{let{error:n}=await e.passkey.deletePasskey({id:t});if(n)throw q(n,`Could not remove the passkey`)},startAuthenticatorApp:async t=>{let{data:n,error:r}=await e.twoFactor.enable({method:`totp`,...t&&{password:t}});if(r||n?.method!==`totp`)throw q(r,`Could not start two-factor authentication`);return{totpURI:n.totpURI,backupCodes:n.backupCodes}},confirmAuthenticatorApp:async t=>{let{error:n}=await e.twoFactor.verifyTotp({code:t});if(n)throw q(n,`The code did not work`)},turnOnEmailedCodes:async t=>{let{error:n}=await e.twoFactor.enable({method:`otp`,...t&&{password:t}});if(n)throw q(n,`Could not turn on two-factor authentication`)},turnOffTwoFactor:async t=>{let{error:n}=await e.twoFactor.disable(t?{password:t}:{});if(n)throw q(n,`Could not turn off two-factor authentication`)},linkedProviders:async()=>{let{data:t,error:n}=await e.listAccounts();if(n||!t)throw q(n,`Could not read your linked accounts`);return[...new Set(t.map(e=>e.providerId).filter(e=>e!==`credential`))]},linkProvider:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start linking the account`);return r.url},linkedPersonalMail:async t=>{let{data:n,error:r}=await e.listAccounts();if(r||!n)throw q(r,`Could not read your linked accounts`);return t.filter(e=>n.some(t=>t.providerId===e.provider&&e.scopes.every(e=>t.scopes.includes(e)))).map(e=>e.id)},linkPersonalMail:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t.provider,scopes:t.scopes,additionalParams:t.params,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start linking the mailbox`);return r.url},workflowConnections:async()=>{let{data:t,error:n}=await e.$fetch(`/connections`);if(n?.status===404)return[];if(n||!t)throw q(n,`Could not read your connections`);return t.connections},connectAccount:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t.provider,scopes:t.scopes,additionalParams:t.link_params,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw q(i,`Could not start connecting the account`);return r.url},disconnectAccount:async t=>{let{data:n,error:r}=await e.$fetch(`/connections/disconnect`,{method:`POST`,body:{accountId:t}});if(r||!n)throw q(r,`Could not disconnect the account`);return n.revocation},connectedApps:async()=>{let{data:t,error:n}=await e.$fetch(`/account/connected-apps`);if(n||!t)throw q(n,`Could not read your connected apps`);return t.apps},disconnectApp:async t=>{let{error:n}=await e.$fetch(`/account/connected-apps/disconnect`,{method:`POST`,body:{clientId:t}});if(n)throw q(n,`Could not disconnect the app`)},sendConfirmationCode:async()=>{let{error:t}=await e.$fetch(`/account/confirmation-code/send`,{method:`POST`});if(t)throw q(t,`Could not email a code`)},confirmWithCode:async t=>{let{error:n}=await e.$fetch(`/account/confirmation-code/verify`,{method:`POST`,body:{code:t}});if(n)throw q(n,`The code did not work`)},confirmWithPassword:async t=>{let{error:n}=await e.$fetch(`/account/confirm-password`,{method:`POST`,body:{password:t}});if(n)throw q(n,`The password did not work`)},newBackupCodes:async t=>{let{data:n,error:r}=await e.twoFactor.generateBackupCodes(t?{password:t}:{});if(r||!n)throw q(r,`Could not make new backup codes`);return n.backupCodes}}),Uh=e=>({mailSenders:async()=>{let{data:t,error:n}=await e.$fetch(`/account/mail-senders`);if(n||!t)throw q(n,`Could not read your From addresses`);return t},addMailSender:async t=>{let{data:n,error:r}=await e.$fetch(`/account/mail-senders/add`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not add the From address`);return n.sender},updateMailSender:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/account/mail-senders/update`,{method:`POST`,body:{id:t,...n}});if(i||!r)throw q(i,`Could not change the From address`);return r.sender},removeMailSender:async t=>{let{error:n}=await e.$fetch(`/account/mail-senders/remove`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not remove the From address`)}}),Wh=e=>({personalAccessTokens:async()=>{let{data:t,error:n}=await e.$fetch(`/account/personal-access-tokens`);if(n||!t)throw q(n,`Could not read your access tokens`);return t.tokens},createPersonalAccessToken:async t=>{let{data:n,error:r}=await e.$fetch(`/account/personal-access-tokens/create`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not make the access token`);return n},revokePersonalAccessToken:async t=>{let{error:n}=await e.$fetch(`/account/personal-access-tokens/revoke`,{method:`POST`,body:{id:t}});if(n)throw q(n,`Could not revoke the access token`)}}),Gh=(e,t)=>new K(e?.message||e?.error_description||t,e?.status??500,e?.code??e?.error),Kh=e=>({client:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/public-client`,{query:{client_id:t}});if(r||!n)throw Gh(r,`Could not read the app asking`);return n},resume:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/continue`,{method:`POST`,body:{postLogin:!0,oauth_query:t}});if(r||!n?.url)throw Gh(r,`Could not go on with the request`);return{url:n.url}},answer:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/oauth2/consent`,{method:`POST`,body:{accept:t,oauth_query:n}});if(i||!r?.url)throw Gh(i,`Could not answer the request`);return{url:r.url}}}),qh=(e,t,n)=>g({baseURL:e,basePath:t,plugins:[m(),re(),b(),oe()],disableDefaultFetchPlugins:!0,fetchOptions:{customFetchImpl:zh(n)}}),Jh=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):typeof e==`string`?JSON.parse(e):[],Yh=e=>{let t=e.split(`,`);return t.includes(`owner`)?`owner`:t.includes(`admin`)?`admin`:`member`},Xh=e=>({id:e.id,userId:e.userId,name:e.user.name||e.user.email,email:e.user.email,role:Yh(e.role),appRoles:Jh(e.appRoles),createdAt:new Date(e.createdAt).toISOString()}),Zh=e=>({id:e.id,email:e.email,role:Yh(e.role),appRoles:Jh(e.appRoles),status:e.status,expiresAt:new Date(e.expiresAt).toISOString(),...e.organizationName&&{organizationName:e.organizationName}}),Qh=(e,t)=>{let n=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.method??(r.body?`POST`:`GET`),...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw q(a,n);return i},r=async e=>(await t().catch(e=>{if(!(e instanceof Rh))throw e}),e);return{list:async()=>await n(`/organization/list`,`Could not read your organizations`)??[],current:()=>n(`/organization/current`,`Could not read the current organization`),switchTo:async e=>r(await n(`/organization/switch`,`Could not switch the organization`,{body:{organizationId:e}})),search:(e,t=0)=>n(`/organization/search`,`Could not search the organizations`,{query:{query:e,...t>0&&{offset:String(t)}}}),create:async e=>r(await n(`/organization/create`,`Could not create the organization`,{body:e})),rename:(e,t)=>n(`/organization/update`,`Could not change the organization`,{body:{organizationId:e,data:t}}),remove:async e=>r(await n(`/organization/delete`,`Could not delete the organization`,{body:{organizationId:e}})),leave:async e=>r(await n(`/organization/leave`,`Could not leave the organization`,{body:{organizationId:e}})),members:async e=>(await n(`/organization/list-members`,`Could not read the members`,{query:{organizationId:e,limit:`1000`}})).members.map(Xh),people:async()=>(await n(`/organization/people`,`Could not read the people`)).people,setRole:(e,t,r)=>n(`/organization/update-member-role`,`Could not change the role`,{body:{organizationId:e,memberId:t,role:r}}),setAppRoles:(e,t)=>n(`/organization/set-app-roles`,`Could not change the app roles`,{body:{memberId:e,appRoles:t}}),removeMember:(e,t)=>n(`/organization/remove-member`,`Could not remove the member`,{body:{organizationId:e,memberIdOrEmail:t}}),transferOwnership:(e,t=`admin`)=>n(`/organization/transfer-ownership`,`Could not hand the organization over`,{body:{memberId:e,keepAs:t}}),invitations:async e=>(await n(`/organization/list-invitations`,`Could not read the invitations`,{query:{organizationId:e}})??[]).map(Zh),invite:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation`,{body:{organizationId:e,...t}});return{invitation:Zh(r),...r.link&&{link:r.link}}},resend:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation again`,{body:{organizationId:e,email:t.email,role:t.role,resend:!0}});return{invitation:Zh(r),...r.link&&{link:r.link}}},revoke:e=>n(`/organization/cancel-invitation`,`Could not revoke the invitation`,{body:{invitationId:e}}),myInvitations:async()=>(await n(`/organization/list-user-invitations`,`Could not read your invitations`)??[]).map(Zh),invitation:e=>n(`/invitation`,`This invitation link is not valid`,{query:{token:e}}),accept:async e=>r(await n(`/invitation/accept`,`Could not accept the invitation`,{body:{token:e}})),acceptMine:async e=>r(await n(`/invitation/accept-own`,`Could not accept the invitation`,{body:{invitationId:e}})),signUpFromInvitation:async(e,t)=>r(await n(`/invitation/sign-up`,`Could not create your account`,{body:{token:e,...t}}))}},$h=(e,t)=>({current:async()=>{let{data:t,error:n}=await e.$fetch(`/role/current`,{method:`GET`});if(n)throw q(n,`Could not read your roles`);return t},switchTo:async n=>{let{error:r}=await e.$fetch(`/role/switch`,{method:`POST`,body:{role:n}});if(r)throw q(r,`Could not switch the role`);await t()}}),eg=20,tg=e=>Array.isArray(e)?e:(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),ng=e=>({id:e.id,name:e.name||e.email,email:e.email,roles:tg(e.role),blocked:!!e.banned,createdAt:new Date(e.createdAt).toISOString()}),rg=e=>({id:e.id,email:e.email,roles:e.roles,expiresAt:new Date(e.expiresAt).toISOString()}),ig=e=>({invitation:rg(e),...e.link&&{link:e.link}}),ag=e=>{let t=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.body?`POST`:`GET`,...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw q(a,n);return i};return{search:async(e,n=0)=>{let r=await t(`/admin/list-users`,`Could not read the users`,{query:{limit:String(eg),sortBy:`createdAt`,sortDirection:`asc`,...n>0&&{offset:String(n)},...e&&{searchValue:e,searchField:`email`}}});return{users:r.users.map(ng),total:r.total}},create:async e=>ng((await t(`/admin/create-user`,`Could not create the account`,{body:{email:e.email,name:e.name,role:e.roles,...e.password&&{password:e.password}}})).user),setRoles:(e,n)=>t(`/admin/set-role`,`Could not change the roles`,{body:{userId:e,role:n}}),block:e=>t(`/admin/ban-user`,`Could not block the account`,{body:{userId:e}}),unblock:e=>t(`/admin/unban-user`,`Could not unblock the account`,{body:{userId:e}}),invite:async e=>ig(await t(`/users/invite`,`Could not send the invitation`,{body:e})),invitations:async()=>(await t(`/users/invitations`,`Could not read the invitations`)).invitations.map(rg),revoke:e=>t(`/users/invitations/cancel`,`Could not revoke the invitation`,{body:{id:e}}),roles:()=>t(`/users/roles`,`Could not read the roles`)}},og=(e,t)=>{let n=async e=>e?.twoFactorRedirect?{kind:`two-factor`,methods:e.twoFactorMethods??[]}:(await t(),{kind:`signed-in`,user:e?.user});return{signIn:async(t,r)=>{let{data:i,error:a}=await e.signIn.email({email:t,password:r});if(a||!i)throw q(a,`Sign-in failed`);return n(i)},sendSignInCode:async t=>{let{error:n}=await e.emailOtp.sendVerificationOtp({email:t,type:`sign-in`});if(n)throw q(n,`Could not send the code`)},signInWithCode:async(t,r)=>{let{data:i,error:a}=await e.signIn.emailOtp({email:t,otp:r});if(a||!i)throw q(a,`Sign-in failed`);return n(i)},sendSignUpCode:async t=>{let{error:n}=await e.$fetch(`/sign-up/send-code`,{method:`POST`,body:{email:t}});if(n)throw q(n,`Could not send the code`)},verifySignUpCode:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/sign-up/verify-code`,{method:`POST`,body:{email:t,code:n}});if(i||!r)throw q(i,`Could not check the code`);return r.ticket},signUp:async n=>{let{data:r,error:i}=await e.$fetch(`/sign-up/create`,{method:`POST`,body:n});if(i||!r)throw q(i,`Could not create your account`);return await t(),r.user},signInWithPasskey:async n=>{let r=await e.$fetch(`/passkey/generate-authenticate-options`,{method:`GET`,...n&&{query:{rpId:n}}});if(r.error||!r.data)throw q(r.error,`Sign-in failed`);let{clientExtensionResults:i,...a}=await ae({optionsJSON:r.data}).catch(e=>{throw new K(`Auth cancelled`,400,e instanceof f?e.code:`AUTH_CANCELLED`)}),o=await e.$fetch(`/passkey/verify-authentication`,{method:`POST`,body:{response:a}});if(o.error||!o.data)throw q(o.error,`Sign-in failed`);return await t(),o.data.user},sendTwoFactorCode:async()=>{let{error:t}=await e.twoFactor.sendOtp();if(t)throw q(t,`Could not send the code`)},verifyTwoFactor:async({method:n,code:r,trustDevice:i=!1})=>{let{data:a,error:o}=await(n===`totp`?e.twoFactor.verifyTotp:n===`otp`?e.twoFactor.verifyOtp:e.twoFactor.verifyBackupCode)({code:r,trustDevice:i});if(o||!a)throw q(o,`The code did not work`);return await t(),a.user}}},sg=e=>({read:async()=>{let{data:t,error:n}=await e.$fetch(`/policy/sign-in`);if(n||!t)throw q(n,`Could not read the sign-in policy`);return t},save:async t=>{let{data:n,error:r}=await e.$fetch(`/policy/sign-in`,{method:`POST`,body:t});if(r||!n)throw q(r,`Could not save the sign-in policy`);return n}}),cg=e=>new Date(e).toISOString(),lg=({startedAt:e,expiresAt:t,endedAt:n,...r})=>({...r,startedAt:cg(e),expiresAt:cg(t),...n&&{endedAt:cg(n)}}),ug=e=>({start:async t=>{let{data:n,error:r}=await e.$fetch(`/staff/sign-in`,{method:`POST`,body:t});if(r||!n?.url)throw q(r,`Could not start the staff sign-in`);return n.url},current:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/session`);if(n||!t)throw q(n,`Could not read the session`);return t.staff?lg(t.staff):void 0},stop:async()=>{let{error:t}=await e.$fetch(`/staff/stop`,{method:`POST`,body:{}});if(t)throw q(t,`Could not end the staff session`)},log:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/sign-ins`);if(n||!t)throw q(n,`Could not read the staff sign-ins`);return t.signIns.map(lg)}}),dg=e=>{let t=e.split(`.`)[1];if(!t)throw Error(`Not a JWT`);let n=JSON.parse(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)));if(typeof n.exp!=`number`)throw Error(`The token has no expiry`);return n.exp*1e3},fg=(e={})=>{let t=e.origin??globalThis.location?.origin??`http://localhost`,n=e.basePath??`/api/auth`,r=e.refreshMarginMs??6e4,i=e.fetch??((e,t)=>fetch(e,t)),a=qh(t,n,i),o=ug(a),s,c,l,u=()=>{s=void 0,clearTimeout(l)},d=async()=>{u();let{data:t}=await a.$fetch(`/token`);if(t?.token)return s={token:t.token,expiresAt:dg(t.token)},l=setTimeout(()=>void f({refresh:!0}).then(t=>t||e.onSignedOut?.()),Math.max(1e3,s.expiresAt-Date.now()-r)),s.token},f=async({refresh:e=!1}={})=>!e&&s&&s.expiresAt-Date.now()>r?s.token:(c??=d().finally(()=>{c=void 0}),c);return{token:f,status:async()=>{let e=await i(`${t}${n}/status`);if(e.status===404)throw new K(`This server has no sign-in. Is the API URL right?`,404);if(!e.ok)throw new K(`Could not read the sign-in status`,e.status);let r=await e.json();return{needsAdmin:!!r.needsAdmin,...r.needsAdmin&&r.firstAdminUrl&&{firstAdminUrl:r.firstAdminUrl},signInMethods:r.signInMethods??[`password`],...r.signInFirst===`emailCode`&&{signInFirst:`emailCode`},passwordReset:!!r.passwordReset,...r.changeEmail&&{changeEmail:!0},...r.accountDeletion&&{accountDeletion:!0},...r.signUp&&{signUp:!0},...r.signUp&&r.signUpFields&&{signUpFields:r.signUpFields},socialProviders:r.socialProviders??[],...r.platformProviders&&{platformProviders:r.platformProviders},...r.deviceLinks&&{deviceLinks:!0},samlProviders:r.samlProviders??[],...r.staffSignIn&&{staffSignIn:r.staffSignIn},...r.passkeyDomains&&{passkeyDomains:r.passkeyDomains},...r.organizations&&{organizations:r.organizations},...r.anonymous&&{anonymous:!0},...r.mcp&&{mcp:{url:r.mcp.url}},...r.personalAccessTokens&&{personalAccessTokens:!0},...r.personalMail&&r.personalMail.length>0&&{personalMail:r.personalMail},...r.plugins&&r.plugins.length>0&&{plugins:r.plugins},...Br(r.locale)&&{locale:r.locale}}},session:async()=>{let{data:e,error:t}=await a.getSession();if(t&&t.status!==401)throw q(t,`Could not read your session`);return e?.user},...og(a,()=>f({refresh:!0})),signInSocial:async(e,t)=>{let{data:n,error:r}=await a.signIn.social({provider:e,callbackURL:t,errorCallbackURL:t,disableRedirect:!0});if(r||!n?.url)throw q(r,`Sign-in failed`);return n.url},signInSaml:async(e,t)=>{let{data:n,error:r}=await a.$fetch(`/sign-in/sso`,{method:`POST`,body:{providerId:e,callbackURL:t,errorCallbackURL:t}});if(r||!n?.url)throw q(r,`Sign-in failed`);return n.url},signOut:async()=>{u(),await a.signOut()},deleteAccount:async e=>{let{error:t}=await a.deleteUser(e?{password:e}:{});if(t)throw q(t,`Could not delete your account`);u()},requestPasswordReset:async(e,t)=>{let{error:n}=await a.requestPasswordReset({email:e,redirectTo:t});if(n)throw q(n,`Could not send the reset link`)},resetPassword:async(e,t)=>{let{error:n}=await a.resetPassword({token:e,newPassword:t});if(n)throw q(n,`Could not set the password`)},account:{...Hh(a),...Vh(a),...Wh(a),...Uh(a)},connect:Kh(a),organizations:Qh(a,()=>f({refresh:!0})),roles:$h(a,()=>f({refresh:!0})),signInPolicy:sg(a),users:ag(a),staff:{...o,stop:async()=>{u(),await o.stop()}}}},pg=e=>Math.min(3e4,1e3*2**e),mg=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),hg=`http://same-origin.invalid`,gg=(e,t)=>{let n=new URL(e,hg),r=new URL(t,`${n.href}/`);if(r.origin!==n.origin)throw Error(`${t} is not on the assistant backend's origin`);return n.origin===hg?`${r.pathname}${r.search}`:r.href},_g=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=e.retryDelayMs??pg,i=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i.method,headers:{...i.body===void 0?{accept:`text/event-stream`}:{"content-type":`application/json`},...a&&{authorization:`Bearer ${a}`}},body:i.body===void 0?void 0:JSON.stringify(i.body),signal:i.signal});if(!o.ok)throw await Bd(o);return o},a=async(e,t,n)=>{let r=await i(`/events`,{method:`GET`,signal:e});if(!r.body)throw Error(`The assistant backend answered the event stream without a body`);n(),await Rr(r.body,e=>t(JSON.parse(e)),e)};return{connect:(e,t)=>{let n=new AbortController,{signal:i}=n;return(async()=>{let n=0;for(;!i.aborted;){t?.({state:`connecting`});let o=await a(i,e,()=>{n=0,t?.({state:`open`})}).then(()=>void 0,e=>e??Error(`The assistant stream failed`));if(i.aborted)return;t?.({state:`retrying`,...o!==void 0&&{error:o}}),await mg(r(n++),i)}})(),()=>n.abort()},send:async(e,t)=>{await i(`/messages`,{method:`POST`,body:{text:e,...t&&{page:t}}})},act:async(e,t)=>{await i(`/actions`,{method:`POST`,body:{partId:e,actionId:t}})},fetch:async(r,i={})=>{let a=gg(t,r),o=await e.token(),s=new Headers(i.headers);o&&s.set(`authorization`,`Bearer ${o}`);let c=await n(a,{...i,headers:s});if(!c.ok)throw await Bd(c);return c}}},vg=e=>e.Capacitor?.isNativePlatform()?e.Capacitor:void 0,yg=[101,204,205,304],bg=/%2f|%5c/i,xg=e=>Object.hasOwn(ni,e),Sg=(e,t)=>e.origin===t&&!e.username&&!e.password&&e.pathname.startsWith(`/api/auth/`)&&!bg.test(e.pathname),Cg=({status:e,headers:t,data:n})=>yg.includes(e)?null:Object.entries(t).some(([e,t])=>e.toLowerCase()===`content-type`&&t.startsWith(`application/json`))?JSON.stringify(n):typeof n==`string`?n:JSON.stringify(n),wg=(e,t)=>{let n=e.getPlatform();if(!xg(n))throw Error(`Signing in through native HTTP is for iOS and Android, not ${n}`);return async(n,r)=>{let i=new Request(n,r),a=new URL(i.url);if(!Sg(a,t))throw Error(`Native sign-in requests go to ${t}${ei}/ only, not ${i.url}`);let o=i.method!==`GET`&&i.method!==`HEAD`,s=await e.nativePromise(`ProtobaseAuth`,`request`,{url:a.href,method:i.method,headers:Object.fromEntries(i.headers),...o&&{data:await i.text()}}),c=Object.entries(s.headers).filter(([e])=>e.toLowerCase()!==`set-cookie`);return new Response(Cg(s),{status:s.status,headers:c})}},Tg=e=>e?.isPluginAvailable(`ProtobaseAuth`)?e:void 0,Eg,Dg,Og=({dsn:e,environment:t})=>(Eg??=s(()=>import(`./lib-sentry-browser-BoddUTMM.js`).then(e=>e.t).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>[...e.filter(e=>e.name!==`BrowserSession`),n.thirdPartyErrorFilterIntegration({filterKeys:[_r],behaviour:`drop-error-if-exclusively-contains-third-party-frames`})],beforeSend:e=>gr(e)}),Dg=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),__vite__mapDeps([0,1,2,3,4])),Eg),kg=(e,t)=>Dg?.(e,t??void 0),Ag=e=>Dg?.(e),jg=class extends Error{reason;constructor(e){super(`The push service gave the app no push token: ${e}`),this.reason=e,this.name=`PushRegistrationError`}},Mg=class extends Error{service;constructor(e,t){super(`The push service gave the app no push token within ${t} ms`),this.service=e}},Ng=class extends Error{constructor(){super(`Push is off, but this device could not store that the user turned it off`)}},Pg=e=>e instanceof jg?{kind:`registration`,reason:e.reason}:e instanceof Mg?{kind:`no-token`,service:e.service}:e instanceof Ng?{kind:`off-not-stored`}:e instanceof Id?{kind:`refused`,reason:e.message}:{kind:`other`,reason:e instanceof Error?e.message:String(e)},Fg=`PushNotifications`,Ig=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),Lg=class extends Error{},Rg=(e,t)=>e instanceof Id&&e.status===409&&e.slug===t,zg=({bridge:e,device:t,records:n,choices:r,permissionAsked:i,devices:a,user:o,userAgent:s,waitMs:c=3e3,tokenMs:l=15e3,report:u})=>{let d=(t,n={})=>e.nativePromise(Fg,t,n),f=async()=>(await d(`checkPermissions`)).receive,p=()=>new Promise((t,n)=>{let r=[],i=e=>{clearTimeout(a);for(let e of r)e.remove();r=[],e()},a=setTimeout(()=>i(()=>n(new Mg(e.getPlatform()===`ios`?`apns`:`fcm`,l))),l);r=[e.addListener(Fg,`registration`,e=>i(()=>t(e.value))),e.addListener(Fg,`registrationError`,e=>i(()=>n(new jg(e.error))))],d(`register`).catch(e=>i(()=>n(e)))}),m=async()=>{await n.clear(),await d(`removeAllDeliveredNotifications`),await d(`unregister`)},h=async e=>{u(e),await m()},g=async e=>{let n=()=>o()?.id===e.id&&o()?.own===!0,r=await p();if(!n())throw new Lg;let i=await a.register({...await t(r),userAgent:s,userId:e.id});if(!n())throw new Lg;return{device:i,token:r}},_=async()=>{let e=await f();if(e===`denied`)return`blocked`;let[t,r]=[o(),await n.read()];return t&&e===`granted`&&r?.userId===t.id?`on`:`off`},v=async()=>{let e=o();if(!e?.own)return _();let t=await f();if((t===`prompt`||t===`prompt-with-rationale`)&&(t=(await d(`requestPermissions`)).receive),t!==`granted`)return _();r.set(e.id,`on`);let i=async()=>{let{device:t,token:r}=await g(e);await n.write({userId:e.id,endpoint:r,deviceId:t.id})};try{await i()}catch(e){if(e instanceof jg)throw await h(e),e;if(await m(),e instanceof Lg)return`off`;if(!Rg(e,`device-held`))throw e;try{await i()}catch(e){if(e instanceof jg)throw await h(e),e;if(await m(),e instanceof Lg)return`off`;throw e}}return`on`},y=async({chosen:e=!1}={})=>{let t=o(),i=!e||!t?.own||r.set(t.id,`off`);if(await b(await n.read()),!i)throw new Ng},b=async e=>{await n.clear(),await Ig(c,Promise.allSettled([d(`removeAllDeliveredNotifications`),d(`unregister`),e?.deviceId?a.remove(e.deviceId):Promise.resolve()]))},x=async()=>{await n.clear(),await Ig(c,Promise.allSettled([d(`removeAllDeliveredNotifications`),d(`unregister`)]))},S=e=>{let t=r.of(e);return t===void 0?i:t===`on`};return{state:_,turnOn:v,turnOff:y,forget:x,adopt:async e=>{let t=await n.read();if(t&&t.userId!==e.id)return m();if(e.own){if(t&&r.of(e.id)===`off`)return b(t);if(t||S(e.id)){if(await f()!==`granted`)return t&&m();try{let{device:r,token:i}=await g(e);await n.write({userId:e.id,endpoint:i,deviceId:r.id}),t?.deviceId&&t.deviceId!==r.id&&await a.remove(t.deviceId)}catch(e){if(e instanceof Lg)return;if(e instanceof jg)return h(e);if(!Rg(e,`device-held`)&&!Rg(e,`other-user`))throw e;await m()}}}}}},Bg=`ProtobasePush`,Vg=e=>{if(!e.isPluginAvailable(`PushNotifications`))return;let t=e.getPlatform();if(t===`android`)return async e=>({kind:`fcm`,token:e});if(t===`ios`&&e.isPluginAvailable(`ProtobasePush`))return async t=>{let{appId:n,environment:r}=await e.nativePromise(Bg,`apns`,{});return{kind:`apns`,token:t.toLowerCase(),appId:n,environment:r}}},Hg=e=>e.replace(/[\u0000-\u001f\u007f]/g,``).slice(0,512),Ug=(e=window)=>{let{navigator:t}=e;return{supported:`serviceWorker`in t&&`PushManager`in e&&`Notification`in e&&`userActivation`in t,permission:()=>e.Notification.permission,requestPermission:()=>e.Notification.requestPermission(),activated:()=>t.userActivation.isActive,existingRegistration:()=>t.serviceWorker.getRegistration(`/`),registration:async()=>(await t.serviceWorker.getRegistration(`/`)||await t.serviceWorker.register(`/${ii}`),t.serviceWorker.ready),clearBadge:async()=>{`clearAppBadge`in t&&await t.clearAppBadge()},userAgent:Hg(t.userAgent)}},Wg=/\bAndroid (\d+)/,Gg=(e,t)=>{if(e===`ios`)return!0;let n=Wg.exec(t)?.[1];return e===`android`&&n!==void 0&&Number(n)>=13},Kg=`protobase:push-choices`,qg=e=>{let t=new Map,n=()=>{try{let t=JSON.parse(e().getItem(Kg)??`{}`);return typeof t==`object`&&t&&!Array.isArray(t)?t:void 0}catch{return}};return{of:e=>{let r=t.get(e);if(r)return r;let i=n();if(!i)return`unknown`;let a=Object.hasOwn(i,e)?i[e]:void 0;return a===`on`||a===`off`?a:void 0},set:(r,i)=>{t.set(r,i);try{return e().setItem(Kg,JSON.stringify({...n(),[r]:i})),!0}catch{return!1}}}},Jg=(e=indexedDB)=>{let t=(t,n)=>new Promise((r,i)=>{let a=e.open(ri.database,1);a.onupgradeneeded=()=>a.result.createObjectStore(ri.store),a.onerror=()=>i(a.error),a.onsuccess=()=>{let e=a.result,o=n(e.transaction(ri.store,t).objectStore(ri.store));o.onsuccess=()=>(e.close(),r(o.result)),o.onerror=()=>(e.close(),i(o.error))}});return{read:()=>t(`readonly`,e=>e.get(ri.key)),write:async e=>void await t(`readwrite`,t=>t.put(e,ri.key)),clear:async()=>void await t(`readwrite`,e=>e.delete(ri.key))}},Yg=e=>Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),Xg=(e,t)=>Promise.race([t,new Promise(t=>setTimeout(t,e))]),Zg=class extends Error{},Qg=(e,t)=>e instanceof Id&&e.status===409&&e.slug===t,$g=({browser:e,records:t,devices:n,meta:r,user:i,waitMs:a=3e3})=>{let o,s=()=>o??=r(),c=async n=>{await t.clear();for(let e of n?await n.getNotifications():[])e.close();await e.clearBadge()},l=async e=>{let t=await e?.pushManager.getSubscription();t&&await t.unsubscribe()},u=async e=>{await c(e),await l(e)},d=async(r,i)=>{let a=r.toJSON().keys??{},o=await n.register({kind:`web`,endpoint:r.endpoint,keys:{p256dh:a.p256dh??``,auth:a.auth??``},userAgent:e.userAgent,userId:i.userId});await t.write({...i,deviceId:o.id})},f=async()=>{if(!e.supported||!(await s()).webPushKey)return`unsupported`;if(e.permission()===`denied`)return`blocked`;let n=i(),r=await e.existingRegistration(),[a,o]=await Promise.all([r?.pushManager.getSubscription(),t.read()]);return n&&a&&o?.userId===n.id&&o.endpoint===a.endpoint?`on`:`off`},p=async()=>{let n=i();if(!e.supported||!e.activated()||!n?.own||e.permission()==="default"&&await e.requestPermission()!==`granted`||e.permission()!==`granted`)return f();let{appName:r,webPushKey:a}=await s();if(!a)return`unsupported`;let o=()=>i()?.id===n.id&&i()?.own===!0,c=await e.registration();if(!o())return f();let[l,p]=await Promise.all([c.pushManager.getSubscription(),t.read()]);l&&(p?.userId!==n.id||p.endpoint!==l.endpoint)&&await u(c);let h=async()=>{if(!o())throw new Zg;let e=await c.pushManager.getSubscription()??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Yg(a)}),i={userId:n.id,endpoint:e.endpoint,appName:r};if(await t.write(i),!o())throw new Zg;await d(e,i)};try{await h()}catch(e){if(Qg(e,`device-held`))return await u(c),m(c,h);if(await u(c),e instanceof Zg||Qg(e,`other-user`))return`off`;throw e}return`on`},m=async(e,t)=>{try{await t()}catch(t){if(await u(e),t instanceof Zg||Qg(t,`device-held`)||Qg(t,`other-user`))return`off`;throw t}return`on`};return{state:f,turnOn:p,turnOff:async()=>{if(!e.supported)return;let r=await e.existingRegistration(),i=await t.read();await c(r),await Xg(a,Promise.allSettled([l(r),i?.deviceId?n.remove(i.deviceId):Promise.resolve()]))},forget:async()=>{if(!e.supported)return;let t=await e.existingRegistration();await c(t),await Xg(a,Promise.allSettled([l(t)]))},adopt:async n=>{if(!e.supported)return;let r=await e.existingRegistration(),[i,a]=await Promise.all([r?.pushManager.getSubscription(),t.read()]);if(!r)return a?t.clear():void 0;if(!a||a.userId!==n.id)return i||a?u(r):void 0;if(!n.own)return;if(!i||e.permission()!==`granted`||a.endpoint!==i.endpoint&&!a.renew)return u(r);let o={userId:a.userId,endpoint:i.endpoint,appName:a.appName};await t.write(o);try{await d(i,o)}catch(e){if(!Qg(e,`device-held`)&&!Qg(e,`other-user`))throw e;await u(r)}}}},e_={state:async()=>`unsupported`,turnOn:async()=>`unsupported`,turnOff:async()=>{},forget:async()=>{},adopt:async()=>{}},t_=({nativeBridge:e,...t})=>{if(typeof window>`u`)return e_;if(e){let n=Vg(e);if(!n)return e_;let{devices:r,user:i,waitMs:a}=t;return zg({bridge:e,device:n,records:Jg(),choices:qg(()=>localStorage),permissionAsked:Gg(e.getPlatform(),navigator.userAgent),devices:r,user:i,userAgent:Hg(navigator.userAgent),report:Ag,...a!==void 0&&{waitMs:a}})}let n=Ug();return n.supported?$g({...t,browser:n,records:Jg()}):e_},n_=e=>e===`http:`||e===`https:`,r_=(e,t=(e,t)=>fetch(e,t))=>{if(n_(e.protocol))return;let n=`${e.protocol}//${e.host}`;return{origin:`https://${e.host}`,fetch:(e,r)=>{let i=new URL(e instanceof Request?e.url:e),a=`${n}${i.pathname}${i.search}`;return e instanceof Request?t(new Request(a,e),r):t(a,r)}}},i_=e=>e!==void 0&&URL.canParse(e)&&n_(new URL(e).protocol),a_=async(e,t)=>{let n=!1;try{n=!!await e?.()}finally{n||await t()}},o_=`sign-in`,s_=`error`,c_=e=>{let t=new URL(e).searchParams;if(!t.has(s_))return t.get(`sign-in`)||void 0},l_=e=>new URL(e).searchParams.get(s_)||void 0,u_=[`totp`,`otp`],d_=e=>{let t=new URL(e).searchParams.get(ti);if(t!==null)return t.split(`,`).filter(e=>u_.includes(e))},f_=e=>{let t=new URL(e);for(let e of[o_,s_,ti])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},p_={github:`GitHub`,gitlab:`GitLab`,google:`Google`,microsoft:`Microsoft`,apple:`Apple`},m_=(e,t=[])=>t.find(t=>t.provider===e)?.name??p_[e]??e.charAt(0).toUpperCase()+e.slice(1),h_=e=>e.filter(({linkOnly:e})=>!e),g_=e=>e.kind===`signed-in`&&!e.staff,__=(e,t)=>e.kind===`loading`||e.kind===`error`?`leave`:e.kind!==`signed-in`||!g_(e)?`clear`:t?{save:{user:e.user,status:t}}:`leave`,v_=(0,j.createContext)(null),y_=[`password`],b_=[],x_=[],S_=[],C_=[],w_=[],J=()=>{let e=(0,j.useContext)(v_);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e},T_=()=>(0,j.useContext)(v_),E_=({session:e,origin:t,nativeBridge:n,afterSignIn:r,children:i})=>{let a=oa(),[o]=(0,j.useState)(()=>a?.session()),[s,c]=(0,j.useState)(()=>o?{kind:`signed-in`,user:o.user}:{kind:`loading`}),[l,u]=(0,j.useState)(o?.status),d=l?.signInMethods??y_,f=l?.signInFirst??`password`,p=Tg(n),m=!!l?.passwordReset&&!p,h=!!l?.changeEmail,g=!!l?.accountDeletion,_=l?.mcp,v=!!l?.personalAccessTokens,y=!!l?.signUp,b=l?.signUpFields?.includes(`name`)??!0,x=l?.passkeyDomains??b_,S=l?.socialProviders??b_,C=l?.platformProviders??C_,w=l?.personalMail??x_,T=l?.samlProviders??S_,E=l?.staffSignIn,D=!!l?.deviceLinks,O=l?.organizations,k=!!l?.anonymous,A=l?.plugins??w_,ee=l?.locale,te=(0,j.useMemo)(()=>({...l?.appName&&{appName:l.appName},...l?.appIcon&&{appIcon:l.appIcon},runsOnNote:!!l?.runsOnNote}),[l]),ne=(0,j.useCallback)(()=>k?{kind:`visitor`}:{kind:`signed-out`},[k]),re=(0,j.useRef)(async()=>{}),ie=(0,j.useRef)(0),ae=(0,j.useCallback)(()=>{ie.current+=1,re.current(),c(e=>e.kind===`signed-in`?{kind:`signed-out`}:e)},[]),oe=(0,j.useRef)(ae);oe.current=ae;let M=(0,j.useMemo)(()=>{if(e)return e;let n=i_(t)?void 0:r_(window.location),r=n?.origin??t;return fg({...r&&{origin:r},...n&&{fetch:n.fetch},...p&&{fetch:wg(p,r??window.location.origin)},onSignedOut:()=>oe.current()})},[e,t,p]),se=(0,j.useRef)(void 0);se.current=s.kind===`signed-in`?{id:s.user.id,own:!s.staff}:void 0;let ce=(0,j.useMemo)(()=>{let e=Xf({baseUrl:`${t??globalThis.location?.origin??``}/api/v1`,token:({refresh:e})=>M.token({refresh:e})}),r=async()=>{let t=await e.meta();if(t.status!==`modified`)throw Error(`The app answered /meta without its content`);return{appName:t.meta.appName,...t.meta.notifications?.webPushKey&&{webPushKey:t.meta.notifications.webPushKey}}};return t_({...n&&{nativeBridge:n},devices:e.devices,meta:r,user:()=>se.current})},[M,t,n]);re.current=ce.forget;let le=(0,j.useRef)(r);le.current=r;let ue=(0,j.useCallback)(async(e,t=ie.current)=>{let[{missing:n},r]=await Promise.all([M.account.signInMethods(),M.staff.current()]);ie.current===t&&(c(n.length>0?{kind:`setup-required`,user:e,missing:n}:{kind:`signed-in`,user:e,...r&&{staff:r}}),n.length===0&&ce.adopt({id:e.id,own:!r}))},[M,ce]),de=(0,j.useCallback)(async e=>{let t=ie.current;await a_(le.current,()=>ue(e,t))},[ue]),fe=(0,j.useCallback)(async e=>e.kind===`two-factor`?c({kind:`two-factor`,methods:e.methods}):de(e.user),[de]),N=(0,j.useCallback)(()=>{let e=ie.current;c(e=>e.kind===`signed-in`?e:{kind:`loading`}),M.status().then(async t=>{if(u(t),ie.current!==e)return;if(t.needsAdmin)return c({kind:`needs-admin`,...t.firstAdminUrl&&{firstAdminUrl:t.firstAdminUrl}});let n=await M.session();if(ie.current!==e)return;if(n)return ue(n,e);let r=d_(window.location.href);c(r?{kind:`two-factor`,methods:r}:{kind:t.anonymous?`visitor`:`signed-out`})}).catch(t=>{ie.current===e&&c(e=>e.kind===`signed-in`?e:{kind:`error`,...t instanceof Error&&{message:t.message}})})},[M,ue]);(0,j.useEffect)(N,[N]),(0,j.useEffect)(()=>{if(!a)return;let e=__(s,l);e===`clear`?a.clear():e!==`leave`&&a.saveSession(e.save)},[a,s,l]);let pe=(0,j.useMemo)(()=>({state:s,session:M,signInMethods:d,signInFirst:f,passwordReset:m,changeEmail:h,accountDeletion:g,mcp:_,personalAccessTokens:v,canSignUp:y,signUpAsksName:b,passkeyDomains:x,socialProviders:S,signInProviders:[...S.map(e=>({id:e,name:m_(e,C),...C.some(t=>t.provider===e&&t.button===!1)&&{linkOnly:!0}})),...T],platformProviders:C,deviceLinks:D,staffSignIn:E,...O&&{organizations:O},markSignedOut:ae,recheck:N,beforeSignIn:A,locale:ee,identity:te,adoptSession:async()=>{let e=await M.session();return e?(await de(e),!0):!1},...k&&{browse:()=>{c(e=>e.kind===`signed-out`?{kind:`visitor`}:e)}},signIn:async(e,t)=>fe(await M.signIn(e,t)),sendSignInCode:e=>M.sendSignInCode(e),signInWithCode:async(e,t)=>fe(await M.signInWithCode(e,t)),sendSignUpCode:e=>M.sendSignUpCode(e),verifySignUpCode:(e,t)=>M.verifySignUpCode(e,t),signUp:async e=>de(await M.signUp(e)),signInWithPasskey:async e=>de(await M.signInWithPasskey(e)),verifyTwoFactor:async e=>de(await M.verifyTwoFactor(e)),signInSocial:async e=>{let t=new URL(f_(window.location.href),window.location.href).href,n=T.some(t=>t.id===e);window.location.assign(await(n?M.signInSaml(e,t):M.signInSocial(e,t)))},linkProvider:async e=>{window.location.assign(await M.account.linkProvider(e,new URL(f_(window.location.href),window.location.href).href))},personalMail:w,linkPersonalMail:async e=>{window.location.assign(await M.account.linkPersonalMail(e,new URL(f_(window.location.href),window.location.href).href))},connectAccount:async e=>{window.location.assign(await M.account.connectAccount(e,new URL(f_(window.location.href),window.location.href).href))},stopStaffSession:async()=>{ie.current+=1,await ce.forget(),await M.staff.stop(),c(ne())},signOut:async()=>{ie.current+=1,await ce.turnOff(),await M.signOut(),c(ne())},deleteAccount:async e=>{await M.deleteAccount(e),ie.current+=1,await ce.forget(),c(ne())},push:ce}),[ce,s,M,d,f,m,h,g,_,v,y,b,x,S,C,D,w,T,E,O,k,A,ee,te,ne,ae,N,fe,de]);return(0,L.jsx)(v_.Provider,{value:pe,children:i})},D_=e=>{let t=!1,n=[];return{tap:r=>t?e(r):void n.push(r),settle:r=>{if(t=r,r)for(let t of n.splice(0))e(t)}}},O_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),k_=(e,{apiOrigin:t,userId:n,basePath:r})=>{if(!O_(e)||n===void 0||e.user!==n)return;let i=mi(e.url);if(i===void 0)return;let a=new URL(i);if(a.origin!==t)return{kind:`browser`,url:i};let o=`${a.pathname}${a.search}${a.hash}`;if(o.startsWith(`//`)||new URL(o,t).origin!==t)return;if(r===``)return{kind:`in-app`,path:o};if(a.pathname!==r&&!a.pathname.startsWith(`${r}/`))return;let s=o.slice(r.length);return{kind:`in-app`,path:s.startsWith(`/`)?s:`/${s}`}},A_=`protobase.push.tap`,j_=({storage:e,reloading:t})=>({receive:(n,r)=>{if(!t())return r(n);e.setItem(A_,JSON.stringify(n??null))},resume:t=>{let n=e.getItem(A_);if(n===null)return;e.removeItem(A_);let r;try{r=JSON.parse(n)}catch(e){if(e instanceof SyntaxError)return;throw e}t(r)}}),M_=`ProtobaseExternal`,N_=async(e,{bridge:t,navigate:n})=>{if(e.kind===`in-app`)return n(e.path);t.isPluginAvailable(M_)&&await t.nativePromise(M_,`open`,{url:e.url})},P_=e=>typeof e==`object`&&e?e.notification?.data:void 0,F_=({nativeBridge:e,apiOrigin:t})=>{let{state:n}=J(),{navigate:r,basePath:i}=Hu(),a=n.kind===`signed-in`?n.user.id:void 0,o=(0,j.useRef)(()=>{});o.current=n=>{let o=k_(n,{apiOrigin:t,userId:a,basePath:i});o&&N_(o,{bridge:e,navigate:r})};let[s]=(0,j.useState)(()=>D_(e=>o.current(e))),[c]=(0,j.useState)(()=>{let e=ue(()=>window.sessionStorage,void 0);return e&&j_({storage:e,reloading:()=>no(e)})});return(0,j.useEffect)(()=>s.settle(n.kind!==`loading`),[s,n.kind,a]),(0,j.useEffect)(()=>{if(!e.isPluginAvailable(`PushNotifications`))return;let t=e.addListener(Fg,`pushNotificationActionPerformed`,e=>c?c.receive(P_(e),s.tap):s.tap(P_(e)));return c?.resume(s.tap),()=>void t.remove()},[e,s,c]),null},Y=F(`account`),I_=`/-/account`,L_=`/-/sign-in-policy`,R_=e=>{if(e===`/-/account`)return{};if(!e.startsWith(`/-/account/`))return;let t=e.slice(11);if(!(t===``||t.includes(`/`)))try{return{tab:decodeURIComponent(t)}}catch(e){if(e instanceof URIError)return;throw e}},z_=e=>e?`${I_}/${encodeURIComponent(e)}`:I_,B_=(e,t,n)=>[{id:`account`,label:Y(`account`),icon:Jl,href:`${e}${I_}`,active:R_(t)!==void 0},...n?[{id:`sign-in-policy`,label:Y(`signInPolicy`),icon:bl,href:`${e}${L_}`,active:t===L_}]:[]],V_=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},H_=(0,j.createContext)(null),U_=e=>{let t=(0,j.useContext)(H_);(0,j.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},W_=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},G_=(0,j.createContext)(0),K_=(e,t)=>e.data!==void 0&&e.dataUpdatedAt<t,q_=(e,t)=>e.data!==void 0&&!K_(e,t),J_=e=>e.isError||e.failureCount>0,Y_=(e,t)=>{let n=e.filter(e=>K_(e.state,t));return n.length===0?`fresh`:n.some(e=>e.state.status===`error`||e.state.fetchFailureCount>0||e.state.fetchStatus===`paused`)?`failed`:n.some(e=>e.state.fetchStatus===`fetching`)?`refreshing`:`stale`},X_=(e,t)=>e.getQueryCache().subscribe(e=>{e.type===`updated`&&e.action.type===`error`&&K_(e.query.state,t)&&e.query.setState({status:`success`,error:null})}),Z_=()=>{let e=x().getQueryCache(),t=(0,j.useContext)(G_),n=(0,j.useCallback)(t=>e.subscribe(t),[e]),r=(0,j.useCallback)(()=>Y_(e.findAll({type:`active`}),t),[e,t]);return(0,j.useSyncExternalStore)(n,r,r)},Q_=(0,j.createContext)(null),$_=(0,j.createContext)(null),ev=(0,j.createContext)(null),X=()=>{let e=(0,j.useContext)(Q_);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},tv=e=>{let t=X();return(0,j.useContext)(ev)?.(e)??t},nv=()=>{let e=X(),t=(0,j.useContext)(ev);return(0,j.useCallback)(n=>t?.(n)??e,[e,t])},rv=()=>{let e=(0,j.useContext)($_);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},iv=({client:e,resourceClient:t,children:n})=>(0,L.jsx)(Q_.Provider,{value:e,children:(0,L.jsx)(ev.Provider,{value:t,children:n})}),av=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,persistence:s,children:c})=>{let[l]=(0,j.useState)(V_),[{queryClient:u,startedAt:d}]=(0,j.useState)(()=>{let e=i??new _({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:l.refetchOnWindowFocus}}});return s?.restore(e),{queryClient:e,startedAt:Date.now()}});(0,j.useEffect)(()=>s?.subscribe(u),[s,u]),(0,j.useEffect)(()=>s?X_(u,d):void 0,[s,u,d]),(0,j.useEffect)(()=>v.setEventListener(W_),[]);let f=(0,j.useRef)(void 0),p=(0,j.useMemo)(()=>t??Xf({baseUrl:e,fetch:r,token:a,onUnauthenticated:o,onMetaVersion:e=>{let t=f.current;f.current=e,t!==void 0&&t!==e&&(u.getQueryData(I.meta)?.versionChange||u.invalidateQueries({queryKey:I.meta},{cancelRefetch:!1}))}}),[t,e,r,u,a,o]),m=(0,j.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=Xf({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&u.invalidateQueries({queryKey:I.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,u]);return(0,L.jsx)(E,{client:u,children:(0,L.jsx)(Q_.Provider,{value:p,children:(0,L.jsx)($_.Provider,{value:m,children:(0,L.jsx)(H_.Provider,{value:l,children:(0,L.jsx)(G_.Provider,{value:d,children:c})})})})})},ov=(0,j.createContext)(null),sv={create:!0,update:!0,delete:!0,conditional:[]},cv=(e,t)=>e?e.versionChange?e:t.protobaseVersion===e.protobaseVersion?t:{...e,versionChange:{...t.protobaseVersion&&{to:t.protobaseVersion}}}:t,lv=()=>{let e=X(),t=x(),n=(0,j.useContext)(ov),r=(0,j.useContext)(G_),i=O({queryKey:I.meta,staleTime:0,refetchOnWindowFocus:`always`,enabled:e=>!e.state.data?.versionChange,queryFn:async()=>{let n=t.getQueryData(I.meta),i=await e.meta(n?.etag);if(i.status===`unchanged`){if(!n)throw Error(`The server answered 304 to a request without If-None-Match`);return n}let a=t.getQueryState(I.meta);return cv(a&&K_(a,r)?void 0:n,{etag:i.etag,appName:i.meta.appName,...i.meta.protobaseVersion&&{protobaseVersion:i.meta.protobaseVersion},...i.meta.appIcon&&{appIcon:i.meta.appIcon},resources:Object.fromEntries(i.meta.resources.map(e=>[e.name,e])),views:Object.fromEntries(i.meta.views.map(e=>[e.resource,e])),pages:Object.fromEntries((i.meta.pages??[]).map(e=>[e.name,e])),...i.meta.account&&{account:i.meta.account},permissions:i.meta.permissions??{},...i.meta.userMenu&&{userMenu:i.meta.userMenu},...i.meta.signIn&&{signIn:Object.fromEntries(i.meta.signIn.map(e=>[e.resource,e]))},...i.meta.bottomBar&&{bottomBar:i.meta.bottomBar},...i.meta.assistant&&{assistant:i.meta.assistant},...i.meta.runtime&&{runtime:i.meta.runtime},...i.meta.errorReporting&&{errorReporting:i.meta.errorReporting},...i.meta.maps&&{maps:i.meta.maps},...i.meta.notifications?.bell&&{bell:!0},...i.meta.status&&{status:!0},...i.meta.calls&&{calls:!0},...i.meta.relay&&{relay:i.meta.relay},...i.meta.locale&&{locale:i.meta.locale},...i.meta.texts&&{texts:i.meta.texts},...i.meta.files&&{files:i.meta.files},...i.meta.plugins&&{plugins:i.meta.plugins},...i.meta.sources&&{sources:i.meta.sources.map(e=>({source:e,state:`loading`}))}})}});return(0,j.useMemo)(()=>n&&i.data?{...i,data:n}:i,[n,i])},uv=1e4,dv=e=>e.map(e=>({data:e.data?.meta,error:e.error})),fv=(e,t)=>{let n=x(),r=ee({queries:e.map(e=>{let r=I.sourceMeta(e.url,e.resources);return{queryKey:r,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let i=n.getQueryData(r),a=await t(e).meta(i?.etag,{signal:AbortSignal.timeout(uv)});if(a.status===`unchanged`){if(!i)throw Error(`${e.label} answered 304 to a request without If-None-Match`);return i}return{etag:a.etag,meta:Lh(a.meta,e)}}}}),combine:dv});return(0,j.useMemo)(()=>e.map((e,t)=>{let{data:n,error:i}=r[t];return n?{source:e,state:`ready`,meta:n}:i?{source:e,state:`error`,error:i}:{source:e,state:`loading`}}),[e,r])},pv=(e,t)=>{if(t.length===0)return e;let n=t.flatMap(e=>e.state===`ready`?[e.meta]:[]),r=t.map(e=>e.state===`error`?{source:e.source,state:`error`,error:e.error}:{source:e.source,state:e.state});return{...e,resources:{...e.resources,...Object.fromEntries(n.flatMap(e=>e.resources.map(e=>[e.name,e])))},views:{...e.views,...Object.fromEntries(n.flatMap(e=>e.views.map(e=>[e.resource,e])))},permissions:{...e.permissions,...Object.assign({},...n.map(e=>e.permissions))},sources:r}},mv=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),hv=e=>{let t=0,n=!1,r=!1,i=()=>queueMicrotask(()=>{!n||r||t>0||(r=!0,e())});return{hold:()=>{t+=1;let e=!1;return()=>{e||(e=!0,--t,i())}},start:()=>{n=!0,i()}}},gv=(0,j.createContext)(void 0),_v=({value:e,children:t})=>(0,L.jsx)(gv.Provider,{value:e,children:t}),vv=()=>{let e=(0,j.useContext)(gv);return(0,j.useEffect)(()=>e?.hold(),[e]),null},yv=({locale:e,children:t})=>(Vi(e)||(0,j.use)(Hi(e)),t),bv=()=>(0,L.jsxs)(`div`,{role:`alert`,className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`The app did not load. Check your connection, then try again.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md border border-border-strong px-3 py-1.5 text-body font-medium hover:bg-muted`,onClick:()=>window.location.reload(),children:`Try again`})]}),xv=class extends j.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,L.jsx)(bv,{}):this.props.children}},Sv=({locale:e,children:t})=>(0,L.jsx)(xv,{children:(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(vv,{}),children:(0,L.jsx)(yv,{locale:e,children:t})})}),Cv=({locale:e,children:t})=>(0,L.jsx)(Sv,{locale:e??ji(),children:(0,L.jsx)(wv,{locale:e,children:t})}),wv=({locale:e,children:t})=>{Ni(e);let n=Ai();return(0,j.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,L.jsx)(j.Fragment,{children:t},n)},Tv=(0,j.createContext)(void 0),Ev=()=>(0,j.useContext)(Tv),Dv=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ov=(e,t)=>Oh(t,String(e.props.i18nKey),Dv(e.props.values)?e.props.values:{}),kv=(e,t)=>e.custom||!Object.values(e.props).some(kh)?e:{...e,props:Object.fromEntries(Object.entries(e.props).map(([e,n])=>[e,kh(n)?Ov(n,t):n]))},Av=(e,t)=>{let n=kv(e,t);if(e.custom||e.type!==`Tabs`)return n;let r=n.children.map(e=>typeof e==`string`?e:kv(e,t));return r.some((e,t)=>e!==n.children[t])?{...n,children:r}:n},jv=`app/built-in-views`,Mv=F(jv),Nv=(e,t)=>Object.hasOwn(Wi(Ai())[jv],e)?Mv(e):t,Pv=(e,t)=>({...t,...t.label!==void 0&&{label:Nv(`${e}.label`,t.label)},...t.help!==void 0&&{help:Nv(`${e}.help`,t.help)},...t.valueLabels&&{valueLabels:Object.fromEntries(Object.entries(t.valueLabels).map(([t,n])=>[t,Nv(`${e}.values.${t}`,n)]))}}),Fv=(e,t)=>{let n=t;return{...t,...n.title!==void 0&&{title:Nv(`${e}.title`,n.title)},...n.help!==void 0&&{help:Nv(`${e}.help`,n.help)},...n.empty!==void 0&&{empty:Nv(`${e}.empty`,n.empty)}}},Iv=e=>e.name===`record_history`&&e.table.name===`history`?`changes.history`:`${e.table.schema??`public`}.${e.table.name}`,Lv=(e,t)=>({...t,label:Nv(`${e}.label`,t.label),...t.confirm!==void 0&&{confirm:Nv(`${e}.confirm`,t.confirm)}}),Rv=(e,t)=>{if(!t)return e;let n=Iv(t);return{...e,...e.names&&{names:{singular:Nv(`${n}.names.singular`,e.names.singular),plural:Nv(`${n}.names.plural`,e.names.plural)}},...e.help!==void 0&&{help:Nv(`${n}.help`,e.help)},fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,Pv(`${n}.fields.${e}`,t)])),layout:e.layout.map((e,t)=>Fv(`${n}.layout.${t}`,e)),actions:e.actions.map(e=>Lv(`${n}.actions.${e.name}`,e))}},zv=e=>({...e,views:Object.fromEntries(Object.entries(e.views).map(([t,n])=>[t,Rv(n,e.resources[n.resource])]))}),Bv=F(`app/meta-gate`),Vv=()=>{let e=(0,j.useContext)(ov);if(!e)throw Error(`useAdminMeta must be used inside MetaGate`);return e},Hv=({title:e,children:t})=>(0,L.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,L.jsx)(`h1`,{className:`text-base font-semibold`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]})}),Uv=({meta:e,children:t})=>{let n=X(),r=rv(),i=(0,j.useMemo)(()=>(e.sources??[]).map(e=>e.source),[e.sources]),a=fv(i,r),o=(0,j.useMemo)(()=>pv(e,a),[e,a]),s=(0,j.useMemo)(()=>{let e=new Map(i.flatMap(e=>e.resources.map(t=>[t,e]))),t=t=>{let n=e.get(t);return n&&r(n)};return{client:Qf(n,t),resourceClient:t}},[i,n,r]);return(0,L.jsx)(iv,{client:s.client,resourceClient:s.resourceClient,children:(0,L.jsx)(Cv,{locale:e.locale,children:(0,L.jsx)(Tv.Provider,{value:e.texts,children:(0,L.jsx)(Wv,{meta:o,children:t})})})})},Wv=({meta:e,children:t})=>{let n=(0,j.useMemo)(()=>zv(e),[e]);return(0,L.jsx)(ov.Provider,{value:n,children:t})},Gv=({children:e})=>{let t=lv();return t.isPending?(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(vv,{}),(0,L.jsx)(fu,{}),` `,Bv(`loading`)]}):t.error?(0,L.jsx)(Hv,{title:Bv(`cannotReach`),children:Rd(t.error)?t.error.message:Bv(`noAnswer`)}):(0,L.jsx)(Uv,{meta:t.data,children:e})},Kv=e=>Vv().permissions[e]??sv,qv=(e,t)=>{let n=em(e,e=>e.custom?e:t.has(e.type)||(e.type===`Tab`||e.type===`Tabs`)&&e.children.length===0?null:e);if(!n)throw Error(`The account page keeps its Page, which no hidden block replaces`);return n},Jv=F(`auth/errors`),Yv={INVALID_EMAIL_OR_PASSWORD:`wrongEmailOrPassword`,INVALID_PASSWORD:`wrongPassword`,INVALID_OTP:`wrongOrExpiredCode`,OTP_EXPIRED:`codeExpired`,OTP_HAS_EXPIRED:`codeExpired`,TOO_MANY_ATTEMPTS:`tooManyCodes`,INVALID_CODE:`wrongCode`,INVALID_BACKUP_CODE:`wrongBackupCode`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`tooManyCodesSignIn`,ACCOUNT_TEMPORARILY_LOCKED:`locked`,INVALID_TWO_FACTOR_COOKIE:`tooSlow`,AUTH_CANCELLED:`passkeyClosed`,ERROR_CEREMONY_ABORTED:`passkeyClosed`,REGISTRATION_CANCELLED:`passkeyClosed`,PASSKEY_NOT_FOUND:`passkeyNotFound`,AUTHENTICATION_FAILED:`passkeyFailed`,PREVIOUSLY_REGISTERED:`passkeyAdded`,ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED:`passkeyAdded`,PASSWORD_COMPROMISED:`passwordLeaked`,EMAIL_DOMAIN_NOT_ALLOWED:`signUpDomainNotAllowed`,DEVICE_LINK_NOT_FOUND:`deviceLinkNotFound`},Xv=(e,t)=>{let n=t?e[t]:void 0;return n&&Jv(n)},Zv=e=>Xv(Yv,e.code),Qv=e=>Zv(e)??(e.status===429?Jv(`tooManyRequests`):e.message),$v=()=>Jv(`unreachable`),ey=e=>Zv(e)??(e.status===429?Jv(`tooManyRequests`):e.status===401?Jv(`wrongEmailOrPassword`):e.message),ty={STAFF_PERMISSION_MISSING:`staffPermissionMissing`,STAFF_SIGN_IN_NOT_STRONG:`staffNotStrong`,STAFF_SIGN_IN_STALE:`staffStale`,STAFF_SIGN_IN_EXPIRED:`staffExpired`,STAFF_SIGN_IN_FAILED:`staffProviderFailed`,STAFF_USER_UNAVAILABLE:`staffUserUnavailable`,STAFF_REASON_REQUIRED:`staffReasonRequired`,SIGN_IN_METHOD_FORBIDDEN:`staffForbidden`,INVALID_CALLBACK_URL:`untrustedCallback`},ny=e=>Xv(ty,typeof e==`string`?e:e.code)||(typeof e==`string`?Jv(`staffFailed`):e.status===429?Jv(`tooManyRequests`):e.message),ry={signup_disabled:e=>Jv(`signupDisabled`,{name:e}),account_not_linked:e=>Jv(`notLinked`,{name:e}),account_already_linked_to_different_user:e=>Jv(`linkedToOther`,{name:e}),unable_to_link_account:e=>Jv(`couldNotLink`,{name:e}),access_denied:e=>Jv(`accessDenied`,{name:e}),EMAIL_DOMAIN_NOT_ALLOWED:e=>Jv(`domainNotAllowed`,{name:e})},iy=(e,t)=>ry[e]?.(t)??Jv(`providerFailed`,{name:t}),ay=e=>{let t=e.slice(1),n=t.length===3?[...t].map(e=>e+e).join(``):t,[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a},oy=`#ffffff`,sy=`#111827`,cy=e=>{let t=ay(e);return 1.05/(t+.05)>=(t+.05)/(ay(sy)+.05)?oy:sy},ly={neutral:`bg-muted text-muted-foreground`,blue:`bg-primary-soft text-primary-text`,green:`bg-success-soft text-success-text`,amber:`bg-warning-soft text-warning-text`,red:`bg-danger-soft text-danger-text`,violet:`bg-violet-soft text-violet-text`},uy={neutral:`bg-faint-foreground`,blue:`bg-primary`,green:`bg-success`,amber:`bg-warning`,red:`bg-danger`,violet:`bg-violet`},dy=`polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%)`,fy=({tone:e=`neutral`,dot:t=!0,color:n,shape:r,children:i,className:a})=>(0,L.jsxs)(`span`,{style:{...n!==void 0&&{backgroundColor:n,color:cy(n)},...r===`arrow`&&{clipPath:dy}},className:R(r===`arrow`?`inline-flex h-5 items-center gap-1.5 rounded-l-sm pr-4 pl-2 text-xs font-semibold whitespace-nowrap`:`inline-flex h-5 items-center gap-1.5 rounded-full px-2 text-xs font-medium whitespace-nowrap`,n===void 0&&ly[e],a),children:[t&&n===void 0&&r===void 0&&(0,L.jsx)(`span`,{className:R(`size-1.5 rounded-full`,uy[e])}),i]}),py=({title:e,status:t,description:n,children:r})=>(0,L.jsxs)(`section`,{"aria-label":e,className:`rounded-lg border bg-background p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t]}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),r&&(0,L.jsx)(`div`,{className:`mt-4`,children:r})]}),my=({message:e})=>e?(0,L.jsx)(`p`,{role:`alert`,className:`mb-3 text-body font-medium text-danger-text`,children:e}):null,hy=({message:e})=>e?(0,L.jsx)(`p`,{role:`status`,className:`mb-3 font-medium`,children:e}):null,gy=({providers:e,linked:t,onConnect:n,error:r,reconnect:i=!1,notes:a={},title:o=Y(`connectedAccounts`),description:s=Y(`connectedAccountsDescription`),children:c})=>{let[l,u]=(0,j.useState)(),[d,f]=(0,j.useState)(r),p=async e=>{u(e),f(void 0);try{await n(e)}catch(e){if(!(e instanceof K))throw e;f(Qv(e)),u(void 0)}};return(0,L.jsxs)(py,{title:o,description:s,children:[(0,L.jsx)(my,{message:d}),(0,L.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,L.jsx)(oc,{className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),a[e.id]&&(0,L.jsx)(`span`,{className:`block text-muted-foreground`,children:a[e.id]})]}),t.includes(e.id)&&(0,L.jsx)(fy,{tone:`green`,children:Y(`connected`)}),(!t.includes(e.id)||i)&&(0,L.jsx)(B,{size:`sm`,loading:l===e.id,disabled:l!==void 0,onClick:()=>void p(e.id),children:Y(t.includes(e.id)?`connectAgain`:`connect`,{name:e.name})})]},e.id))}),c]})},_y=({error:e})=>e?(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:e}):(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Y(`loading`)]}),vy=(e,t)=>{let[n,r]=(0,j.useState)(),[i,a]=(0,j.useState)(),o=(0,j.useRef)(0),s=(0,j.useCallback)(()=>{let n=++o.current;return e().then(e=>{n===o.current&&(r({value:e}),a(void 0))},e=>{n===o.current&&a(e instanceof K?Qv(e):t)})},[e,t]);return(0,j.useEffect)(()=>{s()},[s]),{data:n?.value,loaded:n!==void 0,error:i,reload:s}},yy=()=>{let e=l_(window.location.href);return e&&window.history.replaceState(window.history.state,``,f_(window.location.href)),e},by=({providers:e})=>{let{session:t,linkProvider:n}=J(),{account:r}=t,[i]=(0,j.useState)(yy),{data:a,error:o}=vy((0,j.useCallback)(()=>r.linkedProviders(),[r]),Y(`couldNotReadMethods`));return a?(0,L.jsx)(gy,{providers:e,linked:a,onConnect:n,error:i&&iy(i,e.length===1?e[0].name:Y(`theProvider`))}):(0,L.jsx)(_y,{error:o})},xy=({signInProviders:e,socialProviders:t,platformProviders:n})=>e.filter(e=>t.includes(e.id)&&!n.some(t=>t.provider===e.id&&t.hidden)),Sy=()=>{let e=xy(J());return e.length>0?(0,L.jsx)(by,{providers:e}):null},Cy=()=>{let{account:e}=Vv(),t=J(),{mcp:n,personalAccessTokens:r,accountDeletion:i}=t,a=xy(t).length>0,o=t.personalMail.length>0;return(0,j.useMemo)(()=>{if(!e)return;let t=new Set([...n?[]:[`ConnectedApps`],...r?[]:[`PersonalAccessTokens`],...a?[]:[`ConnectedAccounts`],...o?[]:[`PersonalMail`],...i?[]:[`DeleteAccount`]]);return{...e,tree:qv(e.tree,t)}},[e,n,r,a,o,i])},wy=e=>(0,j.useSyncExternalStore)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>window.matchMedia(e).matches,()=>!1),Ty=()=>wy(`(min-width: 768px)`),Ey=()=>wy(`not all and (min-width: 640px)`),Dy=`ProtobaseTabBar`,Oy=(e,t)=>{let n=typeof e==`object`&&e?e[t]:void 0;return typeof n==`number`&&Number.isFinite(n)?n:void 0},ky=e=>{if(!e?.isPluginAvailable(`ProtobaseTabBar`))return;let t=(t,n,r,i)=>{let a=e.addListener(Dy,t,e=>{let t=Oy(e,n);t!==void 0&&r(t)&&i(t)});return()=>void a.remove()};return{set:async t=>{let n=Oy(await e.nativePromise(Dy,`set`,t),`height`);return n!==void 0&&n>=0?{height:n}:{}},onTap:e=>t(`tap`,`index`,Number.isInteger,e),onHeight:e=>t(`height`,`height`,e=>e>=0,e)}},Ay=(e,t,n,r)=>({visible:!0,tabs:e.map((e,n)=>({label:e,icon:t[n]??null,...n===r&&{search:!0}})),selected:n>=0&&n<e.length?n:null}),jy=(0,j.createContext)(void 0),My=()=>(0,j.useContext)(jy),Ny=new Map,Py=72,Fy=e=>{if(!e)return Promise.resolve(null);let t=e.cloneNode(!0);t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),t.setAttribute(`width`,`24`),t.setAttribute(`height`,`24`),t.removeAttribute(`class`);let n=new XMLSerializer().serializeToString(t).replaceAll(`currentColor`,`#000`),r=Ny.get(n);return r||(r=new Promise(e=>{let t=new Image;t.onload=()=>{let n=document.createElement(`canvas`);n.width=Py,n.height=Py;let r=n.getContext(`2d`);if(!r)return e(null);r.drawImage(t,0,0,Py,Py),e(n.toDataURL(`image/png`))},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}),Ny.set(n,r)),r},Iy=(e,t,n,r,i=[])=>{let a=My(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(),u=JSON.stringify({labels:t,selected:n,search:r,icons:i}),d=(0,j.useRef)(void 0),f=(0,j.useRef)(u);f.current=u,(0,j.useEffect)(()=>{let i=e.current;if(!a||!i)return;let o=!0,c=[...i.children].map(e=>Fy(e.querySelector(`svg`)));return Promise.all(c).then(e=>{o&&a.set(Ay(t,e,n,r)).then(e=>{o&&(d.current=u,s(!1),e.height!==void 0&&l(e.height))},()=>o&&s(!0))}),()=>{o=!1}},[a,u]),(0,j.useEffect)(()=>{if(a)return()=>void a.set({visible:!1})},[a]);let p=(0,j.useRef)(e);return p.current=e,(0,j.useEffect)(()=>a?.onTap(e=>{d.current===f.current&&(p.current.current?.children[e])?.click()}),[a]),(0,j.useEffect)(()=>a?.onHeight(l),[a]),{native:!!a&&!o,height:c}},Ly=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Ry=`flex min-h-[49px] min-w-0 flex-1 flex-col items-center justify-center gap-1 pb-1 pt-1.5 text-[0.625rem] font-medium leading-none`,zy=({tabs:e,onNavigate:t,onSearch:n,searchLabel:r,onMore:i,moreOpen:a,moreControls:o,sticky:s,ref:c})=>{let l=!e.some(e=>e.active),u=(0,j.useRef)(null);(0,j.useImperativeHandle)(c,()=>u.current);let d=[...e.map(e=>e.label),...n?[r??V(`search`)]:[],V(`more`)],f=d.length-1,p=e.map(e=>e.icon.displayName??e.icon.name),{native:m,height:h}=Iy(u,d,l?f:e.findIndex(e=>e.active),n?e.length:void 0,p);return(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-bottom)] shrink-0 md:hidden`}),(0,L.jsxs)(`nav`,{ref:u,"aria-label":V(`tabs`),"aria-hidden":m||void 0,className:R(`flex shrink-0 border-t bg-background pb-[var(--pb-safe-bottom)] md:hidden`,s&&`fixed bottom-0 left-[var(--pb-safe-left)] right-[var(--pb-safe-right)] z-30`,m&&`invisible`),style:m&&h!==void 0?{height:h}:void 0,children:[e.map(e=>{let n=e.icon;return(0,L.jsxs)(`a`,{href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:n=>{!e.external&&t&&Ly(n)&&(n.preventDefault(),t(e.href))},className:R(Ry,e.active?`text-primary-text`:`text-muted-foreground`),children:[(0,L.jsx)(n,{className:`size-6`,strokeWidth:e.active?2.2:1.9,"aria-hidden":!0}),(0,L.jsx)(`span`,{className:`max-w-full truncate px-0.5`,children:e.label})]},e.id)}),n&&(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:R(Ry,`text-muted-foreground`),children:[(0,L.jsx)(ul,{className:`size-6`,strokeWidth:1.9,"aria-hidden":!0}),r??V(`search`)]}),(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":o,"data-current":l||void 0,onClick:i,className:R(Ry,l?`text-primary-text`:`text-muted-foreground`),children:[(0,L.jsx)(As,{className:`size-6`,strokeWidth:l?2.2:1.9,"aria-hidden":!0}),V(`more`)]})]})]})},By=`protobase:close-sidebar`,Vy=e=>{(0,j.useEffect)(()=>(window.addEventListener(By,e),()=>window.removeEventListener(By,e)),[e])},Hy=.35,Uy=`cubic-bezier(0.25, 1, 0.5, 1)`,Wy=(e,t)=>Math.abs(t)>=500?t>0:e>=.5,Gy=e=>e>0?40*(1-1/(.55*e/40+1)):0,Ky=e=>Hy*Math.min(Math.max(e,0),1),qy=(e,t,n)=>e!==0&&Math.abs(t)<=n*Math.abs(e),Jy=(e,t,n)=>Math.hypot(e,t)>=10&&qy(e,t,n),Yy=(e,t,n)=>{let r=e+t/Math.max(1,n);return r<=1?Math.max(r,0):1+Gy((r-1)*n)/Math.max(1,n)},Xy=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Zy=(e,t,n)=>e===`x`?t:-n,Qy=(e,t,n)=>e===`x`?n:t,$y=e=>{let t=e.at(-1);if(!t)return 0;let n=e.find(e=>t.time-e.time<=100)??t,r=t.time-n.time;return r>0?(t.along-n.along)/r*1e3:0},eb=({axis:e,panel:t,backdrop:n,onDraggedClosed:r})=>{let i=(0,j.useRef)(void 0),a=(0,j.useRef)(!1),o=(0,j.useRef)(void 0),s=()=>clearTimeout(o.current);(0,j.useEffect)(()=>()=>clearTimeout(o.current),[]);let c=()=>{let n=t.current;return n?e===`x`?n.offsetWidth:n.offsetHeight:1},l=(r,i)=>{let a=t.current;if(!a)return;let o=i&&!Xy()?`350ms ${Uy}`:`none`,s=(r-1)*c();a.style.transition=o===`none`?`none`:`transform ${o}`,a.style.transform=r===1?``:e===`x`?`translateX(${s}px)`:`translateY(${-s}px)`;let l=n.current;l&&(l.style.transition=o===`none`?`none`:`opacity ${o}`,l.style.opacity=String(Ky(r)/Hy))},u=(e,t)=>{if(s(),Wy(Math.min(e,1),t))return l(1,!0);l(0,!0),o.current=setTimeout(r,Xy()?0:350)},d=t=>({onPointerDown:e=>{e.pointerType!==`mouse`&&(a.current=!1,i.current={x:e.clientX,y:e.clientY,from:1,along:0,dragging:!1,onBackdrop:t,samples:[],ignored:!1})},onPointerMove:t=>{let n=i.current;if(!n||n.ignored)return;let r=t.clientX-n.x,a=t.clientY-n.y,o=Zy(e,r,a);if(!n.dragging){let i=Qy(e,r,a);if(Math.hypot(o,i)<10)return;if(!Jy(o,i,n.onBackdrop?1:.58)){n.ignored=!0;return}n.dragging=!0,s(),n.x=t.clientX,n.y=t.clientY,t.currentTarget.setPointerCapture?.(t.pointerId);return}n.along=o,n.samples.push({along:o,time:t.timeStamp}),l(Yy(n.from,o,c()),!1)},onPointerUp:()=>{let e=i.current;i.current=void 0,e?.dragging&&(a.current=!0,u(Yy(e.from,e.along,c()),$y(e.samples)))},onPointerCancel:()=>{i.current?.dragging&&l(1,!0),i.current=void 0}});return{panelHandlers:d(!1),backdropHandlers:d(!0),dragged:()=>a.current,follow:e=>{s(),l(e,!1)},settle:u}},tb=({id:e,open:t,onClose:n,children:r,underFinger:i,control:a})=>{let o=(0,j.useRef)(null),s=(0,j.useRef)(null);(0,j.useLayoutEffect)(()=>{if(!t)return;let e=document.activeElement;e instanceof HTMLElement&&e.matches(`input, textarea, select, [contenteditable]`)&&e.blur()},[t]),bu(o,t,n);let c=(0,j.useRef)(!1),{panelHandlers:l,backdropHandlers:u,dragged:d,follow:f,settle:p}=eb({axis:`x`,panel:o,backdrop:s,onDraggedClosed:()=>{c.current=!0,n()}});(0,j.useLayoutEffect)(()=>{if(a&&t)return a.current={follow:f,settle:p},()=>{a.current=null}});let[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(t);return t!==g&&(_(t),h(!t&&!c.current),t&&(c.current=!1)),(0,j.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(!1),200);return()=>clearTimeout(e)},[m]),!t&&!m?null:(0,L.jsxs)(`div`,{className:R(`fixed inset-0 z-50 md:hidden`,m&&`pointer-events-none`),children:[(0,L.jsx)(`div`,{ref:s,className:R(`absolute inset-0 touch-none bg-backdrop/40 motion-reduce:[animation:none]`,m?`[animation:pb-fade-out_200ms_ease-in_forwards]`:!i&&`[animation:pb-fade-in_200ms_ease-out]`),style:i&&!m?{opacity:0}:void 0,onClick:()=>!d()&&n(),...u,"aria-hidden":!0}),(0,L.jsx)(`div`,{ref:o,id:e,role:`dialog`,"aria-modal":`true`,"aria-label":V(`navigation`),"aria-hidden":m||void 0,tabIndex:-1,className:R(`absolute inset-y-0 left-0 flex w-[min(88vw,384px)] touch-pan-y bg-sidebar pl-[var(--pb-safe-left)] shadow-pop outline-none motion-reduce:[animation:none] before:absolute before:inset-y-0 before:right-full before:w-10 before:bg-sidebar`,m?`[animation:pb-drawer-out_200ms_ease-in_forwards]`:!i&&`[animation:pb-drawer-in_200ms_ease-out]`),style:i&&!m?{transform:`translateX(-100%)`}:void 0,onClick:e=>e.target.closest(`a`)&&n(),...l,children:r})]})},nb=e=>{let t=e.at(-1),n=typeof t==`object`&&!!t.above,r=n?t:e.slice(0,-1).findLast(e=>typeof e==`object`&&!!e.href);if(typeof r==`object`&&r.href&&!r.loading)return{label:r.label,href:r.href,shown:n}},rb=({desktop:e,back:t,bottomBar:n,drawerOpen:r})=>e?`none`:t?`back`:!n&&!r?`sidebar`:`none`,ib=`ProtobaseEdgeSwipe`,ab=(e,{nativeBack:t,behindIsBack:n})=>e===`back`?t&&n?`back`:`page`:e,ob=e=>{if(e?.isPluginAvailable(`ProtobaseEdgeSwipe`))return{set:t=>e.nativePromise(ib,`set`,{action:t})}},sb=(0,j.createContext)(void 0),cb=()=>!!(0,j.useContext)(sb),lb=(e,t)=>{let n=(0,j.useContext)(sb);(0,j.useEffect)(()=>{n?.set(e).catch(()=>void 0)},[n,e,t])},ub=120,db=e=>{let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;left:0;top:${e-22}px;z-index:90;width:44px;height:44px;border-radius:9999px;display:flex;align-items:center;justify-content:center;background:var(--background);color:var(--foreground);box-shadow:var(--shadow-pop);pointer-events:none;transform:translateX(-48px);opacity:0`,t.innerHTML=`<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m15 18-6-6 6-6"/></svg>`,document.body.append(t),t},fb=(e,t,n)=>{let r=Math.min(t,1.15);e.style.transition=n&&!pb()?`transform 350ms ${Uy}, opacity 350ms`:`none`,e.style.transform=`translateX(${-48+r*64}px) scale(${.8+.2*Math.min(t,1)})`,e.style.opacity=String(Math.min(t*1.5,1))},pb=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,mb=(e,t)=>{let n=e.at(-1);if(!n)return 0;let r=e.find(e=>t-e.time<=100)??n,i=n.time-r.time;return i>0?(n.dx-r.dx)/i*1e3:0},hb=({action:e,onBack:t,openDrawer:n,closeDrawer:r,drawer:i})=>{let a=e===`sidebar`?`sidebar`:e===`page`?`back`:`none`,o=(0,j.useRef)({action:a,onBack:t,openDrawer:n,closeDrawer:r});o.current={action:a,onBack:t,openDrawer:n,closeDrawer:r},(0,j.useEffect)(()=>{let e,t=()=>window.innerWidth,n=(e,t)=>i.current?i.current.settle(e,t):o.current.closeDrawer(),r=e=>{fb(e,0,!0),setTimeout(()=>e.remove(),pb()?0:350)},a=()=>{let t=e;e=void 0,t?.dragging&&(t.action===`sidebar`?n(0,0):t.mark&&r(t.mark))},s=t=>{let n=t.touches[0],r=o.current.action;a(),e=r!==`none`&&t.touches.length===1&&n&&n.clientX<=24?{action:r,x:n.clientX,y:n.clientY,dragging:!1,dx:0,samples:[]}:void 0},c=n=>{let r=n.touches[0];if(!e||!r)return;let a=r.clientX-e.x,s=r.clientY-e.y;if(!e.dragging){if(Math.hypot(a,s)<10)return;if(a<=0||!Jy(a,s,.58)){e=void 0;return}e.dragging=!0,e.x=r.clientX,e.action===`sidebar`?o.current.openDrawer():e.mark=db(r.clientY);return}e.dx=Math.max(0,a),e.samples.push({dx:e.dx,time:n.timeStamp}),e.action===`sidebar`?i.current?.follow(e.dx/Math.min(t()*.88,384)):e.mark&&fb(e.mark,e.dx/ub,!1)},l=i=>{let a=e;if(e=void 0,!a?.dragging)return;let s=mb(a.samples,i.timeStamp);if(a.action===`sidebar`)return n(a.dx/Math.min(t()*.88,384),s);let c=a.mark;c&&(Wy(a.dx/ub,s)&&o.current.onBack(),r(c))};return document.addEventListener(`touchstart`,s,{passive:!0}),document.addEventListener(`touchmove`,c,{passive:!0}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,a),()=>{a(),document.removeEventListener(`touchstart`,s),document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,a)}},[i])},gb=(0,j.createContext)(()=>{}),_b=e=>{let t=(0,j.useContext)(gb);(0,j.useLayoutEffect)(()=>(t(e),()=>t(void 0)),[t,e])},vb=e=>{(0,j.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`scrollbar-gutter`,`stable`),()=>{t.style.removeProperty(`scrollbar-gutter`)}},[e])},yb=[`--pb-sticky-top`,`--pb-sticky-bottom`,`scroll-padding-top`,`scroll-padding-bottom`],bb=(e,t,n,r,i=!0)=>{(0,j.useLayoutEffect)(()=>{if(!e)return;let r=document.documentElement,i=()=>{let e=`${t.current?.offsetHeight??0}px`,i=n.current?`${n.current.offsetHeight}px`:`var(--pb-safe-bottom)`;r.style.setProperty(`--pb-sticky-top`,e),r.style.setProperty(`--pb-sticky-bottom`,i),r.style.setProperty(`scroll-padding-top`,e),r.style.setProperty(`scroll-padding-bottom`,i)},a=new ResizeObserver(i);for(let e of[t.current,n.current])e&&a.observe(e);return i(),()=>{a.disconnect();for(let e of yb)r.style.removeProperty(e)}},[e,t,n,r,i])},xb=`flex min-w-0 items-center gap-2.5`,Sb={xs:`size-5 text-[0.5625rem]`,sm:`size-6 text-[0.625rem]`,md:`size-8 text-xs`,lg:`size-10 text-base`,bar:`size-[min(2rem,max(32px,9vw))] text-[min(0.75rem,max(12px,3.4vw))]`},Cb=({initials:e,hue:t,size:n=`sm`,className:r})=>(0,L.jsx)(`span`,{className:R(`inline-flex shrink-0 select-none items-center justify-center rounded-full font-semibold text-white`,Sb[n],r),style:{background:`oklch(0.58 0.13 ${t})`},children:e}),wb=({people:e,size:t=`sm`})=>(0,L.jsx)(`span`,{className:`inline-flex -space-x-1`,children:e.map(e=>(0,L.jsx)(Cb,{...e,size:t,className:`ring-2 ring-background`},e.initials))}),Tb=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),Eb=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),Db=`fill-[#ff5a1f] dark:fill-[#ff6a33]`,Ob=`fill-[#14161a] dark:fill-[#f1f0ea]`,kb=({className:e})=>(0,L.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:R(`size-7 shrink-0`,e),"aria-hidden":!0,children:[(0,L.jsx)(`path`,{className:Db,fillRule:`evenodd`,d:`M0 5a5 5 0 0 1 5-5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zM4 5a1 1 0 0 1 1-1h5v6H4z`}),(0,L.jsx)(`path`,{className:Ob,d:`M17 0h10a5 5 0 0 1 5 5v22a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V17h17z`})]}),Ab={sm:`size-7`,lg:`size-10`},jb={sm:`md`,lg:`lg`},Mb=({appName:e,appIcon:t,size:n=`sm`,className:r})=>t?(0,L.jsx)(`img`,{src:t,alt:``,className:R(Ab[n],`shrink-0 object-contain`,r)}):e&&e!==`Protobase`?(0,L.jsx)(Cb,{initials:Eb(e).slice(0,1),hue:Tb(e),size:jb[n],className:r}):(0,L.jsx)(kb,{className:R(Ab[n],r)}),Nb=`M312.3 9.9Q257 9.9 217.1 -21.1Q177.3 -52.1 168.4 -108.8L181.1 -110.3V205H54.8V-510H176.7V-404.5L168.3 -407Q179.7 -460.8 221.2 -490.4Q262.7 -520 319.8 -520Q376.2 -520 417 -488.4Q457.8 -456.8 479.8 -398.6Q501.8 -340.5 501.8 -259.9Q501.8 -177.6 478.3 -116.8Q454.9 -55.9 412.5 -23Q370.1 9.9 312.3 9.9ZM274.4 -92.6Q320.2 -92.6 345.8 -133.8Q371.4 -175.1 371.4 -256.4Q371.4 -337.7 345.7 -377.6Q320.1 -417.5 274 -417.5Q228.6 -417.5 202.7 -376.4Q176.9 -335.3 176.9 -254Q176.9 -173.3 202.7 -132.9Q228.4 -92.6 274.4 -92.6Z M549.8 0V-510H671.7V-388.3H676.1V0H549.8ZM676.1 -286.5 661.3 -386.2Q677.9 -455.2 711.8 -487.6Q745.7 -520 794.3 -520Q809 -520 818 -516.6V-394.2Q814.2 -395.6 807.1 -396.1Q800 -396.6 789.4 -396.6Q734.6 -396.6 705.3 -370.5Q676.1 -344.4 676.1 -286.5Z M1043.8 10Q974.7 10 922.6 -23.6Q870.6 -57.2 842.1 -117.5Q813.6 -177.8 813.6 -257Q813.6 -336.5 842.2 -395.5Q870.8 -454.5 922.5 -487.2Q974.2 -520 1043.8 -520Q1113.7 -520 1165.4 -487.2Q1217.1 -454.5 1245.6 -395.5Q1274 -336.5 1274 -257Q1274 -177.8 1245.5 -117.5Q1217 -57.2 1165.3 -23.6Q1113.6 10 1043.8 10ZM1043.8 -90.5Q1073.5 -90.5 1095.9 -108.9Q1118.2 -127.3 1130.9 -164.4Q1143.6 -201.5 1143.6 -257.5Q1143.6 -339.8 1116 -379.7Q1088.4 -419.5 1043.8 -419.5Q999.3 -419.5 971.6 -379.5Q944 -339.5 944 -257.5Q944 -201.5 956.7 -164.4Q969.4 -127.3 991.8 -108.9Q1014.3 -90.5 1043.8 -90.5Z M1509 10.2Q1427.2 10.2 1387.6 -29.2Q1348 -68.6 1348 -147.7V-613.8L1474.2 -666.1V-146.7Q1474.2 -118.4 1489.9 -104.3Q1505.6 -90.3 1539.2 -90.3Q1552 -90.3 1562.7 -92.5Q1573.3 -94.8 1582.5 -98.7V-1.9Q1571.6 4 1552 7.1Q1532.4 10.2 1509 10.2ZM1270.1 -411V-510H1580.6V-411H1270.1Z M1810.8 10Q1741.7 10 1689.6 -23.6Q1637.6 -57.2 1609.1 -117.5Q1580.6 -177.8 1580.6 -257Q1580.6 -336.5 1609.2 -395.5Q1637.8 -454.5 1689.5 -487.2Q1741.2 -520 1810.8 -520Q1880.7 -520 1932.4 -487.2Q1984.1 -454.5 2012.6 -395.5Q2041 -336.5 2041 -257Q2041 -177.8 2012.5 -117.5Q1984 -57.2 1932.3 -23.6Q1880.6 10 1810.8 10ZM1810.8 -90.5Q1840.5 -90.5 1862.9 -108.9Q1885.2 -127.3 1897.9 -164.4Q1910.6 -201.5 1910.6 -257.5Q1910.6 -339.8 1883 -379.7Q1855.4 -419.5 1810.8 -419.5Q1766.3 -419.5 1738.6 -379.5Q1711 -339.5 1711 -257.5Q1711 -201.5 1723.7 -164.4Q1736.4 -127.3 1758.8 -108.9Q1781.3 -90.5 1810.8 -90.5Z M2343.3 9.9Q2288 9.9 2247.7 -21.1Q2207.4 -52.1 2198.5 -108.8L2205.8 -110.3V0H2085.8V-720H2212.1V-404.5L2203.7 -407Q2215.1 -460.8 2255.6 -490.4Q2296.2 -520 2351 -520Q2407.3 -520 2448 -488.4Q2488.8 -456.8 2510.8 -398.6Q2532.8 -340.5 2532.8 -259.9Q2532.8 -177.6 2509.3 -116.8Q2485.9 -55.9 2443.5 -23Q2401.1 9.9 2343.3 9.9ZM2305.4 -92.6Q2350.7 -92.6 2376.6 -133.8Q2402.4 -175.1 2402.4 -256.4Q2402.4 -337.7 2376.5 -377.6Q2350.6 -417.5 2305 -417.5Q2260.5 -417.5 2234.2 -376.4Q2207.9 -335.3 2207.9 -254Q2207.9 -173.3 2234.1 -132.9Q2260.3 -92.6 2305.4 -92.6Z M2834 0Q2828 -19.1 2825.7 -41.7Q2823.3 -64.2 2823.3 -91.8H2818.6V-356Q2818.6 -391.9 2803.1 -409.1Q2787.5 -426.3 2756.2 -426.3Q2724.2 -426.3 2706.4 -408.7Q2688.7 -391.2 2686.3 -358.9H2571.2Q2574.6 -429.6 2625.4 -474.8Q2676.1 -520 2763.5 -520Q2850.2 -520 2896.1 -476.5Q2941.9 -432.9 2941.9 -352.2V-91.8Q2941.9 -69.5 2944.7 -46.7Q2947.5 -23.8 2954.1 0H2834ZM2690.6 10Q2631.9 10 2595.4 -26.3Q2558.9 -62.5 2558.9 -124.5Q2558.9 -185 2594.3 -224Q2629.8 -263 2704.5 -287.6L2845.4 -337.4V-248.7L2753.4 -219.3Q2716.5 -206.1 2699.3 -186.6Q2682.2 -167.2 2682.2 -139Q2682.2 -112.4 2697.5 -98.4Q2712.9 -84.3 2739.4 -84.3Q2773.2 -84.3 2795.9 -104.1Q2818.6 -123.9 2818.6 -153.1L2829.9 -85.8Q2812.6 -37.4 2776.8 -13.7Q2741 10 2690.6 10Z M3168 10Q3080.6 10 3030.1 -34.2Q2979.6 -78.4 2974.7 -158.1H3082.4Q3086.3 -120 3108.9 -100.5Q3131.5 -80.9 3169.8 -80.9Q3202 -80.9 3218.9 -93.9Q3235.8 -106.9 3235.8 -131.3Q3235.8 -151.1 3224.3 -165.6Q3212.9 -180.1 3178.9 -195.4L3111.2 -224.8Q3053 -247.7 3023.8 -284.2Q2994.5 -320.8 2994.5 -373.9Q2994.5 -440.1 3040.1 -480Q3085.7 -520 3162.8 -520Q3242.2 -520 3288.4 -480Q3334.6 -440 3339.5 -367.9H3231.8Q3228.6 -399.7 3211.3 -414.4Q3194 -429.1 3164 -429.1Q3136.1 -429.1 3120.5 -417Q3104.8 -405 3104.8 -382.7Q3104.8 -364.2 3117.7 -349.8Q3130.6 -335.5 3162.4 -321.6L3236.6 -289.6Q3288.6 -269.2 3317.4 -229.2Q3346.1 -189.1 3346.1 -136.9Q3346.1 -69 3299.2 -29.5Q3252.3 10 3168 10Z M3587.8 10Q3520 10 3469.2 -23.3Q3418.5 -56.6 3390.5 -116.5Q3362.6 -176.3 3362.6 -255.8Q3362.6 -336.4 3390.9 -395.7Q3419.3 -454.9 3470.7 -487.5Q3522 -520 3591.1 -520Q3656.6 -520 3702.7 -489.8Q3748.8 -459.7 3773.7 -403.1Q3798.6 -346.5 3798.6 -266.5Q3798.6 -253.7 3798 -242.5Q3797.5 -231.3 3795.8 -221.4H3440V-306.9H3709L3681.8 -277.9Q3681.6 -355.2 3657.7 -390.7Q3633.8 -426.3 3589.3 -426.3Q3541.7 -426.3 3515.6 -384Q3489.5 -341.7 3489.5 -255Q3489.5 -168.4 3515 -126.1Q3540.5 -83.7 3590.6 -83.7Q3623.7 -83.7 3644.6 -102Q3665.5 -120.3 3673.8 -156.3H3788.9Q3772.2 -81.6 3721.5 -35.8Q3670.8 10 3587.8 10Z`,Pb=({className:e})=>(0,L.jsx)(`svg`,{viewBox:`54.8 -720 3743.8 925`,className:R(`h-3.5 w-auto`,e),role:`img`,"aria-label":`Protobase`,children:(0,L.jsx)(`path`,{className:Ob,d:Nb})}),Fb=({compact:e,workspace:t,appName:n,appIcon:r})=>(0,L.jsxs)(`div`,{className:xb,children:[(0,L.jsx)(Mb,{appName:n,appIcon:r}),!e&&(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 leading-tight`,children:[r||n&&n!==`Protobase`?(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:n??`Protobase`}):(0,L.jsx)(Pb,{className:`self-start`}),t&&(0,L.jsx)(`div`,{className:`truncate text-[0.6875rem] text-muted-foreground`,children:t})]})]}),Ib=`protobase:logo-tap`,Lb=(e=window)=>{let t=!e.dispatchEvent(new Event(Ib,{cancelable:!0}));return e.parent&&e.parent!==e&&e.parent.postMessage({type:Ib},`*`),t},Rb=`bg-primary border-transparent`,zb=e=>{let[t=255,n=255,r=255]=(e.match(/\d+(\.\d+)?/g)??[]).map(Number);return .299*t+.587*n+.114*r<150?`DARK`:`LIGHT`},Bb=(0,j.createContext)(void 0),Vb=()=>{let e=(0,j.useContext)(Bb);return e?{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}:{}},Hb=({leading:e,trailing:t,invalid:n,className:r,wrapperClassName:i,...a})=>{let o=Vb();return(0,L.jsxs)(`span`,{className:R(`flex h-8 items-center gap-2 rounded-md border bg-background px-2.5 text-muted-foreground shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,n?`border-danger`:`border-border-strong`,i),children:[e,(0,L.jsx)(`input`,{className:R(`min-w-0 flex-1 bg-transparent text-body text-foreground outline-none placeholder:text-faint-foreground`,r),...o,...n&&{"aria-invalid":!0},...a}),t]})},Ub=({children:e})=>(0,L.jsx)(`kbd`,{className:`inline-flex h-5 items-center rounded border border-border-strong bg-background px-1.5 font-sans text-[0.6875rem] font-medium text-muted-foreground`,children:e}),Wb=(e,t,n)=>Math.min(n-4,Math.max(e,4+t)),Gb=e=>e-8,Kb=(e,t,n)=>{let[r,i]=(0,j.useState)();return(0,j.useLayoutEffect)(()=>{if(!e||!t.current||!n.current){i(void 0);return}let r=document.documentElement.clientWidth,a=Gb(r);n.current.style.maxWidth=`${a}px`;let o=t.current.getBoundingClientRect().right,s=n.current.getBoundingClientRect().width;i({right:o-Wb(o,s,r),maxWidth:a})},[e]),r},qb=()=>{let e=window.visualViewport;return e?{top:e.offsetTop,height:e.height}:{top:0,height:window.innerHeight}},Jb=(e,t,n,r)=>{let i=r.top+r.height-4-e.bottom,a=e.top-r.top-4;return n+t>i&&a>i},Yb=(e,t,n,r)=>{let[i,a]=(0,j.useState)(),[o,s]=(0,j.useState)(0);return(0,j.useEffect)(()=>{let t=window.visualViewport;if(!e||!t)return;let n=()=>s(e=>e+1);return t.addEventListener(`resize`,n),()=>t.removeEventListener(`resize`,n)},[e]),(0,j.useLayoutEffect)(()=>{if(!e||!t.current||!n.current){a(void 0);return}let r=t.current.getBoundingClientRect(),i=n.current.getBoundingClientRect().height,o=parseFloat(getComputedStyle(n.current).marginTop);a(Jb(r,i,o,qb())?-(i+2*o):void 0)},[e,r,o]),i===void 0?void 0:{top:i}},Xb=(e,t,n)=>t===0?-1:e<0?n===1?0:t-1:(e+n+t)%t,Zb=e=>e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0,Qb=({search:e,className:t=`w-96`,fieldClassName:n,autoFocus:r,showShortcut:i=!0,inline:a,ref:o})=>{let s=(0,j.useId)(),c=(0,j.useRef)(null),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(-1),p=e.groups.flatMap(e=>e.hits),m=(l||!!a)&&(e.query!==``||e.loading),h=e=>`${s}-${e}`,g=(0,j.useRef)(null),_=(0,j.useRef)(null),v=Kb(m,g,_),y=Yb(m,g,_,`${v?.right} ${e.loading} ${p.length} ${e.groups.length}`),b=e=>{c.current=e,typeof o==`function`?o(e):o&&(o.current=e)},x=t=>{e.onSelect(t),f(-1),c.current?.blur()},S=()=>{e.onTextChange(``),f(-1),c.current?.focus()},C=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`)t.preventDefault(),f(e=>Xb(e,p.length,t.key===`ArrowDown`?1:-1));else if(t.key===`Enter`){let e=p[d]??p[0];if(!e)return;t.preventDefault(),x(e.href)}else t.key===`Escape`&&(e.text?e.onTextChange(``):t.currentTarget.blur(),f(-1))},w=-1;return(0,L.jsxs)(`div`,{ref:g,className:R(`relative`,t),children:[(0,L.jsx)(Hb,{ref:b,wrapperClassName:R(`w-full bg-surface shadow-none`,n),leading:e.loading?(0,L.jsx)(fu,{className:`size-4`}):(0,L.jsx)(ul,{className:`size-4`}),trailing:e.text?(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`clearSearch`),className:`-mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,onMouseDown:e=>e.preventDefault(),onClick:S,children:(0,L.jsx)(uu,{className:`size-3.5`})}):i?(0,L.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,L.jsx)(Ub,{children:`⌘K`})}):void 0,placeholder:e.placeholder,"aria-label":V(`globalSearch`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":m,"aria-controls":s,"aria-activedescendant":m&&p[d]?h(d):void 0,autoFocus:r,value:e.text,onChange:t=>{e.onTextChange(t.target.value),f(-1)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:C}),m&&(0,L.jsxs)(`div`,{ref:_,id:s,role:`listbox`,"aria-label":V(`searchResults`),style:a?void 0:{...v,...y},className:a?`mt-2 py-1`:`absolute right-0 top-full z-40 mt-1 max-h-96 w-full min-w-72 overflow-y-auto rounded-lg border bg-background py-1 shadow-pop`,children:[e.groups.length===0&&(0,L.jsx)(`p`,{className:`px-3 py-2 text-muted-foreground`,children:e.loading?V(`searching`):V(`noMatches`,{query:e.query})}),e.groups.map(e=>(0,L.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,L.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[0.6875rem] font-medium uppercase tracking-wide text-faint-foreground`,children:e.label}),e.failed&&(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-danger-text`,children:V(`couldNotSearch`,{label:e.label})}),e.hits.map(e=>{w+=1;let t=w;return(0,L.jsxs)(`a`,{id:h(t),href:e.href,tabIndex:-1,role:`option`,"aria-selected":t===d,className:R(`block px-3 py-1.5`,t===d?`bg-primary-soft text-primary-text`:`hover:bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:t=>{Zb(t)||(t.preventDefault(),x(e.href))},onMouseEnter:()=>f(t),children:[(0,L.jsx)(`span`,{className:`block truncate font-semibold`,children:e.title}),e.subtitle&&(0,L.jsx)(`span`,{className:R(`block truncate text-xs`,t===d?`text-primary-text/80`:`text-muted-foreground`),children:e.subtitle})]},e.id)})]},e.id))]})]})},$b=`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))]`,ex=`size-[min(2.75rem,max(44px,13vw))] shrink-0`,tx=`max-h-[max(40px,calc(13vw-4px),calc(1.25em+2px))] text-body [&>input]:leading-[1.25] [&>svg]:size-[min(1rem,max(16px,6vw))] [&>button]:size-[min(1.5rem,max(24px,9vw))] [&>button>svg]:size-[min(0.875rem,max(14px,5vw))]`,nx=`inline-flex min-h-[min(2.75rem,max(44px,13vw))] min-w-0 items-center gap-1 rounded-md pr-2 pl-3 text-muted-foreground hover:bg-muted hover:text-foreground md:hidden [&_svg]:size-[min(1.25rem,max(20px,6vw))]`,rx=({breadcrumb:e,titleStatus:t,onNavigate:n,onBack:r,actions:i,brand:a,leading:o,backInLeadingSlot:s,account:c,searchButton:l=!0,searchOpen:u,onSearchOpenChange:d,onMenu:f,menuOpen:p,menuControls:m,search:h,sticky:g,slotRef:_,ref:v})=>{let y=(0,L.jsx)(`span`,{className:`flex shrink-0 items-center empty:hidden`,children:t}),[b,x]=(0,j.useState)(!1),S=u??b,C=e=>d?d(e):x(e),w=nb(e),T=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{if(!h)return;let e=e=>{if(e.key.toLowerCase()!==`k`||!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=T.current;t&&t.offsetParent!==null?t.focus():C(!0)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{ref:v,className:R(g?`sticky top-0 z-30 max-md:fixed max-md:left-[var(--pb-safe-left)] max-md:right-[var(--pb-safe-right)]`:`relative`,`flex shrink-0 items-center gap-1 border-b pt-[var(--pb-safe-top,--spacing(2))] pr-2 pb-2 pl-4 h-[calc(3rem+var(--pb-safe-top))] md:gap-4 md:px-5 md:pt-[var(--pb-safe-top)] md:pb-0`,a?Rb:`bg-background`),children:[a&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-screen bg-primary md:hidden`}),(0,L.jsxs)(`div`,{className:R(`contents`,a&&`text-primary-foreground [&_*]:text-primary-foreground [&_button:hover]:bg-primary-foreground/15`),children:[f&&(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`openNavigation`),"aria-expanded":!!p,"aria-controls":m,onClick:f,className:R(`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))]`,`-ml-3`),children:(0,L.jsx)(vc,{})}),o&&(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`min-w-0`,children:o}),y]}),!o&&s&&(0,L.jsxs)(`div`,{className:R(`flex min-w-0 items-center gap-2.5`,`flex-1`),children:[w&&(0,L.jsx)(`a`,{href:w.href,"aria-label":V(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&Tu(e)&&(e.preventDefault(),t(w.href))},className:R(`size-[min(1.75rem,max(28px,8vw))]`,`relative flex shrink-0 items-center justify-center rounded-full text-foreground after:absolute after:-inset-2 [&_svg]:size-[min(1.5rem,max(24px,7vw))]`),children:(0,L.jsx)(es,{"aria-hidden":!0})}),(0,L.jsx)(Eu,{parts:e,onNavigate:n,trailing:y})]}),!o&&!s&&w&&(0,L.jsxs)(`a`,{href:w.href,"aria-label":V(`backTo`,{label:w.label}),onClick:e=>{let t=r??n;t&&Tu(e)&&(e.preventDefault(),t(w.href))},className:R(w.shown?nx:`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))]`,!f&&`-ml-3`),children:[(0,L.jsx)(es,{className:`shrink-0`,"aria-hidden":!0}),w.shown&&(0,L.jsx)(`span`,{className:`truncate`,children:w.label})]}),!o&&!s&&(0,L.jsx)(Eu,{parts:e,onNavigate:n,trailing:y}),(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 md:gap-3`,children:[h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`hidden md:block`,children:(0,L.jsx)(Qb,{ref:T,search:h})}),l&&(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`search`),"aria-expanded":S,onClick:()=>C(!0),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))]`,children:(0,L.jsx)(ul,{})})]}),i,(0,L.jsx)(`div`,{ref:_,className:`contents md:hidden`}),c]})]}),h&&S&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-20 flex items-center gap-1 bg-background px-3 pt-[var(--pb-safe-top)] md:hidden`,children:[(0,L.jsx)(Qb,{className:`min-w-0 flex-1`,fieldClassName:tx,autoFocus:!0,showShortcut:!1,search:{...h,onSelect:e=>{h.onSelect(e),C(!1)}}}),(0,L.jsx)(`button`,{type:`button`,"aria-label":V(`closeSearch`),onClick:()=>C(!1),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))]`,children:(0,L.jsx)(uu,{})})]})]}),g&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-[var(--pb-sticky-top,calc(3rem+var(--pb-safe-top)))] shrink-0 md:hidden`})]})},ix=({label:e,current:t,others:n,rowClassName:r,onSwitch:i})=>(0,L.jsxs)(`div`,{className:`border-b py-1`,role:`group`,"aria-label":e,children:[t&&(0,L.jsxs)(`div`,{className:R(r,`text-foreground hover:bg-transparent`),"aria-current":`true`,children:[(0,L.jsx)(Xo,{className:`size-4`}),(0,L.jsx)(`span`,{className:`truncate`,children:t.label})]}),n.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>i(e.id),className:r,children:[(0,L.jsx)(`span`,{className:`size-4`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))]}),ax={sm:{group:`h-[2em]`,option:`px-2.5 text-body`},md:{group:`h-[2.2857em]`,option:`px-3 text-body`}},ox={group:(e=`sm`)=>R(`inline-flex`,ax[e].group,`rounded-md bg-muted p-0.5`),option:(e,t=`sm`)=>R(`inline-flex items-center gap-1.5 rounded`,ax[t].option,`font-medium transition-colors`,e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`)},sx=({value:e,options:t,onChange:n,label:r,size:i=`sm`,iconOnly:a=!1})=>(0,L.jsx)(`span`,{role:`group`,"aria-label":r,"data-segmented":``,className:ox.group(i),children:t.map(t=>(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":t.value===e,...a&&{"aria-label":t.label,title:t.label},onClick:()=>n(t.value),className:ox.option(t.value===e,i),children:[t.icon&&(0,L.jsx)(t.icon,{className:`size-[1em]`}),!a&&t.label]},t.value))}),cx=()=>[{value:`light`,label:V(`light`),icon:Al},{value:`dark`,label:V(`dark`),icon:Mc},{value:`system`,label:V(`system`),icon:Ac}],lx=({theme:e,className:t})=>(0,L.jsxs)(`div`,{className:t,children:[(0,L.jsx)(Ol,{className:`size-4`}),(0,L.jsx)(`span`,{className:`flex-1`,children:V(`theme`)}),(0,L.jsx)(sx,{label:V(`theme`),iconOnly:!0,value:e.preference,options:cx(),onChange:e.onChange})]}),ux=10,dx=100,fx=e=>e>=0?e:-Gy(-e),px=e=>{let t=e.at(-1);if(!t)return 0;let n=e.find(e=>t.time-e.time<=dx)??t,r=t.time-n.time;return r>0?(t.y-n.y)/r:0},mx=(e,t,n)=>e<=ux?!1:!Wy(1-e/Math.max(1,t),-n*1e3),hx=(e,t,n)=>e<=0&&n>0&&qy(n,t,.58),gx=350,_x=Uy,vx=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,yx=({panel:e,backdrop:t,content:n,open:r,onClose:i})=>{let a=(0,j.useRef)(void 0),o=(0,j.useRef)(!1),s=(0,j.useRef)(i);s.current=i;let c=(0,j.useCallback)((n,r)=>{let i=e.current;if(!i)return;let a=r&&!vx()?`${gx}ms ${_x}`:`none`;i.style.transition=a===`none`?`none`:`transform ${a}`,i.style.transform=n===0?``:`translateY(${n}px)`;let o=t.current;o&&(o.style.transition=a===`none`?`none`:`opacity ${a}`,o.style.opacity=String(1-Math.max(0,n)/Math.max(1,i.offsetHeight)))},[e,t]);(0,j.useLayoutEffect)(()=>{let t=e.current;if(!r||!t||(o.current=!1,vx()))return;c(t.offsetHeight,!1);let n=requestAnimationFrame(()=>c(0,!0));return()=>cancelAnimationFrame(n)},[r,e,c]);let l=(0,j.useCallback)(()=>{let t=e.current;if(!o.current){if(!t||vx())return s.current();o.current=!0,c(t.offsetHeight,!0),setTimeout(()=>s.current(),gx)}},[e,c]),u=(e,t,n)=>{a.current={x:e,y:t,samples:[{y:t,time:n}],dragging:!1,scrolling:!1}},d=(e,t)=>{let n=a.current;n&&(n.samples.push({y:e,time:t}),c(fx(e-n.y),!1))},f=()=>{let t=a.current;a.current=void 0;let n=e.current;if(t?.dragging&&n){if(mx(fx(t.samples.at(-1).y-t.y),n.offsetHeight,px(t.samples)))return l();c(0,!0)}};return(0,j.useEffect)(()=>{let e=n.current;if(!r||!e)return;let t=e=>{let t=e.touches[0];e.touches.length===1&&t&&u(t.clientX,t.clientY,e.timeStamp)},i=t=>{let n=a.current,r=t.touches[0];if(n&&r&&!n.scrolling){if(!n.dragging){let t=r.clientX-n.x,i=r.clientY-n.y;if(Math.abs(t)<ux&&Math.abs(i)<ux)return;if(!hx(e.scrollTop,t,i)){n.scrolling=!0;return}n.dragging=!0,n.y=r.clientY}t.preventDefault(),d(r.clientY,t.timeStamp)}};return e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`touchmove`,i,{passive:!1}),e.addEventListener(`touchend`,f),e.addEventListener(`touchcancel`,f),()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchmove`,i),e.removeEventListener(`touchend`,f),e.removeEventListener(`touchcancel`,f)}}),{dismiss:l,header:{onPointerDown:e=>{if(e.button!==0)return;u(e.clientX,e.clientY,e.timeStamp);let t=t=>{let n=a.current;if(n&&t.pointerId===e.pointerId){if(!n.dragging){if(Math.abs(t.clientY-n.y)<ux)return;n.dragging=!0,n.y=t.clientY}d(t.clientY,t.timeStamp)}},n=r=>{if(r.pointerId!==e.pointerId)return;let i=a.current;i&&!i.dragging&&Math.abs(r.clientY-i.y)>=ux&&(i.dragging=!0,i.samples.push({y:r.clientY,time:r.timeStamp})),window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n),f()};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n)}}}},bx=({title:e,open:t,onClose:n,children:r,inset:i=`sides`,header:a=`title`})=>{let o=(0,j.useRef)(null),s=(0,j.useRef)(null),c=(0,j.useRef)(null),{dismiss:l,header:u}=yx({panel:o,backdrop:s,content:c,open:t,onClose:n});return bu(o,t,l),t?(0,M.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[80]`,children:[(0,L.jsx)(`div`,{ref:s,className:`absolute inset-0 bg-backdrop/40`,onClick:l,"aria-hidden":!0}),(0,L.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-label":e,tabIndex:-1,className:`absolute inset-x-0 bottom-0 flex max-h-[85vh] flex-col rounded-t-xl border-t bg-background pl-[var(--pb-safe-left)] pr-[var(--pb-safe-right)] shadow-pop outline-none will-change-transform`,children:[(0,L.jsxs)(`header`,{className:R(`relative flex shrink-0 touch-none select-none items-center justify-between`,a===`title`?`border-b px-4 pt-4`:`h-5`),...u,children:[a===`title`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`close`),onClick:l,className:`-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,L.jsx)(uu,{className:`size-5`})})]}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`dragToClose`),onClick:l,className:`absolute left-1/2 top-0 flex h-4 w-16 -translate-x-1/2 items-start justify-center pt-1.5`,children:(0,L.jsx)(`span`,{className:`h-1 w-9 rounded-full bg-border-strong`})})]}),(0,L.jsx)(`div`,{ref:c,className:R(`min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[calc(1.5rem+max(var(--pb-safe-bottom),var(--pb-sticky-bottom,0px)))]`,i===`sides`&&`px-4`),children:r})]})]}),document.body):null},xx=`py-1 text-menu-sheet [&>*]:min-h-[2.6em] [&_[role=menuitem]]:min-h-[2.6em] [&_svg]:size-[1.2em] [&_[data-segmented]]:h-[2.3em] [&_[data-segmented]_button]:min-w-[2.3em] [&_[data-segmented]_button]:justify-center [&_[data-menu-heading]]:py-[0.75em] [&_[data-menu-heading]>:first-child]:text-[1.15em] [&_[data-menu-heading]>:first-child]:font-semibold [&_[data-menu-heading]>:last-child]:text-[0.9em]`,Sx=({open:e,title:t,onClose:n,menu:r,inPlaceOnDesktop:i})=>{let a=Ty();return e?a?i?r:(0,M.createPortal)(r,document.body):(0,L.jsx)(bx,{title:t,open:!0,onClose:n,inset:`none`,header:`handle`,children:(0,j.cloneElement)(r,{className:xx,style:void 0})}):null},Cx=`flex min-h-11 w-full items-center gap-2.5 px-3 py-1.5 text-left text-muted-foreground hover:bg-muted md:min-h-0`,wx=({user:e,compact:t,open:n,items:r=[],account:i,onNavigate:a,onSignOut:o,organizations:s,roles:c,theme:l,status:u,label:d,inTopBar:f})=>{let p=c?.roles.find(e=>e.name===c.active),[m,h]=(0,j.useState)(!1),g=n??m,_=(0,j.useRef)(null),v=(0,j.useRef)(null),[y,b]=(0,j.useState)();(0,j.useEffect)(()=>{if(!g||n!==void 0)return;let e=e=>{if(v.current?.closest(`[aria-modal="true"]`))return;let t=_.current?.contains(e.target)||v.current?.contains(e.target);(e instanceof KeyboardEvent?e.key===`Escape`:!t)&&h(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[g,n]);let x=r.filter(e=>e.length>0),S=(e,t,n)=>{h(!1),!n&&a&&(e.preventDefault(),a(t))},C=()=>{let e=_.current?.getBoundingClientRect();e&&b({left:e.left,bottom:window.innerHeight-e.top+8}),h(!m)},w=(0,L.jsxs)(`div`,{ref:v,role:`menu`,className:n===void 0?`fixed z-[60] w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`:`absolute bottom-full left-0 z-50 mb-2 w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`,style:n===void 0&&y?{left:y.left,bottom:y.bottom}:void 0,children:[i?(0,L.jsxs)(`a`,{role:`menuitem`,href:i,onClick:e=>S(e,i),"data-menu-heading":``,className:`block border-b px-3 pb-2 pt-1.5 hover:bg-muted`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,L.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}):(0,L.jsxs)(`div`,{"data-menu-heading":``,className:`border-b px-3 pb-2 pt-1.5`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,L.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),u&&(0,L.jsx)(`div`,{className:`border-b py-1`,children:(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:Cx,onClick:()=>{h(!1),u.onOpen()},children:[(0,L.jsx)(Rs,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.label})]})}),s&&(s.current||s.others.length>0)&&(0,L.jsx)(ix,{label:s.label??V(`organizations`),...s.current&&{current:{id:s.current.id,label:s.current.name}},others:s.others.map(({id:e,name:t})=>({id:e,label:t})),rowClassName:Cx,onSwitch:e=>{h(!1),s.onSwitch(e)}}),c&&c.roles.length>1&&(0,L.jsx)(ix,{label:V(`roles`),...p&&{current:{id:p.name,label:p.label}},others:c.roles.filter(e=>e!==p).map(({name:e,label:t})=>({id:e,label:t})),rowClassName:Cx,onSwitch:e=>{h(!1),c.onSwitch(e)}}),x.map((e,t)=>(0,L.jsx)(`div`,{role:`group`,className:R(`py-1`,(t<x.length-1||l||o)&&`border-b`),children:e.map(e=>{let t=e.icon;return(0,L.jsxs)(`a`,{role:`menuitem`,href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:t=>S(t,e.href,e.external),className:R(Cx,e.active&&`bg-muted text-foreground`),children:[(0,L.jsx)(t,{className:`size-4`}),e.label]},e.id)})},e[0]?.id)),l&&(0,L.jsx)(`div`,{className:R(o&&`border-b`),children:(0,L.jsx)(lx,{theme:l,className:R(Cx,`hover:bg-transparent`)})}),o&&(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:o,className:Cx,children:[(0,L.jsx)(fc,{className:`size-4`}),V(`signOut`)]})]});return(0,L.jsxs)(`div`,{ref:_,className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,className:f?R(ex,`flex items-center justify-center rounded-full hover:bg-muted`):`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1 text-left hover:bg-muted md:min-h-0`,"aria-label":d??V(`profileMenu`),"aria-haspopup":`menu`,"aria-expanded":g,onClick:C,children:[f?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`contents`,children:(0,L.jsx)(Cb,{initials:e.initials,hue:e.hue,size:`bar`})}):(0,L.jsx)(Cb,{initials:e.initials,hue:e.hue,size:`md`}),!t&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 leading-tight`,children:[u?.mark?(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),u.mark]}):(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,L.jsx)(fy,{tone:e.roleTone,dot:!1,className:`mt-0.5 h-4 px-1.5 text-[0.625rem]`,children:e.role})]}),(0,L.jsx)(is,{className:`size-3.5 shrink-0 text-faint-foreground`})]})]}),n===void 0?(0,L.jsx)(Sx,{open:g,title:V(`profileMenu`),onClose:()=>h(!1),menu:w,inPlaceOnDesktop:!0}):g&&w]})},Tx={"text-large":`h-8 gap-2.5 px-2.5`,"text-small":`h-7 gap-2 px-2 text-body`},Ex={"text-large":`ml-[20px]`,"text-small":`ml-[17px]`},Dx=({create:e,mode:t,onNavigate:n})=>(0,L.jsx)(`div`,{className:R(`border-l border-transparent pl-1.5`,Ex[t]),children:(0,L.jsxs)(`a`,{href:e.href,onClick:n&&(t=>{t.preventDefault(),n(e.href)}),className:R(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,Tx[t]),children:[(0,L.jsx)(Xc,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]})}),Ox=`protobase:nav-open:`,kx=e=>`${Ox}${e}`,Ax=(e,t)=>ue(()=>e.getItem(t)!==`false`,!0),jx=(e,t,n)=>ue(()=>n?e.removeItem(t):e.setItem(t,`false`),void 0),Mx=({label:e,side:t=`right`,visible:n,children:r})=>(0,L.jsxs)(`span`,{className:`group/tooltip relative inline-flex`,children:[r,(0,L.jsx)(`span`,{role:`tooltip`,className:R(`pointer-events-none absolute z-50 whitespace-nowrap rounded-md bg-foreground px-2 py-1 text-xs font-medium text-background opacity-0 shadow-md transition-opacity group-hover/tooltip:opacity-100`,n&&`opacity-100`,t===`right`&&`left-full top-1/2 ml-2 -translate-y-1/2`,t===`top`&&`bottom-full left-1/2 mb-2 -translate-x-1/2`,t===`bottom`&&`left-1/2 top-full mt-2 -translate-x-1/2`),children:e})]}),Nx=e=>e===`text-large`||e===`text-small`||e===`icon-expand`,Px=e=>e===`text-large`||e===`text-small`,Fx={"text-large":`w-60 max-w-[33vw]`,"text-small":`w-52 max-w-[33vw]`,icon:`w-14`,"icon-label":`w-[76px]`,"icon-tooltip":`w-14`,"icon-expand":`w-14`},Ix={"text-large":`h-9 gap-3 px-3 text-sm`,"text-small":`h-7 gap-2.5 px-2.5 text-body`,icon:`size-9 justify-center`,"icon-label":`w-full flex-col gap-0.5 py-1.5 text-[0.625rem]`,"icon-tooltip":`size-9 justify-center`,"icon-expand":`h-8 gap-3 px-3`},Lx=({item:e,mode:t,active:n,onNavigate:r,className:i})=>{let a=e.icon,o=(0,L.jsxs)(`a`,{onClick:r&&(t=>{t.preventDefault(),r(e.href??`#${e.id}`)}),href:e.href??`#${e.id}`,"aria-label":e.problem?`${e.label}: ${e.problem}`:e.label,"aria-current":n?`page`:void 0,title:e.problem,className:R(`flex shrink-0 items-center rounded-md font-medium transition-colors`,Ix[t],n?`bg-primary-soft text-primary-text`:`text-muted-foreground hover:bg-muted hover:text-foreground`,i),children:[(0,L.jsx)(a,{className:R(`shrink-0`,t===`text-small`?`size-4`:`size-[18px]`),strokeWidth:n?2.2:1.9}),(Nx(t)||t===`icon-label`)&&(0,L.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),Px(t)&&e.count&&(0,L.jsx)(`span`,{className:`ml-auto rounded bg-muted px-1.5 text-[0.6875rem] tabular-nums text-muted-foreground`,children:e.count}),Px(t)&&e.problem&&(0,L.jsx)(Bl,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-warning-text`})]});return t===`icon-tooltip`?(0,L.jsx)(Mx,{label:e.label,children:o}):o},Rx=99,zx=e=>e===void 0||e<=0?void 0:e>Rx?`${Rx}+`:String(e),Bx=({count:e,className:t})=>{let n=zx(e);return n?(0,L.jsx)(fy,{tone:`red`,dot:!1,className:R(`h-4 min-w-4 justify-center px-1 text-[0.625rem] font-semibold`,t),children:n}):null},Vx={neutral:`text-faint-foreground`,info:`text-primary`,success:`text-success`,warning:`text-warning`,danger:`text-danger`},Hx={neutral:(0,L.jsx)(`circle`,{cx:`5`,cy:`5`,r:`3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),info:(0,L.jsx)(`path`,{d:`M5 0.8 9.2 5 5 9.2 0.8 5Z`,fill:`currentColor`}),success:(0,L.jsx)(`circle`,{cx:`5`,cy:`5`,r:`4`,fill:`currentColor`}),warning:(0,L.jsx)(`path`,{d:`M5 0.6 9.6 9H0.4Z`,fill:`currentColor`,strokeLinejoin:`round`}),danger:(0,L.jsx)(`rect`,{x:`1.2`,y:`1.2`,width:`7.6`,height:`7.6`,rx:`1`,fill:`currentColor`})},Ux=({tone:e,pulse:t=!1,className:n})=>(0,L.jsxs)(`span`,{"aria-hidden":!0,className:R(`relative flex size-2.5 shrink-0`,Vx[e],n),"data-tone":e,"data-pulse":t||void 0,children:[t&&(0,L.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`absolute inset-0 size-2.5 animate-ping opacity-60 motion-reduce:animate-none`,children:Hx[e]}),(0,L.jsx)(`svg`,{viewBox:`0 0 10 10`,className:`relative size-2.5`,children:Hx[e]})]}),Wx=F(`status`),Gx=({presence:e})=>{let t=Wx(e);return(0,L.jsx)(`span`,{role:`img`,"aria-label":t,title:t,className:`flex shrink-0`,children:(0,L.jsx)(Ux,{tone:e===`online`?`success`:`neutral`})})},Kx=e=>Wx(e===`busy`?`busy`:e===`do_not_disturb`?`doNotDisturb`:`automatic`),qx=({availability:e,title:t})=>{if(e===`automatic`)return null;let n=Kx(e);return(0,L.jsx)(e===`busy`?ms:cs,{role:`img`,"aria-label":n,className:R(`size-3.5 shrink-0`,e===`busy`?`text-warning`:`text-danger`),children:(0,L.jsx)(`title`,{children:t??n})})},Jx=({status:e,presence:t,textShown:n=`full`,className:r})=>{let i=bi(e);if(!i&&!t)return null;let a=i?.text??void 0;return(0,L.jsxs)(`span`,{className:R(`inline-flex min-w-0 items-center gap-1 text-muted-foreground`,r),title:a,children:[t&&(0,L.jsx)(Gx,{presence:t}),i&&(0,L.jsx)(qx,{availability:i.availability,...n===`hover`&&a&&{title:a}}),i&&n===`hover`&&i.availability===`automatic`&&a&&(0,L.jsx)(`span`,{role:`img`,"aria-label":a,className:`size-1.5 shrink-0 rounded-full bg-faint-foreground`}),a&&n===`full`&&(0,L.jsx)(`span`,{className:`truncate text-xs`,children:a})]})},Yx=(e,t)=>e.map(e=>{let n=t&&Object.hasOwn(t,e.id)?t[e.id]:void 0;return n?{...e,mark:n}:e}),Xx=e=>{if(!e)return[];let t=bi(e.status);return[e.presence&&Wx(e.presence),t&&t.availability!==`automatic`?Kx(t.availability):void 0,t?.text??void 0]},Zx=e=>{let t=[e.status?.label,...Xx(e.mark?.person),e.mark?.typing?V(`typing`):void 0,e.mark?.label].filter(e=>e!==void 0&&e!==``);return{ariaLabel:[e.label,...t].join(`, `),title:t.length===0?e.label:`${e.label} (${t.join(`, `)})`}},Qx=({records:e,mode:t,onNavigate:n})=>e.map(e=>{let{ariaLabel:r,title:i}=Zx(e),a=n&&(t=>{t.preventDefault(),n(e.href)}),o=e.mark?.strong===!0;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`a`,{href:e.href,onClick:a,"aria-label":r,title:i,"aria-current":e.active?`page`:void 0,className:R(`flex min-w-0 items-center rounded-md transition-colors`,Tx[t],o?`font-bold`:`font-medium`,e.active||o?`text-foreground`:`text-muted-foreground`,e.active?`bg-muted`:`hover:bg-muted hover:text-foreground`),children:[e.status&&(0,L.jsx)(Ux,{tone:e.status.tone,pulse:e.status.pulse}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label}),e.mark?.person&&(0,L.jsx)(Jx,{...e.mark.person,textShown:`hover`,className:`ml-1.5 shrink-0`}),e.mark?.typing&&(0,L.jsx)(`span`,{className:`ml-1.5 shrink-0 text-xs font-normal text-muted-foreground`,children:V(`typing`)}),(0,L.jsx)(Bx,{count:e.mark?.count,className:`ml-auto shrink-0`})]})},e.id)}),$x=({records:e,useMarks:t,...n})=>(0,L.jsx)(Qx,{records:Yx(e,t(e)),...n}),eS=({records:e,useMarks:t,mode:n,onNavigate:r})=>t?(0,L.jsx)($x,{records:e,useMarks:t,mode:n,onNavigate:r}):(0,L.jsx)(Qx,{records:e,mode:n,onNavigate:r}),tS=({item:e,recent:t,mode:n,active:r,onNavigate:i})=>{let a=kx(e.id),[o,s]=(0,j.useState)(()=>Ax(localStorage,a)),c=(0,j.useId)(),l=e.href??`#${e.id}`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Lx,{item:e,mode:n,active:r,onNavigate:i,className:`pr-8`}),(0,L.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,"aria-label":V(`recent`,{plural:e.label.toLowerCase()}),onClick:()=>{jx(localStorage,a,!o),s(!o)},className:`absolute right-1 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground`,children:(0,L.jsx)(ns,{className:R(`size-3.5 transition-transform`,o&&`rotate-90`)})})]}),o&&(0,L.jsxs)(`ul`,{id:c,"aria-label":V(`recent`,{plural:e.label.toLowerCase()}),className:R(`flex flex-col gap-0.5 border-l pl-1.5`,Ex[n]),children:[t.state===`loading`&&(0,L.jsx)(`li`,{role:`status`,"aria-label":V(`loading`),className:R(`flex items-center`,Tx[n]),children:(0,L.jsx)(Su,{className:`w-3/4`})}),t.state===`error`&&(0,L.jsx)(`li`,{className:R(`flex items-center text-faint-foreground`,Tx[n]),children:V(`couldNotLoad`)}),t.state===`ready`&&(0,L.jsx)(eS,{records:t.records,useMarks:t.useMarks,mode:n,onNavigate:i}),(0,L.jsx)(`li`,{children:(0,L.jsx)(`a`,{...(e=>({href:e,onClick:i&&(t=>{t.preventDefault(),i(e)})}))(l),className:R(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,Tx[n]),children:V(`viewAll`)})})]})]})},nS=({mode:e,activeItem:t,user:n,workspace:r,appName:i,appIcon:a,forceExpanded:o,profileMenuOpen:s,groups:c=[],userMenu:l,account:u,onNavigate:d,onSignOut:f,signIn:p,organizations:m,roles:h,theme:g,status:_,sticky:v,logo:y=Fb,notice:b,fill:x,page:S,search:C,accountInTopBar:w})=>{let T=e===`icon-expand`,E=T&&o,D=Px(e)||T;return(0,L.jsx)(`nav`,{"aria-label":V(`resources`),className:S?`w-full`:R(v?`sticky top-0 h-dvh self-start`:`relative`,`z-30 shrink-0`,x?`w-full`:Fx[e]),children:(0,L.jsxs)(`div`,{className:R(S?`group/side flex flex-col bg-sidebar`:`group/side absolute inset-y-0 left-0 flex flex-col overflow-hidden border-r bg-sidebar pb-[var(--pb-safe-bottom)] pt-[var(--pb-safe-top)]`,T?`w-14 transition-[width,box-shadow] duration-150 hover:w-60 hover:shadow-pop focus-within:w-60 focus-within:shadow-pop`:`w-full`,E&&`w-60 shadow-pop`),children:[!S&&(0,L.jsx)(`div`,{className:R(`flex h-12 shrink-0 items-center px-3.5`,e===`icon-label`&&`justify-center px-0`),onClick:()=>Lb(),children:(0,L.jsx)(y,{compact:!D,workspace:r,appName:i,appIcon:a})}),C&&(0,L.jsx)(`div`,{className:`px-5 pt-3 pb-3`,children:(0,L.jsx)(Qb,{search:C,className:`w-full`,showShortcut:!1,inline:!0})}),(!C||C.query===``&&!C.loading)&&(0,L.jsx)(`div`,{className:R(S?`pb-2`:`flex-1 overflow-y-auto overflow-x-hidden pb-2`,`px-2`),children:c.map((n,r)=>(0,L.jsxs)(`div`,{className:R(`flex flex-col gap-0.5`,r>0&&`mt-3`),children:[D?n.label&&(0,L.jsx)(`h2`,{className:R(`px-3 pb-1 pt-1 text-xs font-medium uppercase tracking-wide text-faint-foreground`,T&&`h-4 whitespace-nowrap py-0 opacity-0 transition-opacity group-hover/side:opacity-100 group-focus-within/side:opacity-100`,E&&`opacity-100`),children:n.label}):(0,L.jsxs)(L.Fragment,{children:[n.label&&(0,L.jsx)(`h2`,{className:`sr-only`,children:n.label}),r>0&&(0,L.jsx)(`div`,{className:`mx-auto mb-1 h-px w-6 bg-border`})]}),n.items.map(n=>(0,L.jsxs)(j.Fragment,{children:[n.recent&&Px(e)?(0,L.jsx)(tS,{item:n,recent:n.recent,mode:e,active:n.id===t,onNavigate:d}):(0,L.jsx)(Lx,{item:n,mode:e,active:n.id===t,onNavigate:d}),n.create&&Px(e)&&(0,L.jsx)(Dx,{create:n.create,mode:e,onNavigate:d})]},n.id))]},n.label))}),b,!(S&&n)&&(0,L.jsx)(`div`,{className:R(`shrink-0 border-t p-2 empty:hidden`,e!==`text-large`&&e!==`text-small`&&!T&&`flex justify-center`),children:n&&w?null:n?(0,L.jsx)(wx,{user:n,compact:!D,open:s,items:l,account:u,onNavigate:d,onSignOut:f,organizations:m,roles:h,theme:g,status:_}):(0,L.jsxs)(L.Fragment,{children:[g&&D&&(0,L.jsx)(lx,{theme:g,className:`flex min-h-11 w-full items-center gap-2.5 whitespace-nowrap p-1.5 text-muted-foreground md:min-h-0`}),p&&!S&&!w&&(0,L.jsxs)(Du,{to:p,"aria-label":V(`signIn`),className:`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1.5 text-left font-medium text-muted-foreground hover:bg-muted hover:text-foreground md:min-h-0`,children:[(0,L.jsx)(uc,{className:`size-4 shrink-0`}),D&&(0,L.jsx)(`span`,{className:`whitespace-nowrap`,children:V(`signIn`)})]})]})})]})})},rS=e=>Ty()&&Px(e),iS=(0,j.createContext)(null),aS=()=>(0,j.useContext)(iS),oS=`/-/menu`,sS=(e,t,{starting:n,morePage:r})=>e===`/-/menu`&&(n||!r)?t??`/`:void 0,cS=e=>{(0,j.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`background-color`,`var(--color-sidebar)`),document.body.style.setProperty(`background-color`,`var(--color-sidebar)`),()=>{t.style.removeProperty(`background-color`),document.body.style.removeProperty(`background-color`)}},[e])},lS=({desktop:e,tabs:t,menuPage:n})=>e||!t||t.length===0||!n?{on:!1}:{on:!0,href:n.href,shown:n.shown,onTab:t.some(e=>e.active)},uS=(e,t)=>lS({desktop:Ty(),tabs:e,menuPage:t}),dS=e=>!e,fS=e=>!e,pS=({desktop:e,more:t,inBottomBar:n})=>e||!t?`top-bar`:n?`bottom-bar`:`more-page`,mS=e=>{let t=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0});if(!t)return e;t.fillStyle=e,t.fillRect(0,0,1,1);let[n,r,i]=t.getImageData(0,0,1,1).data;return`rgb(${n}, ${r}, ${i})`},hS=(e,t)=>{(0,j.useEffect)(()=>{let n=vg(window);if(!e||!t.current||!n?.isPluginAvailable(`SystemBars`))return;let r=zb(mS(getComputedStyle(t.current).backgroundColor));return n.nativePromise(`SystemBars`,`setStyle`,{style:r}),()=>void n.nativePromise(`SystemBars`,`setStyle`,{style:`DEFAULT`})},[e,t])},gS=({user:e,signIn:t,onBrand:n,...r})=>!e&&!t?null:(0,L.jsx)(`div`,{className:`flex shrink-0 items-center justify-end`,onClick:e=>e.stopPropagation(),children:e?(0,L.jsx)(wx,{user:e,compact:!0,inTopBar:!0,label:V(`accountOf`,{name:e.name}),...r}):t&&(0,L.jsx)(Du,{to:t,"aria-label":V(`signIn`),className:R(`size-[min(2.75rem,max(44px,13vw))] shrink-0`,`flex items-center justify-center rounded-full hover:bg-muted`),children:(0,L.jsx)(`span`,{className:R(`flex size-[min(2rem,max(32px,9vw))] items-center justify-center rounded-full`,n?`bg-primary-foreground/20 text-primary-foreground`:`bg-muted text-muted-foreground`),children:(0,L.jsx)(Jl,{className:`size-[min(1.25rem,max(20px,6vw))]`,"aria-hidden":!0})})})}),_S=`app-drawer`,vS={refreshing:`[animation:pb-stale_1.4s_ease-in-out_infinite] motion-reduce:[animation:none] motion-reduce:opacity-60`,failed:`opacity-60`},yS=({sidebarMode:e,activeItem:t,breadcrumb:n,titleStatus:r,staleContent:i,user:a,workspace:o,appName:s,appIcon:c,logo:l,actions:u,rightPanel:d,sidebarNotice:f,banner:p,forceExpanded:m,profileMenuOpen:h,navGroups:g,userMenu:_,account:v,bottomBar:y,menuPage:b,bottomBarSearch:x,onNavigate:S,onBack:C,backIsHistory:w,onSignOut:T,signIn:E,organizations:D,roles:O,theme:k,status:A,search:ee,pageScroll:te=!1,className:ne,overlays:re,children:ie})=>{let ae=Ty(),oe=rS(e),[M,se]=(0,j.useState)(!1),[ce,le]=(0,j.useState)(!1),ue=(0,j.useRef)(null),de=(0,j.useCallback)(()=>{se(!1),le(!1)},[]);(0,j.useEffect)(()=>{ae&&de()},[ae,de]),Vy(de);let fe=!ae&&y&&y.length>0?y:void 0,N=uS(fe,b),pe=dS(ae),me=fS(ae),he=N.on&&S?()=>S(N.href):()=>se(!0),ge=N.on&&N.shown;cS(ge);let[_e,ve]=(0,j.useState)(!1),ye=(0,j.useRef)(null),be=l??Fb;hS(me,ye);let xe=ee&&pS({desktop:ae,more:N.on,inBottomBar:!!x}),Se=xe===`bottom-bar`,Ce=()=>ve(!0),we=N.on?N.shown?[V(`more`)]:N.onTab?n:[{label:V(`more`),href:N.href},...n]:n,Te=N.on&&!!fe?.[0]?.shown,Ee=nb(we),De=ab(rb({desktop:ae,back:!!Ee,bottomBar:!!fe,drawerOpen:M}),{nativeBack:cb(),behindIsBack:Ee!==void 0&&!!w?.(Ee.href)});lb(De,JSON.stringify(we));let[Oe,ke]=(0,j.useState)(),Ae=Oe??te,je=(0,j.useRef)(null);hb({action:De,onBack:()=>Ee&&(C??S)?.(Ee.href),openDrawer:()=>{le(!0),se(!0)},closeDrawer:de,drawer:ue});let[Me,Ne]=(0,j.useState)(null),Pe=(0,j.useRef)(null);bb(Ae,je,Pe,!!fe),vb(Ae);let Fe=e=>(0,L.jsx)(nS,{...e,accountInTopBar:pe,...e.page&&ee&&xe===`more-page`&&{search:ee},activeItem:t,user:a,workspace:o,appName:s,appIcon:c,forceExpanded:m,profileMenuOpen:h,groups:g,userMenu:_,account:v,onNavigate:S,onSignOut:T,signIn:E,organizations:D,roles:O,theme:k,status:A,logo:l});return(0,L.jsxs)(gb.Provider,{value:ke,children:[(0,L.jsx)(`span`,{ref:ye,"aria-hidden":!0,className:`hidden bg-primary`}),(0,L.jsxs)(`div`,{className:R(Ae?`flex min-h-full w-full overflow-x-clip`:`relative flex h-full min-h-0 w-full overflow-hidden`,ge?`bg-sidebar`:`bg-background`,ne),children:[ae?Fe({mode:e,sticky:Ae,notice:oe&&f}):(0,L.jsx)(tb,{id:_S,open:M,onClose:de,underFinger:ce,control:ue,children:Fe({mode:`text-large`,fill:!0})}),(0,L.jsxs)(`div`,{className:R(`flex min-w-0 flex-1 flex-col`,!fe&&`pb-[var(--pb-safe-bottom)]`),children:[(0,L.jsx)(rx,{ref:je,slotRef:Ne,sticky:Ae,breadcrumb:we,titleStatus:r,onNavigate:S,onBack:C,actions:u,brand:me,backInLeadingSlot:me,...Te&&{leading:(0,L.jsx)(`div`,{className:`flex min-w-0 items-center`,onClick:()=>Lb(),children:(0,L.jsx)(be,{compact:!1,workspace:o,appName:s,appIcon:c})})},account:pe&&(0,L.jsx)(gS,{onBrand:me,user:a,signIn:E,open:h,items:_,account:v,onNavigate:S,onSignOut:T,organizations:D,roles:O,theme:k,status:A}),searchButton:xe===`top-bar`,searchOpen:_e,onSearchOpenChange:ve,onMenu:ae||fe?void 0:()=>se(!0),menuOpen:M,menuControls:_S,search:ee}),p,(0,L.jsx)(`main`,{className:R(Ae?`flex flex-1 flex-col`:`flex min-h-0 flex-1 flex-col`,i&&vS[i]),"aria-busy":i===`refreshing`||void 0,children:(0,L.jsxs)(iS.Provider,{value:Me,children:[ge?Fe({mode:`text-large`,page:!0}):ie,re]})}),fe&&(0,L.jsx)(zy,{ref:Pe,sticky:Ae,tabs:fe,onNavigate:S,...Se&&{onSearch:Ce,searchLabel:x===!0?void 0:x},onMore:he,moreOpen:M,moreControls:_S})]}),d&&(0,L.jsx)(`div`,{className:Ae?`sticky top-0 flex h-dvh shrink-0 self-start pt-[var(--pb-safe-top)]`:`flex shrink-0`,children:d})]})]})},bS=`protobase:signed-out`,xS=(e=window)=>{e.dispatchEvent(new Event(bS)),e.parent&&e.parent!==e&&e.parent.postMessage({type:bS},`*`)},SS=4194304,CS=(e,t=SS)=>{let n=e.reduce((e,t)=>e+t.bytes,0),r=new Set(e.map(e=>e.hash)),i=e.filter(e=>!e.pinned).sort((e,t)=>e.lastUsed-t.lastUsed);for(let e of i){if(n<=t)break;r.delete(e.hash),n-=e.bytes}return r},wS=new TextEncoder,TS=e=>wS.encode(JSON.stringify(e)??``).length,ES=1e3,DS=JSON.stringify(I.meta),OS=e=>e.state.status===`success`&&e.state.fetchFailureCount===0&&!(e.queryHash===DS&&e.state.data?.versionChange),kS=(e,t,n,r,i,a=SS)=>{let o=T(e,{shouldDehydrateQuery:OS}).queries,s=new Set(o.map(e=>e.queryHash)),c=[...o,...t.filter(e=>!s.has(e.queryHash))],l=e=>n[e.queryHash]??e.state.dataUpdatedAt,u=CS(c.map(e=>({hash:e.queryHash,bytes:e.queryHash.length+r(e.state.data),lastUsed:l(e),pinned:e.queryHash===DS||i.has(e.queryHash)})),a),d=c.filter(e=>u.has(e.queryHash));return{queries:d,used:Object.fromEntries(d.map(e=>[e.queryHash,l(e)]))}},AS=({cache:e,owner:t})=>{let n=e.queries(t),r={...n?.used},i=n?.state.queries??[],a=new WeakMap,o=e=>{if(typeof e!=`object`||!e)return TS(e);let t=a.get(e);if(t!==void 0)return t;let n=TS(e);return a.set(e,n),n};return{restore:e=>{n&&(ne(e,n.state),e.invalidateQueries({refetchType:`none`}))},subscribe:n=>{let a,s=()=>{a=void 0;let s=Date.now(),c=new Set(n.getQueryCache().findAll({type:`active`}).map(e=>e.queryHash));for(let e of c)r[e]=s;let l=kS(n,i,r,o,c);i=l.queries,r=l.used,e.saveQueries({owner:t,used:r,state:{mutations:[],queries:i}})},c=n.getQueryCache().subscribe(e=>{if(e.type===`observerAdded`)r[e.query.queryHash]=Date.now();else if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;a??=setTimeout(s,ES)});return()=>{c(),clearTimeout(a)}}}},jS=(e,t)=>e.replace(/\D/g,``).slice(0,t),MS=(e,t,n)=>{let r=jS(t??``,n);return r.length===n?r:jS(e,n)},NS=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):jS(e.slice(0,n)+i+e.slice(n+i.length),r)},PS=({value:e,onChange:t,onComplete:n,length:r=6,invalid:i,disabled:a,className:o,ref:s,onFocus:c,onBlur:l,onSelect:u,onKeyDown:d,onClick:f,onPaste:p,...m})=>{let h=(0,j.useRef)(null),[g,_]=(0,j.useState)(!1),[v,y]=(0,j.useState)(e.length),b=e.slice(0,r),x=Math.min(v,r-1),S=e=>{h.current=e,typeof s==`function`?s(e):s&&(s.current=e)},C=e=>{e!==b&&(t(e),e.length===r&&n?.(e))},w=e=>{let t=h.current;if(!t)return;let n=Math.max(0,Math.min(e,b.length));t.setSelectionRange(n,n<b.length?n+1:n),y(n)},T=e=>{if(d?.(e),e.defaultPrevented||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let t=e.currentTarget.selectionStart??b.length,n={ArrowLeft:t-1,ArrowRight:t+1,Home:0,End:b.length}[e.key];n!==void 0&&(e.preventDefault(),w(n))},E=e=>{f?.(e);let t=e.currentTarget.getBoundingClientRect();e.clientX<=t.left||e.clientX>=t.right||w(Math.floor((e.clientX-t.left)/t.width*r))};return(0,L.jsxs)(`div`,{className:R(`relative`,a&&`opacity-50`,o),children:[(0,L.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=g&&t===x;return(0,L.jsx)(`div`,{"data-slot":t,"data-digit":b[t],className:R(`flex h-12 min-w-0 max-w-12 flex-1 items-center justify-center rounded-md border bg-background font-mono text-xl font-semibold text-foreground shadow-sm transition-colors before:content-[attr(data-digit)]`,i?`border-danger`:n?`border-primary`:`border-border-strong`,n&&(i?`ring-2 ring-danger/20`:`ring-2 ring-primary/20`)),children:b[t]===void 0&&(n?(0,L.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,L.jsx)(`input`,{ref:S,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`[0-9]{${r}}`,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,"aria-invalid":i||void 0,disabled:a,value:b,className:`absolute inset-0 size-full cursor-text bg-transparent text-transparent caret-transparent outline-none selection:bg-transparent disabled:cursor-not-allowed`,...m,onChange:e=>{let{data:t,dataTransfer:n}=e.nativeEvent;C(MS(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=NS(b,e.clipboardData.getData(`text`),t.selectionStart??b.length,r);C(n),y(n.length)},onSelect:e=>{u?.(e);let t=e.currentTarget,n=t.selectionStart??b.length;n===t.selectionEnd&&n<t.value.length&&t.setSelectionRange(n,n+1),y(n)},onKeyDown:T,onClick:E,onFocus:e=>{_(!0),c?.(e)},onBlur:e=>{_(!1),l?.(e)}})]})},FS=F(`app/create`),IS=({address:e,page:t,accountPage:n,resourceLabel:r,singular:i,recordTitle:a,recordLoading:o})=>{if(t)return t.tab?[t.tab,t.title]:[t.title];if(n)return[n];if(!e||e.kind===`page`)return[];let s=r?[r]:[];if(e.kind===`list`)return s;if(e.kind===`create`)return[...i?[FS(`title`,{noun:i})]:[],...s];let c=a??(o?void 0:e.key);return[...c?[c]:[],...s]},LS=(e,t)=>[...e.filter(Boolean),t].join(` · `),RS=e=>{(0,j.useEffect)(()=>{if(e===void 0)return;let t=document.title;return document.title=e,()=>{document.title=t}},[e])},zS=({title:e,description:t,size:n=`sm`,appName:r,icon:i,footer:a,children:o})=>{let s=T_()?.identity;return RS(s?.appName),(0,L.jsxs)(`div`,{className:`flex min-h-full w-full flex-col items-center bg-background px-4 pb-[calc(2.5rem+var(--pb-safe-bottom))] pt-[calc(2.5rem+var(--pb-safe-top))] short:pb-[calc(1rem+var(--pb-safe-bottom))] short:pt-[calc(1rem+var(--pb-safe-top))]`,children:[(0,L.jsx)(`div`,{className:`flex w-full flex-1 items-center justify-center`,children:(0,L.jsxs)(`div`,{className:R(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center short:mb-4`,children:[(0,L.jsx)(Mb,{appName:r??s?.appName,appIcon:i??s?.appIcon,size:`lg`,className:`short:hidden`}),(0,L.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight short:mt-0`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,L.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:o})]})}),a]})},Z=F(`auth`),BS=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,j.useState)(()=>Date.now()+t*1e3),[a,o]=(0,j.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,j.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,L.jsx)(B,{variant:`ghost`,disabled:n||s>0,onClick:()=>{let n=Date.now();i(n+t*1e3),o(n),e()},className:`min-h-10`,children:s>0?Z(`sendNewCodeIn`,{seconds:s}):Z(`sendNewCode`)})},VS=({title:e,description:t,explanation:n,submitLabel:r,onSubmit:i,onResend:a,onChangeAddress:o,changeAddressLabel:s,busy:c,error:l,notice:u,resendCooldown:d})=>{let[f,p]=(0,j.useState)(``),m=(0,j.useRef)(null);return(0,j.useEffect)(()=>{u&&(p(``),m.current?.focus())},[u]),(0,L.jsxs)(zS,{title:e,description:t,children:[(0,L.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,L.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:u}),(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`code`),(0,L.jsx)(PS,{ref:m,name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,L.jsx)(BS,{onResend:a,disabled:c,cooldown:d})]})]})]})},HS=({email:e,onBack:t,...n})=>(0,L.jsx)(VS,{title:Z(`checkEmail`),description:Z(`signInCodeDescription`),explanation:(0,L.jsx)(L.Fragment,{children:Z.rich(`signInCodeSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`signIn`),onChangeAddress:t,changeAddressLabel:Z(`backToSignIn`),...n}),US=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=J(),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(),[c,l]=(0,j.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;s(Qv(e))}a(!1)};return(0,L.jsx)(HS,{email:e,busy:i,error:o,notice:c,onBack:t,onSubmit:t=>void u(()=>n(e,t)),onResend:()=>void u(async()=>{await r(e),l(Z(`newCodeSent`))})})},WS=`protobase users create you@example.com`,GS=({command:e=WS,firstAdminUrl:t,onCheckAgain:n,busy:r})=>(0,L.jsxs)(zS,{title:Z(`noAdminTitle`),description:Z(`noAdminDescription`),children:[t?(0,L.jsx)(KS,{url:t}):(0,L.jsx)(qS,{command:e}),(0,L.jsx)(B,{variant:t?`secondary`:`primary`,className:`mt-4 min-h-10 w-full`,loading:r,onClick:n,children:Z(`reload`)})]}),KS=({url:e})=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`firstAdminExplanation`)}),(0,L.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:R(hu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:[Z(`firstAdminLink`),(0,L.jsx)(Ms,{className:`size-4`})]})]}),qS=({command:e})=>{let[t,n]=(0,j.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`noAdminExplanation`)}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":Z(`copyCommand`),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:t?(0,L.jsx)(Xo,{className:`size-4 text-success`}):(0,L.jsx)(gs,{className:`size-4`})})]})]})},JS=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,j.useState)(``);return i?(0,L.jsxs)(zS,{title:Z(`checkEmail`),children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z.rich(`resetSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:i})})}),(0,L.jsx)(Du,{to:t,className:R(hu({variant:`primary`}),`mt-4 min-h-10 w-full`),children:Z(`backToSignIn`)})]}):(0,L.jsx)(zS,{title:Z(`resetTitle`),description:Z(`resetDescription`),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Hb,{type:`email`,name:`email`,autoComplete:`username`,required:!0,autoFocus:!0,value:a,invalid:!!r,onChange:e=>o(e.target.value),className:`min-h-6`})]}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:Z(`sendResetLink`)}),(0,L.jsx)(Du,{to:t,className:R(hu({variant:`ghost`}),`min-h-10`),children:Z(`backToSignIn`)})]})})},YS=`password-reset`,XS=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${YS}`},ZS=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},QS=e=>{let t=new URL(e);for(let e of[YS,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},$S=({back:e})=>{let{session:t}=J(),[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.requestPasswordReset(e,XS(window.location.href)),s(e)}catch(e){if(!(e instanceof K))throw e;a(e.status===429?Z(`tooManyRequests`):e.message)}r(!1)};return(0,L.jsx)(JS,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},eC=({name:e,workspace:t})=>(0,L.jsx)(zS,{title:Z(`signingInWith`,{name:e}),description:t,children:(0,L.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Z(`takingYouTo`,{name:e})]})}),tC=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=J(),a=r.find(t=>t.id===e),o=a?.name??m_(e),s=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(Z(`providerNotOffered`,{name:o}));i(e).catch(e=>{if(!(e instanceof K))throw e;n(ey(e))})}},[a,o,e,i,n]),(0,L.jsx)(eC,{name:o,workspace:t})},nC=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1);if(t)return(0,L.jsxs)(zS,{title:Z(`linkExpiredTitle`),children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`linkExpiredExplanation`)}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,L.jsx)(B,{variant:`primary`,className:`min-h-10`,onClick:n,children:Z(`sendNewLink`)}),(0,L.jsx)(B,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:Z(`backToSignIn`)})]})]});let f=u?Z(`passwordsDiffer`):a;return(0,L.jsx)(zS,{title:Z(`choosePassword`),description:Z(`atLeast`,{length:12}),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`newPassword`),(0,L.jsx)(Hb,{type:`password`,name:`new-password`,autoComplete:`new-password`,required:!0,minLength:12,autoFocus:!0,value:o,invalid:!!f,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`repeatPassword`),(0,L.jsx)(Hb,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,required:!0,minLength:12,value:c,invalid:!!f,onChange:e=>l(e.target.value),className:`min-h-6`})]}),f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`setPassword`)})]})})},rC=e=>e.status===429?Z(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?Z(`useAtLeast`,{length:12}):e.code===`PASSWORD_TOO_LONG`?Z(`passwordTooLong`):Qv(e),iC=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=J(),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(),[l,u]=(0,j.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof K))throw e;e.code===`INVALID_TOKEN`?u(!0):c(rC(e)),o(!1)}};return(0,L.jsx)(nC,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},aC=F(`app/confirm-sign-in`),oC=({minutes:e,purpose:t=`show`,withPassword:n=!1,onConfirmed:r})=>{let i=T_(),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(!1),p=O({queryKey:[`account-sign-in-methods`],queryFn:()=>i.session.account.signInMethods(),enabled:!!i}),m=S({mutationFn:()=>i.signInWithPasskey(),onSuccess:r}),h=S({mutationFn:e=>i.verifyTwoFactor({method:`totp`,code:e}),onSuccess:r}),g=p.data?.account,_=g?g.twoFactor&&!g.authenticatorApp?`second-step`:p.data?.mail&&g.passkeys===0&&!g.twoFactor?`confirmation`:void 0:void 0,v=n&&g!==void 0&&g.password&&g.passkeys===0&&!g.twoFactor,y=S({mutationFn:e=>i.session.account.confirmWithPassword(e),onSuccess:r}),b=S({mutationFn:async e=>{_===`second-step`?await i.verifyTwoFactor({method:`otp`,code:e}):await i.session.account.confirmWithCode(e)},onSuccess:r}),x=S({mutationFn:()=>_===`second-step`?i.session.sendTwoFactorCode():i.session.account.sendConfirmationCode(),onSuccess:()=>{f(!0),u(``),b.reset()}}),C=m.error??h.error??y.error??x.error??b.error??p.error;return(0,L.jsxs)(`section`,{"aria-label":aC(`confirmTitle`),className:`mt-2 flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:aC(`confirmTitle`)}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:aC(t===`change`?`confirmWhyChange`:`confirmWhy`,{minutes:e})}),g&&g.passkeys>0&&(0,L.jsx)(B,{variant:`primary`,size:`sm`,className:`self-start`,loading:m.isPending,onClick:()=>m.mutate(),children:aC(`usePasskey`)}),g?.authenticatorApp&&(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),h.mutate(a.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[aC(`authenticatorCode`),(0,L.jsx)(PS,{name:`code`,required:!0,value:a,invalid:h.isError,onChange:o,onComplete:e=>h.mutate(e)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:h.isPending,children:aC(`confirm`)})]}),v&&(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),y.mutate(s)},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[aC(`password`),(0,L.jsx)(Hb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:y.isPending,children:aC(`confirm`)})]}),_&&!d&&(0,L.jsx)(B,{variant:`primary`,size:`sm`,className:`self-start`,loading:x.isPending,onClick:()=>x.mutate(),children:aC(`emailCode`)}),_&&d&&(0,L.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),b.mutate(l.trim())},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:aC(`codeSent`,{minutes:10})}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[aC(`emailedCode`),(0,L.jsx)(PS,{name:`code`,required:!0,value:l,invalid:b.isError,onChange:u,onComplete:e=>b.mutate(e)})]}),(0,L.jsx)(B,{type:`submit`,size:`sm`,loading:b.isPending,children:aC(`confirm`)}),(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:x.isPending,onClick:()=>x.mutate(),children:aC(`emailNewCode`)})]})]}),g&&g.passkeys===0&&!g.authenticatorApp&&_===void 0&&!v&&(0,L.jsx)(`p`,{children:aC(`nothingToConfirmWith`)}),C&&(0,L.jsx)(`p`,{role:`alert`,className:`font-medium text-danger-text`,children:C.message})]})},sC=(e,t,n=`text/plain`)=>{let r=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(document.createElement(`a`),{href:r,download:t}).click(),URL.revokeObjectURL(r)},cC=({codes:e})=>{let[t,n]=(0,j.useState)(!1),r=`${e.join(`
3
+ `)}\n`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`ul`,{"aria-label":Y(`backupCodes`),className:`grid grid-cols-2 gap-x-4 gap-y-1 rounded-md border bg-surface p-3 font-mono`,children:e.map(e=>(0,L.jsx)(`li`,{children:e},e))}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsxs)(B,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,L.jsx)(Xo,{className:`size-3.5 text-success`}):(0,L.jsx)(gs,{className:`size-3.5`}),Y(t?`copied`:`copy`)]}),(0,L.jsxs)(B,{size:`sm`,onClick:()=>sC(r,`backup-codes.txt`),children:[(0,L.jsx)(ws,{className:`size-3.5`}),Y(`download`)]})]})]})},lC=({uri:e,className:t})=>{let{size:n,path:r}=(0,j.useMemo)(()=>{let t=D(e,{ecc:`M`,border:2}),n=t.data.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[]));return{size:t.size,path:n.join(``)}},[e]);return(0,L.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":Y(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,L.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,L.jsx)(`path`,{d:r,fill:`#000`})]})},uC=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),dC=()=>[{value:`app`,label:Y(`authenticatorApp`),description:Y(`authenticatorAppDescription`)},{value:`email`,label:Y(`emailedCode`),description:Y(`emailedCodeDescription`)}],fC=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,j.useState)({kind:`choose`}),[l,u]=(0,j.useState)(`app`),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(),[y,b]=(0,j.useState)(!1),x=e?dC():dC().filter(e=>e.value===`app`),S=async e=>{g(!0),v(void 0),b(!1);try{await e()}catch(e){if(!(e instanceof K))throw e;e.code===`STRONG_SIGN_IN_REQUIRED`?b(!0):v(Qv(e))}g(!1)},C=()=>S(async()=>{let e=t?d:void 0;if(l===`email`)return await i(e),a();c({kind:`scan`,setup:await n(e)})}),w=(e,t=p)=>S(async()=>{await r(t),c({kind:`backup-codes`,codes:e.backupCodes})}),T=_&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:_});return s.kind===`backup-codes`?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`twoFactorIsOn`)}),(0,L.jsx)(cC,{codes:s.codes}),(0,L.jsx)(B,{variant:`primary`,onClick:a,className:`min-h-10`,children:Y(`savedCodes`)})]}):s.kind===`scan`?(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),w(s.setup)},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Y(`scanCode`)}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,L.jsx)(lC,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,L.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[Y(`cannotScan`),(0,L.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:uC(s.setup.totpURI)})]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`codeFromApp`),(0,L.jsx)(PS,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!_,onChange:m,onComplete:e=>!h&&void w(s.setup,e)})]}),T,(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`turnOn`)}),o&&(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":Y(`secondStep`),className:`flex flex-col gap-2`,children:x.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.value,onClick:()=>u(e.value),className:R(`rounded-md border p-3 text-left transition-colors`,l===e.value?`border-primary bg-primary-soft`:`border-border-strong hover:bg-muted`),children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,L.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Y(`yourPassword`),(0,L.jsx)(Hb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:d,invalid:!!_,onChange:e=>f(e.target.value),className:`min-h-6`})]}),T,(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:Y(`continue`)}),o&&(0,L.jsx)(B,{variant:`ghost`,onClick:o,className:`min-h-10`,children:Y(`cancel`)})]}),y&&(0,L.jsx)(oC,{purpose:`change`,minutes:15,onConfirmed:()=>void C()})]})},pC=e=>Z(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),mC=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,L.jsxs)(zS,{title:pC(e),description:Z(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,L.jsx)(fC,{...t}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`passkeyExplanation`)}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsxs)(B,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,L.jsx)(Xs,{className:`size-4`}),Z(`addPasskey`)]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:Z(`signOut`)})]}),hC=({missing:e})=>{let{session:t,recheck:n,signOut:r}=J(),[i,a]=(0,j.useState)(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)();(0,j.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof K?Qv(e):Z(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof K))throw e;l(Qv(e)),s(!1)}};return!i&&!c?(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Z(`loading`)]}):(0,L.jsx)(mC,{step:e[0],busy:o,error:c,onAddPasskey:()=>void u(),onSignOut:()=>void r(),twoFactor:{offerEmailedCodes:i?.mail??!1,needsPassword:i?.account.password??!0,onStartApp:e=>t.account.startAuthenticatorApp(e),onConfirmApp:e=>t.account.confirmAuthenticatorApp(e),onEmailedCodes:e=>t.account.turnOnEmailedCodes(e),onDone:n}})},gC=({className:e})=>(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:R(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943`})}),_C=({id:e,className:t})=>e===`github`?(0,L.jsx)(gC,{className:t}):null,vC=`https://protobase.net/`,yC=()=>(0,L.jsx)(`footer`,{className:`mt-8 text-center`,children:(0,L.jsx)(`a`,{href:vC,rel:`nofollow noreferrer`,className:`inline-block text-sm font-normal leading-6 text-muted-foreground no-underline hover:underline focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,children:Z(`runsOnProtobase`)})}),bC=()=>(0,L.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`h-px flex-1 bg-border`}),Z(`or`),(0,L.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),xC=({onSubmit:e,busy:t,error:n,workspace:r,notice:i,methods:a=[`password`],first:o=`password`,onSendCode:s,onPasskey:c,passkeyDomains:l=[],forgotPassword:u,providers:d=[],onContinueWith:f,signUp:p,onBrowse:m,appName:h,runsOnNote:g=!1})=>{let[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!1),C=(0,j.useRef)(null),w=a.includes(`password`),T=a.includes(`emailCode`)&&s!==void 0,E=a.includes(`passkey`)&&c!==void 0,D=f?d:[],O=o===`emailCode`&&w&&T&&!x,k=w&&!O,A=()=>{C.current?.reportValidity()&&s?.(_.trim())};return(0,L.jsxs)(zS,{title:Z(`signInTitle`,{name:h??`Protobase`}),description:r,appName:h,footer:g&&(0,L.jsx)(yC,{}),children:[i&&(0,L.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(D.length>0||E)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[D.map(e=>(0,L.jsxs)(B,{onClick:()=>f?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,L.jsx)(_C,{id:e.id}),Z(`continueWith`,{name:e.name})]},e.id)),E&&(0,L.jsxs)(B,{onClick:()=>c?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,L.jsx)(Xs,{className:`size-4`}),Z(`signInWithPasskey`)]}),E&&l.slice(1).map(e=>(0,L.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>c?.(e),disabled:t,className:`w-full`,children:Z(`passkeyFor`,{domain:e})},e))]}),w||T?(0,L.jsx)(bC,{}):n&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(w||T)&&(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),k?e(_.trim(),y):A()},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Hb,{ref:C,type:`email`,name:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,value:_,invalid:!!n,onChange:e=>v(e.target.value),className:`min-h-6`})]}),k&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`password`),(0,L.jsx)(Hb,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:y,invalid:!!n,onChange:e=>b(e.target.value),className:`min-h-6`})]}),n&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),k&&(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:Z(`signIn`)}),T&&(0,L.jsxs)(B,{variant:k?`secondary`:`primary`,type:k?`button`:`submit`,onClick:k?A:void 0,loading:t&&!k,disabled:t,className:`min-h-10`,children:[(0,L.jsx)(mc,{className:`size-4`}),Z(`emailSignInCode`)]}),O&&(0,L.jsx)(B,{variant:`ghost`,onClick:()=>S(!0),disabled:t,className:`min-h-10`,children:Z(`usePassword`)}),k&&u&&(0,L.jsx)(Du,{to:u,className:`self-center font-medium text-primary-text hover:underline`,children:Z(`forgotPassword`)})]}),p&&(0,L.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[Z(`newHere`),` `,(0,L.jsx)(Du,{to:p,className:`font-medium text-primary-text hover:underline`,children:Z(`createAnAccount`)})]}),m&&(0,L.jsx)(`button`,{type:`button`,onClick:m,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:Z(`browse`)})]})},SC=({workspace:e,notice:t,forgotPassword:n,signUp:r,onBrowse:i,onCodeSent:a,error:o})=>{let{identity:s,signIn:c,signInSocial:l,signInProviders:u,signInMethods:d,signInFirst:f,passkeyDomains:p,sendSignInCode:m,signInWithPasskey:h}=J(),[g,_]=(0,j.useState)(!1),[v,y]=(0,j.useState)(o),b=async(e,t)=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;y(t(e)),_(!1)}};return(0,L.jsx)(xC,{busy:g,error:v,workspace:e,notice:t,methods:d,first:f,forgotPassword:n,signUp:r,onBrowse:i,...s.appName&&{appName:s.appName},runsOnNote:s.runsOnNote,providers:h_(u),onContinueWith:e=>void b(()=>l(e),ey),passkeyDomains:p,onPasskey:e=>void b(()=>h(e),Qv),onSendCode:e=>void b(async()=>{await m(e),a(e)},Qv),onSubmit:(e,t)=>void b(()=>c(e,t),ey)})},CC=({email:e,onBack:t,...n})=>(0,L.jsx)(VS,{title:Z(`checkEmail`),description:Z(`signUpCodeDescription`),explanation:(0,L.jsx)(L.Fragment,{children:Z.rich(`signUpCodeSent`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),minutes:10})}),submitLabel:Z(`continue`),onChangeAddress:t,changeAddressLabel:Z(`useAnotherAddress`),...n}),wC=({email:e,onSubmit:t,onBack:n,methods:r,askName:i=!0,busy:a,error:o})=>{let[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),d=(0,j.useId)(),f=r.includes(`password`),p=r.includes(`emailCode`);return(0,L.jsxs)(zS,{title:Z(`detailsTitle`),description:Z(`detailsDescription`),children:[(0,L.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:Z.rich(`codeWasRight`,{email:(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e})})}),(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({...i&&{name:s.trim()},...f&&l&&{password:l}})},children:[i&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`yourName`),(0,L.jsx)(Hb,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),f&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(p?`passwordOptional`:`password`),(0,L.jsx)(Hb,{type:`password`,name:`password`,autoComplete:`new-password`,"aria-describedby":d,required:!p,minLength:12,maxLength:128,value:l,onChange:e=>u(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`p`,{id:d,className:`text-xs text-muted-foreground`,children:[Z(`atLeast`,{length:12}),p&&Z(`withoutPassword`)]})]}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`createAccount`)}),(0,L.jsx)(B,{variant:`ghost`,onClick:n,className:`min-h-10`,children:Z(`useAnotherAddress`)})]})]})},TC=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,j.useState)(``);return(0,L.jsxs)(zS,{title:Z(`createAnAccount`),description:a,children:[(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`email`),(0,L.jsx)(Hb,{type:`email`,name:`email`,autoComplete:`email`,required:!0,autoFocus:!0,value:o,invalid:!!i,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToConfirm`)}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsxs)(B,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,L.jsx)(mc,{className:`size-4`}),Z(`emailCode`)]}),(0,L.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[Z(`haveAccount`),` `,(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:Z(`signIn`)})]})]}),n&&(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:Z(`browseWithoutAccount`)})]})},EC=({workspace:e,email:t,ticket:n,onCodeSent:r,onVerified:i,onBack:a,onSignIn:o,onBrowse:s})=>{let{signInMethods:c,sendSignUpCode:l,verifySignUpCode:u,signUp:d,signUpAsksName:f}=J(),p=f||c.includes(`password`)&&!c.includes(`emailCode`),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(),[v,y]=(0,j.useState)(),b=async e=>{h(!0),_(void 0),y(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;_(Qv(e))}h(!1)};return t===void 0?(0,L.jsx)(TC,{workspace:e,busy:m,error:g,onSignIn:o,onBrowse:s,onSubmit:e=>void b(async()=>{await l(e),r(e)})}):n===void 0?(0,L.jsx)(CC,{email:t,busy:m,error:g,notice:v,onBack:a,onSubmit:e=>void b(async()=>{let n=await u(t,e);p?i(n):await d({ticket:n})}),onResend:()=>void b(async()=>{await l(t),y(Z(`newCodeSent`))})}):(0,L.jsx)(wC,{email:t,methods:c,askName:f,busy:m,error:g,onBack:a,onSubmit:e=>void b(()=>d({ticket:n,...e}))})},DC=`staff-sign-in`,OC=`staff-error`,kC=e=>{let t=new URL(e).searchParams,n=t.get(OC);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(DC);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},AC=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[DC,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete(OC),`${t.pathname}${t.search}${t.hash}`},jC=10,MC=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,j.useState)(t),[l,u]=(0,j.useState)(n);return e?(0,L.jsx)(zS,{title:Z(`signInAsPerson`),description:Z(`forStaffOf`,{operator:e}),children:(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`theirEmail`),(0,L.jsx)(Hb,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(`reason`),(0,L.jsx)(`textarea`,{name:`reason`,required:!0,minLength:jC,rows:3,value:l,placeholder:Z(`reasonExample`),onChange:e=>u(e.target.value),className:R(`resize-y rounded-md border bg-background px-2.5 py-1.5 font-normal shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,o?`border-danger`:`border-border-strong`)})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`staffExplanation`,{operator:e})}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:Z(`continueWith`,{name:e})}),(0,L.jsx)(B,{variant:`ghost`,onClick:i,className:`min-h-10`,children:Z(`backToSignIn`)})]})}):(0,L.jsxs)(zS,{title:Z(`staffTitle`),description:Z(`staffUnavailable`),children:[o&&(0,L.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,L.jsx)(B,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:Z(`backToSignIn`)})]})},NC=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=J(),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(e.error&&ny(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${AC(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof K))throw e;s(ny(e)),a(!1)}};return(0,L.jsx)(MC,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},PC=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,L.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e,"aria-label":r,disabled:i,onClick:()=>n?.(!e),className:R(`relative inline-flex size-4 shrink-0 items-center justify-center rounded border transition-colors after:absolute after:-inset-1 after:content-[""] pointer-coarse:after:-inset-3.5`,e||t?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background hover:border-faint-foreground`,a),children:t?(0,L.jsx)(wc,{className:`size-3`,strokeWidth:3}):e&&(0,L.jsx)(Xo,{className:`size-3`,strokeWidth:3})}),FC={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},IC=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,j.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,L.jsxs)(zS,{title:Z(`twoFactorTitle`),description:Z(`twoFactorDescription`),children:[m?(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`codeToFinish`)}),a&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,L.jsx)(B,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:Z(`emailCode`)})]}):(0,L.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(FC[c],{minutes:10})}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Z(c===`backup`?`backupCode`:`code`),c===`backup`?(0,L.jsx)(Hb,{name:`code`,autoComplete:`off`,spellCheck:!1,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:e=>d(e.target.value),className:`min-h-6 font-mono`}):(0,L.jsx)(PS,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(PC,{checked:f,onChange:p,label:Z(`trustBrowser`)}),Z(`trustBrowserFor`)]}),a&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:Z(`verify`)})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:Z(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:Z(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:Z(`useBackupCode`)}),(0,L.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:Z(`backToSignIn`)})]})]})},LC=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=J(),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(),[c,l]=(0,j.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof K))throw e;s(Qv(e))}a(!1)};return(0,L.jsx)(IC,{methods:e,busy:i,error:o,codeSent:c,onBack:t,onVerify:e=>void u(()=>n(e)),onSendCode:()=>void u(async()=>{await r.sendTwoFactorCode(),l(!0)})})},RC=()=>{let{path:e,params:t,basePath:n,navigate:r}=Hu(),i=(0,j.useMemo)(()=>wd(e,t),[e,t]),a=f_(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,j.useCallback)((e=`sign-in`,t)=>r(Cd({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,j.useCallback)((e=`sign-in`,t)=>({href:`${n}${Cd({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,j.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},zC=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},BC=e=>`${new URL(e).pathname.slice(0,-13)}/`,Q=F(`organizations`),VC=`/-/organizations`,HC=`/-/organization`,UC=`/-/organization/members`,WC=`/-/organization/invitations`,GC=`/-/first-organization`,KC=`/-/first-organization/new`,qC={[VC]:`organizations`,[HC]:`organization`,[UC]:`members`,[WC]:`invitations`,[GC]:`createTitle`,[KC]:`createTitle`},JC=(e,t)=>{let n=qC[e];return n&&t(n)},YC=e=>e===`/-/first-organization`||e===`/-/first-organization/new`,XC=e=>Q(e),ZC=(e,t)=>e.find(e=>e.name===t)?.label??t,QC=e=>e?.role===`owner`||e?.role===`admin`,$C=(e,t,n,r)=>{let i=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[i(`organizations`,n(`manageOrganizations`),Pc,VC),...r?.organization?[i(`organization`,n(`organization`),Wo,HC)]:[],...QC(r)?[i(`members`,n(`members`),Xl,UC),i(`invitations`,n(`invitations`),mc,WC)]:[]]},ew=(e,t)=>{let n=[...t?.globalRoles??[],...t?.appRoles??[]],r=e.filter(e=>e.membership).map(e=>e.name);if(n.includes(`admin`))return new Set(r);let i=n.flatMap(t=>e.find(e=>e.name===t)?.grants??[]);return new Set([...n,...i].filter(e=>r.includes(e)))},tw=async(e,{setBusy:t,setError:n})=>{t(!0),n(void 0);try{await e()}catch(e){if(e instanceof K)return n(Qv(e));if(e instanceof Rh)return n($v());throw e}finally{t(!1)}},nw=()=>{let[e,t]=(0,j.useState)(!1),[n,r]=(0,j.useState)();return{busy:e,error:n,run:e=>tw(e,{setBusy:t,setError:r}),setError:r}},rw=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=J(),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),{busy:d,error:f,run:p}=nw(),m=a.includes(`password`),h=a.includes(`emailCode`),g=()=>p(async()=>{await i.organizations.signUpFromInvitation(e,{name:s.trim(),...m&&l&&{password:l}}),r(),o()});return(0,L.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Q(n?`makeAccountToJoin`:`makeAccount`,{email:t.email})}),f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(Hb,{"aria-label":Q(`yourName`),placeholder:Q(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,L.jsx)(Hb,{"aria-label":Q(`password`),type:`password`,autoComplete:`new-password`,placeholder:Q(h?`passwordOptional`:`passwordRequired`,{length:12}),value:l,onChange:e=>u(e.target.value)}),(0,L.jsx)(B,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:Q(n?`createAndJoin`:`createYourAccount`)})]})},iw=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=J(),[s,c]=(0,j.useState)(),[l,u]=(0,j.useState)(),{busy:d,error:f,run:p}=nw();if((0,j.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof K?Qv(e):Q(`invalidLink`)))},[r,e]),l)return(0,L.jsx)(zS,{title:Q(`invitation`),description:l,children:(0,L.jsx)(B,{className:`w-full`,onClick:t,children:Q(`goToApp`)})});if(!s)return(0,L.jsx)(zS,{title:Q(`invitation`),children:(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,Q(`loading`)]})});let m=i.kind===`signed-in`?i.user:void 0,h=m?.email.toLowerCase()===s.email.toLowerCase();if(!s.organization){let r=s.app?.name??``,i=Q(`invitesToApp`,{inviter:s.inviter.name,app:r});return(0,L.jsx)(zS,{title:Q(`join`,{name:r}),description:i,children:s.hasAccount?m&&h?(0,L.jsx)(B,{variant:`primary`,className:`w-full`,onClick:t,children:Q(`goToApp`)}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`hasAccount`,{email:s.email})}),m?(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOut`)}):(0,L.jsx)(Du,{to:n,className:R(hu({variant:`primary`}),`w-full`),children:Q(`signInAs`,{email:s.email})})]}):m?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,L.jsx)(rw,{token:e,preview:s,joins:!1,onDone:t})})}let g=s.organization,_=s.appRoles.map(e=>ZC(o?.roles??[],e)),v=XC(s.role).toLowerCase(),y=_.length>0?Q(`invitesToWith`,{inviter:s.inviter.name,organization:g.name,role:v,roles:_.join(`, `)}):Q(`invitesTo`,{inviter:s.inviter.name,organization:g.name,role:v});return m&&!h?(0,L.jsxs)(zS,{title:Q(`join`,{name:g.name}),description:y,children:[(0,L.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:Q(`otherAddress`,{invited:s.email,signedIn:m.email})}),(0,L.jsx)(B,{className:`w-full`,onClick:()=>void a(),children:Q(`signOutToAccept`)})]}):(0,L.jsx)(zS,{title:Q(`join`,{name:g.name}),description:y,children:m?(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,L.jsx)(B,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:Q(`join`,{name:g.name})})]}):s.hasAccount?(0,L.jsx)(Du,{to:n,className:R(hu({variant:`primary`}),`w-full`),children:Q(`signInAsToJoin`,{email:s.email})}):(0,L.jsx)(rw,{token:e,preview:s,joins:!0,onDone:t})})},aw=({children:e})=>(0,L.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),ow=F(`app/pages`),sw=class extends j.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){kg(e,t.componentStack)}componentDidUpdate(e){this.state.failed&&e.resetKey!==this.props.resetKey&&this.setState({failed:!1})}render(){return this.state.failed?this.props.fallback===void 0?(0,L.jsx)(aw,{children:ow.rich(`couldNotDraw`,{name:this.props.name})}):this.props.fallback:this.props.children}},cw=(e,t)=>{let n=Ta(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{Ta(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof ya))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:Ta(...r,n),off:i}},lw=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=J(),{path:i,params:a,navigate:o}=Hu(),{loads:s,settled:c}=Xa(n,qa()),l=(0,j.useMemo)(()=>cw(void 0,s).ui.beforeSignIn,[s]),u=(0,j.useCallback)(e=>{let t=new URLSearchParams(a);for(let n of e)t.delete(n);o(t.size>0?`${i}?${t}`:i,{replace:!0})},[i,a,o]);return t.kind!==`signed-out`&&t.kind!==`visitor`?e:c?l?(0,L.jsx)(sw,{name:`beforeSignIn`,fallback:e,children:(0,L.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(vv,{}),(0,L.jsx)(fu,{}),` `,da(`loading`)]})},uw=()=>{let e=window.location.href,t=ZS(e);if(t)return{kind:`reset-password`,token:t.token};let n=kC(e);if(n)return{kind:`staff-sign-in`,link:n};let r=zC(e);if(r)return{kind:`invitation`,token:r.token};let i=c_(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=l_(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},dw=({to:e})=>{let{navigate:t}=Hu();return(0,j.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},fw=({workspace:e,children:t})=>{let n=pw(e,t);return(0,L.jsx)(lw,{children:n})},pw=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=J(),{path:l,params:u,basePath:d,navigate:f}=Hu(),{address:p,next:m,open:h,link:g,leave:_}=RC(),[v,y]=(0,j.useState)(uw),[b,x]=(0,j.useState)(),[S,C]=(0,j.useState)(),[w,T]=(0,j.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,j.useCallback)(e=>{let t=e(E).slice(d.length);f(t.startsWith(`/`)?t:`/${t}`,{replace:!0})},[E,d,f]),O=n.kind===`signed-in`||n.kind===`two-factor`||n.kind===`setup-required`,k=d_(E)!==void 0;(0,j.useEffect)(()=>{O&&((v.kind===`provider-sign-in`||k)&&D(f_),(v.kind===`provider-sign-in`||v.kind===`sign-in`&&(v.notice||v.error||v.providerError))&&y({kind:`sign-in`}),x(void 0),C(void 0),T(void 0))},[O,v,k,D]);let A=p!==void 0&&l_(E)!==void 0;(0,j.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&A&&D(f_)},[O,v,A,D]);let ee=(0,j.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),te=e=>{D(QS),y(e)},ne=async()=>{n.kind===`signed-in`&&await a(),te({kind:`sign-in`,notice:Z(`passwordChanged`)})},re=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(vv,{}),(0,L.jsx)(fu,{}),` `,Z(`loading`)]});case`error`:return(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`cannotReach`,{message:n.message??Z(`noAnswer`)})}),(0,L.jsx)(B,{onClick:r,children:Z(`tryAgain`)})]});case`needs-admin`:return(0,L.jsx)(GS,{firstAdminUrl:n.firstAdminUrl,onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,L.jsx)(dw,{to:m??`/`});if(v.kind===`reset-password`)return(0,L.jsx)(iC,{token:v.token,onDone:()=>void ne(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Cd({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>te({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,L.jsx)(NC,{link:v.link,onBack:()=>{D(AC),y({kind:`sign-in`})}});let ie=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||ie&&!p))return(0,L.jsx)(iw,{token:v.token,onDone:()=>{D(BC),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,L.jsx)(LC,{methods:n.methods,onBack:re});if(n.kind===`setup-required`)return(0,L.jsx)(hC,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,L.jsx)(tC,{provider:v.provider,workspace:e,onFailed:ee});let ae=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=ae.notice||ae.error||ae.providerError;return n.kind===`visitor`&&!e?t:(0,L.jsx)(dw,{to:Cd({next:m})})}let oe={"sign-in":!0,"forgot-password":i,"email-code":b!==void 0,"sign-up":s,"sign-up-code":s&&S!==void 0,"sign-up-details":s&&w!==void 0}[p.step]?p.step:`sign-in`,M=e=>()=>h(e,{replace:!0}),se=c&&(()=>{c(),_()});if(oe===`forgot-password`)return(0,L.jsx)($S,{back:g(`sign-in`,{replace:!0})});if(oe===`email-code`)return(0,L.jsx)(US,{email:b,onBack:M(`sign-in`)});if(oe===`sign-up`||oe===`sign-up-code`||oe===`sign-up-details`)return(0,L.jsx)(EC,{workspace:e,email:oe===`sign-up`?void 0:S,ticket:oe===`sign-up-details`?w:void 0,onCodeSent:e=>{C(e),T(void 0),h(`sign-up-code`)},onVerified:e=>{T(e),h(`sign-up-details`,{replace:!0})},onBack:M(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:se},oe);let ce=ae.providerError&&iy(ae.providerError,o.length===1?o[0].name:`the provider`),le=ae.error??ce;return(0,L.jsx)(SC,{workspace:e,notice:ae.notice,error:le,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:se},le)},mw=e=>e.charAt(0).toUpperCase()+e.slice(1),hw=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),gw=e=>hw(e).includes(`admin`),_w=e=>mw(e.replace(/[_-]+/g,` `).trim()),vw=e=>{let t=hw(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:Eb(e.name||e.email)||`?`,hue:Tb(e.id||e.email),role:n?Z(`admin`):_w(t[0]??`user`),roleTone:n?`violet`:`blue`}},yw=3e4,bw=(e,t=Date.now())=>Math.max(1e3,dg(e)-t-yw),xw=()=>{let{state:e,session:t}=J(),n=e.kind===`signed-in`,[r,i]=(0,j.useState)();return(0,j.useEffect)(()=>{if(!n)return;let e=!0,r,a=async n=>{let o=await t.token(),s=o!==void 0&&o===n?await t.token({refresh:!0}):o;e&&(i(s),s&&(r=setTimeout(()=>void a(s),bw(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},Sw=({children:e})=>(0,L.jsx)(Cv,{locale:J().locale,children:e}),Cw=e=>{if(e?.kind!==`signed-in`)return;let{id:t,name:n}=e.user;return{id:t,...n&&{name:n}}},ww=()=>{let e=T_()?.state;return(0,j.useMemo)(()=>Cw(e),[e])},Tw=e=>{let t=Cw(e);return t?`user:${t.id}`:`state:${e.kind}`},Ew=`typing`,Dw=3e3,Ow=6e3,kw=(e,t,n)=>{if(t.event!==`typing`||t.channel===void 0||typeof t.payload.typing!=`boolean`)return e;let r=new Map(e.get(t.channel));t.payload.typing?r.set(t.from.user,n+Ow):r.delete(t.from.user);let i=new Map(e);return r.size>0?i.set(t.channel,r):i.delete(t.channel),i},Aw=(e,t)=>{if(![...e.values()].some(e=>[...e.values()].some(e=>e<=t)))return e;let n=new Map;for(let[r,i]of e){let e=new Map([...i].filter(([,e])=>e>t));e.size>0&&n.set(r,e)}return n},jw=e=>{let t=[...e.values()].flatMap(e=>[...e.values()]);return t.length===0?void 0:Math.min(...t)},Mw=(e,t,n)=>[...e.get(t)?.keys()??[]].filter(e=>e!==n),Nw=(e,t)=>{let n=-1/0,r=!1,i,a=()=>{i=void 0,e(!0)&&(n=t.now(),r=!0)},o=()=>{i?.(),i=void 0},s=()=>{o(),r&&(r=!1,e(!1))};return{onText:e=>{if(e.trim()===``)return s();if(i)return;let r=n+Dw-t.now();if(r<=0)return a();i=t.setTimer(a,r)},onSent:s,dispose:o}},Pw=(0,j.createContext)(void 0),Fw=()=>(0,j.useContext)(Pw),Iw=()=>()=>{},Lw=()=>void 0,Rw=e=>{let t=Fw(),n=(0,j.useSyncExternalStore)(t?.store.subscribe??Iw,t?.store.typers??Lw,t?.store.typers??Lw);return n&&t?Mw(n,e,t.me):[]},zw=()=>{let e=Fw(),t=(0,j.useSyncExternalStore)(e?.store.subscribe??Iw,e?.store.typers??Lw,e?.store.typers??Lw);return!t||!e?new Set:new Set([...t.keys()].filter(n=>Mw(t,n,e.me).length>0))},Bw=(e,t)=>{let n=new Set,r,i=()=>{r=void 0;let i=new Set(n);n.clear();let a=e=>Ji(e,i);e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]!==`record`}),e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]===`record`,refetchType:t()?`none`:`active`})};return{changed:e=>{for(let t of e)n.add(t);n.size>0&&!r&&(r=setTimeout(i,300))},stop:()=>clearTimeout(r)}},Vw=e=>{let t=X(),n=Fw(),r=x(),i=(0,j.useContext)(H_),a=(0,j.useMemo)(()=>n?new Set(e.relay?.resources??[]):new Set,[n,e.relay]),o=(0,j.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!a.has(t.name)&&!mv(e,t.name)).map(e=>e.name).sort().join(`,`),[e,a]);(0,j.useEffect)(()=>{if(!n||a.size===0)return;let e=Bw(r,()=>i?.paused()??!1),t=n.store.onNotice(t=>n.store.shows(t)&&e.changed([t.resource])),o=n.store.onResync(()=>e.changed(a));return()=>{t(),o(),e.stop()}},[n,a,r,i]),(0,j.useEffect)(()=>{if(!o)return;let e=Bw(r,()=>i?.paused()??!1),n=t.live({onChanges:t=>e.changed(t.map(e=>e.resource)),onResync:()=>e.changed(o.split(`,`))});return()=>{n(),e.stop()}},[t,r,i,o])},Hw=(e,t,n=!0)=>{let r=X(),i=nr(t);return O({queryKey:I.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},Uw=(e,t,n=!0)=>{let r=X(),i=x(),a=nr(t);return O({queryKey:I.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(I.recordPreview(e,a))})},Ww=()=>{let{path:e}=Hu();return(0,j.useMemo)(()=>Ln(e),[e])},Gw=`/-/call-guest`,Kw=(e,t)=>`${e}${Gw}#${t}`,qw=(e,t)=>{let n=t.replace(/^#/,``);return e===`/-/call-guest`&&n?{token:n}:void 0},Jw=()=>{let{path:e}=Hu();return(0,j.useMemo)(()=>qw(e,globalThis.location?.hash??``),[e])},Yw=[`light`,`dark`,`system`],Xw=`protobase:theme`,Zw=`(prefers-color-scheme: dark)`,Qw=e=>Yw.includes(e),$w=e=>ue(()=>{let t=e.getItem(Xw);return Qw(t)?t:`system`},`system`),eT=(e,t)=>ue(()=>t===`system`?e.removeItem(Xw):e.setItem(Xw,t),void 0),tT=(e,t)=>e===`system`?t?`dark`:`light`:e,nT=(0,j.createContext)(void 0),rT=({children:e})=>{let[t,n]=(0,j.useState)(()=>$w(localStorage)),r=tT(t,wy(Zw));return(0,j.useEffect)(()=>{document.documentElement.dataset.theme=r},[r]),(0,j.useEffect)(()=>{let e=e=>{(e.key===`protobase:theme`||e.key===null)&&n($w(localStorage))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),(0,L.jsx)(nT.Provider,{value:{preference:t,theme:r,choose:e=>{eT(localStorage,e),n(e)}},children:e})},iT=()=>{let e=(0,j.useContext)(nT);if(!e)throw Error(`useTheme needs a ThemeProvider above it`);return e},aT=F(`toasts`),oT=`-my-0.5 rounded px-1.5 py-0.5 font-medium text-primary-text hover:bg-primary-soft`,sT=({action:e})=>{if(`onClick`in e)return(0,L.jsx)(`button`,{type:`button`,onClick:e.onClick,className:oT,children:e.label});let{href:t,onNavigate:n}=e;return(0,L.jsx)(`a`,{href:t,onClick:e=>{n&&Tu(e)&&(e.preventDefault(),n(t))},className:oT,children:e.label})},cT={loading:(0,L.jsx)(fu,{className:`text-primary`}),success:(0,L.jsx)(os,{className:`size-4 text-success`}),warning:(0,L.jsx)(Bl,{className:`size-4 text-warning`}),error:(0,L.jsx)(us,{className:`size-4 text-danger`}),info:(0,L.jsx)(ol,{className:`size-4 text-primary`}),call:(0,L.jsx)(Bc,{className:`size-4 animate-pulse text-success`})},lT=({state:e,title:t,description:n,action:r,actions:i=[],onDismiss:a})=>(0,L.jsxs)(`div`,{role:e===`error`||e===`call`?`alert`:`status`,className:R(`flex w-full max-w-80 items-start gap-3 rounded-lg border bg-background p-3 shadow-pop [animation:pb-slide-in_160ms_ease-out]`,e===`warning`&&`border-warning/40`,e===`error`&&`border-danger/40`),children:[(0,L.jsx)(`span`,{className:`mt-0.5`,children:cT[e]}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium text-foreground`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:n})]}),r&&(0,L.jsx)(sT,{action:r}),i.map(e=>(0,L.jsx)(sT,{action:e},e.label)),a&&(0,L.jsx)(`button`,{type:`button`,"aria-label":aT(`dismiss`),onClick:a,className:`inline-flex items-center justify-center rounded p-0.5 text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-9`,children:(0,L.jsx)(uu,{className:`size-3.5`})})]}),uT={loading:1/0,success:3500,warning:8e3,error:8e3,info:8e3,call:1/0},dT=8e3,fT=(0,j.createContext)(null),pT=()=>{let e=(0,j.useContext)(fT);if(!e)throw Error(`useToast must be used inside ToastProvider`);return e},mT=({children:e})=>{let[t,n]=(0,j.useState)([]),r=(0,j.useRef)(1),i=(0,j.useRef)(new Map),a=(0,j.useRef)(new Set),o=(0,j.useCallback)(e=>{clearTimeout(i.current.get(e)),i.current.delete(e),a.current.delete(e),n(t=>t.filter(t=>t.id!==e))},[]),s=(0,j.useCallback)((e,t,n=!1)=>{if(clearTimeout(i.current.get(e)),a.current.has(e))return;let r=n?dT:uT[t];r!==1/0&&i.current.set(e,setTimeout(()=>o(e),r))},[o]),c=e=>{e.onClose?.(),o(e.id)},l=(0,j.useMemo)(()=>({show:e=>{let t=r.current++;return e.sticky&&a.current.add(t),n(n=>[...n,{...e,id:t}]),s(t,e.state,!!e.action),t},update:(e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n)),t.state&&s(e,t.state,!!t.action)},dismiss:o}),[o,s]);return(0,L.jsxs)(fT.Provider,{value:l,children:[e,(0,L.jsx)(`div`,{className:`pointer-events-none fixed inset-x-4 bottom-[calc(6rem+var(--pb-safe-bottom))] z-[100] flex flex-col items-end gap-2 md:inset-x-auto md:bottom-[calc(1rem+var(--pb-safe-bottom))] md:right-[calc(1rem+var(--pb-safe-right))]`,children:t.map(e=>(0,L.jsx)(`div`,{className:`pointer-events-auto`,children:(0,L.jsx)(lT,{state:e.state,title:e.title,description:e.description,action:e.action,...e.actions&&{actions:e.actions},onDismiss:()=>c(e)})},e.id))})]})},hT=({open:e,onToggle:t})=>(0,L.jsxs)(B,{size:`sm`,variant:e?`primary`:`secondary`,"aria-pressed":e,onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,L.jsx)(wl,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`max-md:sr-only`,children:H(`assistant`)})]}),gT={bell:Ro,"book-open":Bo,bookmark:Ho,building:Wo,"credit-card":bs,"external-link":Ms,"file-text":Hs,globe:Es,heart:Ks,key:Xs,"layout-dashboard":ec,"life-buoy":ic,mail:mc,package:Ic,receipt:nl,settings:vl,shield:bl,"shopping-cart":Sl,tags:Il,users:Xl,warehouse:iu};Object.keys(gT);var _T=(e,t)=>e?gT[e]??t:t,vT=(e,t)=>_T(e.views[t]?.icon??e.signIn?.[t]?.icon,Ml),yT=(e,t,n,r=!1)=>(e.bottomBar?.items??[]).flatMap((i,a)=>i.kind===`search`?[]:i.kind===`link`?[{id:`link-${a}`,label:i.label,icon:_T(i.icon,Ms),href:i.href,external:!0}]:i.kind===`page`?[{id:i.page,label:i.label,icon:_T(i.icon??e.pages[i.page]?.icon,ec),href:ud({kind:`page`,page:i.page},t),active:i.page===n,shown:r&&i.page===n}]:[{id:i.resource,label:i.label,icon:_T(i.icon,vT(e,i.resource)),href:ud({kind:`list`,resource:i.resource},t),active:i.resource===n,shown:r&&i.resource===n}]),bT=e=>{let t=e.bottomBar?.items.find(e=>e.kind===`search`);return t?.kind===`search`?t.label??!0:void 0},xT=({basePath:e,address:t,group:n,page:r,resourceLabel:i,headingless:a,recordTitle:o,recordLoading:s})=>{let c=n&&n!==i?[n]:[];if(r)return[...c,{label:r.title,href:ud({kind:`page`,page:r.name},e)}];if(!t||t.kind===`page`)return[H(`admin`)];let l=ud({kind:`list`,resource:t.resource,...t.kind===`list`&&t.list&&{list:t.list}},e),u=t.kind===`record`&&!a,d=i?[{label:i,href:l,...u&&{above:!0}}]:[];if(t.kind===`list`||u)return[...c,...d];let f=ud(t,e),p=t.kind===`create`?{label:H(`new`),href:f}:o===void 0&&s?{label:H(`loadingRecord`),href:f,loading:!0}:{label:o??t.key,href:f};return[...c,...d,p]},ST=()=>{let e,t=new Set;return{get:()=>e,set:n=>{if(n!==e){e=n;for(let e of t)e()}},subscribe:e=>(t.add(e),()=>void t.delete(e))}},CT=(0,j.createContext)(void 0),wT=()=>()=>{},TT=()=>void 0,ET=()=>{let e=(0,j.useContext)(CT);return(0,j.useSyncExternalStore)(e?.subscribe??wT,e?.get??TT,e?.get??TT)},DT=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,OT=e=>e,kT=e=>e,AT=(0,j.createContext)({}),jT=()=>(0,j.useContext)(AT),MT=({usePresence:e,store:t})=>{let n=e();return(0,j.useEffect)(()=>t.set(n),[t,n]),(0,j.useEffect)(()=>()=>t.set(void 0),[t]),null},NT=({children:e})=>{let{presence:t}=jT(),[n]=(0,j.useState)(ST),[r,i]=(0,j.useState)({hook:t,key:0});return r.hook!==t&&i({hook:t,key:r.key+1}),(0,L.jsxs)(CT.Provider,{value:n,children:[t&&(0,L.jsx)(MT,{usePresence:t,store:n},r.key),e]})},PT=50,FT=()=>{let e=new Map,t,n=new Set,r=new Set,i=new Set,a=[],o=new Map,s=new Set,c=(e,t)=>(e.add(t),()=>void e.delete(t)),l=r=>{if(r===e)return;e=r;for(let e of[...n])e();clearTimeout(t);let i=jw(e);i!==void 0&&(t=setTimeout(()=>l(Aw(e,Date.now())),Math.max(0,i-Date.now())))};return{typers:()=>e,subscribe:e=>c(n,e),onNotice:e=>c(r,e),onResync:e=>c(i,e),sent:e=>{a.push(e),a.length>PT&&a.shift()},own:()=>new Set(a),view:e=>{o.set(e,(o.get(e)??0)+1);for(let t of[...s])t(e);return()=>{let t=(o.get(e)??1)-1;t>0?o.set(e,t):o.delete(e)}},viewing:e=>o.has(e),onView:e=>c(s,e),shows:e=>o.size===0||o.has(e.channel)||e.channel===`${e.resource}/${e.key}`,handlers:{onEvent:t=>l(kw(e,t,Date.now())),onNotice:e=>{for(let t of[...r])t(e)},onStatus:e=>{e!==`open`&&l(new Map)},onResync:()=>{l(new Map);for(let e of[...i])e()}},stop:()=>clearTimeout(t)}},IT=()=>document.visibilityState===`hidden`?`away`:`online`,LT=({children:e})=>{let t=Vv(),n=X(),r=T_(),i=r?.state.kind===`signed-in`?r.state.user.id:void 0,a=!!t.relay&&i!==void 0,[o,s]=(0,j.useState)();return(0,j.useEffect)(()=>{if(!a)return;let e=FT(),t=n.relay.follow(e.handlers),r=()=>{n.relay.presence(IT()),IT()===`online`&&n.relay.reconnect()},o=()=>n.relay.reconnect();return r(),document.addEventListener(`visibilitychange`,r),window.addEventListener(`online`,o),s({relay:n.relay,store:e,me:i}),()=>{document.removeEventListener(`visibilitychange`,r),window.removeEventListener(`online`,o),t(),e.stop(),s(void 0)}},[n,a,i]),(0,L.jsx)(Pw.Provider,{value:o,children:e})},RT=e=>{let t={word:e?.singular??Q(`word`),words:e?.plural??Q(`words`)};return(e,n)=>Q(e,{...t,...n})},zT=()=>{let e=J().organizations?.names;return(0,j.useMemo)(()=>RT(e),[e])},BT=[],VT=e=>{let{session:t}=J(),n=zT(),r=(0,j.useContext)(G_),i=O({queryKey:I.organizations,queryFn:async()=>{let[e,n]=await Promise.all([t.organizations.current(),t.organizations.list()]);return{current:e,organizations:n}},enabled:e,retry:!1}),{refetch:a}=i,o=(0,j.useCallback)(()=>void a(),[a]),s=e?i.data:void 0,c=e&&i.error?i.error instanceof K?Qv(i.error):n(`couldNotReadOrganizations`):void 0;return{current:s?.current,organizations:s?.organizations??BT,fresh:e&&q_(i,r),failed:e&&J_(i),...c&&{error:c},reload:o}},HT=e=>window.location.assign(`${e}/`),UT=(e,t)=>t?.active?{...e,role:t.active}:e,WT=F(`roles`),GT=(e,t)=>e instanceof K?Qv(e):t,KT=(e,t=!0)=>{let{session:n}=J(),r=pT(),i=O({queryKey:I.activeRole,queryFn:()=>n.roles.current(),enabled:t,retry:!1});(0,j.useEffect)(()=>{i.error&&r.show({state:`error`,title:GT(i.error,WT(`couldNotReadRoles`))})},[i.error,r]);let a=(0,j.useCallback)(t=>void n.roles.switchTo(t).then(e,e=>r.show({state:`error`,title:GT(e,WT(`couldNotSwitch`))})),[n,r,e]);return{...t&&i.data&&{current:i.data},switchTo:a}},qT=(e,t)=>e[t]||e.conditional.includes(t),JT=(e,t)=>e.permissions?.[t]??!0,YT=(e,t)=>e?.fields?e.fields[t]??`hidden`:`edit`,XT=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):qT(n,`create`),ZT=e=>new Set((e.userMenu?.items??[]).flatMap(e=>e.kind===`resource`?[e.resource]:e.kind===`page`?[e.page]:[])),QT=(e,t,n)=>(e.userMenu?.items??[]).map((r,i)=>{if(r.kind===`link`)return{id:`link-${i}`,label:r.label,icon:_T(r.icon,Ms),href:r.href,external:!0};if(r.kind===`page`){let i=e.pages[r.page];return{id:r.page,label:r.label??i?.title??P(r.page),icon:_T(r.icon??i?.icon,ec),href:ud({kind:`page`,page:r.page},t),active:r.page===n}}return{id:r.resource,label:r.label??e.views[r.resource]?.names?.plural??P(r.resource),icon:_T(r.icon,vT(e,r.resource)),href:ud({kind:`list`,resource:r.resource},t),active:r.resource===n}}),$T=(e,t)=>t===void 0?e:`${e}/${t}`,eE={sales:`sales`,crm:`crm`,catalog:`catalog`,inventory:`inventory`,core:`admin`,hr:`hr`,table_definitions:`tables`,user_tables:`tables`},tE=(e=`public`)=>e===`public`?``:eE[e]?H(eE[e]):P(e),nE=(e,t,n,r,i)=>!n?.create||!XT(t,e.pages,e.permissions[t.resource]??sv)?{}:{create:{label:n.create===!0?FS(`title`,{noun:r}):n.create.label,href:ud({kind:`create`,resource:t.resource},i)}},rE=(e,t=``,n={})=>{let r=new Map,i=new Map,a=ZT(e);for(let n of Object.values(e.pages)){if(n.nav?.hidden||a.has(n.name))continue;let e=n.nav?.group??H(`pages`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.name,label:n.title,icon:_T(n.icon,ec),href:ud({kind:`page`,page:n.name},t)}),r.set(e,o),i.set(n.name,n.nav?.order??2**53-1)}for(let o of Object.values(e.resources)){let s=e.views[o.name];if(!s||a.has(o.name))continue;let c=s.nav?.group??tE(o.table.schema),l=(e,t,n)=>{let a=r.get(e)??{label:e,items:[]};a.items.push(t),r.set(e,a),i.set(t.id,n??2**53-1)},u=!s.nav?.creatorsOnly||XT(s,e.pages,e.permissions[s.resource]??sv);!s.nav?.hidden&&u&&l(c,{id:$T(o.name),label:s.names?.plural??P(o.name),icon:vT(e,o.name),href:ud({kind:`list`,resource:o.name},t),...n[o.name]&&{recent:n[o.name]},...nE(e,s,s.nav,s.names?.singular??P(o.name),t)},s.nav?.order);for(let n of s.lists??[])n.nav?.hidden||l(n.nav?.group??c,{id:$T(o.name,n.name),label:n.names.plural,icon:vT(e,o.name),href:ud({kind:`list`,resource:o.name,list:n.name},t),...nE(e,s,n.nav,n.names.singular,t)},n.nav?.order)}for(let n of Object.values(e.signIn??{})){if(n.nav?.hidden||a.has(n.resource))continue;let o=n.nav?.group??H(`account`),s=r.get(o)??{label:o,items:[]};s.items.push({id:n.resource,label:n.names?.plural??P(n.resource),icon:vT(e,n.resource),href:ud({kind:`list`,resource:n.resource},t)}),r.set(o,s),i.set(n.resource,n.nav?.order??2**53-1)}for(let n of e.sources??[]){if(n.state!==`error`)continue;let e=r.get(n.source.label)??{label:n.source.label,items:[]};for(let r of n.source.resources)e.items.push({id:r,label:P(r),icon:Ml,href:ud({kind:`list`,resource:r},t),problem:H(`cannotReach`,{label:n.source.label})});r.set(n.source.label,e)}return[...r.values()].map(e=>({...e,items:[...e.items].sort((e,t)=>(i.get(e.id)??0)-(i.get(t.id)??0))}))},iE=e=>{let t=rE(e).flatMap(e=>e.items).find(e=>!e.problem);if(t&&e.pages[t.id])return{kind:`page`,page:t.id};if(t){let[e,n]=t.id.split(`/`);return{kind:`list`,resource:e,...n!==void 0&&{list:n}}}let n=Object.keys(e.pages)[0];if(n)return{kind:`page`,page:n};let r=Object.keys(e.resources)[0];return r?{kind:`list`,resource:r}:void 0},aE=(e,t,n)=>{let r=t[n];return e.fields[n]?.type===`relation`&&typeof r==`object`&&r&&`id`in r?r.id:r},oE=(e,t)=>e.primaryKey.map(n=>String(aE(e,t,n))).join(`,`),sE=(e,t)=>{let n=e.primaryKey.map(n=>aE(e,t,n));return n.length===1?n[0]:n},cE=(e,t)=>{let n=t?.list?.sort?.[0];if(n)return`${n[0]} ${n[1]}`;let r=e.primaryKey[0];return e.fields[r]?.sortable?`${r} asc`:``},lE=e=>{let[t=``,n]=e.trim().split(/\s+/);return{columnId:t,direction:n===`desc`?`desc`:`asc`}},uE=e=>`${e.columnId} ${e.direction}`,dE=e=>{for(let t of rE(e).flatMap(e=>e.items)){let n=t.problem?void 0:e.views[t.id]?.nav?.start,r=e.resources[t.id];if(n&&r)return{model:r,start:n}}},fE=({model:e,start:t},n)=>({filter:t.filter,orderBy:t.orderBy??cE(e,n.views[e.name]),pageSize:1,fields:[...e.primaryKey]}),pE=(e,t)=>{let n=t[0];return n&&nr(sE(e,n))},mE=({entry:e,fallback:t,enabled:n,organization:r,metaSettled:i,lookup:a})=>{let o={state:`ready`,...t&&{address:t}};if(r===null)return o;if(r!==``&&!i)return n?{state:`resolving`}:o;if(!e)return o;if(r===void 0||a.pending)return n?{state:`resolving`}:o;if(a.failed)return o;let s=a.rows&&pE(e.model,a.rows);return s===void 0?o:{state:`ready`,address:{kind:`record`,resource:e.model.name,key:s}}},hE=(e,t,n,r)=>t?.data?.etag===e.etag&&(q_(t,n)||r),gE=(e,t,n)=>{let r=X(),i=(0,j.useContext)(G_),a=lv(),o=x().getQueryState(I.meta),s=(0,j.useMemo)(()=>dE(e),[e]),c=(0,j.useMemo)(()=>iE(e),[e]),l=s&&fE(s,e),u=O({queryKey:I.startRecord(s?.model.name??``,l?.filter??``,l?.orderBy??``,n??``),queryFn:()=>r.list(s.model.name,l),enabled:t&&!!s&&typeof n==`string`,retry:!1});return mE({entry:s,fallback:c,enabled:t,organization:n,metaSettled:hE(e,o,i,J_(a)),lookup:{pending:u.isPending,failed:J_(u),...u.data&&{rows:u.data.items}}})},_E=(0,j.createContext)(null),vE=({route:e,children:t})=>(0,L.jsx)(_E.Provider,{value:e,children:t}),yE=()=>{let e=(0,j.useContext)(_E);if(!e)throw Error(`Tabs render inside a page that gives them their addresses: a composed page`);return e},bE=e=>e.children.filter(e=>typeof e!=`string`).map(e=>({node:e,...e.props})),xE=e=>{let t=e.children.find(e=>typeof e!=`string`&&!e.custom&&e.type===`Tabs`);return t?bE(t):[]},SE=(e,t)=>t===void 0?e[0]:e.find(e=>e.name===t),CE=e=>{let t=jT().shell?.logo;return t?(0,L.jsx)(sw,{name:`shell.logo`,fallback:(0,L.jsx)(Fb,{...e}),children:(0,L.jsx)(t,{...e})}):(0,L.jsx)(Fb,{...e})},wE=(e,t,n)=>{let r=e.bottom+4;return{top:r+t.height>window.innerHeight-4?Math.max(4,e.top-4-t.height):r,right:n-Wb(e.right,t.width,n)}},TE=()=>{let[e,t]=(0,j.useState)(!1),[n,r]=(0,j.useState)(),i=(0,j.useRef)(null),a=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{if(!e||!i.current||!a.current){r(void 0);return}a.current.style.right=`0px`;let t=Gb(document.documentElement.clientWidth);a.current.style.maxWidth=`${t}px`;let n=a.current.getBoundingClientRect();r({...wE(i.current.getBoundingClientRect(),n,n.right),maxWidth:t})},[e]),(0,j.useEffect)(()=>{if(!e)return;let n=e=>e instanceof Node&&!!(i.current?.contains(e)||a.current?.contains(e)),r=e=>{a.current?.closest(`[aria-modal="true"]`)||(e instanceof KeyboardEvent?e.key===`Escape`:!n(e.target))&&t(!1)},o=e=>{a.current?.closest(`[aria-modal="true"]`)||n(e.target)||t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,r),document.addEventListener(`scroll`,o,!0),window.addEventListener(`resize`,o),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,r),document.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,o)}},[e]),{open:e,setOpen:t,place:n,button:i,menu:a}},EE=(e,t)=>({turnOn:async()=>{t({failure:void 0,busy:!0});try{t({state:await e.turnOn()})}catch(e){console.error(`Notifications could not be turned on:`,e),t({failure:Pg(e)})}finally{t({busy:!1})}},turnOff:async()=>{t({failure:void 0,busy:!0});try{await e.turnOff({chosen:!0})}catch(e){console.error(`Notifications could not be turned off for good:`,e),t({failure:Pg(e)})}try{t({state:await e.state()})}catch(e){console.error(`Whether notifications are on could not be read:`,e)}finally{t({busy:!1})}}}),DE=(e,t=window)=>{let n,r=!1,i=()=>{t.document.visibilityState===`visible`&&e()};return t.addEventListener(`focus`,e),t.document.addEventListener(`visibilitychange`,i),`permissions`in t.navigator&&t.navigator.permissions.query({name:`notifications`}).then(t=>{r||(n=t,t.addEventListener(`change`,e))},e=>{if(!(e instanceof TypeError))throw e}),()=>{r=!0,t.removeEventListener(`focus`,e),t.document.removeEventListener(`visibilitychange`,i),n?.removeEventListener(`change`,e)}},OE=()=>{let{push:e,state:t}=J(),n=t.kind===`signed-in`?t.user.id:void 0,[r,i]=(0,j.useState)(`loading`),[a,o]=(0,j.useState)(),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(0);(0,j.useEffect)(()=>{let t=!0,n=()=>void e.state().then(e=>t&&i(e));n();let r=typeof window>`u`?void 0:DE(n);return()=>{t=!1,r?.()}},[e,n,l]);let d=(0,j.useCallback)(()=>u(e=>e+1),[]),{turnOn:f,turnOff:p}=(0,j.useMemo)(()=>EE(e,e=>{e.state&&i(e.state),`failure`in e&&o(e.failure),e.busy!==void 0&&c(e.busy)}),[e]);return{state:r,busy:s,failure:a,turnOn:f,turnOff:p,refresh:d}},kE=new Map,AE=(e,t)=>{let n=Ii(),r=`${n}|${e}`;return kE.has(r)||kE.set(r,t(n)),kE.get(r)},jE=F(`format`),ME=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,NE=new Map,PE=e=>{let t=NE.get(e);if(t)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return NE.set(e,n),n},FE=(e,t)=>{let n=Object.fromEntries(PE(t).formatToParts(e).map(e=>[e.type,e.value]));return{year:Number(n.year),month:Number(n.month),day:Number(n.day),hour:Number(n.hour),minute:Number(n.minute),second:Number(n.second)}},IE=(e,t)=>{let n=FE(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3},LE=e=>String(e).padStart(2,`0`),RE=(e,t)=>{let n=FE(e,t);return`${n.year}-${LE(n.month)}-${LE(n.day)}`},zE=(e,t)=>e-IE(e-IE(e,t),t),BE=(e,t)=>zE(Date.parse(`${e}T00:00:00Z`),t),VE=(e,t)=>{let n=AE(`zoneName:${t}`,e=>new Intl.DateTimeFormat(e,{timeZone:t,timeZoneName:`shortOffset`})).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??t;return t===`UTC`||t===`Etc/UTC`?`UTC`:`${t} (${n})`},HE=(e,t)=>()=>AE(`date:${e}`,e=>new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`})),UE=HE(`day`,{day:`numeric`,month:`short`,year:`numeric`}),WE=HE(`dayShort`,{day:`numeric`,month:`short`}),GE=HE(`month`,{month:`long`,year:`numeric`}),KE=HE(`monthName`,{month:`long`}),qE=HE(`weekday`,{weekday:`short`}),JE=HE(`weekdayDate`,{weekday:`long`,day:`numeric`,month:`short`,year:`numeric`}),YE=e=>UE().format(e),XE=e=>WE().format(e),ZE=e=>AE(`zoned:${e}`,t=>({day:new Intl.DateTimeFormat(t,{day:`numeric`,month:`short`,year:`numeric`,timeZone:e}),time:new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:e})})),QE=(e,t=ME())=>{let n=ZE(t);return`${n.day.format(e)}, ${n.time.format(e)}`},$E=e=>GE().format(e),eD=e=>KE().format(e),tD=(e,t)=>GE().formatRange(e,t),nD=e=>qE().format(e),rD=e=>JE().format(e),iD=(e,t)=>UE().formatRange(e,t),aD=(e,t=ME())=>ZE(t).time.format(e),oD=e=>e<60?jE(`secondsAgo`,{count:e}):e<3600?jE(`minutesAgo`,{count:Math.floor(e/60)}):e<86400?jE(`hoursAgo`,{count:Math.floor(e/3600)}):jE(`daysAgo`,{count:Math.floor(e/86400)}),sD=()=>AE(`relative`,e=>new Intl.RelativeTimeFormat(e,{numeric:`auto`})),cD=[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]],lD=e=>{let t=Math.abs(e),[n,r]=cD.find(([,e])=>t>=e)??[`second`,1];return n===`second`&&t<45?jE(`justNow`):sD().format(-Math.sign(e)*Math.floor(t/r),n)},uD=F(`notifications/bell`),dD=`flex w-full gap-2.5 px-3 py-2.5 text-left`,fD=({item:e,target:t,onNavigate:n,onOpen:r,now:i})=>{let a=e.readAt===null,o=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:R(`mt-1.5 size-2 shrink-0 rounded-full`,a?uy.blue:`bg-transparent`),children:a&&(0,L.jsx)(`span`,{className:`sr-only`,children:uD(`unread`)})}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:R(`block text-body text-foreground`,a&&`font-semibold`),children:e.title}),e.body&&(0,L.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-xs text-muted-foreground`,children:e.body}),(0,L.jsx)(`time`,{dateTime:e.createdAt,className:`mt-0.5 block text-xs text-faint-foreground`,children:lD((i-Date.parse(e.createdAt))/1e3)})]})]}),s=()=>r(e),c=e=>{e.button===1&&s()};return t?t.kind===`app`?(0,L.jsx)(Du,{to:{href:t.href,onFollow:()=>n(t.path)},onClick:s,onAuxClick:c,className:R(dD,`hover:bg-muted`),children:o}):(0,L.jsx)(`a`,{href:t.href,onClick:s,onAuxClick:c,className:R(dD,`hover:bg-muted`),children:o}):(0,L.jsx)(`div`,{className:dD,children:o})},pD=({items:e,loading:t,failed:n,onRetry:r,hasMore:i,loadingMore:a,onMore:o,onMarkAllRead:s,markingAll:c,targetOf:l,onNavigate:u,onOpen:d,footer:f,now:p})=>{let m=e[0],h=e.some(e=>e.readAt===null);return(0,L.jsxs)(`div`,{className:`flex max-h-[min(32rem,calc(100dvh-var(--pb-sticky-top,3rem)-1rem))] flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(`h2`,{className:`flex-1 text-body font-semibold`,children:uD(`notifications`)}),m&&h&&(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:c,onClick:()=>s(m),children:uD(`markAllRead`)})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[t?(0,L.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,L.jsx)(fu,{className:`size-4`})}):n?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-3 py-6 text-center text-body text-muted-foreground`,children:[(0,L.jsx)(`p`,{children:uD(`loadFailed`)}),(0,L.jsx)(B,{size:`sm`,onClick:r,children:uD(`tryAgain`)})]}):e.length===0?(0,L.jsx)(`p`,{className:`px-3 py-8 text-center text-body text-muted-foreground`,children:uD(`empty`)}):(0,L.jsx)(`ul`,{className:`divide-y`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(fD,{item:e,target:l(e),onNavigate:u,onOpen:d,now:p})},e.id))}),i&&!t&&!n&&(0,L.jsx)(`div`,{className:`flex justify-center border-t py-2`,children:(0,L.jsx)(B,{size:`sm`,variant:`ghost`,loading:a,onClick:o,children:uD(`showMore`)})})]}),f]})},mD=(e,{origin:t,basePath:n})=>{if(e===null||!URL.canParse(e,t))return;let r=new URL(e,t);if(r.protocol!==`http:`&&r.protocol!==`https:`)return;if(r.origin!==t)return{kind:`page`,href:r.href};let i=`${r.pathname}${r.search}${r.hash}`;return n===``?{kind:`app`,href:i,path:i}:r.pathname===n||r.pathname.startsWith(`${n}/`)?{kind:`app`,href:i,path:i.slice(n.length)||`/`}:{kind:`page`,href:i}},hD=e=>e.kind===`registration`?uD(`pushRegistrationFailed`,{reason:e.reason}):e.kind===`no-token`?uD(e.service===`apns`?`pushNoTokenApns`:`pushNoTokenFcm`):e.kind===`off-not-stored`?uD(`pushOffNotStored`):e.kind===`refused`?uD(`pushRefused`,{reason:e.reason}):uD(`pushFailed`,{reason:e.reason}),gD=({state:e,busy:t=!1,failure:n,onTurnOn:r,onTurnOff:i})=>{if(e===`loading`||e===`unsupported`)return null;if(e===`blocked`)return(0,L.jsxs)(`p`,{className:`flex gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(Po,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),uD(`pushBlocked`)]});let a=e===`on`,o=!a&&n;return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-t px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(Io,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o?(0,L.jsx)(`span`,{role:`alert`,className:`min-w-0 flex-1 text-danger-text`,children:hD(o)}):(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:uD(a?`pushOn`:`pushOff`)}),(0,L.jsx)(B,{size:`sm`,variant:a?`secondary`:`primary`,loading:t,onClick:a?i:r,children:uD(a?`turnOff`:o&&o.kind!==`off-not-stored`?`tryAgain`:`turnOn`)})]})},_D=3e4,vD=e=>Rd(e)&&e.status===403,yD=({enabled:e=!0}={})=>{let t=X();return O({queryKey:I.inboxUnread,queryFn:()=>t.notifications.unread(),refetchInterval:e=>!vD(e.state.error)&&_D,enabled:e})},bD=({enabled:e=!0}={})=>{let t=X(),n=A({queryKey:I.inboxPages,queryFn:({pageParam:e})=>t.notifications.list(e===``?{}:{cursor:e}),initialPageParam:``,getNextPageParam:e=>e.next??void 0,enabled:e}),r=n.data?.pages.flatMap(e=>e.items)??[];return{...n,items:r}},xD=(e,t)=>{let n=new Date().toISOString(),r=0;e.setQueryData(I.inboxPages,e=>e&&{...e,pages:e.pages.map(e=>({...e,items:e.items.map(e=>e.readAt!==null||!t(e)?e:(r+=1,{...e,readAt:n}))}))}),e.setQueryData(I.inboxUnread,e=>e===void 0?e:Math.max(0,e-r))},SD=()=>{let e=X(),t=x(),n=()=>t.invalidateQueries({queryKey:I.inbox}),r=S({mutationFn:t=>e.notifications.markRead(t.id),onMutate:e=>xD(t,t=>t.id===e.id),onSettled:n}),i=S({mutationFn:t=>e.notifications.markAllRead(t.createdAt),onMutate:e=>xD(t,t=>t.createdAt<=e.createdAt),onSettled:n}),a=r.mutate;return{markRead:(0,j.useCallback)(e=>{e.readAt===null&&a(e)},[a]),markAllRead:i.mutate,markingAll:i.isPending}},CD=99,wD=e=>e===void 0||e<=0?uD(`notifications`):e>CD?uD(`notificationsManyUnread`):uD(`notificationsUnread`,{count:String(e)}),TD=()=>{let{open:e,setOpen:t,place:n,button:r,menu:i}=TE(),a=yD(),o=bD({enabled:e}),{markRead:s,markAllRead:c,markingAll:l}=SD(),u=OE(),{navigate:d,basePath:f}=Hu(),[p,m]=(0,j.useState)(Date.now),h=wD(a.data),g=window.location.origin;return vD(a.error)?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(B,{ref:r,size:`icon`,variant:`ghost`,"aria-label":h,title:h,"aria-haspopup":`dialog`,"aria-expanded":e,onClick:()=>{e||(m(Date.now()),a.refetch(),o.data&&o.refetch(),u.busy||u.refresh()),t(!e)},className:`relative max-md:size-9`,children:[(0,L.jsx)(Ro,{className:`size-4 max-md:size-5`}),(0,L.jsx)(Bx,{count:a.data,className:`pointer-events-none absolute -top-1 -right-1.5 max-md:top-0 max-md:right-0`})]}),(0,L.jsx)(Sx,{open:e,title:wD(void 0),onClose:()=>t(!1),menu:(0,L.jsx)(`div`,{ref:i,role:`dialog`,"aria-label":wD(void 0),style:n??{visibility:`hidden`},className:`fixed z-50 w-[min(22rem,calc(100%-0.5rem))] rounded-md border bg-background shadow-pop`,children:(0,L.jsx)(pD,{items:o.items,loading:o.isPending,failed:o.isError,onRetry:()=>void o.refetch(),hasMore:o.hasNextPage,loadingMore:o.isFetchingNextPage,onMore:()=>void o.fetchNextPage(),onMarkAllRead:c,markingAll:l,targetOf:e=>mD(e.url,{origin:g,basePath:f}),onNavigate:e=>d(e),onOpen:e=>{s(e),t(!1)},footer:(0,L.jsx)(gD,{state:u.state,busy:u.busy,failure:u.failure,onTurnOn:()=>void u.turnOn(),onTurnOff:()=>void u.turnOff()}),now:p})})})]})},ED=({own:e})=>e?(0,L.jsx)(sw,{name:`shell.bell`,fallback:null,children:(0,L.jsx)(e,{})}):(0,L.jsx)(TD,{}),DD=(0,j.createContext)([]),OD=()=>(0,j.useContext)(DD),kD=({ui:e,children:t})=>{let{plugins:n=[]}=Vv(),{loads:r,settled:i}=Xa(n,qa()),a=(0,j.useMemo)(()=>cw(e,r),[e,r]);return i?(0,L.jsx)(AT.Provider,{value:a.ui,children:(0,L.jsx)(DD.Provider,{value:a.off,children:t})}):(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,Cu),children:[(0,L.jsx)(vv,{}),(0,L.jsx)(fu,{}),` `,da(`loading`)]})},AD=({off:e})=>{let[t,n]=(0,j.useState)(!1);return t||e.length===0?null:(0,L.jsxs)(`div`,{role:`region`,"aria-label":da(`pluginsOff`),className:`flex items-start gap-3 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,L.jsx)(el,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,L.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-0.5 break-words`,children:e.map(e=>(0,L.jsx)(`li`,{children:da.rich(`pluginOff`,{plugin:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.name??e.url}),reason:e.reason})},e.url))}),(0,L.jsx)(`button`,{type:`button`,"aria-label":da(`dismiss`),className:`rounded p-0.5 hover:bg-warning/10`,onClick:()=>n(!0),children:(0,L.jsx)(uu,{"aria-hidden":!0,className:`size-4`})})]})},jD=({title:e,description:t,open:n,onClose:r,actions:i,children:a,wide:o})=>{let s=Ty();return n?s?(0,L.jsx)(xu,{title:e,description:t,onClose:r,actions:i,wide:o,children:a}):(0,L.jsx)(bx,{title:e,open:!0,onClose:r,children:(0,L.jsxs)(`div`,{className:`pt-3`,children:[t&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:t}),a&&(0,L.jsx)(`div`,{className:`mt-4`,children:a}),(0,L.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 [&>*]:min-h-11`,children:i})]})}):null},MD=({failed:e})=>(0,L.jsxs)(`span`,{"data-fetching":!0,className:`inline-flex items-center text-muted-foreground`,children:[(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:H(e?`refreshFailed`:`refreshing`)}),e?(0,L.jsx)(ND,{}):(0,L.jsx)(`span`,{className:Cu,children:(0,L.jsx)(fu,{hidden:!0})})]}),ND=()=>{let[e,t]=(0,j.useState)(!1),n=(0,j.useContext)(k),r=(0,j.useContext)(G_);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":H(`refreshWhy`),onClick:()=>t(!0),className:`-m-3 inline-flex size-11 items-center justify-center rounded-md md:-m-1 md:size-7`,children:(0,L.jsx)(Bl,{"aria-hidden":!0,className:`size-4 text-warning`})}),(0,L.jsx)(jD,{title:H(`refreshFailedTitle`),description:H(`refreshFailedHelp`),open:e,onClose:()=>t(!1),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>t(!1),children:H(`refreshClose`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>{t(!1),n?.refetchQueries({type:`active`,predicate:e=>K_(e.state,r)})},children:H(`refreshRetry`)})]})})]})},PD=15e3,FD=()=>{let e=T_();return lv().data?.status&&e?.state.kind===`signed-in`?String(e.state.user.id):void 0},ID=()=>{let e=X(),t=FD();return O({queryKey:I.statuses(t??``),enabled:t!==void 0,refetchInterval:PD,queryFn:()=>e.status.people()})},LD=()=>{let e=X(),t=FD();return O({queryKey:I.ownStatus(t??``),enabled:t!==void 0,refetchInterval:PD,queryFn:()=>e.status.own()})},RD=(e,t=Date.now())=>e.isSuccess&&!e.isFetching&&t-e.dataUpdatedAt>=1e4,zD=(e,t)=>{let n=new Map(t.map(e=>[e.userId,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,status:t}:e})},BD=()=>{let e=T_(),t=e?.state.kind===`signed-in`?e.state.user:void 0,n=O({queryKey:I.members(t?.id??``),enabled:t!==void 0,queryFn:()=>{if(!e?.organizations)throw Error(`useMembers() needs organizations: turn them on in the auth config.`);return e.session.organizations.people()}}),r=ID().data,i=(0,j.useMemo)(()=>n.data&&(r?zD(n.data,r):n.data),[n.data,r]),a=(0,j.useMemo)(()=>new Map((i??[]).map(e=>[e.id,e])),[i]),{refetch:o}=n,s=(0,j.useCallback)(e=>{let t=a.get(e);return!t&&RD(n)&&setTimeout(()=>void o(),0),t},[a,n,o]);return{...n,data:i,member:s}},VD=(e,t)=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&e!==t):[],HD=e=>(t,{user:n,member:r})=>{let i=VD(t[e],n?.id).map(e=>r(e)?.name);if(i.length!==0&&i.every(Boolean))return i.join(`, `)},UD=(e,t)=>t?.titleFrom?.fields??[],WD=(e,t)=>(n,r,i,a)=>{let o=r?.titleFrom;if(!o)return Jr(n,r,i,a);let s=o.rule===`members`?HD(o.fields[0]):e[o.rule];return!s||o.unreadable||o.fields.some(e=>i[e]===void 0)?a:s(i,t)||a},GD=()=>void 0,KD=(0,j.createContext)(WD({},{user:void 0,member:GD})),qD=()=>(0,j.useContext)(KD),JD=({rules:e,user:t,children:n})=>{let r=(0,j.useMemo)(()=>WD(e,{user:t,member:GD}),[e,t]);return(0,L.jsx)(KD.Provider,{value:r,children:n})},YD=({rules:e,user:t,children:n})=>{let{member:r}=BD(),i=(0,j.useMemo)(()=>WD(e,{user:t,member:r}),[e,t,r]);return(0,L.jsx)(KD.Provider,{value:i,children:n})},XD=({children:e})=>{let{views:t}=Vv(),{titles:n}=jT(),r=T_(),i=r?.state.kind===`signed-in`?r.state.user:void 0,a=n??{};return Object.values(t).some(e=>e.titleFrom!==void 0)&&i&&r?.organizations?(0,L.jsx)(YD,{rules:a,user:i,children:e}):(0,L.jsx)(JD,{rules:a,user:i,children:e})},ZD=e=>Rd(e)?e.status===401||e.status===403?H(`signInRefused`,{message:e.message}):e.message:H(`noAnswer`),QD=({status:e})=>{let t=x();return e.state===`error`?(0,L.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,L.jsx)(`h1`,{className:`text-base font-semibold`,children:H(`cannotReach`,{label:e.source.label})}),(0,L.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[ZD(e.error),` `,H(`restWorks`)]}),(0,L.jsx)(B,{className:`mt-3`,onClick:()=>void t.refetchQueries({queryKey:I.sourceMetas(e.source.url)}),children:H(`tryAgain`)})]})}):(0,L.jsxs)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{}),` `,H(`loadingFrom`,{label:e.source.label})]})},$D=(e,t)=>{let[n,r]=(0,j.useState)(e);return(0,j.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},eO=F(`app/search`),tO=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),nO=(e,t,n=``)=>{let r=rE(e,n).flatMap(e=>e.items.filter(e=>e.href!==void 0&&!e.problem)).filter(e=>tO(e.label,t)).slice(0,5),i=t.trim().replace(/^new\s+/i,``),a=Object.values(e.resources).flatMap(r=>{let a=e.views[r.name];if(!a||a.nav?.hidden||!XT(a,e.pages,e.permissions[r.name]??sv))return[];let o=a.names?.singular??P(r.name),s=FS(`title`,{noun:o});return!tO(s,t)&&!tO(o,i)&&!tO(a.names?.plural??P(r.name),i)?[]:[{id:`new:${r.name}`,title:s,href:ud({kind:`create`,resource:r.name},n)}]});return[...r.length>0?[{id:`go-to`,label:eO(`goTo`),hits:r.map(e=>({id:`go-to:${e.id}`,title:e.label,href:e.href}))}]:[],...a.length>0?[{id:`create`,label:eO(`create`),hits:a.slice(0,5)}]:[]]},rO=e=>e==null||e===``,iO=(e,t)=>{let n=e.find(e=>!qt(e).some(e=>rO(t[e])));return n&&an(n,t)},aO=jt(),oO=e=>Object.values(e.resources).flatMap(t=>{let n=e.views[t.name];return!t.search?.length||!n||n.nav?.hidden||e.permissions[t.name]?.read===!1?[]:[{model:t,view:n,label:n.names?.plural??P(t.name)}]}),sO=e=>{let t=e.map(e=>e.label.toLowerCase());return t.length===0?eO(`search`):t.length===1?eO(`searchOne`,{name:t[0]}):t.length===2?eO(`searchTwo`,{first:t[0],second:t[1]}):eO(`searchMore`,{first:t[0],second:t[1]})},cO=e=>bt(aO.search(e.trim())),lO=e=>!e.view?.searchResult?.title?.length&&e.view?.titleFrom!==void 0,uO=e=>{let t=e.view?.searchResult?.title;return t?.length?t:lO(e)?[]:[qr(e.model,e.view)]},dO=e=>{let t=uO(e);return e.view?.searchResult?.subtitle??e.model.search?.find(e=>!t.includes(e))},fO=e=>{let t=dO(e),n=lO(e)?UD(e.model,e.view):[],r=(e.view?.recordOpens??[]).flatMap(qt),i=[...uO(e),...n,...t?[t]:[],...e.model.search??[],...r];return[...new Set([...e.model.primaryKey,...i.filter(t=>Object.hasOwn(e.model.fields,t))])]},pO=(e,t,n)=>{let r=t[n];return r==null?``:e.model.fields[n]?.type===`enum`?Ur(String(r),e.view?.fields[n]?.valueLabels):String(r)},mO=(e,t,n,r=``,i=WD({},{user:void 0,member:()=>void 0}))=>{let a=nr(sE(e.model,t)),o=uO(e),s=dO(e),c=yt(e.model,t,n,[...o,...s?[s]:[]])??s,l=c?pO(e,t,c):``;return{id:a,title:lO(e)?i(e.model,e.view,t,a):o.map(n=>pO(e,t,n)).filter(Boolean).join(` `)||a,...l&&{subtitle:l},href:ud(iO(e.view?.recordOpens??[],t)??{kind:`record`,resource:e.model.name,key:a},r)}},hO=()=>{let e=Vv(),t=X(),{basePath:n}=Hu(),r=qD(),i=(0,j.useMemo)(()=>oO(e),[e]),[a,o]=(0,j.useState)(``),s=a.trim(),c=$D(s,200),l=s.length>=2,u=l&&c.length>=2,d=ee({queries:i.map(e=>({queryKey:[`global-search`,e.model.name,c],enabled:u,staleTime:1/0,gcTime:0,queryFn:()=>t.list(e.model.name,{filter:cO(c),pageSize:5,fields:fO(e)})}))}),f=(0,j.useMemo)(()=>u?nO(e,c,n):[],[u,e,c,n]),p=i.flatMap((e,t)=>{let i=d[t];if(!u||!i)return[];if(i.error)return[{id:e.model.name,label:e.label,hits:[],failed:!0}];let a=(i.data?.items??[]).map(t=>mO(e,t,c,n,r));return a.length>0?[{id:e.model.name,label:e.label,hits:a}]:[]}),m=[...f,...p];return{available:Object.keys(e.pages).length>0||Object.keys(e.resources).length>0,placeholder:sO(i),text:a,setText:o,query:u?c:``,loading:l&&(s!==c||d.some(e=>e.isFetching)),groups:m}},gO=(0,j.createContext)(void 0),_O=()=>(0,j.useContext)(gO),vO=F(`app/new-version`),yO=()=>{let{versionChange:e,appName:t}=Vv(),{reload:n}=Hu(),r=_O();return!e||r?null:(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full shrink-0 items-start gap-2 border-t border-warning/40 bg-warning-soft px-3.5 py-2 text-left text-warning-text transition-colors hover:bg-warning/15 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary`,children:[(0,L.jsx)(ol,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`break-words font-semibold`,children:t?vO.rich(`bannerTitle`,{app:t}):vO(`title`)}),(0,L.jsx)(`span`,{className:`text-xs`,children:vO(`bannerLine`)})]})]})},bO=()=>{let e=!!Vv().versionChange,{reload:t}=Hu(),n=_O();return!e||n?null:(0,L.jsxs)(B,{size:`sm`,variant:`ghost`,"aria-label":vO(`reloadPageHint`),title:vO(`reloadPageHint`),onClick:t,className:`max-md:size-9 max-md:p-0`,children:[(0,L.jsx)(ol,{className:`size-3.5 text-primary`}),(0,L.jsx)(`span`,{className:`max-md:sr-only`,children:vO(`reloadPage`)})]})},xO=()=>document.querySelector(`[aria-modal="true"]`)!==null,SO=()=>{let[e,t]=(0,j.useState)(xO);return(0,j.useEffect)(()=>{let e=new MutationObserver(()=>t(xO()));return e.observe(document.body,{childList:!0,subtree:!0}),t(xO()),()=>e.disconnect()},[]),e},CO=()=>{let e=!!Vv().versionChange,t=SO(),[n,r]=(0,j.useState)(!1),i=pT(),{reload:a}=Hu(),o=_O(),s=e&&!n&&!t&&!o;return(0,j.useEffect)(()=>{if(!s)return;let e=i.show({state:`info`,sticky:!0,title:vO(`title`),description:vO(`description`),action:{label:vO(`reload`),onClick:a},onClose:()=>r(!0)});return()=>i.dismiss(e)},[s,i,a]),null},wO=(e,t=()=>null)=>{let n,r,i=()=>r??=e().then(e=>n=e,e=>{throw r=void 0,e}),a=e=>{let t=n??(0,j.use)(i());return(0,L.jsx)(t,{...e})};return Object.assign(e=>(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(`span`,{"aria-busy":!0,className:`contents`,children:t(e)}),children:(0,L.jsx)(a,{...e})}),{preload:i})},TO=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),"aria-busy":!0,className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,L.jsx)(Su,{className:`h-7 w-48`}),(0,L.jsx)(Su,{className:`h-9 w-full max-w-96`}),(0,L.jsx)(Su,{className:`min-h-60 flex-1 rounded-lg`})]}),EO=[32,24,40,28,20],DO=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),"aria-busy":!0,className:`mx-auto w-full max-w-[1100px] px-4 pb-8 pt-6 md:px-10 md:py-8`,children:[(0,L.jsx)(Su,{className:`h-8 w-3/4 max-w-96`}),(0,L.jsxs)(`div`,{className:`mt-10 grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Su,{className:`h-5 w-32`}),(0,L.jsx)(`div`,{className:`mt-5 divide-y divide-border border-t`,children:EO.map((e,t)=>(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] gap-x-4 py-3`,children:[(0,L.jsx)(Su,{className:`h-4 w-24`}),(0,L.jsx)(Su,{className:`h-4`,style:{width:`${e*2}%`}})]},t))})]}),(0,L.jsx)(Su,{className:`h-40 rounded-lg max-md:hidden`})]})]}),OO=2e3,kO={type:`active`,predicate:e=>e.state.data===void 0},AO=(e,t)=>e.some(e=>K_(e.state,t))&&!e.some(e=>e.state.dataUpdatedAt>=t),jO=({children:e})=>{let t=x(),n=(0,j.useContext)(G_),r=h(kO),[i,a]=(0,j.useState)(()=>AO(t.getQueryCache().getAll(),n));return(0,j.useEffect)(()=>{if(i)return;let e=setTimeout(()=>a(!0),OO);return()=>clearTimeout(e)},[i]),(0,j.useEffect)(()=>{if(i||r>0)return;let e=setTimeout(()=>t.isFetching(kO)===0&&a(!0),0);return()=>clearTimeout(e)},[i,r,t]),(0,L.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,"aria-busy":!i||void 0,children:[(0,L.jsx)(`div`,{className:R(`flex min-h-0 flex-1 flex-col`,!i&&`invisible`),children:e}),!i&&(0,L.jsx)(NO,{})]})},MO=()=>(0,L.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:(0,L.jsx)(NO,{})}),NO=()=>(0,L.jsxs)(`div`,{role:`status`,"aria-label":H(`loading`),className:`absolute inset-x-0 top-0 flex flex-col gap-4 p-4 md:p-6`,children:[(0,L.jsx)(Su,{className:`h-6 w-48`}),(0,L.jsx)(Su,{className:`h-24`}),(0,L.jsx)(Su,{className:`h-40`}),(0,L.jsx)(Su,{className:`h-40`})]}),PO=wO(()=>s(()=>import(`./list-page-BUtWO_Zd.js`).then(e=>e.ListPage),__vite__mapDeps([5,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),()=>(0,L.jsx)(TO,{})),FO=wO(()=>s(()=>import(`./record-page-JFlxtSyg.js`).then(e=>e.RecordPage),__vite__mapDeps([28,1,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,29,30,25,31,32,33,34,35,24,36,37,38])),()=>(0,L.jsx)(DO,{})),IO=wO(()=>s(()=>import(`./create-route-CSe9DhbY.js`).then(e=>e.CreateRoute),__vite__mapDeps([39,1,6,40,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35,37,38])),()=>(0,L.jsx)(DO,{})),LO=wO(()=>s(()=>import(`./composed-page-hn7I0Ulk.js`).then(e=>e.ComposedPage),__vite__mapDeps([40,1,6,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35,37])),()=>(0,L.jsx)(MO,{})),RO=wO(()=>s(()=>import(`./account-page-BsAc4o17.js`).then(e=>e.AccountPage),__vite__mapDeps([41,1,6,29,7,9,10,11,12,13,14,15,16,17,18,19,20,21,30,25,31,32,33,34,35])),()=>(0,L.jsx)(MO,{})),zO=wO(()=>s(()=>import(`./sign-in-policy-page-GgyC3l_6.js`).then(e=>e.SignInPolicyPage),__vite__mapDeps([42,1,6,25])),()=>(0,L.jsx)(MO,{})),BO=wO(()=>s(()=>import(`./organization-page-CjQ7oJk4.js`).then(e=>e.OrganizationPage),__vite__mapDeps([43,1,6,25])),()=>(0,L.jsx)(MO,{})),VO=wO(()=>s(()=>import(`./first-organization-page-BtfoRENE.js`).then(e=>e.FirstOrganizationPage),__vite__mapDeps([44,1,6,45,7])),()=>(0,L.jsx)(MO,{})),HO=wO(()=>s(()=>import(`./organizations-page-2cKqhNJh.js`).then(e=>e.OrganizationsPage),__vite__mapDeps([46,1,6,25,33,45,7])),()=>(0,L.jsx)(MO,{})),UO=wO(()=>s(()=>import(`./members-page-BZyldmfB.js`).then(e=>e.MembersPage),__vite__mapDeps([47,1,6,7,25,32])),()=>(0,L.jsx)(MO,{})),WO=wO(()=>s(()=>import(`./invitations-page-X90SMPsK.js`).then(e=>e.InvitationsPage),__vite__mapDeps([48,1,6,25,31,32,47,7])),()=>(0,L.jsx)(MO,{})),GO=wO(()=>s(()=>import(`./connect-route-l21XyxhS.js`).then(e=>e.ConnectRoute),__vite__mapDeps([49,1,6,34])),()=>(0,L.jsx)(vv,{})),KO=wO(()=>s(()=>import(`./public-form-page-CMaHcrdf.js`).then(e=>e.PublicFormPage),__vite__mapDeps([50,1,6,7,51])),()=>(0,L.jsx)(vv,{})),qO=wO(()=>s(()=>import(`./guest-call-page-D09z7u-V.js`).then(e=>e.GuestCallPage),__vite__mapDeps([52,1,6,7])),()=>(0,L.jsx)(vv,{})),JO=wO(()=>s(()=>import(`./assistant-shell-CdVAnpMe.js`).then(e=>e.AssistantPanel),__vite__mapDeps([53,1,6]))),YO=wO(()=>s(()=>import(`./call-rings-BV5na0xp.js`).then(e=>e.CallRings),__vite__mapDeps([54,1,6,7]))),XO=wO(()=>s(()=>import(`./runtime-update-BaNRaM6l.js`).then(e=>e.RuntimeUpdateButton),__vite__mapDeps([55,1,6]))),ZO,QO=()=>ZO??=Promise.allSettled([PO.preload(),FO.preload(),LO.preload()]),$O=(e,t)=>AE(`money:${e}:${t??``}`,n=>new Intl.NumberFormat(n,{style:`currency`,currency:e,...t!==void 0&&{minimumFractionDigits:t,maximumFractionDigits:t}})),ek=(e,t,n)=>$O(t,n).format(e/100),tk=()=>AE(`grouped`,e=>new Intl.NumberFormat(e)),nk=e=>tk().format(e),rk=e=>e>0?`+${tk().format(e)}`:tk().format(e).replace(`-`,`−`),ik=e=>`${e}%`,ak=e=>{if(e<1e4)return jE(`rows`,{count:nk(e),n:e});let t=10**(Math.floor(Math.log10(e))-3);return jE(`aboutRows`,{count:nk(Math.round(e/t)*t)})},ok=({signIn:e,onStop:t})=>{let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(),o=async()=>{r(!0),a(void 0);try{await t()}catch(e){if(!(e instanceof K))throw e;a(Qv(e)),r(!1)}};return(0,L.jsxs)(`div`,{role:`region`,"aria-label":H(`staffSession`),className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,L.jsx)(Kl,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,L.jsx)(`p`,{className:`min-w-64 flex-1 break-words`,children:H.rich(`staffSignedIn`,{staff:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.staffName??e.staff}),user:(0,L.jsx)(`span`,{className:`font-semibold`,children:e.user}),until:QE(Date.parse(e.expiresAt)),reason:e.reason})}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,L.jsx)(B,{size:`sm`,loading:n,onClick:()=>void o(),children:H(`stopStaffSession`)})]})},sk=(e,t)=>e.startsWith(`${t}/`)?e.slice(t.length+1):void 0,ck=(e,t,n,r,i)=>{if(t.kind!==`create`||t.resource!==n.messages)return e;let a=sk(t.channel,n.conversations);return a===void 0||r(t.channel)||i.has(t.key)?e:{...e,[a]:(e[a]??0)+1}},lk=(e,t)=>e[t]?{...e,[t]:0}:e,uk=e=>/^-?\d+$/.test(e)?e:JSON.stringify(e),dk=(e,t,n,r,i)=>{if(i.length===0)return;let a=i.map(n=>`(${e} = ${uk(n.key)} AND ${t} > ${n.readTo})`).join(` OR `);return`${n} != ${JSON.stringify(r)} AND (${a})`},fk=e=>Object.fromEntries(e.map(({value:e,count:t})=>[String(e),t])),pk=async(e,t,n,r,i)=>{let a=n.readPosition,o=t[n.resource];if(!a||!o||r.length===0)return{};let s=t[a.resource]?.author;if(s===void 0)return{};let c=r.map(e=>`${a.field} = ${uk(e)}`).join(` OR `),l=await e.list(a.resource,{filter:`${s} = ${JSON.stringify(i)} AND (${c})`,pageSize:r.length,fields:[a.field,a.message]}),u=new Map(l.items.map(e=>[String(e[a.field]),Number(e[a.message]??0)])),d=dk(n.field,o.primaryKey[0],n.sender,i,r.map(e=>({key:e,readTo:u.get(e)??0}))),f=fk((await e.aggregate(n.resource,{groupBy:n.field,filter:d,limit:r.length})).groups);return Object.fromEntries(r.map(e=>[e,f[e]??0]))},mk=(e,t,n)=>{let r=Fw(),i=X(),{resources:a}=Vv(),[o,s]=(0,j.useState)(),c=n.join(`
4
+ `);return(0,j.useEffect)(()=>{if(!r||!t)return;let{store:n,me:o}=r,l={conversations:e,messages:t.resource},u=!0,d=()=>{pk(i,a,t,c===``?[]:c.split(`
5
+ `),o).then(t=>{u&&s(Object.fromEntries(Object.entries(t).map(([t,r])=>[t,n.viewing(`${e}/${t}`)?0:r])))},e=>{u&&(s(void 0),reportError(e))})};d();let f=[n.onNotice(e=>s(t=>t&&ck(t,e,l,n.viewing,n.own()))),n.onResync(d),n.onView(t=>{let n=sk(t,e);n!==void 0&&s(e=>e&&lk(e,n))})];return()=>{u=!1;for(let e of f)e()}},[r,i,a,e,t,c]),r&&t?o:void 0},hk=e=>e.record&&`conversation`in e.record?e.record.conversation:void 0,gk=(e,t)=>{if(!t.typing&&!t.unread)return;let n=t.unread?hk(e):void 0;return r=>{let i=zw(),a=mk(e.resource,n,r.map(e=>e.id)),o={};for(let n of r){let r=a?.[n.id]??0,s=t.typing&&!n.active&&i.has(`${e.resource}/${n.id}`);(r!==0||s)&&(o[n.id]={...r>0&&{strong:!0,count:r,label:V(`unread`,{count:r})},...s&&{typing:!0}})}return o}},_k=(e,t)=>!e||!t?e??t:n=>{let r=e(n),i=t(n);if(!r||!i)return r??i;let a={...r};for(let[e,t]of Object.entries(i)){let n=[r[e]?.label,t.label].filter(Boolean).join(`, `);a[e]={...r[e],...t,...n&&{label:n}}}return a},vk=(e,t,n)=>{if(!e)return;let r=new Map((n??[]).map(e=>[e.userId,e]));return Object.fromEntries(Object.entries(e).map(([e,{person:n,...i}])=>{if(n===void 0)return[e,i];let a=r.get(n),o=DT(t,n);return[e,{...i,person:{...a&&{status:a},...o&&{presence:o}}}]}))},yk=(e,t,n)=>({filter:n.filter??``,orderBy:n.orderBy??cE(e,t),pageSize:n.limit??3,fields:[...new Set([...e.primaryKey,qr(e,t),...UD(e,t),...n.status===void 0?[]:[n.status]])]}),bk=(e,t,n,r)=>{if(n.status===void 0)return;let i=String(r[n.status]??``);return{label:e.fields[n.status]?.type===`enum`&&i?Ur(i,t.fields[n.status]?.valueLabels):i,tone:n.tones?.[i]??`neutral`,pulse:n.pulse?.includes(i)??!1}},xk=(e,t,n,r,i,a,o)=>r.map(r=>{let s=nr(sE(e,r)),c=bk(e,t,n,r);return{id:s,label:o(e,t,r,s),href:ud({kind:`record`,resource:e.name,key:s},i),...c&&{status:c},active:s===a}}),Sk=(e,t,n,r,i)=>{let a=n.find(t=>nr(sE(e,t))===r);return a!==void 0&&t.some(e=>!Object.is(a[e],i[e]))},Ck=(e,t,n)=>{if(t.marks===void 0||!n||!Object.hasOwn(n,t.marks))return;let r=n[t.marks];return()=>r(e)},wk=e=>e&&(t=>vk(e(t),ET(),ID().data)),Tk=({model:e,request:t})=>I.navRecent(e.name,t.filter,t.orderBy,t.pageSize),Ek=e=>{let t=x();(0,j.useEffect)(()=>t.getQueryCache().subscribe(n=>{if(n.type!==`updated`||n.action.type!==`success`)return;let[r,i,a]=n.query.queryKey,o=n.action.data?.record;if(r===`record`&&typeof a==`string`&&o)for(let n of e){if(n.model.name!==i)continue;let e=t.getQueryData(Tk(n));e&&Sk(n.model,n.request.fields,e.items,a,o)&&t.invalidateQueries({queryKey:Tk(n),exact:!0})}}),[t,e])},Dk=(e,t,n,r=!0)=>{let i=X(),a=qD(),{marks:o}=jT(),s=(0,j.useMemo)(()=>{if(!r)return[];let t=ZT(e);return Object.values(e.views).flatMap(n=>{let r=e.resources[n.resource],i=n.nav?.recent;return r&&i&&!n.nav?.hidden&&!t.has(r.name)?[{model:r,view:n,recent:i,request:yk(r,n,i),useMarks:wk(_k(Ck(r.name,i,o),gk(n,i)))}]:[]})},[e,o,r]);Ek(s);let c=ee({queries:s.map(e=>({queryKey:Tk(e),queryFn:()=>i.list(e.model.name,e.request)}))});return Object.fromEntries(s.map(({model:e,view:r,recent:i,useMarks:o},s)=>{let l=c[s];if(l.isPending)return[e.name,{state:`loading`}];if(l.isError)return[e.name,{state:`error`}];let u=n.resource===e.name?n.key:void 0;return[e.name,{state:`ready`,records:xk(e,r,i,l.data.items,t,u,a),...o&&{useMarks:o}}]}))},Ok=F(`live`),kk=e=>typeof e==`object`&&!!e&&typeof e.uri==`string`,Ak=e=>typeof e==`object`&&!!e&&typeof e.uploaded?.value==`string`,jk=e=>{if(Ak(e))return{...e.uploaded.file,...e.preview&&{url:e.preview},corrected:e.uploaded.corrected};if(kk(e))return`missing`in e?{name:Ok(`fileMissing`),type:``,missing:!0}:e},Mk=[`bytes`,`kB`,`MB`,`GB`],Nk=e=>{let t=e,n=0;for(;t>=1e3&&n<Mk.length-1;)t/=1e3,n+=1;return n===0?`${e} ${e===1?`byte`:`bytes`}`:`${t<10?t.toFixed(1):Math.round(t)} ${Mk[n]}`},Pk=e=>e.startsWith(`image/`)&&e!==`image/svg+xml`,Fk=2,Ik=1e5,Lk=(e,t)=>(e.width!==void 0||e.height!==void 0)&&(e.width??Ik)>=t.width*Fk&&(e.height??Ik)>=t.height*Fk,Rk=e=>(e.width??Ik)*(e.height??Ik),zk=(e,t)=>{let n=jk(e);if(!(!n||`missing`in n||!n.url||!Pk(n.type)))return{url:(`variants`in n&&n.variants?Object.values(n.variants):[]).filter(e=>Lk(e,t)).sort((e,t)=>Rk(e)-Rk(t))[0]?.url??n.url,...`placeholder`in n&&n.placeholder!==void 0&&{placeholder:n.placeholder}}},Bk=e=>{let t=e.file?.accept??[];return t.length===0||t.includes(`*/*`)?void 0:t.join(`,`)},Vk=e=>Ak(e)?e.uploaded.value:kk(e)?e.uri:null,Hk=(e,t)=>{if(Ak(e))return!0;let n=e=>kk(e)?e.uri:null;return n(e)!==n(t)},Uk=F(`data-grid`),Wk=e=>typeof e==`object`&&e&&`name`in e?String(e.name):String(e),Gk=(e,t)=>{if(t==null)return`—`;switch(e.kind){case`text`:case`id`:return String(t);case`money`:if(e.currency===void 0)throw Error(`Money column "${e.id}" has no currency`);return`${ek(Number(t),e.currency,e.decimals)}${e.suffix??``}`;case`date`:return YE(Number(t));case`datetime`:return e.relative?lD(Math.round((Date.now()-Number(t))/1e3)):QE(Number(t));case`number`:return`${e.prefix??``}${nk(Number(t))}${e.suffix??``}`;case`signed`:return`${e.prefix??``}${rk(Number(t))}${e.suffix??``}`;case`percent`:return Number(t)===0?`—`:ik(Number(t));case`status`:return Ur(String(t),e.labels);case`relation`:return Wk(t);case`boolean`:return t?void 0:Uk(`no`);case`file`:return jk(t)?.name??`—`;case`user`:return e.users?.(String(t))?.name??String(t)}},Kk=(e,t)=>Math.ceil(e.length*7.2)+24+(t?16:0)+28,qk=e=>Math.ceil(Math.max(0,...e.map(e=>e.length))*7.2)+56,Jk={body:7.5,mono:7.2,numeric:8},Yk=24,Xk=16,Zk=new Set([`status`,`money`,`number`,`signed`,`percent`,`date`,`datetime`,`boolean`]),Qk=new Set([`money`,`number`,`signed`,`percent`,`date`,`datetime`]),$k=80,eA=400,tA=240,nA=e=>e===`id`?Jk.mono:Qk.has(e)?Jk.numeric:Jk.body,rA=(e,t)=>e.value?e.value(t):t[e.id],iA=(e,t)=>{let n=t.map(t=>Gk(e,rA(e,t)));if(e.kind===`status`)return qk(n.map(e=>e??``));let r=e.kind===`user`||e.kind===`file`?Yk:0;return Math.max(0,...n.map(t=>t===void 0?Xk:Math.ceil(t.length*nA(e.kind))))+r+24},aA=(e,t,n)=>Math.min(n,Math.max(t,e)),oA=(e,t)=>{if(Zk.has(e.kind)&&!e.title)return{...e,fixed:!0,width:Math.max(e.minWidth??0,t)};let n={...e,fixed:!1,width:aA(t,$k,eA)};return e.kind===`id`?{...n,minWidth:Math.max(Kk(e.header,e.sortable??!1),Math.min(t,tA))}:n},sA=(e,t)=>{if(!e.fit)return e;let n=Math.max(0,...t.map(e.fit));return{...e,fixed:!0,width:aA(n,e.minWidth??0,e.maxWidth??1/0)}},cA=(e,t)=>{if(t.length===0)return e;let n=e.map(e=>e.render?sA(e,t):oA(e,iA(e,t))),r=n.filter((t,n)=>!t.fixed&&!t.title&&!e[n].render).map(e=>e.width),i=Math.max(0,...r);return n.map((t,n)=>t.title&&!e[n].render?{...t,width:Math.max(t.width,i)}:t)},lA=[[/^\s*(```|~~~).*$/,``],[/^\s*\[[^\]]+\]:\s+\S.*$/,``],[/^\s*([-*_]\s*){3,}$/,``],[/^\s*\|?(\s*:?-+:?\s*\|)+\s*:?-*:?\s*$/,``],[/^\s*#{1,6}\s+/,``],[/^\s*(>\s?)+/,``],[/^\s*([-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/,``]],uA=[[/!\[([^\]]*)\]\([^)]*\)/g,`$1`],[/\[([^\]]*)\]\([^)]*\)/g,`$1`],[/\[([^\]]+)\]\[[^\]]*\]/g,`$1`],[/<((?:https?|mailto):[^>\s]+)>/gi,`$1`],[/<\/?[a-z][^>]*>/gi,``],[/`([^`]+)`/g,`$1`],[/(?<!\\)(\*\*|__)(?=\S)(.+?)(?<=\S)\1/g,`$2`],[/(?<![\\\w*])\*(?=\S)(.+?)(?<=\S)\*/g,`$1`],[/(?<![\\\w])_(?=\S)(.+?)(?<=\S)_(?!\w)/g,`$1`],[/(?<!\\)~~(.+?)~~/g,`$1`],[/\s*\|\s*/g,` `],[/\\([\\`*_{}[\]()#+\-.!>~|])/g,`$1`]],dA=200,fA=e=>{let t=e.split(/\r?\n/).map(e=>lA.reduce((e,[t,n])=>e.replace(t,n),e)),n=uA.reduce((e,[t,n])=>e.replace(t,n),t.join(`
6
+ `)).replace(/\s+/g,` `).trim();return n.length>dA?`${n.slice(0,199).trimEnd()}…`:n},pA=(e,t)=>e.type===`text`&&!!t?.markdown,mA=new Set([`email`,`phone`,`url`]),hA=e=>e?.format!==void 0&&mA.has(e.format)?e.format:void 0,gA=(e,t)=>{let n=t.trim();if(e===`email`)return/^[^\s@]+@[^\s@]+$/.test(n)?`mailto:${n}`:void 0;if(e===`phone`){let e=n.replace(/[^\d+]/g,``).replace(/(?!^)\+/g,``);return/\d/.test(e)?`tel:${e}`:void 0}return/^https?:\/\/\S+$/i.test(n)?n:void 0},_A=e=>e===`email`?{type:`email`,inputMode:`email`,autoComplete:`email`}:e===`phone`?{type:`tel`,inputMode:`tel`,autoComplete:`tel`}:e===`url`?{type:`url`,inputMode:`url`,autoComplete:`url`}:{},vA=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},yA=(e,t)=>{let n=vA(e,t);return n===void 0||Yn(n)?void 0:n},bA=(e,t)=>{let n=vA(e,t);return n!==void 0&&Yn(n)?n:`neutral`},xA=e=>typeof e!=`object`||!e,SA=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,CA=e=>Array.isArray(e)?e.length===0?`[]`:`[…]`:typeof e==`object`&&e?Object.keys(e).length===0?`{}`:`{…}`:e===``?`""`:SA(String(e),40),wA=e=>{let t=``;for(let n of e)if(t=t===``?n:`${t}, ${n}`,t.length>160)break;return SA(t,160)};function*TA(e){let t=e;for(let e in t)xA(t[e])&&(yield`${e}: ${CA(t[e])}`);for(let e in t)xA(t[e])||(yield`${e}: ${CA(t[e])}`)}function*EA(e){for(let t of e)yield CA(t)}var DA=e=>Array.isArray(e)?e.length===0?`[]`:e.every(xA)?wA(EA(e)):Ok(`jsonItems`,{count:e.length}):typeof e==`object`&&e?Object.keys(e).length===0?`{}`:wA(TA(e)):SA(String(e),160),OA=(e,t)=>`${t.prefix??``}${e}${t.suffix??``}`,kA=(e,t,n={},r=ME(),i=Date.now())=>{if(t==null||t===``)return`—`;switch(e.type){case`boolean`:return Ok(t?`yes`:`no`);case`file`:return jk(t)?.name??`—`;case`enum`:return Ur(String(t),n.valueLabels);case`timestamp`:{let e=Date.parse(String(t));return n.format===`relative`?lD(Math.round((i-e)/1e3)):QE(e,r)}case`date`:return YE(Date.parse(String(t)));case`decimal`:{let e=n.decimals===void 0?String(t):Number(t).toFixed(n.decimals);return n.format===`percent`?`${Number(t)}%`:OA(Number(e).toLocaleString(Ii(),{minimumFractionDigits:n.decimals??0,maximumFractionDigits:n.decimals??20}),n)}case`integer`:case`bigint`:return OA(String(t),n);default:return typeof t==`object`?JSON.stringify(t):String(t)}},AA=(e,t,n=ME(),r={})=>{if(e.type!==`timestamp`||typeof t!=`string`)return;let i=Date.parse(t);if(!Number.isNaN(i))return r.format===`relative`?QE(i,n):Ok(`shownIn`,{zone:VE(i,n)})},jA=e=>e==null||e===``,MA=(e,t,n,r,i)=>{let a=e.fields[n];return a?a.type===`relation`?i[n]??Wk(r):kA(a,r,t?.fields[n]):String(r)},NA=(e,t,n,r,i={})=>{let a=t?.fields[n]?.linkText;if(a===void 0||Jt(a).some(e=>jA(r[e])))return;let o=Xt(a,n=>MA(e,t,n,r[n],i)).trim();return o===``?void 0:o},PA={text:200,id:140,money:120,date:110,datetime:170,status:150,relation:200,boolean:64,number:100,signed:110,percent:110,user:130,file:180},FA=new Set([`datetime`,`date`,`boolean`,`percent`]),IA=(e,t,n)=>{switch(e.type){case`relation`:return`relation`;case`file`:return`file`;case`enum`:return`status`;case`boolean`:return`boolean`;case`timestamp`:return`datetime`;case`date`:return`date`;case`decimal`:return t?.format===`percent`?`percent`:t?.currency===void 0?`number`:`money`;case`integer`:case`bigint`:return t?.format===`signed`?`signed`:`number`;default:return t?.format===`code`||n===0&&e.name===`id`?`id`:`text`}},LA=e=>Math.round(Number.parseFloat(String(e))*100),RA=(e,t,n=[],r=xi(e,t))=>{let i=qr(e,t);return r.flatMap((r,a)=>{let o=e.fields[r];if(!o)return[];let s=t?.fields[r],c=IA(o,s,a),l=Object.fromEntries((o.enumValues??[]).map(e=>[e,Ur(e,s?.valueLabels)])),u=(c===`number`||c===`signed`)&&s?.prefix?s.prefix:void 0,d=Math.ceil(((u?.length??0)+(s?.suffix?.length??0))*7.2);return[{id:r,header:s?.label??P(r),kind:c,width:(r===`name`?260:PA[c])+d,sortable:o.sortable,minWidth:Math.max(c===`id`?150:0,Kk(s?.label??P(r),o.sortable),c===`status`?qk(Object.values(l)):0,d>0?PA[c]+d:0),...FA.has(c)&&{fixed:!0},...r===i&&{title:!0},...c===`text`&&r!==i&&hA(s)&&{link:hA(s)},...c===`text`&&r!==i&&s?.linkText!==void 0&&{linkText:n=>NA(e,t,r,n)},...n.includes(r)&&{highlight:!0},...o.type===`enum`&&{tones:Object.fromEntries((o.enumValues??[]).map(e=>[e,bA(s?.valueColors,e)])),labels:l},...o.type===`enum`&&s?.valueColors&&{colors:s.valueColors},...o.type===`enum`&&s?.badgeShape&&{shape:s.badgeShape},...u!==void 0&&{prefix:u},...s?.suffix!==void 0&&{suffix:s.suffix},...c===`datetime`&&s?.format===`relative`&&{relative:!0},...c===`money`&&s?.decimals!==void 0&&{decimals:s.decimals},...c===`money`&&s?.currency!==void 0&&{currency:s.currency,value:e=>e[r]==null?null:LA(e[r])},...(c===`datetime`||c===`date`)&&{value:e=>e[r]==null?null:Date.parse(String(e[r]))},...o.type===`json`&&{value:e=>e[r]==null?null:DA(e[r])},...pA(o,s)&&{value:e=>typeof e[r]==`string`?fA(e[r]):e[r]},...(c===`percent`||c===`number`&&o.type===`decimal`)&&{value:e=>e[r]==null?null:Number(e[r])}}]})},zA=`$photos`,BA=e=>{for(let t of e?.list?.displays??[])if(t.kind===`cards`&&t.photos)return t.photos},VA=(e,t,n)=>{if(n===void 0||e.primaryKey.length!==1)return t;let r=e.primaryKey[0];return t.map(e=>({...e,[zA]:n[String(e[r])]??[]}))},HA=(e,t)=>t.filter(t=>e[t]!==null&&e[t]!==void 0&&e[t]!==``),UA=F(`app/displays`),WA=(e,t,n)=>{let r=e.fields[n.by];if(!r)return[];let i=t?.fields[n.by],a=(r.enumValues??[]).map(e=>({value:e,label:Ur(e,i?.valueLabels)}));return r.nullable?[...a,{value:null,label:UA(`noValue`,{label:i?.label??P(n.by)})}]:a},GA=e=>e.position&&e.position.within===void 0?e.position.field:void 0,KA=(e,t,n)=>{let r=bt(n===null?Mt.isNull(t):Mt.eq(t,n));return e===``?r:`(${e}) AND ${r}`},qA=(e,t,n)=>({kind:`cards`,name:n.name,title:n.title??qr(e,t),...n.subtitle!==void 0&&{subtitle:n.subtitle},...n.badge!==void 0&&{badge:n.badge},...n.meta&&{meta:n.meta}}),JA=e=>{if(!Rd(e))return e instanceof Error?e.message:UA(`somethingWrong`);let t=e.errors.map(e=>e.message);return t.length>0?t.join(`; `):e.message},YA=e=>e?.list?.displays??[],XA=(e,t)=>t??e?.list?.default,ZA=(e,t,n)=>{let r=XA(e,n);return r===void 0?t?YA(e).find(e=>e.kind===`cards`)?.name??`table`:En:r},QA=`rows`,$A=(e,t)=>{if(YA(t).some(e=>e.kind===`cards`||e.name===`rows`))return;let n=qr(e,t),r=xi(e,t).filter(t=>t!==n&&e.fields[t]!==void 0),i=r.find(t=>e.fields[t].type===`enum`),a=r.filter(t=>t!==i&&e.fields[t].type!==`boolean`).slice(0,2);return{kind:`cards`,name:QA,label:UA(`list`),icon:`list`,title:n,...i!==void 0&&{badge:i},footer:a}},ej=(e,t)=>t.name===`rows`&&!YA(e).some(e=>e.name===`rows`),tj=(e,t,n)=>{let r=ZA(t,n);return n&&XA(t)===void 0&&r===`table`&&$A(e,t)?QA:r},nj=(e,t,n)=>(n===`rows`?$A(e,t):void 0)??rj(t,n),rj=(e,t)=>{if(t===`table`)return;let n=t=>YA(e).find(e=>e.name===t);return n(t)??n(e?.list?.default)},ij={cards:`cards`,map:`map`,board:`kanban`,calendar:`calendar`,timeline:`timeline`},aj=e=>[{name:En,label:UA(`table`),icon:`table`},...YA(e).map(e=>({name:e.name,label:e.label??P(e.name),icon:e.icon??ij[e.kind]}))],oj=(e,t,n)=>{let r=aj(t);return n&&$A(e,t)?[...r,{name:QA,label:UA(`list`),icon:`list`}]:r},sj=(e,t,n)=>({image:n.image,title:n.title??qr(e,t),subtitle:n.subtitle,amount:n.amount??[],badge:n.badge,code:n.code,meta:n.meta??[],footer:n.footer??[],flags:n.flags??[]}),cj=(e,t)=>HA(e.record,t),lj=(e,t)=>cj(e,t)[0],uj=(e,t)=>t===void 0?void 0:cj(e,[t])[0],dj=(e,t)=>e?.type===`text`&&typeof t==`string`?t:void 0,fj=(e,t,n={})=>{let{suffix:r,...i}=n;return e.type!==`decimal`&&e.type!==`integer`&&e.type!==`bigint`||r===void 0||n.format===`percent`?{amount:kA(e,t,n)}:{amount:kA(e,t,i),suffix:r}},pj=(e,t)=>{let n=YA(e).filter(e=>e.kind===`cards`);return(t.cards===void 0?n[0]:n.find(e=>e.name===t.cards))??{kind:`cards`,name:t.name}},mj=(e,t,n)=>{if(n.kind===`custom`)return n.fields;if(n.kind===`map`)return[n.latitude,n.longitude,...mj(e,t,pj(t,n))];if(n.kind===`board`){let r=qA(e,t,n);return[n.by,r.title,r.subtitle,r.badge,...r.meta??[]].filter(e=>e!==void 0)}if(n.kind===`calendar`)return[n.start,n.end,n.title??qr(e,t)].filter(e=>e!==void 0);if(n.kind===`timeline`)return[n.start,n.end,n.group,n.title??qr(e,t)].filter(e=>e!==void 0);let{image:r,title:i,subtitle:a,amount:o,badge:s,code:c,meta:l,footer:u,flags:d}=sj(e,t,n);return[r,i,a,...o,s,c,...l,...u,...d].filter(e=>e!==void 0)},hj=e=>(e?.actions??[]).flatMap(e=>(e.inputs??[]).flatMap(e=>e.from===void 0?[]:[e.from])),gj=(e,t)=>t.flatMap(t=>Jt(e?.fields[t]?.linkText??``)),_j=(e,t,n)=>{let r=$A(e,t),i=r?[...YA(t),r]:YA(t),a=[...n,...i.flatMap(n=>mj(e,t,n))];return[...new Set([...a,...gj(t,a),...hj(t)])]},vj=(e,t,n)=>{let r=ej(t,n)?[qr(e,t),...xi(e,t)]:mj(e,t,n);return[...new Set(r)].filter(t=>e.fields[t]?.sortable)},yj=e=>typeof e==`object`&&!!e&&`id`in e&&`name`in e,bj=(e,t)=>{let n={},r={},i=Array.isArray(t.$photos)?t[zA]:void 0;for(let[i,a]of Object.entries(t))(i!==`id`&&i!==`$photos`||Object.hasOwn(e.fields,i))&&(e.fields[i]?.type===`relation`&&yj(a)?(n[i]=a.id,r[i]=a.name):n[i]=a);return{key:nr(sE(e,n)),record:n,labels:r,...i&&{photos:i}}},xj=(e,t,n,r)=>{let i=e[n],a=zn(t[n],r),o=a?.listOf,s=o===void 0?void 0:i?.fields[o]?.relation?.resource;return s!==void 0&&e[s]?{model:e[s],view:t[s],listOf:!0}:{model:i,view:a,listOf:!1}},Sj=(e,t,n=!1)=>({display:e?tj(e,t,n):ZA(t,n),orderBy:e?cE(e,t):``,filterLayout:`bar`,filter:t?.list?.filter??``}),Cj=(e,t)=>e?.kind===`record`?{kind:`record`,resource:e.resource,key:nr(e.key),...e.edit&&{edit:!0},...e.open&&{open:e.open},...e.tab&&{tab:e.tab},...e.standard&&{standard:!0},...e.call&&{call:e.call},...e.version!==void 0&&{version:e.version},...e.run&&{run:e.run},...e.panel&&{panel:e.panel},...e.file&&{file:e.file},...e.thread&&{thread:e.thread}}:e?.kind===`list`?{...t(e.resource,e.list),...e}:e,wj=(e,t,n)=>{let r={...e,...t},i=e=>r[e]!==void 0&&r[e]!==n[e];return{kind:`list`,resource:e.resource,...e.list&&{list:e.list},...i(`filter`)&&{filter:r.filter},...i(`display`)&&{display:r.display},...i(`orderBy`)&&{orderBy:r.orderBy},...i(`filterLayout`)&&{filterLayout:r.filterLayout},...r.map&&{map:r.map},...r.calendar&&{calendar:r.calendar},...r.timeline&&{timeline:r.timeline},...r.savedSearch&&{savedSearch:r.savedSearch}}},Tj=()=>{let{path:e,params:t,basePath:n,navigate:r,back:i,backIsHistory:a}=Hu(),{pages:o,resources:s,views:c}=Vv(),l=Ey(),u=(0,j.useMemo)(()=>new Set(Object.keys(o)),[o]),d=t.toString(),f=(0,j.useMemo)(()=>hd(d?`${e}?${d}`:e,u),[e,d,u]),p=(0,j.useCallback)((e,t)=>{let n=xj(s,c,e,t);return Sj(n.model,n.view,l)},[s,c,l]),m=(0,j.useMemo)(()=>Cj(f,p),[f,p]),h=(0,j.useCallback)((e,t)=>r(ud(e),t),[r]),g=(0,j.useCallback)(e=>{if(f?.kind!==`list`)throw Error(`listTo and set change the list the app shows; use go to move to another address`);return wj(f,e,p(f.resource,f.list))},[f,p]),_=(0,j.useCallback)(e=>h(g(e),{replace:!0}),[g,h]),v=(0,j.useCallback)(e=>ud(e,n),[n]),y=(0,j.useCallback)(e=>e.startsWith(`${n}/`)?e.slice(n.length):e,[n]);return{address:m,set:_,listTo:g,go:h,href:v,open:(0,j.useCallback)(e=>r(y(e)),[y,r]),back:(0,j.useCallback)(e=>i(y(e)),[y,i]),backIsHistory:(0,j.useCallback)(e=>a(y(e)),[y,a])}},Ej=({to:e,...t})=>(0,L.jsx)(Zu,{to:ud(e),...t}),Dj=`SplashScreen`,Oj=e=>{if(e?.isPluginAvailable(Dj))return{show:()=>e.nativePromise(Dj,`show`,{autoHide:!1}),hide:()=>e.nativePromise(Dj,`hide`,{})}},kj=({answer:e,current:t,next:n})=>!e?.bundleId||e.required||e.bundleId===t||e.bundleId===n?{kind:`none`}:{kind:`take`,bundleId:e.bundleId},Aj=e=>{let t=typeof e==`object`&&e?e.bundleId:void 0;return typeof t==`string`?t:null},jj=({bridge:e,check:t,releasesUrl:n,splash:r})=>{let i=(t,n={})=>e.nativePromise(`LiveUpdate`,t,n),a=t=>t instanceof e.Exception,o=async(e,t)=>{try{return await e()}catch(e){if(!a(e))throw e;return t}},s=async e=>{await i(`downloadBundle`,{bundleId:e,url:`${n}/${e}`,artifactType:`manifest`}),await i(`setNextBundle`,{bundleId:e})},c=()=>o(async()=>{let[e,n,r]=await Promise.all([t(),i(`getCurrentBundle`),i(`getNextBundle`)]),a=kj({answer:e,current:Aj(n),next:Aj(r)});a.kind!==`none`&&await s(a.bundleId)},void 0),l=e=>o(async()=>{let[t,n]=await Promise.all([i(`getCurrentBundle`),i(`getNextBundle`)]),a=Aj(n);if(a===null||a===Aj(t))return!1;e();let o=!1;try{await r?.show(),await i(`reload`),o=!0}finally{o||await r?.hide()}return!0},!1),u;return{ready:()=>i(`ready`),applyNext:l,check:()=>(u??=c().finally(()=>{u=void 0}),u)}},Mj=e=>/(?:^|\s)ProtobaseNative\/([0-9a-f]{16})(?:\s|$)/.exec(e)?.[1],Nj=/^[A-Za-z0-9_-]{1,64}$/,Pj=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fj=e=>{if(!Pj(e))return;let{bundleId:t,url:n,required:r}=e;if((t===null||typeof t==`string`&&Nj.test(t))&&(n===null||typeof n==`string`)&&typeof r==`boolean`)return{bundleId:t,url:n,required:r}},Ij=15e3,Lj=e=>e instanceof TypeError||e instanceof DOMException&&e.name===`TimeoutError`,Rj=async(e,{apiOrigin:t,fingerprint:n,shellVersion:r})=>{let i=`${t}${Zr}?${$r({fingerprint:n,shellVersion:r})}`;try{let t=await e(i,{credentials:`omit`,cache:`no-store`,signal:AbortSignal.timeout(Ij)});return t.status===200?Fj(await t.json()):void 0}catch(e){if(Lj(e)||e instanceof SyntaxError)return;throw e}},zj=({bridge:e,apiOrigin:t,userAgent:n,fetch:r})=>{if(!e?.Exception||!e.isPluginAvailable(`LiveUpdate`))return;let i=Mj(n);return jj({bridge:{nativePromise:e.nativePromise.bind(e),Exception:e.Exception},check:async()=>i&&t?Rj(r,{apiOrigin:t,fingerprint:i,shellVersion:$i}):void 0,releasesUrl:`${t}${Qr}`,splash:Oj(e)})},Bj=({updater:e,children:t})=>((0,j.useEffect)(()=>{e&&e.ready()},[e]),(0,L.jsx)(gO.Provider,{value:e,children:t})),Vj=async(e,t)=>{let n=!1,r=!1;try{r=await e.applyNext(()=>{t.keep(),n=!0})}finally{!r&&n&&t.forget()}return r},Hj=2e4,Uj=async(e,t)=>{let n,r=new Promise(e=>{n=setTimeout(()=>e(!1),Hj)}),i=e.check();return await Promise.race([i.then(()=>!0),r]).finally(()=>clearTimeout(n))?t?Vj(e,t):!1:(i.then(()=>void 0),!1)},Wj=`protobase:ui-ready`,Gj=(e=window)=>void e.requestAnimationFrame(()=>e.setTimeout(()=>e.dispatchEvent(new Event(Wj)),0)),Kj=`pb-start`,qj=`pb-start-hand-off`,Jj=e=>{let t=e.getElementById(Kj);t&&(t.dispatchEvent(new Event(qj)),t.remove())},Yj=9e5,Xj=(e,t)=>{e();let n=setInterval(()=>{t()&&e()},Yj);return()=>clearInterval(n)},Zj=()=>{let e=_O(),t=J().state.kind===`signed-in`,n=!!Vv().versionChange;return(0,j.useEffect)(()=>{if(e&&t)return Xj(()=>void e.check(),()=>document.visibilityState===`visible`)},[e,t,n]),null},Qj=(e=Date.now)=>{let t;return{leave:()=>{t=e()},back:()=>{let n=t===void 0?0:e()-t;return t=void 0,n}}},$j=({updater:e,holdsChanges:t,page:n,now:r})=>{let i=Qj(r);return{leave:i.leave,back:async()=>{let r=i.back();n&&r>=3e5&&!t()&&await Vj(e,n)||await e.check()}}},eM=()=>{let e=_O(),{holdsChanges:t}=Hu();return(0,j.useEffect)(()=>{if(!e)return;let n=$j({updater:e,holdsChanges:t,page:io()}),r=()=>{if(document.visibilityState===`hidden`)return n.leave();n.back()};return document.addEventListener(`visibilitychange`,r),()=>document.removeEventListener(`visibilitychange`,r)},[e,t]),null},tM=[`never`,`thirty_minutes`,`one_hour`,`four_hours`,`today`,`this_week`,`custom`],nM={thirty_minutes:30,one_hour:60,four_hours:240},rM=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),iM=(e,t,n=``)=>{if(e===`never`)return null;if(e===`today`)return rM(t,1).toISOString();if(e===`this_week`)return rM(t,(8-t.getDay())%7||7).toISOString();if(e===`custom`){let e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/.test(n)?new Date(n):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString():void 0}return new Date(t.getTime()+nM[e]*6e4).toISOString()},aM=e=>String(e).padStart(2,`0`),oM=e=>{let t=new Date(e);return`${t.getFullYear()}-${aM(t.getMonth()+1)}-${aM(t.getDate())}T${aM(t.getHours())}:${aM(t.getMinutes())}`},sM=(e,t=Date.now())=>{let n=bi(e,t);return n?{availability:n.availability,text:n.text??``,clears:n.clearsAt===null?`never`:`custom`,custom:n.clearsAt===null?``:oM(n.clearsAt)}:{availability:`automatic`,text:``,clears:`never`,custom:``}},cM=(e,t)=>{let n=e.text.trim(),r=n===``?void 0:yi(n);if(r)return{problem:`text`,message:r};let i=iM(e.clears,t,e.custom);return i===void 0||i!==null&&Date.parse(i)<=t.getTime()?{problem:`time`}:{input:{availability:e.availability,text:n===``?null:n,clearsAt:i}}},lM={never:`never`,thirty_minutes:`thirtyMinutes`,one_hour:`oneHour`,four_hours:`fourHours`,today:`today`,this_week:`thisWeek`,custom:`custom`},uM=({current:e,onSave:t,onClear:n,onClose:r})=>{let[i,a]=(0,j.useState)(()=>sM(e)),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(),[u,d]=(0,j.useState)(!1),f=(0,j.useId)(),p=(0,j.useId)(),m=(0,j.useId)(),h=e=>a({...i,...e}),g=cM(i,new Date),_=u&&`problem`in g?g:void 0,v=async e=>{s(!0),l(void 0);try{await e(),r()}catch(e){if(!(e instanceof Id))throw e;l(e.status===400?e.message:Wx(`couldNotSave`)),s(!1)}},y=()=>{d(!0),`input`in g&&v(()=>t(g.input))};return(0,L.jsx)(xu,{title:Wx(e?`editStatus`:`setStatus`),onClose:r,actions:(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.jsx)(B,{variant:`ghost`,className:`sm:mr-auto`,disabled:o,onClick:()=>void v(n),children:Wx(`clear`)}),(0,L.jsx)(B,{onClick:r,children:Wx(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,form:f,loading:o,children:Wx(`save`)})]}),children:(0,L.jsxs)(`form`,{id:f,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:Wx(`statusText`)}),(0,L.jsx)(Hb,{id:p,name:`status`,autoComplete:`off`,autoFocus:!0,placeholder:Wx(`statusPlaceholder`),value:i.text,maxLength:200,invalid:_?.problem===`text`,..._?.problem===`text`&&{"aria-describedby":`${p}-problem`},onChange:e=>h({text:e.target.value})}),_?.problem===`text`&&(0,L.jsx)(`span`,{id:`${p}-problem`,className:`text-xs text-danger-text`,children:_.message})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-medium`,children:[Wx(`availability`),(0,L.jsx)(sx,{label:Wx(`availability`),value:i.availability,onChange:e=>h({availability:e}),options:[{value:`automatic`,label:Wx(`automatic`)},{value:`busy`,label:Wx(`busy`)},{value:`do_not_disturb`,label:Wx(`doNotDisturb`)}]}),i.availability===`do_not_disturb`&&(0,L.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:Wx(`doNotDisturbHint`)})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[Wx(`clearsAfter`),(0,L.jsx)(`select`,{name:`clears`,value:i.clears,onChange:e=>h({clears:e.target.value}),className:`h-8 rounded-md border border-border-strong bg-background px-2 font-normal`,children:tM.map(e=>(0,L.jsx)(`option`,{value:e,children:Wx(lM[e])},e))})]}),i.clears===`custom`&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:m,className:`font-medium`,children:Wx(`clearsAt`)}),(0,L.jsx)(Hb,{id:m,type:`datetime-local`,name:`clears-at`,value:i.custom,invalid:_?.problem===`time`,..._?.problem===`time`&&{"aria-describedby":`${m}-problem`},onChange:e=>h({custom:e.target.value})}),_?.problem===`time`&&(0,L.jsx)(`span`,{id:`${m}-problem`,className:`text-xs text-danger-text`,children:Wx(`pickTime`)})]}),c&&(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:c})]})})},dM=e=>{let t=X(),n=x(),r=LD(),[i,a]=(0,j.useState)(!1);if(!e||!r.isSuccess)return{};let o=bi(r.data),s=()=>n.invalidateQueries({queryKey:[`statuses`]});return{menu:{mark:o&&(0,L.jsx)(Jx,{status:o,textShown:`hover`}),label:o?(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-foreground`,children:[(0,L.jsx)(qx,{availability:o.availability}),(0,L.jsx)(`span`,{className:`truncate`,children:o.text??Kx(o.availability)})]}):Wx(`setStatus`),onOpen:()=>a(!0)},...i&&{dialog:(0,L.jsx)(uM,{current:o,onSave:async e=>{await t.status.set(e),await s()},onClear:async()=>{await t.status.clear(),await s()},onClose:()=>a(!1)})}}},fM=e=>e?.kind===`page`?e.page:e?.kind===`list`?$T(e.resource,e.list):e?.resource,pM=e=>e?.kind===`record`?e:void 0,mM=({workspace:e,sidebarMode:t,assistant:n,runtime:r})=>{let i=Vv(),{state:a,session:o,signOut:s,stopStaffSession:c,organizations:l}=J(),[u,d]=(0,j.useState)(!1),f=async()=>{d(!1),await s(),xS()},p=RC();if(a.kind!==`signed-in`&&a.kind!==`visitor`)throw Error(`The shell is only rendered for a signed-in user or a visitor`);let m=a.kind===`signed-in`?a.user:void 0,h=a.kind===`signed-in`?a.staff:void 0,{path:g,params:_,basePath:v,navigate:y}=Hu(),{address:b,go:x,open:S,back:C,backIsHistory:w}=Tj(),T=fM(b),E=pM(b),D=hO(),O=iT(),k=VT(!!(l&&m)),A=k.current,ee=zT(),te=!!l&&A!==void 0&&!A.organization&&k.fresh,ne=!!(l&&m)&&!k.error&&(A===void 0||!A.organization&&!k.fresh),re=!te&&!ne,ie=Dk(i,v,{resource:E?.resource,key:E?.key},re),ae=Z_();Vw(i);let oe=re?rE(i,v,ie):[],M=!l||!m?``:k.fresh?A?.organization?.id??``:k.failed?null:void 0,se=gE(i,g===`/`&&re,M),ce=b?.kind===`page`?i.pages[b.page]:void 0;(0,j.useEffect)(()=>{g===`/`&&re&&se.state!==`resolving`&&(se.address?x(se.address,{replace:!0}):m&&y(I_,{replace:!0}))},[g,re,se,x,m,y]);let le=b?.kind===`page`?void 0:b?.resource,ue=le?mv(i,le):void 0,de=le?zn(i.views[le],b?.kind===`list`?b.list:void 0):void 0,fe=oe.find(e=>e.items.some(e=>e.id===T)),N=le?i.resources[le]:void 0,pe=Uw(E?.resource??``,E?.key??``,!!(N&&E)),me=qD(),he=N&&E&&pe.data?me(N,de,pe.data.record,E.key):void 0,ge=!!E&&(pe.isLoading||ue?.state===`loading`),{shell:_e}=jT(),ve=_e?.actions,ye=_e?.rightPanel,be=i.bell&&m&&!h&&(0,L.jsx)(ED,{own:_e?.bell}),xe=dM(!!(i.status&&m&&!h)),Se=ID().data,Ce=ET(),[we,Te]=(0,j.useState)(!1),Ee=i.assistant?.url,De=Ee&&(0,L.jsx)(hT,{open:we,onToggle:()=>Te(!we)}),Oe=Ee&&we&&(0,L.jsx)(JO,{url:Ee,client:n,page:_.size>0?`${g}?${_}`:g,onClose:()=>Te(!1)}),ke=i.errorReporting;(0,j.useEffect)(()=>{ke&&Og(ke)},[ke]);let Ae=i.runtime?.url,je=Ae&&(0,L.jsx)(XO,{url:Ae,client:r}),Me=rS(t??`text-small`),Ne=i.versionChange&&!Me&&(0,L.jsx)(bO,{}),Pe=KT((0,j.useCallback)(()=>HT(v),[v]),!!m),Fe=m&&UT(m,Pe.current),Ie=Fe?gw(Fe):!1,Le=OD(),Re=l&&m?JC(g,ee):void 0,ze=Cy(),Be=m?R_(g):void 0,Ve=YC(g)||g===`/-/organizations`||g===`/-/sign-in-policy`||g===`/-/menu`||!!Be,He=YC(g);(0,j.useEffect)(()=>{te&&!Ve?y(GC,{replace:!0}):re&&A?.organization&&He&&y(`/`,{replace:!0})},[te,Ve,re,A,He,y]);let Ue=Be&&ze?SE(xE(ze.tree),Be.tab):void 0,We=g===oS,Ge=re?yT(i,v,T,b?.kind===`list`||b?.kind===`page`):[],Ke=Ge.find(e=>!e.external)?.href.slice(v.length),qe={href:`${v}${oS}`,shown:We},Je=lS({desktop:Ty(),tabs:Ge,menuPage:qe}).on,Ye=(0,j.useRef)(!1);(0,j.useEffect)(()=>{let e=!Ye.current;Ye.current=!0;let t=sS(g,Ke,{starting:e,morePage:Je});t&&y(t,{replace:!0})},[g,Ke,Je,y]);let Xe=We?H(`menu`):m?Be?ze?.title??H(`account`):g===`/-/sign-in-policy`?H(`signInPolicy`):Re:void 0,Ze=de?.names?.plural??(le&&P(le)),Qe=b?.kind===`record`&&!b.standard&&!!i.views[b.resource]?.record,$e=Xe?[Xe]:xT({basePath:v,address:b,group:fe?.label,page:ce,resourceLabel:Ze,headingless:Qe,recordTitle:he,recordLoading:ge}),et=de?.names?.singular??(le&&P(le)),tt=ce&&b?.kind===`page`?SE(xE(ce.tree),b.tab):void 0;RS(LS(IS({address:b,page:ce?{title:ce.title,...tt&&{tab:tt.label}}:Be&&ze&&{title:ze.title,...Ue&&{tab:Ue.label}},accountPage:Xe,resourceLabel:Ze,singular:et,recordTitle:he,recordLoading:ge}),i.appName));let nt=Be?(0,L.jsx)(RO,{...Be}):m&&g===`/-/sign-in-policy`?Ie?(0,L.jsx)(zO,{}):(0,L.jsx)(Hv,{title:H(`adminsOnly`),children:H(`onlyAdminPolicy`)}):Re&&g===`/-/organization`?(0,L.jsx)(BO,{current:A,basePath:v,onChanged:k.reload}):Re&&(g===`/-/organization/members`||g===`/-/organization/invitations`)?QC(A)?g===`/-/organization/members`?(0,L.jsx)(UO,{current:A,statuses:Se,presence:Ce}):(0,L.jsx)(WO,{current:A}):(0,L.jsx)(Hv,{title:H(`ownersOnly`),children:H(`onlyOwners`)}):Re&&g===`/-/organizations`?(0,L.jsx)(HO,{state:k,basePath:v}):ne&&k.failed?(0,L.jsx)(Hv,{title:ee(`couldNotReadOrganizations`),children:(0,L.jsx)(B,{className:`mt-3`,onClick:k.reload,children:ee(`tryAgain`)})}):te||ne?null:b?b.kind===`page`?ce?(0,L.jsx)(LO,{name:ce.name,...b.tab&&{tab:b.tab},...b.params&&{params:b.params}},ce.name):(0,L.jsx)(Hv,{title:H(`notFound`),children:H.rich(`noPage`,{page:b.page})}):ue&&ue.state!==`ready`?(0,L.jsx)(QD,{status:ue}):b.kind===`create`?(0,L.jsx)(IO,{resource:b.resource,values:b.values},b.resource):b.kind===`record`?(0,L.jsx)(FO,{resource:b.resource,recordKey:b.key},`${b.resource}/${b.key}`):(0,L.jsx)(PO,{address:b},$T(b.resource,b.list)):g===`/`?se.state===`resolving`||se.address?null:(0,L.jsx)(Hv,{title:H(`chooseResource`),children:H(`pickFromSidebar`)}):(0,L.jsx)(Hv,{title:H(`notFound`),children:H(`nothingHere`)}),rt=Ie&&Le.length>0,it=u&&(0,L.jsx)(xu,{title:H(`signOutQuestion`),description:H(`signOutHelp`),onClose:()=>d(!1),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>d(!1),children:H(`signOutCancel`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>void f(),children:H(`signOutConfirm`)})]})});return m&&te&&YC(g)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(VO,{path:g,basePath:v,email:m.email,mayCreate:l?.create===`everyone`||gw(m),seesAll:(A?.globalRoles.length??0)>0,onSignOut:()=>d(!0)}),it]}):(0,L.jsx)(yS,{pageScroll:!0,sidebarMode:t??`text-small`,activeItem:T??``,breadcrumb:$e,titleStatus:(ae===`refreshing`||ae===`failed`)&&(0,L.jsx)(MD,{failed:ae===`failed`}),staleContent:ae===`failed`?`failed`:void 0,user:Fe&&vw(Fe),onSignOut:m&&(()=>d(!0)),signIn:m?void 0:p.link(),workspace:A?.organization?.name??e,appName:i.appName,appIcon:i.appIcon,logo:CE,navGroups:oe,bottomBar:Ge,menuPage:qe,bottomBarSearch:bT(i),userMenu:[re?QT(i,v,T):[],l&&m?$C(v,g,ee,A):[],m?B_(v,g,Ie):[]],account:m&&`${v}/-/account`,organizations:l&&{label:ee(`organizations`),...A?.organization&&{current:{id:A.organization.id,name:A.organization.name}},others:k.organizations.filter(e=>e.id!==A?.organization?.id),onSwitch:e=>void o.organizations.switchTo(e).then(()=>HT(v))},theme:{preference:O.preference,onChange:O.choose},...xe.menu&&{status:xe.menu},roles:Pe.current?.active?{active:Pe.current.active,roles:Pe.current.roles,onSwitch:Pe.switchTo}:void 0,onNavigate:S,onBack:C,backIsHistory:w,sidebarNotice:(0,L.jsx)(yO,{}),banner:(h||rt)&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(ok,{signIn:h,onStop:c}),rt&&(0,L.jsx)(AD,{off:Le})]}),search:D.available&&re?{placeholder:D.placeholder,text:D.text,onTextChange:D.setText,query:D.query,loading:D.loading,groups:D.groups,onSelect:S}:void 0,actions:(ve||be||Ne||je||De)&&(0,L.jsxs)(L.Fragment,{children:[ve&&(0,L.jsx)(sw,{name:`shell.actions`,fallback:null,children:(0,L.jsx)(ve,{})}),be,Ne,je,De]}),overlays:(0,L.jsxs)(L.Fragment,{children:[xe.dialog,i.calls&&m&&!h&&(0,L.jsx)(YO,{}),it]}),rightPanel:(ye||Oe)&&(0,L.jsxs)(L.Fragment,{children:[ye&&(0,L.jsx)(sw,{name:`shell.rightPanel`,fallback:null,children:(0,L.jsx)(ye,{})}),Oe]}),children:(0,L.jsx)(sw,{name:`page`,fallback:(0,L.jsx)(Hv,{title:H(`pageNotLoaded`),children:H(`pageNotLoadedHelp`)}),resetKey:_.size>0?`${g}?${_}`:g,children:nt})})},hM=({baseUrl:e,client:t,sources:n,workspace:r,sidebarMode:i,ui:a,assistant:o,runtime:s})=>{let{state:c,session:l,markSignedOut:u}=J(),d=rS(i??`text-small`),{path:f}=Hu(),p=Tw(c),m=g_(c),h=oa(),g=(0,j.useMemo)(()=>h&&m?AS({cache:h,owner:p}):void 0,[h,m,p]);return(0,L.jsx)(av,{baseUrl:e,client:t,sources:n,token:c.kind===`visitor`?void 0:l.token,onUnauthenticated:u,persistence:g,children:(0,L.jsx)(Gv,{children:(0,L.jsxs)(mT,{children:[!d&&(0,L.jsx)(CO,{}),(0,L.jsx)(Zj,{}),f===`/-/connect`?(0,L.jsx)(GO,{}):(0,L.jsx)(kD,{ui:a,children:(0,L.jsx)(NT,{children:(0,L.jsx)(LT,{children:(0,L.jsx)(XD,{children:(0,L.jsx)(mM,{workspace:r,sidebarMode:i,assistant:o,runtime:s})})})})})]})})},p)},gM=({baseUrl:e,client:t,ui:n,children:r})=>{let i=Ww();return i?(0,L.jsx)(av,{baseUrl:e,client:t,children:(0,L.jsx)(AT.Provider,{value:n??{},children:(0,L.jsx)(KO,{name:i.name},i.name)})}):r},_M=({baseUrl:e,children:t})=>{let n=Jw(),{basePath:r}=Hu();if(!n)return t;let i=new URL(e??`/api/v1`,window.location.href),a=`${i.origin}${i.pathname.slice(0,i.pathname.lastIndexOf(`/`))}`;return(0,L.jsx)(qO,{link:n.token,systemPath:a,base:`${window.location.origin}${r}`})},vM=({auth:e,workspace:t,basePath:n,initialUrl:r,pluginLoader:i,pluginSource:a,locale:o,nativeBridge:s,startCache:c,...l})=>{Mi(o??`en`);let u=l.baseUrl&&new URL(l.baseUrl,window.location.href).origin,d=(0,j.useMemo)(()=>zj({bridge:s,apiOrigin:u,userAgent:navigator.userAgent,fetch:window.fetch.bind(window)}),[s,u]),f=(0,j.useMemo)(()=>d&&(()=>Uj(d,io())),[d]),p=(0,j.useMemo)(()=>ky(s),[s]),m=(0,j.useMemo)(()=>ob(s),[s]),h=(0,j.useMemo)(()=>hv(()=>{Jj(document),Oj(s)?.hide(),Gj()}),[s]);return(0,j.useEffect)(()=>h.start(),[h]),(0,j.useEffect)(()=>void QO(),[]),(0,L.jsx)(_v,{value:h,children:(0,L.jsx)(aa,{value:c,children:(0,L.jsx)(rT,{children:(0,L.jsx)(jy.Provider,{value:p,children:(0,L.jsx)(sb.Provider,{value:m,children:(0,L.jsx)(Bj,{updater:d,children:(0,L.jsx)(E_,{session:e,...u&&{origin:u},...s&&{nativeBridge:s},...f&&{afterSignIn:f},children:(0,L.jsxs)(Xu,{basePath:n,initialUrl:r,children:[(0,L.jsx)(eM,{}),s&&u&&(0,L.jsx)(F_,{nativeBridge:s,apiOrigin:u}),(0,L.jsx)(Ka,{...i&&{loader:i},...a&&{source:a},children:(0,L.jsx)(Sw,{children:(0,L.jsx)(gM,{baseUrl:l.baseUrl,client:l.client,ui:l.ui,children:(0,L.jsx)(_M,{...l.baseUrl&&{baseUrl:l.baseUrl},children:(0,L.jsx)(fw,{workspace:t,children:(0,L.jsx)(hM,{workspace:t,...l})})})})})})]})})})})})})})})},yM=`protobase:first-frame`,bM=e=>ue(()=>e.sessionStorage.getItem(yM)===`1`,!1),xM=(e,t)=>{let n=(0,se.createRoot)(e);(0,M.flushSync)(()=>n.render(t));let r=e.innerHTML;n.unmount(),e.innerHTML=r,e.dataset.firstFrame=`frozen`},SM=async e=>{e.getPlatform()===`ios`&&e.isPluginAvailable(`Keyboard`)&&await e.nativePromise(`Keyboard`,`setAccessoryBarVisible`,{isVisible:!0})},CM=(e,t)=>{t===`ios`&&(e.dataset.pbTextSize=`system`)},wM=e=>[...e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^maximum-scale\s*=/.test(e)),`maximum-scale=1`].join(`, `),TM=e=>{let t=e.querySelector(`meta[name="viewport"]`);t&&t.setAttribute(`content`,wM(t.getAttribute(`content`)??``))},EM=e=>{if(e.length===0)return;if(e.length>1)throw Error(`The page has ${e.length} ${Yr} meta tags; it may have one`);let t=e[0],n=URL.canParse(t)?new URL(t):void 0;if(!n||n.protocol!==`http:`&&n.protocol!==`https:`||n.origin!==t)throw Error(`The page's ${Yr} meta tag holds "${t}", which is not an http or https origin such as https://shop.example.com`);return t},DM=()=>EM([...document.querySelectorAll(`meta[name="${Yr}"]`)].map(e=>e.content)),OM=document.getElementById(`root`);if(!OM)throw Error(`index.html needs an element with id "root"`);de(document);var kM=vg(window);if(kM){TM(document),CM(document.documentElement,kM.getPlatform()),SM(kM);let e=ue(()=>window.sessionStorage,void 0);e&&ro(e,window.history)}var AM=Pi(),jM=Hi(AM).catch(()=>void 0),MM=Ua(Ra);ua().then(async e=>{let t=Yi(e);await Promise.race([Promise.all([Wa(MM,Xi(e),Ja),jM,...t?.locale?[Hi(t.locale).catch(()=>void 0)]:[],...t?[QO()]:[]]),new Promise(e=>setTimeout(e,Ja))]);let n=(0,L.jsx)(j.StrictMode,{children:(0,L.jsx)(vM,{baseUrl:`${DM()??``}/api/v1`,ui:va(ce),locale:AM,nativeBridge:kM,startCache:e,pluginSource:MM})});if(bM(window))return xM(OM,n);(0,se.createRoot)(OM).render(n)});var NM=(e,t,{filter:n,orderBy:r,pageSize:i=50,fields:a,labels:o,startToken:s=``})=>{let c=Td(n)??``;return{queryKey:[...I.list(t,c,r??``,i,s),a?.join(`,`)??``,...o?[o]:[]],initialPageParam:s,queryFn:({pageParam:n})=>e.list(t,{filter:c,orderBy:r,pageSize:i,fields:a,labels:o,pageToken:n}),getNextPageParam:e=>e.nextPageToken||void 0}},PM=(e,{enabled:t=!0,refetchInterval:n,...r}={})=>{let i=A({...NM(X(),e,r),enabled:t,refetchInterval:n}),a=i.data?.pages??[];return{...i,items:a.flatMap(e=>e.items),totalEstimate:a[0]?.totalSizeEstimate,labels:Object.fromEntries(Object.keys(r.labels??{}).map(e=>[e,Object.assign({},...a.map(t=>t.labels?.[e]??{}))]))}},FM=e=>{let t=new Map,n=async(t,{batch:n,waiting:r})=>{let i=await e.batchAggregates(t,n).then(e=>({result:e}),e=>({error:e}));for(let e of r)`error`in i?e.reject(i.error):e.resolve(i.result[e.kind][e.index])},r=(e,r)=>{t.get(e)===r&&(t.delete(e),n(e,r))},i=(e,n,i)=>new Promise((a,o)=>{let s=t.get(e);s&&s.batch[n].length>=100&&r(e,s);let c=t.get(e)??{batch:{facets:[],histograms:[],series:[]},waiting:[]};t.has(e)||(t.set(e,c),setTimeout(()=>r(e,c),0));let l=c.batch[n];l.push(i),c.waiting.push({kind:n,index:l.length-1,resolve:a,reject:o})});return{facets:(e,t,n={})=>i(e,`facets`,{field:t,...n}),histogram:(e,t,n={})=>i(e,`histograms`,{field:t,...n}),series:(e,t)=>i(e,`series`,t)}},IM=new WeakMap,LM=e=>{let t=IM.get(e);if(t)return t;let n=FM(e);return IM.set(e,n),n},RM=(e,t,n,r=!0)=>{let i=LM(X()),a=Td(n)??``;return O({queryKey:I.facets(e,t,a),enabled:r,queryFn:()=>i.facets(e,t,{filter:a,limit:50})})},zM=(e,t,n=!0)=>{let r=LM(X()),i=Td(t.filter)??``;return O({queryKey:I.series(e,t.field,`${t.range??``}${t.from??``}${t.to??``}`,t.granularity??``,i),enabled:n,queryFn:()=>r.series(e,{...t,filter:i})})},BM=(e,t,n,r=20,i=!0)=>{let a=LM(X()),o=Td(n)??``;return O({queryKey:I.histogram(e,t,r,o),enabled:i,queryFn:()=>a.histogram(e,t,{filter:o,buckets:r})})},VM=(e,t,n)=>{let r={...n,filter:Td(n.filter)??``};return{queryKey:I.aggregate(t,JSON.stringify(r)),queryFn:()=>e.aggregate(t,r)}},HM=(e,t,n=!0)=>O({...VM(X(),e,t),enabled:n}),UM=(e,t,n=!0)=>{let r=X();return ee({queries:t.map(t=>{let i={...t,filter:Td(t.filter)??``};return{queryKey:I.aggregate(e,JSON.stringify(i)),enabled:n,queryFn:()=>r.aggregate(e,i)}})})},WM=(e,t)=>{let n=X(),r=x(),i=nr(t);return S({mutationFn:({patch:r,etag:i})=>n.update(e,t,r,i),onSuccess:t=>{r.setQueryData(I.record(e,i),t),r.invalidateQueries({queryKey:[`page`,e]}),r.invalidateQueries({queryKey:[`list`,e]}),r.invalidateQueries({queryKey:[`map`,e]}),r.invalidateQueries({queryKey:[`count`,e]}),r.invalidateQueries({queryKey:[`aggregate`,e]}),r.invalidateQueries({predicate:t=>t.queryKey[0]===`plan`&&Ji(t.queryKey,new Set([e]))})}})},GM=e=>e instanceof Ld,KM=class extends Error{errors;constructor(e){super(Object.values(e).join(`; `)),this.errors=e,this.name=`ActionInputError`}},qM=(e,t)=>{let n=new Set(t.map(e=>e.name)),r=e instanceof KM?Object.entries(e.errors):Rd(e)?e.errors.flatMap(e=>e.field?[[e.field,e.message]]:[]):[];return Object.fromEntries(r.filter(([e])=>n.has(e)))},JM=e=>{if(!(!kk(e)||`missing`in e||!e.url))return{uri:e.uri,name:e.name,type:e.type,url:e.url,...e.size!==void 0&&{size:e.size}}},YM=(e,t)=>e&&Object.hasOwn(e,t)?e[t]:void 0,XM=(e,t)=>{if(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith(`/`)||t.startsWith(`#`))return;let n=t.split(/[?#]/,1)[0],r=n.slice(n.lastIndexOf(`/`)+1);return e.find(e=>e.name===r)},ZM=(e,t,n)=>e?.nonce===t?e.value:n,QM=(e,t)=>{let[n,r]=(0,j.useState)(),i=(0,j.useCallback)(n=>r(r=>({nonce:e,value:n(ZM(r,e,t))})),[e,t]);return[ZM(n,e,t),i]},$M=`data-protobase-link`,eN=`(() => {
7
+ const post = (message) => parent.postMessage({ protobase: 'html-frame', ...message }, '*')
8
+ const place = (hash) => {
9
+ const name = decodeURIComponent(hash.slice(1))
10
+ const target = name === '' || name === 'top' ? null : document.getElementById(name) ?? document.getElementsByName(name)[0]
11
+ if (!target) return 0
12
+ if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1')
13
+ target.focus({ preventScroll: true })
14
+ return target.getBoundingClientRect().top + window.scrollY
15
+ }
16
+ const follow = (event) => {
17
+ const link = event.target instanceof Element ? event.target.closest('a, area') : null
18
+ if (!link) return
19
+ event.preventDefault()
20
+ const index = link.getAttribute('${$M}')
21
+ const href = link.getAttribute('href') ?? ''
22
+ if (index !== null) post({ link: Number(index), newTab: event.button === 1 || event.ctrlKey || event.metaKey || event.shiftKey })
23
+ else if (href.startsWith('#') && event.button === 0) post({ scroll: place(href) })
24
+ }
25
+ document.addEventListener('click', follow, true)
26
+ document.addEventListener('auxclick', (event) => event.button === 1 && follow(event), true)
27
+ const height = () => post({ height: document.documentElement.getBoundingClientRect().height })
28
+ new ResizeObserver(height).observe(document.documentElement)
29
+ })()`,tN=`allow-scripts`,nN=(e,t)=>[`default-src 'none'`,e===`bridge`?`script-src 'nonce-${t}'`:`script-src 'unsafe-inline'`,`img-src data:`,`media-src data:`,`style-src 'unsafe-inline' data:`,`font-src data:`,`base-uri 'none'`,`form-action 'none'`].join(`; `),rN=()=>Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``),iN=`meta[http-equiv], base, noscript`,aN=(e,t,n)=>{let r=new DOMParser().parseFromString(e,`text/html`);for(let e of r.querySelectorAll(iN))e.remove();let i=r.createElement(`meta`);i.httpEquiv=`Content-Security-Policy`,i.content=nN(t,n);let a=r.createElement(`meta`);a.name=`referrer`,a.content=`no-referrer`;let o=r.createElement(`script`);return t===`bridge`&&o.setAttribute(`nonce`,n),o.textContent=eN,r.head.prepend(i,a,o),`<!doctype html>${r.documentElement.outerHTML}`},oN=1,sN=(e,t,n)=>e?.kind===`fixed`?e:e&&n!==e.viewport&&Math.abs(t-e.height-(n-e.viewport))<=oN?{kind:`fixed`}:{kind:`measured`,height:t,viewport:n},cN=e=>e?.kind===`measured`&&e.height>0?{style:{height:e.height}}:{className:`min-h-[60vh]`},lN=1e5,uN=(e,t,n)=>{if(!t||e.source!==t)return;let r=e.data;if(typeof r==`object`&&r&&`protobase`in r&&r.protobase===`html-frame`){if(`link`in r&&Number.isInteger(r.link)&&r.link>=0&&r.link<n)return{kind:`link`,index:r.link,newTab:`newTab`in r&&r.newTab===!0};if(`height`in r&&typeof r.height==`number`&&Number.isFinite(r.height)&&r.height>=0)return{kind:`height`,height:Math.min(Math.ceil(r.height),lN)};if(`scroll`in r&&typeof r.scroll==`number`&&Number.isFinite(r.scroll))return{kind:`scroll`,top:Math.min(Math.max(Math.round(r.scroll),0),lN)}}},dN=[],fN=(e,t)=>{let n=Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop)||0;window.scrollTo({top:e.getBoundingClientRect().top+window.scrollY+t-n})},pN=({html:e,title:t,links:n=dN,onLink:r,scripts:i=`bridge`,className:a})=>{let o=(0,j.useRef)(null),s=(0,j.useMemo)(()=>{let t=rN();return{nonce:t,srcDoc:aN(e,i,t)}},[e,i]),[c,l]=QM(s.nonce,void 0),[u,d]=QM(s.nonce,0),f=`${s.nonce}:${u}`,p=(0,j.useRef)({key:f,count:0});(0,j.useEffect)(()=>{let e=e=>{let t=uN(e,o.current?.contentWindow,n.length),i=o.current?.clientHeight;t?.kind===`height`&&i!==void 0&&l(e=>sN(e,t.height,i)),t?.kind===`link`&&r?.(n[t.index],{newTab:t.newTab}),t?.kind===`scroll`&&o.current&&fN(o.current,t.top)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[n,r,l]);let m=()=>{p.current.key!==f&&(p.current={key:f,count:0}),p.current.count+=1,p.current.count>1&&d(e=>e+1)},h=cN(c);return(0,L.jsx)(`iframe`,{ref:o,title:t,sandbox:tN,referrerPolicy:`no-referrer`,allow:i===`bridge`?`fullscreen`:void 0,srcDoc:u>1?``:s.srcDoc,onLoad:m,className:R(`block w-full border-0 bg-white`,h.className,a),style:h.style},f)},mN=e=>e.split(/[?#]/,1)[0].split(`/`).includes(`..`),hN=(e,t)=>{let n=t.trim(),r=gN(n);if(!(mN(n)||mN(r)))return XM(e,n)??XM(e,r)},gN=e=>{try{return decodeURI(e)}catch(t){if(t instanceof URIError)return e;throw t}},_N=(e,t)=>e.split(`,`).map(e=>{let n=/^(\s*)(\S+)([\s\S]*)$/.exec(e),r=n&&t(n[2]);return n&&r?`${n[1]}${r}${n[3]}`:e}).join(`,`),vN=(e,t)=>e.replace(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi,(e,n,r)=>{let i=t(r.trim());return i?`url("${i}")`:e}),yN=e=>{if(!URL.canParse(e))return;let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:void 0},bN=[`img[src]`,`source[src]`,`video[src]`,`audio[src]`,`track[src]`,`input[src]`].join(`, `),xN=(e,t)=>{let n=(e,t,n)=>n!==void 0&&e.setAttribute(t,n);for(let r of e.querySelectorAll(bN))n(r,`src`,t(r.getAttribute(`src`)));for(let r of e.querySelectorAll(`video[poster]`))n(r,`poster`,t(r.getAttribute(`poster`)));for(let r of e.querySelectorAll(`img[srcset], source[srcset]`))n(r,`srcset`,_N(r.getAttribute(`srcset`),t));for(let r of e.querySelectorAll(`link[href]`))n(r,`href`,t(r.getAttribute(`href`)));for(let r of e.querySelectorAll(`image[href]`))n(r,`href`,t(r.getAttribute(`href`)));for(let r of e.querySelectorAll(`[style]`))n(r,`style`,vN(r.getAttribute(`style`),t));for(let n of e.querySelectorAll(`style`))n.textContent=vN(n.textContent,t)},SN=e=>new DOMParser().parseFromString(e,`text/html`),CN=(e,t)=>{let n=new Set;return xN(SN(e),e=>{let r=hN(t,e);r&&n.add(r)}),[...n]},wN=(e,t,n,r)=>{let i=SN(e);for(let e of i.querySelectorAll(`[${$M}]`))e.removeAttribute($M);xN(i,e=>{let r=hN(t,e);return r&&n.get(r.uri)});let a=[];for(let e of i.querySelectorAll(`a[href], area[href]`)){let n=e.getAttribute(`href`);if(n.startsWith(`#`))continue;e.removeAttribute(`target`);let i=hN(t,n),o=i?void 0:yN(n);if(!i&&!o){e.removeAttribute(`href`);continue}let s=i?{kind:`file`,file:i}:{kind:`external`,url:o},c=r?.(s);c!==void 0&&e.setAttribute(`href`,c),e.setAttribute($M,String(a.length)),a.push(s)}return{html:`<!doctype html>${i.documentElement.outerHTML}`,links:a}},TN=e=>JSON.stringify(e.map(e=>[e.uri,`key`in e?e.key:null,`field`in e?e.field:null])),EN=(0,j.createContext)(void 0),DN=()=>{let e=(0,j.useContext)(EN);if(e===void 0)throw Error(`useViewedResource must be used inside a file viewer`);return e},ON=class extends Error{status;name=`FileReadError`;constructor(e){super(`The file could not be read: its link answered ${e}`),this.status=e}},kN=e=>{let t=DN(),n=tv(t);return O({queryKey:[`file-text`,t,e.uri],staleTime:1/0,queryFn:async()=>{let r=await fetch(n.fileReadUrl(t,e));if(!r.ok)throw new ON(r.status);return r.text()}})},AN=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),jN=e=>{let t=DN(),n=tv(t),r=ee({queries:e.map(e=>({queryKey:[`file-data-url`,t,e.uri],staleTime:1/0,retry:!1,queryFn:async()=>{let r=await fetch(n.fileReadUrl(t,e));if(!r.ok)throw new ON(r.status);return AN(new Blob([await r.arrayBuffer()],{type:e.type}))}}))}),i=new Map;return r.forEach((t,n)=>t.data!==void 0&&i.set(e[n].uri,t.data)),{contents:i,ready:r.every(e=>!e.isPending)}},MN=(e,t,n)=>{let r=TN(t),{contents:i,ready:a}=jN((0,j.useMemo)(()=>e===void 0?[]:CN(e,t),[e,r])),o=[...i.keys()].join(`
30
+ `);return(0,j.useMemo)(()=>e===void 0||!a?void 0:wN(e,t,i,n),[e,r,a,o,n])},NN=e=>{if(!Rd(e))return[{message:e instanceof Error?e.message:H(`somethingWentWrong`)}];let t=e.errors.map(e=>({message:e.message,hint:e.hint}));return t.length>0?t:[{message:e.message}]},PN=({error:e,title:t,onRetry:n})=>(0,L.jsxs)(`div`,{role:`alert`,className:`flex gap-2.5 rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-danger-text`,children:[(0,L.jsx)(Bl,{className:`mt-0.5 size-4 shrink-0`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:t}),NN(e).map(e=>(0,L.jsxs)(`p`,{className:`text-body`,children:[e.message,e.hint&&(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.hint]})]},e.message))]}),n&&(0,L.jsx)(B,{size:`sm`,onClick:n,children:H(`tryAgain`)})]}),FN=({title:e,description:t,actions:n,className:r,bodyClassName:i,children:a})=>(0,L.jsxs)(`section`,{className:R(`flex min-w-0 flex-col rounded-lg border border-border bg-background`,r),"aria-label":e,children:[(e||t||n)&&(0,L.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2 px-4 pt-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[e&&(0,L.jsx)(`h2`,{className:`text-base font-semibold tracking-tight`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t})]}),n&&(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),(0,L.jsx)(`div`,{className:R(`min-w-0 flex-1 p-4`,i),children:a})]}),IN=({children:e})=>(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:e}),LN=(0,j.createContext)(void 0),RN=({value:e,children:t})=>(0,L.jsx)(LN.Provider,{value:e,children:t}),zN=()=>(0,j.useContext)(LN),BN=({read:e,list:t,empty:n,children:r})=>e.isPending?(0,L.jsx)(Su,{className:`h-4 w-full`}):e.error?(0,L.jsx)(PN,{title:ow(`couldNotLoad`),error:e.error}):t.items.length===0&&n!==void 0?(0,L.jsx)(IN,{children:n}):(0,L.jsxs)(RN,{value:t,children:[r,t.loadMore&&(0,L.jsx)(B,{size:`sm`,onClick:t.loadMore,loading:t.loadingMore,className:`self-start`,children:ow(`loadMore`)})]}),VN=e=>`item`in e,HN=(0,j.createContext)(void 0),UN=(0,j.createContext)([]),WN=({value:e,row:t,children:n})=>{let r=(0,j.useContext)(UN),i=t?.index,a=t?.count,o=(0,j.useMemo)(()=>[...r,i===void 0||a===void 0?e:{...e,row:{index:i,count:a}}],[r,e,i,a]);return(0,L.jsx)(KN,{stack:o,children:n})},GN=({value:e,children:t})=>{let n=(0,j.useMemo)(()=>[{...e,root:!0}],[e]);return(0,L.jsx)(KN,{stack:n,children:t})},KN=({stack:e,children:t})=>{let n=e.at(-1);return(0,L.jsx)(UN.Provider,{value:e,children:(0,L.jsx)(HN.Provider,{value:VN(n)?void 0:n,children:(0,L.jsx)(RN,{value:void 0,children:t})})})},qN=()=>(0,j.useContext)(HN),JN=()=>(0,j.useContext)(UN),YN=e=>{let t=e[0];return t?.root&&!VN(t)?t.record:void 0},XN=e=>{let t=YN(e);return{stack:(t?e.slice(1):e).map(e=>({record:VN(e)?e.item:e.record,...e.row&&{row:e.row}})),...t&&{root:t}}},ZN=e=>typeof e==`object`&&!!e,QN=(e,t)=>t.reduce((e,t)=>ZN(e)&&Object.hasOwn(e,t)?e[t]:void 0,e),$N=(e,t)=>{let n=Rt(t);if(!n)return;let r=e=>{if(e)return VN(e)?{item:QN(e.item,n.names)}:n.names.length===0?void 0:{frame:e,path:n.names.join(`.`)}};if(n.kind===`data`)return n.variable===`root`&&e[0]?.root?r(e[0]):void 0;if(n.explicit)return r(e[e.length-1-n.up]);let i=n.names[0];return r(e.findLast(e=>VN(e)?ZN(e.item)&&Object.hasOwn(e.item,i):Object.hasOwn(e.model.fields,i))??e.at(-1))},eP=(0,j.createContext)(null),tP={},nP=(e,t={})=>{let n=Object.fromEntries(Object.entries({...e.given,...t}).filter(e=>e[1]!==void 0&&e[1]!==``));return{kind:`page`,page:e.page,...e.tab&&{tab:e.tab},...Object.keys(n).length>0&&{params:n}}},rP=({page:e,tab:t,tree:n,given:r=tP,children:i})=>{let a=(0,j.useMemo)(()=>im(n,r),[n,r]),o=(0,j.useMemo)(()=>({page:e,...t&&{tab:t},given:r,values:a}),[e,t,r,a]);return(0,L.jsx)(eP.Provider,{value:o,children:i})},iP=()=>(0,j.useContext)(eP)?.values??tP,aP=()=>(0,j.useContext)(eP)?.given??tP,oP=()=>{let e=sP();if(!e)throw Error(`A SelectInput and a select render inside a composed page, whose address holds their values`);return e},sP=()=>{let e=(0,j.useContext)(eP),{go:t,href:n}=Tj();return e?{values:e.values,given:e.given,linkTo:r=>{let i=nP(e,r);return{href:n(i),onFollow:()=>t(i,{keepScroll:!0})}}}:void 0},cP=async(e,t,n={})=>{let r=t.filter||void 0,i=t.etag?{}:{etag:!1};if(t.kind===`aggregate`)return{rows:(await e.aggregate(t.resource,{groupBy:t.groupBy[0],filter:r,...t.pageSize!==void 0&&{limit:t.pageSize}})).groups.map(({value:e,count:t})=>({value:e,count:t}))};if(t.kind===`count`){let n=await e.list(t.resource,{filter:r,pageSize:1,count:`exact`,fields:t.fields,...i});return{rows:[],total:n.totalSize??n.totalSizeEstimate}}let a=await e.list(t.resource,{filter:r,orderBy:t.orderBy,pageSize:t.pageSize,fields:t.fields,limitPer:t.limitPer,...n,...i});return{rows:a.items,...a.labels&&{labels:a.labels},...a.photos&&{photos:a.photos}}},lP=jt(),uP=async(e,t,n,r,i)=>{let a=n.primaryKey[0],o=[...new Set(r)].sort();if(o.length===0||n.primaryKey.length!==1)return new Map;let s=Kr(n,i),c=await e.fetchQuery({queryKey:I.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:bt(lP.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},dP=(e,t,n)=>n.flatMap(n=>{let r=t.fields[n],i=r?.type===`relation`&&r.relation?e[r.relation.resource]:void 0;return i?[{name:n,target:i}]:[]}),fP=(e,t,n,r)=>Object.fromEntries(dP(e,n,r).filter(({target:e})=>e.primaryKey.length===1&&!t[e.name]?.titleFrom).map(({name:e,target:n})=>[e,Kr(n,t[n.name])])),pP=(e,t,n,r,i={})=>{let a=dP(e,t,n);return r.map(e=>{let t={...e};for(let{name:n}of a)e[n]!=null&&(t[n]={id:e[n],name:i[n]?.[String(e[n])]??String(e[n])});return t})},mP=jt(),hP=(e,t)=>{let n=t?.titleFrom;if(n&&!n.unreadable&&e.primaryKey.length===1)return n.fields},gP=(e,t,n)=>I.titleRow(e.name,t,n.join(`,`)),_P=async(e,t,n,r)=>{let i=t.primaryKey[0],a=[...new Set(r)];if(a.length===0)return new Map;let o=await e.list(t.name,{filter:bt(mP.in(i,a)),fields:[i,...n],pageSize:a.length});return new Map(o.items.map(e=>[String(e[i]),e]))},vP=async(e,t,n,r,i,a,o)=>{let s=new Map;for(let e of a){let t=i.fields[e],a=t?.type===`relation`&&t.relation?n[t.relation.resource]:void 0;if(!a||!hP(a,r[a.name]))continue;let c=o.flatMap(t=>t[e]==null?[]:[String(t[e])]);s.set(a.name,[...s.get(a.name)??[],...c])}await Promise.all([...s].map(async([i,a])=>{let o=n[i],s=hP(o,r[i]),c=await _P(t,o,s,a);for(let t of new Set(a))e.setQueryData(gP(o,t,s),{row:c.get(t)??null})}))},yP=({label:e,className:t})=>(0,L.jsx)(`span`,{role:e===void 0?void 0:`img`,"aria-label":e,title:e,className:R(`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,t),children:(0,L.jsx)(Xo,{className:`size-3`,strokeWidth:3})}),bP=(e,t,n)=>{if(!URL.canParse(e,t))return`no-referrer`;let r=new URL(e,t);if((r.protocol===`http:`||r.protocol===`https:`)&&!(r.origin===new URL(t).origin||n.includes(r.hostname)))return`no-referrer`},xP=e=>URL.canParse(e)?[new URL(e).hostname]:[],SP=()=>{let e=(0,j.useContext)(ov);return(0,j.useMemo)(()=>[...e?.files?.trustedHosts??[],...(e?.sources??[]).flatMap(({source:e})=>xP(e.url))],[e?.files,e?.sources])},CP=e=>{let t;try{t=atob(e)}catch(e){if(e instanceof DOMException&&e.name===`InvalidCharacterError`)return;throw e}return te(Uint8Array.from(t,e=>e.charCodeAt(0)))},wP=({image:e,alt:t=``,className:n,loading:r})=>{let[i,a]=(0,j.useState)(),o=SP(),s=(0,j.useMemo)(()=>e.placeholder===void 0?void 0:CP(e.placeholder),[e.placeholder]),c=s!==void 0&&i!==e.url;return(0,L.jsx)(`img`,{src:e.url,alt:t,loading:r,decoding:`async`,referrerPolicy:bP(e.url,window.location.href,o),onLoad:()=>a(e.url),className:n,style:c?{backgroundImage:`url("${s}")`,backgroundSize:`cover`,backgroundPosition:`center`}:void 0})},TP=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},EP=({text:e,className:t})=>(0,L.jsx)(`span`,{className:R(`truncate`,t),onMouseEnter:TP(e),children:e}),DP=e=>e.stopPropagation(),OP=({format:e,value:t,label:n,className:r})=>{let i=gA(e,t);return i?(0,L.jsx)(`a`,{href:i,...e===`url`?{target:`_blank`,rel:`noreferrer`}:{},onClick:DP,className:R(`font-medium text-primary-text hover:underline`,r),children:n??t}):(0,L.jsx)(`span`,{className:r,children:t})},kP=e=>(0,L.jsx)(`span`,{className:`text-faint-foreground`,children:e}),AP=(e,t,n)=>{if(t==null)return kP(`—`);let r=Gk(e,t)??``;switch(e.kind){case`text`:return e.link?(0,L.jsx)(OP,{format:e.link,value:r,label:n&&e.linkText?.(n),className:`block min-w-0 truncate`}):(0,L.jsx)(EP,{text:r});case`id`:return(0,L.jsx)(EP,{text:r,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`date`:return(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r});case`datetime`:return(0,L.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?QE(Number(t)):Uk(`shownIn`,{zone:VE(Number(t),ME())}),children:r});case`number`:return(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`signed`:return(0,L.jsx)(`span`,{className:R(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:r});case`percent`:return Number(t)===0?kP(`—`):(0,L.jsx)(`span`,{className:`tabular-nums`,children:r});case`status`:return(0,L.jsx)(fy,{tone:e.tones?.[String(t)]??`neutral`,color:yA(e.colors,t),shape:e.shape,children:r});case`relation`:return(0,L.jsx)(EP,{text:r,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,L.jsx)(yP,{}):kP(Uk(`no`));case`file`:{let e=jk(t);if(!e)return kP(`—`);if(`missing`in e)return(0,L.jsx)(EP,{text:e.name,className:`text-danger-text`});let n=zk(t,{width:20,height:20});return(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,L.jsx)(wP,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,L.jsx)(Rc,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(EP,{text:e.name})]})}case`user`:{let n=e.users?.(String(t));return n?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,L.jsx)(Cb,{initials:n.initials,hue:n.hue,size:`xs`,className:`ring-0`}),(0,L.jsx)(EP,{text:n.name,className:`text-muted-foreground`})]}):(0,L.jsx)(EP,{text:r,className:`text-muted-foreground`})}}},jP=e=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`},MP=({invalid:e,className:t,rows:n=3,value:r,ref:i,...a})=>{let o=(0,j.useRef)(null),s=(0,j.useCallback)(e=>{o.current=e,typeof i==`function`?i(e):i&&(i.current=e)},[i]),c=Vb();return(0,j.useLayoutEffect)(()=>{o.current&&jP(o.current)},[r]),(0,j.useEffect)(()=>{let e=o.current;if(!e)return;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,jP(e))});return n.observe(e),()=>n.disconnect()},[]),(0,L.jsx)(`textarea`,{ref:s,rows:n,value:r,className:R(`block w-full resize-none overflow-hidden rounded-md border bg-background px-2.5 py-1.5 text-body text-foreground shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,e?`border-danger`:`border-border-strong`,t),...c,...e&&{"aria-invalid":!0},...a})},NP=({children:e})=>(0,L.jsx)(`pre`,{className:`whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md bg-muted/60 px-3 py-2 font-mono text-xs text-foreground`,children:e}),PP=e=>{let t=e.split(`
31
+ `);return t.length<=20?{lines:t.length,folded:null}:{lines:t.length,folded:t.slice(0,20).join(`
32
+ `)}},FP=F(`app/field-types/json`),IP=({value:e})=>{let[t,n]=(0,j.useState)(!1),r=JSON.stringify(e,null,2),{lines:i,folded:a}=PP(r);return a===null?(0,L.jsx)(NP,{children:r}):(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(NP,{children:t?r:a}),(0,L.jsx)(B,{size:`sm`,variant:`ghost`,className:`-ml-2 justify-self-start`,"aria-expanded":t,onClick:()=>n(!t),children:t?FP(`showLess`):FP(`showAll`,{count:i})})]})},LP=Symbol(`not JSON`),RP=e=>{if(e.trim()===``)return null;try{return JSON.parse(e)}catch(e){if(!(e instanceof SyntaxError))throw e;return LP}},zP=({value:e})=>e===null?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,L.jsx)(IP,{value:e}),BP=({value:e})=>(0,L.jsx)(EP,{text:DA(e)}),VP=({value:e,onChange:t,invalid:n})=>{let[r,i]=(0,j.useState)(),a=r??(e===null?``:JSON.stringify(e,null,2)),o=r!==void 0&&RP(r)===LP;return(0,L.jsxs)(`div`,{className:`grid gap-1`,children:[(0,L.jsx)(MP,{value:a,rows:3,invalid:n||o,className:`font-mono text-xs`,onChange:e=>{i(e.target.value);let n=RP(e.target.value);n!==LP&&t(n)}}),o&&(0,L.jsx)(`p`,{className:`text-xs text-danger-text`,children:FP(`notJson`)})]})},HP={of:[...Si.json],display:zP,editor:VP,cell:BP,wide:!0},UP=({editor:e,cell:t,...n},r)=>{let i=(e,t)=>wO(()=>r().then(t=>e(t)??(()=>null)),()=>(0,L.jsx)(Su,{className:t})),a=n.wide?`h-24 w-full`:`h-4 w-24`;return{...n,display:i(e=>e.display,a),...e&&{editor:i(e=>e.editor,a)},...t&&{cell:i(e=>e.cell,`h-3 w-16`)}}},WP=F(`app/field-types/members`),GP=({id:e,name:t})=>(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(Cb,{initials:t&&Eb(t)||`?`,hue:Tb(e),size:`xs`,className:`ring-0`}),(0,L.jsx)(`span`,{className:t===void 0?`truncate text-muted-foreground`:`truncate`,children:t??WP(`unknownMember`)})]}),KP=jt(),qP=e=>e.split(/\s+/).filter(Boolean),JP=(e,t,n,r=!1)=>{let i=qP(n);if(i.length===0)return{filter:void 0,local:!1};if(r)return{filter:void 0,local:!0};if(e.search?.length)return{filter:bt(KP.search(n)),local:!1};let a=e.fields[t];if(a?.type!==`text`||!a.filterable)return{filter:void 0,local:!0};let o=i.map(e=>KP.eq(t,`*${e.replaceAll(`*`,``)}*`));return{filter:bt(KP.and(...o)),local:!1}},YP=(e,t)=>{if(e==null)return!1;let n=String(e).toLowerCase();return qP(t).every(e=>n.includes(e.toLowerCase()))},XP=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],ZP=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],QP=(e,t)=>e.filter(e=>YP(e.name,t)).map(e=>({key:e.id,label:e.name})),$P=()=>{let e=T_(),t=BD();return{...t,needsOrganizations:!e?.organizations,failed:t.isError}},eF=({value:e,line:t})=>{let n=$P(),r=XP(e);return r.length===0?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):n.needsOrganizations?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:WP(`needsOrganizations`)}):n.failed?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:WP(`couldNotLoadMembers`)}):n.isLoading?(0,L.jsx)(Su,{className:`h-4 w-24`}):(0,L.jsx)(`span`,{className:R(`flex min-w-0 items-center gap-x-3 gap-y-1`,t?`overflow-hidden`:`flex-wrap`),children:r.map(e=>(0,L.jsx)(GP,{id:e,name:n.member(e)?.name},e))})},tF=e=>(0,L.jsx)(eF,{...e,line:!1}),nF=e=>(0,L.jsx)(eF,{...e,line:!0}),rF=({label:e,onRemove:t})=>(0,L.jsxs)(`span`,{className:`inline-flex h-5 max-w-full items-center gap-0.5 rounded bg-primary-soft pl-1.5 pr-0.5 text-xs font-medium text-primary-text`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:e}),(0,L.jsx)(`button`,{type:`button`,"aria-label":du(`remove`,{label:e}),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,L.jsx)(uu,{className:`size-3`})})]}),iF=()=>{let[e,t]=(0,j.useState)(``),[n,r]=(0,j.useState)(!1);return{text:e,setText:t,open:n,setOpen:r}},aF=(e,t,n,r)=>{(0,j.useEffect)(()=>{if(!e||!t||!r)return;let n=new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&r(),{root:e});return n.observe(t),()=>n.disconnect()},[e,t,n,r])},oF=({search:e,options:t,chosen:n,several:r,closedText:i,placeholder:a,invalid:o,paging:s,loading:c,failed:l,onChoose:u})=>{let{text:d,setText:f,open:p,setOpen:m}=e,[h,g]=(0,j.useState)(-1),[_,v]=(0,j.useState)(null),[y,b]=(0,j.useState)(null),x=(0,j.useId)(),S=s?.more??!1;aF(_,y,s?.loaded??0,s?.loadMore);let C=e=>`${x}-${e}`,w=(0,j.useRef)(null);(0,j.useEffect)(()=>{!p&&document.activeElement===w.current&&w.current?.select()},[p]),(0,j.useEffect)(()=>{p&&h>=0&&document.getElementById(C(h))?.scrollIntoView({block:`nearest`})});let T=()=>{f(``),g(-1),m(!1)},E=e=>{if(u(e),!r)return T();f(``),g(-1)};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Hb,{ref:w,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":p,"aria-controls":x,"aria-activedescendant":p&&t[h]?C(h):void 0,invalid:o,placeholder:a,value:p?d:i,onFocus:()=>m(!0),onBlur:T,onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!p)return m(!0);let n=e.key===`ArrowDown`?1:-1;g(e=>Math.min(Math.max(e+n,0),t.length-1));return}if(e.key===`Enter`&&p&&t[h]){e.preventDefault(),E(t[h]);return}e.key===`Escape`&&p&&(e.preventDefault(),e.stopPropagation(),T())},onChange:e=>{f(e.target.value),g(e.target.value.trim()?0:-1),m(!0)}}),p&&(0,L.jsxs)(`ul`,{ref:v,id:x,role:`listbox`,"aria-multiselectable":r||void 0,className:`absolute z-30 mt-1 max-h-60 w-full overflow-y-auto rounded-md border bg-background py-1 shadow-pop`,onMouseDown:e=>e.preventDefault(),children:[t.map((e,t)=>(0,L.jsx)(`li`,{id:C(t),role:`option`,"aria-selected":t===h,className:R(`cursor-pointer truncate px-3 py-1.5`,t===h&&`bg-muted`,n.includes(e.key)&&`font-medium`),onMouseMove:()=>t!==h&&g(t),onClick:()=>E(e),children:e.label},e.key)),S&&(0,L.jsx)(`li`,{ref:b,"aria-hidden":!0,className:`h-px`}),l&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`couldNotLoadOptions`)}),!S&&!c&&!l&&t.length===0&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`noMatches`)}),c&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:H(`loading`)})]})]})},sF=({value:e,invalid:t,onChange:n})=>{let r=iF(),i=$P(),a=XP(e);if(i.needsOrganizations)return(0,L.jsx)(`p`,{className:`py-1.5 text-muted-foreground`,children:WP(`needsOrganizations`)});let o=e=>i.member(e)?.name??WP(`unknownMember`);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(oF,{search:r,options:QP(i.data??[],r.text),chosen:a,several:!0,closedText:``,placeholder:WP(`searchMembers`),invalid:t,loading:i.isLoading,failed:i.failed,onChoose:e=>n(ZP(a,e.key))}),a.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>(0,L.jsx)(rF,{label:o(e),onRemove:()=>n(a.filter(t=>t!==e))},e))})]})},cF={json:HP,members:{of:[...Si.members],display:tF,editor:sF,cell:nF},workflow:UP({of:[...Si.workflow],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./workflow-field-CpGs8ZXh.js`).then(e=>e.workflowField),__vite__mapDeps([56,1,6,7,57,58,59,60,61,62,63,64,65]))),workflow_run:UP({of:[...Si.workflow_run],wide:!0,editor:!1,cell:!0},()=>s(()=>import(`./workflow-run-field-R43RqM3Z.js`).then(e=>e.workflowRunField),__vite__mapDeps([66,1,6,7]))),workflow_status:UP({of:[...Si.workflow_status],editor:!1,cell:!0},()=>s(()=>import(`./workflow-status-field-BaytFzWg.js`).then(e=>e.workflowStatusField),__vite__mapDeps([67,1,6,10,7,68,8,65,57,58,59,60,61,62,63]))),custom_step_container:UP({of:[...Si.custom_step_container],wide:!0,editor:!0,cell:!0},()=>s(()=>import(`./custom-step-container-field-C5l4j0FI.js`).then(e=>e.customStepContainerField),__vite__mapDeps([69,1,6]))),runner_install:UP({of:[...Si.runner_install],editor:!1,cell:!0},()=>s(()=>import(`./runner-install-field-wpoIgnks.js`).then(e=>e.runnerInstallField),__vite__mapDeps([70,1,6,35])))},lF=(e,t)=>{if(e&&Object.hasOwn(e,t))return e[t];if(Object.hasOwn(cF,t))return cF[t]},uF=(e,t,n)=>{let r=n?.widget;if(!r||t.sensitive)return;let i=lF(e,r.name);return i?.of.includes(t.type)?{name:r.name,widget:i,props:r.props??{}}:void 0},dF=(e,t)=>uF(jT().fields,e,t),fF=(e,t,n)=>{let r=uF(e,t,n);return!!(n?.multiline||n?.markdown||(r?r.widget.wide:t.type===`json`))},pF=F(`app/field-types`),mF=({shown:e,part:t,field:n,value:r,onChange:i,invalid:a=!1})=>{let{widget:o,props:s}=e,c={field:n,value:r??null,props:s};if(t!==`editor`){let e=t===`cell`?o.cell??o.display:o.display;return(0,L.jsx)(e,{...c})}let l=o.editor;return l&&i?(0,L.jsx)(l,{...c,onChange:i,invalid:a}):void 0},hF=({fallback:e,...t})=>{let n=mF(t);return n?(0,L.jsx)(sw,{name:pF(`fieldType`,{name:t.shown.name}),fallback:e,children:n}):e},gF=(e,t)=>e.type===`relation`&&typeof t==`object`&&t&&`id`in t?t.id:t,_F=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&uF(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,L.jsx)(hF,{shown:a,part:`cell`,field:i,value:gF(i,t[e.id]),fallback:AP(e,e.value?e.value(t):t[e.id],t)})}:e}),vF=(e,t,n,r,i)=>{let a=r?.titleFrom;return a?{queryKey:gP(n,i,a.fields),queryFn:async()=>({row:(await _P(t,n,a.fields,[i])).get(i)??null})}:{queryKey:I.relatedLabel(n.name,i),queryFn:async()=>({label:(await uP(e,t,n,[i],r)).get(i)??i})}},yF=(e,t,n,r,i)=>{if(e)return`label`in e?e.label:e.row?t(n,r,e.row,i):i},bF=(e,t,n=!0)=>{let{views:r}=Vv(),i=X(),a=x(),o=qD(),s=r[e.name];return yF(O({...vF(a,i,e,s,t),staleTime:3e5,enabled:n}).data,o,e,s,t)},xF=e=>String(typeof e==`object`&&e&&`id`in e?e.id:e),SF=({target:e,id:t})=>(0,L.jsx)(EP,{text:bF(e,t)??t,className:`font-medium text-primary-text hover:underline`}),CF=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i?.type===`relation`&&i.relation?n[i.relation.resource]:void 0;return e.render||!a||!r[a.name]?.titleFrom?e:{...e,render:t=>t[e.id]==null?AP(e,null):(0,L.jsx)(SF,{target:a,id:xF(t[e.id])})}}),wF=({value:e,hints:t,children:n})=>(0,L.jsx)(fy,{tone:bA(t?.valueColors,e),color:yA(t?.valueColors,e),shape:t?.badgeShape,children:n}),TF=(0,j.lazy)(()=>s(()=>import(`./markdown-content-jO-R6jpp.js`).then(e=>({default:e.MarkdownContent})),__vite__mapDeps([71,1,6,72,73,74]))),EF=e=>(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(`div`,{className:R(`whitespace-pre-line break-words`,e.className),children:e.source}),children:(0,L.jsx)(TF,{...e})}),DF=F(`app/file-viewers`),OF=({name:e})=>(0,L.jsxs)(`div`,{className:`space-y-3 px-4 py-6 md:px-10`,"aria-busy":`true`,children:[(0,L.jsx)(`span`,{role:`status`,className:`sr-only`,children:DF(`loading`,{name:e})}),(0,L.jsx)(Su,{className:`h-6 w-2/3`}),(0,L.jsx)(Su,{className:`h-40`})]}),kF=(0,j.lazy)(()=>s(()=>import(`./html-viewer-BtwOBvDg.js`).then(e=>({default:e.HtmlViewer})),__vite__mapDeps([75,1,6]))),AF={"text/html":{component:e=>(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(OF,{name:e.file.name}),children:(0,L.jsx)(kF,{...e})})}},jF=(e,t)=>YM(e.fileViewers,t)??YM(AF,t),MF=({file:e,className:t})=>(0,L.jsxs)(`a`,{href:e.url,download:e.name,className:R(hu({size:`sm`}),`gap-1.5`,t),children:[(0,L.jsx)(ws,{className:`size-4`,"aria-hidden":`true`}),DF(`download`)]}),NF=(e,t)=>Object.values(e.fields).filter(n=>n.type===`relation`&&n.filterable&&n.name!==e.tenant&&t[n.name]!=null),PF=e=>typeof e==`object`&&e&&`id`in e?e.id:e,FF=(e,t)=>{let n=NF(e,t);if(n.length!==0)return n.map(e=>`${e.name} = ${JSON.stringify(PF(t[e.name]))}`).join(` AND `)},IF=(e,t,n)=>{let r=Object.values(e.fields).filter(e=>e.type===`file`),i=new Map;for(let a of t)for(let t of r){let r=JM(a[t.name]);r&&r.uri!==n.uri&&!i.has(r.uri)&&i.set(r.uri,{...r,key:sE(e,a),field:t.name})}return[...i.values()]},LF=100,RF=(e,t)=>t.type===`file`?[t.name,...[t.file?.typeField,t.file?.sizeField].filter(t=>t!==void 0&&Object.hasOwn(e.fields,t))]:[],zF=(e,t,n)=>{let r=FF(e,t),i=[...e.primaryKey,...Object.values(e.fields).flatMap(t=>RF(e,t))],a=PM(e.name,{filter:r,pageSize:LF,fields:i,enabled:r!==void 0});return{siblings:IF(e,r===void 0?[t]:[t,...a.items],n),ready:r===void 0||!a.isPending}},BF=(e,t,n,r)=>{if(t.fields[r]?.type!==`file`)return;let i=JM(n[r]);if(!i)return;let a=jF(e,i.type);return a?{field:r,file:i,viewer:a}:{field:r,file:i}},VF=({model:e,record:t,viewed:n,back:r})=>{let{file:i,viewer:a}=n;return(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 md:px-10`,children:[(0,L.jsxs)(Ej,{to:r,className:R(hu({variant:`ghost`,size:`sm`}),`gap-1.5`),children:[(0,L.jsx)(So,{className:`size-4`,"aria-hidden":`true`}),DF(`backToRecord`)]}),(0,L.jsxs)(`h1`,{className:`min-w-0 flex-1 truncate font-medium`,title:i.name,children:[i.name,i.size!==void 0&&(0,L.jsx)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:Nk(i.size)})]}),(0,L.jsx)(MF,{file:i})]}),(0,L.jsx)(`div`,{className:`flex-1`,children:a?(0,L.jsx)(HF,{model:e,record:t,file:i,viewer:a}):(0,L.jsx)(UF,{file:i})})]})},HF=({model:e,record:t,file:n,viewer:r})=>{let{siblings:i,ready:a}=zF(e,t,n);if(!a)return(0,L.jsx)(OF,{name:n.name});let o=r.component;return(0,L.jsx)(EN.Provider,{value:e.name,children:(0,L.jsx)(sw,{name:n.type,fallback:(0,L.jsx)(WF,{file:n}),children:(0,L.jsx)(o,{file:n,siblings:i})})})},UF=({file:e})=>(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`status`,children:[(0,L.jsx)(`p`,{children:DF(`noPreview`,{name:e.name})}),(0,L.jsx)(MF,{file:e})]}),WF=({file:e})=>(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-4 py-6 md:px-10`,role:`alert`,children:[(0,L.jsx)(`p`,{children:DF(`couldNotShow`,{name:e.name})}),(0,L.jsx)(MF,{file:e})]}),GF=({field:e,model:t,record:n,name:r,url:i,className:a})=>{let o=jT(),s=e&&t&&n&&t.primaryKey.every(e=>n[e]!=null)?BF(o,t,n,e):void 0;return s?.viewer&&t&&n?(0,L.jsx)(Ej,{to:{kind:`record`,resource:t.name,key:sE(t,n),file:s.field},className:a,children:r}):(0,L.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:a,children:r})},KF=({invalid:e,className:t,children:n,...r})=>{let i=Vb();return(0,L.jsx)(`select`,{...i,...e&&{"aria-invalid":!0},className:R(`h-8 w-full min-w-0 rounded-md border bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,e?`border-danger`:`border-border-strong`,t),...r,children:n})},qF=F(`mailbox`),JF=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase(),YF=({address:e,senders:t})=>[...e&&!t.some(t=>JF(t.address,e))?[{address:e}]:[],...t.map(e=>({address:e.address,...e.name&&{name:e.name}}))],XF=({address:e,name:t})=>t?`${t} <${e}>`:e,ZF=3e4,QF,$F=new Set,eI=({owner:e,mailSenders:t})=>{if(QF&&QF.owner===e&&Date.now()-QF.at<ZF)return QF.read;let n=t().then(YF);return QF={owner:e,at:Date.now(),read:n},n.then(void 0,()=>{QF?.read===n&&(QF=void 0)}),n},tI=e=>($F.add(e),()=>void $F.delete(e)),nI=()=>{QF=void 0;for(let e of $F)e()},rI=()=>{let e=T_(),t=e&&e.personalMail.length>0&&e.state.kind===`signed-in`?e.state.user.id:void 0,n=e?.session.account,[r,i]=(0,j.useState)(0),a=(0,j.useCallback)(()=>i(e=>e+1),[]);(0,j.useEffect)(()=>tI(a),[a]);let[o,s]=(0,j.useState)({});return(0,j.useEffect)(()=>{if(t===void 0||!n)return;let e=!0;return eI({owner:t,mailSenders:n.mailSenders}).then(n=>{e&&s({owner:t,reads:r,options:n})},n=>{if(!(n instanceof K)&&!(n instanceof Rh))throw n;let i=n instanceof K?Qv(n):qF(`sendersNotRead`);e&&s({owner:t,reads:r,error:i,retry:a})}),()=>{e=!1}},[t,n,r,a]),t===void 0?{options:[]}:o.owner===t&&(o.reads===r||o.options)?o:{}},iI=e=>(0,L.jsx)(aI,{...e,...rI()}),aI=({field:e,value:t,invalid:n,onChange:r,options:i,error:a,retry:o})=>{let s=String(t??``),c=i?.find(e=>s!==``&&JF(e.address,s)),l=s!==``&&i!==void 0&&!c;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(KF,{invalid:n,disabled:i===void 0&&!a,value:c?.address??s,onChange:e=>r(e.target.value),children:[(e.nullable||s===``)&&(0,L.jsx)(`option`,{value:``,children:qF(e.nullable?`defaultSender`:`chooseSender`)}),s!==``&&!c&&(0,L.jsx)(`option`,{value:s,children:l?qF(`senderNotAvailable`,{address:s}):s}),(i??[]).map(e=>(0,L.jsx)(`option`,{value:e.address,children:XF(e)},e.address))]}),l&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:qF.rich(`senderNotYours`,{account:(0,L.jsx)(Zu,{to:`/-/account`,className:`font-medium text-primary-text hover:underline`,children:qF(`accountPage`)})})}),a&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}),o&&(0,L.jsx)(B,{size:`sm`,onClick:o,children:qF(`tryAgain`)})]})]})},oI=({value:e})=>{let{options:t}=rI(),n=t?.find(t=>JF(t.address,e));return(0,L.jsx)(`span`,{className:`break-words`,children:n?XF(n):e})},sI=({target:e,id:t,known:n})=>{let r=bF(e,t,n===void 0);return(0,L.jsx)(Ej,{to:{kind:`record`,resource:e.name,key:t},className:`font-medium text-primary-text hover:underline`,children:n??r??t})},cI=({field:e,value:t,known:n})=>{let{resources:r}=Vv(),i=e.relation?r[e.relation.resource]:void 0;return i?(0,L.jsx)(sI,{target:i,id:String(t),known:n}):(0,L.jsx)(`span`,{children:String(t)})},lI=()=>(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,L.jsx)(`span`,{className:`sr-only`,children:H(`noValue`)})]}),uI=({field:e,value:t,hints:n,relationLabel:r,linkText:i,model:a,record:o})=>{if(t==null||t===``)return(0,L.jsx)(lI,{});if(e.type===`relation`)return(0,L.jsx)(cI,{field:e,value:t,known:r});let s=e.type===`file`?jk(t):void 0;if(s&&`url`in s&&s.url){let n=zk(t,{width:40,height:40});return(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n&&(0,L.jsx)(wP,{image:n,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,L.jsx)(GF,{field:e.name,model:a,record:o,name:s.name,url:s.url,className:`truncate font-medium text-primary-text hover:underline`})]})}if(pA(e,n))return(0,L.jsx)(EF,{source:String(t)});if(e.type===`json`)return(0,L.jsx)(IP,{value:t});if(e.type===`mail_sender`)return(0,L.jsx)(oI,{value:String(t)});let c=kA(e,t,n),l=e.type===`text`?hA(n):void 0;return l?(0,L.jsx)(OP,{format:l,value:c,label:i}):e.type===`enum`||n.format===`badge`?(0,L.jsx)(wF,{value:t,hints:n,children:c}):e.type===`timestamp`||e.type===`date`?(0,L.jsx)(`time`,{dateTime:String(t),title:AA(e,t,void 0,n),children:c}):(0,L.jsx)(`span`,{title:AA(e,t,void 0,n),className:R(n.format===`code`&&`font-mono text-xs`,(e.type===`decimal`||e.type===`integer`)&&`tabular-nums`,n.multiline&&`whitespace-pre-line break-words`),children:c})},dI=({model:e,field:t,value:n,format:r,relationLabel:i,record:a,relationLabels:o})=>{let{views:s}=Vv(),c={...s[e.name]?.fields[t.name],...r&&{format:r}},l=a&&c.format===`url`?NA(e,s[e.name],t.name,a,o):void 0;return(0,L.jsx)(uI,{field:t,value:n,hints:c,relationLabel:i,linkText:l,model:e,record:a})},fI=e=>{let{views:t}=Vv(),n=dF(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,L.jsx)(dI,{...e});return n?(0,L.jsx)(hF,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},pI=(e,t)=>({model:e,record:t,key:nr(sE(e,t)),etag:typeof t.etag==`string`?t.etag:void 0,permissions:t.permissions}),mI=(e,t,n=``)=>({queryKey:I.count(t.name,n),queryFn:async()=>{let r=await e.list(t.name,{filter:n||void 0,pageSize:1,count:`exact`,fields:t.primaryKey});return r.totalSize??r.totalSizeEstimate}}),hI=(e,t=``,n=!0)=>O({...mI(X(),e,t),enabled:n}),gI=(e,t,{filter:n=``,sort:r=``,key:i})=>({queryKey:i===void 0?I.firstRecord(t.name,n,r):I.record(t.name,i),queryFn:async()=>{if(i!==void 0){let n=await e.get(t.name,i);return{...pI(t,n.record),etag:n.etag,permissions:n.permissions}}let a=await e.list(t.name,{filter:n||void 0,orderBy:r||void 0,pageSize:1});return a.items[0]?pI(t,a.items[0]):null}}),_I=(e,{enabled:t=!0,...n})=>O({...gI(X(),e,n),enabled:t}),vI=(e,t,{filter:n=``,sort:r=``,pageSize:i,pageToken:a=``})=>({queryKey:I.list(t.name,n,r,i,a),queryFn:()=>e.list(t.name,{filter:n||void 0,orderBy:r||void 0,pageSize:i,pageToken:a||void 0})}),yI=(e,{enabled:t=!0,...n})=>O({...vI(X(),e,n),enabled:t,placeholderData:y}),bI=(e,t)=>({isPending:t.isPending,error:t.error,data:t.rows[0]?{...pI(e,t.rows[0]),planned:!0}:t.isPending?void 0:null}),xI=()=>{let e=x();return(0,j.useCallback)(t=>e.invalidateQueries({predicate:e=>Ji(e.queryKey,new Set([t]))}),[e])},SI=(e,t,n)=>{if(!t)return[];let r=Em(e,t.model.name,n);return r.ok?r.steps:[]},CI=(e,t,n,r,i)=>({queryKey:I.pathValue(n?.model.name??``,n?.key??``,r),enabled:i.length>1,queryFn:async()=>{let r=n.record;for(let n of i.slice(0,-1)){let i=r[n.field.name];if(i==null)return null;let a=n.field.relation.resource;r=(await t.fetchQuery({queryKey:I.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),wI=(e,t,n)=>{let r=t.at(-1);return!e||!r?{state:`missing`}:t.length===1?{state:`ready`,value:e.record[r.field.name],field:r.field,model:r.model}:n.isPending?{state:`loading`}:{state:`ready`,value:n.data??null,field:r.field,model:r.model}},TI=(e,t)=>{let{resources:n}=Vv(),r=SI(n,e,t);return wI(e,r,O(CI(X(),x(),e,t,r)))},EI=e=>{let t=$N(JN(),e),n=TI(t&&`frame`in t?t.frame:void 0,t&&`path`in t?t.path:e);return t&&`item`in t?{state:`plain`,value:t.item}:n},DI=e=>{let{resources:t}=Vv(),n=X(),r=x(),i=e.map(({scope:e,path:n})=>SI(t,e,n)),a=ee({queries:e.map(({scope:e,path:t},a)=>CI(n,r,e,t,i[a]))});return e.map(({scope:e},t)=>wI(e,i[t],a[t]))},OI=e=>e.includes(`.`),kI=({model:e,row:t,column:n})=>{let r=TI(pI(e,bj(e,t).record),n);return r.state===`loading`?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,L.jsx)(fI,{model:r.model,field:r.field,value:r.value})},AI=(e,t,{resources:n,views:r})=>{let i=Em(n,e.name,t),a=i.ok?i.steps.at(-1):void 0,o=a?.field.name??t;return{id:t,header:r[a?.model.name??e.name]?.fields[o]?.label??P(o),kind:`text`,width:200,render:n=>(0,L.jsx)(kI,{model:e,row:n,column:t})}},jI=(e,t,n,r)=>{let i=new Map(CF(_F(RA(e,t,[],n.filter(e=>!OI(e))),e,t,r.fieldTypes),e,r.resources,r.views).map(e=>[e.id,e]));return n.flatMap(t=>OI(t)?[AI(e,t,r)]:i.get(t)??[])},MI=(e,t,{shown:n,opens:r,bulk:i})=>{if(i)return;let a=[...e.primaryKey,...n.map(e=>e.split(`.`)[0]),...r?[r]:[],qr(e,t),...UD(e,t)];return[...new Set(a)].filter(t=>Object.hasOwn(e.fields,t))},NI=({model:e,view:t,resources:n,views:r,fieldTypes:i,columns:a,button:o,opens:s,bulk:c,phoneColumns:l,xs:u})=>{let d=jI(e,t,a??xi(e,t),{resources:n,views:r,fieldTypes:i}),f=u&&l?l(d):d,p=_j(e,t,[...f.map(e=>e.id),...o?Or(o):[]]);return{specs:f,fields:p,read:MI(e,t,{shown:p,opens:s,bulk:c})}},PI=e=>e.props,FI=e=>t=>{let n=new Map(t.map(e=>[e.id,{title:e.title,badge:e.kind===`status`}])),r=(e??t.map(e=>e.id)).filter(e=>n.has(rh(e))),i=new Set(sh(r,e=>n.get(e)));return t.filter(e=>i.has(e.id))},II=(e,t)=>e.orderBy||t||void 0,LI=(e,t)=>e&&t?[...new Set([...e,...t])].sort():void 0,RI={Table:(e,t,n)=>{let{resource:r,columns:i,button:a,bulk:o=!1}=PI(e),s=r===void 0?void 0:n.resources[r];if(!s)return;let c=n.views[s.name],{fields:l,read:u}=NI({...n,model:s,view:c,columns:i?.map(rh),button:a,bulk:o,phoneColumns:FI(i)}),d=BA(c);return{read:{...t,orderBy:II(t,cE(s,c)),fields:LI(t.fields,u)},extras:{labels:fP(n.resources,n.views,s,l),...d&&{photos:d}},then:e=>vP(n.queryClient,n.client,n.resources,n.views,s,l,e.rows)}},RecordCards:(e,t,n)=>{let r=n.resources[PI(e).resource];if(r)return{read:{...t,orderBy:II(t,cE(r,n.views[r.name])),fields:void 0},extras:{}}},Thread:(e,t,n)=>{if(t.part===`calls`)return{read:t,extras:{}};let{resource:r,sender:i}=PI(e),a=n.resources[r];if(a)return{read:t,extras:{labels:fP(n.resources,n.views,a,i===void 0?[]:[i])}}}},zI=(e,t,n)=>{if(t.split&&!e.custom){if(t.part===`total`)return{read:t,extras:{}};if(t.part===void 0||t.part===`calls`)return RI[e.type]?.(e,t,n)}},BI=new Set([`RecordCard`,`CardRow`,`Stat`,`ReferenceManyField`,`ReferenceArrayField`,`ReferenceField`]),VI=(e,t)=>{let n=lh(e,t.block);return n?.custom?n.reads!==void 0&&t.part!==`chosen`:t.part===void 0&&n!==void 0&&BI.has(n.type)},HI=(e,t,n)=>(n?.reads??[]).flatMap(r=>{let i=lh(t,r.block),a=i&&zI(i,r,e);if(!a&&!VI(t,r))return[];let o=Ah(a?.read??r,{params:e.params,...e.root&&{root:e.root}}),s=a?.extras??{},c=async()=>{let t=await cP(e.client,o,s);return await a?.then?.(t),t};return[{read:o,queryKey:[...I.planRead(jh(r,n),o),s],queryFn:c}]}),UI=(e,t)=>!e||!t?t:e.isPending===t.isPending&&e.error===t.error&&e.total===t.total&&e.labels===t.labels&&e.photos===t.photos&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>e===t.rows[n])?e:t,WI=(0,j.createContext)(new Map),GI=({tree:e,plan:t,children:n})=>{let r=X(),i=x(),{resources:a,views:o}=Vv(),s=jT().fields,c=Ey(),l=iP(),u=YN(JN()),d=(0,j.useMemo)(()=>HI({client:r,queryClient:i,resources:a,views:o,fieldTypes:s,xs:c,params:l,...u&&{root:u}},e,t),[r,i,a,o,s,c,l,u,e,t]),f=ee({queries:d.map(({queryKey:e,queryFn:t})=>({queryKey:e,queryFn:t}))}),p=new Map(d.map(({read:e},t)=>[nh(e),{read:e,query:f[t]}]));return(0,L.jsx)(WI.Provider,{value:p,children:n})},KI=(e,t,n,r)=>{let i=r===void 0?void 0:e.get(r);if(!i)return;let{read:a,query:o}=i,s=t.at(-1);if(a.split&&!(s&&`model`in s&&s.planned))return;let c=o.data?Mh(a,o.data.rows,{...XN(t),params:n}):[],{total:l,labels:u,photos:d}=o.data??{};return{isPending:o.isPending,error:o.error,rows:c,...l!==void 0&&{total:l},...u&&{labels:u},...d&&{photos:d}}},qI=e=>JI([e])[0],JI=e=>{let t=(0,j.useContext)(WI),n=JN(),r=iP(),i=(0,j.useRef)([]),a=e.map((e,a)=>UI(i.current[a],KI(t,n,r,e)));return i.current=a,a},YI=(0,j.createContext)(void 0),XI=({node:e,at:t,children:n})=>{let r=(0,j.useMemo)(()=>({node:e,...t!==void 0&&{at:t}}),[e,t]);return(0,L.jsx)(YI.Provider,{value:r,children:n})},ZI=(e,t)=>t===void 0?void 0:e.props[t],QI=e=>{let t=(0,j.useContext)(YI);if(!t)throw Error(`${e} is for a custom component in a layout`);return t},$I=()=>{let{node:e,at:t}=QI(`useComponentReads`),n=JN(),r=iP();return eL((0,j.useMemo)(()=>xh(e,{...XN(n),params:r}),[e,n,r]),t)},eL=(e,t)=>{let{resources:n,views:r}=Vv(),i=X(),a=ch(e).flatMap(({reads:t,part:r})=>{let i=n[String(ZI(e,t.resource))];return i?[{reads:t,part:r,model:i}]:[]}),o=JI(t===void 0?[]:a.map(({part:e})=>nh({block:t,part:e}))),s=ee({queries:a.map(({reads:t,model:n},r)=>{let a=Xm(ZI(e,t.filter))??``,s=Ym(ZI(e,t.sort))??``,c=ZI(e,t.limit),l=typeof c==`number`?c:500;return{enabled:o[r]===void 0,queryKey:I.list(n.name,a,s,l,``),queryFn:()=>i.list(n.name,{filter:a||void 0,orderBy:s||void 0,pageSize:l})}})});return Object.fromEntries(a.map(({reads:e,model:t},n)=>{let i=o[n],a=s[n],c=i??{isPending:a.isPending,error:a.error,rows:a.data?.items??[]};return[e.resource,{model:t,view:r[t.name],rows:c.rows,isPending:c.isPending,error:c.error}]}))},tL=()=>{let{node:e}=QI(`useComponentSelect`),t=sP(),n=Wp(e)?.param;if(n!==void 0&&t)return{chosen:t.given[n],linkTo:e=>t.linkTo({[n]:e})}},nL=({model:e,view:t,field:n,record:r})=>{let i=e.fields[n],a=r[n];if(!i||a==null)return null;let o=t?.fields[n];return(0,L.jsxs)(wF,{value:a,hints:o,children:[(0,L.jsxs)(`span`,{className:`sr-only`,children:[o?.label??n,`: `]}),kA(i,a,o)]})},rL=(e,t)=>{let n=yA(e,t);return n===void 0?{className:uy[bA(e,t)]}:{style:{backgroundColor:n}}},iL=({view:e,field:t,record:n})=>{let r=rL(e?.fields[t]?.valueColors,n[t]);return(0,L.jsx)(`span`,{"aria-hidden":!0,"data-tone-edge":!0,style:r.style,className:R(`absolute -inset-y-px -left-px w-1 rounded-l-lg`,r.className)})},aL=(0,j.createContext)(void 0),oL=({value:e,children:t})=>(0,L.jsx)(aL.Provider,{value:e,children:t}),sL=()=>{let e=(0,j.useContext)(aL);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},cL=()=>(0,j.useContext)(aL),lL=({row:e,resource:t,recordKey:n,...r})=>{let i=cL(),a=qN(),o=t??i?.resource??a?.model.name;if(o===void 0)throw Error(`RecordLink needs a resource outside a list display or a record`);return(0,L.jsx)(Ej,{to:{kind:`record`,resource:o,key:e?e.key:n},...r})},uL=F(`app/conversation-page`),dL=e=>e.length===0?``:e.length===1?uL(`typingOne`,{name:e[0]}):e.length===2?uL(`typingTwo`,{first:e[0],second:e[1]}):uL(`typingMany`),fL=({channel:e})=>{let{member:t}=BD(),n=Rw(e).map(e=>t(e)?.name??uL(`someone`));return(0,L.jsx)(`p`,{className:`h-5 shrink-0 truncate px-4 text-xs text-muted-foreground`,"aria-live":`polite`,children:dL(n)})},pL={now:()=>Date.now(),setTimer:(e,t)=>{let n=setTimeout(e,t);return()=>clearTimeout(n)}},mL=e=>{if(!(e instanceof gf))throw e},hL=e=>{let t=Fw(),n=(0,j.useMemo)(()=>Nw(n=>t?.relay.joined(e)?(t.relay.send(e,Ew,{typing:n}).catch(mL),!0):!1,pL),[t,e]);return(0,j.useEffect)(()=>()=>n.onSent(),[n]),n},gL=e=>{let t=Fw();(0,j.useEffect)(()=>{if(!t)return;let n=t.store.view(e),r=t.relay.join(e);return()=>{n(),r()}},[t,e])},$=F(`calls`),_L=(e,t)=>{e.srcObject=new MediaStream([t]);let n=()=>{t.readyState===`live`&&e.play().catch(e=>{if(!(e instanceof DOMException&&(e.name===`AbortError`||e.name===`NotAllowedError`)))throw e})};return e.addEventListener(`pause`,n),()=>e.removeEventListener(`pause`,n)},vL=({track:e,...t})=>{let n=(0,j.useCallback)(t=>t?_L(t,e):void 0,[e]);return(0,L.jsx)(`video`,{ref:n,autoPlay:!0,playsInline:!0,muted:!0,...t})},yL=({track:e})=>{let t=(0,j.useCallback)(t=>t?_L(t,e):void 0,[e]);return(0,L.jsx)(`audio`,{ref:t,autoPlay:!0})},bL=e=>R(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),xL=({name:e,member:t,camera:n,microphoneOn:r,cameraOn:i,microphone:a,cameraAvailable:o,notices:s,onMicrophone:c,onCamera:l,onJoin:u,cancel:d,joinLabel:f=$(`joinCall`)})=>(0,L.jsxs)(`section`,{"aria-label":$(`preview`),className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4`,children:[(0,L.jsx)(`figure`,{className:`relative flex aspect-video w-full max-w-md items-center justify-center overflow-hidden rounded-lg bg-neutral-900`,children:n&&i?(0,L.jsx)(vL,{track:n,"aria-label":$(`preview`),className:`size-full -scale-x-100 object-cover`}):(0,L.jsx)(Cb,{initials:Eb(e),hue:Tb(t),size:`md`,className:`size-16 text-xl ring-0`})}),s.length>0&&(0,L.jsx)(`div`,{role:`status`,className:`flex w-full max-w-md flex-col gap-1`,children:s.map(e=>(0,L.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:e},e))}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(B,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":r,disabled:!a,className:bL(r),onClick:c,children:r?(0,L.jsx)(Sc,{className:`size-4`}):(0,L.jsx)(bc,{className:`size-4`})}),(0,L.jsx)(B,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":i,disabled:!o,className:bL(i),onClick:l,children:i?(0,L.jsx)(eu,{className:`size-4`}):(0,L.jsx)(Ql,{className:`size-4`})}),(0,L.jsx)(B,{variant:`primary`,className:`h-10 rounded-full px-5`,onClick:u,children:f}),(0,L.jsx)(Du,{to:d,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]})]}),SL=()=>{let[e,t]=(0,j.useState)(!1);return{run:(0,j.useCallback)(e=>{t(!1),(async()=>{let{GuestRefused:n}=await s(async()=>{let{GuestRefused:e}=await import(`./calls-n9IoOXzL.js`);return{GuestRefused:e}},[]);await e().catch(e=>{if(!(e instanceof n))throw e;t(!0)})})()},[]),refused:e}},CL={all:[`camera`,`microphone`,`screen`,`screen-audio`],camera:[`camera`,`microphone`],microphone:[`microphone`]},wL={call:void 0,hour:36e5},TL=({name:e,children:t})=>(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-2 py-1.5`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-sm text-foreground`,children:e}),(0,L.jsx)(`span`,{className:`flex shrink-0 gap-1.5`,children:t})]}),EL=({lobby:e,inCall:t,guests:n,linkOf:r,open:i,onClose:a})=>{let[o,s]=(0,j.useState)(`camera`),[c,l]=(0,j.useState)(`call`),[u,d]=(0,j.useState)(),[f,p]=(0,j.useState)(!1),{run:m,refused:h}=SL(),g=()=>m(async()=>{let e=wL[c],{link:t,token:i}=await n.link({publish:CL[o],...e!==void 0&&{expiresAt:new Date(Date.now()+e)}});d({id:t.id,url:r(i)})}),_=e=>void navigator.clipboard.writeText(e).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)});return(0,L.jsx)(jD,{title:$(`guests`),description:$(`addressesVisible`),open:i,onClose:a,actions:(0,L.jsx)(B,{onClick:a,children:$(`close`)}),children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h&&(0,L.jsx)(`p`,{role:`alert`,className:`rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:$(`guestRefused`)}),e.guests.length>0&&(0,L.jsxs)(`section`,{"aria-label":$(`inLobby`),children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`inLobby`)}),(0,L.jsx)(`ul`,{children:e.guests.map(({guest:e,name:t})=>(0,L.jsxs)(TL,{name:t,children:[(0,L.jsx)(B,{size:`sm`,variant:`primary`,onClick:()=>m(()=>n.admit(e)),children:$(`admit`)}),(0,L.jsx)(B,{size:`sm`,onClick:()=>m(()=>n.deny(e)),children:$(`deny`)})]},e))})]}),t.length>0&&(0,L.jsxs)(`section`,{"aria-label":$(`guestsInCall`),children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestsInCall`)}),(0,L.jsx)(`ul`,{children:t.map(({guest:e,name:t})=>(0,L.jsx)(TL,{name:t,children:(0,L.jsx)(B,{size:`sm`,variant:`danger`,onClick:()=>m(()=>n.remove(e)),children:$(`remove`)})},e))})]}),(0,L.jsxs)(`section`,{"aria-label":$(`guestLinks`),className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:$(`guestLinks`)}),e.links.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:$(`noLinks`)}),(0,L.jsx)(`ul`,{children:e.links.map(e=>(0,L.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-1.5`,children:[u?.id===e.id&&(0,L.jsx)(Hb,{readOnly:!0,value:u.url,"aria-label":$(`copyLink`),onFocus:e=>e.currentTarget.select(),trailing:(0,L.jsx)(`button`,{type:`button`,"aria-label":$(f?`copied`:`copyLink`),onClick:()=>_(u.url),className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:f?(0,L.jsx)(Xo,{className:`size-4 text-success`}):(0,L.jsx)(gs,{className:`size-4`})})}),(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[e.expires_at?$(`linkUntil`,{until:new Date(e.expires_at).toLocaleString()}):$(`linkUntilEnd`),(0,L.jsx)(B,{size:`sm`,onClick:()=>m(()=>n.revoke(e.id)),children:$(`revoke`)})]})]},e.id))}),(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`guestsMaySend`),(0,L.jsx)(sx,{label:$(`guestsMaySend`),value:o,onChange:s,options:[{value:`all`,label:$(`sendAll`)},{value:`camera`,label:$(`sendCamera`)},{value:`microphone`,label:$(`sendMicrophone`)}]})]}),(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[$(`linkLasts`),(0,L.jsx)(sx,{label:$(`linkLasts`),value:c,onChange:l,options:[{value:`call`,label:$(`linkUntilEnd`)},{value:`hour`,label:$(`forAnHour`)}]})]}),(0,L.jsx)(B,{variant:`primary`,onClick:g,children:$(`newLink`)})]})]})]})})},DL=({waiting:e,guests:t})=>{let{run:n,refused:r}=SL(),i=e[0];return i?(0,L.jsxs)(`div`,{role:`status`,className:`flex shrink-0 flex-wrap items-center gap-2 rounded-md bg-primary-soft px-3 py-1.5 text-xs text-foreground`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r?$(`guestRefused`):$(`waitingGuest`,{name:i.name})}),(0,L.jsx)(B,{size:`sm`,variant:`primary`,onClick:()=>n(()=>t.admit(i.guest)),children:$(`admit`)}),(0,L.jsx)(B,{size:`sm`,onClick:()=>n(()=>t.deny(i.guest)),children:$(`deny`)})]}):null},OL={ended:`ended`,removed:`removed`,full:`full`,refused:`refused`,unavailable:`unavailable`,denied:`denied`},kL=({reason:e,onJoinAgain:t})=>(0,L.jsxs)(`section`,{role:`status`,className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm text-foreground`,children:$(e===`rejoin`?`ended`:OL[e])}),t&&e!==`removed`&&e!==`refused`&&e!==`denied`&&(0,L.jsx)(B,{onClick:t,children:$(`callAgain`)})]}),AL=(e,t)=>t<640?e<=2?1:2:Math.min(4,Math.ceil(Math.sqrt(e))),jL=({people:e,sharers:t,width:n})=>t[0]===void 0?e<=1?{kind:`alone`}:{kind:`grid`,columns:AL(e,n)}:{kind:`share`,sharer:t[0]},ML=({roundTripMs:e,lostRatio:t})=>(e??0)>400||(t??0)>.05?`poor`:`good`,NL=(e,t,n)=>e===`failed`||e!==`connected`&&n-t>=15e3,PL=(e,t=.05)=>{let n;for(let[r,i]of e)i>=t&&(!n||i>n[1])&&(n=[r,i]);return n?.[0]},FL=(e,t)=>e.find(e=>e.source===t&&e.track),IL=({members:e,self:t,tracks:n,own:r,nameOf:i,speaker:a,connections:o,seen:s,now:c})=>(e.some(e=>e.member===t)?e:[{member:t,joined_at:``},...e]).map(({member:e,name:l})=>{let u={member:e,name:e.startsWith(`guest:`)?$(`guestName`,{name:l??``}):l??i(e),...a===e&&{speaking:!0}};if(e===t)return{...u,self:!0,...r.camera&&{camera:r.camera},...r.microphone&&{microphone:r.microphone},...r.screen&&{screen:r.screen},microphoneOff:!r.microphone||!r.microphoneOn,cameraOff:!r.camera||!r.cameraOn};let d=n.filter(t=>t.member===e),[f,p,m,h]=[`camera`,`microphone`,`screen`,`screen-audio`].map(e=>FL(d,e)),g=o.find(t=>t.member===e),_=NL(g?.state,s.get(e)??c,c)?`failed`:g?.state===`connected`?ML(g):void 0;return{...u,...f&&{camera:f.track},...p&&{microphone:p.track},...m&&{screen:m.track},...h&&{screenAudio:h.track},microphoneOff:!p||p.muted,cameraOff:!f||f.muted,..._&&{connection:_}}}),LL=e=>R(`size-10 rounded-full`,!e&&`bg-danger-soft text-danger-text`),RL=({microphoneOn:e,cameraOn:t,sharing:n,onMicrophone:r,onCamera:i,onShare:a,guests:o,leave:s})=>(0,L.jsxs)(`div`,{role:`toolbar`,"aria-label":$(`joinCall`),className:`flex shrink-0 flex-wrap items-center justify-center gap-2 py-2`,children:[(0,L.jsx)(B,{size:`icon`,"aria-label":$(`microphone`),"aria-pressed":e,title:$(`microphone`),className:LL(e),onClick:r,children:e?(0,L.jsx)(Sc,{className:`size-4`}):(0,L.jsx)(bc,{className:`size-4`})}),(0,L.jsx)(B,{size:`icon`,"aria-label":$(`camera`),"aria-pressed":t,title:$(`camera`),className:LL(t),onClick:i,children:t?(0,L.jsx)(eu,{className:`size-4`}):(0,L.jsx)(Ql,{className:`size-4`})}),a&&(0,L.jsx)(B,{size:`icon`,"aria-label":$(n?`stopSharing`:`shareScreen`),"aria-pressed":!!n,title:$(n?`stopSharing`:`shareScreen`),className:`size-10 rounded-full`,onClick:a,children:n?(0,L.jsx)(Oc,{className:`size-4`}):(0,L.jsx)(Ec,{className:`size-4`})}),o&&(0,L.jsxs)(B,{size:`icon`,"aria-label":$(`guests`),title:$(`guests`),className:`relative size-10 rounded-full`,onClick:o.onOpen,children:[(0,L.jsx)(Wl,{className:`size-4`}),(0,L.jsx)(Bx,{count:o.waiting,className:`absolute -top-1 -right-1`})]}),(0,L.jsxs)(Du,{to:s,className:R(hu({variant:`danger`}),`h-10 rounded-full px-4`),children:[(0,L.jsx)(Hc,{className:`size-4`}),$(`leave`)]})]}),zL=({person:e,screen:t=!1,className:n})=>{let r=t?e.screen:e.cameraOff?void 0:e.camera,i=t?e.self?$(`youAreSharing`):$(`sharing`,{name:e.name}):e.self?`${e.name} (${$(`you`)})`:e.name;return(0,L.jsxs)(`figure`,{"data-member":e.member,"data-speaking":e.speaking?`true`:void 0,"aria-label":i,className:R(`relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-lg bg-neutral-900 ring-offset-2 ring-offset-background`,e.speaking&&!t&&`ring-2 ring-success`,n),children:[r?(0,L.jsx)(vL,{track:r,className:R(`size-full`,t?`object-contain`:`object-cover`,e.self&&!t&&`-scale-x-100`)}):(0,L.jsx)(Cb,{initials:Eb(e.name),hue:Tb(e.member),size:`md`,className:`size-16 text-xl ring-0`}),e.connection===`failed`&&!e.self&&(0,L.jsx)(`p`,{role:`status`,className:`absolute inset-x-1 top-1 truncate rounded bg-black/70 px-2 py-1 text-center text-xs text-white`,children:$(`cannotConnect`,{name:e.name})}),(0,L.jsxs)(`figcaption`,{className:`absolute bottom-1.5 left-1.5 flex max-w-[calc(100%-0.75rem)] items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs text-white`,children:[!t&&e.microphoneOff&&(0,L.jsx)(bc,{role:`img`,"aria-label":$(`muted`),className:`size-3 shrink-0`}),!t&&e.connection===`poor`&&(0,L.jsx)(ou,{role:`img`,"aria-label":$(`poorConnection`),className:`size-3 shrink-0 text-warning`}),(0,L.jsx)(`span`,{className:`truncate`,children:i})]})]})},BL=()=>{let[e,t]=(0,j.useState)(0);return{ref:(0,j.useCallback)(e=>{if(!e)return;t(e.clientWidth);let n=new ResizeObserver(([e])=>t(e.contentRect.width));return n.observe(e),()=>n.disconnect()},[]),width:e}},VL=4,HL=({people:e,columns:t})=>(0,L.jsx)(`div`,{className:`grid size-full min-h-0 gap-2`,style:{gridTemplateColumns:`repeat(${t}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${Math.ceil(e.length/t)}, minmax(0, 1fr))`},children:e.map(e=>(0,L.jsx)(zL,{person:e},e.member))}),UL=({people:e,sharer:t,narrow:n})=>{let r=e.slice(0,VL),i=e.length-r.length;return(0,L.jsxs)(`div`,{className:R(`flex size-full min-h-0 gap-2`,n?`flex-col`:`flex-row`),children:[(0,L.jsx)(zL,{person:t,screen:!0,className:`min-h-0 flex-1`}),(0,L.jsxs)(`div`,{className:R(`flex shrink-0 gap-2`,n?`h-20 flex-row`:`w-40 flex-col`),children:[r.map(e=>(0,L.jsx)(zL,{person:e,className:n?`aspect-video h-full`:`aspect-video w-full`},e.member)),i>0&&(0,L.jsxs)(`p`,{className:`flex items-center justify-center rounded-lg bg-muted px-2 text-xs text-muted-foreground`,children:[`+`,i]})]})]})},WL=({layout:e,people:t,narrow:n})=>e.kind===`share`?(0,L.jsx)(UL,{people:t,sharer:t.find(t=>t.member===e.sharer),narrow:n}):e.kind===`grid`?(0,L.jsx)(HL,{people:t,columns:e.columns}):(0,L.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,L.jsx)(zL,{person:t[0],className:`size-full`}),(0,L.jsx)(`p`,{className:`absolute inset-x-0 top-3 text-center text-sm text-white drop-shadow`,children:$(`alone`)})]}),GL=({people:e,state:t,notices:n=[],controls:r,aside:i,children:a,className:o})=>{let{ref:s,width:c}=BL(),l=c>0&&c<640,u=jL({people:e.length,sharers:e.filter(e=>e.screen).map(e=>e.member),width:c}),d=[...t===`resuming`?[$(`reconnecting`)]:[],...n];return(0,L.jsxs)(`section`,{ref:s,"aria-label":$(`joinCall`),"data-layout":u.kind,className:R(`flex size-full min-h-0 flex-col gap-2 bg-background p-2`,o),children:[d.length>0&&(0,L.jsx)(`div`,{role:`status`,className:`flex shrink-0 flex-col gap-1`,children:d.map(e=>(0,L.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground`,children:[e===$(`reconnecting`)&&(0,L.jsx)(fu,{className:`size-3`}),e]},e))}),i,(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:t===`joining`?(0,L.jsxs)(`p`,{role:`status`,className:`flex size-full items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(fu,{className:`size-4`}),$(`connecting`)]}):(0,L.jsx)(WL,{layout:u,people:e,narrow:l})}),(0,L.jsx)(RL,{...r}),e.filter(e=>!e.self).flatMap(e=>[[`microphone`,e.microphone],[`screen-audio`,e.screenAudio]].map(([t,n])=>n&&{key:`${e.member} ${t}`,track:n})).filter(e=>e!==void 0).map(({key:e,track:t})=>(0,L.jsx)(yL,{track:t},e)),a]})},KL=({leave:e})=>(0,L.jsxs)(`section`,{role:`status`,className:`flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4 text-center`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,L.jsx)(fu,{className:`size-4`}),$(`waiting`)]}),(0,L.jsx)(Du,{to:e,className:`px-2 text-sm text-muted-foreground hover:text-foreground`,children:$(`leave`)})]}),qL=200,JL=1e3,YL=(e,t)=>{e.getFloatTimeDomainData(t);let n=0;for(let e of t)n+=e*e;return Math.min(1,Math.sqrt(n/t.length)*4)},XL=e=>{let[t,n]=(0,j.useState)(),r=[...e].map(([e,t])=>`${e}:${t.id}`).join(`,`);return(0,j.useEffect)(()=>{if(e.size===0||typeof AudioContext>`u`)return;let t=new AudioContext,r=new Map([...e].map(([e,n])=>{let r=t.createAnalyser();return r.fftSize=512,t.createMediaStreamSource(new MediaStream([n])).connect(r),[e,r]})),i=new Float32Array(512),a,o=setInterval(()=>{let e=PL(new Map([...r].map(([e,t])=>[e,YL(t,i)])));e&&(a={member:e,at:Date.now()}),n(a&&Date.now()-a.at<JL?a.member:void 0)},qL);return()=>{clearInterval(o),t.close()}},[r]),t},ZL=new Set([`NotAllowedError`,`SecurityError`]),QL=new Set([`NotFoundError`,`NotReadableError`,`OverconstrainedError`]),$L=async(e,t)=>{try{return{track:(await e.getUserMedia({[t]:!0})).getTracks()[0],blocked:!1}}catch(e){if(!(e instanceof DOMException))throw e;if(ZL.has(e.name))return{blocked:!0};if(QL.has(e.name))return{blocked:!1};throw e}},eR=async(e=navigator.mediaDevices)=>{try{let t=await e.getUserMedia({audio:!0,video:!0});return{microphone:t.getAudioTracks()[0],camera:t.getVideoTracks()[0],blocked:{microphone:!1,camera:!1},none:!1}}catch(e){if(!(e instanceof DOMException)||!(ZL.has(e.name)||QL.has(e.name)))throw e}let[t,n]=[await $L(e,`audio`),await $L(e,`video`)];return{...t.track&&{microphone:t.track},...n.track&&{camera:n.track},blocked:{microphone:t.blocked,camera:n.blocked},none:!t.track&&!n.track&&!t.blocked&&!n.blocked}},tR=class extends Error{reason;constructor(e){super(`Not let into the call: ${e}`),this.reason=e,this.name=`NotLetIn`}},nR=1e3,rR=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})}),iR=async(e,t,n,r)=>{let{LobbyRefused:i}=await s(async()=>{let{LobbyRefused:e}=await import(`./calls-n9IoOXzL.js`);return{LobbyRefused:e}},[]),a=e=>e instanceof i?new tR(e.status===404?`refused`:e.status===429?`unavailable`:`ended`):e,{token:o}=await e.enter(t,n).catch(e=>Promise.reject(a(e)));for(;!r.aborted;){let t=await e.wait(o).catch(e=>Promise.reject(a(e)));if(t.state===`admitted`)return o;if(t.state===`denied`)throw new tR(`denied`);if(t.state===`ended`)throw new tR(`ended`);await rR(nR,r)}throw await e.leave(o),new tR(`ended`)},aR=2e3,oR=e=>{for(let t of e)t?.stop()},sR=(e,{admission:t}={})=>{let[n,r]=(0,j.useState)({kind:`check`}),[i,a]=(0,j.useState)(),o=(0,j.useRef)(new AbortController),[c,l]=(0,j.useState)(),[u,d]=(0,j.useState)(!0),[f,p]=(0,j.useState)(!0),[m,h]=(0,j.useState)([]),[g,_]=(0,j.useState)([]),[v,y]=(0,j.useState)([]),[b,x]=(0,j.useState)(),[S,C]=(0,j.useState)(!1),w=(0,j.useRef)(void 0),T=(0,j.useRef)(!1),E=(0,j.useRef)([]),D=(0,j.useRef)(new Map),O=(0,j.useRef)(Promise.resolve(void 0));(0,j.useEffect)(()=>{let e=!1;return T.current=!1,O.current=eR().then(t=>{if(e){oR([t.microphone,t.camera]);return}return E.current.push(t.microphone,t.camera),l(t),t}),()=>{e=!0,T.current=!0,o.current.abort(),w.current?.leave(),w.current=void 0,oR(E.current),E.current=[]}},[]),(0,j.useEffect)(()=>{for(let{member:e}of g)D.current.has(e)||D.current.set(e,Date.now())},[g]),(0,j.useEffect)(()=>{if(n.kind!==`in`)return;let e=setInterval(()=>void w.current?.connections().then(y),aR);return()=>clearInterval(e)},[n.kind]);let k=async()=>{if(!t)return{};r({kind:`waiting`}),o.current=new AbortController;let e=await t(o.current.signal).then(e=>e,e=>{if(!(e instanceof tR))throw e;r({kind:`left`,reason:e.reason})});return e===void 0?void 0:{guest:e}},A=(0,j.useCallback)(async()=>{let t=await k();if(!t||T.current)return;r({kind:`joining`});let{joinCall:n,PublishRefused:i}=await s(async()=>{let{joinCall:e,PublishRefused:t}=await import(`./calls-n9IoOXzL.js`);return{joinCall:e,PublishRefused:t}},[]),o=await n({url:e,...t,onLobby:a,onTracks:h,onMembers:_,onState:e=>{(e.state===`joined`||e.state===`resuming`)&&r({kind:`in`,resuming:e.state===`resuming`}),e.state===`left`&&r({kind:`left`,reason:e.reason})}}).then(e=>e,()=>void 0);if(!o)return;if(T.current)return o.leave();w.current=o;let c=await O.current,l={...c?.microphone&&{microphone:c.microphone},...c?.camera&&{camera:c.camera}};await o.publish(l).then(()=>{l.microphone&&o.mute(`microphone`,!u),l.camera&&o.mute(`camera`,!f)},e=>{if(!(e instanceof i))throw e;C(!0)})},[e,t,u,f]),ee=(0,j.useCallback)(()=>{let e=!u;d(e),c?.microphone&&(c.microphone.enabled=e),w.current?.mute(`microphone`,!e)},[u,c]),te=(0,j.useCallback)(()=>{let e=!f;p(e),c?.camera&&(c.camera.enabled=e),w.current?.mute(`camera`,!e)},[f,c]),ne=(0,j.useCallback)(async e=>{x(void 0),oR([e.video,e.audio]),await w.current?.unpublish(`screen`),e.audio&&await w.current?.unpublish(`screen-audio`)},[]),re=(0,j.useCallback)(async()=>{if(b)return ne(b);let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0})}catch(e){if(e instanceof DOMException&&e.name===`NotAllowedError`)return;throw e}let t={video:e.getVideoTracks()[0],...e.getAudioTracks()[0]&&{audio:e.getAudioTracks()[0]}};E.current.push(t.video,t.audio),t.video.addEventListener(`ended`,()=>void ne(t)),await w.current?.publish({screen:t.video,...t.audio&&{"screen-audio":t.audio}}),x(t)},[b,ne]),ie=typeof navigator<`u`&&typeof navigator.mediaDevices?.getDisplayMedia==`function`;return{phase:n,devices:c,microphoneOn:u,cameraOn:f,tracks:m,members:g,connections:v,screen:b,refusedSending:S,seen:D.current,self:w.current?.participant,lobby:i,guests:w.current?.guests,join:A,toggleMicrophone:ee,toggleCamera:te,...ie&&{toggleScreen:re}}},cR=(e,t)=>[...e?.blocked.microphone?[$(`noMicrophone`)]:[],...e?.blocked.camera?[$(`noCamera`)]:[],...e?.none?[$(`noDevices`)]:[],...t?[$(`refused`)]:[]],lR=({url:e,leave:t,nameOf:n=e=>e,admission:r,name:i,className:a})=>{let o=sR(e,{...r&&{admission:r}}),[s,c]=(0,j.useState)(!1),{basePath:l}=Hu(),u=T_(),d=u?.state.kind===`signed-in`?u.state.user:void 0,f=o.self??d?.id??``,[p]=(0,j.useState)(()=>Date.now()),{devices:m,phase:h}=o,g={...m?.microphone&&{microphone:m.microphone},...m?.camera&&{camera:m.camera},...o.screen&&{screen:o.screen.video},microphoneOn:o.microphoneOn,cameraOn:o.cameraOn},_=new Map([...m?.microphone&&o.microphoneOn?[[f,m.microphone]]:[],...o.tracks.filter(e=>e.source===`microphone`&&e.track&&!e.muted).map(e=>[e.member,e.track])]),v=XL(h.kind===`in`?_:new Map),y=cR(m,o.refusedSending);if(h.kind===`left`)return(0,L.jsx)(kL,{reason:h.reason,onJoinAgain:()=>void o.join()});if(h.kind===`waiting`)return(0,L.jsx)(KL,{leave:t});if(h.kind===`check`)return(0,L.jsx)(xL,{name:i??d?.name??$(`you`),...r&&{joinLabel:$(`askToJoin`)},member:f,...m?.camera&&{camera:m.camera},microphoneOn:o.microphoneOn,cameraOn:o.cameraOn,microphone:!!m?.microphone,cameraAvailable:!!m?.camera,notices:y,onMicrophone:o.toggleMicrophone,onCamera:o.toggleCamera,onJoin:()=>void o.join(),cancel:t});let{lobby:b,guests:x}=o,S=o.members.filter(e=>e.member.startsWith(`guest:`)).map(e=>({guest:e.member.slice(6),name:e.name??``})),C=IL({members:o.members,self:f,tracks:o.tracks,own:g,nameOf:n,...v&&{speaker:v},connections:o.connections,seen:o.seen,now:Math.max(p,Date.now())});return(0,L.jsx)(GL,{...a&&{className:a},people:C,state:h.kind===`joining`?`joining`:h.resuming?`resuming`:`joined`,notices:y,...b&&x&&{aside:(0,L.jsx)(DL,{waiting:b.guests,guests:x})},controls:{microphoneOn:o.microphoneOn&&!!m?.microphone,cameraOn:o.cameraOn&&!!m?.camera,sharing:!!o.screen,onMicrophone:o.toggleMicrophone,onCamera:o.toggleCamera,...o.toggleScreen&&{onShare:()=>void o.toggleScreen()},...b&&{guests:{waiting:b.guests.length,onOpen:()=>c(!0)}},leave:t},children:b&&x&&(0,L.jsx)(EL,{lobby:b,inCall:S,guests:x,linkOf:e=>Kw(`${window.location.origin}${l}`,e),open:s,onClose:()=>c(!1)})})},uR=(e,t)=>{let{address:n,href:r,open:i}=Tj(),a=n?.kind===`record`&&n.resource===e&&n.key===t&&n.call===`join`,o=e=>({href:e,onFollow:()=>i(e)});return{joining:a,join:o(r({kind:`record`,resource:e,key:t,call:`join`})),leave:o(r({kind:`record`,resource:e,key:t}))}},dR=({resource:e,recordKey:t,...n})=>{let{joining:r,leave:i}=uR(e,t);return r?(0,L.jsx)(lR,{leave:i,...n},`${e}/${t}`):null},fR=(e,t)=>{let n=X(),r=x(),i=I.recordCalls(e,t),a=O({queryKey:i,queryFn:()=>n.calls(e,t)});return(0,j.useEffect)(()=>{let i=I.recordCalls(e,t),a=n.channel(e,t),o=a.on(Di,e=>e.server&&r.setQueryData(i,e.payload.items)),s=a.onStatus(e=>e.state===`joined`&&void r.invalidateQueries({queryKey:i}));return()=>{o(),s(),a.leave()}},[n,r,e,t]),{...a,ongoing:a.data?.find(e=>e.ended_at===null)}},pR=({resource:e,recordKey:t,className:n})=>{let{ongoing:r,isPending:i}=fR(e,t),{joining:a,join:o}=uR(e,t);if(i)return null;if(!r)return a?null:(0,L.jsxs)(Du,{to:o,className:R(hu({size:`sm`}),n),children:[(0,L.jsx)(Wc,{className:`size-3.5`}),$(`startCall`)]});let s=r.members.length;return(0,L.jsxs)(`span`,{role:`status`,className:R(`inline-flex items-center gap-1.5 rounded-md bg-success-soft px-2 py-0.5 text-body text-foreground`,n),children:[(0,L.jsx)(Wc,{className:`size-3.5 text-success`}),$(`inProgress`),(0,L.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,L.jsx)(`span`,{"aria-label":$(`people`,{count:s}),children:s}),!a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,L.jsx)(Du,{to:o,className:hu({variant:`primary`,size:`sm`}),children:$(`join`)})]})]})},mR={wallet:nu,"file-text":Hs,send:ml,ruler:cl,bed:Mo,bath:Ao,house:Js,"door-open":Ss,"land-plot":Qs,leaf:nc,tag:Pl,key:Xs,calendar:Ko,heart:Ks,history:il,bell:Ro,bookmark:Ho,"external-link":Ms,ban:Oo,play:Kc,stop:El,power:Qc,restart:ol,terminal:Rl,camera:Jo,"hard-drive":Ws,server:gl,network:Pc,archive:bo,copy:gs,"arrow-right-left":wo,download:ws,upload:Hl,cpu:vs,memory:gc,plug:Jc,wrench:cu,plus:Xc,table:Ml},hR=e=>e!==void 0&&Object.hasOwn(mR,e)?mR[e]:void 0,gR=({benefits:e})=>e&&e.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(Xo,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,_R=({prompt:e})=>{let{canSignUp:t}=J(),{link:n}=RC(),r=hu({variant:`primary`}),i=e.signUp?(0,L.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,L.jsx)(Du,{to:n(`sign-up`),className:r,children:Z(`createAnAccount`)});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Du,{to:n(),className:i?hu():r,children:Z(`signIn`)}),i]})},vR=e=>{let{prompt:t}=e,n=(0,j.useId)();if(e.as===`dialog`)return(0,L.jsx)(jD,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:e.onClose,children:Z(`notNow`)}),(0,L.jsx)(_R,{prompt:t})]}),children:(0,L.jsx)(gR,{benefits:t.benefits})});let r=hR(t.icon)??uc;return(0,L.jsxs)(`section`,{"aria-labelledby":n,className:`mx-auto flex w-full max-w-md flex-col items-center gap-4 px-5 py-10 text-center sm:py-16`,children:[(0,L.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,L.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,L.jsx)(gR,{benefits:t.benefits}),(0,L.jsx)(`div`,{className:`mt-2 flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row sm:justify-center [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:(0,L.jsx)(_R,{prompt:t})})]})},yR=F(`chat`),bR=e=>new Date(Date.parse(`${e}T00:00:00Z`)-864e5).toISOString().slice(0,10),xR=(e,t,n=ME())=>RE(Date.parse(e),n)===RE(Date.parse(t),n),SR=(e,t=Date.now(),n=ME())=>{let r=RE(Date.parse(e),n),i=RE(t,n);return r===i?yR(`today`):r===bR(i)?yR(`yesterday`):rD(Date.parse(`${r}T00:00:00Z`))},CR=({tone:e=`day`,label:t})=>{let n=t??yR(`newMessages`),r=R(`h-px flex-1`,e===`new`?`bg-danger`:`bg-border`);return(0,L.jsxs)(`div`,{role:`separator`,"aria-label":n,"data-tone":e,"data-chat-divider":``,className:`flex items-center gap-3 text-xs font-medium`,children:[(0,L.jsx)(`span`,{className:r}),(0,L.jsx)(`span`,{className:e===`new`?`text-danger`:`text-muted-foreground`,children:n}),(0,L.jsx)(`span`,{className:r})]})},wR=({children:e,className:t})=>(0,L.jsx)(`p`,{className:R(`text-xs text-muted-foreground`,t),children:e}),TR=({time:e})=>{let t=Date.parse(e);return(0,L.jsx)(`time`,{dateTime:e,title:QE(t),className:`text-xs text-muted-foreground`,children:aD(t)})},ER=e=>{let{children:t,footer:n}=e;if(e.author){let{author:r,time:i,avatar:a,continued:o}=e,s=r.name??r.id;return(0,L.jsxs)(`div`,{"data-from":`person`,className:R(`flex min-w-0 gap-3`,o&&`-mt-3`),children:[(0,L.jsx)(`div`,{className:`w-8 shrink-0`,children:!o&&(a??(0,L.jsx)(Cb,{initials:Eb(s)||`?`,hue:Tb(r.id),size:`md`,className:`ring-0`}))}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[!o&&(0,L.jsxs)(`p`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:s}),i&&(0,L.jsx)(TR,{time:i})]}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,L.jsx)(wR,{children:n})]})]})}if(e.alone){let{time:r,continued:i}=e;return(0,L.jsxs)(`div`,{"data-from":`person`,className:R(`flex min-w-0 flex-col gap-0.5`,i&&`-mt-3`),children:[!i&&r&&(0,L.jsx)(TR,{time:r}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words text-foreground`,children:t}),n&&(0,L.jsx)(wR,{children:n})]})}let r=(0,L.jsx)(`div`,{"data-from":e.from,className:R(`flex min-w-0 flex-col gap-2 whitespace-pre-wrap break-words`,e.from===`user`?`ml-8 self-end rounded-lg rounded-br-sm bg-primary px-3 py-2 text-primary-foreground shadow-sm`:`mr-4 text-foreground`),children:t});return n?(0,L.jsxs)(`div`,{className:R(`flex min-w-0 flex-col gap-1`,e.from===`user`&&`items-end`),children:[r,(0,L.jsx)(wR,{className:e.from===`user`?`text-right`:void 0,children:n})]}):r},DR=({working:e})=>(0,L.jsx)(`div`,{role:`status`,className:`shrink-0 pl-11`,children:e&&(0,L.jsxs)(`p`,{"data-chat-working":!0,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-1`,children:[0,200,400].map(e=>(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground [animation:pb-shimmer_1.2s_ease-in-out_infinite]`,style:{animationDelay:`${e}ms`}},e))}),yR(`working`)]})}),OR=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=24,kR=(e,t)=>{if(t.followKey!==e.followKey)return t.scrollHeight;if(e.first===void 0&&t.first!==void 0&&t.newLineTop!==void 0)return Math.max(0,t.scrollTop+t.newLineTop-16);if(e.first!==void 0&&t.first!==e.first&&e.anchor&&t.anchorTop!==void 0)return t.scrollTop+t.anchorTop-e.anchor.top;if(e.atEnd)return t.scrollHeight},AR=(e,t,n)=>{let r=e.getBoundingClientRect().top,i=Array.from(t.children).find(e=>!e.hasAttribute(`data-chat-divider`)&&e.getBoundingClientRect().bottom>r),a=i&&{anchor:{element:i,top:i.getBoundingClientRect().top-r}};return{atEnd:OR(e),first:t.firstElementChild??void 0,followKey:n,...a}},jR=(e,t)=>{let n=(0,j.useRef)({onReadToEnd:e,atEnd:t});(0,j.useLayoutEffect)(()=>{n.current={onReadToEnd:e,atEnd:t}});let r=(0,j.useCallback)(()=>{document.visibilityState===`visible`&&n.current.onReadToEnd?.()},[]);return(0,j.useEffect)(()=>{let e=()=>{n.current.atEnd()&&r()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[r]),r},MR=e=>e.querySelector(`[data-chat-divider][data-tone="new"]`),NR=({children:e,empty:t,length:n,onLoadEarlier:r,loadingEarlier:i,followKey:a,onReadToEnd:o,working:s})=>{let c=(0,j.useRef)(null),l=(0,j.useRef)(null),u=(0,j.useRef)({atEnd:!0,first:void 0,followKey:a}),d=()=>{c.current&&l.current&&(u.current=AR(c.current,l.current,a))},f=()=>u.current.atEnd&&u.current.first!==void 0,p=jR(o,f),m=()=>{let e=u.current.atEnd;d(),!e&&f()&&p()};(0,j.useLayoutEffect)(()=>{let e=c.current;if(!e||!l.current)return;let t=u.current,n=t.anchor&&t.anchor.element.isConnected?t.anchor.element.getBoundingClientRect().top-e.getBoundingClientRect().top:void 0,r=MR(l.current),i=r?r.getBoundingClientRect().top-e.getBoundingClientRect().top:void 0,o=kR(t,{first:l.current.firstElementChild??void 0,anchorTop:n,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,followKey:a,newLineTop:i});o!==void 0&&(e.scrollTop=o),d(),f()&&p()},[n,a,s]),(0,j.useEffect)(()=>{let e=c.current;if(!e||!l.current)return;let t=new ResizeObserver(()=>{u.current.atEnd&&(e.scrollTop=e.scrollHeight)});return t.observe(e),t.observe(l.current),()=>t.disconnect()},[]);let h=n===0&&!!t;return(0,L.jsxs)(`div`,{ref:c,onScroll:m,className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4 [overflow-anchor:none]`,children:[r&&(0,L.jsx)(B,{size:`sm`,className:`self-center`,loading:i,onClick:r,children:yR(`loadEarlier`)}),h&&(0,L.jsx)(`div`,{className:`m-auto max-w-60 text-center text-muted-foreground`,children:t}),(0,L.jsx)(`div`,{ref:l,role:`log`,"aria-live":`polite`,className:R(`flex flex-col gap-4`,h&&`hidden`),children:e}),s!==void 0&&(0,L.jsx)(DR,{working:s})]})},PR=(e,t,n)=>{if(n!==0){if(e===`Home`)return 0;if(e===`End`)return n-1;if(e===`ArrowDown`)return t<0?0:(t+1)%n;if(e===`ArrowUp`)return t<0?n-1:(t-1+n)%n}},FR=(e,t)=>{let n=/(?:^|\s)@([^\s@]*)$/.exec(e.slice(0,t));return n?{start:t-n[1].length-1,query:n[1]}:void 0},IR=(e,t,n)=>{let r=e.slice(t.start+1+t.query.length),i=`@${n}${r.startsWith(` `)?``:` `}`;return{text:`${e.slice(0,t.start)}${i}${r}`,caret:t.start+i.length+ +!!r.startsWith(` `)}},LR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),RR=e=>{let t=[...new Set(e)].filter(Boolean).sort((e,t)=>t.length-e.length);return t.length===0?void 0:RegExp(`(?<![\\p{L}\\p{N}_@])@(${t.map(LR).join(`|`)})(?![\\p{L}\\p{N}_])`,`gu`)},zR=(e,t)=>{let n=RR(t.map(e=>e.name)),r=new Set(n?[...e.matchAll(n)].map(e=>e[1]):[]);return[...new Set(t.filter(e=>r.has(e.name)).map(e=>e.id))]},BR=`rounded-sm bg-primary/10 px-0.5 font-medium text-primary [strong_&]:font-bold`,VR=(e,t)=>{let n=RR(t.flatMap(e=>e.name?[e.name]:[]));if(!n)return[{text:e}];let r=[],i=0;for(let t of e.matchAll(n))t.index>i&&r.push({text:e.slice(i,t.index)}),r.push({mention:t[1]}),i=t.index+t[0].length;return i<e.length&&r.push({text:e.slice(i)}),r},HR=F(`mentions`),UR=({id:e,optionId:t,people:n,active:r,onActive:i,onPick:a,failed:o,at:s})=>(0,L.jsxs)(`ul`,{id:e,role:`listbox`,"aria-label":HR(`peopleToMention`),className:R(`absolute z-30 w-full max-w-sm rounded-md border bg-background py-1 shadow-pop`,s===`above`?`bottom-full mb-1`:`mt-1`),onMouseDown:e=>e.preventDefault(),children:[n.map((e,n)=>(0,L.jsx)(`li`,{id:t(n),role:`option`,"aria-selected":n===r,className:R(`cursor-pointer truncate px-3 py-1.5`,n===r&&`bg-muted`),onMouseMove:()=>n!==r&&i(n),onClick:()=>a(e),children:e.name},e.id)),n.length===0&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:HR(o?`couldNotSearch`:`noOneFound`)})]}),WR=(e,t)=>{let n=$D(t,150),[r,i]=(0,j.useState)(),a=(0,j.useRef)(e);return a.current=e,(0,j.useEffect)(()=>{let e=a.current;if(n===void 0||!e)return;let t=!0;return e(n).then(e=>t&&i({people:e}),()=>t&&i({failed:!0})),()=>{t=!1}},[n]),t===void 0?void 0:r},GR={text:``,picked:[]},KR=8,qR=({value:e,onChange:t,searchPeople:n,listAt:r=`below`,onKeyDown:i,onFocus:a,onBlur:o,ref:s,...c})=>{let[l,u]=(0,j.useState)(0),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(0),[h,g]=(0,j.useState)(),_=(0,j.useRef)(null),v=(0,j.useCallback)(e=>{_.current=e,typeof s==`function`?s(e):s&&(s.current=e)},[s]),y=(0,j.useRef)(void 0),b=(0,j.useId)(),x=n?FR(e.text,l):void 0,S=d&&x!==void 0&&x.start!==h,C=WR(n,S?x.query:void 0),w=S&&C&&`people`in C?C.people.slice(0,KR):[],T=S&&C!==void 0,E=e=>`${b}-${e}`;(0,j.useEffect)(()=>m(0),[x?.query]);let D=x?.start;(0,j.useEffect)(()=>{D===void 0&&g(void 0)},[D]),(0,j.useLayoutEffect)(()=>{y.current!==void 0&&_.current&&(_.current.setSelectionRange(y.current,y.current),u(y.current),y.current=void 0)},[e.text]);let O=n=>{if(!x)return;let r=IR(e.text,x,n.name);y.current=r.caret,t({text:r.text,picked:[...e.picked,n]})},k=e=>{if(S){let t=PR(e.key,p,w.length);if(t!==void 0&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),m(t);return}if((e.key===`Enter`||e.key===`Tab`)&&w[p]){e.preventDefault(),O(w[p]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(x.start);return}}i?.(e)},A=n&&{role:`combobox`,"aria-multiline":!0,"aria-autocomplete":`list`,"aria-expanded":T,"aria-controls":b,"aria-activedescendant":T&&w[p]?E(p):void 0};return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(MP,{...c,...A,ref:v,value:e.text,onChange:n=>{t({...e,text:n.target.value}),u(n.target.selectionStart)},onSelect:e=>u(e.currentTarget.selectionStart),onFocus:e=>{f(!0),a?.(e)},onBlur:e=>{f(!1),o?.(e)},onKeyDown:k}),T&&(0,L.jsx)(UR,{id:b,optionId:E,people:w,active:p,onActive:m,onPick:O,failed:`failed`in C,at:r})]})},JR=class extends j.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){this.props.onError(e,t.componentStack)}render(){return this.state.failed?this.props.fallback:this.props.children}},YR=((e,t,n=kg)=>{let r=!1,i,a=t=>({number:t,Part:(0,j.lazy)(()=>e().then(e=>({default:e}),e=>{throw r=!0,i=e,n(e),e}))}),o=a(0),s=new Set,c=e=>(s.add(e),()=>s.delete(e)),l=()=>{if(r){r=!1,o=a(o.number+1);for(let e of s)e()}},u=(e,t)=>{e!==i&&n(e,t)};return e=>{(0,j.useEffect)(l,[]);let{number:n,Part:r}=(0,j.useSyncExternalStore)(c,()=>o);return(0,L.jsx)(JR,{fallback:(0,L.jsx)(t,{...e}),onError:u,children:(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(t,{...e}),children:(0,L.jsx)(r,{...e})})},n)}})(()=>s(()=>import(`./message-content-DJEa6jyY.js`).then(e=>e.MessageContent),__vite__mapDeps([76,1,6,72,73,74])),({text:e,mentions:t})=>(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:VR(e,t).map((e,t)=>`mention`in e?(0,L.jsxs)(`span`,{className:BR,children:[`@`,e.mention]},t):e.text)})),XR=e=>e.types.includes(`Files`),ZR=e=>e.types.includes(`text/plain`)?[]:[...e.files],QR=(e,{busy:t,canSendEmpty:n})=>t?!1:e!==``||n===!0,$R=({onSend:e,busy:t,placeholder:n,inputRef:r,searchPeople:i,attachments:a,actions:o,canSendEmpty:s,onFiles:c,onDraft:l})=>{let[u,d]=(0,j.useState)(GR),f=e=>{d(e),l?.(e.text)},p=u.text.trim(),m=QR(p,{busy:t,canSendEmpty:s}),h=()=>{if(!m)return;let t=e?.(p,zR(p,u.picked));if(!(t instanceof Promise)){d(GR);return}t.then(e=>{e&&d(e=>e.text.trim()===p?GR:e)})};return(0,L.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),h()},onDragOver:e=>{c&&XR(e.dataTransfer)&&e.preventDefault()},onDrop:e=>{c&&XR(e.dataTransfer)&&(e.preventDefault(),c([...e.dataTransfer.files]))},children:[a&&(0,L.jsx)(`div`,{className:`basis-full`,children:a}),o,(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(qR,{ref:r,rows:1,"aria-label":yR(`message`),placeholder:n,value:u,onChange:f,searchPeople:i,listAt:`above`,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),h())},onPaste:e=>{if(!c)return;let t=ZR(e.clipboardData);t.length!==0&&(e.preventDefault(),c(t))}})}),(0,L.jsx)(B,{type:`submit`,variant:`primary`,className:`w-8 px-0`,"aria-label":yR(`send`),disabled:!m,children:(0,L.jsx)(fl,{className:`size-4`})})]})},ez=e=>{let[t,n]=(0,j.useState)();return(0,j.useEffect)(()=>{let t=window.visualViewport;if(!e||!t)return n(void 0);let r=()=>n({top:t.offsetTop,height:t.height});return r(),t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r),()=>{t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r)}},[e]),e?t:void 0},tz=F(`side-panel`),nz=({title:e,icon:t,status:n,onClose:r,footer:i,children:a})=>{let o=ez(!Ty());return(0,L.jsxs)(`aside`,{"aria-label":e,className:`flex h-full w-[380px] max-w-full shrink-0 flex-col border-l border-border bg-surface max-md:fixed max-md:inset-0 max-md:z-40 max-md:w-full max-md:border-l-0`,style:o&&{top:o.top,bottom:`auto`,height:o.height},children:[(0,L.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-4`,children:[t,(0,L.jsx)(`h2`,{className:`flex-1 font-semibold`,children:e}),n&&(0,L.jsx)(`span`,{className:`truncate text-xs font-medium text-muted-foreground`,children:n}),r&&(0,L.jsx)(B,{variant:`ghost`,size:`sm`,className:`w-7 px-0`,"aria-label":tz(`close`),onClick:r,children:(0,L.jsx)(uu,{className:`size-4`})})]}),a,i&&(0,L.jsx)(`footer`,{className:`shrink-0 space-y-2 border-t border-border bg-background p-3`,children:i})]})},rz=F(`action-card`),iz={neutral:{border:`border-border-strong`,header:`bg-surface text-foreground`},info:{border:`border-primary-border`,header:`bg-primary-soft text-primary-text`},success:{border:`border-success/40`,header:`bg-success-soft text-success-text`},warning:{border:`border-warning/40`,header:`bg-warning-soft text-warning-text`},danger:{border:`border-danger/40`,header:`bg-danger-soft text-danger-text`}},az=({title:e,tone:t=`neutral`,badge:n,note:r,actions:i=[],onAction:a,children:o,frameless:s=!1})=>{let[c,l]=(0,j.useState)(),u=i.flatMap(e=>e.hint?[e.hint]:[]),d=e=>e.confirm?l(e):a?.(e.id);return(0,L.jsxs)(`section`,{"aria-label":e,className:s?`whitespace-normal text-foreground`:R(`shrink-0 overflow-hidden rounded-lg border bg-background whitespace-normal text-foreground shadow-sm`,iz[t].border),children:[!s&&(0,L.jsxs)(`header`,{className:R(`flex items-center gap-2 px-3 py-2`,iz[t].header),children:[(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 font-semibold`,children:e}),n&&(0,L.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:n})]}),(o||r||i.length>0)&&(0,L.jsxs)(`div`,{className:R(`space-y-2.5`,!s&&`px-3 py-2.5`),children:[o,r&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),i.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:i.map(e=>(0,L.jsx)(B,{size:`sm`,variant:e.style??`secondary`,className:R(e.style===`primary`&&`flex-1`),disabled:e.disabled,onClick:()=>d(e),children:e.label},e.id))}),u.map(e=>(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e))]}),c&&(0,L.jsx)(xu,{title:`${c.label}?`,description:c.confirm,onClose:()=>l(void 0),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:()=>l(void 0),children:rz(`cancel`)}),(0,L.jsx)(B,{variant:c.style===`danger`?`danger`:`primary`,onClick:()=>{l(void 0),a?.(c.id)},children:c.label})]})})]})},oz=({fields:e})=>(0,L.jsx)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-body`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,L.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.value})]},`${t}-${e.label}`))}),sz=e=>e==null?`null`:typeof e==`object`?JSON.stringify(e):String(e),cz=F(`compact-table`),lz=({columns:e,rows:t,caption:n,truncated:r,className:i})=>(0,L.jsxs)(`section`,{"aria-label":n??cz(`table`),className:R(`shrink-0 overflow-hidden rounded-lg border border-border-strong bg-background shadow-sm`,i),children:[n&&(0,L.jsx)(`code`,{className:`block whitespace-pre-wrap break-words bg-surface px-3 py-2 font-mono text-[0.6875rem] text-foreground`,children:n}),t.length===0?(0,L.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:cz(`noRows`)}):(0,L.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,L.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.6875rem]`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 bg-background`,children:(0,L.jsx)(`tr`,{children:e.map(e=>(0,L.jsx)(`th`,{scope:`col`,className:`border-b border-border px-2 py-1 font-semibold whitespace-nowrap`,children:e},e))})}),(0,L.jsx)(`tbody`,{children:t.map((e,t)=>(0,L.jsx)(`tr`,{className:`border-b border-border last:border-b-0`,children:e.map((e,t)=>(0,L.jsx)(`td`,{className:R(`px-2 py-1 whitespace-nowrap`,e===null&&`text-faint-foreground`),children:sz(e)},t))},t))})]})}),(0,L.jsxs)(`footer`,{className:`border-t border-border px-3 py-1.5 text-[0.6875rem] text-muted-foreground`,children:[cz(`rows`,{count:t.length}),r&&cz(`cutOff`)]})]}),uz=(e,t=1)=>{let n=t,r=t;return e.split(`
33
+ `).map(e=>e.startsWith(`+`)?{kind:`add`,text:e.slice(1),newNo:r++}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1),oldNo:n++}:{kind:`ctx`,text:e.startsWith(` `)?e.slice(1):e,oldNo:n++,newNo:r++})},dz=e=>({added:e.filter(e=>e.kind===`add`).length,removed:e.filter(e=>e.kind===`del`).length}),fz=e=>{let t=[],n=[],r=[],i=()=>{for(let e=0;e<Math.max(n.length,r.length);e++)t.push({kind:`pair`,old:n[e],new:r[e]});n=[],r=[]};for(let a of e){if(a.kind===`del`){r.length>0&&i(),n.push(a);continue}if(a.kind===`add`){r.push(a);continue}i(),t.push(a.kind===`hunk`?{kind:`hunk`,text:a.text}:{kind:`pair`,old:a,new:a})}return i(),t},pz={add:`bg-success-soft text-success-text`,del:`bg-danger-soft text-danger-text`,ctx:`text-muted-foreground`,hunk:`bg-surface text-faint-foreground`},mz={add:`+`,del:`−`,ctx:``,hunk:``},hz=`bg-background py-1 font-mono text-[0.6875rem] leading-[18px]`,gz=({line:e})=>(0,L.jsxs)(`div`,{className:R(`flex min-w-0`,e?pz[e.kind]:`bg-surface`),children:[(0,L.jsx)(`span`,{className:`w-8 shrink-0 select-none pr-2 text-right opacity-60`,children:e?.newNo??e?.oldNo}),(0,L.jsx)(`span`,{className:`w-3 shrink-0 select-none`,children:e&&mz[e.kind]}),(0,L.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words pr-3`,children:e?.text})]}),_z=({line:e})=>(0,L.jsx)(gz,{line:e&&e.kind===`ctx`?{...e,newNo:void 0}:e}),vz=({lines:e,className:t})=>(0,L.jsx)(`pre`,{className:R(`overflow-x-auto`,hz,t),children:e.map((e,t)=>(0,L.jsx)(gz,{line:e},t))}),yz=({lines:e,className:t})=>(0,L.jsx)(`pre`,{className:R(`grid-cols-2`,hz,t),children:fz(e).map((e,t)=>e.kind===`hunk`?(0,L.jsx)(`div`,{className:R(`col-span-2 px-3`,pz.hunk),children:e.text},t):(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(_z,{line:e.old}),(0,L.jsx)(gz,{line:e.new})]},t))}),bz=({source:e,start:t,path:n,split:r,className:i})=>{let a=typeof e==`string`?uz(e,t):e,o=dz(a);return(0,L.jsxs)(`div`,{className:R(`overflow-hidden`,i),children:[n&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-surface px-3 py-1.5`,children:[(0,L.jsx)(Bs,{className:`size-3.5 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.6875rem] text-foreground`,children:n}),(0,L.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-success-text`,children:[`+`,o.added]}),o.removed>0&&(0,L.jsxs)(`span`,{className:`text-[0.6875rem] font-medium text-danger-text`,children:[`−`,o.removed]})]}),a.length>0&&!r&&(0,L.jsx)(vz,{lines:a}),a.length>0&&r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vz,{lines:a,className:`md:hidden`}),(0,L.jsx)(yz,{lines:a,className:`hidden md:grid`})]})]})},xz={a:7,b:8,t:9,n:10,v:11,f:12,r:13,'"':34,"\\":92},Sz=new TextEncoder,Cz=new TextDecoder,wz=e=>{if(!e.startsWith(`"`))return;let t=[],n=1;for(;n<e.length;){let r=String.fromCodePoint(e.codePointAt(n));if(r===`"`)return{path:Cz.decode(new Uint8Array(t)),rest:e.slice(n+1)};if(r!==`\\`){t.push(...Sz.encode(r)),n+=r.length;continue}let i=/^[0-3][0-7]{2}/.exec(e.slice(n+1));if(i){t.push(parseInt(i[0],8)),n+=4;continue}let a=xz[e[n+1]??``];if(a===void 0)return;t.push(a),n+=2}},Tz=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,Ez=/^(index |old mode |new mode |deleted file mode |new file mode |similarity index |dissimilarity index |rename from |rename to |copy from |copy to |Binary files )/,Dz=e=>{let t=wz(e.slice(4)),n=t?t.path:e.slice(4).split(` `)[0];if(n!==`/dev/null`)return n.replace(/^[ab]\//,``)},Oz=(e,t)=>{let n=wz(t);if(n&&n.rest!==``)return;let r=n?n.path:t;if(e.startsWith(`a/`)&&r.startsWith(`b/`))return{old:e.slice(2),new:r.slice(2)}},kz=e=>{if(!e.startsWith(`diff --git `))return;let t=e.slice(11),n=wz(t);if(n)return n.rest.startsWith(` `)?Oz(n.path,n.rest.slice(1)):void 0;let r=t.indexOf(` "b/`);if(r!==-1)return Oz(t.slice(0,r),t.slice(r+1));let i=[...t.matchAll(/ b\//g)].map(e=>[t.slice(0,e.index),t.slice(e.index+1)]),a=i.find(([e,t])=>e.slice(2)===t.slice(2))??i.at(-1);return a&&Oz(...a)},Az=(e,t)=>{let n=t.find(t=>e.startsWith(t));if(n===void 0)return;let r=e.slice(n.length);return wz(r)?.path??r},jz=(e,t)=>kz(e[t])!==void 0||e[t].startsWith(`--- `)&&e[t+1]?.startsWith(`+++ `)===!0,Mz=e=>{let t=e.replace(/\r\n/g,`
34
+ `).split(`
35
+ `);t.at(-1)===``&&t.pop();let n=0;for(;n<t.length&&!jz(t,n);)n++;let r=[],i;for(;n<t.length;){let e=t[n],a=r.at(-1);if(e===`-- `)break;let o=kz(e);if(o!==void 0){r.push({path:o.new,lines:[]}),i=o,n++;continue}if(e.startsWith(`--- `)&&t[n+1]?.startsWith(`+++ `)){let a=Dz(e),o=Dz(t[n+1]);(i===void 0||(a??i.old)!==i.old||(o??i.new)!==i.new)&&r.push({path:o??a??``,lines:[]}),i=void 0,n+=2;continue}if(a&&a.lines.length===0&&Ez.test(e)){let t=Az(e,[`rename from `,`copy from `]),r=Az(e,[`rename to `,`copy to `]);i&&t!==void 0&&(i.old=t),i&&r!==void 0&&(i.new=r,a.path=r),n++;continue}let s=Tz.exec(e);if(!a||!s)return;i=void 0,a.lines.push({kind:`hunk`,text:e});let c=Number(s[1]),l=Number(s[3]),u=s[2]===void 0?1:Number(s[2]),d=s[4]===void 0?1:Number(s[4]);for(n++;u>0||d>0;){let e=t[n];if(e===void 0)return;if(n++,!e.startsWith(`\\`)){if(e.startsWith(`+`))a.lines.push({kind:`add`,text:e.slice(1),newNo:l++}),d--;else if(e.startsWith(`-`))a.lines.push({kind:`del`,text:e.slice(1),oldNo:c++}),u--;else if(e.startsWith(` `)||e===``)a.lines.push({kind:`ctx`,text:e.slice(1),oldNo:c++,newNo:l++}),u--,d--;else return;if(u<0||d<0)return}}for(;t[n]?.startsWith(`\\`);)n++}return r.length>0?r:void 0},Nz={pending:(0,L.jsx)(fs,{className:`size-3 text-faint-foreground`}),running:(0,L.jsx)(fu,{className:`size-3.5 text-primary`}),done:(0,L.jsx)(Xo,{className:`size-3.5 text-success`,strokeWidth:2.5}),failed:(0,L.jsx)(uu,{className:`size-3.5 text-danger`,strokeWidth:2.5})},Pz={pending:`text-muted-foreground`,running:`text-foreground`,done:`text-muted-foreground`,failed:`text-danger-text`},Fz=({steps:e,className:t})=>(0,L.jsx)(`ul`,{className:R(`shrink-0 space-y-2`,t),children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2.5`,"data-state":e.state,children:[(0,L.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:Nz[e.state]}),(0,L.jsx)(`span`,{className:Pz[e.state],children:e.label})]},`${t}-${e.label}`))}),Iz=F(`assistant-dock`),Lz=({part:e,note:t})=>e.fallback?(0,L.jsx)(az,{title:e.fallback.title,note:t,children:e.fallback.body&&(0,L.jsx)(`p`,{children:e.fallback.body})}):(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`${e.name}: ${t}`}),Rz=class extends j.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){kg(e,t.componentStack)}render(){return this.state.failed?(0,L.jsx)(Lz,{part:this.props.part,note:Iz(`couldNotDraw`)}):this.props.children}},zz=({part:e})=>{let{components:t={}}=jT(),n=Object.hasOwn(t,e.name)?t[e.name]:void 0;return n?(0,L.jsx)(Rz,{part:e,children:(0,L.jsx)(n,{...e.props})}):(0,L.jsx)(Lz,{part:e,note:Iz(`cannotShowLive`)})},Bz=({part:e,onAction:t})=>{switch(e.type){case`text`:return(0,L.jsx)(`p`,{children:e.text});case`table`:return(0,L.jsx)(lz,{columns:e.columns,rows:e.rows,caption:e.caption,truncated:e.truncated});case`card`:return(0,L.jsxs)(az,{title:e.title,tone:e.tone,badge:e.badge,note:e.note,actions:e.actions,onAction:n=>t?.(e.id,n),children:[e.body&&(0,L.jsx)(`p`,{children:e.body}),e.code&&(0,L.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-surface px-2.5 py-2 font-mono text-[0.6875rem] whitespace-pre-wrap break-words`,children:e.code}),e.fields&&e.fields.length>0&&(0,L.jsx)(oz,{fields:e.fields}),e.steps&&e.steps.length>0&&(0,L.jsx)(Fz,{steps:e.steps}),e.diffs?.map((e,t)=>(0,L.jsx)(bz,{source:e.source,start:e.start,path:e.path,className:`rounded-md border border-border`},`${t}-${e.path}`))]});case`widget`:return(0,L.jsx)(zz,{part:e})}},Vz=(0,j.createContext)(void 0),Hz=e=>e instanceof Error?e:Error(Iz(`backendNoAnswer`)),Uz=(e,t)=>typeof e==`function`?e(t):e,Wz=(e,{refreshMs:t=!1}={})=>{let n=(0,j.useContext)(Vz),[r,i]=(0,j.useState)({}),[a,o]=(0,j.useState)(0),s=(0,j.useRef)(t);s.current=t;let c=(0,j.useRef)(void 0);return(0,j.useEffect)(()=>{if(!n){i({error:Error(`useBackendData works only in a widget the assistant dock draws`)});return}let t=!0,r,a=async()=>{let o=await n.fetch(e).then(e=>e.json()).then(e=>({data:e}),e=>({data:c.current,error:Hz(e)}));if(!t)return;c.current=o.data,i(o);let l=Uz(s.current,o.data);l!==!1&&(r=setTimeout(a,l))};return a(),()=>{t=!1,clearTimeout(r)}},[n,e,a]),{...r,reload:()=>o(e=>e+1),post:async(e,t)=>{if(!n)throw Error(`useBackendData works only in a widget the assistant dock draws`);let r={method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t??{})},a=await n.fetch(e,r).then(e=>e.json()).then(e=>({data:e}),e=>({data:c.current,error:Hz(e)}));c.current=a.data,i(a)}}},Gz=({state:e,offline:t,error:n,onSend:r,onAction:i,onClose:a,client:o})=>{let s=(0,j.useRef)(null);return(0,j.useEffect)(()=>{e.placeholder&&s.current?.focus()},[e.placeholder]),(0,L.jsx)(nz,{title:Iz(`assistant`),icon:(0,L.jsx)(wl,{className:`size-4 text-primary`}),status:t?Iz(`reconnecting`):e.status,onClose:a,footer:(0,L.jsxs)(L.Fragment,{children:[n&&(0,L.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:n}),(0,L.jsx)($R,{inputRef:s,onSend:r,busy:e.replying,placeholder:e.placeholder??Iz(`askQuestion`)})]}),children:(0,L.jsx)(Vz.Provider,{value:o,children:(0,L.jsx)(NR,{length:e.messages.reduce((e,t)=>e+t.parts.length,0),empty:Iz(`empty`),children:e.messages.map(e=>(0,L.jsx)(ER,{from:e.from,children:e.parts.map(e=>(0,L.jsx)(Bz,{part:e,onAction:i},e.id))},e.id))})})})},Kz=e=>e instanceof Error?e.message:Iz(`noAnswer`),qz=e=>{let[t,n]=(0,j.useState)(Nr),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)();(0,j.useEffect)(()=>{if(e)return e.connect(e=>n(t=>Ir(t,e)),e=>i(e.state===`retrying`))},[e]);let s=e=>{o(void 0),e.catch(e=>o(Kz(e)))};return{state:t,offline:r,error:a,send:(t,n)=>e&&s(e.send(t,n)),act:(t,n)=>e&&s(e.act(t,n))}},Jz=e=>{let t=xw(),n=(0,j.useRef)(t);n.current=t;let r=t!==void 0;return(0,j.useMemo)(()=>r?_g({url:e,token:()=>n.current}):void 0,[e,r])},Yz=`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60`,Xz=F(`record-view`),Zz=({actions:e,label:t=Xz(`actions`),className:n})=>{let{open:r,setOpen:i,place:a,button:o,menu:s}=TE();return e.length===0?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{ref:o,type:`button`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r,onClick:()=>i(!r),className:n,children:(0,L.jsx)(Os,{className:`size-5`})}),(0,L.jsx)(Sx,{open:r,title:t,onClose:()=>i(!1),menu:(0,L.jsx)(`ul`,{ref:s,role:`menu`,"aria-label":t,style:a??{visibility:`hidden`},className:`fixed z-50 max-h-[calc(100dvh-1rem)] min-w-48 overflow-y-auto rounded-md border bg-background py-1 shadow-pop`,children:e.map(({name:e,icon:t,onRun:n,blocked:r,running:a,tone:o,render:s})=>{let c=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(t,{className:R(`size-4 shrink-0`,o===`danger`?`text-danger-text`:`text-muted-foreground`),"aria-hidden":!0}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:R(`block font-medium`,o===`danger`&&`text-danger-text`),children:e}),r&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r})]})]});return(0,L.jsx)(`li`,{role:`none`,onClick:()=>i(!1),children:s&&!r?s({className:Yz,children:c,role:`menuitem`}):(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:n,disabled:!!r||a,title:r,className:Yz,children:c})},e)})})})]})},Qz=(0,j.createContext)(void 0),$z=()=>{let e=(0,j.useContext)(Qz);if(!e)throw Error(`A focus part is used outside a FocusPage`);return e},eB=()=>{let e=(0,j.useContext)(Qz);return e&&{size:e.size}},tB=F(`focus-page`),nB=2,rB=({action:e})=>{let t=e.icon,n=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),e.name]});return e.render&&!e.blocked?e.render({className:hu(),children:n}):(0,L.jsx)(B,{variant:e.tone===`danger`?`danger`:`secondary`,onClick:()=>!e.blocked&&e.onRun?.(),"aria-disabled":!!e.blocked,loading:e.running,title:e.blocked,children:n})},iB=(e,t)=>t===`wide`||t===`medium`?e.filter(e=>e.inBar).slice(0,nB):[],aB=()=>{let{store:e,size:t}=$z();return iB((0,j.useSyncExternalStore)(e.subscribe,e.actions),t).map(e=>(0,L.jsx)(rB,{action:e},e.name))},oB=()=>{let{store:e,size:t}=$z(),n=(0,j.useSyncExternalStore)(e.subscribe,e.actions),r=aS(),i=Ty(),a=iB(n,t),o=n.filter(e=>!a.includes(e)),s=[...o.filter(e=>e.tone!==`danger`),...o.filter(e=>e.tone===`danger`)];return r&&!i?(0,M.createPortal)((0,L.jsx)(Zz,{actions:s,label:tB(`more`),className:$b}),r):(0,L.jsx)(Zz,{actions:s,label:tB(`more`),className:hu({size:`icon`})})},sB=e=>e>=1100?`wide`:e>=950?`medium`:e>=720?`narrow`:`compact`,cB=(e,t=1)=>e>0&&t>0&&e-t*380<480,lB=[`refused`,`conflict`,`draft`,`info`],uB=e=>lB.indexOf(e),dB=()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=new Set,a=[],o,s=()=>{a=[...e.values()].flat(),o=[...t].sort(([,e],[,t])=>uB(e)-uB(t))[0]?.[0];for(let e of i)e()};return{subscribe:e=>(i.add(e),()=>{i.delete(e)}),actions:()=>a,notice:()=>o,filled:e=>(n.get(e)??0)>0,openPanels:()=>new Set(r.values()).size,openPanel:(e,t)=>(r.set(e,t),s(),()=>{r.delete(e),s()}),setActions:(t,n)=>{n?e.set(t,n):e.delete(t),s()},setNotice:(e,n)=>{n?t.set(e,n):t.delete(e),s()},fill:e=>(n.set(e,(n.get(e)??0)+1),s(),()=>{n.set(e,(n.get(e)??1)-1),s()})}},fB=()=>{let[e,t]=(0,j.useState)(0),n=(0,j.useRef)(void 0);return[(0,j.useCallback)(e=>{n.current?.disconnect(),e&&(t(e.getBoundingClientRect().width),n.current=new ResizeObserver(([e])=>t(e.contentRect.width)),n.current.observe(e))},[]),e]},pB=e=>(0,j.useState)(()=>{let t=t=>n=>e(e=>e[t]===n?e:{...e,[t]:n});return{mode:t(`mode`),controls:t(`controls`),state:t(`state`),secondary:t(`secondary`),primary:t(`primary`),notice:t(`notice`),start:t(`start`),end:t(`end`)}})[0],mB=`flex min-w-0 shrink-0 items-center gap-2 empty:hidden`,hB=({label:e,children:t})=>{_b(!1);let[n]=(0,j.useState)(dB),[r,i]=(0,j.useState)({}),a=pB(i),[o,s]=fB(),[c,l]=fB(),u=sB(s),d=cB(l,(0,j.useSyncExternalStore)(n.subscribe,n.openPanels)),f=(0,j.useMemo)(()=>({store:n,hosts:r,size:u}),[n,r,u]);return(0,L.jsx)(Qz.Provider,{value:f,children:(0,L.jsxs)(`section`,{"aria-label":e,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`h1`,{className:`sr-only`,children:e}),(0,L.jsxs)(`div`,{ref:o,role:`group`,"aria-label":tB(`tools`),className:`flex min-h-12 shrink-0 items-center gap-2 border-b bg-background px-3 max-md:min-h-14`,children:[(0,L.jsx)(`div`,{ref:a.mode,className:R(mB,`shrink`)}),(0,L.jsx)(`div`,{ref:a.controls,className:mB}),(0,L.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,L.jsx)(`div`,{ref:a.state,className:R(mB,`shrink text-xs text-muted-foreground`)}),(0,L.jsx)(aB,{}),(0,L.jsx)(`div`,{ref:a.secondary,className:mB}),(0,L.jsx)(`div`,{ref:a.primary,className:mB}),(0,L.jsx)(oB,{})]}),(0,L.jsx)(`div`,{ref:a.notice,className:`shrink-0 empty:hidden`}),(0,L.jsxs)(`div`,{ref:c,className:`relative flex min-h-0 flex-1`,children:[(0,L.jsx)(`div`,{ref:a.start,className:R(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 left-0 z-10 shadow-pop`)}),(0,L.jsx)(`div`,{className:`relative isolate min-h-0 min-w-0 flex-1`,children:t}),(0,L.jsx)(`div`,{ref:a.end,className:R(`h-full shrink-0 empty:hidden`,d&&`absolute inset-y-0 right-0 z-10 shadow-pop`)})]})]})})},gB=({zone:e,fallback:t=!1,children:n})=>{let{store:r,hosts:i}=$z();(0,j.useLayoutEffect)(()=>t?void 0:r.fill(e),[r,e,t]);let a=_B(e),o=i[e];return o&&!(t&&a)?(0,M.createPortal)(n,o):null},_B=e=>{let{store:t}=$z();return(0,j.useSyncExternalStore)(t.subscribe,()=>t.filled(e))},vB=({actions:e})=>{let{store:t}=$z(),n=(0,j.useId)();return(0,j.useLayoutEffect)(()=>t.setActions(n,e)),(0,j.useEffect)(()=>()=>t.setActions(n,void 0),[t,n]),null},yB={refused:`bg-danger-soft`,conflict:`bg-warning-soft`,draft:`bg-surface`,info:`bg-surface`},bB=({level:e,actions:t,children:n})=>{let{store:r,hosts:i}=$z(),a=(0,j.useId)();(0,j.useLayoutEffect)(()=>(r.setNotice(a,e),()=>r.setNotice(a,void 0)),[r,a,e]);let o=(0,j.useSyncExternalStore)(r.subscribe,r.notice)===a,s=i.notice;return!o||!s?null:(0,M.createPortal)((0,L.jsxs)(`div`,{role:e===`refused`||e===`conflict`?`alert`:`status`,className:R(`flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-3 py-2 text-body`,yB[e]),children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1 basis-48`,children:n}),t&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]}),s)},xB=({side:e=`end`,title:t,icon:n,status:r,onClose:i,footer:a,takesFocus:o=!1,children:s})=>{let{hosts:c,store:l}=$z(),u=c[e],d=(0,j.useId)();(0,j.useLayoutEffect)(()=>l.openPanel(d,e),[l,d,e]);let f=(0,j.useRef)(null),[p]=(0,j.useState)(()=>document.activeElement),m=!!u;return(0,j.useEffect)(()=>{if(o&&m)return f.current?.contains(document.activeElement)||f.current?.focus(),()=>{p instanceof HTMLElement&&p.isConnected&&p.focus()}},[o,m,p]),u?(0,M.createPortal)((0,L.jsx)(nz,{title:t,icon:n,status:r,onClose:i,footer:a,children:(0,L.jsx)(`div`,{ref:f,tabIndex:-1,className:`min-h-0 flex-1 overflow-y-auto p-4 outline-none`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i())},children:s})}),u):null},SB=(0,j.createContext)(void 0),CB=()=>(0,j.useContext)(SB),wB=(e,t)=>t.every(t=>e.includes(t)),TB=(e,t)=>wB([e.title,e.description??``,...e.keywords??[]].join(` `).toLowerCase(),t),EB=(e,t)=>wB(e.title.toLowerCase(),t),DB=(e,t)=>{let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return[...e];let r=e.flatMap(e=>{let t=e.items.filter(e=>TB(e,n));return t.length>0?[{...e,items:[...t.filter(e=>EB(e,n)),...t.filter(e=>!EB(e,n))]}]:[]}),i=e=>EB(e.items[0],n);return[...r.filter(i),...r.filter(e=>!i(e))]},OB=F(`search-picker`),kB=({groups:e,label:t=OB(`search`),autoFocus:n=!1,onPick:r})=>{let[i,a]=(0,j.useState)(``),[o,s]=(0,j.useState)(0),c=(0,j.useRef)(null),l=(0,j.useId)(),u=(0,j.useMemo)(()=>DB(e,i),[e,i]),d=u.flatMap(e=>e.items),f=d[Math.min(o,d.length-1)],p=e=>`${l}-${d.indexOf(e)}`;(0,j.useEffect)(()=>{n&&c.current?.focus()},[n]);let m=f&&p(f);return(0,j.useEffect)(()=>{m&&document.getElementById(m)?.scrollIntoView({block:`nearest`})},[m]),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(Hb,{ref:c,type:`search`,role:`combobox`,"aria-label":t,"aria-expanded":!0,"aria-controls":l,"aria-activedescendant":f&&p(f),placeholder:t,leading:(0,L.jsx)(ul,{className:`size-4`,"aria-hidden":!0}),value:i,onChange:e=>{a(e.target.value),s(0)},onKeyDown:e=>{if(!(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),d.length===0)return;let t=Math.min(o,d.length-1);s((t+(e.key===`ArrowDown`?1:d.length-1))%d.length)}e.key===`Enter`&&f&&!e.nativeEvent.isComposing&&(e.preventDefault(),r(f))}}}),(0,L.jsx)(`div`,{id:l,role:`listbox`,"aria-label":t,className:`flex flex-col gap-3`,children:u.map(e=>(0,L.jsxs)(`div`,{role:`group`,"aria-label":e.title,children:[(0,L.jsx)(`div`,{className:`px-2 pb-1 text-xs font-medium text-muted-foreground`,children:e.title}),e.items.map(e=>{let t=e.icon;return(0,L.jsxs)(`div`,{id:p(e),role:`option`,"aria-selected":e===f,className:R(`flex cursor-pointer items-start gap-2.5 rounded-md px-2 py-2 max-md:min-h-11`,e===f?`bg-muted`:`hover:bg-muted`),onMouseEnter:()=>s(d.indexOf(e)),onClick:()=>r(e),children:[t&&(0,L.jsx)(t,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:e.title}),e.description&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.id)})]},e.title))}),d.length===0&&(0,L.jsx)(`p`,{className:`px-2 text-body text-muted-foreground`,children:OB(`nothing`,{query:i.trim()})})]})},AB=F(`carousel`),jB=`pointer-events-auto absolute top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm opacity-0 transition-opacity group-hover/arrows:opacity-100 group-has-[:focus-visible]/arrows:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,MB=`[@media(hover:none)]:opacity-100`,NB=({carousel:e,count:t,swipe:n,reveal:r,className:i})=>{if(t<2)return null;let{index:a,press:o}=e;return(0,L.jsxs)(`div`,{className:R(`group/arrows pointer-events-none absolute`,i),children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":AB(`previousPhoto`),className:R(jB,r,!n&&MB,`left-2`),onClick:()=>o(-1),children:(0,L.jsx)(es,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsx)(`button`,{type:`button`,"aria-label":AB(`nextPhoto`),className:R(jB,r,!n&&MB,`right-2`),onClick:()=>o(1),children:(0,L.jsx)(ns,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:AB(`photoOf`,{index:a+1,count:t})}),(0,L.jsx)(`span`,{className:`flex items-center gap-1 rounded-full bg-background/70 px-1.5 py-1 leading-none`,"aria-hidden":!0,children:Array.from({length:t},(e,t)=>(0,L.jsx)(`span`,{className:R(`size-1.5 rounded-full`,t===a?`bg-foreground`:`bg-foreground/35`)},t))})]})]})},PB={width:640,height:480},FB=e=>e.flatMap(e=>{if(`src`in e)return[{image:{url:e.src},alt:e.alt}];let t=zk(e,PB);return t?[{image:t,alt:e.alt??``}]:[]}),IB=({carousel:e,swipe:t,slides:n,className:r,...i})=>(0,L.jsx)(`span`,{...i,ref:e.track,tabIndex:-1,onPointerDown:e.touch,onScroll:t=>e.scrolled(t.currentTarget),className:R(`flex size-full snap-x snap-mandatory outline-none [scrollbar-width:none] motion-safe:scroll-smooth [&::-webkit-scrollbar]:hidden`,t?`overflow-x-auto overscroll-x-contain`:`overflow-x-hidden`,r),children:n.map((e,t)=>(0,L.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:e},t))}),LB=(e,t)=>t===0?0:(e%t+t)%t,RB=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),zB=e=>{let t=(0,j.useRef)(null),n=(0,j.useRef)(void 0),[r,i]=(0,j.useState)(0),a=e=>{let n=t.current;n&&n.scrollTo({left:e*n.clientWidth})};return{track:t,index:r,press:t=>{n.current=LB((n.current??r)+t,e),a(n.current)},touch:()=>{n.current=void 0},scrolled:t=>{i(RB(t.scrollLeft,t.clientWidth,e)),n.current!==void 0&&Math.abs(t.scrollLeft-n.current*t.clientWidth)<1&&(n.current=void 0)}}},BB=({images:e,label:t,fit:n=`cover`,swipe:r=!0,className:i})=>{let a=FB(e),o=zB(a.length);return(0,L.jsxs)(`div`,{role:`group`,"aria-roledescription":`carousel`,"aria-label":t,className:R(`group/carousel relative overflow-hidden`,i),children:[(0,L.jsx)(IB,{"data-carousel-track":!0,carousel:o,swipe:r,slides:a.map(({image:e,alt:t})=>(0,L.jsx)(wP,{image:e,alt:t,loading:`lazy`,className:R(`size-full`,n===`cover`?`object-cover`:`object-contain`)}))}),(0,L.jsx)(NB,{carousel:o,count:a.length,swipe:r,reveal:`group-hover/carousel:opacity-100`,className:`inset-0`})]})},VB=500,HB=(e=window)=>e.top!==e.self,UB=(e,t,n)=>{let r=!1,i,a=e=>{r!==e&&(r=e,n(e))},o=()=>{clearTimeout(i),a(!1)},s=()=>{o(),e.defaultView&&e.visibilityState===`visible`&&e.hasFocus()&&(i=setTimeout(()=>a(!0),t))},c=()=>e.visibilityState===`visible`?s():o(),l=()=>{r||s()},u=e=>{`persisted`in e&&e.persisted&&s()};return e.defaultView?.addEventListener(`focus`,s),e.defaultView?.addEventListener(`blur`,o),e.defaultView?.addEventListener(`pagehide`,o),e.defaultView?.addEventListener(`pageshow`,u),e.addEventListener(`visibilitychange`,c),e.addEventListener(`pointerdown`,l,!0),e.addEventListener(`keydown`,l,!0),s(),()=>{clearTimeout(i),e.defaultView?.removeEventListener(`focus`,s),e.defaultView?.removeEventListener(`blur`,o),e.defaultView?.removeEventListener(`pagehide`,o),e.defaultView?.removeEventListener(`pageshow`,u),e.removeEventListener(`visibilitychange`,c),e.removeEventListener(`pointerdown`,l,!0),e.removeEventListener(`keydown`,l,!0)}},WB=()=>{let e=!1;return{down:(t,n=!1)=>{e=t&&!n},take:()=>{let t=e;return e=!1,t}}},GB=(e,t)=>n=>n?e(!0):t(()=>e(!1)),KB=e=>{let[t,n]=(0,j.useState)(!1);return(0,j.useEffect)(()=>UB(document,e,GB(n,M.flushSync)),[e]),t},qB=(e,t)=>{let n=(0,j.useRef)(WB());return{onPointerDown:()=>n.current.down(e),onKeyDown:t=>n.current.down(e,t.repeat),onClick:()=>{n.current.take()&&t()}}},JB=({value:e,options:t,onChange:n,link:r,label:i})=>{let[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)([]),u=(0,j.useRef)(null),d=Kb(a,s,u),f=Yb(a,s,u,d?.right),p=t.findIndex(t=>t.value===e),m=t[p];(0,j.useEffect)(()=>{if(!a)return;l.current[Math.max(p,0)]?.focus();let e=e=>{e.target instanceof Node&&!s.current?.contains(e.target)&&!u.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);let h=()=>{o(!1),c.current?.focus()};return(0,L.jsxs)(`div`,{ref:s,className:`relative shrink-0`,children:[(0,L.jsxs)(`button`,{ref:c,type:`button`,"aria-label":m?`${i}: ${m.label}`:i,"aria-haspopup":`menu`,"aria-expanded":a,onClick:()=>o(!a),className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border-strong bg-background px-2.5 text-body font-medium shadow-sm transition-colors hover:bg-muted pointer-coarse:h-11`,children:[m?.icon&&(0,L.jsx)(m.icon,{className:`size-3.5`}),m?.label??i,(0,L.jsx)(Qo,{className:`size-3.5 text-muted-foreground`})]}),(0,L.jsx)(Sx,{open:a,title:i,onClose:()=>o(!1),inPlaceOnDesktop:!0,menu:(0,L.jsx)(`ul`,{ref:u,role:`menu`,"aria-label":i,onKeyDown:e=>{if(e.key===`Escape`)return h();if(e.key===`Tab`)return o(!1);let n=PR(e.key,l.current.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),l.current[n]?.focus())},style:{...d,...f},className:`absolute right-0 top-full z-30 mt-1 w-max min-w-40 rounded-md border bg-background py-1 text-body shadow-pop`,children:t.map((t,i)=>{let a={ref:e=>{l.current[i]=e},role:`menuitemradio`,"aria-checked":t.value===e,className:R(`flex min-h-9 w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-muted focus:bg-muted focus:outline-none pointer-coarse:min-h-11`,t.value===e&&`font-medium`)},o=(0,L.jsxs)(L.Fragment,{children:[t.icon?(0,L.jsx)(t.icon,{className:`size-3.5`}):(0,L.jsx)(`span`,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,L.jsx)(Xo,{className:`size-3.5 text-primary-text`})]});return(0,L.jsx)(`li`,{role:`none`,children:r?(0,L.jsx)(Du,{...a,to:r(t.value),onClick:h,children:o}):(0,L.jsx)(`button`,{...a,type:`button`,onClick:()=>{h(),t.value!==e&&n(t.value)},children:o})},t.value)})})})]})},YB=({name:e,label:t,options:n,value:r,onChange:i})=>(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":t,className:`flex flex-col gap-2`,children:n.map(t=>(0,L.jsxs)(`label`,{className:R(`block rounded-lg border p-3 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary`,t.disabled?`cursor-default bg-background opacity-60`:t.value===r?`cursor-pointer border-primary bg-primary-soft`:`cursor-pointer bg-background hover:bg-surface`),children:[(0,L.jsx)(`input`,{type:`radio`,name:e,value:t.value,checked:t.value===r,disabled:t.disabled,onChange:()=>i(t.value),className:`sr-only`}),(0,L.jsx)(`span`,{className:R(`block font-medium`,t.value===r&&`text-primary-text`),children:t.label}),t.description&&(0,L.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-muted-foreground`,children:t.description})]},t.value))}),XB=({name:e,label:t,required:n,help:r,example:i,error:a,conflict:o,wide:s,readOnly:c,children:l})=>{let u=(0,j.useId)(),d=[r&&`${u}-help`,i&&`${u}-example`,a&&`${u}-error`].filter(Boolean).join(` `)||void 0;return(0,L.jsxs)(`div`,{className:s?`sm:col-span-2`:void 0,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[c?(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:t}):(0,L.jsxs)(`label`,{htmlFor:u,className:`font-medium text-foreground`,children:[t,n&&(0,L.jsx)(`span`,{className:`ml-0.5 text-danger-text`,"aria-hidden":`true`,children:`*`})]}),o&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-warning-text`,title:Xz(`savedDifferent`,{name:o.user.name}),children:[(0,L.jsx)(Bl,{className:`size-3.5`}),(0,L.jsx)(Cb,{initials:o.user.initials,hue:o.user.hue,size:`xs`})]})]}),(0,L.jsx)(Bb,{value:{id:u,name:e,describedBy:d,invalid:!!a,required:!!n},children:l}),r&&(0,L.jsx)(`p`,{id:`${u}-help`,className:`mt-1.5 text-xs text-muted-foreground`,children:r}),i&&(0,L.jsxs)(`p`,{id:`${u}-example`,className:`mt-0.5 text-xs text-faint-foreground`,children:[Xz(`example`),` `,i]}),a&&(0,L.jsx)(`p`,{id:`${u}-error`,className:`mt-1.5 text-body font-medium text-danger-text`,children:a}),o&&(0,L.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-body text-warning-text`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:o.user.name}),` `,Xz(`savedThis`,{ago:o.ago}),` `,(0,L.jsx)(`strong`,{children:o.theirValue})]}),(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsx)(B,{size:`sm`,onClick:o.onKeepMine,children:Xz(`keepMine`)}),(0,L.jsx)(B,{size:`sm`,onClick:o.onUseTheirs,children:Xz(`useTheirs`)})]})]})]})},ZB=(0,j.createContext)(0),QB=()=>(0,j.useContext)(ZB),$B={2:`h2`,3:`h3`,4:`h4`,5:`h5`,6:`h6`},eV=()=>Math.min(Math.max(QB(),1)+1,6),tV=({title:e,help:t,actions:n,count:r,level:i,children:a})=>{let o=eV(),s=i??o,c=$B[s],l=e?(0,L.jsxs)(c,{className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[e,r]}):null,u=!!(l||n||t),d=l?(0,L.jsx)(ZB.Provider,{value:s,children:a}):a;return(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[l??(0,L.jsx)(`span`,{}),n]}):l,t&&(0,L.jsx)(`p`,{className:`mt-1 max-w-xl leading-6 text-muted-foreground`,children:t}),u?(0,L.jsx)(`div`,{className:`mt-5`,children:d}):d]})},nV=({title:e,help:t,actions:n,count:r,level:i,children:a})=>(0,L.jsx)(`section`,{className:`py-8 first:pt-8`,children:(0,L.jsx)(tV,{title:e,help:t,actions:n,count:r,level:i,children:a})}),rV=({title:e,eyebrow:t,width:n,submit:r,saving:i,disabled:a,error:o,errorTitle:s=FS(`notSaved`),onSubmit:c,onCancel:l,children:u,ref:d})=>{let f=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,L.jsx)(B,{className:`max-sm:min-h-11`,onClick:l,children:FS(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,type:`submit`,className:`max-sm:min-h-11 max-sm:flex-1`,loading:i,disabled:a,children:r})]}),p=o!==void 0&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(PN,{title:s,error:o})}),m=(0,L.jsx)(`div`,{className:`divide-y divide-border`,children:u}),h=e=>{e.preventDefault(),c()};return e===void 0?(0,L.jsxs)(`form`,{ref:d,className:`max-w-[760px]`,onSubmit:h,children:[p,m,(0,L.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:f})]}):(0,L.jsx)(`form`,{ref:d,className:`flex-1`,onSubmit:h,children:(0,L.jsxs)(`div`,{className:R(n!==`full`&&`mx-auto max-w-[760px]`,`px-4 py-6 md:px-10 md:py-8`),children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-end sm:justify-between sm:gap-6`,children:[(0,L.jsxs)(`div`,{children:[t&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,L.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),f]}),p,m]})})},iV=({checked:e,onChange:t,label:n})=>{let r=Vb();return(0,L.jsx)(`button`,{type:`button`,role:`switch`,id:r.id,"aria-describedby":r[`aria-describedby`],"aria-checked":e,"aria-label":n,onClick:()=>t?.(!e),className:R(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors`,e?`bg-primary`:`bg-border-strong`),children:(0,L.jsx)(`span`,{className:R(`size-4 rounded-full bg-white shadow transition-transform`,e?`translate-x-[18px]`:`translate-x-0.5`)})})},aV=({target:e,view:t,value:n,label:r,chosen:i=[n],several:a=!1,invalid:o,onChange:s})=>{let c=iF(),l=e.primaryKey[0],u=Kr(e,t),[d,f]=(0,j.useState)(!1),p=qD(),m=JP(e,u,c.text,d||t?.titleFrom!==void 0&&!e.search?.length),h=[...new Set([l,u,...t?.titleFrom?.fields??[]])],g=n=>t?.titleFrom?p(e,t,n,String(n[l])):String(n[u]),_=PM(e.name,{filter:m.filter,fields:h,enabled:c.open}),v=m.filter!==void 0&&_.error instanceof Id&&_.error.slug===`expensive-query`;(0,j.useEffect)(()=>{v&&f(!0)},[v]);let y=m.local?_.items.filter(e=>YP(g(e),c.text)):_.items,{fetchNextPage:b}=_,x=(0,j.useCallback)(()=>b({cancelRefetch:!1}),[b]);return(0,L.jsx)(oF,{search:c,options:y.map(e=>({key:String(e[l]),label:g(e)})),chosen:i,several:a,closedText:r??n,placeholder:H(`searchPlural`,{plural:(t?.names?.plural??P(e.name)).toLowerCase()}),invalid:o,paging:{more:!!_.hasNextPage,loaded:_.items.length,loadMore:x},loading:_.isPending||_.isFetchingNextPage,failed:!!_.error&&!v,onChoose:e=>s(e.key,e.label)})},oV=(e=Ii())=>new Intl.NumberFormat(e).formatToParts(1.5).find(e=>e.type===`decimal`)?.value===`,`?`,`:`.`,sV=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),cV=(e,t)=>{let n=`[${sV(t===`.`?`,`:`.`)}\\s\\u00a0\\u202f']`,r=RegExp(`^([-+]?)(\\d{1,3}(?:${n}\\d{3})+|\\d+)(?:${sV(t)}(\\d+))?$`).exec(e.trim());if(r)return`${r[1]===`-`?`-`:``}${r[2].replace(/\D/g,``)}${r[3]?`.${r[3]}`:``}`;if(t===`.`&&/^[-+]?\d+(\.\d+)?e[-+]?\d+$/i.test(e.trim()))return String(Number(e.trim()))},lV=e=>e==null?``:typeof e==`object`?JSON.stringify(e):String(e),uV=new Set([`text`,`integer`,`bigint`,`decimal`,`date`,`currency`,`country`,`mail_sender`]),dV=new Set([`uuid`,`timestamp`,`relation`]),fV=(e,t)=>e.readOnly||dV.has(e.type)?!1:e.type!==`json`||t?.widget!==void 0,pV=e=>!e.readOnly&&!e.nullable&&e.type!==`boolean`,mV=new Set([`integer`,`bigint`,`decimal`]),hV=e=>{try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return e;throw t}},gV=(e,t)=>cV(e,t)??e,_V=(e,t,n=oV())=>{if(e.type===`boolean`)return!!t;if(e.type===`file`)return Vk(t);let r=String(t).trim();if(r===``)return e.nullable?null:``;let i=mV.has(e.type)?gV(r,n):r;if(e.type===`integer`)return Number(i);if(e.type===`relation`)return typeof t==`number`?t:i;if(uV.has(e.type)||e.type===`enum`)return i;if(e.type===`json`)return hV(i);throw Error(`Not implemented: editing ${e.type} fields`)},vV=(e,t,n=oV())=>e.type===`boolean`?!!t:String(t??``).trim()===``?null:_V(e,t,n),yV=(e,t)=>e.type===`boolean`?!!t:lV(t),bV=(e,t,n,r=oV())=>{if(e.type===`boolean`)return!!t!=!!n;if(e.type===`file`)return Hk(t,n);let i=String(t??``).trim(),a=lV(n);return e.type===`decimal`||e.type===`integer`?i===``||a===``?i!==a:Number(gV(i,r))!==Number(a):i!==a},xV=`••••••••••`,SV=e=>Rd(e)&&e.slug===`strong-sign-in-required`?e.problem.minutes??15:void 0,CV=({field:e,hints:t,value:n,reveal:r,locked:i,invalid:a,placeholder:o,onChange:s})=>{let[c,l]=(0,j.useState)(!1),u=S({mutationFn:async()=>r(),onSuccess:()=>l(!0)}),d=lV(n)!==``,f=t?.label??P(e.name),p=(0,L.jsx)(B,{variant:`ghost`,size:`sm`,className:`-mr-1.5 px-1.5`,"aria-label":H(c?`hide`:`show`,{label:f}),"aria-pressed":c,loading:u.isPending,onClick:()=>{c||d||!r||u.isSuccess?l(!c):u.mutate()},children:!u.isPending&&(c?(0,L.jsx)(Ps,{className:`size-3.5`}):(0,L.jsx)(Is,{className:`size-3.5`}))}),m=SV(u.error),h=m===void 0?u.error&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(PN,{title:H(`couldNotShow`,{label:f}),error:u.error})}):(0,L.jsx)(oC,{minutes:m,onConfirmed:()=>u.mutate()});if(i)return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,L.jsx)(`span`,{className:R(c?t?.format===`code`?`font-mono text-xs`:``:`tracking-widest text-muted-foreground`),children:c?kA(e,u.data,t):xV}),r&&p]}),h]});let g=d?lV(n):c&&u.isSuccess?lV(u.data):``;return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Hb,{type:c?`text`:`password`,autoComplete:`off`,invalid:a,"aria-label":f,className:R(t?.format===`code`&&`font-mono text-xs`),placeholder:d||!r?o??(e.writeOnly?H(`setNewValue`):void 0):xV,value:g,trailing:p,onChange:e=>s(e.target.value)}),h]})},wV=({value:e})=>{let t=zk(e,{width:40,height:40});return t?(0,L.jsx)(wP,{image:t,className:`size-10 shrink-0 rounded border border-border object-cover`}):(0,L.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded border border-border bg-muted text-muted-foreground`,children:(0,L.jsx)(Hs,{className:`size-4`})})},TV=({value:e,field:t,resource:n,record:r})=>{let i=(0,j.useContext)(ov)?.resources[n],a=jk(e);if(!a)return(0,L.jsx)(`div`,{className:`py-1.5 text-muted-foreground`,children:`—`});if(`missing`in a)return(0,L.jsx)(`div`,{className:`py-1.5 text-danger-text`,children:H(`fileMissing`)});let o=`url`in a?a.url:void 0,s=`corrected`in a?a.corrected:void 0;return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 py-1`,children:[(0,L.jsx)(wV,{value:e}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[o&&!o.startsWith(`blob:`)?(0,L.jsx)(GF,{field:t,model:i,record:Ak(e)?void 0:r,name:a.name,url:o,className:`block truncate font-medium text-primary-text hover:underline`}):(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:a.name}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[a.type,a.size!==void 0&&` · ${Nk(a.size)}`,s&&` · sent as ${s.from}`]})]})]})},EV=({field:e,hints:t,resource:n,record:r,value:i,locked:a,invalid:o,onChange:s})=>{let c=X(),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(),[f,p]=(0,j.useState)(!1),m=t?.label??P(e.name),h=S({mutationFn:async t=>{d(0);let r=await c.upload(n,e.name,t,{onProgress:(e,t)=>d(t>0?e/t:0)});return{uploaded:r,...Pk(r.file.type)&&{preview:URL.createObjectURL(t)}}},onSuccess:e=>s(e),onSettled:()=>d(void 0)});if(a||e.readOnly)return(0,L.jsx)(TV,{value:i,field:e.name,resource:n,record:r});let g=e=>{let t=e?.[0];t&&h.mutate(t)},_=e=>{e.preventDefault(),p(!1),g(e.dataTransfer.files)},v=(0,L.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:Bk(e),"aria-label":H(`chooseFileFor`,{label:m}),onChange:e=>g(e.target.files)}),y=h.error&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(PN,{title:H(`notUploaded`),error:h.error})});return h.isPending?(0,L.jsxs)(`div`,{className:`py-1.5`,role:`status`,"aria-label":H(`uploadingLabel`,{label:m}),children:[(0,L.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${Math.round((u??0)*100)}%`}})}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:H(`uploading`,{percent:Math.round((u??0)*100)})})]}):jk(i)?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(TV,{value:i,field:e.name,resource:n,record:r})}),(0,L.jsx)(B,{size:`sm`,onClick:()=>l.current?.click(),children:H(`replace`)}),e.nullable&&(0,L.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>s(null),children:H(`remove`)})]}),v,y]}):(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:_,className:R(`flex items-center gap-3 rounded-md border border-dashed px-3 py-2.5 text-muted-foreground`,f?`border-primary bg-primary/5`:o?`border-danger`:`border-border-strong`),children:[(0,L.jsx)(Hl,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`flex-1`,children:H(`dropFile`)}),(0,L.jsxs)(B,{size:`sm`,onClick:()=>l.current?.click(),children:[(0,L.jsx)(Rc,{className:`size-3.5`}),H(`chooseFile`)]})]}),v,y]})},DV=F(`markdown`),OV=()=>[{value:`write`,label:DV(`write`)},{value:`preview`,label:DV(`preview`)}],kV=({value:e,onChange:t,label:n,invalid:r,placeholder:i})=>{let[a,o]=(0,j.useState)(`write`);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`span`,{className:`self-start`,children:(0,L.jsx)(sx,{value:a,options:OV(),onChange:o,label:n})}),a===`write`?(0,L.jsx)(MP,{rows:5,invalid:r,placeholder:i,value:e,onChange:e=>t(e.target.value)}):(0,L.jsx)(`div`,{className:`min-h-[7.5rem] rounded-md border border-border px-2.5 py-1.5`,children:e.trim()===``?(0,L.jsx)(`span`,{className:`text-faint-foreground`,children:DV(`nothingToPreview`)}):(0,L.jsx)(EF,{source:e})})]})},AV=new Set([`integer`,`bigint`,`decimal`]),jV=e=>e===`integer`||e===`bigint`?{inputMode:`numeric`,enterKeyHint:`done`}:e===`decimal`?{inputMode:`decimal`,enterKeyHint:`done`}:{},MV=e=>typeof e==`object`&&e&&`key`in e?e.key:e,NV=(e,t,n,r,i)=>t?.confirm!==void 0&&!bV(e,n,r)&&bV(e,MV(i),r),PV=F(`app/change-confirm`),FV=e=>e instanceof Element&&e.closest(`[data-dialog="change-confirm"]`)!==null,IV=({field:e,hints:t,value:n,stored:r,onChange:i})=>{let[a,o]=(0,j.useState)(),s=a=>{NV(e,t,n,r,a)?o({next:a}):i(a)},c=()=>o(void 0);return{onChange:s,dialog:a&&(0,L.jsx)(xu,{name:`change-confirm`,title:PV(`title`,{label:t?.label??P(e.name)}),description:t?.confirm,onClose:c,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B,{onClick:c,children:PV(`cancel`)}),(0,L.jsx)(B,{variant:`primary`,onClick:()=>{o(void 0),i(a.next)},children:PV(`change`)})]})})}},LV=({field:e,hints:t,value:n,stored:r,relationLabel:i,relationTo:a,relationPicker:o,invalid:s,locked:c,placeholder:l,reveal:u,resource:d,record:f,linkText:p,onChange:m})=>{if(e.type===`file`)return(0,L.jsx)(EV,{field:e,hints:t,resource:d??``,record:f,value:n,locked:c||!d,invalid:s,onChange:m});if(e.sensitive)return(0,L.jsx)(CV,{field:e,hints:t,value:n,reveal:u,locked:c||e.readOnly,invalid:s,placeholder:l,onChange:m});if(e.type===`relation`&&o&&!e.readOnly&&!c){let e=(0,L.jsx)(aV,{target:o.target,view:o.view,value:String(n),label:i,invalid:s,onChange:(e,t)=>m({key:e,label:t})});return a?(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),(0,L.jsx)(Ej,{to:a,"aria-label":H(`openLabel`,{label:i??String(n)}),title:H(`open`),className:R(hu({variant:`ghost`}),`w-8 px-0`),children:(0,L.jsx)(Eo,{className:`size-4`})})]}):e}if(e.type===`relation`){if(r==null||r===``)return(0,L.jsx)(`div`,{className:`py-1.5`,children:(0,L.jsx)(uI,{field:e,value:r,hints:t??{}})});let n=i??String(r);return(0,L.jsx)(`div`,{className:`py-1.5`,children:a?(0,L.jsx)(Ej,{to:a,className:`font-medium text-primary-text hover:underline`,children:n}):n})}if(!fV(e)||c)return(0,L.jsx)(`div`,{className:`min-w-0 break-words py-1.5 text-foreground`,children:(0,L.jsx)(uI,{field:e,value:r,hints:t??{},linkText:p})});if(e.type===`boolean`)return(0,L.jsx)(iV,{checked:!!n,onChange:m,label:t?.label??P(e.name)});let h=!!t?.multiline&&e.type===`text`;return pA(e,t)?(0,L.jsx)(kV,{label:t?.label??P(e.name),invalid:s,placeholder:l,value:String(n),onChange:m}):e.type===`mail_sender`?(0,L.jsx)(iI,{field:e,value:n,invalid:s,onChange:m}):e.type===`enum`?(0,L.jsxs)(KF,{invalid:s,value:String(n),onChange:e=>m(e.target.value),children:[n===``&&(0,L.jsx)(`option`,{value:``,children:H(`choose`)}),(e.enumValues??[]).map(e=>(0,L.jsx)(`option`,{value:e,children:Ur(e,t?.valueLabels)},e))]}):h?(0,L.jsx)(MP,{invalid:s,placeholder:l,value:String(n),onChange:e=>m(e.target.value)}):(0,L.jsx)(Hb,{invalid:s,leading:t?.prefix?(0,L.jsx)(`span`,{children:t.prefix}):void 0,trailing:t?.suffix?(0,L.jsx)(`span`,{children:t.suffix.trim()}):void 0,placeholder:l,className:R(AV.has(e.type)&&`text-right tabular-nums`),...jV(e.type),..._A(e.type===`text`?hA(t):void 0),value:String(n),onChange:e=>m(e.target.value)})},RV=(e,t,n,r)=>e.sensitive||e.type===`file`?!1:n||e.readOnly?!0:e.type===`relation`?!r:!fV(e,t),zV=e=>{let{field:t,hints:n,value:r,stored:i,invalid:a,locked:o,onChange:s}=e,c=dF(t,n),l=(0,L.jsx)(LV,{...e});return c?o||!fV(t,n)?(0,L.jsx)(hF,{shown:c,part:`display`,field:t,value:i,fallback:l}):t.type===`file`||t.type===`relation`?l:(0,L.jsx)(hF,{shown:c,part:`editor`,field:t,value:vV(t,r),invalid:!!a,onChange:e=>s(yV(t,e)),fallback:l}):l},BV=e=>{let t=IV(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zV,{...e,onChange:t.onChange}),t.dialog]})},VV=F(`app/field`),HV=(e,t)=>typeof e?.[t]==`number`?e[t]:void 0,UV=(e,t)=>{let n=HV(t,`min`),r=HV(t,`max`);if(n!==void 0)return VV(`atLeastCharacters`,{label:e,count:nk(n),n});if(r!==void 0)return VV(`atMostCharacters`,{label:e,count:nk(r),n:r})},WV=e=>{let t=HV(e,`min`),n=HV(e,`max`);return t===void 0?n===void 0?VV(`wholeNumber`):VV(`wholeNumberAtMost`,{max:nk(n)}):VV(`wholeNumberAtLeast`,{min:nk(t)})},GV=e=>{let t=HV(e,`precision`),n=HV(e,`scale`);if(t===void 0||n===void 0)return VV(`number`);let r=nk(10**(t-n));return n===0?VV(`wholeNumberBelow`,{below:r}):VV(`decimalsBelow`,{scale:n,below:r})},KV={text:UV,integer:(e,t)=>WV(t),bigint:()=>VV(`wholeNumber`),decimal:(e,t)=>GV(t),date:()=>VV(`date`),timestamp:()=>VV(`timestamp`),country:()=>VV(`country`),currency:()=>VV(`currency`),uuid:()=>VV(`uuid`),enum:()=>VV(`enum`),relation:()=>VV(`relation`),json:()=>VV(`json`),mail_sender:(e,t)=>typeof t?.address==`string`?VV(`mailSender`,{address:t.address}):void 0},qV=(e,t,n)=>n.code===`required`?VV(`required`,{label:t}):n.code!==`invalid-value`||!e?n.message:KV[e.type]?.(t,n.params)??n.message,JV=e=>{if(!Rd(e))return{};let t={};for(let n of e.errors)n.field&&n.field!==`_record`&&!Object.hasOwn(t,n.field)&&(t[n.field]=n);return t},YV=e=>{if(e.operation!==void 0)return e.message;let t=new Set(e.errors.flatMap(e=>e.field&&e.field!==`_record`?[e.field]:[])),n=e.errors.flatMap(e=>e.field===`_record`?[e.message]:[]);return t.size===0&&n.length===0?e.message:[...t.size===0?[]:[t.size===1?VV(`checkField`):VV(`checkFields`,{count:t.size})],...n].join(` `)},XV=e=>{let t=(0,j.useRef)(null),n=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{e>0&&(n.current=!0)},[e]),(0,j.useEffect)(()=>{if(!n.current)return;let e=t.current?.querySelector(`[aria-invalid="true"]`);e&&(e.focus(),n.current=!1)}),t},ZV=F(`app/record`),QV=2e3,$V=Symbol(`nothing saved`),eH=(e,t)=>{let n=pT(),[r,i]=(0,j.useState)(`idle`),[a,o]=(0,j.useState)(),s=(0,j.useRef)(void 0);return(0,j.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:ZV(`savingSubject`,{subject:t})}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r()===$V?(a!==void 0&&n.dismiss(a),e===`button`&&i(`idle`),!0):(a!==void 0&&n.update(a,{state:`success`,title:ZV(`subjectSaved`,{subject:t})}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),QV)),!0)}catch(t){if(!Rd(t))throw t;let r=t.status===412?ZV(`changedBySomeoneElse`):ZV(`couldNotSave`),s=YV(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},tH=(e,t,n)=>t?e===void 0||e===`edit`||n?{shown:`form`,offersEdit:!1,editing:!0}:{shown:e,offersEdit:t,editing:!1}:{shown:`read`,offersEdit:!1,editing:!1},nH=(e,t,n)=>(e??t?.helpWhen??`always`)===`always`||n,rH=(e,t,n)=>e?.help!==void 0&&nH(e.helpWhen,t,n)?e.help:void 0,iH=(e,t)=>e===`editing`?t:e!==`reading`||!t,aH=e=>typeof e==`object`&&!!e&&`key`in e,oH=(e,t,n)=>t.name!==e.tenant&&!t.readOnly&&!n?.notOnCreate&&(t.type===`relation`||fV(t,n)),sH=(e,t)=>{let n=Object.values(e.fields).filter(n=>oH(e,n,t?.fields[n.name])).map(e=>e.name),r=new Set,i=Rn(t?.layout??[]).flatMap(e=>{if(e.kind!==`section`||ed(e.when)||!iH(e.when,!0))return[];let i=e.fields.filter(e=>n.includes(e)&&!r.has(e)&&iH(t?.fields[e]?.when,!0));return i.forEach(e=>r.add(e)),i.length>0?[{title:e.title,help:e.help,fields:i}]:[]}),a=n.filter(t=>!r.has(t)&&!e.fields[t].writeOnly);return a.length===0?i:[...i,{title:i.length===0?FS(`details`):FS(`otherFields`),fields:a}]},cH=(e,t)=>(e?.primaryKey.length===1?e.fields[e.primaryKey[0]]?.type:void 0)===`integer`?Number(t):t,lH=(e,t,n)=>Object.fromEntries(Object.entries(n).flatMap(([n,r])=>{let i=e.fields[n];return i?aH(r)?[[n,cH(t[i.relation?.resource??``],r.key)]]:i.type===`boolean`?[[n,!!r]]:i.type===`file`?r?[[n,_V(i,r)]]:[]:String(r).trim()===``?[]:[[n,_V(i,r)]]:[]})),uH=e=>!e.nullable&&!e.default&&e.type!==`boolean`,dH=(e,t)=>e.type===`relation`?{key:t,label:t}:e.type===`boolean`?t===`true`:t,fH=new Set([`integer`,`bigint`,`decimal`]),pH=e=>{if(!fH.has(e.type)||!e.default||!(`value`in e.default))return;let t=e.default.value;return t==null?void 0:String(t)},mH=(e,t,n={})=>Object.fromEntries(t.flatMap(t=>t.fields.flatMap(t=>{let r=e.fields[t];if(Object.hasOwn(n,t))return[[t,dH(r,n[t])]];let i=r.default;return pH(r)!==void 0||!i||!(`value`in i)||i.value===null||i.value===void 0?[]:[[t,typeof i.value==`boolean`?i.value:lV(i.value)]]}))),hH=e=>!!(e.default&&`db`in e.default),gH=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),_H=({resource:e,values:t,onCreated:n,feedback:r})=>{let i=Vv(),a=i.resources[e],o=i.views[e],s=X(),c=x(),{fields:l}=jT(),u=o?.names?.singular??P(e),d=eH(r??o?.saveFeedback??`toast`,FS(`subject`,{noun:u})),f=sH(a,o),[p,m]=(0,j.useState)(()=>mH(a,f,t)),[h,g]=(0,j.useState)({}),[_,v]=(0,j.useState)(0),y=XV(_),[b,S]=(0,j.useState)(!1),C=(0,j.useRef)(!1),[w,T]=(0,j.useState)(!1);(0,j.useEffect)(()=>{for(let[e,n]of Object.entries(t??{})){let t=i.resources[a.fields[e]?.relation?.resource??``];t&&uP(c,s,t,[n],i.views[t.name]).then(t=>{let r=t.get(n);r&&m(t=>aH(t[e])&&t[e].key===n&&t[e].label!==r?{...t,[e]:{key:n,label:r}}:t)})}},[t,i,a,s,c]);let E=(e,t)=>{g(t=>gH(t,e)),S(!0),m(n=>({...n,[e]:t}))},D=async(e={})=>{if(C.current)return!1;C.current=!0,T(!0);try{return await O(e)}finally{C.current=!1,T(!1)}},O=t=>d.run(async()=>{let r;try{r=await s.create(e,{...lH(a,i.resources,p),...t})}catch(t){let r=Rd(t)?t.existing:void 0;if(r)return n(void 0,{kind:`record`,resource:e,key:r.key}),$V;let i=JV(t);throw g(i),Object.keys(i).length>0&&v(e=>e+1),t}for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`,`aggregate`,`count`])c.invalidateQueries({queryKey:[t,e]});n(r.record,{kind:`record`,resource:e,key:sE(a,r.record)})});return{ref:y,sections:f.map(e=>({title:e.title,help:e.help,fields:e.fields.map(e=>{let t=a.fields[e],n=p[e],r=t.relation?i.resources[t.relation.resource]:void 0,s=o?.fields[e]?.label??P(e),c=h[e];return{name:e,label:s,help:o?.fields[e]?.help,required:uH(t),error:c&&qV(t,s,c),wide:fF(l,t,o?.fields[e]),editor:(0,L.jsx)(BV,{field:t,hints:o?.fields[e],value:aH(n)?n.key:n??(t.type!==`boolean`&&``),stored:void 0,relationLabel:aH(n)?n.label:void 0,placeholder:hH(t)?FS(`setByDatabase`):pH(t),relationPicker:r?{target:r,view:i.views[r.name]}:void 0,invalid:!!h[e],resource:a.name,onChange:t=>E(e,t)})}})})),set:E,submit:D,touched:b,saving:w,message:d.message}},vH=({form:e,fields:t,submit:n,disabled:r,onSubmit:i,children:a})=>{let o=e.sections.flatMap(e=>e.fields).filter(e=>t.includes(e.name));return(0,L.jsxs)(`form`,{ref:e.ref,className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),i?i():e.submit()},children:[e.message&&(0,L.jsx)(PN,{title:FS(`notCreated`),error:Error(e.message)}),a,o.map(e=>(0,L.jsx)(XB,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name)),(0,L.jsx)(B,{variant:`primary`,type:`submit`,className:`max-md:min-h-11`,loading:e.saving,disabled:r,children:n})]})},yH=(e,t,n)=>{let r=X(),i=x(),a=[...new Set(n)].sort();return O({queryKey:I.pickedLabels(e.name,a.join(`,`)),enabled:a.length>0,placeholderData:y,queryFn:()=>uP(i,r,e,a,t)}).data??new Map},bH=e=>{let{resources:t,views:n}=Vv(),r=t[e.resource];if(!r)throw Error(`RecordPicker: the app has no resource named "${e.resource}"`);if(r.primaryKey.length!==1)throw Error(`RecordPicker: "${e.resource}" has a composite key, which a picker cannot name`);let i=n[e.resource],a=e.multiple?e.value:e.value===void 0?[]:[e.value],[o,s]=(0,j.useState)({}),c=yH(r,i,a),l=e=>o[e]??c.get(e)??e,u=(e,t)=>s(n=>({...n,[e]:t}));if(!e.multiple){let{value:t,onChange:n}=e;return(0,L.jsx)(aV,{target:r,view:i,value:t??``,label:t===void 0?void 0:l(t),invalid:e.invalid,onChange:(e,t)=>{u(e,t),n(e)}})}let{value:d,onChange:f}=e;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(aV,{target:r,view:i,value:``,chosen:d,several:!0,invalid:e.invalid,onChange:(e,t)=>{u(e,t),f(d.includes(e)?d.filter(t=>t!==e):[...d,e])}}),d.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,L.jsx)(rF,{label:l(e),onRemove:()=>f(d.filter(t=>t!==e))},e))})]})};export{vB as $,Bw as $a,es as $c,BD as $i,qt as $l,hP as $n,_b as $o,ZA as $r,Um as $s,sL as $t,_V as A,yE as Aa,Hl as Ac,hA as Ai,Tr as Al,BF as An,aS as Ao,XM as Ar,J_ as As,zR as At,YB as B,JT as Ba,Ic as Bc,kk as Bi,zn as Bl,fF as Bn,Wb as Bo,zM as Br,Oh as Bs,pR as Bt,FV as C,IE as Ca,xu as Cc,RA as Ci,xi as Cl,yI as Cn,BS as Co,PN as Cr,lv as Cs,nz as Ct,pV as D,vE as Da,fu as Dc,DA as Di,Ur as Dl,qF as Dn,FS as Do,DN as Dr,nv as Ds,GR as Dt,fV as E,TE as Ea,hu as Ec,AA as Ei,qr as El,nI as En,RS as Eo,kN as Er,tv as Es,qR as Et,nV as F,sE as Fa,el as Fc,Uk as Fi,qn as Fl,bF as Fn,bx as Fo,VM as Fr,J as Fs,SR as Ft,qB as G,jT as Ga,Ms as Gc,ek as Gi,Pn as Gl,IP as Gn,Vb as Go,Wj as Gr,lh as Gs,iR as Gt,VB as H,zT as Ha,Xs as Hc,Ok as Hi,In as Hl,rF as Hn,Yb as Ho,NM as Hr,bh as Hs,dR as Ht,tV as I,$T as Ia,Qc as Ic,Bk as Ii,Kn as Il,yF as In,sx as Io,HM as Ir,T_ as Is,xR as It,IB as J,pT as Ja,gs as Jc,wO as Ji,On as Jl,AP as Jn,kb as Jo,wj as Jr,th as Js,hL as Jt,BB as K,DT as Ka,As as Kc,jO as Ki,An as Kl,NP as Kn,Ib as Ko,Ej as Kr,uh as Ks,$ as Kt,ZB as L,XT as La,Xc as Lc,jk as Li,Hn as Ll,vF as Ln,ox as Lo,UM as Lr,m_ as Ls,vR as Lt,cV as M,lE as Ma,Ml as Mc,fA as Mi,nr as Ml,EF as Mn,Jx as Mo,qM as Mr,U_ as Ms,NR as Mt,iV as N,uE as Na,ul as Nc,cA as Ni,Jn as Nl,wF as Nn,Ux as No,GM as Nr,z_ as Ns,ER as Nt,lV as O,SE as Oa,du as Oc,yA as Oi,P as Ol,KF as On,PS as Oo,wN as Or,G_ as Os,VR as Ot,rV as P,oE as Pa,il as Pc,Kk as Pi,Yn as Pl,CF as Pn,Sx as Po,WM as Pr,Y as Ps,CR as Pt,CB as Q,Hw as Qa,ns as Qc,VD as Qi,gn as Ql,yP as Qn,wb as Qo,sj as Qr,Wm as Qs,oL as Qt,QB as R,qT as Ra,Kc as Rc,Nk as Ri,Wn as Rl,_F as Rn,$b as Ro,RM as Rr,K as Rs,_R as Rt,RV as S,ME as Sa,Su as Sc,VA as Si,Si as Sl,_I as Sn,VS as So,IN as Sr,Av as Ss,az as St,vV as T,OE as Ta,B as Tc,kA as Ti,Jr as Tl,fI as Tn,LS as To,ON as Tr,X as Ts,YR as Tt,HB as U,kT as Ua,Ks as Uc,ak as Ui,Mn as Ul,RP as Un,Hb as Uo,PM as Ur,mh as Us,uR as Ut,JB as V,HT as Va,mc as Vc,zk as Vi,Rn as Vl,uF as Vn,Kb as Vo,LM as Vr,Th as Vs,fR as Vt,KB as W,OT as Wa,Hs as Wc,nk as Wi,Dn as Wl,LP as Wn,Bb as Wo,vM as Wr,ph as Ws,lR as Wt,kB as X,Kw as Xa,os as Xc,$D as Xi,Cn as Xl,EP as Xn,Eb as Xo,xj as Xr,Km as Xs,uL as Xt,NB as Y,iT as Ya,us as Yc,iO as Yi,En as Yl,OP as Yn,Tb as Yo,Sj as Yr,eh as Ys,fL as Yt,SB as Z,Uw as Za,is as Zc,qD as Zi,vn as Zl,wP as Zn,Cb as Zo,fj as Zr,Gm as Zs,lL as Zt,ZV as _,nD as _a,Hu as _c,KA as _i,Ui as _l,gI as _n,PC as _o,XN as _r,Hv as _s,bz as _t,dt as _u,lH as a,SD as aa,Wp as ac,cj as ai,So as al,eL as an,sw as ao,rP as ar,Sy as as,fB as at,pn as au,qV as b,zE as ba,Du as bc,HA as bi,wi as bl,pI as bn,sC as bo,zN as br,Bv as bs,lz as bt,ue as bu,aH as c,YE as ca,Id as cc,pj as ci,Ha as cl,JI as cn,nw as co,oP as cr,_y as cs,Xz as ct,mn as cu,pH as d,XE as da,Bd as dc,mj as di,Ta as dl,NI as dn,ew as do,WN as dr,my as ds,qz as dt,Ht as du,PD as ea,Bm as ec,aj as ei,Qo as el,iL as en,Fw as eo,_P as er,By as es,bB as et,on as eu,rH as f,$E as fa,_d as fc,nj as fi,va as fl,jI as fn,QC as fo,GN as fr,hy as fs,Gz as ft,jt as fu,eH as g,aD as ga,Qu as gc,GA as gi,F as gl,mI as gn,Q as go,JN as gr,iy as gs,Mz as gt,ft as gu,iH as h,lD as ha,Zu as hc,WA as hi,I as hl,EI as hn,ZC as ho,qN as hr,Qv as hs,Fz as ht,vt as hu,_H as i,bD as ia,Cm as ic,uj as ii,Ro as il,tL as in,gw as io,pP as ir,Cy as is,hB as it,Gt as iu,oV as j,cE as ja,Bl as jc,pA as ji,Er as jl,OF as jn,qx as jo,KM as jr,H_ as js,PR as jt,yV as k,bE as ka,uu as kc,bA as ki,Dr as kl,VF as kn,bS as ko,pN as kr,q_ as ks,BR as kt,uH as l,QE as la,Ld as lc,dj as li,Ia as ll,FI as ln,KC as lo,aP as lr,gy as ls,Yz as lt,Wt as lu,tH as m,tD as ma,ed as mc,qA as mi,$i as ml,DI as mn,VC as mo,YN as mr,uy as ms,Bz as mt,bt as mu,yH as n,ID as na,Om as nc,YA as ni,Ko as nl,XI as nn,ww as no,uP as nr,Ey as ns,gB as nt,rn as nu,hH as o,yD as oa,Ip as oc,oj as oi,z as ol,GI as on,ow as oo,nP as or,yy as os,eB as ot,fn as ou,nH as p,eD as pa,ud as pc,vj as pi,Qi as pl,TI as pn,XC as po,$N as pr,fy as ps,Wz as pt,Mt as pu,zB as q,ET as qa,ws as qc,DO as qi,Fn as ql,MP as qn,Mb as qo,Tj as qr,rh as qs,gL as qt,vH as r,jD as ra,Dm as rc,lj as ri,Ho as rl,$I as rn,xw as ro,fP as rr,wy as rs,_B as rt,Xt as ru,mH as s,oD as sa,$f as sc,_j as si,R as sl,qI as sn,aw as so,iP as sr,vy as ss,Zz as st,Yt as su,bH as t,LD as ta,km as tc,bj as ti,Xo as tl,nL as tn,Rw as to,vP as tr,Ty as ts,xB as tt,an as tu,cH as u,iD as ua,Rd as uc,rj as ui,Oa as ul,PI as un,GC as uo,sP as ur,py as us,Jz as ut,Zt as uu,XV as v,rD as va,ku as vc,JA as vi,Ai as vl,vI as vn,fC as vo,RN as vr,Vv as vs,dz as vt,Me as vu,bV as w,AE as wa,bu as wc,NA as wi,Kr as wl,xI as wn,zS as wo,MN as wr,av as ws,$R as wt,BV as x,BE as xa,Tu as xc,BA as xi,Ci as xl,hI as xn,oC as xo,FN as xr,Ev as xs,oz as xt,JV as y,RE as ya,H as yc,UA as yi,Ii as yl,bI as yn,cC as yo,BN as yr,Kv as ys,uz as yt,_e as yu,XB as z,YT as za,Rc as zc,Pk as zi,Un as zl,hF as zn,Gb as zo,BM as zr,Dh as zs,hR as zt};
36
+ //# debugId=5bf3c334-549d-46e4-b6b9-371ee761b87c