@lobu/runtime-server 24.8.0 → 24.9.0

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 (218) hide show
  1. package/dist/catalogs/connectors.json +83 -6
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +6 -2
  5. package/dist/connectors/github.ts +16 -3
  6. package/dist/connectors/market_quotes.ts +388 -91
  7. package/dist/connectors/postgres.ts +21 -14
  8. package/dist/connectors/x-dm-adapter.js +55 -21
  9. package/dist/connectors/x.ts +1 -1
  10. package/dist/db/migrations/20261109010000_workspace_navigation.sql +14 -0
  11. package/dist/db/migrations/20261110010000_view_resources.sql +11 -0
  12. package/dist/dependencies.bun.lock +61 -61
  13. package/dist/owletto/dist/assets/_-B2C9B2RM.js +2 -0
  14. package/dist/owletto/dist/assets/_-CjyiGzwB.js +3 -0
  15. package/dist/owletto/dist/assets/_agentId-DKHXGvS2.js +2 -0
  16. package/dist/owletto/dist/assets/_agentId-bna2tPsW.js +2 -0
  17. package/dist/owletto/dist/assets/_automationId-CowRFD4E.js +2 -0
  18. package/dist/owletto/dist/assets/_connectorKey._connectionId-dE6im18z.js +2 -0
  19. package/dist/owletto/dist/assets/{_connectorKey.index-DM5MTO8c.js → _connectorKey.index-DqwSv8Zs.js} +2 -2
  20. package/dist/owletto/dist/assets/{_conversationId-OJrZjd0o.js → _conversationId-zcs-S3dY.js} +2 -2
  21. package/dist/owletto/dist/assets/_eventId-BVOVizs4.js +2 -0
  22. package/dist/owletto/dist/assets/_owner-DsvIC94q.js +3 -0
  23. package/dist/owletto/dist/assets/_shape-CWjpzcvv.js +2 -0
  24. package/dist/owletto/dist/assets/_slug-DuCxYsJk.js +2 -0
  25. package/dist/owletto/dist/assets/_viewKey-BqVeHB6Z.js +2 -0
  26. package/dist/owletto/dist/assets/_viewKey-DzyOCG5U.js +2 -0
  27. package/dist/owletto/dist/assets/{accept-invitation-BC-ZIsrf.js → accept-invitation-k1u3zBcn.js} +2 -2
  28. package/dist/owletto/dist/assets/activity-route-view-jTBMW7a9.js +2 -0
  29. package/dist/owletto/dist/assets/{agent-connect-pages-CdDjrHjn.js → agent-connect-pages-D3mVM_q4.js} +4 -4
  30. package/dist/owletto/dist/assets/{agent-editor-form-CDAHRNWl.js → agent-editor-form-Bnc_q5WD.js} +2 -2
  31. package/dist/owletto/dist/assets/{agent-loading-shells-BupiSjR-.js → agent-loading-shells-xteN-pyK.js} +2 -2
  32. package/dist/owletto/dist/assets/{agent-permissions-matrix-ju7L2M0l.js → agent-permissions-matrix-C_ayr0pd.js} +2 -2
  33. package/dist/owletto/dist/assets/{agent-skill-context-B0ZYVE3n.js → agent-skill-context-r0O0BVOu.js} +2 -2
  34. package/dist/owletto/dist/assets/{agent-subpage-shell-ByU0xhXn.js → agent-subpage-shell-C2KpYdu3.js} +2 -2
  35. package/dist/owletto/dist/assets/{agent-thread-DiVKn1WX.js → agent-thread-Bv_chdPy.js} +3 -3
  36. package/dist/owletto/dist/assets/{app._appId-BQWElSoP.js → app._appId-BUcNaSMS.js} +2 -2
  37. package/dist/owletto/dist/assets/{assist-composer-igTXq3DL.js → assist-composer-B1LykXpD.js} +2 -2
  38. package/dist/owletto/dist/assets/automation-run-now-CjkJIkaZ.js +2 -0
  39. package/dist/owletto/dist/assets/{callback-Dmaio9CX.js → callback-kSLa4n5s.js} +2 -2
  40. package/dist/owletto/dist/assets/{card-rE4Ctuy6.js → card-C01y1O-W.js} +2 -2
  41. package/dist/owletto/dist/assets/{claim-BN17CPYh.js → claim-Dnux9Lqf.js} +2 -2
  42. package/dist/owletto/dist/assets/{client-activity-scopes-B7xVaUA-.js → client-activity-scopes-BBIq16tG.js} +2 -2
  43. package/dist/owletto/dist/assets/{client-rows-B3LULJxW.js → client-rows-DGh1O-Fu.js} +2 -2
  44. package/dist/owletto/dist/assets/{clients-CydgUHrc.js → clients-BCvjAJDT.js} +2 -2
  45. package/dist/owletto/dist/assets/{code-editor-UppEMWpt.js → code-editor-BdRMYojw.js} +2 -2
  46. package/dist/owletto/dist/assets/connect-DZeFSGIH.js +2 -0
  47. package/dist/owletto/dist/assets/connect-menu-D4w-JhJW.js +2 -0
  48. package/dist/owletto/dist/assets/connect._clientId-IZEMQJ64.js +2 -0
  49. package/dist/owletto/dist/assets/{connected._clientId-CaF-ZWlZ.js → connected._clientId-BsDzltNz.js} +2 -2
  50. package/dist/owletto/dist/assets/{connection-D8ZAMHBT.js → connection-C7glVpPE.js} +2 -2
  51. package/dist/owletto/dist/assets/{connection-feed-detail-CJYqryAV.js → connection-feed-detail-CJju0qiw.js} +2 -2
  52. package/dist/owletto/dist/assets/{connector-page-shell-C23dWdKz.js → connector-page-shell-BeuyjiB2.js} +2 -2
  53. package/dist/owletto/dist/assets/{connector-provenance-CW4CXtCz.js → connector-provenance-B2C2cjBg.js} +2 -2
  54. package/dist/owletto/dist/assets/{connectors-Bp08_KPq.js → connectors-DSQ5AWPf.js} +2 -2
  55. package/dist/owletto/dist/assets/{consent-_PpYI1cT.js → consent-B6Aw_89N.js} +2 -2
  56. package/dist/owletto/dist/assets/{copy-button-1ALlvZU1.js → copy-button-BhXeXLIm.js} +2 -2
  57. package/dist/owletto/dist/assets/{core.esm-6koO33th.js → core.esm-CJUp2aNZ.js} +3 -3
  58. package/dist/owletto/dist/assets/create-CWcza8NT.js +2 -0
  59. package/dist/owletto/dist/assets/{create-kUevP9Xx.js → create-DUlRsFNn.js} +2 -2
  60. package/dist/owletto/dist/assets/{create-automation-form-BhujNbRr.js → create-automation-form-D141prEG.js} +3 -3
  61. package/dist/owletto/dist/assets/{create-Drx9tcnG.js → create-bGOYifof.js} +2 -2
  62. package/dist/owletto/dist/assets/create._connectorKey-Ds4tpwHP.js +2 -0
  63. package/dist/owletto/dist/assets/{custom-guardrail-edits-B_aCgvoZ.js → custom-guardrail-edits-DuQ28xv3.js} +2 -2
  64. package/dist/owletto/dist/assets/{definition-comparison-3zKUSTt8.js → definition-comparison-BUDNuAN_.js} +2 -2
  65. package/dist/owletto/dist/assets/{detail-page-skeleton-BmxqqIsH.js → detail-page-skeleton-BRHaq5Sj.js} +2 -2
  66. package/dist/owletto/dist/assets/{device-D2eUt_nr.js → device-D3fzoIrM.js} +2 -2
  67. package/dist/owletto/dist/assets/{device-pin-tombstone-BFPbTM_o.js → device-pin-tombstone-BIM-ziCH.js} +2 -2
  68. package/dist/owletto/dist/assets/{device._deviceId-Dqtmb1Xp.js → device._deviceId-BnPqTgK1.js} +2 -2
  69. package/dist/owletto/dist/assets/{dynamic-schema-form-D3KnzCsW.js → dynamic-schema-form-OkIZImgp.js} +2 -2
  70. package/dist/owletto/dist/assets/entity-options-CpeX7iiX.js +2 -0
  71. package/dist/owletto/dist/assets/entity-page-Cjc8oXA2.js +2 -0
  72. package/dist/owletto/dist/assets/{entity-pages-DJNSQrfB.js → entity-pages-18xSANrS.js} +2 -2
  73. package/dist/owletto/dist/assets/entity-schema-graph-uwZ-P0t8.js +2 -0
  74. package/dist/owletto/dist/assets/{entity-type-page-CouHZbc9.js → entity-type-page-MgZ7_0oh.js} +2 -2
  75. package/dist/owletto/dist/assets/event-detail-D6AH6a2C.js +2 -0
  76. package/dist/owletto/dist/assets/events-feed-BI7wNRUY.js +2 -0
  77. package/dist/owletto/dist/assets/filter-editors-DDTwyYt0.js +3 -0
  78. package/dist/owletto/dist/assets/{full-page-spinner-B7A6Ycyi.js → full-page-spinner-DWo519BU.js} +2 -2
  79. package/dist/owletto/dist/assets/index-9tTjJo_J.css +1 -0
  80. package/dist/owletto/dist/assets/{index-B-dZruj6.js → index-BW7IFKXC.js} +2 -2
  81. package/dist/owletto/dist/assets/{index-C7QM3aqU.js → index-BYcFrinP.js} +2 -2
  82. package/dist/owletto/dist/assets/index-BhJsTy-C.js +2 -0
  83. package/dist/owletto/dist/assets/index-CEcsgXDj.js +2 -0
  84. package/dist/owletto/dist/assets/index-CPscKk2u.js +2 -0
  85. package/dist/owletto/dist/assets/{index-DXfYVs5m.js → index-Cd8jMsz8.js} +2 -2
  86. package/dist/owletto/dist/assets/index-CdDNNAx2.js +7906 -0
  87. package/dist/owletto/dist/assets/index-CfJ2-EpK.js +2 -0
  88. package/dist/owletto/dist/assets/{index-BztXeLBN.js → index-D1UCJQl1.js} +2 -2
  89. package/dist/owletto/dist/assets/index-D5DM4g2w.js +2 -0
  90. package/dist/owletto/dist/assets/index-DmqnKGqW.js +2 -0
  91. package/dist/owletto/dist/assets/index-DznAbTOF.js +2 -0
  92. package/dist/owletto/dist/assets/{json-diff-CJK-gzCt.js → json-diff-C-WQqyIf.js} +2 -2
  93. package/dist/owletto/dist/assets/{list-skeleton-bQAZ0hQp.js → list-skeleton-0B1bTrAK.js} +2 -2
  94. package/dist/owletto/dist/assets/{login-DLqL54Rk.js → login-CH7P2AyR.js} +2 -2
  95. package/dist/owletto/dist/assets/{logout-H0F3IfiO.js → logout-D474YsYQ.js} +2 -2
  96. package/dist/owletto/dist/assets/{member-scope-gate-Doic_6qX.js → member-scope-gate-CH_0jHiM.js} +2 -2
  97. package/dist/owletto/dist/assets/memory-browse-page-Ba4aYavw.js +74 -0
  98. package/dist/owletto/dist/assets/{model-selector-BrfaDwIg.js → model-selector-XYmk7Iru.js} +2 -2
  99. package/dist/owletto/dist/assets/needs-you-list-Bd4iiiqm.js +2 -0
  100. package/dist/owletto/dist/assets/new-BOsrRqp8.js +2 -0
  101. package/dist/owletto/dist/assets/{new-5GkxlOuQ.js → new-CJ6TF3Vc.js} +2 -2
  102. package/dist/owletto/dist/assets/{new-BiA4DGoN.js → new-DGPOjak2.js} +2 -2
  103. package/dist/owletto/dist/assets/new-Q0XqiZq2.js +2 -0
  104. package/dist/owletto/dist/assets/{organization-CLrcmgNK.js → organization-hD_Z6TSd.js} +2 -2
  105. package/dist/owletto/dist/assets/peek-pane-content-Cc8YX1oy.js +2 -0
  106. package/dist/owletto/dist/assets/{pending-seed-DYYOoCvj.js → pending-seed-D7-ld7as.js} +2 -2
  107. package/dist/owletto/dist/assets/{proposal-review-shell-BVwOMoq9.js → proposal-review-shell-BWRJidwb.js} +2 -2
  108. package/dist/owletto/dist/assets/public-shell-ready-CRyAZATw.js +2 -0
  109. package/dist/owletto/dist/assets/record-activity-9ux6SfCd.js +2 -0
  110. package/dist/owletto/dist/assets/{record-session-KuEDuF3S.js → record-session-ClKBr1_C.js} +2 -2
  111. package/dist/owletto/dist/assets/{renderer-ucwCQmBk.js → renderer-DZ0w2k2r.js} +2 -2
  112. package/dist/owletto/dist/assets/{reset-password-BkiAmXZW.js → reset-password-D2RfrEVZ.js} +2 -2
  113. package/dist/owletto/dist/assets/{run-initiator-8vdkq-3o.js → run-initiator-B8IRlRd-.js} +2 -2
  114. package/dist/owletto/dist/assets/runs-CuC7WMtd.js +2 -0
  115. package/dist/owletto/dist/assets/runs-list-8gUPWjP4.js +2 -0
  116. package/dist/owletto/dist/assets/{schema-value-CefbtPIY.js → schema-value-k19Ata7u.js} +3 -3
  117. package/dist/owletto/dist/assets/scoped-feed-bar-L7h-Ca4u.js +2 -0
  118. package/dist/owletto/dist/assets/{settings-DvzkRYQy.js → settings-BZqntV3E.js} +2 -2
  119. package/dist/owletto/dist/assets/{source-record-panels-LJIWGtHb.js → source-record-panels-C4UItfdk.js} +2 -2
  120. package/dist/owletto/dist/assets/{status-variants-BxHtpMOj.js → status-variants-BR_iGWN5.js} +2 -2
  121. package/dist/owletto/dist/assets/subDays-hOwerOLo.js +2 -0
  122. package/dist/owletto/dist/assets/{table-1O-ik4_O.js → table-C3DMoL4K.js} +2 -2
  123. package/dist/owletto/dist/assets/use-automations-CdtiVLCv.js +2 -0
  124. package/dist/owletto/dist/assets/{use-login-redirect-CfCbEeJR.js → use-login-redirect-CYlVkAhE.js} +2 -2
  125. package/dist/owletto/dist/assets/{use-mention-search-CA-evCDf.js → use-mention-search-CtbixPEE.js} +2 -2
  126. package/dist/owletto/dist/assets/view-param-filters-BdN8OU35.js +2 -0
  127. package/dist/owletto/dist/assets/{views-access-required-BerT4Z1d.js → views-access-required-CvIIxdS_.js} +2 -2
  128. package/dist/owletto/dist/index.html +19 -12
  129. package/dist/server-main.bundle.mjs +4245 -2432
  130. package/npm-shrinkwrap.json +328 -328
  131. package/package.json +1 -1
  132. package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
  133. package/vendor/connector-sdk/package.json +1 -1
  134. package/vendor/core/dist/classify-error.d.ts +3 -4
  135. package/vendor/core/dist/classify-error.js +8 -8
  136. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  137. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  138. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
  139. package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
  140. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  141. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  142. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  143. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  144. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  145. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  146. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  147. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  148. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  149. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  150. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  151. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  152. package/vendor/core/dist/contracts/tools/view-host.js +28 -1
  153. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  154. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  155. package/vendor/core/dist/errors.d.ts +17 -24
  156. package/vendor/core/dist/errors.js +17 -24
  157. package/vendor/core/dist/types.d.ts +0 -6
  158. package/vendor/core/package.json +11 -1
  159. package/vendor/views/dist/api.d.ts +30 -5
  160. package/vendor/views/dist/api.js +22 -8
  161. package/vendor/views/dist/bridge.d.ts +17 -0
  162. package/vendor/views/dist/bridge.js +49 -1
  163. package/vendor/views/dist/components.d.ts +27 -5
  164. package/vendor/views/dist/components.js +57 -7
  165. package/vendor/views/dist/embed.d.ts +98 -0
  166. package/vendor/views/dist/embed.js +418 -0
  167. package/vendor/views/dist/index.d.ts +3 -1
  168. package/vendor/views/dist/index.js +1 -0
  169. package/vendor/views/package.json +1 -1
  170. package/dist/owletto/dist/assets/_-B0tmXZ86.js +0 -2
  171. package/dist/owletto/dist/assets/_-DwXULq4r.js +0 -3
  172. package/dist/owletto/dist/assets/_agentId-B1dNkhnr.js +0 -2
  173. package/dist/owletto/dist/assets/_agentId-sYjvnBaB.js +0 -2
  174. package/dist/owletto/dist/assets/_automationId-Bnw_CnT_.js +0 -2
  175. package/dist/owletto/dist/assets/_connectorKey._connectionId-D7Z8DQ-B.js +0 -2
  176. package/dist/owletto/dist/assets/_eventId-CfB0_2zK.js +0 -2
  177. package/dist/owletto/dist/assets/_owner-BDvTUY0a.js +0 -3
  178. package/dist/owletto/dist/assets/_shape-BZidoJMB.js +0 -2
  179. package/dist/owletto/dist/assets/_slug-R989vOiM.js +0 -2
  180. package/dist/owletto/dist/assets/_viewKey-BDUSrpe5.js +0 -2
  181. package/dist/owletto/dist/assets/_viewKey-BnFqh5-t.js +0 -2
  182. package/dist/owletto/dist/assets/activity-route-view-CN2dOiCD.js +0 -2
  183. package/dist/owletto/dist/assets/automation-detail-content-BJwRU6qT.js +0 -2
  184. package/dist/owletto/dist/assets/connect-OdHpIVV9.js +0 -2
  185. package/dist/owletto/dist/assets/connect-menu-B9u86bb2.js +0 -2
  186. package/dist/owletto/dist/assets/connect._clientId-EI1tcdSE.js +0 -2
  187. package/dist/owletto/dist/assets/connector-boxes-BWPXijAk.js +0 -2
  188. package/dist/owletto/dist/assets/create-DULVO0HS.js +0 -2
  189. package/dist/owletto/dist/assets/create._connectorKey-N6fhcIPy.js +0 -2
  190. package/dist/owletto/dist/assets/entity-options-IUdQ-64R.js +0 -2
  191. package/dist/owletto/dist/assets/entity-page-B3Im65EI.js +0 -2
  192. package/dist/owletto/dist/assets/event-detail-CvaRN1qB.js +0 -2
  193. package/dist/owletto/dist/assets/events-feed-DwOkLk6A.js +0 -2
  194. package/dist/owletto/dist/assets/filter-editors-DQ5V4Cvh.js +0 -2
  195. package/dist/owletto/dist/assets/home-stream-Bg97PUBJ.js +0 -2
  196. package/dist/owletto/dist/assets/home-toolbar-CpCcHA6z.js +0 -2
  197. package/dist/owletto/dist/assets/index-9PGnv4-5.js +0 -2
  198. package/dist/owletto/dist/assets/index-C2TCKJDP.js +0 -7901
  199. package/dist/owletto/dist/assets/index-CWn46a4y.js +0 -2
  200. package/dist/owletto/dist/assets/index-CxJONizf.js +0 -2
  201. package/dist/owletto/dist/assets/index-DJhb3li3.js +0 -2
  202. package/dist/owletto/dist/assets/index-DY-YGnCe.js +0 -2
  203. package/dist/owletto/dist/assets/index-j3v7ITPb.js +0 -2
  204. package/dist/owletto/dist/assets/index-oiy6ygaI.js +0 -2
  205. package/dist/owletto/dist/assets/index-pEgtAY1t.js +0 -2
  206. package/dist/owletto/dist/assets/index-xAvK3IyQ.css +0 -1
  207. package/dist/owletto/dist/assets/memory-browse-page-CUea2Llz.js +0 -74
  208. package/dist/owletto/dist/assets/new-M-MX_T5C.js +0 -2
  209. package/dist/owletto/dist/assets/peek-pane-content-B29OcHwm.js +0 -2
  210. package/dist/owletto/dist/assets/public-shell-ready-BbjPgh3k.js +0 -2
  211. package/dist/owletto/dist/assets/record-activity-BCpNKaUo.js +0 -2
  212. package/dist/owletto/dist/assets/runs-B_iywKWb.js +0 -2
  213. package/dist/owletto/dist/assets/runs-list-CJJFRhTl.js +0 -2
  214. package/dist/owletto/dist/assets/schema-type-editor-panel-C4e8pq1A.js +0 -2
  215. package/dist/owletto/dist/assets/scoped-feed-bar-CapleZvS.js +0 -2
  216. package/dist/owletto/dist/assets/subDays-DwIOMzYC.js +0 -2
  217. package/dist/owletto/dist/assets/use-automations-lV8PuE8L.js +0 -2
  218. package/dist/owletto/dist/assets/view-param-filters-Bp84PUMd.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{j0 as e,j as o,aT as n}from"./index-CdDNNAx2.js";import{A as a}from"./agent-connect-pages-D3mVM_q4.js";import"./connector-page-shell-BeuyjiB2.js";import"./copy-button-BhXeXLIm.js";import"./clients-BCvjAJDT.js";import"./client-rows-DGh1O-Fu.js";function j(){const{owner:t}=e.useParams();return o.jsx(n,{owner:t,children:({ownerSlug:r})=>o.jsx(a,{owner:r})})}export{j as component};
2
+ //# sourceMappingURL=index-CfJ2-EpK.js.map
@@ -1,2 +1,2 @@
1
- import{az as l,n as c,j as e,m as t,L as m,C as d,aA as x}from"./index-C2TCKJDP.js";function u({owner:r}){const{destinations:a}=l(),{isMember:i,isLoading:o,org:n}=c(r);return e.jsxs("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-6 px-4 pt-4 pb-8",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Settings"}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n.name}):null]}),o?e.jsx("div",{role:"status","aria-label":"Loading settings","aria-busy":"true",children:e.jsx("div",{"aria-hidden":"true",children:a.map(s=>e.jsx("div",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs("div",{className:"flex min-h-12 items-center gap-3 px-3",children:[e.jsx(t,{className:"h-4 w-4 shrink-0 rounded-none"}),e.jsx(t,{className:"h-4 w-24 rounded-none"})]})},s.key))})}):i?e.jsx("nav",{"aria-label":"Settings sections",children:e.jsx("ul",{children:a.map(s=>e.jsx("li",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs(m,{to:s.to,params:s.params,search:s.search,className:"flex min-h-12 items-center gap-3 rounded-md px-3 text-sm font-medium transition-colors hover:bg-sidebar-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx(s.icon,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.label}),e.jsx(d,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})},s.key))})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace settings are available to members."})]})}function p(){const{owner:r}=x.useParams();return e.jsx(u,{owner:r})}export{p as component};
2
- //# sourceMappingURL=index-BztXeLBN.js.map
1
+ import{az as l,n as c,j as e,m as t,L as m,C as d,aA as x}from"./index-CdDNNAx2.js";function u({owner:r}){const{destinations:a}=l(),{isMember:i,isLoading:o,org:n}=c(r);return e.jsxs("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-6 px-4 pt-4 pb-8",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Settings"}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n.name}):null]}),o?e.jsx("div",{role:"status","aria-label":"Loading settings","aria-busy":"true",children:e.jsx("div",{"aria-hidden":"true",children:a.map(s=>e.jsx("div",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs("div",{className:"flex min-h-12 items-center gap-3 px-3",children:[e.jsx(t,{className:"h-4 w-4 shrink-0 rounded-none"}),e.jsx(t,{className:"h-4 w-24 rounded-none"})]})},s.key))})}):i?e.jsx("nav",{"aria-label":"Settings sections",children:e.jsx("ul",{children:a.map(s=>e.jsx("li",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs(m,{to:s.to,params:s.params,search:s.search,className:"flex min-h-12 items-center gap-3 rounded-md px-3 text-sm font-medium transition-colors hover:bg-sidebar-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx(s.icon,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.label}),e.jsx(d,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})},s.key))})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace settings are available to members."})]})}function p(){const{owner:r}=x.useParams();return e.jsx(u,{owner:r})}export{p as component};
2
+ //# sourceMappingURL=index-D1UCJQl1.js.map
@@ -0,0 +1,2 @@
1
+ import{aB as e,aC as s,j as t,ar as p,as as a}from"./index-CdDNNAx2.js";import{A as n}from"./activity-route-view-jTBMW7a9.js";import{E as c}from"./events-feed-BI7wNRUY.js";import"./record-activity-9ux6SfCd.js";import"./filter-editors-DDTwyYt0.js";import"./subDays-hOwerOLo.js";import"./runs-CuC7WMtd.js";import"./event-kind-options-fHAIXu24.js";import"./source-record-panels-C4UItfdk.js";import"./run-initiator-B8IRlRd-.js";import"./list-skeleton-0B1bTrAK.js";import"./use-automations-CdtiVLCv.js";import"./clients-BCvjAJDT.js";import"./client-activity-scopes-BBIq16tG.js";import"./client-rows-DGh1O-Fu.js";import"./renderer-DZ0w2k2r.js";import"./schema-value-k19Ata7u.js";import"./card-C01y1O-W.js";import"./table-C3DMoL4K.js";import"./agent-loading-shells-xteN-pyK.js";import"./member-scope-gate-CH_0jHiM.js";import"./needs-you-list-Bd4iiiqm.js";import"./entity-schema-graph-uwZ-P0t8.js";import"./feed-event-kinds-BYuZCoU4.js";import"./public-shell-ready-CRyAZATw.js";import"./definition-comparison-BUDNuAN_.js";import"./json-diff-C-WQqyIf.js";import"./code-editor-BdRMYojw.js";import"./index-Vcq4gwWv.js";import"./copy-button-BhXeXLIm.js";import"./device-automation-Dp3faMvp.js";function G(){const{owner:o}=e.useParams(),i=e.useSearch();if(o==="me"){const r=s(i),m={sortBy:"date",sortOrder:"desc",...r.contentIds?.length?{contentIds:r.contentIds}:{clientIds:r.clientIds,mcpActivityId:r.mcpActivityId}};return t.jsx(p,{className:"gap-6 pt-2.5 pb-8",children:t.jsxs(a,{className:"flex flex-col gap-6",children:[t.jsx("h1",{className:"text-lg font-semibold",children:"Your MCP activity"}),t.jsx(c,{organizationId:null,ownerSlug:"me",filters:m})]})})}return t.jsx(n,{owner:o,search:i})}export{G as component};
2
+ //# sourceMappingURL=index-D5DM4g2w.js.map
@@ -0,0 +1,2 @@
1
+ import{j as n,i as Z,aD as ee,c as Y,r as y,aE as H,aF as ne,aG as se,B as T,aH as oe,aI as ae,aJ as te,aK as re,aL as ie,aM as ce,aN as B,aO as V,aP as F,aQ as q,aR as de,aS as W,aT as le,aU as me,aV as pe,aW as ue,aX as he,aY as fe,aZ as xe,a_ as ve,a$ as be,as as U,b0 as ge,b1 as ye,b2 as je,b3 as _e,b4 as Ce,b5 as Ne,b6 as ke,b7 as Ie,b8 as Le,b9 as G,ba as Ee,bb as $e,bc as we,L as M,bd as z,be as X,bf as Oe,bg as Re,bh as Se,bi as De,bj as Pe,bk as Me,bl as Ae,bm as Ke}from"./index-CdDNNAx2.js";import{L as Te}from"./list-skeleton-0B1bTrAK.js";const Be="overflow-hidden rounded-lg border divide-y";function Fe({header:o,action:r}){return n.jsxs("div",{className:Z("flex items-center",ee),children:[n.jsx("div",{className:"min-w-0 flex-1",children:o}),r?n.jsx("div",{className:"shrink-0 pr-3",children:r}):null]})}function We({ownerSlug:o,catalog:r,trigger:i}){const p=Y(),[u,c]=y.useState(!1),N=y.useMemo(()=>new Map(r.map(t=>[t.key,t])),[r]),j=y.useMemo(()=>r.filter(t=>!H(t)).sort((t,f)=>t.name.localeCompare(f.name)),[r]),h=t=>{c(!1),p(t?{to:"/$owner/connectors/create/$connectorKey",params:{owner:o,connectorKey:t}}:{to:"/$owner/connectors/create",params:{owner:o}})};return n.jsxs(ne,{open:u,onOpenChange:c,children:[n.jsx(se,{asChild:!0,children:i??n.jsxs(T,{size:"sm",className:"h-8 shrink-0 justify-start text-xs",children:[n.jsx(oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Add connector"]})}),n.jsx(ae,{align:"end",className:"w-72 p-0",children:n.jsxs(te,{children:[n.jsx(re,{placeholder:"Search connectors…"}),n.jsxs(ie,{children:[n.jsx(ce,{children:"No connector matches."}),n.jsx(B,{children:j.map(t=>{const f=V(t.key,N,{name:t.name});return n.jsxs(F,{value:`${t.name} ${t.key}`,onSelect:()=>h(t.key),className:"gap-2",children:[n.jsx(q,{icon:f.icon,iconUrl:f.iconUrl,name:f.name,faviconDomain:f.faviconDomain,className:"h-5 w-5 shrink-0 rounded text-[9px]"}),n.jsx("span",{className:"truncate",children:t.name}),t.installed?n.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"Added"}):null]},t.key)})}),n.jsx(de,{}),n.jsx(B,{children:n.jsx(F,{value:"browse all connectors",onSelect:()=>h(),children:"Browse all connectors…"})})]})]})})]})}function qe(){const{owner:o}=W.useParams(),{filter:r}=W.useSearch();return n.jsx(le,{owner:o,children:i=>n.jsx(Ue,{ownerSlug:i.ownerSlug,organizationId:i.organizationId,isWorkspaceLoading:i.isWorkspaceLoading,requestedFilter:r})})}function Ue({ownerSlug:o,organizationId:r,isWorkspaceLoading:i,requestedFilter:p}){const{data:u=[],isLoading:c,isError:N,refetch:j}=me(r??""),{data:h=[],isLoading:t,isError:f,refetch:A}=pe(r??""),{data:R=[]}=ue(r,{}),{data:I=[],isLoading:L,isError:_,refetch:w}=he(),{data:E=[]}=fe(),{data:S,isLoading:D,isError:s,refetch:l}=xe(),{data:C=[],isLoading:x,isError:$,refetch:v}=ve(),e=i||c||t||L||D||x,a=S?.sandboxes??[],d=y.useMemo(()=>C.filter(m=>be(m,o)),[C,o]);return N||f||_||s||$?n.jsx(U,{children:n.jsxs("div",{role:"alert",className:"space-y-2",children:[n.jsx("p",{children:"Could not load the connector inventory."}),n.jsx(T,{variant:"outline",size:"sm",onClick:()=>{Promise.all([j(),A(),w(),l(),v()])},children:"Retry"})]})}):n.jsx(U,{className:"flex flex-1 flex-col gap-6",children:n.jsx(Ge,{ownerSlug:o,isContentLoading:e,groups:u,installedDefs:h,authProfiles:R,inferenceProviders:I,inferenceCatalog:E,sandboxes:a,devices:d,requestedFilter:p})})}function Ge({ownerSlug:o,isContentLoading:r,groups:i,installedDefs:p,authProfiles:u,inferenceProviders:c,inferenceCatalog:N,sandboxes:j,devices:h,requestedFilter:t}){const f=Y(),A=y.useMemo(()=>new Map(p.map(s=>[s.key,s])),[p]),R=t??"all",I=y.useMemo(()=>{const s=new Map(i.map(e=>[e.connector_key,e])),l=new Map;for(const e of p)l.set(e.key,e);for(const e of i)l.has(e.connector_key)||l.set(e.connector_key,{key:e.connector_key,name:e.connector_name??e.connector_key,description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1,favicon_domain:e.favicon_domain,facets:e.facets});const C=ge(c).filter((e,a,d)=>d.findIndex(m=>m.provider.kind===e.provider.kind)===a).map(e=>({connector:{...e.connector,key:`${ye}${e.provider.kind}`,name:N.find(a=>a.slug===e.provider.kind)?.displayName??e.provider.kind},group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:!1,provider:e.provider,sandbox:void 0,device:void 0,deviceFamily:void 0})),x=je(j).filter((e,a,d)=>d.findIndex(m=>m.sandbox.providerKind===e.sandbox.providerKind)===a).map(e=>({connector:{...e.connector,key:`${_e}${e.sandbox.providerKind}`,name:Ce(e.sandbox.providerKind)},group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:j.some(a=>a.providerKind===e.sandbox.providerKind&&!a.connected),provider:void 0,sandbox:e.sandbox,device:void 0,deviceFamily:void 0})),$=Ne(h,i,o).map(e=>({connector:e.connector,group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:!1,isDevice:!0,provider:void 0,sandbox:void 0,device:e.device,deviceFamily:e}));return[...Array.from(l.values()).filter(e=>e.installed||(s.get(e.key)?.connection_count??0)>0).filter(e=>!H(e)).map(e=>{const a=s.get(e.key),d=ke(e.auth_schema),m=u.reduce((b,g)=>(g.connector_key!==e.key||(b[g.profile_kind]+=1),b),{env:0,oauth_app:0,oauth_account:0,browser_session:0}),O=Ie(e,a),P=h.some(b=>b.connectors.some(g=>g.organization_slug===o&&g.connector_key===e.key)),K=Ye(e,a,d,m);return{connector:e,group:a,profileCounts:m,facets:O,needsSetup:K,isDevice:P,provider:void 0,sandbox:void 0,device:void 0,deviceFamily:void 0}}),...C,...x,...$].sort((e,a)=>e.needsSetup&&!a.needsSetup?-1:!e.needsSetup&&a.needsSetup?1:e.connector.name.localeCompare(a.connector.name))},[o,u,h,i,p,c,N,j]),L=y.useMemo(()=>{const s=Le.filter(l=>l!=="all"&&I.some(C=>G(C,l)));return s.length>1?["all",...s]:[]},[I]),_=L.includes(R)?R:"all",w=y.useMemo(()=>I.filter(s=>G(s,_)),[I,_]),E=y.useMemo(()=>_==="all"?Ee(o,h,$e()):[],[_,o,h]),S=n.jsx(We,{ownerSlug:o,catalog:p});if(r)return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex justify-end",children:S}),n.jsx(Te,{label:"Loading connectors",rows:6})]});const D=s=>{f({to:"/$owner/connectors",params:{owner:o},search:l=>({...l,filter:s==="all"?void 0:s}),replace:!0})};return n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"What your agents can reach — data, tools, models, and runtimes."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5",children:[L.map(s=>n.jsx(T,{type:"button",variant:_===s?"secondary":"ghost","aria-pressed":_===s,size:"sm",className:"h-7 px-2 text-xs",onClick:()=>D(s),children:we[s]},s)),L.length===0&&w.length===0&&E.length>0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing connected yet — set up one of the apps below."}):null]}),n.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:S})]}),E.length>0?n.jsx("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-dashed bg-border sm:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]",children:E.map(s=>n.jsxs(M,{to:"/$owner/connectors/app/$appId",params:{owner:o,appId:s.id},title:s.tagline,className:"flex min-w-0 items-center gap-2 bg-background px-3 py-2.5 text-muted-foreground transition-colors last:odd:col-span-2 hover:bg-accent/50 hover:text-foreground sm:last:odd:col-span-1",children:[n.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center text-muted-foreground",children:s.icon}),n.jsx("span",{className:"truncate text-sm font-medium",children:s.name})]},s.id))}):null,w.length===0?L.length>0?n.jsx(z,{icon:X.connectors.icon,title:"No connectors match this filter",description:"Try another capability.",secondaryActionLabel:"Show all",secondaryOnAction:()=>D("all")}):E.length>0?null:n.jsx(z,{icon:X.connectors.icon,title:"No connectors yet",description:"Connect your first connector to this workspace."}):n.jsx("div",{className:Be,children:w.map(({connector:s,group:l,facets:C,profileCounts:x,needsSetup:$,provider:v,sandbox:e,device:a,deviceFamily:d})=>{const m=V(s.key,A,{name:s.name,iconUrl:v?N.find(k=>k.slug===v.kind)?.iconUrl:void 0,faviconDomain:s.favicon_domain??l?.favicon_domain??(e?Oe(e.providerKind):void 0)}),O=x.oauth_account+x.browser_session,P=l?.connection_count??0,K=a?`${d?.devices.length??1} ${a.platform==="chrome-extension"?d?.devices.length===1?"profile":"profiles":d?.devices.length===1?"device":"devices"} · ${d?.devices.filter(k=>k.online).length??0} online`:v?ze(c.filter(k=>k.kind===v.kind).length,"configured account","configured accounts"):e?`${j.filter(k=>k.providerKind===e.providerKind).length} instances`:[`${P} ${P===1?"connection":"connections"}`,O>0?`${O} ${O===1?"saved authorization":"saved authorizations"}`:null,x.oauth_app>0?`${x.oauth_app} OAuth app${x.oauth_app===1?"":"s"}`:null].filter(Boolean).join(" · "),b=Xe,g=n.jsx(Re,{mark:a?n.jsx(Pe,{platform:Me(a)}):n.jsx(q,{icon:m.icon,iconUrl:m.iconUrl,name:m.name,faviconDomain:m.faviconDomain,className:"h-7 w-7 text-[10px]"}),name:m.name,tone:$?"amber":null,details:n.jsx(Se,{parts:[$?"Needs setup":null,De(C).join(", "),K]})}),J=d?.appId?n.jsx(M,{to:"/$owner/connectors/app/$appId",params:{owner:o,appId:d.appId},className:b,children:g},s.key):a?n.jsx(M,{to:"/$owner/connectors/device/$deviceId",params:{owner:o,deviceId:a.id},className:b,children:g},s.key):n.jsx(M,{to:"/$owner/connectors/$connectorKey",params:{owner:o,connectorKey:s.key},search:v||e?{instances:!0}:{},className:b,children:g},s.key),Q=!v&&!e&&!a&&!d;return n.jsx(Fe,{header:J,action:Q?n.jsx(Ke,{ownerSlug:o,connectorKey:s.key,iconOnly:!0}):void 0},s.key)})})]})}function ze(o,r,i){return`${o} ${o===1?r:i}`}const Xe=Ae;function Ye(o,r,i,p){if((r?.connection_count??0)>0)return!1;const u=i.some(c=>c.type==="none");return!!(!u&&i.some(c=>c.type==="oauth")&&p.oauth_app===0||!u&&i.some(c=>c.type==="env_keys")&&p.env===0||!u&&i.some(c=>c.type==="app_installation")&&!r||o.required_capability&&!r)}export{qe as component};
2
+ //# sourceMappingURL=index-DmqnKGqW.js.map
@@ -0,0 +1,2 @@
1
+ import{ie as n,j as s,ig as r}from"./index-CdDNNAx2.js";function i(){const{owner:e}=n.useParams(),{connector:o,install:t}=n.useSearch();return s.jsx(r,{owner:e,initialConnectorKey:o||t})}export{i as component};
2
+ //# sourceMappingURL=index-DznAbTOF.js.map
@@ -1,4 +1,4 @@
1
- import{j as C,B as Ue,X as Ve,r as H,e6 as qe,C as ze,i as _e,dN as $e}from"./index-C2TCKJDP.js";import{T as be,P as ve,E as S,S as U,g as Ke,V as Qe,F as Be,a as K,R as P,D as M,G as Q,W as Z,l as Ze,h as Xe,b as Ye,c as et,d as tt,e as le,s as nt,j as rt,f as it}from"./code-editor-UppEMWpt.js";function It({sources:t,onRemove:e,disabled:n,wrap:l=!1}){return C.jsx(C.Fragment,{children:t.length>0?C.jsx("ul",{className:"space-y-2",children:t.map(i=>C.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("div",{className:"truncate font-mono text-xs font-medium",children:i.name}),C.jsx("div",{className:l?"whitespace-pre-wrap break-words text-xs text-muted-foreground":"truncate text-xs text-muted-foreground",children:i.query})]}),e?C.jsx(Ue,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${i.name}`,disabled:n,onClick:()=>e?.(i),children:C.jsx(Ve,{className:"h-3.5 w-3.5"})}):null]},i.query))}):null})}class x{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new x(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function j(t,e,n,l,i,r){if(t==l)return[];let o=Y(t,e,n,l,i,r),a=ee(t,e+o,n,l,i+o,r);e+=o,n-=a,i+=o,r-=a;let f=n-e,c=r-i;if(!f||!c)return[new x(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new x(e,e+d,i,i),new x(e+d+c,n,r,r)]}else if(c>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new x(e,e,i,i+d),new x(n,n,i+d+f,r)]}if(f==1||c==1)return[new x(e,n,i,r)];let s=Me(t,e,n,l,i,r);if(s){let[d,u,h]=s;return j(t,e,d,l,i,u).concat(j(t,d+h,n,l,u+h,r))}return lt(t,e,n,l,i,r)}let G=1e9,R=0,X=!1;function lt(t,e,n,l,i,r){let o=n-e,a=r-i;if(G<1e9&&Math.min(o,a)>G*16||R>0&&Date.now()>R)return Math.min(o,a)>G*64?[new x(e,n,i,r)]:oe(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);q.reset(f),z.reset(f);let c=(h,m)=>t.charCodeAt(e+h)==l.charCodeAt(i+m),s=(h,m)=>t.charCodeAt(n-h-1)==l.charCodeAt(r-m-1),d=(o-a)%2!=0?z:null,u=d?null:q;for(let h=0;h<f;h++){if(h>G||R>0&&!(h&63)&&Date.now()>R)return oe(t,e,n,l,i,r);let m=q.advance(h,o,a,f,d,!1,c)||z.advance(h,o,a,f,u,!0,s);if(m)return ot(t,e,n,e+m[0],l,i,r,i+m[1])}return[new x(e,n,i,r)]}class Le{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,o,a){for(let f=-e+this.start;f<=e-this.end;f+=2){let c=i+f,s=f==-e||f!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=s-f;for(;s<n&&d<l&&a(s,d);)s++,d++;if(this.vec[c]=s,s>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let u=i+(n-l)-f;if(u>=0&&u<this.len&&r.vec[u]!=-1)if(o){let h=r.vec[u];if(h>=n-s)return[h,i+h-u]}else{let h=n-r.vec[u];if(s>=h)return[s,d]}}}return null}}const q=new Le,z=new Le;function ot(t,e,n,l,i,r,o,a){let f=!1;return!E(t,l)&&++l==n&&(f=!0),!E(i,a)&&++a==o&&(f=!0),f?[new x(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function De(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function Y(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=De(n-e,r-i);for(let a=e,f=i;;){let c=a+o,s=f+o;if(c>n||s>r||t.slice(a,c)!=l.slice(f,s)){if(o==1)return a-e-(E(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function ee(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=De(n-e,r-i);for(let a=n,f=r;;){let c=a-o,s=f-o;if(c<e||s<i||t.slice(c,a)!=l.slice(s,f)){if(o==1)return n-a-(E(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function _(t,e,n,l,i,r,o,a){let f=l.slice(i,r),c=null;for(;;){if(c||o<a)return c;for(let s=e+o;;){E(t,s)||s++;let d=s+o;if(E(t,d)||(d+=d==s+1?1:-1),d>=n)break;let u=t.slice(s,d),h=-1;for(;(h=f.indexOf(u,h+1))!=-1;){let m=Y(t,d,n,l,i+h+u.length,r),p=ee(t,e,s,l,i,i+h),g=u.length+m+p;(!c||c[2]<g)&&(c=[s-p,i+h-p,g])}s=d}if(a<0)return c;o=o>>1}}function Me(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Me(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:_(t,e,n,l,i,r,Math.floor(o/4),-1)}function oe(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=_(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=_(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new x(e,n,i,r)];let[c,s,d]=f;return j(t,e,c,l,i,s).concat(j(t,c+d,n,l,s+d,r))}function Se(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new x(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function at(t,e,n){for(;;){Se(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=Y(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA,r.toA-a,r.fromB,r.toB-a));let f=r.toA-r.fromA,c=r.toB-r.fromB;if(f&&c)continue;let s=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!s||!d)continue;let u=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);s<=u.length&&t.slice(r.fromA-s,r.fromA)==u.slice(u.length-s)?(n[i]=new x(r.fromA-s,r.toA-s,r.fromB-s,r.toB-s),l=!0):d<=u.length&&t.slice(r.toA,r.toA+d)==u.slice(0,d)&&(n[i]=new x(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function st(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],o=r.toA-r.fromA,a=r.toB-r.fromB;if(o&&a||o>3||a>3){let f=i==t.length-1?e.length:t[i+1].fromA,c=r.fromA-l,s=f-r.toA,d=se(e,r.fromA,c),u=ae(e,r.toA,s),h=r.fromA-d,m=u-r.toA;if((!o||!a)&&h&&m){let p=Math.max(o,a),[g,k,T]=o?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>h&&e.slice(d,r.fromA)==g.slice(T-h,T)?(r=t[i]=new x(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=ae(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new x(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=se(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new x(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=fe(e,r.fromA,r.toA),g,k=p<0?-1:de(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=s&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toA-k)<=c&&e.slice(r.fromA-g,r.fromA)==e.slice(k,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=fe(n,r.fromB,r.toB),g,k=p<0?-1:de(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=s&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toB-k)<=c&&n.slice(r.fromB-g,r.fromB)==n.slice(k,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return Se(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function ye(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function je(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?ye(n)?1:0:y?!Oe(n)||e==t.length-1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e,e+2))?2:0:0}function Ne(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?ye(n)?1:0:y?!Te(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Ee=8;function ae(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Ee;r++){let o=je(t,l);if(!o||l+o>i)return l;l+=o}return e}function se(t,e,n){if(!e||!je(t,e))return e;for(let l=e,i=e-n,r=0;r<Ee;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function de(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function fe(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Oe=t=>t>=55296&&t<=56319,Te=t=>t>=56320&&t<=57343;function E(t,e){return!e||e==t.length||!Oe(t.charCodeAt(e-1))||!Te(t.charCodeAt(e))}function dt(t,e,n){var l;let i=n?.override;return i?i(t,e):(G=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,R=n?.timeout?Date.now()+n.timeout:0,X=!1,at(t,e,j(t,0,t.length,e,0,e.length)))}function Fe(){return!X}function Ge(t,e,n){return st(dt(t,e,n),t,e)}const D=Be.define({combine:t=>t[0]}),ft=K.define(),Re=Be.define(),w=U.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ft)&&(t=n.value);for(let n of e.state.facet(Re))t=n(t,e);return t}});class N{constructor(e,n,l,i,r,o=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=o}offset(e,n){return e||n?new N(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ge(e.toString(),n.toString(),l);return Ie(i,e,n,0,0,Fe())}static updateA(e,n,l,i,r){return ge(me(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return ge(me(e,i,!1,n.length),e,n,l,r)}}function ce(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function ue(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Ie(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ce(f.fromA+l,f.fromB+i,e,n),[d,u]=ue(f.toA+l,f.toB+i,e,n),h=[f.offset(-c+l,-s+i)];for(;a<t.length-1;){let m=t[a+1],[p,g]=ce(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>u+1)break;h.push(m.offset(-c+l,-s+i)),[d,u]=ue(m.toA+l,m.toB+i,e,n),a++}o.push(new N(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const W=1e3;function he(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let s=0,d=0;i&&({toA:s,toB:d}=t[i-1]);let u=e-(n?s:d);return[s+u,d+u]}let o=i+r>>1,a=t[o],[f,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(f>e)r=o;else if(c<=e)i=o+1;else return l?[a.fromA,a.fromB]:[a.toA,a.toB]}}function me(t,e,n,l){let i=[];return e.iterChangedRanges((r,o,a,f)=>{let c=0,s=n?e.length:l,d=0,u=n?l:e.length;r>W&&([c,d]=he(t,r-W,n,!0)),o<e.length-W&&([s,u]=he(t,o+W,n,!1));let h=f-a-(o-r),m,[p,g]=n?[h,0]:[0,h];i.length&&(m=i[i.length-1]).toA>=c?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:s,toB:u,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:c,toA:s,fromB:d,toB:u,diffA:p,diffB:g})}),i}function ge(t,e,n,l,i){if(!t.length)return e;let r=[];for(let o=0,a=0,f=0,c=0;;o++){let s=o==t.length?null:t[o],d=s?s.fromA+a:n.length,u=s?s.fromB+f:l.length;for(;c<e.length;){let g=e[c];if(s&&(g.toA+a>d||g.toB+f>u))break;r.push(g.offset(a,f)),c++}if(!s)break;let h=s.toA+a+s.diffA,m=s.toB+f+s.diffB,p=Ge(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of Ie(p,n,l,d,u,Fe()))r.push(g);for(a+=s.diffA,f+=s.diffB;c<e.length;){let g=e[c];if(g.fromA+a>h&&g.fromB+f>m)break;c++}}return r}const ct={scanLimit:500},We=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ce(t))}update(t){(t.docChanged||t.viewportChanged||ut(t.startState,t.state)||ht(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ce(t.view))}},{decorations:t=>t.deco});function ut(t,e){return t.field(w,!1)!=e.field(w,!1)}function ht(t,e){return t.facet(D)!=e.facet(D)}const pe=M.line({class:"cm-changedLine"}),He=M.mark({class:"cm-changedText"}),mt=M.mark({tagName:"ins",class:"cm-insertedLine"}),gt=M.mark({tagName:"del",class:"cm-deletedLine"}),xe=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function pt(t,e,n,l,i,r){let o=n?t.fromA:t.fromB,a=n?t.toA:t.toB,f=0;if(o!=a){i.add(o,o,pe),i.add(o,a,n?gt:mt),r&&r.add(o,o,xe);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,pe),r&&r.add(s,s,xe);continue}let d=s+c.value.length;if(l)for(;f<t.changes.length;){let u=t.changes[f],h=o+(n?u.fromA:u.fromB),m=o+(n?u.toA:u.toB),p=Math.max(s,h),g=Math.min(d,m);if(p<g&&i.add(p,g,He),m<d)f++;else break}s=d}}}function Ce(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new P,f=i?new P:null,{from:c,to:s}=t.viewport;for(let d of e){if((o?d.fromA:d.fromB)>=s)break;(o?d.toA:d.toB)>c&&(!r||!r(t.state,d,a,f))&&pt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=K.define({map:(t,e)=>e.mapPos(t)});class xt extends Z{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:$.of(i)});let{side:r,sibling:o}=e.state.facet(D);o&&o().dispatch({effects:$.of(Ct(i,e.state.field(w),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Ct(t,e,n){let l=0,i=0;for(let r=0;;r++){let o=r<e.length?e[r]:null;if(!o||(n?o.fromA:o.fromB)>=t)return i+(t-l);[l,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}const At=U.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is($)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(w)!=e.startState.field(w,!1)){let n=e.state.facet(D).side=="a",l=[];for(let i of e.state.field(w))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>S.decorations.from(t)});function kt({margin:t=3,minSize:e=4}){return At.init(n=>wt(n,t,e))}function wt(t,e,n){let l=new P,i=t.facet(D).side=="a",r=t.field(w),o=1;for(let a=0;;a++){let f=a<r.length?r[a]:null,c=a?o+e:1,s=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=s-c+1;if(d>=n&&l.add(t.doc.line(c).from,t.doc.line(s).to,M.replace({widget:new xt(d),block:!0})),!f)break;o=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const bt=S.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),vt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Bt=ve.low(Ke({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(We))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Pe?vt:null}));function Lt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ct;return[ve.low(We),yt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Re.of((i,r)=>{let o=r.effects.find(a=>a.is(te));return o&&(i=N.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=N.updateB(i,r.state.field(O),r.newDoc,r.changes,l)),i}),D.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Ot:void 0,side:"b"}),O.init(()=>n),Bt,t.collapseUnchanged?kt(t.collapseUnchanged):[],w.init(i=>N.build(n,i.doc,l))]}const te=K.define(),O=U.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(te)&&(t=n.value.doc);return t}}),Ae=new WeakMap;class Pe extends Z{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Dt(t,e,n){let l=Ae.get(e.changes);if(l)return l;let i=o=>{let{highlightChanges:a,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:c,mergeControls:s}=t.facet(D),d=document.createElement("div");if(d.className="cm-deletedChunk",s){let b=d.appendChild(document.createElement("div"));b.className="cm-chunkButtons";let B=A=>{A.preventDefault(),Mt(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),St(o,o.posAtDOM(d))};if(typeof s=="function")b.appendChild(s("accept",B)),b.appendChild(s("reject",L));else{let A=b.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let v=b.appendChild(document.createElement("button"));v.name="reject",v.textContent=t.phrase("Reject"),v.onmousedown=L}}if(n||e.fromA>=e.toA)return d;let u=o.state.field(O).sliceString(e.fromA,e.endA),h=f&&t.facet(Ze),m=T(),p=e.changes,g=0,k=!1;function T(){let b=d.appendChild(document.createElement("div"));return b.className="cm-deletedLine",b.appendChild(document.createElement("del"))}function I(b,B,L){for(let A=b;A<B;){if(u.charAt(A)==`
1
+ import{j as C,B as Ue,X as Ve,r as H,dj as qe,C as ze,i as _e,e8 as $e}from"./index-CdDNNAx2.js";import{T as be,P as ve,E as S,S as U,g as Ke,V as Qe,F as Be,a as K,R as P,D as M,G as Q,W as Z,l as Ze,h as Xe,b as Ye,c as et,d as tt,e as le,s as nt,j as rt,f as it}from"./code-editor-BdRMYojw.js";function It({sources:t,onRemove:e,disabled:n,wrap:l=!1}){return C.jsx(C.Fragment,{children:t.length>0?C.jsx("ul",{className:"space-y-2",children:t.map(i=>C.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("div",{className:"truncate font-mono text-xs font-medium",children:i.name}),C.jsx("div",{className:l?"whitespace-pre-wrap break-words text-xs text-muted-foreground":"truncate text-xs text-muted-foreground",children:i.query})]}),e?C.jsx(Ue,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${i.name}`,disabled:n,onClick:()=>e?.(i),children:C.jsx(Ve,{className:"h-3.5 w-3.5"})}):null]},i.query))}):null})}class x{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new x(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function j(t,e,n,l,i,r){if(t==l)return[];let o=Y(t,e,n,l,i,r),a=ee(t,e+o,n,l,i+o,r);e+=o,n-=a,i+=o,r-=a;let f=n-e,c=r-i;if(!f||!c)return[new x(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new x(e,e+d,i,i),new x(e+d+c,n,r,r)]}else if(c>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new x(e,e,i,i+d),new x(n,n,i+d+f,r)]}if(f==1||c==1)return[new x(e,n,i,r)];let s=Me(t,e,n,l,i,r);if(s){let[d,u,h]=s;return j(t,e,d,l,i,u).concat(j(t,d+h,n,l,u+h,r))}return lt(t,e,n,l,i,r)}let G=1e9,R=0,X=!1;function lt(t,e,n,l,i,r){let o=n-e,a=r-i;if(G<1e9&&Math.min(o,a)>G*16||R>0&&Date.now()>R)return Math.min(o,a)>G*64?[new x(e,n,i,r)]:oe(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);q.reset(f),z.reset(f);let c=(h,m)=>t.charCodeAt(e+h)==l.charCodeAt(i+m),s=(h,m)=>t.charCodeAt(n-h-1)==l.charCodeAt(r-m-1),d=(o-a)%2!=0?z:null,u=d?null:q;for(let h=0;h<f;h++){if(h>G||R>0&&!(h&63)&&Date.now()>R)return oe(t,e,n,l,i,r);let m=q.advance(h,o,a,f,d,!1,c)||z.advance(h,o,a,f,u,!0,s);if(m)return ot(t,e,n,e+m[0],l,i,r,i+m[1])}return[new x(e,n,i,r)]}class Le{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,o,a){for(let f=-e+this.start;f<=e-this.end;f+=2){let c=i+f,s=f==-e||f!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=s-f;for(;s<n&&d<l&&a(s,d);)s++,d++;if(this.vec[c]=s,s>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let u=i+(n-l)-f;if(u>=0&&u<this.len&&r.vec[u]!=-1)if(o){let h=r.vec[u];if(h>=n-s)return[h,i+h-u]}else{let h=n-r.vec[u];if(s>=h)return[s,d]}}}return null}}const q=new Le,z=new Le;function ot(t,e,n,l,i,r,o,a){let f=!1;return!E(t,l)&&++l==n&&(f=!0),!E(i,a)&&++a==o&&(f=!0),f?[new x(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function De(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function Y(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=De(n-e,r-i);for(let a=e,f=i;;){let c=a+o,s=f+o;if(c>n||s>r||t.slice(a,c)!=l.slice(f,s)){if(o==1)return a-e-(E(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function ee(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=De(n-e,r-i);for(let a=n,f=r;;){let c=a-o,s=f-o;if(c<e||s<i||t.slice(c,a)!=l.slice(s,f)){if(o==1)return n-a-(E(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function _(t,e,n,l,i,r,o,a){let f=l.slice(i,r),c=null;for(;;){if(c||o<a)return c;for(let s=e+o;;){E(t,s)||s++;let d=s+o;if(E(t,d)||(d+=d==s+1?1:-1),d>=n)break;let u=t.slice(s,d),h=-1;for(;(h=f.indexOf(u,h+1))!=-1;){let m=Y(t,d,n,l,i+h+u.length,r),p=ee(t,e,s,l,i,i+h),g=u.length+m+p;(!c||c[2]<g)&&(c=[s-p,i+h-p,g])}s=d}if(a<0)return c;o=o>>1}}function Me(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Me(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:_(t,e,n,l,i,r,Math.floor(o/4),-1)}function oe(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=_(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=_(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new x(e,n,i,r)];let[c,s,d]=f;return j(t,e,c,l,i,s).concat(j(t,c+d,n,l,s+d,r))}function Se(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new x(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function at(t,e,n){for(;;){Se(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=Y(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA,r.toA-a,r.fromB,r.toB-a));let f=r.toA-r.fromA,c=r.toB-r.fromB;if(f&&c)continue;let s=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!s||!d)continue;let u=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);s<=u.length&&t.slice(r.fromA-s,r.fromA)==u.slice(u.length-s)?(n[i]=new x(r.fromA-s,r.toA-s,r.fromB-s,r.toB-s),l=!0):d<=u.length&&t.slice(r.toA,r.toA+d)==u.slice(0,d)&&(n[i]=new x(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function st(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],o=r.toA-r.fromA,a=r.toB-r.fromB;if(o&&a||o>3||a>3){let f=i==t.length-1?e.length:t[i+1].fromA,c=r.fromA-l,s=f-r.toA,d=se(e,r.fromA,c),u=ae(e,r.toA,s),h=r.fromA-d,m=u-r.toA;if((!o||!a)&&h&&m){let p=Math.max(o,a),[g,k,T]=o?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>h&&e.slice(d,r.fromA)==g.slice(T-h,T)?(r=t[i]=new x(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=ae(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new x(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=se(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new x(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=fe(e,r.fromA,r.toA),g,k=p<0?-1:de(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=s&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toA-k)<=c&&e.slice(r.fromA-g,r.fromA)==e.slice(k,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=fe(n,r.fromB,r.toB),g,k=p<0?-1:de(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=s&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toB-k)<=c&&n.slice(r.fromB-g,r.fromB)==n.slice(k,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return Se(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function ye(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function je(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?ye(n)?1:0:y?!Oe(n)||e==t.length-1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e,e+2))?2:0:0}function Ne(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?ye(n)?1:0:y?!Te(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Ee=8;function ae(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Ee;r++){let o=je(t,l);if(!o||l+o>i)return l;l+=o}return e}function se(t,e,n){if(!e||!je(t,e))return e;for(let l=e,i=e-n,r=0;r<Ee;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function de(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function fe(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Oe=t=>t>=55296&&t<=56319,Te=t=>t>=56320&&t<=57343;function E(t,e){return!e||e==t.length||!Oe(t.charCodeAt(e-1))||!Te(t.charCodeAt(e))}function dt(t,e,n){var l;let i=n?.override;return i?i(t,e):(G=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,R=n?.timeout?Date.now()+n.timeout:0,X=!1,at(t,e,j(t,0,t.length,e,0,e.length)))}function Fe(){return!X}function Ge(t,e,n){return st(dt(t,e,n),t,e)}const D=Be.define({combine:t=>t[0]}),ft=K.define(),Re=Be.define(),w=U.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ft)&&(t=n.value);for(let n of e.state.facet(Re))t=n(t,e);return t}});class N{constructor(e,n,l,i,r,o=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=o}offset(e,n){return e||n?new N(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ge(e.toString(),n.toString(),l);return Ie(i,e,n,0,0,Fe())}static updateA(e,n,l,i,r){return ge(me(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return ge(me(e,i,!1,n.length),e,n,l,r)}}function ce(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function ue(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Ie(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ce(f.fromA+l,f.fromB+i,e,n),[d,u]=ue(f.toA+l,f.toB+i,e,n),h=[f.offset(-c+l,-s+i)];for(;a<t.length-1;){let m=t[a+1],[p,g]=ce(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>u+1)break;h.push(m.offset(-c+l,-s+i)),[d,u]=ue(m.toA+l,m.toB+i,e,n),a++}o.push(new N(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const W=1e3;function he(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let s=0,d=0;i&&({toA:s,toB:d}=t[i-1]);let u=e-(n?s:d);return[s+u,d+u]}let o=i+r>>1,a=t[o],[f,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(f>e)r=o;else if(c<=e)i=o+1;else return l?[a.fromA,a.fromB]:[a.toA,a.toB]}}function me(t,e,n,l){let i=[];return e.iterChangedRanges((r,o,a,f)=>{let c=0,s=n?e.length:l,d=0,u=n?l:e.length;r>W&&([c,d]=he(t,r-W,n,!0)),o<e.length-W&&([s,u]=he(t,o+W,n,!1));let h=f-a-(o-r),m,[p,g]=n?[h,0]:[0,h];i.length&&(m=i[i.length-1]).toA>=c?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:s,toB:u,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:c,toA:s,fromB:d,toB:u,diffA:p,diffB:g})}),i}function ge(t,e,n,l,i){if(!t.length)return e;let r=[];for(let o=0,a=0,f=0,c=0;;o++){let s=o==t.length?null:t[o],d=s?s.fromA+a:n.length,u=s?s.fromB+f:l.length;for(;c<e.length;){let g=e[c];if(s&&(g.toA+a>d||g.toB+f>u))break;r.push(g.offset(a,f)),c++}if(!s)break;let h=s.toA+a+s.diffA,m=s.toB+f+s.diffB,p=Ge(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of Ie(p,n,l,d,u,Fe()))r.push(g);for(a+=s.diffA,f+=s.diffB;c<e.length;){let g=e[c];if(g.fromA+a>h&&g.fromB+f>m)break;c++}}return r}const ct={scanLimit:500},We=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ce(t))}update(t){(t.docChanged||t.viewportChanged||ut(t.startState,t.state)||ht(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ce(t.view))}},{decorations:t=>t.deco});function ut(t,e){return t.field(w,!1)!=e.field(w,!1)}function ht(t,e){return t.facet(D)!=e.facet(D)}const pe=M.line({class:"cm-changedLine"}),He=M.mark({class:"cm-changedText"}),mt=M.mark({tagName:"ins",class:"cm-insertedLine"}),gt=M.mark({tagName:"del",class:"cm-deletedLine"}),xe=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function pt(t,e,n,l,i,r){let o=n?t.fromA:t.fromB,a=n?t.toA:t.toB,f=0;if(o!=a){i.add(o,o,pe),i.add(o,a,n?gt:mt),r&&r.add(o,o,xe);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,pe),r&&r.add(s,s,xe);continue}let d=s+c.value.length;if(l)for(;f<t.changes.length;){let u=t.changes[f],h=o+(n?u.fromA:u.fromB),m=o+(n?u.toA:u.toB),p=Math.max(s,h),g=Math.min(d,m);if(p<g&&i.add(p,g,He),m<d)f++;else break}s=d}}}function Ce(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new P,f=i?new P:null,{from:c,to:s}=t.viewport;for(let d of e){if((o?d.fromA:d.fromB)>=s)break;(o?d.toA:d.toB)>c&&(!r||!r(t.state,d,a,f))&&pt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=K.define({map:(t,e)=>e.mapPos(t)});class xt extends Z{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:$.of(i)});let{side:r,sibling:o}=e.state.facet(D);o&&o().dispatch({effects:$.of(Ct(i,e.state.field(w),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Ct(t,e,n){let l=0,i=0;for(let r=0;;r++){let o=r<e.length?e[r]:null;if(!o||(n?o.fromA:o.fromB)>=t)return i+(t-l);[l,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}const At=U.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is($)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(w)!=e.startState.field(w,!1)){let n=e.state.facet(D).side=="a",l=[];for(let i of e.state.field(w))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>S.decorations.from(t)});function kt({margin:t=3,minSize:e=4}){return At.init(n=>wt(n,t,e))}function wt(t,e,n){let l=new P,i=t.facet(D).side=="a",r=t.field(w),o=1;for(let a=0;;a++){let f=a<r.length?r[a]:null,c=a?o+e:1,s=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=s-c+1;if(d>=n&&l.add(t.doc.line(c).from,t.doc.line(s).to,M.replace({widget:new xt(d),block:!0})),!f)break;o=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const bt=S.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),vt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Bt=ve.low(Ke({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(We))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Pe?vt:null}));function Lt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ct;return[ve.low(We),yt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Re.of((i,r)=>{let o=r.effects.find(a=>a.is(te));return o&&(i=N.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=N.updateB(i,r.state.field(O),r.newDoc,r.changes,l)),i}),D.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Ot:void 0,side:"b"}),O.init(()=>n),Bt,t.collapseUnchanged?kt(t.collapseUnchanged):[],w.init(i=>N.build(n,i.doc,l))]}const te=K.define(),O=U.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(te)&&(t=n.value.doc);return t}}),Ae=new WeakMap;class Pe extends Z{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Dt(t,e,n){let l=Ae.get(e.changes);if(l)return l;let i=o=>{let{highlightChanges:a,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:c,mergeControls:s}=t.facet(D),d=document.createElement("div");if(d.className="cm-deletedChunk",s){let b=d.appendChild(document.createElement("div"));b.className="cm-chunkButtons";let B=A=>{A.preventDefault(),Mt(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),St(o,o.posAtDOM(d))};if(typeof s=="function")b.appendChild(s("accept",B)),b.appendChild(s("reject",L));else{let A=b.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let v=b.appendChild(document.createElement("button"));v.name="reject",v.textContent=t.phrase("Reject"),v.onmousedown=L}}if(n||e.fromA>=e.toA)return d;let u=o.state.field(O).sliceString(e.fromA,e.endA),h=f&&t.facet(Ze),m=T(),p=e.changes,g=0,k=!1;function T(){let b=d.appendChild(document.createElement("div"));return b.className="cm-deletedLine",b.appendChild(document.createElement("del"))}function I(b,B,L){for(let A=b;A<B;){if(u.charAt(A)==`
2
2
  `){m.firstChild||m.appendChild(document.createElement("br")),m=T(),A++;continue}let v=B,ne=L+(k?" cm-deletedText":""),re=!1,V=u.indexOf(`
3
3
  `,A);if(V>-1&&V<B&&(v=V),a&&g<p.length){let F=Math.max(0,k?p[g].toA:p[g].fromA);F<=v&&(v=F,k&&g++,re=!0)}if(v>A){let F=document.createTextNode(u.slice(A,v));if(ne){let ie=m.appendChild(document.createElement("span"));ie.className=ne,ie.appendChild(F)}else m.appendChild(F);A=v}re&&(k=!k)}}if(h&&e.toA-e.fromA<=c){let b=h.parser.parse(u),B=0;Xe(b,{style:L=>Ye(t,L)},(L,A,v)=>{L>B&&I(B,L,""),I(L,A,v),B=A}),I(B,u.length,"")}else I(0,u.length,"");return m.firstChild||m.appendChild(document.createElement("br")),d},r=M.widget({block:!0,side:-1,widget:new Pe(i)});return Ae.set(e.changes,r),r}function Mt(t,e){let{state:n}=t,l=e??n.selection.main.head,i=t.state.field(w).find(f=>f.fromB<=l&&f.endB>=l);if(!i)return!1;let r=t.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=t.state.field(O);i.fromB!=i.toB&&i.toA<=o.length&&(r+=t.state.lineBreak);let a=et.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:r},o.length);return t.dispatch({effects:te.of({doc:a.apply(o),changes:a}),userEvent:"accept"}),!0}function St(t,e){let{state:n}=t,l=e??n.selection.main.head,i=n.field(w).find(a=>a.fromB<=l&&a.endB>=l);if(!i)return!1;let o=n.field(O).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(o+=n.lineBreak),t.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:o},userEvent:"revert"}),!0}function ke(t){let e=new P;for(let n of t.field(w)){let l=t.facet(D).overrideChunk&&Je(t,n);e.add(n.fromB,n.fromB,Dt(t,n,!!l))}return e.finish()}const yt=U.define({create:t=>ke(t),update(t,e){return e.state.field(w,!1)!=e.startState.field(w,!1)?ke(e.state):t},provide:t=>S.decorations.from(t)}),we=new WeakMap;function Je(t,e){let n=we.get(e);if(n!==void 0)return n;n=null;let l=t.field(O),i=t.doc,r=l.lineAt(e.endA).number-l.lineAt(e.fromA).number+1,o=i.lineAt(e.endB).number-i.lineAt(e.fromB).number+1;e:if(r==o&&r<10){let a=[],f=0,c=e.fromA,s=e.fromB;for(let d of e.changes){if(d.fromA<d.toA){f+=d.toA-d.fromA;let u=l.sliceString(c+d.fromA,c+d.toA);if(/\n/.test(u))break e;a.push(M.widget({widget:new jt(u),side:-1}).range(s+d.fromB))}d.fromB<d.toB&&a.push(He.range(s+d.fromB,s+d.toB))}f<e.endA-e.fromA-r*2&&(n=a)}return we.set(e,n),n}class jt extends Z{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const Nt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Et=M.line({class:"cm-inlineChangedLine"});function Ot(t,e,n,l){let i=Je(t,e),r=0;if(!i)return!1;for(let o=t.doc.lineAt(e.fromB);;){for(l&&l.add(o.from,o.from,Nt),n.add(o.from,o.from,Et);r<i.length&&i[r].to<=o.to;){let a=i[r++];n.add(a.from,a.to,a.value)}if(o.to>=e.endB)break;o=t.doc.lineAt(o.to+1)}return!0}const Tt=S.theme({"&":{backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"12px",border:"1px solid var(--border)",borderRadius:"0.5rem",overflow:"hidden",width:"100%"},"& .cm-scroller":{overflow:"auto",maxHeight:"20rem",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'},".cm-content":{padding:"6px 0"},".cm-content span":{color:"inherit"},".cm-gutters":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none",borderRight:"1px solid var(--border)"},".cm-changedLine":{backgroundColor:"color-mix(in oklch, var(--chart-2) 14%, transparent)"},".cm-changedText":{background:"color-mix(in oklch, var(--chart-2) 32%, transparent)"},".cm-deletedChunk":{backgroundColor:"color-mix(in oklch, var(--destructive) 10%, transparent)"},".cm-deletedText":{background:"color-mix(in oklch, var(--destructive) 28%, transparent)"},".cm-collapsedLines":{background:"var(--muted)",color:"var(--muted-foreground)",padding:"2px 8px"}});function J(t){if(Array.isArray(t))return t.map(J);if(t&&typeof t=="object"){const e=Object.create(null);for(const n of Object.keys(t).sort())e[n]=J(t[n]);return e}return t}function Ft({before:t,after:e}){const n=H.useRef(null);return H.useEffect(()=>{if(!n.current)return;const l=new S({state:le.create({doc:e,extensions:[le.readOnly.of(!0),S.editable.of(!1),S.lineWrapping,nt(it,{fallback:!0}),rt(),Lt({original:t,mergeControls:!1,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}),Tt]}),parent:n.current});return()=>l.destroy()},[t,e]),C.jsx("div",{ref:n,className:"w-full"})}function Wt({before:t,after:e}){const[n,l]=H.useState(!1),i=H.useId();if(!t&&!e)return null;const r=!!(t&&e);return C.jsxs("div",{className:"mt-2",children:[C.jsxs("button",{type:"button",onClick:()=>l(o=>!o),"aria-expanded":n,"aria-controls":n?i:void 0,className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[n?C.jsx(qe,{className:"h-3 w-3"}):C.jsx(ze,{className:"h-3 w-3"}),r?n?"Hide diff":"Show diff":n?"Hide details":"Show details"]}),n&&(r?C.jsx("div",{id:i,className:"mt-2",children:C.jsx(Ft,{before:JSON.stringify(J(t),null,2),after:JSON.stringify(J(e),null,2)})}):C.jsxs("div",{id:i,className:"mt-2",children:[C.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase text-muted-foreground",children:e?"After":"Before"}),C.jsx("pre",{className:_e($e,"max-h-48 overflow-auto p-2 text-xs"),children:JSON.stringify(e??t,null,2)})]}))]})}export{It as A,Wt as J};
4
- //# sourceMappingURL=json-diff-CJK-gzCt.js.map
4
+ //# sourceMappingURL=json-diff-C-WQqyIf.js.map
@@ -1,2 +1,2 @@
1
- import{j as s,ba as t,m as e,i as o}from"./index-C2TCKJDP.js";function d({mark:a=!0}){return s.jsxs("div",{className:t,children:[a?s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}):null,s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-3.5 w-40 max-w-[60%]"}),s.jsx(e,{className:"h-3 w-64 max-w-[80%]"})]}),s.jsx(e,{className:"h-3 w-10 shrink-0"})]})}function x({label:a,rows:r=4,bordered:l=!0,className:n}){return s.jsx("div",{role:"status","aria-label":a,className:o(l&&"divide-y overflow-hidden rounded-lg border",n),children:Array.from({length:r},(m,i)=>s.jsx(d,{},i))})}export{x as L,d as a};
2
- //# sourceMappingURL=list-skeleton-bQAZ0hQp.js.map
1
+ import{j as s,bl as t,m as e,i as o}from"./index-CdDNNAx2.js";function d({mark:a=!0}){return s.jsxs("div",{className:t,children:[a?s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}):null,s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-3.5 w-40 max-w-[60%]"}),s.jsx(e,{className:"h-3 w-64 max-w-[80%]"})]}),s.jsx(e,{className:"h-3 w-10 shrink-0"})]})}function x({label:a,rows:r=4,bordered:l=!0,className:n}){return s.jsx("div",{role:"status","aria-label":a,className:o(l&&"divide-y overflow-hidden rounded-lg border",n),children:Array.from({length:r},(m,i)=>s.jsx(d,{},i))})}export{x as L,d as a};
2
+ //# sourceMappingURL=list-skeleton-0B1bTrAK.js.map
@@ -1,2 +1,2 @@
1
- import{c as Ne,ad as Ce,z as Se,ae as Ee,M as Le,r as s,af as Ue,ag as Fe,ah as ae,j as e,ai as b,aj as ce,ak as q,al as Pe,am as Me,an as Ie,aa as ze,$ as Ae,ab as Re,ao as oe}from"./index-C2TCKJDP.js";import{s as $e}from"./index-DXfYVs5m.js";import{C as qe,c as Be}from"./card-rE4Ctuy6.js";function B(l){if(!l||typeof l!="object")return null;const f=l.error;if(typeof f=="string")return f;if(f&&typeof f=="object"){const y=f.message;if(typeof y=="string"&&y.length>0)return y}const m=l.message;return typeof m=="string"&&m.length>0?m:null}async function le(l,f){if(typeof window>"u")return;const m=window.PasswordCredential;if(!(!m||!navigator.credentials?.store))try{const y=new m({id:l,password:f});await navigator.credentials.store(y)}catch{}}function Oe({domain:l}){const[f,m]=s.useState(!1);return!(l.length>0&&l.length<=253&&/^[A-Za-z0-9.-]+$/.test(l))||f?e.jsx(ce,{className:"w-4 h-4"}):e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(l)}&sz=32`,alt:"",width:16,height:16,className:"h-4 w-4",onError:()=>m(!0)})}function E(l){return l?l.toLowerCase().replaceAll("_"," ").trim().includes("account not linked")?"This social account matches an existing Lobu user. Sign in with a magic link to verify ownership, then continue.":l:null}function He(){const l=Ne(),f=Ce(),{session:m,isReady:y}=Se(),{data:a,isLoading:U,error:O}=Ee(),i=Le({from:"/auth/login"}),de=i.invitationOrg,[p,j]=s.useState("social"),[d,P]=s.useState(i.intent??"sign-in"),[T,ue]=s.useState(""),[o,W]=s.useState(()=>i.loginHint??""),[k,me]=s.useState(""),[N,ge]=s.useState(""),[M,V]=s.useState(""),[fe,J]=s.useState(!1),[c,u]=s.useState(null),[I,r]=s.useState(null),[Q,G]=s.useState(!1),[pe,K]=s.useState(!1),[Z,he]=s.useState(!1),X=s.useRef(!1),L=i.callbackUrl?Ue(i.callbackUrl):void 0,z=Fe(de,i.loginHint),Y=i.mode==="extension",D=i.error==="account_not_linked",ee=E(i.errorDescription||i.error),A=Object.values(a?.social??{}).some(Boolean),w=!!a?.magicLink,R=!!a?.phone,h=!!a?.emailPassword,te=!!a?.passkey,x=!!a?.singleUserMode,ne=!!a?.hasUser,H=x,F=p==="magic-link"&&w&&Q,v=s.useMemo(()=>{const t=[];return h&&t.push("email-password"),A&&t.push("social"),w&&t.push("magic-link"),R&&t.push("whatsapp"),t},[h,w,A,R]),xe=s.useMemo(()=>h?v.filter(t=>t!=="magic-link"&&t!=="social"):v,[v,h]),_=O instanceof Error?O.message:O?"Unable to load sign-in options.":null;s.useEffect(()=>{if(m){const t=ae(L);L?window.location.href=t:l({to:"/"})}},[m,l,L]),s.useEffect(()=>{!a||v.length===0||v.includes(p)||j(v[0])},[a,p,v]),s.useEffect(()=>{!w||!D||(j("magic-link"),i.loginHint&&!o&&W(i.loginHint))},[w,D,i.loginHint,o]),s.useEffect(()=>{i.intent&&P(i.intent)},[i.intent]),s.useEffect(()=>{if(!x||!a)return;const t=ne?"sign-in":"sign-up";d!==t&&P(t)},[x,ne,a,d]);const C=()=>L?ae(L):"/",se=async(t,{quiet:n=!1}={})=>{u(t),r(null);try{const g=await q.social({provider:t,callbackURL:C(),newUserCallbackURL:L?C():`/?onboard_provider=${encodeURIComponent(t)}`}),S=B(g);if(S&&!n){const $=E(S);$?.toLowerCase().includes("magic link")&&j("magic-link"),r($)}}catch(g){if(n)return;r(E(g instanceof Error?g.message:`Failed to sign in with ${t}`))}finally{u(null)}};s.useEffect(()=>{if(X.current||!y||m||U||!a||i.error)return;const t=i.provider;if(!t)return;X.current=!0;const n=Object.hasOwn(a.social??{},t)&&!!a.social?.[t];se(t,{quiet:!n})},[a,U,m,y,i.provider,i.error]);const re=async()=>{if(o){u("magic-link"),r(null);try{return await q.magicLink({email:o,callbackURL:C()}),G(!0),!0}catch(t){return r(t instanceof Error?t.message:"Failed to send magic link"),!1}finally{u(null)}}},be=async t=>{t.preventDefault(),await re()},ye=async t=>{if(t.preventDefault(),!(!o||!k)){u("email-password"),r(null);try{if(d==="sign-up"){const n=await Me.email({email:o,password:k,name:T||o.split("@")[0]||"User",callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(await le(o,k),await f.invalidateQueries({queryKey:["organizations"]}),x&&te)try{await Ie.passkey.addPasskey({name:T||`${navigator.platform||"This device"}`})}catch{}}else{const n=await q.email({email:o,password:k,callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(!n?.data){r("Invalid email or password");return}await le(o,k)}}catch(n){const g=n instanceof Error?n.message:typeof n=="string"?n:B(n);r(g||"Authentication failed")}finally{u(null)}}},ie=async()=>{r(null),he(!0),u("local");try{const t=await Pe();if(!t.ok){const n=await t.json().catch(()=>null);r(n?.error_description??"Could not sign in to your local install.");return}window.location.href=C()}catch(t){r(t instanceof Error?t.message:"Could not sign in to your local install.")}finally{u(null)}};s.useEffect(()=>{H&&a&&!m&&!Z&&ie()},[H,a,m,Z]);const je=async()=>{if(!o){r("Enter your email address first to reset your password.");return}u("reset-password-request"),r(null);try{const t=`${window.location.origin}/auth/reset-password`,n=await ze(`${Ae}/api/auth/request-password-reset`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:o,redirectTo:t})});if(!n.ok)throw await Re(n);K(!0)}catch(t){r(t instanceof Error?t.message:"Failed to send password reset email")}finally{u(null)}},we=async t=>{if(t.preventDefault(),!!N){u("phone"),r(null);try{await oe.sendOtp({phoneNumber:N}),J(!0)}catch(n){r(n instanceof Error?n.message:"Failed to send verification code")}finally{u(null)}}},ve=async t=>{if(t.preventDefault(),!(!N||!M)){u("verify"),r(null);try{await oe.verify({phoneNumber:N,code:M})}catch(n){r(n instanceof Error?n.message:"Invalid verification code"),u(null)}}};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:z?z.title:x&&d==="sign-up"?"Set up your local install":x?"Welcome back":d==="sign-up"?"Create your account":"Sign in"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:z?z.detail:x&&d==="sign-up"?"This account stays on this machine. Email is just an identifier — pick anything you’ll remember.":x?"Sign in to your local install.":Y?"Sign in to connect the browser extension":d==="sign-up"?"Choose a sign-up method":"Choose your preferred sign-in method"}),x&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-muted text-muted-foreground rounded-full text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Local install · nothing sent to lobu.ai"]}),Y&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Browser Extension"]})]}),e.jsx(qe,{children:e.jsx(Be,{children:H?e.jsx("div",{className:"space-y-4",children:I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:I}),e.jsx("button",{type:"button",disabled:c!==null,onClick:ie,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:"Try again"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Signing you into your local install…"})]})}):e.jsxs(e.Fragment,{children:[U&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Loading sign-in options…"})]}),!U&&_&&e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load sign-in options. ",_]}),!U&&!_&&v.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No sign-in methods are configured. Contact support for access."}),h&&!F&&e.jsxs("div",{className:"mb-4 flex rounded-lg border p-1",children:[e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-in"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-in"),children:"Sign In"}),e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-up"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-up"),children:"Sign Up"})]}),!F&&xe.length>1&&e.jsxs("div",{className:"mb-6 flex rounded-lg border p-1",children:[h&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="email-password"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("email-password"),children:"Email + Password"}),A&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="social"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("social"),children:"Social"}),!h&&w&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="magic-link"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("magic-link"),children:"Magic Link"}),R&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="whatsapp"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("whatsapp"),children:"WhatsApp"})]}),D&&e.jsx("div",{className:"mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:"We found an existing account for this identity. To protect the account, verify with a magic link before linking social sign-in."}),ee&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:ee}),I&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:I}),!F&&(h||p==="social")&&A&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(a?.social??{}).filter(([,t])=>t).map(([t])=>{const n=$e.find(ke=>ke.provider===t),g=n?.icon,S=a?.socialMeta?.[t],$=n?.name??S?.name??t.charAt(0).toUpperCase()+t.slice(1);return e.jsxs("button",{type:"button",onClick:()=>se(t),disabled:c!==null,className:"w-full flex items-center justify-center gap-3 h-10 px-4 border border-input rounded-lg bg-background hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-50",children:[c===t?e.jsx(b,{size:"lg"}):g?e.jsx(g,{className:"w-4 h-4"}):S?.faviconDomain?e.jsx(Oe,{domain:S.faviconDomain},S.faviconDomain):e.jsx(ce,{className:"w-4 h-4"}),"Continue with ",$]},t)}),h&&e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),!F&&h&&e.jsxs("form",{onSubmit:ye,className:"space-y-4",children:[d==="sign-up"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"full-name",className:"block text-sm font-medium",children:"Full name"}),e.jsx("input",{id:"full-name",type:"text",value:T,onChange:t=>ue(t.target.value),placeholder:"Jane Doe",className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email-password-email",type:"email",value:o,onChange:t=>{W(t.target.value),K(!1)},placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-password",className:"block text-sm font-medium",children:"Password"}),e.jsx("input",{id:"email-password-password",type:"password",value:k,onChange:t=>me(t.target.value),placeholder:"Enter a password",required:!0,minLength:8,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o||!k,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="email-password"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:d==="sign-up"?"Creating account...":"Signing in..."})]}):d==="sign-up"?x?"Create local account":"Create Account":"Sign In"}),d==="sign-in"&&te&&e.jsx("button",{type:"button",disabled:c!==null,onClick:async()=>{r(null),u("passkey");try{const t=await q.passkey();if(t?.error){const n=t.error.message??"Passkey sign-in failed.";r(E(n)??n);return}window.location.href=C()}catch(t){const n=t instanceof Error?t.message:String(t);r(E(n)??n)}finally{u(null)}},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="passkey"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Waiting for passkey…"})]}):"Sign in with passkey"}),d==="sign-in"&&w&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:async()=>{await re()&&j("magic-link")},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending magic link..."})]}):"Send me a magic link instead"}),d==="sign-in"&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:je,className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="reset-password-request"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending reset email..."})]}):"Forgot password?"}),d==="sign-in"&&pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If this email exists, we sent a password reset link."})]}),p==="magic-link"&&w&&(Q?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("svg",{className:"h-12 w-12 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsx("h2",{className:"text-lg font-medium",children:"Check your email"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a magic link to ",e.jsx("strong",{children:o}),".",e.jsx("br",{}),"Click the link in the email to sign in."]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-primary hover:underline",onClick:()=>G(!1),children:"Use a different email"})]}):e.jsxs("form",{onSubmit:be,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email",type:"email",value:o,onChange:t=>W(t.target.value),placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Magic Link"})]})),!F&&p==="whatsapp"&&R&&(fe?e.jsxs("form",{onSubmit:ve,className:"space-y-4",children:[e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",e.jsx("strong",{children:N})]}),e.jsx("div",{children:e.jsx("input",{type:"text",value:M,onChange:t=>V(t.target.value),placeholder:"000000",maxLength:6,pattern:"[0-9]{6}",required:!0,className:"block h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-xl tracking-widest placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),e.jsx("button",{type:"submit",disabled:c!==null||M.length!==6,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="verify"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Verifying..."})]}):"Verify & Sign In"}),e.jsx("button",{type:"button",className:"w-full text-sm text-primary hover:underline",onClick:()=>{J(!1),V("")},children:"Use a different number"})]}):e.jsxs("form",{onSubmit:we,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium",children:"WhatsApp Number"}),e.jsx("input",{id:"phone",type:"tel",value:N,onChange:t=>ge(t.target.value),placeholder:"+1234567890",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include country code (e.g., +1 for US)"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!N,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Code via WhatsApp"})]}))]})})})]})})}export{He as component};
2
- //# sourceMappingURL=login-DLqL54Rk.js.map
1
+ import{c as Ne,ad as Ce,z as Se,ae as Ee,M as Le,r as s,af as Ue,ag as Fe,ah as ae,j as e,ai as b,aj as ce,ak as q,al as Pe,am as Me,an as Ie,aa as ze,$ as Ae,ab as Re,ao as oe}from"./index-CdDNNAx2.js";import{s as $e}from"./index-Cd8jMsz8.js";import{C as qe,c as Be}from"./card-C01y1O-W.js";function B(l){if(!l||typeof l!="object")return null;const f=l.error;if(typeof f=="string")return f;if(f&&typeof f=="object"){const y=f.message;if(typeof y=="string"&&y.length>0)return y}const m=l.message;return typeof m=="string"&&m.length>0?m:null}async function le(l,f){if(typeof window>"u")return;const m=window.PasswordCredential;if(!(!m||!navigator.credentials?.store))try{const y=new m({id:l,password:f});await navigator.credentials.store(y)}catch{}}function Oe({domain:l}){const[f,m]=s.useState(!1);return!(l.length>0&&l.length<=253&&/^[A-Za-z0-9.-]+$/.test(l))||f?e.jsx(ce,{className:"w-4 h-4"}):e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(l)}&sz=32`,alt:"",width:16,height:16,className:"h-4 w-4",onError:()=>m(!0)})}function E(l){return l?l.toLowerCase().replaceAll("_"," ").trim().includes("account not linked")?"This social account matches an existing Lobu user. Sign in with a magic link to verify ownership, then continue.":l:null}function He(){const l=Ne(),f=Ce(),{session:m,isReady:y}=Se(),{data:a,isLoading:U,error:O}=Ee(),i=Le({from:"/auth/login"}),de=i.invitationOrg,[p,j]=s.useState("social"),[d,P]=s.useState(i.intent??"sign-in"),[T,ue]=s.useState(""),[o,W]=s.useState(()=>i.loginHint??""),[k,me]=s.useState(""),[N,ge]=s.useState(""),[M,V]=s.useState(""),[fe,J]=s.useState(!1),[c,u]=s.useState(null),[I,r]=s.useState(null),[Q,G]=s.useState(!1),[pe,K]=s.useState(!1),[Z,he]=s.useState(!1),X=s.useRef(!1),L=i.callbackUrl?Ue(i.callbackUrl):void 0,z=Fe(de,i.loginHint),Y=i.mode==="extension",D=i.error==="account_not_linked",ee=E(i.errorDescription||i.error),A=Object.values(a?.social??{}).some(Boolean),w=!!a?.magicLink,R=!!a?.phone,h=!!a?.emailPassword,te=!!a?.passkey,x=!!a?.singleUserMode,ne=!!a?.hasUser,H=x,F=p==="magic-link"&&w&&Q,v=s.useMemo(()=>{const t=[];return h&&t.push("email-password"),A&&t.push("social"),w&&t.push("magic-link"),R&&t.push("whatsapp"),t},[h,w,A,R]),xe=s.useMemo(()=>h?v.filter(t=>t!=="magic-link"&&t!=="social"):v,[v,h]),_=O instanceof Error?O.message:O?"Unable to load sign-in options.":null;s.useEffect(()=>{if(m){const t=ae(L);L?window.location.href=t:l({to:"/"})}},[m,l,L]),s.useEffect(()=>{!a||v.length===0||v.includes(p)||j(v[0])},[a,p,v]),s.useEffect(()=>{!w||!D||(j("magic-link"),i.loginHint&&!o&&W(i.loginHint))},[w,D,i.loginHint,o]),s.useEffect(()=>{i.intent&&P(i.intent)},[i.intent]),s.useEffect(()=>{if(!x||!a)return;const t=ne?"sign-in":"sign-up";d!==t&&P(t)},[x,ne,a,d]);const C=()=>L?ae(L):"/",se=async(t,{quiet:n=!1}={})=>{u(t),r(null);try{const g=await q.social({provider:t,callbackURL:C(),newUserCallbackURL:L?C():`/?onboard_provider=${encodeURIComponent(t)}`}),S=B(g);if(S&&!n){const $=E(S);$?.toLowerCase().includes("magic link")&&j("magic-link"),r($)}}catch(g){if(n)return;r(E(g instanceof Error?g.message:`Failed to sign in with ${t}`))}finally{u(null)}};s.useEffect(()=>{if(X.current||!y||m||U||!a||i.error)return;const t=i.provider;if(!t)return;X.current=!0;const n=Object.hasOwn(a.social??{},t)&&!!a.social?.[t];se(t,{quiet:!n})},[a,U,m,y,i.provider,i.error]);const re=async()=>{if(o){u("magic-link"),r(null);try{return await q.magicLink({email:o,callbackURL:C()}),G(!0),!0}catch(t){return r(t instanceof Error?t.message:"Failed to send magic link"),!1}finally{u(null)}}},be=async t=>{t.preventDefault(),await re()},ye=async t=>{if(t.preventDefault(),!(!o||!k)){u("email-password"),r(null);try{if(d==="sign-up"){const n=await Me.email({email:o,password:k,name:T||o.split("@")[0]||"User",callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(await le(o,k),await f.invalidateQueries({queryKey:["organizations"]}),x&&te)try{await Ie.passkey.addPasskey({name:T||`${navigator.platform||"This device"}`})}catch{}}else{const n=await q.email({email:o,password:k,callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(!n?.data){r("Invalid email or password");return}await le(o,k)}}catch(n){const g=n instanceof Error?n.message:typeof n=="string"?n:B(n);r(g||"Authentication failed")}finally{u(null)}}},ie=async()=>{r(null),he(!0),u("local");try{const t=await Pe();if(!t.ok){const n=await t.json().catch(()=>null);r(n?.error_description??"Could not sign in to your local install.");return}window.location.href=C()}catch(t){r(t instanceof Error?t.message:"Could not sign in to your local install.")}finally{u(null)}};s.useEffect(()=>{H&&a&&!m&&!Z&&ie()},[H,a,m,Z]);const je=async()=>{if(!o){r("Enter your email address first to reset your password.");return}u("reset-password-request"),r(null);try{const t=`${window.location.origin}/auth/reset-password`,n=await ze(`${Ae}/api/auth/request-password-reset`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:o,redirectTo:t})});if(!n.ok)throw await Re(n);K(!0)}catch(t){r(t instanceof Error?t.message:"Failed to send password reset email")}finally{u(null)}},we=async t=>{if(t.preventDefault(),!!N){u("phone"),r(null);try{await oe.sendOtp({phoneNumber:N}),J(!0)}catch(n){r(n instanceof Error?n.message:"Failed to send verification code")}finally{u(null)}}},ve=async t=>{if(t.preventDefault(),!(!N||!M)){u("verify"),r(null);try{await oe.verify({phoneNumber:N,code:M})}catch(n){r(n instanceof Error?n.message:"Invalid verification code"),u(null)}}};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:z?z.title:x&&d==="sign-up"?"Set up your local install":x?"Welcome back":d==="sign-up"?"Create your account":"Sign in"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:z?z.detail:x&&d==="sign-up"?"This account stays on this machine. Email is just an identifier — pick anything you’ll remember.":x?"Sign in to your local install.":Y?"Sign in to connect the browser extension":d==="sign-up"?"Choose a sign-up method":"Choose your preferred sign-in method"}),x&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-muted text-muted-foreground rounded-full text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Local install · nothing sent to lobu.ai"]}),Y&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Browser Extension"]})]}),e.jsx(qe,{children:e.jsx(Be,{children:H?e.jsx("div",{className:"space-y-4",children:I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:I}),e.jsx("button",{type:"button",disabled:c!==null,onClick:ie,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:"Try again"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Signing you into your local install…"})]})}):e.jsxs(e.Fragment,{children:[U&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Loading sign-in options…"})]}),!U&&_&&e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load sign-in options. ",_]}),!U&&!_&&v.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No sign-in methods are configured. Contact support for access."}),h&&!F&&e.jsxs("div",{className:"mb-4 flex rounded-lg border p-1",children:[e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-in"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-in"),children:"Sign In"}),e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-up"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-up"),children:"Sign Up"})]}),!F&&xe.length>1&&e.jsxs("div",{className:"mb-6 flex rounded-lg border p-1",children:[h&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="email-password"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("email-password"),children:"Email + Password"}),A&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="social"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("social"),children:"Social"}),!h&&w&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="magic-link"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("magic-link"),children:"Magic Link"}),R&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="whatsapp"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("whatsapp"),children:"WhatsApp"})]}),D&&e.jsx("div",{className:"mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:"We found an existing account for this identity. To protect the account, verify with a magic link before linking social sign-in."}),ee&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:ee}),I&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:I}),!F&&(h||p==="social")&&A&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(a?.social??{}).filter(([,t])=>t).map(([t])=>{const n=$e.find(ke=>ke.provider===t),g=n?.icon,S=a?.socialMeta?.[t],$=n?.name??S?.name??t.charAt(0).toUpperCase()+t.slice(1);return e.jsxs("button",{type:"button",onClick:()=>se(t),disabled:c!==null,className:"w-full flex items-center justify-center gap-3 h-10 px-4 border border-input rounded-lg bg-background hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-50",children:[c===t?e.jsx(b,{size:"lg"}):g?e.jsx(g,{className:"w-4 h-4"}):S?.faviconDomain?e.jsx(Oe,{domain:S.faviconDomain},S.faviconDomain):e.jsx(ce,{className:"w-4 h-4"}),"Continue with ",$]},t)}),h&&e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),!F&&h&&e.jsxs("form",{onSubmit:ye,className:"space-y-4",children:[d==="sign-up"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"full-name",className:"block text-sm font-medium",children:"Full name"}),e.jsx("input",{id:"full-name",type:"text",value:T,onChange:t=>ue(t.target.value),placeholder:"Jane Doe",className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email-password-email",type:"email",value:o,onChange:t=>{W(t.target.value),K(!1)},placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-password",className:"block text-sm font-medium",children:"Password"}),e.jsx("input",{id:"email-password-password",type:"password",value:k,onChange:t=>me(t.target.value),placeholder:"Enter a password",required:!0,minLength:8,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o||!k,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="email-password"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:d==="sign-up"?"Creating account...":"Signing in..."})]}):d==="sign-up"?x?"Create local account":"Create Account":"Sign In"}),d==="sign-in"&&te&&e.jsx("button",{type:"button",disabled:c!==null,onClick:async()=>{r(null),u("passkey");try{const t=await q.passkey();if(t?.error){const n=t.error.message??"Passkey sign-in failed.";r(E(n)??n);return}window.location.href=C()}catch(t){const n=t instanceof Error?t.message:String(t);r(E(n)??n)}finally{u(null)}},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="passkey"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Waiting for passkey…"})]}):"Sign in with passkey"}),d==="sign-in"&&w&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:async()=>{await re()&&j("magic-link")},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending magic link..."})]}):"Send me a magic link instead"}),d==="sign-in"&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:je,className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="reset-password-request"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending reset email..."})]}):"Forgot password?"}),d==="sign-in"&&pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If this email exists, we sent a password reset link."})]}),p==="magic-link"&&w&&(Q?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("svg",{className:"h-12 w-12 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsx("h2",{className:"text-lg font-medium",children:"Check your email"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a magic link to ",e.jsx("strong",{children:o}),".",e.jsx("br",{}),"Click the link in the email to sign in."]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-primary hover:underline",onClick:()=>G(!1),children:"Use a different email"})]}):e.jsxs("form",{onSubmit:be,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email",type:"email",value:o,onChange:t=>W(t.target.value),placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Magic Link"})]})),!F&&p==="whatsapp"&&R&&(fe?e.jsxs("form",{onSubmit:ve,className:"space-y-4",children:[e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",e.jsx("strong",{children:N})]}),e.jsx("div",{children:e.jsx("input",{type:"text",value:M,onChange:t=>V(t.target.value),placeholder:"000000",maxLength:6,pattern:"[0-9]{6}",required:!0,className:"block h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-xl tracking-widest placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),e.jsx("button",{type:"submit",disabled:c!==null||M.length!==6,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="verify"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Verifying..."})]}):"Verify & Sign In"}),e.jsx("button",{type:"button",className:"w-full text-sm text-primary hover:underline",onClick:()=>{J(!1),V("")},children:"Use a different number"})]}):e.jsxs("form",{onSubmit:we,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium",children:"WhatsApp Number"}),e.jsx("input",{id:"phone",type:"tel",value:N,onChange:t=>ge(t.target.value),placeholder:"+1234567890",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include country code (e.g., +1 for US)"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!N,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Code via WhatsApp"})]}))]})})})]})})}export{He as component};
2
+ //# sourceMappingURL=login-CH7P2AyR.js.map
@@ -1,2 +1,2 @@
1
- import{r as n,ac as o,j as e}from"./index-C2TCKJDP.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
- //# sourceMappingURL=logout-H0F3IfiO.js.map
1
+ import{r as n,ac as o,j as e}from"./index-CdDNNAx2.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
+ //# sourceMappingURL=logout-D474YsYQ.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,m as o,z as c,n as u,H as d,b0 as h,cW as b,B as p,L as x,J as g}from"./index-C2TCKJDP.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:r,callbackUrl:a}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&r?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:a,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:r,isLoading:a}=u(),i=d({select:m=>m.href});return!s||a?e.jsx(j,{}):n?r?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
- //# sourceMappingURL=member-scope-gate-Doic_6qX.js.map
1
+ import{j as e,m as o,z as c,n as d,H as u,bd as h,cZ as b,B as p,L as x,J as g}from"./index-CdDNNAx2.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:r,callbackUrl:a}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&r?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:a,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:r,isLoading:a}=d(),i=u({select:m=>m.href});return!s||a?e.jsx(j,{}):n?r?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
+ //# sourceMappingURL=member-scope-gate-CH_0jHiM.js.map
@@ -0,0 +1,74 @@
1
+ import{eI as Tt,c6 as Is,c7 as As,g2 as Ps,g3 as Fs,j as s,dy as Ds,cb as Vs,T as Ve,U as se,bT as Bs,B as R,bz as It,g4 as At,g5 as te,g6 as je,g7 as qs,g8 as Us,g9 as Qe,ga as Hs,gb as Ue,gc as He,gd as zs,ge as Gs,gf as Js,dA as Pt,dM as Ne,r as x,dc as Ws,ez as Ys,bR as Qs,eF as Ks,G as Ee,x as Ft,cD as Xs,g0 as Zs,c as ne,u as Dt,fg as en,c2 as tn,bd as Vt,db as Bt,fI as sn,f_ as nn,f0 as an,a2 as ze,i as ie,dP as qt,gg as rn,L as ke,e8 as on,d2 as ln,aF as Ut,aG as Ht,dj as zt,aI as Gt,aJ as cn,aK as dn,aL as un,aM as mn,aN as wt,aR as pn,cY as fn,aP as hn,cT as Jt,a4 as gn,gh as Wt,gi as Yt,ax as yn,gj as xn,M as Qt,z as bn,gk as vn,cl as K,w as Kt,gl as Be,cN as jn,gm as Nn,gn as Sn,dW as Et,go as qe,gp as Cn,gq as wn,da as En,cU as kn,cJ as _n,cK as $n,cj as Ge,dI as Rn,gr as Ln,gs as Je,gt as Mn,gu as On,gv as Tn,bp as In,gw as An,gx as Pn,gy as Fn,a as Dn,gz as Vn,gA as Bn,gB as qn,gC as Un,cS as Hn,ar as zn,aT as Gn}from"./index-CdDNNAx2.js";import{P as Jn}from"./public-shell-ready-CRyAZATw.js";import{D as Wn,c as Yn}from"./dynamic-schema-form-OkIZImgp.js";import{S as Qn,E as Xt,a as Kn,e as Xn,b as Zn,c as ea}from"./entity-pages-18xSANrS.js";import{b as ta,F as sa}from"./filter-editors-DDTwyYt0.js";import{l as na,H as aa,n as ra,G as Zt,c as oa}from"./entity-schema-graph-uwZ-P0t8.js";import{l as ia,p as _e,e as es,a as la,S as ca,J as da}from"./renderer-DZ0w2k2r.js";import{u as ua,a as ma,D as pa,P as fa,b as ts,c as ha,C as ga}from"./core.esm-CJUp2aNZ.js";import{v as ya,V as ss,M as ns,a as as,w as xa,b as ba}from"./view-param-filters-BdN8OU35.js";import{M as va}from"./member-scope-gate-CH_0jHiM.js";function ja({onClose:e,entityTypeSlug:t,orgContext:r,onSuccess:l}){const{data:n,isLoading:d}=Tt(t,r),i=`${r.organizationId??r.slug}:${t}`,a=Is(i,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},n?.metadata_schema),[u,o]=a.field("name"),[c,m]=a.field("customSlug"),[p,f]=a.field("useCustomSlug"),[y,N]=a.field("metadata"),[v,w]=As(i,null),b=Ps(),C=p?c:Fs(u),j=async L=>{if(L.preventDefault(),!a.canSubmit)return;if(w(null),!u.trim()){w("Name is required");return}const O=Yn(y),X={entityType:t,name:u.trim(),slug:p?c:void 0,metadata:Object.keys(O).length>0?O:void 0};try{const $=await b.mutateAsync(X);if(e(),$.approval_queued||!$.entity){It.info("Create queued for approval");return}typeof $.entity.id=="number"&&l?.($.entity.id)}catch($){w($ instanceof Error?$.message:"Failed to create entity")}},S=n?.name||t,g=a.revision,E=`Create ${S}`,k=`Add a new ${S.toLowerCase()} to your workspace.`;return d?s.jsx(Ds,{rows:6}):s.jsxs("form",{onSubmit:j,children:[s.jsx(Vs,{visible:a.hasConflict,onReload:a.reset}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:E}),s.jsx("p",{className:"text-sm text-muted-foreground",children:k})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsxs(Ve,{htmlFor:"name",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx(se,{id:"name",value:u,onChange:L=>o(L.target.value),placeholder:`Enter ${S.toLowerCase()} name`,autoFocus:!0})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ve,{htmlFor:"slug",children:"URL Slug"}),s.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-xs text-muted-foreground hover:text-foreground",children:p?"Auto-generate":"Customize"})]}),p?s.jsx(se,{id:"slug",value:c,onChange:L=>m(L.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):s.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:C||"slug-preview"})]}),g&&Object.keys(g).length>0?s.jsxs(s.Fragment,{children:[s.jsx(Qn,{className:"my-2"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(Ve,{className:"text-sm font-medium",children:"Additional Fields"}),s.jsx(Wn,{schema:a.revision,values:y,onValuesChange:N,orgContext:r})]})]}):null,v&&s.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:v})]}),s.jsx(Bs,{onCancel:e,cancelDisabled:b.isPending,className:"mt-2",children:s.jsx(R,{type:"submit",disabled:!a.canSubmit||b.isPending||!u.trim(),children:b.isPending?"Creating...":`Create ${S}`})})]})}function Na(e){const t=e?.properties??{},r=zs(e);return Object.entries(t).flatMap(([l,n])=>{const d=r.find(m=>m.field===l);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(l)||!n||n.const!==void 0||n["x-table-column"]!==!0&&n["x-facet"]!==!0&&!d)return[];const i=[n,...Array.isArray(n.anyOf)?n.anyOf:[]],a=d?.options??Gs(n),u=a.find(m=>m.value!==null)?.value,o=i.find(m=>["string","number","integer","boolean"].includes(String(m.type)))??(u===void 0?void 0:{type:typeof u});if(!o)return[];const c=n.format==="date-time"||o.format==="date-time"?"datetime-local":n.format==="date"||o.format==="date"?"date":o.type==="number"||o.type==="integer"?"number":o.type==="boolean"?"boolean":"string";return[{field:l,label:String(n["x-table-label"]??n.title??l.replaceAll("_"," ")),type:c,options:c==="boolean"&&!a.some(m=>typeof m.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...a]:a}]})}const kt={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Sa(e,t){return e.value===null&&e.op==="neq"?{op:kt.eq,value:"set"}:{op:kt[e.op],value:t?.options.find(r=>r.value===e.value)?.label??String(e.value)}}function Ca(e){const t=e?.[He];return t===void 0?{}:Qe(t)}function wa(e,t){return(e.presets??[]).filter(r=>!r.viewer||!!t?.email)}function Ea(e,t,r,l){try{const n=Ca(t),d=wa(n,l),i=e[At],a=i===void 0?void 0:d.find(p=>p.key===i);if(i!==void 0&&!a)throw new Error("This saved filter is unavailable. Choose another filter.");if(a&&!r&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const u=a&&e[te]===void 0?{collection:je(a,void 0,l)}:qs(e,r);if(u.error)throw u.error;const o=e[Us],c=o===void 0?a?.table??n.table??{}:Qe({table:typeof o=="string"?JSON.parse(o):o}).table??{},m=!!a&&(_t(u.collection)!==_t(je(a,void 0,l))||Se(c)!==Se(a.table??n.table??{}));return{...u,presentation:n,presets:d,preset:a,table:c,edited:m}}catch(n){return{collection:{},presentation:{},presets:[],table:{},edited:!1,error:n instanceof Error?n:new Error("Invalid collection configuration")}}}function _t(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(Q)])}function Q(e){return JSON.stringify([e.field,e.op,e.value])}function Se(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function ka(e,t){return t?{[At]:t,[te]:Ue(e)[te]??"{}"}:Ue(e)}function _a(e,t,r,l,n=new Date,d){let i=t.filters??[],a=e.viewer;if(a){const o=d?.email?Q({field:a.field,op:"eq",value:d.email.toLowerCase()}):void 0;o&&i.some(c=>Q(c)===o)?i=i.filter(c=>Q(c)!==o):a=void 0}let u=e.relativeDate;if(u){const o=(je({...e,viewer:void 0,selection:{}},n).filters??[]).map(Q),c=i.map(Q);o.every(m=>c.includes(m))?i=i.filter(m=>!o.includes(Q(m))):u=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...i.length?{filters:i}:{},...t.segment?{segment:t.segment}:{}},...Se(r)!==Se(l.table??{})?{table:r}:{},...u?{relativeDate:u}:{},...a?{viewer:a}:{}}}function $a(e,t,r){const l=[...e.filters??[]],n=r??(t.length===1&&t[0].op==="eq"?l.findIndex(i=>i.field===t[0].field&&i.op==="eq"):-1),d=n>=0?[...l.slice(0,n),...t,...l.slice(n+1)]:[...l,...t];return{...e,filters:Js({filters:d}).filters}}function Ra(e,t){return{...e,filters:e.filters?.filter((r,l)=>l!==t)}}function La(e,t){return{...typeof e.$preset=="string"?e[te]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[te]:String(Hs(e[te]))}:Ue(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const Ma=[{field:"name",label:"Name"},{field:"created_at",label:"Created"},{field:"total_content",label:"Activity count"},{field:"active_connections",label:"Connections"},{field:"automations_count",label:"Automations"},{field:"children_count",label:"Children"}];function Oa(e){return e.sort&&Ma.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Ta(e,t,r,l,n){const d={...l,filters:l.filters?.filter(i=>i.field!==r)};return Pt({queryKey:["collection-facets",e,t,r,d],enabled:!!t&&!!r,staleTime:3e4,retry:!1,queryFn:async({signal:i})=>{const a=await Ne("query_sdk",{title:`Value counts query for ${r}`,script:`const input = ${JSON.stringify({field:r,collection:d})};
2
+ ${t}`},e,{signal:i}),u=a.return_value;if(!a.success||typeof u?.connection!="string"||typeof u.sql!="string")throw new Error(a.error?.message??"Value distribution is unavailable");if(i.aborted)throw new DOMException("Aborted","AbortError");const o=await Ne("query_sql",{title:`Value counts for ${r}`,connection:u.connection,sql:u.sql,limit:51},e,{signal:i});if(o.error)throw new Error(o.error);if(!Array.isArray(o.rows))throw new Error("Source did not return value counts");const c=o.rows.map(m=>{const p=m,f=typeof p.count=="string"&&/^\d+$/.test(p.count)?Number(p.count):p.count;if(!(p.value===null||["string","number","boolean"].includes(typeof p.value))||typeof f!="number"||!Number.isSafeInteger(f)||f<0)throw new Error("Source returned an invalid value distribution");return{value:p.value,count:f}});return{values:c.slice(0,50),truncated:c.length>50||o.truncated===!0}}})}const Ia=300;function Aa({label:e,search:t,onSearch:r,className:l}){const n=t??"",[d,i]=x.useState(n),a=x.useRef({search:t,onSearch:r});a.current={search:t,onSearch:r};const u=x.useRef(void 0);x.useEffect(()=>{const c=()=>{clearTimeout(u.current),i(a.current.search??"")};return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const o=x.useRef(n);return x.useEffect(()=>{n!==o.current&&(o.current=n,i(n))},[n]),x.useEffect(()=>{if(d===(a.current.search??""))return;const c=setTimeout(()=>{const m=a.current.onSearch;o.current=d,m(d||void 0,!0)},Ia);return u.current=c,()=>clearTimeout(c)},[d]),s.jsxs("div",{className:`relative${l?` ${l}`:""}`,children:[s.jsx(Ws,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(se,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:d,onChange:c=>i(c.target.value),className:"pl-9"})]})}function Pa({field:e,initial:t,org:r,facetQuery:l,collection:n,onApply:d,close:i}){const[a,u]=x.useState(t?.op??"eq"),[o,c]=x.useState(t?.value==null?"":String(t.value)),[m,p]=x.useState(""),[f,y]=x.useState(!1),[N,v]=x.useState(),w=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",b=Ta(r,l,e.field,n),C=g=>{try{const E=f?[{field:e.field,op:"gte",value:e.type==="number"?Number(o):o},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:a,value:g}];if(e.type==="datetime-local")for(const O of E)typeof O.value=="string"&&(O.value=new Date(O.value).toISOString());if(E.some(O=>typeof O.value=="number"&&!Number.isFinite(O.value)))throw new Error("Enter a valid number.");const k=E[0].value,L=E[1]?.value;if(f&&k!=null&&L!=null&&k>L)throw new Error("The lower bound must be before the upper bound.");d(E),i()}catch(E){v(E instanceof Error?E.message:"Could not apply filter")}},j=[...e.options];for(const g of b.data?.values??[])j.some(E=>E.value===g.value)||j.push({value:g.value,label:g.value===null?"Not supplied":String(g.value)});const S=Math.max(1,...b.data?.values.map(g=>g.count)??[]);return s.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[s.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:f?"range":a,onChange:g=>{y(g.target.value==="range"),g.target.value!=="range"&&u(g.target.value)},children:[s.jsx("option",{value:"eq",children:"is"}),s.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&s.jsxs(s.Fragment,{children:[s.jsx("option",{value:"lt",children:"less than / before"}),s.jsx("option",{value:"lte",children:"at most / on or before"}),s.jsx("option",{value:"gt",children:"greater than / after"}),s.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:s.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&s.jsxs("form",{className:"space-y-2",onSubmit:g=>{g.preventDefault(),C(e.type==="number"?Number(o):o)},children:[s.jsx(se,{required:!0,"aria-label":f?"From value":"Filter value",type:w,step:e.type==="number"?"any":void 0,value:o,onChange:g=>c(g.target.value),placeholder:"Enter a value…"}),f&&s.jsx(se,{required:!0,"aria-label":"To value",type:w,step:e.type==="number"?"any":void 0,value:m,onChange:g=>p(g.target.value)}),s.jsx(R,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!f&&(a==="eq"||a==="neq")&&s.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:j.filter(g=>!o||g.label.toLowerCase().includes(o.toLowerCase())).map(g=>{const E=b.data?.values.find(k=>k.value===g.value)?.count;return s.jsxs("button",{type:"button","aria-label":g.label,onClick:()=>C(g.value),className:"relative flex w-full items-center justify-between gap-3 overflow-hidden rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[E!==void 0&&s.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${E/S*100}%`}}),s.jsx("span",{className:"relative truncate",children:g.label}),s.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:E?.toLocaleString()})]},JSON.stringify(g.value))})}),l&&b.isFetching&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),b.isError&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),b.data?.truncated&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),N&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:N})]})}function rs({collection:e,schema:t,label:r,onChange:l,org:n,facetQuery:d,segmentChip:i,viewFilters:a,onClearAll:u}){const o=Na(t),c=(y,N)=>({kind:"custom",className:"w-80",render:v=>s.jsx(Pa,{field:y,initial:N==null?void 0:e.filters?.[N],org:n,facetQuery:d,collection:e,onApply:w=>l($a(e,w,N)),close:v})}),m=o.map(y=>({key:y.field,label:y.label,icon:s.jsx(Ys,{className:"h-4 w-4"}),editor:c(y)})),p=new Map,f=(e.filters??[]).map((y,N)=>{const v=`${y.field}:${y.op}:${JSON.stringify(y.value)}`,w=p.get(v)??0;p.set(v,w+1);const b=o.find(C=>C.field===y.field);return{id:`${v}:${w}`,label:b?.label??y.field,...Sa(y,b),editor:b?c(b,N):void 0,onRemove:()=>l(Ra(e,N))}});if(i&&f.unshift(i),a?.fields.length){for(const y of m)y.group=r;m.push(...a.fields),f.push(...a.chips)}return!m.length&&!f.length?{fields:m,chips:f,clearAll:()=>{}}:{fields:m,chips:f,clearAll:u??(()=>l({...e,filters:[],segment:void 0}))}}function Fa(e){const{fields:t}=rs(e);return t.length?s.jsx(ta,{fields:t}):null}function Da(e){const{chips:t,clearAll:r}=rs(e);return t.length?s.jsx(sa,{label:`${e.label} filters`,fields:[],chips:t,onClearAll:r,className:"mb-4"}):null}const Ce=120,U=12;function $t(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Va(e){const t=e.records.slice(0,Ce),r=o=>e.types.get(o)??{label:o},l=new Map;for(const o of t)l.set(String(o.id),{source:o.source,entityType:e.typeSlug,slug:o.slug,name:o.name,isFocus:!0,hasMoreLinks:!1});const n=new Map;for(const o of e.links){if(!l.has(String(o.recordId)))continue;const c=n.get(o.recordId)??new Map;c.set(o.linkId,o),n.set(o.recordId,c)}const d=new Map;for(const[o,c]of n){const m=[...c.values()].sort($t),p=l.get(String(o));p&&m.length>U&&(p.hasMoreLinks=!0);for(const f of m.slice(0,U)){d.set(f.linkId,f);const y=String(f.peer.id);l.has(y)||l.set(y,{source:f.peer.source,...f.peer.remote?{remote:f.peer.remote}:{},entityType:f.peer.type,slug:f.peer.slug,name:f.peer.name,isFocus:!1,hasMoreLinks:!1})}}const i=[];for(const[o,c]of l){const m=c.remote?{label:c.entityType}:r(c.entityType),p=c.name||c.slug,f=c.hasMoreLinks?`${m.label} · ${U}+ links`:m.label;i.push({id:o,data:{slug:c.slug,label:p,icon:m.icon,isSystem:!1,metaLabel:f},width:ra(p,f),height:aa})}const a=new Map;for(const o of[...d.values()].sort($t)){const c=String(o.fromId),m=String(o.toId),p=JSON.stringify([c,m]),f=a.get(p)??{source:c,target:m,rels:new Map,symmetric:!0};f.symmetric&&=o.isSymmetric,f.rels.has(o.relSlug)||f.rels.set(o.relSlug,{slug:o.relSlug,label:o.relName,ruleCount:1}),a.set(p,f)}const u=[...a.entries()].map(([o,c])=>({id:`link:${o}`,source:c.source,target:c.target,data:{relationships:[...c.rels.values()],isSymmetric:c.symmetric}}));return{nodes:i,edges:u,records:l,hasMoreRecords:e.hasMore===!0||e.records.length>Ce,listedCount:t.length,focusCount:t.length}}async function Ba(e,t){const r=Va(e);return{...await na({nodes:r.nodes,edges:r.edges},t),records:r.records,hasMoreRecords:r.hasMoreRecords,listedCount:r.listedCount,focusCount:r.focusCount}}const qa=8,Ua=3,Ha=4;function ve(e){return`source:${JSON.stringify([e.type,e.key])}`}function za(e,t){return t.map(r=>{const l={type:e,key:r.slug};return{...r,id:ve(l),source:l}})}function Rt(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Ga(e,t,r){const l=e.slice(0,qa),n=[];let d=0;return await Promise.all(Array.from({length:Math.min(Ua,l.length)},async()=>{for(;d<l.length;){const i=d++,a=l[i];try{if(r?.aborted)throw r.reason;const u=await t(a),o=new Map(a.links.map(v=>[Rt(v),v]));for(const v of u.record_links){const w=Rt(v),b=o.get(w);(!b||b.occurred_at<v.occurred_at)&&o.set(w,v)}const c=new Map((a.relationships??[]).map(v=>[v.id,v]));for(const v of u.relationships??[])c.set(v.id,v);const m=[...c.values()].slice(0,U+1),p=[...o.values()].slice(0,U+1),f=(a.pagesRead??0)+1,y=!!u.next_cursor&&f>=Ha,N=u.record_failures.length>0||!!u.relationship_failures?.length||y;n[i]={read:{record:a.record,links:p,failed:N,entityId:a.entityId,relationships:m},...!y&&(N||u.next_cursor&&p.length+m.length<=U)?{next:{record:a.record,entityId:a.entityId,relationships:m,pagesRead:f,cursor:u.next_cursor??a.cursor,links:p}}:{}}}catch(u){if(r?.aborted)throw u;n[i]={read:{record:a.record,links:a.links,failed:!0,entityId:a.entityId,relationships:a.relationships},next:{...a,cursor:u instanceof Qs&&u.status===400?null:a.cursor}}}}})),{reads:n.map(i=>i.read),pending:[...n.flatMap(i=>i.next?[i.next]:[]),...e.slice(l.length)]}}function Ja(e,t){const r=new Map;for(const d of e)for(const i of d.reads)r.set(String(i.entityId??ve(i.record)),i);const l=new Map(t.map(d=>[d.slug,d])),n=[];for(const[d,i]of r){for(const a of i.relationships??[]){const u=(v,w,b)=>b?`remote:${b}`:typeof v=="number"?v:ve({type:w,key:v}),o=u(a.from_entity_id,a.from_entity_type,a.from_entity_url),c=u(a.to_entity_id,a.to_entity_type,a.to_entity_url),m=String(o)===d,p=m?c:o,f=m?a.to_entity_id:a.from_entity_id,y=m?a.to_entity_url:a.from_entity_url,N=(m?a.to_entity_type:a.from_entity_type)??"";n.push({recordId:d,linkId:a.id,fromId:o,toId:c,relSlug:a.relationship_type_slug,relName:a.relationship_type_name,isSymmetric:a.is_symmetric,peer:{id:p,name:(m?a.to_entity_name:a.from_entity_name)??String(f),slug:(m?a.to_entity_slug:a.from_entity_slug)??String(f),type:N,...y?{remote:{url:Ks(y)}}:typeof f=="string"?{source:{type:N,key:f}}:{}}})}for(const a of i.links){const u={type:a.entity_type,key:a.key},o=ve(u),c=l.get(a.relationship_type);let m=a.direction==="incoming"?o:d,p=a.direction==="incoming"?d:o;c?.is_symmetric&&m>p&&([m,p]=[p,m]),n.push({recordId:d,linkId:JSON.stringify([m,p,a.relationship_type]),fromId:m,toId:p,relSlug:a.relationship_type,relName:c?.name||a.relationship_type.replaceAll("_"," "),isSymmetric:c?.is_symmetric??!1,peer:{id:o,name:a.name||a.key,slug:a.key,type:a.entity_type,source:u}})}}return{links:n,checked:r.size,failed:[...r.values()].filter(d=>d.failed).length}}function Wa(e,t,r,l,n,d=!1){const{orgContext:i}=Ee(),a=Ft(i),u=Xs(i),o=x.useMemo(()=>d?za(t,r):r,[d,t,r]),c=x.useMemo(()=>o.slice(0,Ce).flatMap(j=>j.source?[{record:j.source,cursor:null,links:[]}]:typeof j.id=="number"?[{entityId:j.id,record:{type:t,key:j.slug},cursor:null,links:[]}]:[]),[o,t]),m=Zs({queryKey:["source-records-graph",i.organizationId,e,t,c.map(j=>[j.record,j.entityId])],enabled:!0,initialPageParam:c,queryFn:({pageParam:j,signal:S})=>Ga(j,async g=>{const E=await Ne("manage_entity",{action:"list_links",...g.entityId===void 0?{record:g.record,cursor:g.cursor}:{entity_id:g.entityId,offset:Number(g.cursor??0)},limit:U+1},e,{signal:S});return{...E,record_links:E.record_links??[],record_failures:E.record_failures??[],next_cursor:g.entityId===void 0?E.next_cursor:E.metadata?.has_more?String(Number(g.cursor??0)+U+1):null}},S),getNextPageParam:j=>j.pending.length?j.pending:void 0,staleTime:3e4,retry:!1}),p=x.useMemo(()=>m.data?Ja(m.data.pages,u.data??[]):void 0,[m.data,u.data]),f=p?.links,y=m.isError,N=JSON.stringify([i.organizationId,e,t,d,o.map(j=>[j.id,j.name,j.slug]),l]),v=x.useMemo(()=>new Map((a.data??[]).map(j=>[j.slug,{label:j.name||j.slug,icon:j.icon}])),[a.data]),[w,b]=x.useState(null);x.useEffect(()=>{if(!f)return;let j=!1;return Ba({typeSlug:t,records:o,hasMore:l,links:f,types:v},{targetAspect:n}).then(S=>{j||b({graph:S,key:N,isError:!1})}).catch(()=>{j||b({graph:null,key:N,isError:!0})}),()=>{j=!0}},[f,t,o,l,v,n,N]);const C=w?.key===N?w:null;return{graph:C?.graph??null,isLoading:!y&&!C,isError:y||C?.isError===!0,sourceProgress:{checked:p?.checked??0,total:Math.min(r.length,Ce),failed:p?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Ya(e){const t=new Map(e.nodes.map(n=>[n.id,n.data.label])),r=e.nodes.map(n=>({id:n.id,x:n.position.x+n.width/2,y:n.position.y+n.height/2,w:n.width,h:n.height,title:n.data.label,meta:n.data.metaLabel,icon:n.data.icon,muted:e.records.get(n.id)?.isFocus===!1})),l=e.edges.map(n=>{const{relationships:d,isSymmetric:i}=n.data,a=d.map(u=>u.label);return{id:n.id,source:n.source,target:n.target,route:n.route??null,summary:a.length===1?a[0]:`${a.length} relationships`,details:a,directed:!i,ariaLabel:`${t.get(n.source)??n.source} ${i?"and":"to"} ${t.get(n.target)??n.target}: ${a.join(", ")}`}});return{boxes:r,edges:l}}function Qa({ownerSlug:e,typeSlug:t,records:r,hasMore:l,sourceBacked:n=!1}){const d=ne(),i=Dt(),{orgContext:a}=Ee(),{data:u=[]}=Ft(a),o=u.find(S=>S.slug===t)?.name??t,[c,m]=x.useState(),p=x.useRef(null),f=x.useCallback(S=>{if(p.current?.disconnect(),p.current=null,!S||typeof ResizeObserver>"u")return;const g=()=>{if(!S.clientWidth||!S.clientHeight)return;const k=Math.round(S.clientHeight/S.clientWidth*10)/10;m(L=>L===k?L:k)};g();const E=new ResizeObserver(g);E.observe(S),p.current=E},[]),{graph:y,isLoading:N,isError:v,sourceProgress:w}=Wa(e,t,r,l,c,n),b=x.useMemo(()=>y?Ya(y):null,[y]),C=x.useCallback(S=>{const g=y?.records.get(S);if(g){if(g.remote){g.remote.url&&window.open(g.remote.url,"_blank","noopener,noreferrer");return}if(i){i.open(ia({...g.source?{record:g.source}:{entityId:Number(S)},ownerSlug:e,orgContext:a,name:g.name||g.slug}));return}d({to:en(e,[{entity_type:g.entityType,slug:g.slug}])})}},[y,e,a,i,d]);if(v)return s.jsx(tn,{label:`${o} graph`});if(N||!y||!b)return s.jsx(Zt,{label:`Loading ${o} graph`});const j=w?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[s.jsxs("p",{children:["Checked ",w.checked," of ",w.total," records. Up to ",U," relationships per record."]}),w.failed>0?s.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),w.hasMore?s.jsx(R,{variant:"outline",size:"sm",disabled:w.isFetching,onClick:w.loadMore,children:w.isFetching?"Loading…":w.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return y.focusCount===0?s.jsxs("div",{className:"space-y-3",children:[j,s.jsx(Vt,{icon:Bt,title:`No ${o} records match`,description:"Change the search or filters to see records here."})]}):s.jsxs("div",{className:"flex flex-col gap-2",children:[j,s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",y.hasMoreRecords?"the first ":"",y.focusCount," ",o," record",y.focusCount===1?"":"s",". Click a record to see it."]}),s.jsx("div",{ref:f,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:s.jsx(oa,{boxes:b.boxes,edges:b.edges,label:`${o} records`,onOpenBox:C,openLabel:S=>`Show ${S.title}`})})]})}function Ka(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function os(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function Ke(e){const t=e?.properties;if(!t)return null;const n=sn(t).find(([,o])=>os(o)==="workflowState");if(!n)return null;const[d,i]=n,a=i["x-lobu"]?.states,u=Array.isArray(a)&&a.length>0?a:(i.enum??[]).map(o=>({value:o}));return u.length===0||u.some(o=>typeof o.value!="string")?null:{field:d,states:u.map(o=>({...o,label:o.label||nn(i,o.value)||Ka(o.value),terminal:o.terminal??["done","complete","completed","closed","archived"].includes(o.value.toLowerCase())}))}}function Xa(e){const t=e?.properties;if(!t)return null;const r=Object.entries(t),l=r.find(([,i])=>os(i)==="sortRank"),n=r.find(([i])=>["rank","sort_rank","order"].includes(i)),d=l??n;return d?{field:d[0]}:null}function Za(e,{isDerived:t}){const r=e?.["x-lobu"]?.defaultView;return(r==="table"||r==="board")&&!(t&&r!=="table")?r:t?"table":Ke(e)?"board":"table"}const is={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},er={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function tr(e){const{canShowBoard:t,builtinData:r,builtInLabels:l}=e,n=["table",...t?["board"]:[]],d={table:is,board:er};return n.map(i=>({id:i,label:l[i],builtInMode:i,template:d[i],data:r}))}function We(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function we(e,t){if(!t)return e.created_at??String(e.id);const r=_e(e.metadata);return String(r[t.field]??e.created_at??e.id)}function sr(e,t){const r=e?Number(e):Number.NaN,l=t?Number(t):Number.NaN;return Number.isFinite(r)&&Number.isFinite(l)&&r<l?String((r+l)/2):Number.isFinite(r)?String(r+1):Number.isFinite(l)?String(l-1):String(Date.now())}function Ye(e,t){const r=_e(e.metadata);return String(r[t]??"")}function ls(e,t){return[...e].sort((r,l)=>we(r,t).localeCompare(we(l,t)))}function nr(e,t,r,l,n){if(!t.startsWith("card:")||!r)return null;const d=Number(t.slice(5)),i=e.find(b=>b.id===d);if(!i)return null;const a=r.startsWith("column:")?r.slice(7):Ye(e.find(b=>`card:${b.id}`===r)??i,l.field);if(!a)return null;const u=ls(e.filter(b=>b.id!==d&&Ye(b,l.field)===a),n),o=r.startsWith("card:")?u.findIndex(b=>`card:${b.id}`===r):u.length,c=o>=0?o:u.length,m=c>0?u[c-1]:void 0,p=u[c],f=n?sr(m?we(m,n):void 0,p?we(p,n):void 0):void 0,y=_e(i.metadata),N={[l.field]:a,...n&&f?{[n.field]:f}:{}};l.states.find(b=>b.value===a)?.terminal&&!y.completed_at&&(N.completed_at=new Date().toISOString());const w={...y,...N};return{entityId:d,changedMetadata:N,nextMetadata:w}}function Lt(e,t,r){return e.map(l=>l.id===t?{...l,metadata:r}:l)}function ar({id:e,children:t,className:r}){const{setNodeRef:l,isOver:n}=ts({id:`column:${e}`});return s.jsx("div",{ref:l,className:ie("min-h-[220px] rounded-lg bg-card p-2 transition-colors",n?"bg-accent/50":"",r),children:t})}function rr({entity:e,owner:t,statusField:r,entityTypeIcon:l,schema:n,didDragRef:d}){const i=_e(e.metadata),{attributes:a,listeners:u,setNodeRef:o,transform:c,isDragging:m}=ha({id:`card:${e.id}`}),{setNodeRef:p,isOver:f}=ts({id:`card:${e.id}`}),y=qt(t,es(e)),N=v=>{d.current&&(v.preventDefault(),v.stopPropagation())};return s.jsx("div",{ref:v=>{o(v),p(v)},style:{transform:ga.Translate.toString(c)},className:ie(on,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",m?"opacity-60":"",f?"ring-1 ring-ring":""),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...a,...u,children:s.jsx(rn,{className:"h-4 w-4"})}),s.jsx(Xt,{metadata:i,metadataSchema:n,name:e.name,typeIcon:l,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(ke,{to:y,className:"font-medium text-foreground hover:underline",onClick:N,children:e.name}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof i.priority=="string"&&i.priority?s.jsx(ze,{variant:"outline",className:"text-xs",children:We(i.priority)}):null,typeof i[r]=="string"&&i[r]?s.jsx(ze,{variant:"secondary",className:"text-xs",children:We(String(i[r]))}):null]})]})]})})}function or({owner:e,entities:t,totalCount:r,schema:l,entityTypeIcon:n,onUpdate:d}){const i=x.useMemo(()=>Ke(l),[l]),a=x.useMemo(()=>Xa(l),[l]),[u,o]=x.useState(t),[c,m]=x.useState(()=>new Set),p=x.useRef(!1),f=ua(ma(fa,{activationConstraint:{distance:6}})),y=x.useCallback(()=>{window.setTimeout(()=>{p.current=!1},0)},[]);x.useEffect(()=>{o(t)},[t]);const N=x.useMemo(()=>{if(!i)return new Map;const C=new Map(i.states.map(j=>[j.value,[]]));for(const j of u){const S=Ye(j,i.field),g=C.has(S)?S:i.states[0]?.value;g&&C.get(g)?.push(j)}for(const[j,S]of C)C.set(j,ls(S,a));return C},[u,a,i]);if(!i)return null;const v=C=>{m(j=>{const S=new Set(j);return S.has(C)?S.delete(C):S.add(C),S})},w=()=>{p.current=!0},b=C=>{const j=String(C.active.id),S=C.over?String(C.over.id):null,g=nr(u,j,S,i,a);if(!g){y();return}const{entityId:E,changedMetadata:k,nextMetadata:L}=g,X=u.find($=>$.id===E)?.metadata;o($=>Lt($,E,L)),d(E,k).catch(()=>{o($=>Lt($,E,X))}),y()};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-semibold",children:"Board"}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",We(i.field),typeof r=="number"&&r>u.length?s.jsxs(s.Fragment,{children:[" · ",s.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",u.length," of ",r," — narrow with search"]})]}):null]})]}),s.jsx(pa,{sensors:f,onDragStart:w,onDragEnd:b,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:i.states.map(C=>{const j=N.get(C.value)??[],S=C.collapsed??C.terminal,g=S&&!c.has(C.value);return s.jsxs(ar,{id:C.value,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[C.terminal?s.jsx(an,{className:"h-4 w-4 text-muted-foreground"}):null,s.jsx("h3",{className:"text-sm font-medium",children:C.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ze,{variant:"secondary",className:"text-xs",children:j.length}),S?s.jsx(R,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>v(C.value),children:g?"Show":"Hide"}):null]})]}),g?s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[j.length," hidden ",C.label?.toLowerCase()," item",j.length===1?"":"s"]}):s.jsx("div",{className:"space-y-2",children:j.length>0?j.map(E=>s.jsx(rr,{entity:E,owner:e,statusField:i.field,entityTypeIcon:n,schema:l,didDragRef:p},E.id)):s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",C.label?.toLowerCase()," items"]})})]},C.value)})})})]})}const ir=x.memo(or);function lr(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t.toString(36)}function cs(e,t){return{queryKey:["metric_series",e,lr(t)],queryFn:()=>Ne("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function ds(e,t){const r=!!e&&!!t,l=cs(e??"",t??"");return Pt({...l,enabled:r})}ds.queryOptions=(e,t)=>cs(e,t);function cr(e,t){if(!e?.columns?.length||!e.rows)return[];const r=e.columns.indexOf(t);return r<0?[]:e.rows.map(l=>Number(l[r])||0)}const Mt=/^[a-z][a-z0-9_]*$/;function dr(e){const t=Object.entries(e);for(const[n,d]of t){if(!Mt.test(n))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${n}'`);if(!Mt.test(d))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${d}'`)}const r=t.flatMap(([n,d])=>[`COUNT(*) FILTER (
3
+ WHERE semantic_type = 'change'
4
+ AND metadata->>'category' = 'lifecycle'
5
+ AND metadata->>'entity_type' = '${d}'
6
+ AND metadata->>'op' = 'created'
7
+ ) AS ${n}_added`,`COUNT(*) FILTER (
8
+ WHERE semantic_type = 'change'
9
+ AND metadata->>'category' = 'lifecycle'
10
+ AND metadata->>'entity_type' = '${d}'
11
+ AND metadata->>'op' = 'deleted'
12
+ ) AS ${n}_removed`]).join(`,
13
+ `),l=t.map(([n])=>` SUM(COALESCE(b.${n}_added, 0) - COALESCE(b.${n}_removed, 0))
14
+ OVER (ORDER BY d.bucket) AS ${n}`).join(`,
15
+ `);return`
16
+ WITH days AS (
17
+ SELECT generate_series(
18
+ date_trunc('day', now() - interval '13 days'),
19
+ date_trunc('day', now()),
20
+ interval '1 day'
21
+ ) AS bucket
22
+ ),
23
+ buckets AS (
24
+ SELECT
25
+ date_trunc('day', created_at) AS bucket,
26
+ ${r}
27
+ FROM events
28
+ WHERE created_at > now() - interval '14 days'
29
+ GROUP BY 1
30
+ )
31
+ SELECT d.bucket,
32
+ ${l}
33
+ FROM days d
34
+ LEFT JOIN buckets b ON b.bucket = d.bucket
35
+ ORDER BY d.bucket
36
+ `}const ur={"memory-activity":`
37
+ WITH days AS (
38
+ SELECT generate_series(
39
+ date_trunc('day', now() - interval '13 days'),
40
+ date_trunc('day', now()),
41
+ interval '1 day'
42
+ ) AS bucket
43
+ ),
44
+ buckets AS (
45
+ SELECT
46
+ date_trunc('day', created_at) AS bucket,
47
+ COUNT(*) FILTER (
48
+ WHERE semantic_type NOT IN ('change', 'audit', 'operation')
49
+ ) AS events_count,
50
+ COUNT(*) FILTER (
51
+ WHERE semantic_type = 'change'
52
+ AND metadata->>'category' = 'lifecycle'
53
+ AND metadata->>'entity_type' = 'connection'
54
+ AND metadata->>'op' = 'created'
55
+ ) AS connections_added,
56
+ COUNT(*) FILTER (
57
+ WHERE semantic_type = 'change'
58
+ AND metadata->>'category' = 'lifecycle'
59
+ AND metadata->>'entity_type' = 'connection'
60
+ AND metadata->>'op' = 'deleted'
61
+ ) AS connections_removed
62
+ FROM events
63
+ WHERE created_at > now() - interval '14 days'
64
+ GROUP BY 1
65
+ )
66
+ SELECT d.bucket,
67
+ COALESCE(b.events_count, 0)::int AS events,
68
+ SUM(COALESCE(b.connections_added, 0) - COALESCE(b.connections_removed, 0))
69
+ OVER (ORDER BY d.bucket) AS connections
70
+ FROM days d
71
+ LEFT JOIN buckets b ON b.bucket = d.bucket
72
+ ORDER BY d.bucket
73
+ `};function mr(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const t=Object.fromEntries(Object.entries(e.lifecycle).map(([r,l])=>[r,String(l)]));if(Object.keys(t).length>0)try{return dr(t)}catch{return null}}return typeof e.preset=="string"?ur[e.preset]??null:null}function pr({owner:e,sql:t,lifecycle:r,preset:l,column:n,chart:d,height:i,width:a,color:u,label:o,className:c}){const m=x.useMemo(()=>mr({sql:t,lifecycle:r,preset:l}),[t,r,l]),p=typeof e=="string"&&e?e:null,{data:f}=ds(p,m),y=String(n??""),N=x.useMemo(()=>cr(f,y),[f,y]),v=x.useMemo(()=>!f?.columns?.length||!f.rows?[]:f.rows.map((b,C)=>({label:String(b[0]??"").slice(0,10),value:N[C]??0})),[f,N]);if(!p||!m||!y)return null;const w=d==="line"?s.jsx(la,{data:v,height:typeof i=="number"?i:void 0}):s.jsx(ca,{data:N,height:typeof i=="number"?i:void 0,width:typeof a=="number"?a:void 0,color:typeof u=="string"?u:void 0});return o==null?s.jsx("div",{className:c,children:w}):s.jsxs("div",{className:c,children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:String(o)}),w]})}function fr({metadata:e,metadataSchema:t,name:r,typeIcon:l,initialsFallback:n,className:d}){return s.jsx(Xt,{metadata:e,metadataSchema:t,name:String(r??""),typeIcon:l,initialsFallback:!!n,className:d})}function hr({entity:e,owner:t,className:r,onClick:l,children:n}){const d=e;if(!d)return s.jsx(s.Fragment,{children:n});const i=qt(String(t??""),es(d));return s.jsx(ke,{to:i,className:r,onClick:l,children:n})}function gr({state:e}){return e?s.jsx(Kn,{...e}):null}function yr({state:e,onUpdate:t}){return e?s.jsx(ir,{...e,onUpdate:t}):null}const xr={"entity-avatar":fr,"entity-link":hr,"entity-table":gr,"entity-board":yr,"metric-series":pr};function br({ownerSlug:e,typeSlug:t,title:r,shape:l}){const[n,d]=x.useState(!1),i=ne(),{visible:a,system:u,isTypesLoading:o}=ln(e),c=p=>{d(!1);const f=`/${e}/${Wt(p)}`;i({to:l?`${f}/${Yt}/${l}`:f})},m=p=>s.jsxs(hn,{value:`${p.name} ${p.slug}`,onSelect:()=>c(p.slug),children:[s.jsx(Jt,{icon:p.icon,className:"mr-2 h-4 w-4 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:p.name||p.slug}),p.slug===t?s.jsx(gn,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,p.entity_count!=null?s.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:p.entity_count.toLocaleString()}):null]},p.slug);return s.jsxs(Ut,{open:n,onOpenChange:d,children:[s.jsx("h1",{className:"flex min-w-0 items-center text-lg font-semibold tracking-tight @sm:text-2xl",children:s.jsx(Ht,{asChild:!0,children:s.jsxs(R,{type:"button",variant:"ghost",title:r,className:"-ml-2 h-auto min-w-0 gap-1 px-2 py-1 text-lg font-semibold tracking-tight @sm:gap-1.5 @sm:text-2xl",children:[s.jsx("span",{className:"truncate",children:r}),s.jsx(zt,{className:"h-5 w-5 shrink-0 text-muted-foreground"})]})})}),s.jsx(Gt,{align:"start",className:"w-72 p-0",children:s.jsxs(cn,{children:[s.jsx(dn,{autoFocus:!0,placeholder:"Find a type…"}),s.jsxs(un,{children:[s.jsx(mn,{children:o?"Loading types…":"No type matches."}),a.length>0?s.jsx(wt,{heading:"Types",children:a.map(m)}):null,u.length>0?s.jsx(wt,{heading:"System",children:u.map(m)}):null]}),s.jsx(pn,{}),s.jsxs(ke,{to:"/$owner",params:{owner:e},search:{layout:"graph"},onClick:()=>d(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(fn,{className:"h-4 w-4"}),"Data map"]})]})})]})}function vr(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,r])=>({name:t,description:r.description}))}const be={table:{label:"Table",icon:En},board:{label:"Board",icon:wn},graph:{label:"Graph",icon:Bt}},us=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,jr=new Set(["table","board","graph"]);function Nr(e,t){const r=_n(us(e,t));return r&&jr.has(r)?r:void 0}function Sr(e,t,r){$n(us(e,t),r)}const Ot=":records";function Cr({ownerSlug:e,entityTypeSlug:t,create:r,onCreateChange:l,viewKey:n,shape:d}){const{orgContext:i,hasOrgContext:a}=Ee(),u=Tt(t,i),{data:o,isLoading:c,error:m}=u;yn(`/${e}`,i);const p=xn(),[f,y]=x.useState({key:"",page:0}),N=Qt({strict:!1}),v=ne(),w=Dt(),b=`/${e}/${Wt(t)}`,{session:C,isReady:j}=bn(),S=j&&!c&&o?.slug===t,g=C?.user?.email,E=x.useMemo(()=>g?{email:g}:void 0,[g]),{collection:k,error:L,presentation:O,presets:X,preset:$,edited:le,table:I}=x.useMemo(()=>Ea(N,o?.metadata_schema,!!n,E),[N,o?.metadata_schema,n,E]),z=S?L:void 0,G=x.useMemo(()=>La(N,k),[N,k]),[ms,Xe]=x.useState(!1),[$e,ps]=x.useState(0),Re=k.search??"",Z=k.segment,fs=JSON.stringify(k),ae=Z?vr(o).find(h=>h.name===Z)??{name:Z,description:""}:null,hs=h=>void v({to:".",search:_=>({...Ge(_,K(h)),...G}),replace:!0}),J=vn(u.data),Ze=J?I.sort:Oa(I),Le=Ze?.field,et=Ze?.order,W=x.useMemo(()=>Le?[{id:Le,desc:et==="desc"}]:[],[Le,et]),ce=x.useCallback(h=>void v({to:".",search:{...n?K(N):{},...G,$table:JSON.stringify(h)},replace:!0}),[v,n,N,G]),tt=x.useCallback(h=>{const _=typeof h=="function"?h(W):h;_[0]&&ce({...I,sort:{field:_[0].id,order:_[0].desc?"desc":"asc"}})},[W,ce,I]),de=r===!0,st=()=>l(!0),gs=()=>l(!1),ys=W[0]?.id,xs=W[0]?W[0].desc?"desc":"asc":void 0,Me=u.data?.metadata_schema,ue=!!Ke(Me)&&!J,bs=Za(Me,{isDerived:J}),P=Kt(i),vs=Be(P.data??[],t,k),re=(h,_=!1,A=K(N))=>{const T=!n||!P.data||Be(P.data,t,h).some(ye=>ye.key===n);v({to:T?".":b,search:{...T&&n?A:{},...ka(h,$?.key),$table:JSON.stringify(I)},replace:_})},me=h=>{const _=h?je(h,void 0,E):{},A=!n||Be(P.data??[],t,_).some(T=>T.key===n);Xe(!1),ps(T=>T+1),v({to:A?".":b,search:h?{$preset:h.key}:{}})},{isAdmin:js}=jn(i.organizationId),Oe=Nn(i),Ns=js&&!!o&&!u.isPlaceholderData,nt=x.useRef(N);nt.current=N;const Ss=async()=>{if(!$)return;const h=JSON.stringify(N),{data:_}=await u.refetch(),A=_?.metadata_schema,T=A?Qe(A[He]??{}):void 0,ye=T?.presets?.find(xe=>xe.key===$.key);if(!_||!A||!T||!ye){It.error("This saved filter changed. Reload and try again.");return}const De=_a(ye,k,I,T,void 0,E);await Oe.mutateAsync({slug:_.slug,metadata_schema:{...A,[He]:{...T,presets:T.presets?.map(xe=>xe.key===De.key?De:xe)}}}).then(()=>!0,()=>!1)&&(await u.refetch(),JSON.stringify(nt.current)===h&&me(De))},Cs=x.useMemo(()=>Nr(e,t),[e,t]),D=Sn(P.data??[],t,{viewKey:n,shape:d??(n?void 0:Cs)},bs,k),V=D.kind==="builtin"?D.mode==="board"&&!ue?"table":D.mode:null,at=V==="graph";x.useEffect(()=>{d&&S&&V&&Sr(e,t,V)},[d,S,V,e,t]);const rt=["table",...ue?["board"]:[],"graph"],Y=D.kind==="view"?D.view:null,ot=D.kind==="missing"?D.key:null,Te=D.kind==="inapplicable"?D:null,oe=V==="table"?50:200,pe=`${t}?${fs}&sort=${JSON.stringify(I.sort)}&size=${oe}`,fe=f.key===pe?f.page:0,Ie=x.useCallback(h=>y(_=>({key:pe,page:h(_.key===pe?_.page:0)})),[pe]),he=Et(t,i,{limit:oe,offset:fe*oe,search:Re.trim()||void 0,sortBy:ys,sortOrder:xs,segment:Z,filters:k.filters,enabled:S&&!n&&!z}),it=Et(t,i,{limit:1,offset:0,parentId:null,search:Re.trim()||void 0,segment:Z,filters:k.filters,enabled:S&&!n&&!z&&!J}),{data:ge,error:ws}=he,Es=he.isLoading||he.isPending&&he.fetchStatus==="paused",lt=z||m||(n?null:ws),ks=!!n&&P.data===void 0&&P.isError,B=ge?.entities??[],Ae=ge?.metadata?.has_more??!1,F=ge?.metadata?.total_count??0,ct=B.length>0||Re.trim().length>0||fe>0||!!Z||!!k.filters?.length,M=o?.name?.trim()||qe(t),ee=o?.icon||void 0,q=J,H=Me,_s=!z&&(!a||!S||(n?P.data===void 0&&!P.isError:Es||!J&&it.isLoading)),dt=ge?.linked_entities??{},ut=it.data?.metadata?.total_count,mt=F>0&&typeof ut=="number"?ut<F:!1,pt=x.useMemo(()=>o?.measure_columns??[],[o?.measure_columns]),ft=x.useCallback(h=>ce({...I,columns:h}),[ce,I]),ht=x.useMemo(()=>({entities:B,owner:e,schema:H,entityTypeIcon:ee,isDerived:q,measureColumns:pt,linkedEntityLookups:dt,hasAnyParents:mt,sorting:W,onSortingChange:tt,visibleColumns:I.columns,columnChoices:Xn(H,q,B),onVisibleColumnsChange:ft,page:fe,pageSize:oe,totalCount:F,hasMore:Ae,pageTitle:M,onPrevPage:()=>Ie(h=>Math.max(0,h-1)),onNextPage:()=>Ie(h=>h+1)}),[B,e,H,ee,q,pt,dt,mt,W,I.columns,ft,tt,Ie,fe,oe,F,Ae,M]),gt=F>B.length,yt=`showing first ${B.length} of ${F} — narrow with search`,xt=x.useMemo(()=>({owner:e,entityType:o,entities:B,totalCount:F,schema:H,entityTypeIcon:ee}),[e,o,B,F,H,ee]),Pe=x.useMemo(()=>({tableState:ht,boardState:xt,owner:e,schema:H,entityType:o,entityTypeIcon:ee,totalCount:F,isTruncated:gt,truncationNotice:yt,canCreate:!q,addLabel:`Add ${o?.name||qe(t)}`}),[ht,xt,e,H,o,ee,F,gt,yt,q,t]),$s=x.useMemo(()=>tr({canShowBoard:ue,builtinData:Pe,builtInLabels:{table:be.table.label,board:be.board.label}}),[ue,Pe]),bt=V?$s.find(h=>h.id===V)??null:null,Rs=bt?.template??is,Ls=bt?.data??Pe,vt=h=>void v({to:h===Ot?b:`${b}${Je(h)}`,search:G}),Fe=K(N),Ms=ya(Y?.params,Fe,h=>void v({to:".",search:{...K(h),...G}})),Os=()=>re({...k,filters:[],segment:void 0},!1,xa(Y?.params,Fe)),jt={collection:k,schema:H,label:M,org:i??"",facetQuery:O.facetQuery,onChange:re,viewFilters:Ms,onClearAll:Os,segmentChip:ae?{id:"segment",label:"Segment",op:"is",value:qe(ae.name),title:ae.description||void 0,editor:ae.description?{kind:"custom",render:()=>s.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ae.description})}:void 0,onRemove:()=>re({...k,segment:void 0})}:void 0},Nt=`Moved on ${o?.name||o?.slug||t} board`,St=x.useMemo(()=>(h,_)=>p.mutateAsync({entityId:h,metadata:_,field_note:Nt}),[p,Nt]),Ts=x.useMemo(()=>({updateEntity:St,openCreate:()=>l(!0)}),[St,l]),Ct=h=>w?s.jsx("span",{className:h,children:s.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Edit type",title:"Edit type",onClick:()=>w.open({href:Ln(e,t),title:M}),children:s.jsx(Rn,{className:"h-4 w-4"})})}):null;return s.jsx(Zn,{title:s.jsx(br,{ownerSlug:e,typeSlug:t,title:M,shape:n?null:V}),actions:Ct("hidden @sm:contents"),controls:s.jsxs(s.Fragment,{children:[de?s.jsx("div",{className:"max-w-3xl",children:s.jsx(ja,{onClose:gs,entityTypeSlug:t,orgContext:i})}):null,!de&&S&&s.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${M} views`,children:[Ct("-mr-1 @sm:hidden"),!n&&rt.length>1&&s.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:rt.map(h=>{const _=be[h].icon,A=V===h;return s.jsx(R,{type:"button",variant:"ghost",size:"sm","aria-pressed":A,title:be[h].label,"data-testid":`shape-${h}`,className:ie("h-7 px-2",A&&"bg-accent text-accent-foreground"),onClick:()=>void v({to:`${b}/${Yt}/${h}`,search:G,replace:!0}),children:s.jsx(_,{className:"h-4 w-4"})},h)})}),n&&s.jsx(R,{variant:"ghost",onClick:()=>vt(Ot),children:"Records"}),!!X.length&&s.jsxs(Ut,{open:ms,onOpenChange:Xe,children:[s.jsx(Ht,{asChild:!0,children:s.jsxs(R,{variant:"outline",className:ie("gap-2",le&&"border-dashed border-primary"),"data-edited":le||void 0,title:"Choose saved filter",children:[$?.label??(k.filters?.length||k.search?"Custom filter":"All records"),le?s.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,s.jsx(zt,{className:"h-4 w-4 text-muted-foreground"})]})}),s.jsxs(Gt,{align:"start",className:"w-60 p-1",children:[s.jsx(R,{variant:$?"ghost":"secondary",className:"w-full justify-start",onClick:()=>me(),children:"All records"}),X.map(h=>s.jsx(R,{variant:$?.key===h.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>me(h),children:h.label},h.key))]})]}),$&&le?s.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[s.jsx(R,{variant:"ghost",size:"sm",onClick:()=>me($),children:"Reset"}),Ns?s.jsx(R,{size:"sm",disabled:Oe.isPending,onClick:()=>void Ss(),children:Oe.isPending?"Saving…":"Save"}):null]}):null,vs.map(h=>s.jsx(R,{"data-testid":`tab-${h.key}`,variant:n===h.key?"secondary":"ghost","aria-pressed":n===h.key,onClick:()=>vt(h.key),children:h.name},h.key)),!z&&s.jsx(Fa,{...jt},`filters:${t}:${$e}`),s.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-x-3 gap-y-2",children:[s.jsx(Aa,{label:M,search:k.search,onSearch:(h,_)=>re({...k,search:h},_),className:"w-64 max-w-full"},`search:${t}:${$e}`),!q&&!n?s.jsxs(R,{size:"sm","aria-label":`Add ${M||"entity"}`,onClick:()=>st(),children:[s.jsx(kn,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),!de&&S&&!z?s.jsx(Da,{...jt},`applied:${t}:${$e}`):null]}),children:de?null:_s?at?s.jsx(Zt,{label:`Loading ${M} graph`}):s.jsx(ea,{}):lt?s.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[lt.message||`Failed to load ${M.toLowerCase()}.`,z&&s.jsx(R,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>re({}),children:"Clear filters"})]}):ks?s.jsx(ss,{onRetry:()=>void P.refetch()}):Te?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[s.jsxs("h2",{className:"text-lg font-semibold",children:["“",Te.view.name,"” doesn’t apply to the current filters"]}),s.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(Te.when).map(([h,_])=>`${h} is ${_===null?"not supplied":String(_)}`).join(" and "),"."]}),s.jsx(ke,{to:b,search:G,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${M}`})]}):ot?s.jsx(ns,{viewKey:ot,backTo:b,backLabel:`Back to ${M}`}):Y?s.jsx(as,{orgSlug:e,viewKey:Y.key,scope:{type:t,collection:k},params:Fe,onParamsChange:hs,paramDecls:Y.params,contentHash:Y.content_hash,title:Y.name,minHeight:320}):at&&ct?s.jsx(Qa,{ownerSlug:e,typeSlug:t,sourceBacked:J,records:B.map(h=>({...h,id:h.id??JSON.stringify([h.entity_type,h.slug])})),hasMore:Ae}):ct?s.jsx(da,{template:Rs,data:Ls,actions:Ts,components:xr}):s.jsx(Vt,{icon:Cn,iconElement:s.jsx(Jt,{icon:o?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${M.toLowerCase()} yet`,description:q?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${o?.name?.toLowerCase()||"entity"}.`,actionLabel:q?void 0:`Add ${o?.name||"Entity"}`,onAction:q?void 0:()=>st()})})}function wr(e,t){return ie("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",t,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}const Er=12,kr=50;function _r({navigation:e,views:t,currentKey:r}){const l=ne(),[n,d]=x.useState(""),i=x.useMemo(()=>e.filter(c=>!c.external&&c.href.includes("/-/views/")),[e]),a=Mn(i,t,n,n.trim()?kr:Er),u=On(i,t,n),o=c=>{c.key==="Enter"&&a[0]&&(c.preventDefault(),l({href:a[0].href}))};return s.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-col gap-2",children:[s.jsx(se,{type:"search","aria-label":"Find a view",placeholder:"Find a view",value:n,onChange:c=>d(c.target.value),onKeyDown:o,className:"h-8 max-w-sm"}),a.length>0?s.jsx("ul",{className:"flex flex-wrap items-center gap-1",children:a.map(c=>{const m=c.key===r;return s.jsx("li",{children:s.jsxs(Tn,{item:{id:c.key,label:c.label,href:c.href,children:[]},active:m,className:wr(m,"min-h-8 max-w-full gap-2 px-3 text-sm break-words"),children:[s.jsx("span",{children:c.label}),c.trail.length>0&&c.trail[0]!=="Views"?s.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:c.trail.join(" › ")}):null]})},c.key)})}):s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["No view matches “",n.trim(),"”."]}),u>a.length?s.jsxs("p",{role:"status",className:"text-xs text-muted-foreground",children:["Showing ",a.length," of ",u,". Type to narrow the list."]}):null]})}function $r({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){const d=ne(),i=Qt({strict:!1}),a=t?In(t):void 0,u=a==="$member",o=m=>{if(!a)return;const p=Hn(e,a);d({to:p.to,params:p.params,search:m?{create:!0}:{},replace:!0})},c=a?s.jsx(Cr,{ownerSlug:e,entityTypeSlug:a,create:r,onCreateChange:o,viewKey:l,shape:n}):l?s.jsx(Rr,{ownerSlug:e,viewKey:l,search:i}):null;return s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:u?s.jsx(va,{children:c}):c})}function Rr({ownerSlug:e,viewKey:t,search:r}){const l=ne(),{orgContext:n}=Ee(),{data:d,isError:i,error:a,refetch:u}=Kt(n),o=An(n),c=Pn(e,`/${e}/data`),m=Fn(d??[],t),p=Dn(),f=Vn(d??[]),y=i?Bn(a,{subject:"Views"}):null;if(d===void 0)return i?s.jsx(ss,{error:a,onRetry:()=>void u()}):null;if(m.kind==="missing")return s.jsx(ns,{viewKey:m.key,backTo:`/${e}`,backLabel:"Back to Home"});const N=qn(o.data??[]),v=f.some(b=>!N.has(`/${e}/data${Je(b.key)}`)),w=f.length>0&&(p||o.data!==void 0&&v);return s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[w?s.jsx(_r,{navigation:c.navigation,views:c.views,currentKey:Un(`/${e}/data${Je(t)}`,r)}):null,p&&y?s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[y.title,"."," ",y.retryable?s.jsx("button",{type:"button",onClick:()=>void u(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,s.jsx(ba,{decls:m.view.params,params:K(r),onParamsChange:b=>void l({to:".",search:C=>Ge(C,b)})}),s.jsx(as,{orgSlug:e,viewKey:m.view.key,scope:{},params:K(r),onParamsChange:b=>void l({to:".",search:C=>Ge(C,b),replace:!0}),paramDecls:m.view.params,contentHash:m.view.content_hash,title:m.view.name,minHeight:400})]})}function qr({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){return s.jsxs(zn,{inset:l?"flush":"page",className:l?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[s.jsx(Jn,{}),s.jsx(Gn,{owner:e,children:d=>s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:s.jsx($r,{ownerSlug:d.ownerSlug,typeScope:t,create:r,viewKey:l,shape:n})})})]})}export{qr as M};
74
+ //# sourceMappingURL=memory-browse-page-Ba4aYavw.js.map
@@ -1,2 +1,2 @@
1
- import{aJ as v,aK as N,j as s,gF as y,dq as m,a4 as p,i as f,B as w,gH as b}from"./index-C2TCKJDP.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=v(),{data:a=[]}=N(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),g=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),g?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
- //# sourceMappingURL=model-selector-BrfaDwIg.js.map
1
+ import{aX as v,aY as N,j as s,gS as y,aP as m,a4 as p,i as f,B as w,gU as b}from"./index-CdDNNAx2.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function S(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function D({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=v(),{data:a=[]}=N(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),g=S(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),g?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{D as M,M as b,S as s};
2
+ //# sourceMappingURL=model-selector-XYmk7Iru.js.map
@@ -0,0 +1,2 @@
1
+ import{r as N,j as e,er as M,es as $,et as B,eu as b,G as S,ev as E,ew as _,ex as f,B as O,a4 as P,bz as j}from"./index-CdDNNAx2.js";const T=5,Y=5;function z({entries:s,onMarkRead:t,disabled:o=!1}){const n=s.filter(r=>r.unreadIds.length>0);return n.length===0?null:e.jsxs("button",{type:"button",disabled:o,className:"ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>t(n.flatMap(r=>r.unreadIds)),children:[e.jsx($,{"aria-hidden":"true",className:"h-3.5 w-3.5"}),"Mark ",n.length," read"]})}function W({owner:s,entries:t,pageIds:o,onMarkRead:n,markPending:r}){const[u,x]=N.useState(!1);if(t.length===0)return null;const a=u?t:t.slice(0,Y),d=t.length-a.length,p=i=>{const c=o.has(i.item.id)?"This page":w(i);return c?`Needs you · ${c}`:"Needs you"};return e.jsxs("ul",{"aria-label":"Needs you",className:"mb-4 divide-y overflow-hidden rounded-lg border",children:[t.length>1?e.jsxs("li",{className:"flex flex-wrap items-center gap-2 px-3 py-1.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[t.length," need you"]}),e.jsx(z,{entries:t,onMarkRead:n,disabled:r}),e.jsx(M,{owner:s,showMarkRead:!1})]}):null,e.jsx(y,{owner:s,entries:a,tag:p}),d>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>x(!0),children:["Show all ",t.length]})}):null]})}function F({owner:s,entries:t}){return t.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:e.jsx(y,{owner:s,entries:t,tag:w})})}const w=s=>s.repeats>1?`${s.repeats}×`:void 0;function y({owner:s,entries:t,tag:o}){return B(t).map(n=>e.jsx("li",{children:n.entries.length>1?e.jsx(D,{owner:s,group:n}):e.jsx(b,{owner:s,item:n.entries[0].item,variant:"row",tag:o(n.entries[0])})},n.key))}function D({owner:s,group:t}){const[o,n]=N.useState(!1),{orgContext:r}=S(),u=E(),x=_(r),{entries:a}=t,d=a[0],p=a[a.length-1],i=new Set(a.map(({card:l})=>l.run_id)).size,c=o?a:a.slice(0,T),g=a.length-c.length,m=a.flatMap(({item:l})=>l.approvalRunId!=null?[l.approvalRunId]:[]),k=u.isPending||x.isPending,R=d.card.automation_name?.trim(),A=d.card.at===p.card.at?f(d.card.at):`${f(p.card.at)} – ${f(d.card.at)}`,C=async()=>{const l=await u.mutateAsync({decision:"approve",runIds:m}),I=new Set(l.failedRunIds),v=a.flatMap(({item:h})=>h.approvalRunId!=null&&!I.has(h.approvalRunId)&&h.notificationId!=null?[h.notificationId]:[]);v.length>0&&await x.mutateAsync(v),l.failed>0?j.error(`${l.succeeded} approved; ${l.failed} failed.`):j.success(`${l.succeeded} approved.`)};return e.jsxs("section",{"aria-label":`${a.length} approvals`,className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 px-3 pt-2.5 pb-1.5",children:[e.jsxs("h3",{className:"text-sm font-medium",children:[a.length," approvals waiting"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Proposed by ",R??"this Automation"," ·"," ",i===1?"1 run":`${i} runs`," · ",A]})]}),e.jsx("ul",{className:"divide-y border-t",children:c.map(l=>e.jsx("li",{children:e.jsx(b,{owner:s,item:l.item,variant:"row",showMark:!1})},l.item.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t px-3 py-2 text-xs",children:[g>0?e.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>n(!0),children:[g," more · Review all"]}):null,m.length>1?e.jsxs(O,{type:"button",size:"sm",className:"ml-auto h-7 text-xs",disabled:k,onClick:()=>void C(),children:[e.jsx(P,{className:"mr-1 h-3 w-3"}),"Approve all ",m.length]}):null]})]})}export{z as M,W as N,F as a};
2
+ //# sourceMappingURL=needs-you-list-Bd4iiiqm.js.map
@@ -0,0 +1,2 @@
1
+ import{dp as s,G as n,c as r,j as t,ar as p,as as i}from"./index-CdDNNAx2.js";import{E as m}from"./entity-type-page-MgZ7_0oh.js";import"./event-kind-options-fHAIXu24.js";import"./code-editor-BdRMYojw.js";import"./index-Vcq4gwWv.js";function y(){const{owner:e}=s.useParams(),{orgContext:a}=n(),o=r();return t.jsx(p,{className:"gap-4 pt-2.5 pb-8",children:t.jsx(i,{children:t.jsx(m,{entityType:null,orgContext:a,onClose:()=>{o({to:"/$owner",params:{owner:e},search:{layout:"graph"}})}})})})}export{y as component};
2
+ //# sourceMappingURL=new-BOsrRqp8.js.map