@lobu/runtime-server 24.4.0 → 24.6.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 (305) hide show
  1. package/dist/catalogs/connectors.json +342 -4
  2. package/dist/catalogs/skills.json +2 -2
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/linkedin-identity.ts +43 -0
  5. package/dist/connectors/linkedin.ts +154 -3
  6. package/dist/connectors/postgres.ts +77 -48
  7. package/dist/connectors/x-like-follow.ts +329 -0
  8. package/dist/connectors/x.ts +709 -80
  9. package/dist/dependencies.bun.lock +104 -135
  10. package/dist/owletto/dist/assets/_-DT3E3BmS.js +3 -0
  11. package/dist/owletto/dist/assets/_-c1xy7bLu.js +2 -0
  12. package/dist/owletto/dist/assets/_agentId-CTfoi0-7.js +2 -0
  13. package/dist/owletto/dist/assets/_agentId-DV8utajn.js +2 -0
  14. package/dist/owletto/dist/assets/_automationId-DvP3qyYL.js +2 -0
  15. package/dist/owletto/dist/assets/_connectorKey._connectionId-CL5SivCn.js +2 -0
  16. package/dist/owletto/dist/assets/_connectorKey.index-tnMwC67b.js +2 -0
  17. package/dist/owletto/dist/assets/_conversationId-DXN_8m88.js +2 -0
  18. package/dist/owletto/dist/assets/_eventId-SdpFT7jB.js +2 -0
  19. package/dist/owletto/dist/assets/_name-CM1AMywz.js +2 -0
  20. package/dist/owletto/dist/assets/_owner-CaGsXXBW.js +3 -0
  21. package/dist/owletto/dist/assets/_shape-DGAkETDp.js +2 -0
  22. package/dist/owletto/dist/assets/_skillKey-Dd4ZHPY8.js +2 -0
  23. package/dist/owletto/dist/assets/_slug-cRvJQtNo.js +2 -0
  24. package/dist/owletto/dist/assets/_view-B5I7mmkl.js +2 -0
  25. package/dist/owletto/dist/assets/_viewKey-Bwn0dyLo.js +2 -0
  26. package/dist/owletto/dist/assets/_viewKey-YjSYD0wc.js +2 -0
  27. package/dist/owletto/dist/assets/accept-invitation-CQZQ0wwC.js +2 -0
  28. package/dist/owletto/dist/assets/activity-route-view-CZykJXQp.js +2 -0
  29. package/dist/owletto/dist/assets/{agent-card-controls-99mG6H5k.js → agent-card-controls-DuQJhtqp.js} +2 -2
  30. package/dist/owletto/dist/assets/{agent-client-setup-list-kMmqQSrf.js → agent-client-setup-list-CpUTAjXf.js} +2 -2
  31. package/dist/owletto/dist/assets/agent-connect-pages-Br_ycC0z.js +2 -0
  32. package/dist/owletto/dist/assets/agent-editor-form-BXQBFHSv.js +2 -0
  33. package/dist/owletto/dist/assets/agent-guardrails-route-CN7vpC0X.js +2 -0
  34. package/dist/owletto/dist/assets/agent-list-row-BnP6r4pm.js +2 -0
  35. package/dist/owletto/dist/assets/{agent-loading-shells-Dnmb6W5Y.js → agent-loading-shells-_18OREnx.js} +2 -2
  36. package/dist/owletto/dist/assets/{agent-permissions-matrix-CbhXlbgY.js → agent-permissions-matrix-DSjidWHL.js} +2 -2
  37. package/dist/owletto/dist/assets/{agent-skill-context-V__2i6Vl.js → agent-skill-context-1DBn7Xc_.js} +2 -2
  38. package/dist/owletto/dist/assets/agent-skills-route-d5jh3oBR.js +2 -0
  39. package/dist/owletto/dist/assets/agent-tab-intro-DKrC3SQt.js +2 -0
  40. package/dist/owletto/dist/assets/agent-thread-FyEO-y44.js +6 -0
  41. package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +2 -0
  42. package/dist/owletto/dist/assets/agents-kXojozTU.js +2 -0
  43. package/dist/owletto/dist/assets/agents-workbench-CDpJmUVN.js +2 -0
  44. package/dist/owletto/dist/assets/app._appId-DwNeXRJp.js +2 -0
  45. package/dist/owletto/dist/assets/assist-composer-Mn9EfX4X.js +2 -0
  46. package/dist/owletto/dist/assets/automation-detail-content-Bs3vwAPd.js +2 -0
  47. package/dist/owletto/dist/assets/automation-row-B5Q1B10y.js +2 -0
  48. package/dist/owletto/dist/assets/automation-source-list-Dhucq1sI.js +2 -0
  49. package/dist/owletto/dist/assets/automations-kXojozTU.js +2 -0
  50. package/dist/owletto/dist/assets/{callback-B-CAz-bK.js → callback-9xSHyA12.js} +2 -2
  51. package/dist/owletto/dist/assets/{card-SFtxv9f2.js → card-g4yxo4Hr.js} +2 -2
  52. package/dist/owletto/dist/assets/change-summary-DeuXQEpb.js +2 -0
  53. package/dist/owletto/dist/assets/{claim-DrxIRWKt.js → claim-B98IhDra.js} +2 -2
  54. package/dist/owletto/dist/assets/{client-activity-scopes-boZOHuPW.js → client-activity-scopes-BD2HBo-_.js} +2 -2
  55. package/dist/owletto/dist/assets/{client-rows-BJ2PxM4J.js → client-rows-x_CxeWkP.js} +2 -2
  56. package/dist/owletto/dist/assets/{clients-C7Lnuc3S.js → clients-Cmp0LmOp.js} +2 -2
  57. package/dist/owletto/dist/assets/connect-menu-CezOH3s7.js +2 -0
  58. package/dist/owletto/dist/assets/connect-zUot_0kG.js +2 -0
  59. package/dist/owletto/dist/assets/connect._clientId-nsGxe6yO.js +2 -0
  60. package/dist/owletto/dist/assets/connected._clientId-DnclRRXk.js +2 -0
  61. package/dist/owletto/dist/assets/connected._clientId.activity-CDB8atTX.js +2 -0
  62. package/dist/owletto/dist/assets/connected._clientId.index-DBNP2mZo.js +2 -0
  63. package/dist/owletto/dist/assets/connection-B6fM2KHN.js +2 -0
  64. package/dist/owletto/dist/assets/{connection-feed-detail-D7pnWaFB.js → connection-feed-detail-Ckq-qEbD.js} +2 -2
  65. package/dist/owletto/dist/assets/{connections-browser-DDJQh8Na.js → connections-browser-BXsJqieG.js} +2 -2
  66. package/dist/owletto/dist/assets/{connector-boxes-DDX7Ebc4.js → connector-boxes-CbqSFeVm.js} +2 -2
  67. package/dist/owletto/dist/assets/connector-page-shell-Di6XzkVo.js +2 -0
  68. package/dist/owletto/dist/assets/connector-provenance-BrnasBW4.js +2 -0
  69. package/dist/owletto/dist/assets/{connector-scope-lists-BibdzKl1.js → connector-scope-lists-dQnZARCD.js} +2 -2
  70. package/dist/owletto/dist/assets/connectors-DnOUxX_U.js +2 -0
  71. package/dist/owletto/dist/assets/consent-Byli4yMs.js +2 -0
  72. package/dist/owletto/dist/assets/copy-button-Ddf7lBjZ.js +2 -0
  73. package/dist/owletto/dist/assets/{core.esm-CHnfRiEM.js → core.esm-BsXtvNoI.js} +3 -3
  74. package/dist/owletto/dist/assets/create-B34eskZ_.js +2 -0
  75. package/dist/owletto/dist/assets/create-DLB9sXgU.js +2 -0
  76. package/dist/owletto/dist/assets/create-YdAnh3ml.js +2 -0
  77. package/dist/owletto/dist/assets/create-automation-form-C9PMX7N8.js +3 -0
  78. package/dist/owletto/dist/assets/create._connectorKey-Bz4OYRiC.js +2 -0
  79. package/dist/owletto/dist/assets/definition-comparison-B5WgZILB.js +2 -0
  80. package/dist/owletto/dist/assets/device-DdCoCj-Q.js +2 -0
  81. package/dist/owletto/dist/assets/device-pin-tombstone-B06J7Af1.js +2 -0
  82. package/dist/owletto/dist/assets/device._deviceId-Bh9S4bFp.js +2 -0
  83. package/dist/owletto/dist/assets/dynamic-schema-form-qWSRtOAv.js +2 -0
  84. package/dist/owletto/dist/assets/entity-options-BkU_En_f.js +2 -0
  85. package/dist/owletto/dist/assets/entity-page-BPFDHY8q.js +2 -0
  86. package/dist/owletto/dist/assets/entity-pages-DxgbjLMt.js +2 -0
  87. package/dist/owletto/dist/assets/entity-type-page-D0ghgRgq.js +2 -0
  88. package/dist/owletto/dist/assets/event-card-CjA_dLzq.js +2 -0
  89. package/dist/owletto/dist/assets/event-detail-CmC-DVrK.js +2 -0
  90. package/dist/owletto/dist/assets/{events-feed-BysC9HgU.js → events-feed-CGzA1w3R.js} +2 -2
  91. package/dist/owletto/dist/assets/filter-bar-CQ_oE7a9.js +2 -0
  92. package/dist/owletto/dist/assets/{full-page-spinner-BMiXl54z.js → full-page-spinner-B5xXnKtV.js} +2 -2
  93. package/dist/owletto/dist/assets/guardrails-DkXatmea.js +2 -0
  94. package/dist/owletto/dist/assets/identity-BwJy3ixB.js +2 -0
  95. package/dist/owletto/dist/assets/index-35ehGReZ.js +2 -0
  96. package/dist/owletto/dist/assets/index-B9hYiwBw.js +2 -0
  97. package/dist/owletto/dist/assets/index-BDl1_w6U.js +53 -0
  98. package/dist/owletto/dist/assets/{index-C-WaHj1Y.js → index-BdNR51Ua.js} +2 -2
  99. package/dist/owletto/dist/assets/index-BjcZVe7n.js +7899 -0
  100. package/dist/owletto/dist/assets/{index-B4wXJwQY.js → index-BqAVebvY.js} +2 -2
  101. package/dist/owletto/dist/assets/index-BvK1fS1J.js +2 -0
  102. package/dist/owletto/dist/assets/index-CNEpTkgw.css +1 -0
  103. package/dist/owletto/dist/assets/index-CRc73k1t.js +2 -0
  104. package/dist/owletto/dist/assets/index-CYGaSD3y.js +2 -0
  105. package/dist/owletto/dist/assets/index-CfZGe-zn.js +2 -0
  106. package/dist/owletto/dist/assets/{index-CzoK57xp.js → index-CkiyxW4w.js} +2 -2
  107. package/dist/owletto/dist/assets/index-CzLDNB2E.js +2 -0
  108. package/dist/owletto/dist/assets/index-D-o5iOVd.js +2 -0
  109. package/dist/owletto/dist/assets/index-DjYVV1Ml.js +2 -0
  110. package/dist/owletto/dist/assets/{index-D4-uel59.js → index-TkPy_P_u.js} +2 -2
  111. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +2 -0
  112. package/dist/owletto/dist/assets/index-VyAX-asP.js +2 -0
  113. package/dist/owletto/dist/assets/json-diff-DtZtra_g.js +28 -0
  114. package/dist/owletto/dist/assets/{list-skeleton-Bp4HNgJ9.js → list-skeleton-CIHWCi2a.js} +2 -2
  115. package/dist/owletto/dist/assets/login-TWR0vF4_.js +2 -0
  116. package/dist/owletto/dist/assets/{logout-DxmfsVKD.js → logout-BA5kojS0.js} +2 -2
  117. package/dist/owletto/dist/assets/manage-gear-C-0BAMbC.js +2 -0
  118. package/dist/owletto/dist/assets/{member-scope-gate-vp3FihBD.js → member-scope-gate-BQiRAqtx.js} +2 -2
  119. package/dist/owletto/dist/assets/memory-browse-page-Ba32-vVL.js +74 -0
  120. package/dist/owletto/dist/assets/model-C2q7WDcS.js +2 -0
  121. package/dist/owletto/dist/assets/model-selector-B2cjCn0V.js +2 -0
  122. package/dist/owletto/dist/assets/models-CZkH5gtj.js +2 -0
  123. package/dist/owletto/dist/assets/nav-pill-Bam6s3jj.js +2 -0
  124. package/dist/owletto/dist/assets/new-BJst6K0b.js +2 -0
  125. package/dist/owletto/dist/assets/{new-CvX8_gIb.js → new-Dc5Bbotb.js} +2 -2
  126. package/dist/owletto/dist/assets/new-DgbivfDe.js +2 -0
  127. package/dist/owletto/dist/assets/organization-B9U1L-56.js +2 -0
  128. package/dist/owletto/dist/assets/peek-pane-content-Cq8P38s3.js +2 -0
  129. package/dist/owletto/dist/assets/pending-seed-BP3xHM2d.js +2 -0
  130. package/dist/owletto/dist/assets/permissions-BVlbeY4u.js +2 -0
  131. package/dist/owletto/dist/assets/proposal-review-shell-BED-DO9C.js +2 -0
  132. package/dist/owletto/dist/assets/public-shell-ready-Diq15_QW.js +2 -0
  133. package/dist/owletto/dist/assets/record-activity-CTLwq8s1.js +2 -0
  134. package/dist/owletto/dist/assets/{record-session-CWXnCVln.js → record-session-DOFgdd43.js} +2 -2
  135. package/dist/owletto/dist/assets/renderer-CHPS-1vD.js +96 -0
  136. package/dist/owletto/dist/assets/{reset-password-CFUzxH7m.js → reset-password-BmNM-apc.js} +2 -2
  137. package/dist/owletto/dist/assets/run-activity-link-Dh1YyCfk.js +2 -0
  138. package/dist/owletto/dist/assets/run-initiator-CCxNv0rK.js +2 -0
  139. package/dist/owletto/dist/assets/{runs-BPtQBTRN.js → runs-BntGAKQG.js} +2 -2
  140. package/dist/owletto/dist/assets/runs-panel-BwTVaRsE.js +2 -0
  141. package/dist/owletto/dist/assets/runs-table-CYS1jDdL.js +2 -0
  142. package/dist/owletto/dist/assets/{schema-type-editor-panel-CAhOB648.js → schema-type-editor-panel-v3nR2Oa2.js} +2 -2
  143. package/dist/owletto/dist/assets/schema-value-BFb7jCBo.js +3 -0
  144. package/dist/owletto/dist/assets/settings-DBgT60nY.js +2 -0
  145. package/dist/owletto/dist/assets/settings-DubSpJfg.js +2 -0
  146. package/dist/owletto/dist/assets/skills-DDoeRGhJ.js +2 -0
  147. package/dist/owletto/dist/assets/{source-record-panels-Bh5F4C5K.js → source-record-panels-m8gECt82.js} +2 -2
  148. package/dist/owletto/dist/assets/{status-dot-D3FoDRcc.js → status-dot-BnQPFrcU.js} +2 -2
  149. package/dist/owletto/dist/assets/{table-DFcJRNk7.js → table-DALHuXPE.js} +2 -2
  150. package/dist/owletto/dist/assets/{use-automations-BHoV0dLs.js → use-automations-D9hKpufo.js} +2 -2
  151. package/dist/owletto/dist/assets/use-login-redirect-ciwfc-7A.js +2 -0
  152. package/dist/owletto/dist/assets/{use-mention-search-C3rWLuKm.js → use-mention-search-CJGCatFS.js} +3 -3
  153. package/dist/owletto/dist/assets/use-scroll-sentinel-BWCrmNIB.js +2 -0
  154. package/dist/owletto/dist/assets/view-param-filters-CDvwie_f.js +2 -0
  155. package/dist/owletto/dist/assets/views-access-required-CZ1fvAks.js +2 -0
  156. package/dist/owletto/dist/index.html +2 -2
  157. package/dist/server-main.bundle.mjs +56428 -52475
  158. package/dist/server.bundle.mjs +5 -5
  159. package/dist/verify.mjs +1 -1
  160. package/npm-shrinkwrap.json +277 -311
  161. package/package.json +3 -4
  162. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
  163. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
  164. package/vendor/connector-sdk/package.json +1 -1
  165. package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
  166. package/vendor/core/dist/contracts/agent-settings.js +10 -7
  167. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
  168. package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
  169. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
  170. package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
  171. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  172. package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
  173. package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
  174. package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
  175. package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
  176. package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
  177. package/vendor/core/dist/contracts/tools/view-host.js +28 -0
  178. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
  179. package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
  180. package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
  181. package/vendor/core/dist/error-report.d.ts +73 -0
  182. package/vendor/core/dist/error-report.js +346 -0
  183. package/vendor/core/dist/index.d.ts +3 -1
  184. package/vendor/core/dist/index.js +4 -1
  185. package/vendor/core/dist/logger.js +7 -4
  186. package/vendor/core/dist/otel-fetch.d.ts +19 -0
  187. package/vendor/core/dist/otel-fetch.js +96 -0
  188. package/vendor/core/dist/otel.d.ts +9 -0
  189. package/vendor/core/dist/otel.js +28 -7
  190. package/vendor/core/dist/reserved.d.ts +1 -1
  191. package/vendor/core/dist/reserved.js +6 -4
  192. package/vendor/core/dist/tool-result.d.ts +8 -0
  193. package/vendor/core/dist/tool-result.js +61 -0
  194. package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
  195. package/vendor/core/dist/worker/auth.js +4 -0
  196. package/vendor/core/package.json +16 -1
  197. package/vendor/views/dist/api.d.ts +9 -4
  198. package/vendor/views/dist/api.js +33 -2
  199. package/vendor/views/dist/bridge.d.ts +8 -0
  200. package/vendor/views/dist/bridge.js +12 -2
  201. package/vendor/views/dist/components.d.ts +4 -2
  202. package/vendor/views/dist/components.js +29 -14
  203. package/vendor/views/dist/index.d.ts +1 -1
  204. package/vendor/views/dist/index.js +1 -1
  205. package/vendor/views/dist/native.d.ts +327 -0
  206. package/vendor/views/dist/native.js +57 -0
  207. package/vendor/views/package.json +1 -1
  208. package/dist/owletto/dist/assets/_-DIK0ae_S.js +0 -2
  209. package/dist/owletto/dist/assets/_-gTbcArpS.js +0 -3
  210. package/dist/owletto/dist/assets/_agentId-DOmcJZfk.js +0 -2
  211. package/dist/owletto/dist/assets/_agentId-DW6wRCVC.js +0 -2
  212. package/dist/owletto/dist/assets/_automationId-B9IcDYBu.js +0 -2
  213. package/dist/owletto/dist/assets/_connectorKey._connectionId-C6PmMPTA.js +0 -2
  214. package/dist/owletto/dist/assets/_connectorKey.index-BrJ8Pzze.js +0 -2
  215. package/dist/owletto/dist/assets/_conversationId-BpJAeYYW.js +0 -2
  216. package/dist/owletto/dist/assets/_eventId-DarQJo0G.js +0 -2
  217. package/dist/owletto/dist/assets/_name-DtmNTcUm.js +0 -2
  218. package/dist/owletto/dist/assets/_owner-Db8at3hk.js +0 -3
  219. package/dist/owletto/dist/assets/_shape-6iFA8A86.js +0 -2
  220. package/dist/owletto/dist/assets/_skillKey-CXkHn3Nl.js +0 -2
  221. package/dist/owletto/dist/assets/_slug-DBOuBLoX.js +0 -2
  222. package/dist/owletto/dist/assets/_viewKey-DC27aIN9.js +0 -2
  223. package/dist/owletto/dist/assets/_viewKey-DuYDieln.js +0 -2
  224. package/dist/owletto/dist/assets/accept-invitation-BbDCVvur.js +0 -2
  225. package/dist/owletto/dist/assets/activity-route-view-V4ftmSN7.js +0 -2
  226. package/dist/owletto/dist/assets/agent-connect-pages-B-NPTFs6.js +0 -2
  227. package/dist/owletto/dist/assets/agent-editor-form-DfMTSIvj.js +0 -2
  228. package/dist/owletto/dist/assets/agent-guardrails-route-BvGgfd-h.js +0 -2
  229. package/dist/owletto/dist/assets/agent-skills-route-DFXr_bHp.js +0 -2
  230. package/dist/owletto/dist/assets/agent-subpage-shell-DWzljvFb.js +0 -2
  231. package/dist/owletto/dist/assets/agent-thread-DQIr20H-.js +0 -6
  232. package/dist/owletto/dist/assets/agents-CLbeiqTR.js +0 -2
  233. package/dist/owletto/dist/assets/agents-workbench-C8bTa2rv.js +0 -2
  234. package/dist/owletto/dist/assets/app._appId-Bsq40nak.js +0 -2
  235. package/dist/owletto/dist/assets/automation-detail-content-C9Cgr5Zj.js +0 -2
  236. package/dist/owletto/dist/assets/automations-CLbeiqTR.js +0 -2
  237. package/dist/owletto/dist/assets/calendar-DMq3Dtqy.js +0 -2
  238. package/dist/owletto/dist/assets/code-editor-rX0t1g5C.js +0 -16
  239. package/dist/owletto/dist/assets/connect-BcwgytDV.js +0 -2
  240. package/dist/owletto/dist/assets/connect-menu-BF-AlunU.js +0 -2
  241. package/dist/owletto/dist/assets/connect._clientId-sDypRDeN.js +0 -2
  242. package/dist/owletto/dist/assets/connected._clientId-C9OkW1tv.js +0 -2
  243. package/dist/owletto/dist/assets/connected._clientId.activity-Dc6HYr55.js +0 -2
  244. package/dist/owletto/dist/assets/connected._clientId.index-C6qbqgwF.js +0 -2
  245. package/dist/owletto/dist/assets/connection-88YzIBK9.js +0 -2
  246. package/dist/owletto/dist/assets/connector-provenance-Th8ymGec.js +0 -2
  247. package/dist/owletto/dist/assets/connectors-BqwgLUUK.js +0 -2
  248. package/dist/owletto/dist/assets/consent-BR5U7dwb.js +0 -2
  249. package/dist/owletto/dist/assets/copy-button-2swYh4jb.js +0 -2
  250. package/dist/owletto/dist/assets/create-BsPVnRpG.js +0 -2
  251. package/dist/owletto/dist/assets/create-CVPYVOR5.js +0 -2
  252. package/dist/owletto/dist/assets/create-QFjmhOEU.js +0 -2
  253. package/dist/owletto/dist/assets/create-automation-form-DmCOFbRT.js +0 -3
  254. package/dist/owletto/dist/assets/create._connectorKey-DLDDVtLS.js +0 -2
  255. package/dist/owletto/dist/assets/cronstrue-CKwjNYgj.js +0 -2
  256. package/dist/owletto/dist/assets/device-CKup7kvB.js +0 -2
  257. package/dist/owletto/dist/assets/device-pin-tombstone-xGhCTU5_.js +0 -2
  258. package/dist/owletto/dist/assets/device._deviceId-B1H_ivDT.js +0 -2
  259. package/dist/owletto/dist/assets/entity-avatar-HloBoalJ.js +0 -2
  260. package/dist/owletto/dist/assets/entity-options-BSW_EG0W.js +0 -2
  261. package/dist/owletto/dist/assets/entity-page-D-WDWrAe.js +0 -2
  262. package/dist/owletto/dist/assets/entity-type-page-BCBdFndu.js +0 -2
  263. package/dist/owletto/dist/assets/event-card-Mcxv56DG.js +0 -2
  264. package/dist/owletto/dist/assets/event-detail-DXifj49J.js +0 -2
  265. package/dist/owletto/dist/assets/filter-bar-BQm-ubB1.js +0 -2
  266. package/dist/owletto/dist/assets/guardrails-D7W80sJO.js +0 -2
  267. package/dist/owletto/dist/assets/identity-N0cAO9BR.js +0 -2
  268. package/dist/owletto/dist/assets/index-4gCDI7m4.js +0 -7950
  269. package/dist/owletto/dist/assets/index-BNaI5GpS.js +0 -2
  270. package/dist/owletto/dist/assets/index-BUUrHuJJ.js +0 -2
  271. package/dist/owletto/dist/assets/index-BqrvJmLh.js +0 -2
  272. package/dist/owletto/dist/assets/index-CnvQEA5V.js +0 -2
  273. package/dist/owletto/dist/assets/index-Cq7P2c_E.js +0 -2
  274. package/dist/owletto/dist/assets/index-D3omC3Us.js +0 -2
  275. package/dist/owletto/dist/assets/index-DDGdlQrt.css +0 -1
  276. package/dist/owletto/dist/assets/index-DFEW7hMg.js +0 -2
  277. package/dist/owletto/dist/assets/index-DVV-WWuT.js +0 -2
  278. package/dist/owletto/dist/assets/index-DduQ_e9q.js +0 -2
  279. package/dist/owletto/dist/assets/index-DutlI1d-.js +0 -2
  280. package/dist/owletto/dist/assets/index-wHFQv1aT.js +0 -12
  281. package/dist/owletto/dist/assets/json-diff-E5D-NGYT.js +0 -4
  282. package/dist/owletto/dist/assets/login-7F48UJGx.js +0 -2
  283. package/dist/owletto/dist/assets/memory-browse-page-CfDmjhDl.js +0 -74
  284. package/dist/owletto/dist/assets/model-Dn40BUzs.js +0 -2
  285. package/dist/owletto/dist/assets/model-selector-88PJnyTq.js +0 -2
  286. package/dist/owletto/dist/assets/models-BBK_n2RP.js +0 -2
  287. package/dist/owletto/dist/assets/new-4ruWHLR5.js +0 -2
  288. package/dist/owletto/dist/assets/new-gMD1PHTL.js +0 -2
  289. package/dist/owletto/dist/assets/oauth-workspace-access-D9BNmyMY.js +0 -2
  290. package/dist/owletto/dist/assets/organization-BHcp5Pzg.js +0 -2
  291. package/dist/owletto/dist/assets/peek-pane-content-0sa10jER.js +0 -2
  292. package/dist/owletto/dist/assets/permissions-hhxosugv.js +0 -2
  293. package/dist/owletto/dist/assets/proposal-review-shell-B4CSiyLB.js +0 -2
  294. package/dist/owletto/dist/assets/public-shell-ready-CsenJeXa.js +0 -2
  295. package/dist/owletto/dist/assets/record-activity-D7bRaMk2.js +0 -2
  296. package/dist/owletto/dist/assets/renderer-7EGgTVX0.js +0 -97
  297. package/dist/owletto/dist/assets/runs-panel-Bj63_hb9.js +0 -2
  298. package/dist/owletto/dist/assets/settings-Dg6nxKyw.js +0 -2
  299. package/dist/owletto/dist/assets/settings-KJJ6WihO.js +0 -2
  300. package/dist/owletto/dist/assets/skills-ayt06_o2.js +0 -2
  301. package/dist/owletto/dist/assets/use-scroll-sentinel-Ct-jt7O0.js +0 -2
  302. package/dist/owletto/dist/assets/view-param-filters-mKoqDsaD.js +0 -2
  303. package/dist/owletto/dist/assets/views-access-required-DHrDO333.js +0 -2
  304. /package/vendor/@better-auth-kysely-adapter/{.bun-tag-abf95749a412716 → .bun-tag-654b3a002b271269} +0 -0
  305. /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
@@ -1,4 +0,0 @@
1
- import{j as x,bo as Je,V as W,r as P,cB as ze,C as _e,h as qe,d9 as Ke}from"./index-4gCDI7m4.js";import{T as be,P as Be,E as S,S as J,g as $e,V as Qe,F as Le,a as Q,R as U,D as M,G as Z,W as Y,l as Ze,h as Ye,b as Xe,C as et,c as tt,d as oe,s as nt,j as rt,e as it}from"./index-wHFQv1aT.js";function lt({operation:t}){switch(t){case"create":case"created":return x.jsx(W,{variant:"default",children:"Created"});case"update":case"updated":return x.jsx(W,{variant:"secondary",children:"Updated"});case"delete":case"deleted":return x.jsx(W,{variant:"destructive",children:"Deleted"});default:return x.jsx(W,{variant:"outline",children:t||"Change"})}}function Wt({operation:t,actor:e,createdAt:n,resource:l,changedFields:i,showAttribution:r=!0}){return x.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[x.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l?x.jsx("span",{className:"break-words text-sm font-medium",children:l}):null,x.jsx(lt,{operation:t}),r?x.jsx("time",{dateTime:n,title:n,className:"ml-auto text-xs text-muted-foreground",children:Je(n)}):null]}),r?x.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["by ",e||"unknown"]}):null,i?.length?x.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["Changed: ",i.join(", ")]}):null]})}class C{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new C(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=ee(t,e,n,l,i,r),a=te(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 C(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new C(e,e+d,i,i),new C(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 C(e,e,i,i+d),new C(n,n,i+d+f,r)]}if(f==1||c==1)return[new C(e,n,i,r)];let s=Se(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 ot(t,e,n,l,i,r)}let R=1e9,F=0,X=!1;function ot(t,e,n,l,i,r){let o=n-e,a=r-i;if(R<1e9&&Math.min(o,a)>R*16||F>0&&Date.now()>F)return Math.min(o,a)>R*64?[new C(e,n,i,r)]:ae(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);_.reset(f),q.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?q:null,u=d?null:_;for(let h=0;h<f;h++){if(h>R||F>0&&!(h&63)&&Date.now()>F)return ae(t,e,n,l,i,r);let m=_.advance(h,o,a,f,d,!1,c)||q.advance(h,o,a,f,u,!0,s);if(m)return at(t,e,n,e+m[0],l,i,r,i+m[1])}return[new C(e,n,i,r)]}class De{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 _=new De,q=new De;function at(t,e,n,l,i,r,o,a){let f=!1;return!N(t,l)&&++l==n&&(f=!0),!N(i,a)&&++a==o&&(f=!0),f?[new C(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function Me(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function ee(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=Me(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-(N(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function te(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=Me(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-(N(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function K(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;;){N(t,s)||s++;let d=s+o;if(N(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=ee(t,d,n,l,i+h+u.length,r),p=te(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 Se(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Se(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:K(t,e,n,l,i,r,Math.floor(o/4),-1)}function ae(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=K(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=K(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new C(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 ye(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 C(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function st(t,e,n){for(;;){ye(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new C(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=te(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new C(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 C(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 C(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function dt(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=de(e,r.fromA,c),u=se(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 C(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=se(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new C(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=de(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new C(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=ce(e,r.fromA,r.toA),g,k=p<0?-1:fe(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=ce(n,r.fromB,r.toB),g,k=p<0?-1:fe(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 ye(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function je(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Ee(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?je(n)?1:0:y?!Te(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?je(n)?1:0:y?!Ge(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Oe=8;function se(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Oe;r++){let o=Ee(t,l);if(!o||l+o>i)return l;l+=o}return e}function de(t,e,n){if(!e||!Ee(t,e))return e;for(let l=e,i=e-n,r=0;r<Oe;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function fe(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function ce(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Te=t=>t>=55296&&t<=56319,Ge=t=>t>=56320&&t<=57343;function N(t,e){return!e||e==t.length||!Te(t.charCodeAt(e-1))||!Ge(t.charCodeAt(e))}function ft(t,e,n){var l;let i=n?.override;return i?i(t,e):(R=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,F=n?.timeout?Date.now()+n.timeout:0,X=!1,st(t,e,j(t,0,t.length,e,0,e.length)))}function Re(){return!X}function Fe(t,e,n){return dt(ft(t,e,n),t,e)}const D=Le.define({combine:t=>t[0]}),ct=Q.define(),Ie=Le.define(),w=J.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ct)&&(t=n.value);for(let n of e.state.facet(Ie))t=n(t,e);return t}});class E{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 E(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=Fe(e.toString(),n.toString(),l);return We(i,e,n,0,0,Re())}static updateA(e,n,l,i,r){return pe(ge(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return pe(ge(e,i,!1,n.length),e,n,l,r)}}function ue(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 he(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 We(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ue(f.fromA+l,f.fromB+i,e,n),[d,u]=he(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]=ue(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]=he(m.toA+l,m.toB+i,e,n),a++}o.push(new E(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const H=1e3;function me(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 ge(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>H&&([c,d]=me(t,r-H,n,!0)),o<e.length-H&&([s,u]=me(t,o+H,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 pe(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=Fe(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of We(p,n,l,d,u,Re()))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 ut={scanLimit:500},He=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ae(t))}update(t){(t.docChanged||t.viewportChanged||ht(t.startState,t.state)||mt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ae(t.view))}},{decorations:t=>t.deco});function ht(t,e){return t.field(w,!1)!=e.field(w,!1)}function mt(t,e){return t.facet(D)!=e.facet(D)}const xe=M.line({class:"cm-changedLine"}),Pe=M.mark({class:"cm-changedText"}),gt=M.mark({tagName:"ins",class:"cm-insertedLine"}),pt=M.mark({tagName:"del",class:"cm-deletedLine"}),Ce=new class extends Z{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function xt(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,xe),i.add(o,a,n?pt:gt),r&&r.add(o,o,Ce);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,xe),r&&r.add(s,s,Ce);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,Pe),m<d)f++;else break}s=d}}}function Ae(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new U,f=i?new U: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))&&xt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=Q.define({map:(t,e)=>e.mapPos(t)});class Ct extends Y{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(At(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 At(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 kt=J.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 wt({margin:t=3,minSize:e=4}){return kt.init(n=>vt(n,t,e))}function vt(t,e,n){let l=new U,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 Ct(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"}}),Bt=new class extends Z{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Lt=Be.low($e({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(He))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Ue?Bt:null}));function Dt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ut;return[Be.low(He),jt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Ie.of((i,r)=>{let o=r.effects.find(a=>a.is(ne));return o&&(i=E.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=E.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?Tt:void 0,side:"b"}),O.init(()=>n),Lt,t.collapseUnchanged?wt(t.collapseUnchanged):[],w.init(i=>E.build(n,i.doc,l))]}const ne=Q.define(),O=J.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(ne)&&(t=n.value.doc);return t}}),ke=new WeakMap;class Ue extends Y{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 Mt(t,e,n){let l=ke.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 v=d.appendChild(document.createElement("div"));v.className="cm-chunkButtons";let B=A=>{A.preventDefault(),St(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),yt(o,o.posAtDOM(d))};if(typeof s=="function")v.appendChild(s("accept",B)),v.appendChild(s("reject",L));else{let A=v.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let b=v.appendChild(document.createElement("button"));b.name="reject",b.textContent=t.phrase("Reject"),b.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 v=d.appendChild(document.createElement("div"));return v.className="cm-deletedLine",v.appendChild(document.createElement("del"))}function I(v,B,L){for(let A=v;A<B;){if(u.charAt(A)==`
2
- `){m.firstChild||m.appendChild(document.createElement("br")),m=T(),A++;continue}let b=B,re=L+(k?" cm-deletedText":""),ie=!1,z=u.indexOf(`
3
- `,A);if(z>-1&&z<B&&(b=z),a&&g<p.length){let G=Math.max(0,k?p[g].toA:p[g].fromA);G<=b&&(b=G,k&&g++,ie=!0)}if(b>A){let G=document.createTextNode(u.slice(A,b));if(re){let le=m.appendChild(document.createElement("span"));le.className=re,le.appendChild(G)}else m.appendChild(G);A=b}ie&&(k=!k)}}if(h&&e.toA-e.fromA<=c){let v=h.parser.parse(u),B=0;Ye(v,{style:L=>Xe(t,L)},(L,A,b)=>{L>B&&I(B,L,""),I(L,A,b),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 Ue(i)});return ke.set(e.changes,r),r}function St(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:ne.of({doc:a.apply(o),changes:a}),userEvent:"accept"}),!0}function yt(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 we(t){let e=new U;for(let n of t.field(w)){let l=t.facet(D).overrideChunk&&Ve(t,n);e.add(n.fromB,n.fromB,Mt(t,n,!!l))}return e.finish()}const jt=J.define({create:t=>we(t),update(t,e){return e.state.field(w,!1)!=e.startState.field(w,!1)?we(e.state):t},provide:t=>S.decorations.from(t)}),ve=new WeakMap;function Ve(t,e){let n=ve.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 Et(u),side:-1}).range(s+d.fromB))}d.fromB<d.toB&&a.push(Pe.range(s+d.fromB,s+d.toB))}f<e.endA-e.fromA-r*2&&(n=a)}return ve.set(e,n),n}class Et extends Y{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 Z{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Ot=M.line({class:"cm-inlineChangedLine"});function Tt(t,e,n,l){let i=Ve(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,Ot);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 Gt=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-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 V(t){if(Array.isArray(t))return t.map(V);if(t&&typeof t=="object"){const e={};for(const n of Object.keys(t).sort())e[n]=V(t[n]);return e}return t}function Rt({before:t,after:e}){const n=P.useRef(null);return P.useEffect(()=>{if(!n.current)return;const l=new S({state:oe.create({doc:e,extensions:[oe.readOnly.of(!0),S.editable.of(!1),S.lineWrapping,nt(it,{fallback:!0}),rt(),Dt({original:t,mergeControls:!1,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}),Gt]}),parent:n.current});return()=>l.destroy()},[t,e]),x.jsx("div",{ref:n,className:"w-full"})}function Ht({before:t,after:e}){const[n,l]=P.useState(!1),i=P.useId();if(!t&&!e)return null;const r=!!(t&&e);return x.jsxs("div",{className:"mt-2",children:[x.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?x.jsx(ze,{className:"h-3 w-3"}):x.jsx(_e,{className:"h-3 w-3"}),r?n?"Hide diff":"Show diff":n?"Hide details":"Show details"]}),n&&(r?x.jsx("div",{id:i,className:"mt-2",children:x.jsx(Rt,{before:JSON.stringify(V(t),null,2),after:JSON.stringify(V(e),null,2)})}):x.jsxs("div",{id:i,className:"mt-2",children:[x.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase text-muted-foreground",children:e?"After":"Before"}),x.jsx("pre",{className:qe(Ke,"max-h-48 overflow-auto p-2 text-xs"),children:JSON.stringify(e??t,null,2)})]}))]})}export{Wt as C,Ht as J};
4
- //# sourceMappingURL=json-diff-E5D-NGYT.js.map
@@ -1,2 +0,0 @@
1
- import{v as Ne,a5 as Ce,o as Se,a6 as Ee,E as Le,r as s,a7 as Ue,a8 as Fe,a9 as ie,j as e,aa as b,ab as Pe,ac as ce,ad as $,ae as Ie,af as Me,ag as ze,a2 as Ae,Q as Re,a3 as qe,ah as oe}from"./index-4gCDI7m4.js";import{C as $e,c as Be}from"./card-SFtxv9f2.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 De(){const l=Ne(),f=Ce(),{session:m,isReady:y}=Se(),{data:i,isLoading:U,error:O}=Ee(),a=Le({from:"/auth/login"}),de=a.invitationOrg,[p,j]=s.useState("social"),[d,P]=s.useState(a.intent??"sign-in"),[T,ue]=s.useState(""),[o,W]=s.useState(()=>a.loginHint??""),[k,me]=s.useState(""),[N,ge]=s.useState(""),[I,V]=s.useState(""),[fe,Q]=s.useState(!1),[c,u]=s.useState(null),[M,r]=s.useState(null),[J,G]=s.useState(!1),[pe,K]=s.useState(!1),[Z,he]=s.useState(!1),X=s.useRef(!1),L=a.callbackUrl?Ue(a.callbackUrl):void 0,z=Fe(de,a.loginHint),Y=a.mode==="extension",D=a.error==="account_not_linked",ee=E(a.errorDescription||a.error),A=Object.values(i?.social??{}).some(Boolean),w=!!i?.magicLink,R=!!i?.phone,h=!!i?.emailPassword,te=!!i?.passkey,x=!!i?.singleUserMode,ne=!!i?.hasUser,H=x,F=p==="magic-link"&&w&&J,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=ie(L);L?window.location.href=t:l({to:"/"})}},[m,l,L]),s.useEffect(()=>{!i||v.length===0||v.includes(p)||j(v[0])},[i,p,v]),s.useEffect(()=>{!w||!D||(j("magic-link"),a.loginHint&&!o&&W(a.loginHint))},[w,D,a.loginHint,o]),s.useEffect(()=>{a.intent&&P(a.intent)},[a.intent]),s.useEffect(()=>{if(!x||!i)return;const t=ne?"sign-in":"sign-up";d!==t&&P(t)},[x,ne,i,d]);const C=()=>L?ie(L):"/",se=async(t,{quiet:n=!1}={})=>{u(t),r(null);try{const g=await $.social({provider:t,callbackURL:C(),newUserCallbackURL:L?C():`/?onboard_provider=${encodeURIComponent(t)}`}),S=B(g);if(S&&!n){const q=E(S);q?.toLowerCase().includes("magic link")&&j("magic-link"),r(q)}}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||!i||a.error)return;const t=a.provider;if(!t)return;X.current=!0;const n=Object.hasOwn(i.social??{},t)&&!!i.social?.[t];se(t,{quiet:!n})},[i,U,m,y,a.provider,a.error]);const re=async()=>{if(o){u("magic-link"),r(null);try{return await $.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 ze.passkey.addPasskey({name:T||`${navigator.platform||"This device"}`})}catch{}}else{const n=await $.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)}}},ae=async()=>{r(null),he(!0),u("local");try{const t=await Ie();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&&i&&!m&&!Z&&ae()},[H,i,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 Ae(`${Re}/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 qe(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}),Q(!0)}catch(n){r(n instanceof Error?n.message:"Failed to send verification code")}finally{u(null)}}},ve=async t=>{if(t.preventDefault(),!(!N||!I)){u("verify"),r(null);try{await oe.verify({phoneNumber:N,code:I})}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($e,{children:e.jsx(Be,{children:H?e.jsx("div",{className:"space-y-4",children:M?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsx("button",{type:"button",disabled:c!==null,onClick:ae,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}),M&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:M}),!F&&(h||p==="social")&&A&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(i?.social??{}).filter(([,t])=>t).map(([t])=>{const n=Pe.find(ke=>ke.provider===t),g=n?.icon,S=i?.socialMeta?.[t],q=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 ",q]},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 $.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&&(J?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:I,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||I.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:()=>{Q(!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{De as component};
2
- //# sourceMappingURL=login-7F48UJGx.js.map
@@ -1,74 +0,0 @@
1
- import{r as x,j as t,B as Y,c_ as mt,e_ as Os,e$ as As,bY as Ps,h as le,cZ as Rt,S as ve,f0 as Ds,f1 as Fs,t as Fe,f2 as en,f3 as zs,f4 as Ws,f5 as Bs,H as De,bz as Ft,bA as zt,bB as Wt,bC as Bt,bD as yt,f6 as Hs,I as at,f7 as Vs,bK as Gn,f8 as Kn,f9 as Yn,fa as Us,k as It,ea as qs,fb as Gs,v as ot,u as tn,em as Jn,aI as Ks,aJ as Ys,cw as Js,fc as Qs,aC as Xs,fd as Qn,b6 as Zs,ba as er,bW as Xn,Y as tr,L as we,X as nr,ee as Zn,b_ as sr,b$ as rr,fe as ar,ff as or,fg as ir,c2 as cr,bT as es,fh as ts,fi as nt,fj as jt,fk as lr,fl as dr,fm as nn,fn as ur,fo as Kt,fp as Yt,fq as mr,fr,cI as ns,cJ as Nt,dA as hr,d2 as pr,dx as sn,dz as rn,fs as ss,dy as an,bI as gr,eW as yr,dG as rs,b4 as as,ft as os,ez as is,fu as qe,eM as xr,cK as st,V as ht,eA as br,dL as vr,fv as wr,d9 as kr,cR as jr,cB as cs,dB as Nr,dC as Sr,dD as Er,dE as Cr,cM as vn,fw as _r,fx as Mr,cN as Tr,du as Lr,fy as ls,fz as ds,ar as Rr,fA as Ir,E as us,fB as $r,cb as Ue,i as ms,fC as Ht,fD as Or,fE as Ar,cU as wn,fF as Pr,fG as Dr,bk as Fr,fH as zr,fI as Wr,bx as Br,fJ as Hr,a as Vr,fK as Ur,aA as qr}from"./index-4gCDI7m4.js";import{P as Gr}from"./public-shell-ready-CsenJeXa.js";import{f as Kr,a as Yr,c as kn,d as Jr,A as Qr}from"./connector-boxes-DDX7Ebc4.js";import{u as Xr}from"./use-automations-BHoV0dLs.js";import{c as Zr}from"./connections-browser-DDJQh8Na.js";import{d as ea,e as ta}from"./model-Dn40BUzs.js";import{c as na}from"./connection-label-BobuYiAG.js";import{f as sa}from"./feed-event-kinds-BYuZCoU4.js";import{S as ra}from"./schema-type-editor-panel-CAhOB648.js";import{D as aa,c as oa,l as ia,p as Ee,S as jn,n as ca,e as $t,a as la,g as da,f as Nn,b as ua,d as ma,J as fa}from"./renderer-7EGgTVX0.js";import{S as ha,E as on}from"./entity-avatar-HloBoalJ.js";import{F as pa}from"./filter-bar-BQm-ubB1.js";import{T as ga,a as ya,b as Vt,c as Sn,d as xa,e as Ut}from"./table-DFcJRNk7.js";import{u as ba,a as va,D as wa,P as ka,b as fs,c as ja,C as Na}from"./core.esm-CHnfRiEM.js";import{v as Sa,V as hs,M as ps,a as gs,w as Ea,b as Ca}from"./view-param-filters-mKoqDsaD.js";import{E as _a}from"./entity-type-page-BCBdFndu.js";import{M as Ma}from"./member-scope-gate-vp3FihBD.js";function En(e){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.x-i.w/2),a=Math.max(a,i.x+i.w/2),s=Math.min(s,i.y-i.h/2),r=Math.max(r,i.y+i.h/2);return Number.isFinite(n)?{x0:n,y0:s,x1:a,y1:r}:null}const St=(e,n,s)=>e<n?n:e>s?s:e;function Ta(e,n,s,{padding:a=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const o=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),g=St(Math.min(n/(o*(1+a)),s/(l*(1+a))),r,i);return{z:g,x:n/2-(e.x0+e.x1)/2*g,y:s/2-(e.y0+e.y1)/2*g}}function La(e,n,s=0){if(e===n){const b=e.x+e.w/2,j=e.y-e.h/2;return[{x:b-30,y:j},{x:b-30,y:j-26},{x:b+22,y:j-26},{x:b+22,y:e.y-6},{x:b,y:e.y-6}]}const a=s*8,r=e.x+e.w/2,i=e.y+St(a,-e.h/2+6,e.h/2-6),o=n.x-n.w/2,l=n.y+St(a,-n.h/2+6,n.h/2-6);if(o-r>=40){const b=(r+o)/2+a;return[{x:r,y:i},{x:b,y:i},{x:b,y:l},{x:o,y:l}]}const g=Math.max(e.y+e.h/2,n.y+n.h/2)+24+Math.abs(a),c=Math.min(e.y-e.h/2,n.y-n.h/2)-24-Math.abs(a),y=(i+l)/2,m=Math.abs(g-y)<=Math.abs(c-y)?g:c,f=r+24+Math.abs(a),h=o-24-Math.abs(a);return[{x:r,y:i},{x:f,y:i},{x:f,y:m},{x:h,y:m},{x:h,y:l},{x:o,y:l}]}function Ra(e,n,s){const a=s.x-n.x,r=s.y-n.y,i=a*a+r*r,o=i?St(((e.x-n.x)*a+(e.y-n.y)*r)/i,0,1):0;return Math.hypot(e.x-(n.x+o*a),e.y-(n.y+o*r))}function Ia(e,n){let s=Number.POSITIVE_INFINITY;for(let a=0;a<n.length-1;a++)s=Math.min(s,Ra(e,n[a],n[a+1]));return s}function $a(e,n){return Math.abs(n.x-e.x)<=e.w/2&&Math.abs(n.y-e.y)<=e.h/2}class tt{cells=new Set;static CELL_W=12;static CELL_H=16;keys(n){const s=[],a=Math.floor(n.x0/tt.CELL_W),r=Math.floor(n.x1/tt.CELL_W),i=Math.floor(n.y0/tt.CELL_H),o=Math.floor(n.y1/tt.CELL_H);for(let l=a;l<=r;l++)for(let g=i;g<=o;g++)s.push(l*1e5+g);return s}isFree(n){return this.keys(n).every(s=>!this.cells.has(s))}reserve(n){for(const s of this.keys(n))this.cells.add(s)}}function Oa(e,n,s,a,r){const i=e.slice(0,-1).map((m,f)=>({i:f,length:Math.hypot(e[f+1].x-m.x,e[f+1].y-m.y)})).sort((m,f)=>f.length-m.length);if(i.length===0)return null;const o=m=>({x0:m.x-n/2,x1:m.x+n/2,y0:m.y-s/2,y1:m.y+s/2}),l=m=>({x:(e[m].x+e[m+1].x)/2,y:(e[m].y+e[m+1].y)/2});for(const{i:m,length:f}of i){if(!r&&f<n*.7)break;const h=l(m);if(a.isFree(o(h)))return a.reserve(o(h)),h}if(!r)return null;const g=l(i[0].i),y=[-1,1,-1.6,1.6].map(m=>({x:g.x,y:g.y+m*(s+12)})).find(m=>a.isFree(o(m)))??g;return a.reserve(o(y)),y}const Aa=e=>t.jsx(Rt,{icon:e||null,className:"h-4 w-4"}),Pa='600 14px "DM Sans", system-ui, sans-serif',Da='400 11px "DM Sans", system-ui, sans-serif',Fa='500 9px "DM Sans", system-ui, sans-serif',za='500 11px "DM Sans", system-ui, sans-serif',dt=18,Cn=8;function _n(e){const n=getComputedStyle(e),s=(a,r)=>n.getPropertyValue(a).trim()||r;return{foreground:s("--foreground","#141414"),muted:s("--muted-foreground","#545454"),card:s("--card","#ffffff"),background:s("--background","#fcfcfb"),border:s("--border","#e7e4dc"),primary:s("--primary","#2f63e8"),mutedSurface:s("--muted","#f3f1ea")}}function xt(e,n,s){if(e.measureText(n).width<=s)return n;let a=0,r=n.length;for(;a<r;){const i=Math.ceil((a+r)/2);e.measureText(`${n.slice(0,i)}…`).width<=s?a=i:r=i-1}return`${n.slice(0,a)}…`}function Wa(e,n,s,a){const r=Math.hypot(s.x-n.x,s.y-n.y);if(r<1)return;const i=(s.x-n.x)/r,o=(s.y-n.y)/r;e.moveTo(s.x-i*a-o*a*.55,s.y-o*a+i*a*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*a+o*a*.55,s.y-o*a-i*a*.55)}function ys({boxes:e,edges:n,label:s,onOpenBox:a,openLabel:r,onConnect:i,renderIcon:o=Aa,className:l}){const g=x.useRef(null),c=x.useRef(null),y=x.useRef(null),m=x.useRef({z:1,x:0,y:0}),f=x.useRef({w:0,h:0,dpr:1}),h=x.useRef(!0),b=x.useRef(new Map),j=x.useRef(null),d=x.useRef(null),S=x.useRef(new Map),N=x.useRef(null),E=x.useRef(""),w=x.useRef(!1),[p,v]=x.useState(()=>new Map),[M,A]=x.useState(null),[F,z]=x.useState(null),[Q,G]=x.useState(null),[se,V]=x.useState(null),[pe,ge]=x.useState(0),{placed:I,movedIds:L}=x.useMemo(()=>{const C=new Map,u=new Set;for(const T of e){const $=p.get(T.id);$&&$.from.x===T.x&&$.from.y===T.y?(C.set(T.id,{...T,x:$.at.x,y:$.at.y}),u.add(T.id)):C.set(T.id,T)}return{placed:C,movedIds:u}},[e,p]),q=x.useMemo(()=>{const C=new Map;for(const T of n){const $=[T.source,T.target].sort().join("|");C.set($,[...C.get($)??[],T])}const u=new Map;for(const T of n){const $=I.get(T.source),k=I.get(T.target);if(!$||!k)continue;if(T.route&&!L.has($.id)&&!L.has(k.id)){u.set(T.id,T.route);continue}const _=C.get([T.source,T.target].sort().join("|"))??[T];u.set(T.id,La($,k,_.indexOf(T)-(_.length-1)/2))}return u},[n,I,L]),U=x.useCallback(()=>{h.current=!0},[]),H=x.useCallback(()=>{const C=En([...I.values()]),{w:u,h:T}=f.current;!C||!u||!T||(m.current=Ta(C,u,T),w.current=!0,U())},[I,U]),J=C=>{m.current=C,w.current=!1,U()},X=C=>{const u=En(C),{w:T,h:$}=f.current;if(!u||!T||!$)return;const k=m.current,_=24;u.x0*k.z+k.x>=_&&u.y0*k.z+k.y>=_&&u.x1*k.z+k.x<=T-_&&u.y1*k.z+k.y<=$-_||J({...k,x:T/2-(u.x0+u.x1)/2*k.z,y:$/2-(u.y0+u.y1)/2*k.z})},fe=C=>{V(C);const u=I.get(C);u&&X([u])},de=e.map(C=>`${C.id}@${Math.round(C.x)},${Math.round(C.y)}`).join(";");x.useEffect(()=>{!de||E.current===de||f.current.w&&(E.current=de,H())},[de,H]);const Ce=x.useRef(H);Ce.current=H;const ze=x.useRef(de);ze.current=de,x.useEffect(()=>{const C=g.current,u=c.current;if(!C||!u||typeof ResizeObserver>"u")return;const T=()=>{const k=window.devicePixelRatio||1,_=C.clientWidth,W=C.clientHeight;f.current={w:_,h:W,dpr:k},u.width=Math.round(_*k),u.height=Math.round(W*k);const B=ze.current;B&&_&&W&&(E.current!==B||w.current)&&(E.current=B,Ce.current()),U()};T();const $=new ResizeObserver(T);return $.observe(C),()=>$.disconnect()},[U]);const[Te,Ge]=x.useState(0);x.useEffect(()=>{const C=y.current,u=c.current;if(!C||!u)return;const T=_n(u).muted;for(const $ of C.querySelectorAll("[data-icon-key]")){const k=$.dataset.iconKey??"";if(b.current.has(k))continue;const _=$.querySelector("svg"),W=_?null:$.querySelector("img")?.src;if(!_&&!W){b.current.set(k,$.textContent??"");continue}const B=new Image;if(B.onload=U,B.onerror=()=>{b.current.delete(k),Ge(R=>R+1)},_){const R=_.cloneNode(!0);R.getAttribute("width")||R.setAttribute("width","24"),R.getAttribute("height")||R.setAttribute("height","24");const D=new XMLSerializer().serializeToString(R).replaceAll("currentColor",T);B.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(D)}`}else W&&(B.src=W);b.current.set(k,B)}},[e,pe,Te,U]);const ke=(C,u)=>{const T=m.current;return{x:(C-T.x)/T.z,y:(u-T.y)/T.z}},Le=(C,u)=>{const T=m.current,$=ke(C,u),k=M&&M.kind!=="edge"?I.get(M.box.id):void 0;if(k&&i){const R=Mn(k);if(Math.hypot(R.x*T.z+T.x-C,R.y*T.z+T.y-u)<=Cn+3)return{kind:"handle",box:k}}const _=[...I.values()];for(let R=_.length-1;R>=0;R--)if($a(_[R],$))return{kind:"box",box:_[R]};let W=null,B=7/T.z;for(const R of n){const D=q.get(R.id);if(!D)continue;const ie=Ia($,D);ie<B&&(B=ie,W=R)}return W?{kind:"edge",edge:W}:null},ye=x.useMemo(()=>{const C=new Set;for(const T of[F,Q])T&&C.add(T);M?.kind==="edge"&&C.add(M.edge.id);const u=M&&M.kind!=="edge"?M.box.id:se;if(u)for(const T of n)(T.source===u||T.target===u)&&C.add(T.id);for(const T of n)T.dimmed&&C.delete(T.id);return C},[n,M,F,Q,se]);x.useEffect(U,[I,q,ye,M,se,U]);const Re=x.useCallback(()=>{const C=c.current,u=C?.getContext("2d");if(!C||!u)return;const{w:T,h:$,dpr:k}=f.current,_=_n(C),W=getComputedStyle(C),B=new Map,R=P=>{let ee=B.get(P);return ee===void 0&&(ee=W.getPropertyValue(P).trim(),B.set(P,ee)),ee},{z:D,x:ie,y:ce}=m.current,Se=P=>({x:P.x*D+ie,y:P.y*D+ce});u.setTransform(k,0,0,k,0,0),u.clearRect(0,0,T,$);const Oe=M&&M.kind!=="edge"?M.box.id:null;u.lineJoin="round";for(const P of n){const ee=q.get(P.id);if(!ee)continue;const ne=ee.map(Se),K=ye.has(P.id);u.globalAlpha=P.dimmed?.15:K?.95:.55,u.strokeStyle=K?_.foreground:_.muted,u.lineWidth=K?1.75:1.25,u.beginPath(),u.moveTo(ne[0].x,ne[0].y);for(const re of ne.slice(1))u.lineTo(re.x,re.y);P.directed&&Wa(u,ne[ne.length-2],ne[ne.length-1],8),u.stroke()}const Ye=new tt;for(const P of I.values()){const ee=Se(P),ne=P.w*D,K=P.h*D,re=ee.x-ne/2,Z=ee.y-K/2;if(Ye.reserve({x0:re,y0:Z,x1:re+ne,y1:Z+K}),re>T||Z>$||re+ne<0||Z+K<0)continue;const Pe=Oe===P.id||N.current?.over?.id===P.id;u.globalAlpha=P.dimmed?.25:1,u.beginPath(),u.roundRect(re,Z,ne,K,8*D),u.fillStyle=P.muted?_.mutedSurface:_.card,u.fill(),u.lineWidth=Pe||se===P.id?1.5:1,u.strokeStyle=Pe||se===P.id?_.primary:_.border,u.stroke();const oe=P.accent&&R(P.accent);if(oe&&(u.save(),u.clip(),u.fillStyle=oe,u.fillRect(re,Z,3*D,K),u.restore()),14*D<5)continue;const he=12*D,ae=16*D,me=P.meta?Z+K/2-8*D:Z+K/2,_e=b.current.get(P.icon??"");_e instanceof HTMLImageElement&&_e.complete&&_e.naturalWidth>0?u.drawImage(_e,re+he,me-ae/2,ae,ae):typeof _e=="string"&&_e&&(u.font=`${14*D}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(_e,re+he,me));const He=re+he+ae+8*D,it=12*D;u.textBaseline="middle",u.textAlign="left";let Xe=re+ne-it-He;if(P.badge){u.font=Fa.replace("9px",`${9*D}px`);const ct=xt(u,P.badge.toUpperCase(),Xe*.35),Ze=u.measureText(ct).width+8*D,lt=re+ne-it-Ze;u.strokeStyle=_.border,u.lineWidth=1,u.beginPath(),u.roundRect(lt,me-7*D,Ze,14*D,3*D),u.stroke(),u.fillStyle=_.muted,u.fillText(ct,lt+4*D,me+.5),Xe-=Ze+6*D}u.font=Pa.replace("14px",`${14*D}px`),u.fillStyle=_.foreground,u.fillText(xt(u,P.title,Xe),He,me+.5),P.meta&&(u.font=Da.replace("11px",`${11*D}px`),u.fillStyle=_.muted,u.fillText(xt(u,P.meta,re+ne-he-He),He,Z+K/2+10*D))}const Ae=N.current,Je=Ae?.from??(Oe?I.get(Oe):void 0);if(i&&Je&&Je.w*D>=60){const P=Se(Mn(Je));if(u.globalAlpha=1,Ae){const ee=Se(Ae.to);u.strokeStyle=_.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo(P.x,P.y),u.lineTo(ee.x,ee.y),u.stroke(),u.setLineDash([])}u.fillStyle=_.card,u.strokeStyle=_.primary,u.lineWidth=1.5,u.beginPath(),u.arc(P.x,P.y,Cn,0,Math.PI*2),u.fill(),u.stroke(),u.beginPath(),u.moveTo(P.x-4,P.y),u.lineTo(P.x+4,P.y),u.moveTo(P.x,P.y-4),u.lineTo(P.x,P.y+4),u.stroke()}u.font=za,u.textAlign="center",u.textBaseline="middle";const Qe=(P,ee,ne,K)=>{u.globalAlpha=1,u.fillStyle=_.background,u.strokeStyle=ne?_.foreground:_.border,u.lineWidth=1,u.beginPath(),u.roundRect(P.x-K/2,P.y-dt/2,K,dt,5),u.fill(),u.stroke(),u.fillStyle=ne?_.foreground:_.muted,u.fillText(ee,P.x,P.y+.5)},Ot=[...n].sort((P,ee)=>Number(ye.has(ee.id))-Number(ye.has(P.id)));for(const P of Ot){const ee=q.get(P.id);if(!ee||P.dimmed&&!ye.has(P.id))continue;const ne=ee.map(Se),K=ye.has(P.id),Z=(K?P.details:[P.summary]).map(ae=>xt(u,ae,200)),Pe=Math.max(...Z.map(ae=>u.measureText(ae).width))+14,oe=Z.length*(dt+2);if(!K&&D<.45)continue;const he=Oa(ne,Pe,oe,Ye,K);he&&Z.forEach((ae,me)=>{Qe({x:he.x,y:he.y-oe/2+(dt+2)*me+dt/2},ae,K,Pe)})}u.globalAlpha=1},[n,q,I,ye,M,se,i]);x.useEffect(()=>{let C=0;const u=()=>{C=requestAnimationFrame(u),h.current&&(h.current=!1,Re())};return C=requestAnimationFrame(u),document.addEventListener("visibilitychange",U),()=>{cancelAnimationFrame(C),document.removeEventListener("visibilitychange",U)}},[Re,U]),x.useEffect(()=>{const C=new MutationObserver(()=>{b.current.clear(),ge(u=>u+1),U()});return C.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>C.disconnect()},[U]);const je=(C,u,T)=>{const $=m.current,k=Math.min(3,Math.max(.15,$.z*C));J({z:k,x:u-(u-$.x)*(k/$.z),y:T-(T-$.y)*(k/$.z)})},We=C=>{const u=c.current?.getBoundingClientRect();return{x:C.clientX-(u?.left??0),y:C.clientY-(u?.top??0)}},ue=C=>{if(C.button!==0&&C.pointerType==="mouse")return;C.currentTarget.setPointerCapture(C.pointerId);const u=We(C);if(C.pointerType==="touch"&&(S.current.set(C.pointerId,u),S.current.size===2)){const[k,_]=[...S.current.values()];j.current=null,N.current=null,d.current={d:Math.hypot(k.x-_.x,k.y-_.y)||1,mid:{x:(k.x+_.x)/2,y:(k.y+_.y)/2}};return}const T=Le(u.x,u.y),$={start:u,last:u,hit:T,moved:!1};if(T?.kind==="handle")N.current={from:T.box,to:ke(u.x,u.y),over:null};else if(T?.kind==="box"){const k=ke(u.x,u.y);$.grab={x:T.box.x-k.x,y:T.box.y-k.y}}j.current=$},Ke=C=>{const u=We(C);S.current.has(C.pointerId)&&S.current.set(C.pointerId,u);const T=d.current;if(T&&S.current.size===2){const[R,D]=[...S.current.values()],ie=Math.hypot(R.x-D.x,R.y-D.y)||1,ce={x:(R.x+D.x)/2,y:(R.y+D.y)/2};J({...m.current,x:m.current.x+ce.x-T.mid.x,y:m.current.y+ce.y-T.mid.y}),je(ie/T.d,ce.x,ce.y),d.current={d:ie,mid:ce};return}const $=j.current;if(!$){const R=Le(u.x,u.y);A(ie=>Ba(ie,R)?ie:R);const D=c.current;D&&(D.style.cursor=R?.kind==="handle"?"crosshair":R?"pointer":"grab");return}const k=u.x-$.last.x,_=u.y-$.last.y;if($.last=u,!$.moved&&Math.hypot(u.x-$.start.x,u.y-$.start.y)>4&&($.moved=!0),!$.moved)return;const W=N.current;if(W){W.to=ke(u.x,u.y);const R=Le(u.x,u.y);W.over=R?.kind==="box"?R.box:null,U();return}const B=$.hit;if(B?.kind==="box"&&$.grab){const R=ke(u.x,u.y),D=e.find(ce=>ce.id===B.box.id);if(!D)return;const ie={x:R.x+$.grab.x,y:R.y+$.grab.y};v(ce=>new Map(ce).set(D.id,{at:ie,from:{x:D.x,y:D.y}}));return}J({...m.current,x:m.current.x+k,y:m.current.y+_}),c.current&&(c.current.style.cursor="grabbing")},xe=C=>{if(S.current.delete(C.pointerId),d.current){S.current.size<2&&(d.current=null),j.current=null;return}const u=j.current;j.current=null;const T=N.current;if(N.current=null,!u)return;if(c.current&&(c.current.style.cursor="grab"),T){U(),T.over&&i&&i(T.from.id,T.over.id);return}if(u.moved)return;const $=u.hit;$?.kind==="box"?a($.box.id):$?.kind==="edge"?z(k=>k===$.edge.id?null:$.edge.id):z(null)},Ie=C=>{S.current.delete(C.pointerId),d.current=null,j.current=null,N.current=null,U()};x.useEffect(()=>{const C=c.current;if(!C)return;const u=T=>{T.preventDefault();const $=We(T);T.ctrlKey||T.metaKey?je(Math.exp(-T.deltaY*(T.ctrlKey?.01:.002)),$.x,$.y):J({...m.current,x:m.current.x-T.deltaX,y:m.current.y-T.deltaY})};return C.addEventListener("wheel",u,{passive:!1}),()=>C.removeEventListener("wheel",u)});const $e=C=>je(C,f.current.w/2,f.current.h/2),Be=[...new Set(e.map(C=>C.icon??""))];return t.jsxs("div",{ref:g,className:le("relative h-full w-full overflow-hidden",l),children:[t.jsx("canvas",{ref:c,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:ue,onPointerMove:Ke,onPointerUp:xe,onPointerCancel:Ie,onPointerLeave:()=>{j.current||A(null)}}),t.jsxs("ul",{ref:y,"aria-label":s,className:"sr-only",children:[Be.map(C=>t.jsx("li",{"aria-hidden":"true","data-icon-key":C,children:o(C)},`icon:${C}`)),e.map(C=>t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>a(C.id),onFocus:()=>fe(C.id),onBlur:()=>V(null),children:r(C)})},C.id)),n.map(C=>t.jsx("li",{"data-revealed":ye.has(C.id)||void 0,children:t.jsx("button",{type:"button","aria-pressed":F===C.id,onClick:()=>z(u=>u===C.id?null:C.id),onFocus:()=>{G(C.id);const u=q.get(C.id);u&&X(u.map(T=>({...T,w:0,h:0})))},onBlur:()=>G(null),children:C.ariaLabel})},C.id))]}),t.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>$e(1.25),children:t.jsx(mt,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>$e(.8),children:t.jsx(Os,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:H,children:t.jsx(As,{className:"h-3.5 w-3.5"})}),L.size>0?t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>v(new Map),children:t.jsx(Ps,{className:"h-3.5 w-3.5"})}):null]})]})}const Mn=e=>({x:e.x+e.w/2,y:e.y});function Ba(e,n){return!e||!n?e===n:e.kind==="edge"||n.kind==="edge"?e.kind==="edge"&&n.kind==="edge"&&e.edge.id===n.edge.id:e.kind===n.kind&&e.box.id===n.box.id}function cn({label:e,fill:n=!1,schemaActions:s=!1}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:le("flex min-w-0 flex-col gap-3",n&&"min-h-0 flex-1"),children:[t.jsx("div",{"aria-hidden":"true",children:t.jsx(ve,{className:"h-5 w-3/4 max-w-xl rounded-none"})}),t.jsxs("div",{className:le("relative flex min-h-0 flex-col",n&&"flex-1"),"aria-hidden":"true",children:[s?t.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[t.jsx(ve,{className:"h-8 w-40 rounded-none"}),t.jsx(ve,{className:"h-8 w-36 rounded-none"})]}):null,t.jsxs("div",{className:le("relative min-h-[420px]",n?"flex-1":"h-[70vh]"),children:[t.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[t.jsx(ve,{className:"h-4 w-4 shrink-0 rounded-none"}),t.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[t.jsx(ve,{className:"h-3.5 w-24 rounded-none"}),t.jsx(ve,{className:"h-2.5 w-32 rounded-none"})]})]}),t.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(a=>t.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:t.jsx(ve,{className:"h-3 w-3 rounded-none"})},a))})]})]})]})}function bt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qt={exports:{}},Tn;function Ha(){return Tn||(Tn=1,(function(e,n){(function(s){e.exports=s()})(function(){return(function(){function s(a,r,i){function o(c,y){if(!r[c]){if(!a[c]){var m=typeof bt=="function"&&bt;if(!y&&m)return m(c,!0);if(l)return l(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[c]={exports:{}};a[c][0].call(h.exports,function(b){var j=a[c][1][b];return o(j||b)},h,h.exports,s,a,r,i)}return r[c].exports}for(var l=typeof bt=="function"&&bt,g=0;g<i.length;g++)o(i[g]);return o}return s})()({1:[function(s,a,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function i(f){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},i(f)}function o(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}function l(f,h){for(var b=0;b<h.length;b++){var j=h[b];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(f,c(j.key),j)}}function g(f,h,b){return h&&l(f.prototype,h),Object.defineProperty(f,"prototype",{writable:!1}),f}function c(f){var h=y(f,"string");return i(h)=="symbol"?h:h+""}function y(f,h){if(i(f)!="object"||!f)return f;var b=f[Symbol.toPrimitive];if(b!==void 0){var j=b.call(f,h);if(i(j)!="object")return j;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}r.default=(function(){function f(){var h=this,b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},j=b.defaultLayoutOptions,d=j===void 0?{}:j,S=b.algorithms,N=S===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:S,E=b.workerFactory,w=b.workerUrl;if(o(this,f),this.defaultLayoutOptions=d,this.initialized=!1,typeof w>"u"&&typeof E>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var p=E;typeof w<"u"&&typeof E>"u"&&(p=function(A){return new Worker(A)});var v=p(w);if(typeof v.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new m(v),this.worker.postMessage({cmd:"register",algorithms:N}).then(function(M){return h.initialized=!0}).catch(console.err)}return g(f,[{key:"layout",value:function(b){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=j.layoutOptions,S=d===void 0?this.defaultLayoutOptions:d,N=j.logging,E=N===void 0?!1:N,w=j.measureExecutionTime,p=w===void 0?!1:w;return b?this.worker.postMessage({cmd:"layout",graph:b,layoutOptions:S,options:{logging:E,measureExecutionTime:p}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var m=(function(){function f(h){var b=this;if(o(this,f),h===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=h,this.worker.onmessage=function(j){setTimeout(function(){b.receive(b,j)},0)}}return g(f,[{key:"postMessage",value:function(b){var j=this.id||0;this.id=j+1,b.id=j;var d=this;return new Promise(function(S,N){d.resolvers[j]=function(E,w){E?(d.convertGwtStyleError(E),N(E)):S(w)},d.worker.postMessage(b)})}},{key:"receive",value:function(b,j){var d=j.data,S=b.resolvers[d.id];S&&(delete b.resolvers[d.id],d.error?S(d.error):S(null,d.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(b){if(b){var j=b.__java$exception;j&&(j.cause&&j.cause.backingJsObject&&(b.cause=j.cause.backingJsObject,this.convertGwtStyleError(b.cause)),delete b.__java$exception)}}}])})()},{}],2:[function(s,a,r){var i=s("./elk-api.js").default;Object.defineProperty(a.exports,"__esModule",{value:!0}),a.exports=i,i.default=i},{"./elk-api.js":1}]},{},[2])(2)})})(qt)),qt.exports}var Va=Ha();const Ua=Ds(Va);function qa(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const Ga=200,Ka=320,rt=56,Ya=7.4,Ja=5.9,Qa=84,Xa=48;function ft(e,n){return Math.round(Math.min(Ka,Math.max(Ga,Qa+e.length*Ya,Xa+n.length*Ja)))}function Za(e,n){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof n=="number"&&s.push(`${n.toLocaleString()} ${n===1?"record":"records"}`),s.join(" · ")}function Ln(e,n){return e.slug<n.slug?-1:e.slug>n.slug?1:0}function xs(e,n){const s=new Set;return e.filter(a=>a.status!=="active"||a.organization_slug&&a.organization_slug!==n||s.has(a.slug)?!1:(s.add(a.slug),!0))}function eo(e){const n=e.metadata_schema;if(!n||typeof n!="object")return 0;const s=n.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function bs(e){const{entityTypes:n,relationshipTypes:s,rulesBySlug:a}=e,r=e.ownerSlug??"",i=[...n].sort(Ln),o=xs(s,r).sort(Ln),l=p=>!p.organization_slug||p.organization_slug===r,g=p=>p.organization_slug||r,c=new Map;for(const p of i)c.set(p.slug,[...c.get(p.slug)??[],p]);const y=p=>(c.get(p.slug)?.length??0)>1?`${g(p)}:${p.slug}`:p.slug,m=new Set(i.filter(l).map(y)),f=p=>{const v=c.get(p)??[];return v.find(l)??(v.length===1?v[0]:void 0)},h=new Set(m),b=o.flatMap(p=>[...a[p.slug]??[]].sort((v,M)=>v.id-M.id).flatMap(v=>{const M=f(v.source_entity_type_slug),A=f(v.target_entity_type_slug);if(!M||!A)return[];const F=y(M),z=y(A);return!m.has(F)&&!m.has(z)?[]:(h.add(F),h.add(z),[{rt:p,source:F,target:z}])})),j=i.filter(p=>h.has(y(p))),d=[],S=new Map,N=new Map;for(const{rt:p,source:v,target:M}of b){const A=`${p.slug}|${v}|${M}`,F=N.get(A);if(F){F.ruleCount+=1;continue}const z={slug:p.slug,label:p.name||p.slug,ruleCount:1};N.set(A,z);const Q=`${v}|${M}`,G=S.get(Q);if(G){G.data.relationships.push(z),G.data.isSymmetric=G.data.isSymmetric&&p.is_symmetric;continue}const se={id:`pair:${v}|${M}`,source:v,target:M,data:{relationships:[z],isSymmetric:p.is_symmetric}};S.set(Q,se),d.push(se)}const E=new Map;for(const{rt:p,source:v,target:M}of b){const A=E.get(p.slug)??new Set;A.add(`${v}|${M}`),E.set(p.slug,A)}for(const{rt:p}of b)if(E.get(p.slug)?.size===1&&typeof p.relationship_count=="number")for(const v of N.values())v.slug===p.slug&&(v.linkCount=p.relationship_count);return{nodes:j.map(p=>{const v=p.name||p.slug,M=eo(p),A=Za(M,p.entity_count);return{id:y(p),width:ft(v,A),height:rt,data:{slug:p.slug,label:v,icon:p.icon,isSystem:Fs(p),organizationSlug:l(p)?void 0:g(p),metaLabel:A}}}),edges:d}}const Ve=24,to=72,no=16;let Rn=null;function so(){return Rn??=new Ua({workerFactory:()=>new qa}),Rn}const Gt={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function ln(e,{elk:n=so(),targetAspect:s}={}){const a=new Set;for(const d of e.edges)a.add(d.source),a.add(d.target);const r=e.nodes.some(d=>d.lane!==void 0),i=e.nodes.filter(d=>r||a.has(d.id)),o=e.nodes.filter(d=>!r&&!a.has(d.id)),l=o.reduce((d,S)=>Math.max(d,S.width),0),g=o.length>0?Ve+l+to:0,c=d=>({x:d.x+Ve+g,y:d.y+Ve});let y=[];const m=new Map;if(i.length>0){const d=e.edges.filter(p=>p.source!==p.target),S=p=>n.layout({id:"root",layoutOptions:r?{...p,"elk.partitioning.activate":"true"}:p,children:i.map(v=>({id:v.id,width:v.width,height:v.height,...r?{layoutOptions:{"elk.partitioning.partition":String(v.lane??1)}}:{}})),edges:d.map(v=>({id:v.id,sources:[v.layoutReversed?v.target:v.source],targets:[v.layoutReversed?v.source:v.target]}))});let N=await S(Gt);const E=s&&N.width&&N.height?s*N.width/N.height:1;if(E>1.08){const p=Number(Gt["elk.spacing.nodeNode"]),v=Math.min(E,2.2);N=await S({...Gt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,p*v+rt*(v-1))))})}const w=new Map((N.children??[]).map(p=>[p.id,p]));y=i.map(p=>{const v=w.get(p.id);return{...p,position:c({x:v?.x??0,y:v?.y??0})}});for(const p of N.edges??[]){const v=(p.sections??[]).flatMap(A=>[A.startPoint,...A.bendPoints??[],A.endPoint]);if(v.length<2)continue;const M=e.edges.find(A=>A.id===p.id)?.layoutReversed;m.set(p.id,(M?[...v].reverse():v).map(c))}}let f=Ve;const h=o.map(d=>{const S={x:Ve,y:f};return f+=d.height+no,{...d,position:S}}),b=new Map([...y,...h].map(d=>[d.id,d]));return{nodes:e.nodes.map(d=>b.get(d.id)??{...d,position:{x:Ve,y:Ve}}),edges:e.edges.map(d=>({...d,route:m.get(d.id)??null}))}}function ro(e,n){return ln(bs(e),n)}const Jt="connector:",In=e=>`${Jt}${e}`,ao={event:"Zap",schedule:"CalendarClock",manual:"Hand"},oo=0,io=1,$n=2;function co(e,n){const s=new Map;for(const{kind:a,targets:r}of sa(e?.feeds_schema?.[n]))for(const{entityType:i,creates:o}of r){const l=s.get(i)??{creates:!1,eventKinds:new Set};l.creates||=o,l.eventKinds.add(a),s.set(i,l)}return s}function lo(e,n){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),a=new Map(e.connectorDefs.map(d=>[d.key,d.name])),r=new Map(e.connections.map(d=>[d.id,d])),i=Kr(e.feeds),o=d=>`connection:${d}`,l=d=>`automation:${d}`,g=[],c=new Set,y=(d,S,N,E,w=!1)=>{g.push({id:`flow:${d}->${S}`,source:d,target:S,layoutReversed:w,data:{relationships:[],isSymmetric:!1,flow:{summary:N,details:E}}}),c.add(d),c.add(S)},m=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const S=new Map;for(const N of i.get(d.id)??[]){const E=co(s.get(d.connector_key),N.feed_key);for(const[w,p]of E){const v=S.get(w)??{creates:!1,eventKinds:new Set};v.creates||=p.creates;for(const M of p.eventKinds)v.eventKinds.add(M);S.set(w,v)}}for(const[N,E]of S){const w=n.get(N);w&&y(o(d.id),w,E.creates?"creates records":"links records",[`From ${[...E.eventKinds].sort().join(", ")} events`])}}const f=Yr(e.automations);for(const[d,S]of f)if(m.has(d))for(const{automation:N,reason:E,eventTypes:w}of S){const p=l(N.automation_id);E==="trigger"?y(o(d),p,kn.trigger,w.length>0?[`On ${[...w].sort().join(", ")}`]:[]):y(p,o(d),kn.delivery,[],!0)}const h=[];for(const d of e.automations){const S=l(d.automation_id),N=d.entity_type?n.get(d.entity_type):void 0;N&&y(N,S,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const E=ea(d,a,r),w=ta(d),p=d.health==="degraded"?"Needs attention":void 0;h.push({id:S,lane:$n,width:ft(`${E.does} ${p??""}`,E.when),height:rt,data:{slug:S,label:E.does,icon:w?In(w):ao[E.kind],isSystem:!1,badge:p,metaLabel:E.when,ref:{kind:"automation",automationId:d.automation_id}}})}const b=[];for(const d of e.metrics){const S=n.get(d.typeSlug);if(!S)continue;const N=`metric:${d.typeSlug}:${d.name}`;y(S,N,"measures",[d.description].filter(Boolean)),b.push({id:N,lane:$n,width:ft(d.name,d.agg),height:rt,data:{slug:N,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.filter(d=>c.has(o(d.id))).map(d=>{const S=na(d),N=Zr(d,s.get(d.connector_key)),E=Jr({feeds:i.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:f.get(d.id)?.length??0}),w=N.needsAttention?"Needs attention":d.device_label??void 0;return{id:o(d.id),lane:oo,width:ft(`${S} ${w??""}`,E),height:rt,data:{slug:o(d.id),label:S,icon:In(d.connector_key),isSystem:!1,badge:w,metaLabel:E,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...h,...b],edges:g}}function ut(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function uo(e,n){const s=new Map;for(const y of e.nodes)(!y.data.organizationSlug||!s.has(y.data.slug))&&s.set(y.data.slug,y.id);const a=lo(n,s),{layers:r}=n,i=[...a.nodes,...e.nodes.map(y=>({...y,lane:io}))],o=new Set(i.filter(y=>r[ut(y)]).map(y=>y.id)),l=[...e.edges,...a.edges].filter(y=>o.has(y.source)&&o.has(y.target)),g=new Set(l.flatMap(y=>[y.source,y.target]));return{graph:{nodes:i.filter(y=>o.has(y.id)&&(ut(y)==="entities"||ut(y)==="automations"||g.has(y.id))),edges:l},hidden:{connections:r.connections?n.connections.length-a.nodes.filter(y=>ut(y)==="connections").length:0}}}const On="__new__";function An(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function mo({entityTypes:e,initialSource:n="",initialTarget:s="",onDone:a}){const r=x.useId(),i=`${r}-relationship`,o=`${r}-name`,l=`${r}-symmetric`,g=`${r}-source`,c=`${r}-target`,{orgContext:y}=Fe(),{data:m=[]}=en(y),f=zs(),h=Ws(),[b,j]=x.useState(""),[d,S]=x.useState(""),[N,E]=x.useState(!1),[w,p]=x.useState(n),[v,M]=x.useState(s),[A,F]=x.useState(null),z=b===On,Q=m.filter(V=>V.status==="active"&&V.purpose!==Bs&&(!V.organization_slug||V.organization_slug===y?.slug)),G=f.isPending||h.isPending,se=async()=>{if(F(null),!b)return F("Pick a relationship");if(!w||!v)return F("Pick both ends");try{let V=b;if(z){const pe=d.trim();if(!pe)return F("Name the relationship");const ge=An(pe);if(!ge)return F("Name must contain a letter or number");V=(await f.mutateAsync({slug:ge,name:pe,is_symmetric:N})).relationship_type.slug,j(V)}await h.mutateAsync({slug:V,source_entity_type_slug:w,target_entity_type_slug:v}),a()}catch(V){F(V instanceof Error?V.message:"Could not save")}};return t.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[t.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(De,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),t.jsxs(Ft,{value:b,onValueChange:j,children:[t.jsx(zt,{id:i,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Pick or define one"})}),t.jsxs(Bt,{children:[Q.map(V=>t.jsx(yt,{value:V.slug,children:V.name||V.slug},V.slug)),Q.length>0?t.jsx(Hs,{}):null,t.jsx(yt,{value:On,children:"Define a new one…"})]})]})]}),z?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(De,{htmlFor:o,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),t.jsx(at,{id:o,value:d,onChange:V=>S(V.target.value),placeholder:"works at",className:"h-8 text-xs"}),d.trim()?t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",t.jsx("code",{children:An(d)||"—"})]}):null]}),t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs(De,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",t.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),t.jsx(Vs,{id:l,checked:N,onCheckedChange:E})]})]}):null,t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(De,{htmlFor:g,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),t.jsxs(Ft,{value:w,onValueChange:p,children:[t.jsx(zt,{id:g,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(De,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),t.jsxs(Ft,{value:v,onValueChange:M,children:[t.jsx(zt,{id:c,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),A?t.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,t.jsx(Gn,{onCancel:a,cancelDisabled:G,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:t.jsx(Y,{type:"button",size:"sm",onClick:se,disabled:G,children:G?"Saving…":"Add relationship"})})]})}const vs=288,fo=440,Et=240,Ct=720,ho=320,dn="lobu.schema-panel-width:v1";function _t(e,n){if(!Number.isFinite(e))return vs;const s=Math.max(Et,Math.min(Ct,n-ho));return Math.round(Math.min(s,Math.max(Et,e)))}function po(){const e=Kn(dn);if(e===null)return null;const n=Number.parseInt(e,10);return!Number.isFinite(n)||n<Et||n>Ct?null:n}function go(e){Yn(dn,String(Math.round(e)))}function yo(){Us(dn)}const Pn={nodes:[],edges:[]};function xo(e,n,s){const{orgContext:a,hasOrgContext:r}=Fe(),{data:i=[],isLoading:o,isError:l}=It(a),{data:g=[],isLoading:c,isError:y}=en(a),m=x.useMemo(()=>xs(g,e),[g,e]),f=x.useCallback(p=>{const v={};return m.forEach((M,A)=>{const F=p[A]?.data;F?.length&&(v[M.slug]=F)}),{rulesBySlug:v,isRulesLoading:p.some(M=>M.isLoading),isRulesError:p.some(M=>M.isError)}},[m]),{rulesBySlug:h,isRulesLoading:b,isRulesError:j}=qs({queries:m.map(p=>({...Gs.queryOptions(p.slug,a),enabled:r})),combine:f}),d=x.useMemo(()=>({entityTypes:i,relationshipTypes:m,rulesBySlug:h,ownerSlug:e,targetAspect:n,flow:s}),[i,m,h,e,n,s]),[S,N]=x.useState(null),E=o||c||b,w=l||y||j;return x.useEffect(()=>{if(E||w)return;let p=!1;const v={targetAspect:d.targetAspect};let M,A;if(d.flow){const F=uo(bs(d),d.flow);M=F.hidden,A=ln(F.graph,v)}else A=ro(d,v);return A.then(F=>{p||N({graph:F,isError:!1,hidden:M})}).catch(()=>{p||N({graph:Pn,isError:!0})}),()=>{p=!0}},[d,E,w]),{graph:S?.graph??Pn,hidden:S?.hidden,isLoading:!w&&!S,isError:w||S?.isError===!0}}function Dn(e){const n=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${n}${s}`}const ws={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function bo(e,n){const s=e.nodes.some(o=>o.data.ref),a=new Map(e.nodes.map(o=>[o.id,o.data.label])),r=e.nodes.map(o=>({id:o.id,x:o.position.x+o.width/2,y:o.position.y+o.height/2,w:o.width,h:o.height,title:o.data.label,meta:o.data.metaLabel,icon:o.data.icon,badge:o.data.badge??o.data.organizationSlug,muted:o.data.isSystem,dimmed:n?!n.nodes.has(o.id):!1,accent:s?ws[ut(o)]:void 0})),i=e.edges.map(o=>{const{relationships:l,isSymmetric:g,flow:c}=o.data;if(c)return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:c.summary,details:[c.summary,...c.details],directed:!0,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} to ${a.get(o.target)??o.target}: ${c.summary}`};const y=l.map(m=>m.label).join(", ");return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:l.length===1?Dn(l[0]):`${l.length} relationships`,details:l.map(Dn),directed:!g,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} ${g?"and":"to"} ${a.get(o.target)??o.target}: ${y}`}});return{boxes:r,edges:i}}const Fn=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],vo={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function wo({metric:e,ownerSlug:n}){const s=(a,r)=>r.length>0?t.jsxs("section",{className:"flex flex-col gap-1.5",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:r.map(i=>t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:i.name}),i.description?t.jsx("span",{className:"text-muted-foreground",children:` · ${i.description}`}):null]},i.name))})]}):null;return t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm",children:[vo[e.agg]??e.agg," of"," ",t.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(a=>({name:a,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),t.jsx(Y,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:t.jsxs(we,{to:"/$owner/$entityType",params:{owner:n,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function ko({ownerSlug:e,metric:n,endpointOptions:s,canAuthor:a,mode:r,onModeChange:i}){const o=()=>i({kind:"index"});return r.kind==="metric"?n?t.jsx(wo,{metric:n,ownerSlug:e}):null:a?r.kind==="create-type"?t.jsx(ra,{slug:null,onClose:o}):r.kind==="new-relationship"?t.jsx(mo,{entityTypes:s,initialSource:r.source,initialTarget:r.target,onDone:o},`${r.source??""}|${r.target??""}`):null:null}function jo(e){const{mode:n,canAuthor:s,onModeChange:a,isPeekOpen:r}=e,i=s&&n.kind==="create-type",o=n.kind==="metric"?n.name:s&&n.kind==="new-relationship"?"New relationship":i?"New entity type":"Schema",l=x.useRef(null),g=JSON.stringify(n),c=x.useRef(g);return x.useEffect(()=>{c.current!==g&&(c.current=g,l.current?.focus({preventScroll:!0}))},[g]),t.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:le("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",n.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",r&&"lg:hidden"),children:t.jsxs("div",{className:le("flex min-h-0 flex-1 flex-col",n.kind!=="index"&&"lg:absolute lg:inset-0"),children:[t.jsxs("div",{className:n.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[t.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:o}),n.kind!=="index"?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>a({kind:"index"}),children:t.jsx(nr,{className:"h-4 w-4"})}):null]}),t.jsx("div",{className:le("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",n.kind==="index"?"pb-1":"p-4"),children:t.jsx(ko,{...e})})]})})}function ks(e){const n=e.previousElementSibling,s=e.nextElementSibling;if(n instanceof HTMLElement&&s instanceof HTMLElement){const a=n.clientWidth+s.clientWidth;if(a>0)return a}return 0}function No({width:e,maxWidth:n,onResize:s,onCommit:a,onReset:r,className:i}){const[o,l]=x.useState(!1),g=x.useRef(0),c=f=>{const h=ks(f);return h>0?h:f.parentElement?.clientWidth??0},y=f=>{if(f.button!==0)return;const h=f.currentTarget;if(!h.parentElement)return;f.preventDefault(),g.current=c(h);const j=f.clientX,d=e;l(!0),h.setPointerCapture(f.pointerId);const S=p=>_t(d-(p-j),g.current);let N=d;const E=p=>{N=S(p.clientX),s(N)},w=p=>{h.removeEventListener("pointermove",E),h.removeEventListener("pointerup",w),h.removeEventListener("pointercancel",w),l(!1),a(p.type==="pointercancel"?N:S(p.clientX))};h.addEventListener("pointermove",E),h.addEventListener("pointerup",w),h.addEventListener("pointercancel",w)},m=f=>{const h=c(f.currentTarget),b=j=>{f.preventDefault(),a(_t(e+j,h))};f.key==="ArrowLeft"?b(16):f.key==="ArrowRight"?b(-16):f.key==="Home"&&(f.preventDefault(),r())};return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize schema panel","aria-valuenow":e,"aria-valuemin":Et,"aria-valuemax":n,tabIndex:0,onPointerDown:y,onKeyDown:m,onDoubleClick:r,className:le("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",o&&"cursor-col-resize",i),children:t.jsx("div",{className:le("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",o&&"w-0.5 bg-primary")})})}function So({ownerSlug:e}){const n=ot(),s=tn(),a=s?.item!=null,{orgContext:r}=Fe(),{isAdmin:i}=Jn(r.organizationId),[o,l]=x.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[g,c]=x.useState({kind:"index"}),y=s?.close,m=x.useCallback(k=>{k.kind!=="index"&&a&&y?.(),c(k)},[a,y]),[f,h]=x.useState(),b=x.useRef(null),j=x.useCallback(k=>{if(b.current?.disconnect(),b.current=null,!k||typeof ResizeObserver>"u")return;const _=()=>{if(!k.clientWidth||!k.clientHeight)return;const B=Math.round(k.clientHeight/k.clientWidth*10)/10;h(R=>R===B?R:B)};_();const W=new ResizeObserver(_);W.observe(k),b.current=W},[]),d=r.organizationId,S=Ks(d),N=Ys(d),E=Js(d),w=Xr(d??void 0),{data:p}=It(r),v=x.useMemo(()=>p?.filter(k=>Qs(k,e)),[p,e]),M=x.useMemo(()=>(v??[]).flatMap(k=>Object.entries(k.metrics_config?.measures??{}).map(([_,W])=>({typeSlug:k.slug,name:_,agg:W.agg,description:W.description}))),[v]),A=S.isLoading||N.isLoading||E.isLoading||w.isLoading,F=x.useMemo(()=>A?null:{connections:S.data??[],feeds:N.data??[],connectorDefs:E.data??[],automations:w.data??[],metrics:M,layers:o},[A,S.data,N.data,E.data,w.data,M,o]),{graph:z,isLoading:Q,isError:G,hidden:se}=xo(e,f,F),V=Q||A,pe={connections:!A&&(S.data??[]).length===0,entities:!1,automations:!A&&(w.data??[]).length===0,metrics:!A&&M.length===0},ge=k=>!pe[k]||i&&Le[k]!=null,I=g.kind==="metric"?g:null,L=x.useMemo(()=>{if(!I)return null;const k=`metric:${I.typeSlug}:${I.name}`,_=z.edges.find(R=>R.target===k);if(!_)return null;const W=_.source,B=z.edges.filter(R=>R.target===W&&z.nodes.find(D=>D.id===R.source)?.data.ref?.kind==="connection");return{typeId:W,nodes:new Set([k,W,...B.map(R=>R.source)]),edges:new Set([_.id,...B.map(R=>R.id)]),sources:B.map(R=>z.nodes.find(D=>D.id===R.source)?.data.label??R.source)}},[I,z]),{boxes:q,edges:U}=x.useMemo(()=>bo(z,L),[z,L]),H=x.useMemo(()=>{if(!I)return null;const k=v?.find(B=>B.slug===I.typeSlug),_=k?.metrics_config,W=_?.measures?.[I.name];return!k||!W?null:{name:I.name,typeSlug:k.slug,typeLabel:k.name||k.slug,agg:W.agg,eventSet:W.eventSet,description:W.description,dimensions:Object.entries(_?.dimensions??{}).map(([B,R])=>({name:B,description:R.description})),segments:Object.entries(_?.segments??{}).map(([B,R])=>({name:B,description:R.description})),sources:L?.sources??[]}},[I,v,L]),J=x.useMemo(()=>new Map(z.nodes.map(k=>[k.id,k.data.slug])),[z.nodes]),X=x.useMemo(()=>new Map(z.nodes.flatMap(k=>k.data.ref?[[k.id,k.data.ref]]:[])),[z.nodes]),{data:fe=[]}=Xs(r.organizationId),de=x.useMemo(()=>{const k=new Map;for(const _ of z.nodes)_.data.ref||(!_.data.organizationSlug||!k.has(_.data.slug))&&k.set(_.data.slug,{slug:_.data.slug,label:_.data.label});return[...k.values()]},[z.nodes]),Ce=x.useCallback(k=>{const _=X.get(k);if(_?.kind==="connection"){n({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:_.connectorKey,connectionId:String(_.connectionId)},search:{}});return}if(_?.kind==="metric"){m({kind:"metric",typeSlug:_.typeSlug,name:_.name});return}if(_?.kind==="automation"){n({to:"/$owner/automations/$automationId",params:{owner:e,automationId:_.automationId},search:{view:"activity",run_id:void 0}});return}n(Qn(e,J.get(k)??k))},[n,e,J,X,m]),ze=x.useCallback((k,_)=>{X.has(k)||X.has(_)||m({kind:"new-relationship",source:J.get(k)??k,target:J.get(_)??_})},[J,X,m]),Te=z.nodes.some(k=>!k.data.ref&&!k.data.isSystem&&!k.data.organizationSlug),Ge=z.nodes.some(k=>k.data.ref),ke="size-6 text-muted-foreground hover:text-foreground",Le={connections:t.jsx(Qr,{ownerSlug:e,catalog:fe,trigger:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:ke,"aria-label":"New connector",title:"New connector",children:t.jsx(mt,{className:"size-3.5"})})}),entities:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:ke,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>m({kind:"create-type"}),children:t.jsx(mt,{className:"size-3.5"})}),automations:t.jsx(Y,{asChild:!0,variant:"ghost",size:"icon",className:ke,children:t.jsx(we,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:t.jsx(mt,{className:"size-3.5"})})})},ye=x.useCallback(k=>{const _=k.startsWith(Jt)?k.slice(Jt.length):null;if(!_)return t.jsx(Rt,{icon:k||null,className:"h-4 w-4"});const W=Zs(_,E.data??[],{name:S.data?.find(B=>B.connector_key===_)?.connector_name??_});return t.jsx(er,{plain:!0,icon:W.icon,iconUrl:W.iconUrl,name:W.name,faviconDomain:W.faviconDomain})},[E.data,S.data]),Re=i&&g.kind==="create-type",je=g.kind==="metric"||i&&g.kind!=="index",[We,ue]=x.useState(()=>po()),Ke=We??(Re?fo:vs),[xe,Ie]=x.useState(null),$e=x.useRef(null),Be=x.useCallback(k=>{if($e.current?.disconnect(),$e.current=null,!k||typeof ResizeObserver>"u")return;const _=k.children[1];if(!_)return;const W=()=>{const R=ks(_);R>0&&Ie(D=>D===R?D:R)};W();const B=new ResizeObserver(W);B.observe(k),$e.current=B},[]),C=xe===null?Ke:_t(Ke,xe),u=xe===null?Ct:_t(Ct,xe),T=x.useCallback(k=>{ue(k),go(k)},[]),$=x.useCallback(()=>{ue(null),yo()},[]);return V?t.jsx(cn,{label:"Loading workspace schema",fill:!0,schemaActions:i}):G?t.jsx(Xn,{label:"workspace schema"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsxs("div",{className:le("flex flex-wrap items-center justify-between gap-3",je&&"hidden lg:flex"),children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Ge?`Where records come from, the types they land in, and what uses them. Click a box to open it${i?", or drag a type's ⊕ onto another to relate them":""}. Only stored links are drawn${se?.connections?`; ${se.connections} connections have none yet`:""}.`:Te?z.edges.length>0?`Your workspace schema. Hover a type or select a line to name its relationships, click a type to open it${i?", or drag its ⊕ to relate types.":"."}`:"Your workspace schema. Click a type to open it — relationships appear here once you add one to a type.":i?"Member is already here: everyone in this workspace. Create the first type of record you track — a company, a deal, a ticket — then drag its ⊕ onto Member to relate them.":"Member is already here: everyone in this workspace. An admin can add the types of record this workspace tracks."}),t.jsxs("fieldset",{className:"m-0 flex min-w-0 shrink-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",children:[t.jsx("legend",{className:"sr-only",children:"Show on the map"}),Fn.map(({key:k,label:_})=>{if(!ge(k))return null;const W=`memory-map-show-${k}`,B=pe[k],R=o[k]&&Fn.filter(({key:D})=>o[D]&&ge(D)).length===1;return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[B?null:t.jsxs(t.Fragment,{children:[t.jsx(tr,{id:W,checked:o[k],disabled:R,onCheckedChange:D=>l(ie=>({...ie,[k]:D===!0}))}),t.jsxs("label",{htmlFor:W,className:"inline-flex cursor-pointer select-none items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":"true",className:"size-2 rounded-full",style:{background:`var(${ws[k]})`}}),_]})]}),i?Le[k]:null]},k)})]})]}),t.jsxs("div",{ref:Be,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[t.jsx("div",{className:le("flex min-w-0 flex-1 flex-col lg:pb-8",je&&"hidden lg:flex"),children:t.jsx("div",{ref:j,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:t.jsx(ys,{boxes:q,edges:U,label:"Workspace schema",onOpenBox:Ce,openLabel:k=>`Open ${k.title}`,onConnect:i?ze:void 0,renderIcon:ye})})}),t.jsx(No,{width:C,maxWidth:u,onResize:ue,onCommit:T,onReset:$,className:a||g.kind==="index"?"lg:hidden":void 0}),t.jsx(jo,{width:C,metric:H,ownerSlug:e,endpointOptions:de,canAuthor:i,mode:g,onModeChange:m,isPeekOpen:a})]})]})}function Eo({onClose:e,entityTypeSlug:n,orgContext:s,onSuccess:a}){const{data:r,isLoading:i}=Zn(n,s),o=`${s.organizationId??s.slug}:${n}`,l=sr(o,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[g,c]=l.field("name"),[y,m]=l.field("customSlug"),[f,h]=l.field("useCustomSlug"),[b,j]=l.field("metadata"),[d,S]=rr(o,null),N=ar(),E=f?y:or(g),w=async F=>{if(F.preventDefault(),!l.canSubmit)return;if(S(null),!g.trim()){S("Name is required");return}const z=oa(b),Q={entityType:n,name:g.trim(),slug:f?y:void 0,metadata:Object.keys(z).length>0?z:void 0};try{const G=await N.mutateAsync(Q);if(e(),G.approval_queued||!G.entity){es.info("Create queued for approval");return}typeof G.entity.id=="number"&&a?.(G.entity.id)}catch(G){S(G instanceof Error?G.message:"Failed to create entity")}},p=r?.name||n,v=l.revision,M=`Create ${p}`,A=`Add a new ${p.toLowerCase()} to your workspace.`;return i?t.jsx(ir,{rows:6}):t.jsxs("form",{onSubmit:w,children:[t.jsx(cr,{visible:l.hasConflict,onReload:l.reset}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:A})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs(De,{htmlFor:"name",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(at,{id:"name",value:g,onChange:F=>c(F.target.value),placeholder:`Enter ${p.toLowerCase()} name`,autoFocus:!0})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(De,{htmlFor:"slug",children:"URL Slug"}),t.jsx("button",{type:"button",onClick:()=>h(!f),className:"text-xs text-muted-foreground hover:text-foreground",children:f?"Auto-generate":"Customize"})]}),f?t.jsx(at,{id:"slug",value:y,onChange:F=>m(F.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):t.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:E||"slug-preview"})]}),v&&Object.keys(v).length>0?t.jsxs(t.Fragment,{children:[t.jsx(ha,{className:"my-2"}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(De,{className:"text-sm font-medium",children:"Additional Fields"}),t.jsx(aa,{schema:l.revision,values:b,onValuesChange:j,orgContext:s})]})]}):null,d&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:d})]}),t.jsx(Gn,{onCancel:e,cancelDisabled:N.isPending,className:"mt-2",children:t.jsx(Y,{type:"submit",disabled:!l.canSubmit||N.isPending||!g.trim(),children:N.isPending?"Creating...":`Create ${p}`})})]})}function Co(e){const n=e?.properties??{},s=mr(e);return Object.entries(n).flatMap(([a,r])=>{const i=s.find(m=>m.field===a);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a)||!r||r.const!==void 0||r["x-table-column"]!==!0&&r["x-facet"]!==!0&&!i)return[];const o=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],l=i?.options??[],g=l.find(m=>m.value!==null)?.value,c=o.find(m=>["string","number","integer","boolean"].includes(String(m.type)))??(g===void 0?void 0:{type:typeof g});if(!c)return[];const y=r.format==="date-time"||c.format==="date-time"?"datetime-local":r.format==="date"||c.format==="date"?"date":c.type==="number"||c.type==="integer"?"number":c.type==="boolean"?"boolean":"string";return[{field:a,label:String(r["x-table-label"]??r.title??a.replaceAll("_"," ")),type:y,options:y==="boolean"&&!l.some(m=>typeof m.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function _o(e){const n=e?.[Yt];return n===void 0?{}:nn(n)}function Mo(e,n,s){try{const a=_o(n),r=e[ts],i=r===void 0?void 0:a.presets?.find(y=>y.key===r);if(r!==void 0&&!i)throw new Error("This saved filter is unavailable. Choose another filter.");if(i&&!s&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const o=i&&e[nt]===void 0?{collection:jt(i)}:lr(e,s);if(o.error)throw o.error;const l=e[dr],g=l===void 0?i?.table??a.table??{}:nn({table:typeof l=="string"?JSON.parse(l):l}).table??{},c=!!i&&(zn(o.collection)!==zn(jt(i))||Mt(g)!==Mt(i.table??a.table??{}));return{...o,presentation:a,preset:i,table:g,edited:c}}catch(a){return{collection:{},presentation:{},table:{},edited:!1,error:a instanceof Error?a:new Error("Invalid collection configuration")}}}function zn(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(wt)])}function wt(e){return JSON.stringify([e.field,e.op,e.value])}function Mt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function To(e,n){return n?{[ts]:n,[nt]:Kt(e)[nt]??"{}"}:Kt(e)}function Lo(e,n,s,a,r=new Date){let i=n.filters??[],o=e.relativeDate;if(o){const l=(jt({...e,selection:{}},r).filters??[]).map(wt),g=i.map(wt);l.every(c=>g.includes(c))?i=i.filter(c=>!l.includes(wt(c))):o=void 0}return{key:e.key,label:e.label,selection:{...n.search?{search:n.search}:{},...i.length?{filters:i}:{},...n.segment?{segment:n.segment}:{}},...Mt(s)!==Mt(a.table??{})?{table:s}:{},...o?{relativeDate:o}:{}}}function Ro(e,n,s){const a=[...e.filters??[]],r=s??(n.length===1&&n[0].op==="eq"?a.findIndex(o=>o.field===n[0].field&&o.op==="eq"):-1),i=r>=0?[...a.slice(0,r),...n,...a.slice(r+1)]:[...a,...n];return{...e,filters:fr({filters:i}).filters}}function Io(e,n){return{...e,filters:e.filters?.filter((s,a)=>a!==n)}}function $o(e,n){return{...typeof e.$preset=="string"?e[nt]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[nt]:String(ur(e[nt]))}:Kt(n),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const Oo=[{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 Ao(e){return e.sort&&Oo.some(n=>n.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Po(e,n,s,a,r){const i={...a,filters:a.filters?.filter(o=>o.field!==s)};return ns({queryKey:["collection-facets",e,n,s,i],enabled:!!n&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:o})=>{const l=await Nt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
2
- ${n}`},e,{signal:o}),g=l.return_value;if(!l.success||typeof g?.connection!="string"||typeof g.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(o.aborted)throw new DOMException("Aborted","AbortError");const c=await Nt("query_sql",{title:`Value counts for ${s}`,connection:g.connection,sql:g.sql,limit:51},e,{signal:o});if(c.error)throw new Error(c.error);if(!Array.isArray(c.rows))throw new Error("Source did not return value counts");const y=c.rows.map(m=>{const f=m,h=typeof f.count=="string"&&/^\d+$/.test(f.count)?Number(f.count):f.count;if(!(f.value===null||["string","number","boolean"].includes(typeof f.value))||typeof h!="number"||!Number.isSafeInteger(h)||h<0)throw new Error("Source returned an invalid value distribution");return{value:f.value,count:h}});return{values:y.slice(0,50),truncated:y.length>50||c.truncated===!0}}})}const Do=300;function Fo({label:e,search:n,onSearch:s,className:a}){const r=n??"",[i,o]=x.useState(r),l=x.useRef({search:n,onSearch:s});l.current={search:n,onSearch:s};const g=x.useRef(void 0);x.useEffect(()=>{const y=()=>{clearTimeout(g.current),o(l.current.search??"")};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[]);const c=x.useRef(r);return x.useEffect(()=>{r!==c.current&&(c.current=r,o(r))},[r]),x.useEffect(()=>{if(i===(l.current.search??""))return;const y=setTimeout(()=>{const m=l.current.onSearch;c.current=i,m(i||void 0,!0)},Do);return g.current=y,()=>clearTimeout(y)},[i]),t.jsxs("div",{className:`relative${a?` ${a}`:""}`,children:[t.jsx(pr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(at,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:y=>o(y.target.value),className:"pl-9"})]})}const zo={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Wo({field:e,initial:n,org:s,facetQuery:a,collection:r,onApply:i,close:o}){const[l,g]=x.useState(n?.op??"eq"),[c,y]=x.useState(n?.value==null?"":String(n.value)),[m,f]=x.useState(""),[h,b]=x.useState(!1),[j,d]=x.useState(),S=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",N=Po(s,a,e.field,r),E=v=>{try{const M=h?[{field:e.field,op:"gte",value:e.type==="number"?Number(c):c},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:l,value:v}];if(e.type==="datetime-local")for(const z of M)typeof z.value=="string"&&(z.value=new Date(z.value).toISOString());if(M.some(z=>typeof z.value=="number"&&!Number.isFinite(z.value)))throw new Error("Enter a valid number.");const A=M[0].value,F=M[1]?.value;if(h&&A!=null&&F!=null&&A>F)throw new Error("The lower bound must be before the upper bound.");i(M),o()}catch(M){d(M instanceof Error?M.message:"Could not apply filter")}},w=[...e.options];for(const v of N.data?.values??[])w.some(M=>M.value===v.value)||w.push({value:v.value,label:v.value===null?"Not supplied":String(v.value)});const p=Math.max(1,...N.data?.values.map(v=>v.count)??[]);return t.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[t.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:h?"range":l,onChange:v=>{b(v.target.value==="range"),v.target.value!=="range"&&g(v.target.value)},children:[t.jsx("option",{value:"eq",children:"is"}),t.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"lt",children:"less than / before"}),t.jsx("option",{value:"lte",children:"at most / on or before"}),t.jsx("option",{value:"gt",children:"greater than / after"}),t.jsx("option",{value:"gte",children:"at least / on or after"}),n?null:t.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&t.jsxs("form",{className:"space-y-2",onSubmit:v=>{v.preventDefault(),E(e.type==="number"?Number(c):c)},children:[t.jsx(at,{required:!0,"aria-label":h?"From value":"Filter value",type:S,step:e.type==="number"?"any":void 0,value:c,onChange:v=>y(v.target.value),placeholder:"Enter a value…"}),h&&t.jsx(at,{required:!0,"aria-label":"To value",type:S,step:e.type==="number"?"any":void 0,value:m,onChange:v=>f(v.target.value)}),t.jsx(Y,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!h&&(l==="eq"||l==="neq")&&t.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:w.filter(v=>!c||v.label.toLowerCase().includes(c.toLowerCase())).map(v=>{const M=N.data?.values.find(A=>A.value===v.value)?.count;return t.jsxs("button",{type:"button","aria-label":v.label,onClick:()=>E(v.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:[M!==void 0&&t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${M/p*100}%`}}),t.jsx("span",{className:"relative truncate",children:v.label}),t.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:M?.toLocaleString()})]},JSON.stringify(v.value))})}),a&&N.isFetching&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),N.isError&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),N.data?.truncated&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),j&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:j})]})}function Bo({choices:e,visible:n,onChange:s}){return t.jsxs(sn,{children:[t.jsx(rn,{asChild:!0,children:t.jsx(Y,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:t.jsx(ss,{className:"h-4 w-4"})})}),t.jsxs(an,{align:"end",className:"max-h-80 overflow-y-auto p-3",children:[t.jsx("p",{className:"mb-2 text-sm font-medium",children:"Visible columns"}),e.map(a=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 py-1.5 text-sm",children:[t.jsx("input",{type:"checkbox",checked:!n||n.includes(a.field),onChange:r=>{const i=n??e.map(o=>o.field);s(r.target.checked?[...i,a.field]:i.filter(o=>o!==a.field))}}),a.label]},a.field))]})]})}function Ho({collection:e,schema:n,label:s,onChange:a,org:r,facetQuery:i,segmentChip:o,viewFilters:l,onClearAll:g}){const c=Co(n),y=(b,j)=>({kind:"custom",className:"w-80",render:d=>t.jsx(Wo,{field:b,initial:j==null?void 0:e.filters?.[j],org:r,facetQuery:i,collection:e,onApply:S=>a(Ro(e,S,j)),close:d})}),m=c.map(b=>({key:b.field,label:b.label,icon:t.jsx(hr,{className:"h-4 w-4"}),editor:y(b)})),f=new Map,h=(e.filters??[]).map((b,j)=>{const d=`${b.field}:${b.op}:${JSON.stringify(b.value)}`,S=f.get(d)??0;f.set(d,S+1);const N=c.find(w=>w.field===b.field),E=N?.options.find(w=>w.value===b.value)?.label??String(b.value??"Not supplied");return{id:`${d}:${S}`,label:N?.label??b.field,op:zo[b.op],value:E,editor:N?y(N,j):void 0,onRemove:()=>a(Io(e,j))}});if(o&&h.unshift(o),l?.fields.length){for(const b of m)b.group=s;m.push(...l.fields),h.push(...l.chips)}return!m.length&&!h.length?null:t.jsx(pa,{label:`${s} filters`,fields:m,chips:h,onClearAll:g??(()=>a({...e,filters:[],segment:void 0}))})}const Tt=120,Me=12;function Wn(e,n){return typeof e.linkId=="number"&&typeof n.linkId=="number"?e.linkId-n.linkId:String(e.linkId).localeCompare(String(n.linkId))}function Vo(e){const n=e.records.slice(0,Tt),s=c=>e.types.get(c)??{label:c},a=new Map;for(const c of n)a.set(String(c.id),{source:c.source,entityType:e.typeSlug,slug:c.slug,name:c.name,isFocus:!0,hasMoreLinks:!1});const r=new Map;for(const c of e.links){if(!a.has(String(c.recordId)))continue;const y=r.get(c.recordId)??new Map;y.set(c.linkId,c),r.set(c.recordId,y)}const i=new Map;for(const[c,y]of r){const m=[...y.values()].sort(Wn),f=a.get(String(c));f&&m.length>Me&&(f.hasMoreLinks=!0);for(const h of m.slice(0,Me)){i.set(h.linkId,h);const b=String(h.peer.id);a.has(b)||a.set(b,{source:h.peer.source,entityType:h.peer.type,slug:h.peer.slug,name:h.peer.name,isFocus:!1,hasMoreLinks:!1})}}const o=[];for(const[c,y]of a){const m=s(y.entityType),f=y.name||y.slug,h=y.hasMoreLinks?`${m.label} · ${Me}+ links`:m.label;o.push({id:c,data:{slug:y.slug,label:f,icon:m.icon,isSystem:!1,metaLabel:h},width:ft(f,h),height:rt})}const l=new Map;for(const c of[...i.values()].sort(Wn)){const y=String(c.fromId),m=String(c.toId),f=JSON.stringify([y,m]),h=l.get(f)??{source:y,target:m,rels:new Map,symmetric:!0};h.symmetric&&=c.isSymmetric,h.rels.has(c.relSlug)||h.rels.set(c.relSlug,{slug:c.relSlug,label:c.relName,ruleCount:1}),l.set(f,h)}const g=[...l.entries()].map(([c,y])=>({id:`link:${c}`,source:y.source,target:y.target,data:{relationships:[...y.rels.values()],isSymmetric:y.symmetric}}));return{nodes:o,edges:g,records:a,hasMoreRecords:e.hasMore===!0||e.records.length>Tt,listedCount:n.length,focusCount:n.length}}async function Uo(e,n){const s=Vo(e);return{...await ln({nodes:s.nodes,edges:s.edges},n),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const qo=8,Go=3,Ko=4;function kt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Yo(e,n){return n.map(s=>{const a={type:e,key:s.slug};return{...s,id:kt(a),source:a}})}function Bn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Jo(e,n,s){const a=e.slice(0,qo),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(Go,a.length)},async()=>{for(;i<a.length;){const o=i++,l=a[o];try{if(s?.aborted)throw s.reason;const g=await n(l),c=new Map(l.links.map(d=>[Bn(d),d]));for(const d of g.record_links){const S=Bn(d),N=c.get(S);(!N||N.occurred_at<d.occurred_at)&&c.set(S,d)}const y=new Map((l.relationships??[]).map(d=>[d.id,d]));for(const d of g.relationships??[])y.set(d.id,d);const m=[...y.values()].slice(0,Me+1),f=[...c.values()].slice(0,Me+1),h=(l.pagesRead??0)+1,b=!!g.next_cursor&&h>=Ko,j=g.record_failures.length>0||!!g.relationship_failures?.length||b;r[o]={read:{record:l.record,links:f,failed:j,entityId:l.entityId,relationships:m},...!b&&(j||g.next_cursor&&f.length+m.length<=Me)?{next:{record:l.record,entityId:l.entityId,relationships:m,pagesRead:h,cursor:g.next_cursor??l.cursor,links:f}}:{}}}catch(g){if(s?.aborted)throw g;r[o]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:g instanceof gr&&g.status===400?null:l.cursor}}}}})),{reads:r.map(o=>o.read),pending:[...r.flatMap(o=>o.next?[o.next]:[]),...e.slice(a.length)]}}function Qo(e,n){const s=new Map;for(const i of e)for(const o of i.reads)s.set(String(o.entityId??kt(o.record)),o);const a=new Map(n.map(i=>[i.slug,i])),r=[];for(const[i,o]of s){for(const l of o.relationships??[]){const g=(j,d)=>typeof j=="number"?j:kt({type:d,key:j}),c=g(l.from_entity_id,l.from_entity_type),y=g(l.to_entity_id,l.to_entity_type),m=String(c)===i,f=m?y:c,h=m?l.to_entity_id:l.from_entity_id,b=(m?l.to_entity_type:l.from_entity_type)??"";r.push({recordId:i,linkId:l.id,fromId:c,toId:y,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:f,name:(m?l.to_entity_name:l.from_entity_name)??String(h),slug:(m?l.to_entity_slug:l.from_entity_slug)??String(h),type:b,...typeof h=="string"?{source:{type:b,key:h}}:{}}})}for(const l of o.links){const g={type:l.entity_type,key:l.key},c=kt(g),y=a.get(l.relationship_type);let m=l.direction==="incoming"?c:i,f=l.direction==="incoming"?i:c;y?.is_symmetric&&m>f&&([m,f]=[f,m]),r.push({recordId:i,linkId:JSON.stringify([m,f,l.relationship_type]),fromId:m,toId:f,relSlug:l.relationship_type,relName:y?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:y?.is_symmetric??!1,peer:{id:c,name:l.name||l.key,slug:l.key,type:l.entity_type,source:g}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function Xo(e,n,s,a,r,i=!1){const{orgContext:o}=Fe(),l=It(o),g=en(o),c=x.useMemo(()=>i?Yo(n,s):s,[i,n,s]),y=x.useMemo(()=>c.slice(0,Tt).flatMap(w=>w.source?[{record:w.source,cursor:null,links:[]}]:typeof w.id=="number"?[{entityId:w.id,record:{type:n,key:w.slug},cursor:null,links:[]}]:[]),[c,n]),m=yr({queryKey:["source-records-graph",o.organizationId,e,n,y.map(w=>[w.record,w.entityId])],enabled:!0,initialPageParam:y,queryFn:({pageParam:w,signal:p})=>Jo(w,async v=>{const M=await Nt("manage_entity",{action:"list_links",...v.entityId===void 0?{record:v.record,cursor:v.cursor}:{entity_id:v.entityId,offset:Number(v.cursor??0)},limit:Me+1},e,{signal:p});return{...M,record_links:M.record_links??[],record_failures:M.record_failures??[],next_cursor:v.entityId===void 0?M.next_cursor:M.metadata?.has_more?String(Number(v.cursor??0)+Me+1):null}},p),getNextPageParam:w=>w.pending.length?w.pending:void 0,staleTime:3e4,retry:!1}),f=x.useMemo(()=>m.data?Qo(m.data.pages,g.data??[]):void 0,[m.data,g.data]),h=f?.links,b=m.isError,j=JSON.stringify([o.organizationId,e,n,i,c.map(w=>[w.id,w.name,w.slug]),a]),d=x.useMemo(()=>new Map((l.data??[]).map(w=>[w.slug,{label:w.name||w.slug,icon:w.icon}])),[l.data]),[S,N]=x.useState(null);x.useEffect(()=>{if(!h)return;let w=!1;return Uo({typeSlug:n,records:c,hasMore:a,links:h,types:d},{targetAspect:r}).then(p=>{w||N({graph:p,key:j,isError:!1})}).catch(()=>{w||N({graph:null,key:j,isError:!0})}),()=>{w=!0}},[h,n,c,a,d,r,j]);const E=S?.key===j?S:null;return{graph:E?.graph??null,isLoading:!b&&!E,isError:b||E?.isError===!0,sourceProgress:{checked:f?.checked??0,total:Math.min(s.length,Tt),failed:f?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Zo(e){const n=new Map(e.nodes.map(r=>[r.id,r.data.label])),s=e.nodes.map(r=>({id:r.id,x:r.position.x+r.width/2,y:r.position.y+r.height/2,w:r.width,h:r.height,title:r.data.label,meta:r.data.metaLabel,icon:r.data.icon,muted:e.records.get(r.id)?.isFocus===!1})),a=e.edges.map(r=>{const{relationships:i,isSymmetric:o}=r.data,l=i.map(g=>g.label);return{id:r.id,source:r.source,target:r.target,route:r.route??null,summary:l.length===1?l[0]:`${l.length} relationships`,details:l,directed:!o,ariaLabel:`${n.get(r.source)??r.source} ${o?"and":"to"} ${n.get(r.target)??r.target}: ${l.join(", ")}`}});return{boxes:s,edges:a}}function ei({ownerSlug:e,typeSlug:n,records:s,hasMore:a,sourceBacked:r=!1}){const i=ot(),o=tn(),{orgContext:l}=Fe(),{data:g=[]}=It(l),c=g.find(p=>p.slug===n)?.name??n,[y,m]=x.useState(),f=x.useRef(null),h=x.useCallback(p=>{if(f.current?.disconnect(),f.current=null,!p||typeof ResizeObserver>"u")return;const v=()=>{if(!p.clientWidth||!p.clientHeight)return;const A=Math.round(p.clientHeight/p.clientWidth*10)/10;m(F=>F===A?F:A)};v();const M=new ResizeObserver(v);M.observe(p),f.current=M},[]),{graph:b,isLoading:j,isError:d,sourceProgress:S}=Xo(e,n,s,a,y,r),N=x.useMemo(()=>b?Zo(b):null,[b]),E=x.useCallback(p=>{const v=b?.records.get(p);if(v){if(o){o.open(ia({...v.source?{record:v.source}:{entityId:Number(p)},ownerSlug:e,orgContext:l,name:v.name||v.slug}));return}i({to:rs(e,[{entity_type:v.entityType,slug:v.slug}])})}},[b,e,l,o,i]);if(d)return t.jsx(Xn,{label:`${c} graph`});if(j||!b||!N)return t.jsx(cn,{label:`Loading ${c} graph`});const w=S?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[t.jsxs("p",{children:["Checked ",S.checked," of ",S.total," records. Up to ",Me," relationships per record."]}),S.failed>0?t.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),S.hasMore?t.jsx(Y,{variant:"outline",size:"sm",disabled:S.isFetching,onClick:S.loadMore,children:S.isFetching?"Loading…":S.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return b.focusCount===0?t.jsxs("div",{className:"space-y-3",children:[w,t.jsx(as,{icon:os,title:`No ${c} records match`,description:"Change the search or filters to see records here."})]}):t.jsxs("div",{className:"flex flex-col gap-2",children:[w,t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",b.hasMoreRecords?"the first ":"",b.focusCount," ",c," record",b.focusCount===1?"":"s",". Click a record to see it."]}),t.jsx("div",{ref:h,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:t.jsx(ys,{boxes:N.boxes,edges:N.edges,label:`${c} records`,onOpenBox:E,openLabel:p=>`Show ${p.title}`})})]})}function ti({direction:e}){return e?t.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:e==="asc"?"Sort ascending":"Sort descending"}),e==="asc"?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})]}):t.jsxs("svg",{className:"h-4 w-4 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:"Sort"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})]})}function et({column:e,children:n,alignRight:s=!1}){return t.jsxs("button",{type:"button",className:`flex items-center gap-1.5 whitespace-nowrap text-left transition-colors hover:text-foreground [&>svg]:shrink-0${s?" ml-auto":""}`,onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:[n,t.jsx(ti,{direction:e.getIsSorted()})]})}function Qt(e,n,s){const a=is(e?.properties).filter(([i,o])=>(!n||i!=="name")&&!o["x-image"]&&o["x-table-column"]===!0);if(a.length)return a.map(([i,o])=>({field:i,label:o["x-table-label"]??qe(i.replaceAll("_"," "))}));if(!n)return[];const r=s.find(i=>Object.keys(Ee(i.metadata)).length>0);return Object.keys(Ee(r?.metadata)).filter(i=>i!=="id"&&i!=="slug"&&i!=="name"&&!xr(e?.properties?.[i])).map(i=>({field:i,label:qe(i.replaceAll("_"," "))}))}function ni(e){return e.some(n=>Object.hasOwn(Ee(n.metadata),"name"))}function si(e,n){return st(e,$t(n))}function ri(e){return`${e.entityType}:${e.lookupField}`}const ai=new Set(["stage","category","round_type","investor_type"]);function oi(e,n){const s=e.toLowerCase();return s==="mrr"||s==="arr"||s==="revenue"||s==="valuation"||s==="funding_raised"||s==="fund_size"||s.endsWith("_usd")||n.description?.toLowerCase().includes("usd")===!0}function ii(e,n){if(oi(e,n))return"currency";if(ai.has(e)||e.endsWith("_slug"))return"enum"}function ci({entities:e,owner:n,schema:s,entityTypeIcon:a,isDerived:r,measureColumns:i,linkedEntityLookups:o,hasAnyParents:l,sorting:g,onSortingChange:c,visibleColumns:y,columnChoices:m,onVisibleColumnsChange:f,page:h,pageSize:b,totalCount:j,hasMore:d,pageTitle:S,onPrevPage:N,onNextPage:E}){const w=m?.length&&f?t.jsx(Bo,{choices:m,visible:y,onChange:f}):null,p=s?.properties,v=!r||ni(e),M=x.useMemo(()=>p?Object.fromEntries(Object.entries(p).flatMap(([I,L])=>L["x-link-entity-type"]?[[I,{entityType:L["x-link-entity-type"],lookupField:L["x-link-lookup-field"]||"slug"}]]:[])):{},[p]),A=x.useMemo(()=>p?Qt({properties:p},r,[]).map(({field:L})=>[L,p[L]]).map(([L,q])=>{const U=M[L],H=U?o[ri(U)]:void 0;return{id:r?L:`meta_${L}`,accessorFn:J=>{const X=Ee(J.metadata);return ca(X[L],q.enum)},header:({column:J})=>{const X=q["x-table-label"]||q.title||q.description||qe(L.replace(/_/g," "));return r?t.jsx(et,{column:J,children:X}):X},cell:({getValue:J})=>t.jsx(jn,{value:J(),prop:q,format:ii(L,q),className:"text-muted-foreground",resolveLink:H?X=>{const fe=H[X];return fe?{label:fe.name,to:st(n,[{entity_type:fe.entity_type,slug:fe.slug}])}:void 0}:void 0})}}):[],[r,M,o,n,p]),F=x.useMemo(()=>new Set(i),[i]),z=x.useMemo(()=>!r||A.length>0?[]:Qt({properties:p},!0,e).map(({field:L})=>L).map(L=>{const q=F.has(L);return{id:L,accessorFn:U=>Ee(U.metadata)[L],header:({column:U})=>t.jsxs(et,{column:U,children:[q?L:qe(L.replace(/_/g," ")),q&&t.jsx(ht,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:U})=>t.jsx(jn,{value:U(),prop:p?.[L],className:q?"tabular-nums":"text-muted-foreground"}),meta:q?{align:"right"}:void 0}}),[r,A,e,F,p]),Q=x.useMemo(()=>{const I=s?.["x-table-relationships"];return!I||I.length===0?[]:I.map(L=>({id:`rel_${L.relationship_type}`,accessorFn:q=>q.relationships?.[L.relationship_type]??[],header:L.label,cell:({getValue:q})=>{const U=q();return!U||U.length===0?t.jsx("span",{className:"text-muted-foreground",children:"-"}):t.jsx("div",{className:"flex flex-wrap gap-1",children:U.map((H,J)=>{const X=st(n,[{entity_type:H.entity_type,slug:H.slug}]);return t.jsxs("span",{children:[t.jsx(we,{to:X,className:"text-primary hover:underline",onClick:fe=>fe.stopPropagation(),children:H.name}),J<U.length-1&&","]},H.id)})})}}))},[n,s]),G=x.useMemo(()=>l||e.some(L=>L.parent_name&&L.parent_slug&&L.parent_entity_type)?[{id:"parent",accessorFn:L=>L.parent_name,header:"Parent",cell:({row:L})=>{if(!L.original.parent_name||!L.original.parent_slug||!L.original.parent_entity_type)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const q=st(n,[{entity_type:L.original.parent_entity_type,slug:L.original.parent_slug}]);return t.jsx(we,{to:q,className:"text-primary hover:underline",children:L.original.parent_name})}}]:[],[e,l,n]),se=x.useMemo(()=>{const I=[],L=e.some(H=>(H.total_content??0)>0),q=e.some(H=>(H.active_connections??0)>0),U=e.some(H=>(H.automations_count??0)>0);return L&&I.push({accessorKey:"total_content",header:({column:H})=>t.jsx(et,{column:H,alignRight:!0,children:"Activity"}),cell:({row:H,getValue:J})=>{const X=J()??0;if(X===0)return t.jsx("span",{className:"tabular-nums",children:"0"});const fe=$t(H.original);return t.jsx(we,{to:rs(n,fe),className:"tabular-nums hover:underline",children:X})},meta:{align:"right"}}),q&&I.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:H})=>{const J=H();return J&&J>0?t.jsxs(ht,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[J," active"]}):t.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),U&&I.push({accessorKey:"automations_count",header:({column:H})=>t.jsx(et,{column:H,alignRight:!0,children:"Automations"}),cell:({getValue:H})=>t.jsx("span",{className:"tabular-nums",children:H()??0}),meta:{align:"right"}}),I},[e,n]),V=x.useMemo(()=>[{accessorKey:"name",header:({column:I})=>v?t.jsx(et,{column:I,children:"Name"}):"Name",cell:({row:I})=>{const L=Ee(I.original.metadata);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(on,{metadata:L,metadataSchema:s,name:I.original.name,typeIcon:a,className:"h-6 w-6 shrink-0"}),t.jsx("div",{className:"min-w-0",children:(()=>{const q=si(n,I.original);return t.jsx(we,{to:q,className:"block max-w-56 truncate font-medium hover:underline",title:I.original.name,children:I.original.name})})()})]})}},...G,...A,...z,...Q,...se,...r?[]:[{accessorKey:"created_at",header:({column:I})=>t.jsx(et,{column:I,children:"Created"}),cell:({getValue:I})=>t.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date(I()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[n,G,A,z,Q,se,s,a,r,v]),pe=la({data:e,columns:V,state:{sorting:g,columnVisibility:Object.fromEntries([...A,...z].flatMap(I=>I.id?[[I.id,!y||y.includes(r?I.id:I.id.replace(/^meta_/,""))]]:[]))},onSortingChange:c,getCoreRowModel:da(),manualSorting:!0,enableSortingRemoval:!1}),ge=e.length>0||h>0;return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"rounded-lg border",children:t.jsxs(ga,{className:"min-w-[48rem]",children:[t.jsx(ya,{children:pe.getHeaderGroups().map(I=>t.jsxs(Vt,{children:[I.headers.map(L=>t.jsx(Sn,{"aria-sort":L.column.getIsSorted()==="asc"?"ascending":L.column.getIsSorted()==="desc"?"descending":void 0,className:L.column.columnDef.meta?.align==="right"?"text-right":"",children:L.isPlaceholder?null:Nn(L.column.columnDef.header,L.getContext())},L.id)),w?t.jsx(Sn,{className:"w-10 pr-2 text-right",children:w}):null]},I.id))}),t.jsx(xa,{children:pe.getRowModel().rows.length?pe.getRowModel().rows.map(I=>t.jsxs(Vt,{children:[I.getVisibleCells().map(L=>t.jsx(Ut,{className:L.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:Nn(L.column.columnDef.cell,L.getContext())},L.id)),w?t.jsx(Ut,{}):null]},I.id)):t.jsx(Vt,{children:t.jsx(Ut,{colSpan:V.length+(w?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),ge&&t.jsxs("div",{className:"mt-4 flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:["Showing ",e.length," of ",j," ",S.toLowerCase()]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["Page ",h+1," of ",Math.max(1,Math.ceil(j/b))]}),t.jsx(Y,{variant:"outline",size:"sm",onClick:N,disabled:h===0,children:"Previous"}),t.jsx(Y,{variant:"outline",size:"sm",onClick:E,disabled:!d,children:"Next"})]})]})]})}function li(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function js(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function un(e){const n=e?.properties;if(!n)return null;const r=is(n).find(([,c])=>js(c)==="workflowState");if(!r)return null;const[i,o]=r,l=o["x-lobu"]?.states,g=Array.isArray(l)&&l.length>0?l:(o.enum??[]).map(c=>({value:c}));return g.length===0||g.some(c=>typeof c.value!="string")?null:{field:i,states:g.map(c=>({...c,label:c.label||br(o,c.value)||li(c.value),terminal:c.terminal??["done","complete","completed","closed","archived"].includes(c.value.toLowerCase())}))}}function di(e){const n=e?.properties;if(!n)return null;const s=Object.entries(n),a=s.find(([,o])=>js(o)==="sortRank"),r=s.find(([o])=>["rank","sort_rank","order"].includes(o)),i=a??r;return i?{field:i[0]}:null}function ui(e,{isDerived:n}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(n&&s!=="table")?s:n?"table":un(e)?"board":"table"}const Ns={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},mi={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function fi(e){const{canShowBoard:n,builtinData:s,builtInLabels:a}=e,r=["table",...n?["board"]:[]],i={table:Ns,board:mi};return r.map(o=>({id:o,label:a[o],builtInMode:o,template:i[o],data:s}))}function Xt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Lt(e,n){if(!n)return e.created_at??String(e.id);const s=Ee(e.metadata);return String(s[n.field]??e.created_at??e.id)}function hi(e,n){const s=e?Number(e):Number.NaN,a=n?Number(n):Number.NaN;return Number.isFinite(s)&&Number.isFinite(a)&&s<a?String((s+a)/2):Number.isFinite(s)?String(s+1):Number.isFinite(a)?String(a-1):String(Date.now())}function Zt(e,n){const s=Ee(e.metadata);return String(s[n]??"")}function Ss(e,n){return[...e].sort((s,a)=>Lt(s,n).localeCompare(Lt(a,n)))}function pi(e,n,s,a,r){if(!n.startsWith("card:")||!s)return null;const i=Number(n.slice(5)),o=e.find(N=>N.id===i);if(!o)return null;const l=s.startsWith("column:")?s.slice(7):Zt(e.find(N=>`card:${N.id}`===s)??o,a.field);if(!l)return null;const g=Ss(e.filter(N=>N.id!==i&&Zt(N,a.field)===l),r),c=s.startsWith("card:")?g.findIndex(N=>`card:${N.id}`===s):g.length,y=c>=0?c:g.length,m=y>0?g[y-1]:void 0,f=g[y],h=r?hi(m?Lt(m,r):void 0,f?Lt(f,r):void 0):void 0,b=Ee(o.metadata),j={[a.field]:l,...r&&h?{[r.field]:h}:{}};a.states.find(N=>N.value===l)?.terminal&&!b.completed_at&&(j.completed_at=new Date().toISOString());const S={...b,...j};return{entityId:i,changedMetadata:j,nextMetadata:S}}function Hn(e,n,s){return e.map(a=>a.id===n?{...a,metadata:s}:a)}function gi({id:e,children:n,className:s}){const{setNodeRef:a,isOver:r}=fs({id:`column:${e}`});return t.jsx("div",{ref:a,className:le("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:n})}function yi({entity:e,owner:n,statusField:s,entityTypeIcon:a,schema:r,didDragRef:i}){const o=Ee(e.metadata),{attributes:l,listeners:g,setNodeRef:c,transform:y,isDragging:m}=ja({id:`card:${e.id}`}),{setNodeRef:f,isOver:h}=fs({id:`card:${e.id}`}),b=st(n,$t(e)),j=d=>{i.current&&(d.preventDefault(),d.stopPropagation())};return t.jsx("div",{ref:d=>{c(d),f(d)},style:{transform:Na.Translate.toString(y)},className:le(kr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",m?"opacity-60":"",h?"ring-1 ring-ring":""),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.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}`,...l,...g,children:t.jsx(wr,{className:"h-4 w-4"})}),t.jsx(on,{metadata:o,metadataSchema:r,name:e.name,typeIcon:a,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(we,{to:b,className:"font-medium text-foreground hover:underline",onClick:j,children:e.name}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof o.priority=="string"&&o.priority?t.jsx(ht,{variant:"outline",className:"text-xs",children:Xt(o.priority)}):null,typeof o[s]=="string"&&o[s]?t.jsx(ht,{variant:"secondary",className:"text-xs",children:Xt(String(o[s]))}):null]})]})]})})}function xi({owner:e,entities:n,totalCount:s,schema:a,entityTypeIcon:r,onUpdate:i}){const o=x.useMemo(()=>un(a),[a]),l=x.useMemo(()=>di(a),[a]),[g,c]=x.useState(n),[y,m]=x.useState(()=>new Set),f=x.useRef(!1),h=ba(va(ka,{activationConstraint:{distance:6}})),b=x.useCallback(()=>{window.setTimeout(()=>{f.current=!1},0)},[]);x.useEffect(()=>{c(n)},[n]);const j=x.useMemo(()=>{if(!o)return new Map;const E=new Map(o.states.map(w=>[w.value,[]]));for(const w of g){const p=Zt(w,o.field),v=E.has(p)?p:o.states[0]?.value;v&&E.get(v)?.push(w)}for(const[w,p]of E)E.set(w,Ss(p,l));return E},[g,l,o]);if(!o)return null;const d=E=>{m(w=>{const p=new Set(w);return p.has(E)?p.delete(E):p.add(E),p})},S=()=>{f.current=!0},N=E=>{const w=String(E.active.id),p=E.over?String(E.over.id):null,v=pi(g,w,p,o,l);if(!v){b();return}const{entityId:M,changedMetadata:A,nextMetadata:F}=v,Q=g.find(G=>G.id===M)?.metadata;c(G=>Hn(G,M,F)),i(M,A).catch(()=>{c(G=>Hn(G,M,Q))}),b()};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Board"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",Xt(o.field),typeof s=="number"&&s>g.length?t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",g.length," of ",s," — narrow with search"]})]}):null]})]}),t.jsx(wa,{sensors:h,onDragStart:S,onDragEnd:N,children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:o.states.map(E=>{const w=j.get(E.value)??[],p=E.collapsed??E.terminal,v=p&&!y.has(E.value);return t.jsxs(gi,{id:E.value,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[E.terminal?t.jsx(vr,{className:"h-4 w-4 text-muted-foreground"}):null,t.jsx("h3",{className:"text-sm font-medium",children:E.label})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ht,{variant:"secondary",className:"text-xs",children:w.length}),p?t.jsx(Y,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>d(E.value),children:v?"Show":"Hide"}):null]})]}),v?t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[w.length," hidden ",E.label?.toLowerCase()," item",w.length===1?"":"s"]}):t.jsx("div",{className:"space-y-2",children:w.length>0?w.map(M=>t.jsx(yi,{entity:M,owner:e,statusField:o.field,entityTypeIcon:r,schema:a,didDragRef:f},M.id)):t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",E.label?.toLowerCase()," items"]})})]},E.value)})})})]})}const bi=x.memo(xi);function vi(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s),n|=0;return n.toString(36)}function Es(e,n){return{queryKey:["metric_series",e,vi(n)],queryFn:()=>Nt("metric_series",{sql:n},{slug:e}),staleTime:6e4}}function Cs(e,n){const s=!!e&&!!n,a=Es(e??"",n??"");return ns({...a,enabled:s})}Cs.queryOptions=(e,n)=>Es(e,n);function wi(e,n){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(n);return s<0?[]:e.rows.map(a=>Number(a[s])||0)}const Vn=/^[a-z][a-z0-9_]*$/;function ki(e){const n=Object.entries(e);for(const[r,i]of n){if(!Vn.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!Vn.test(i))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${i}'`)}const s=n.flatMap(([r,i])=>[`COUNT(*) FILTER (
3
- WHERE semantic_type = 'change'
4
- AND metadata->>'category' = 'lifecycle'
5
- AND metadata->>'entity_type' = '${i}'
6
- AND metadata->>'op' = 'created'
7
- ) AS ${r}_added`,`COUNT(*) FILTER (
8
- WHERE semantic_type = 'change'
9
- AND metadata->>'category' = 'lifecycle'
10
- AND metadata->>'entity_type' = '${i}'
11
- AND metadata->>'op' = 'deleted'
12
- ) AS ${r}_removed`]).join(`,
13
- `),a=n.map(([r])=>` SUM(COALESCE(b.${r}_added, 0) - COALESCE(b.${r}_removed, 0))
14
- OVER (ORDER BY d.bucket) AS ${r}`).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
- ${s}
27
- FROM events
28
- WHERE created_at > now() - interval '14 days'
29
- GROUP BY 1
30
- )
31
- SELECT d.bucket,
32
- ${a}
33
- FROM days d
34
- LEFT JOIN buckets b ON b.bucket = d.bucket
35
- ORDER BY d.bucket
36
- `}const ji={"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 Ni(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const n=Object.fromEntries(Object.entries(e.lifecycle).map(([s,a])=>[s,String(a)]));if(Object.keys(n).length>0)try{return ki(n)}catch{return null}}return typeof e.preset=="string"?ji[e.preset]??null:null}function Si({owner:e,sql:n,lifecycle:s,preset:a,column:r,chart:i,height:o,width:l,color:g,label:c,className:y}){const m=x.useMemo(()=>Ni({sql:n,lifecycle:s,preset:a}),[n,s,a]),f=typeof e=="string"&&e?e:null,{data:h}=Cs(f,m),b=String(r??""),j=x.useMemo(()=>wi(h,b),[h,b]),d=x.useMemo(()=>!h?.columns?.length||!h.rows?[]:h.rows.map((N,E)=>({label:String(N[0]??"").slice(0,10),value:j[E]??0})),[h,j]);if(!f||!m||!b)return null;const S=i==="line"?t.jsx(ua,{data:d,height:typeof o=="number"?o:void 0}):t.jsx(ma,{data:j,height:typeof o=="number"?o:void 0,width:typeof l=="number"?l:void 0,color:typeof g=="string"?g:void 0});return c==null?t.jsx("div",{className:y,children:S}):t.jsxs("div",{className:y,children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:String(c)}),S]})}function Ei({metadata:e,metadataSchema:n,name:s,typeIcon:a,initialsFallback:r,className:i}){return t.jsx(on,{metadata:e,metadataSchema:n,name:String(s??""),typeIcon:a,initialsFallback:!!r,className:i})}function Ci({entity:e,owner:n,className:s,onClick:a,children:r}){const i=e;if(!i)return t.jsx(t.Fragment,{children:r});const o=st(String(n??""),$t(i));return t.jsx(we,{to:o,className:s,onClick:a,children:r})}function _i({state:e}){return e?t.jsx(ci,{...e}):null}function Mi({state:e,onUpdate:n}){return e?t.jsx(bi,{...e,onUpdate:n}):null}const Ti={"entity-avatar":Ei,"entity-link":Ci,"entity-table":_i,"entity-board":Mi,"metric-series":Si};function Li({ownerSlug:e,typeSlug:n,title:s,shape:a}){const[r,i]=x.useState(!1),o=ot(),{visible:l,system:g,isTypesLoading:c}=jr(e),y=f=>{i(!1);const h=`/${e}/${ls(f)}`;o({to:a?`${h}/${ds}/${a}`:h})},m=f=>t.jsxs(Tr,{value:`${f.name} ${f.slug}`,onSelect:()=>y(f.slug),children:[t.jsx(Rt,{icon:f.icon,className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"flex-1 truncate",children:f.name||f.slug}),f.slug===n?t.jsx(Lr,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,f.entity_count!=null?t.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:f.entity_count.toLocaleString()}):null]},f.slug);return t.jsxs(sn,{open:r,onOpenChange:i,children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t.jsx(rn,{asChild:!0,children:t.jsxs(Y,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,t.jsx(cs,{className:"h-5 w-5 text-muted-foreground"})]})})}),t.jsx(an,{align:"start",className:"w-72 p-0",children:t.jsxs(Nr,{children:[t.jsx(Sr,{autoFocus:!0,placeholder:"Find a type…"}),t.jsxs(Er,{children:[t.jsx(Cr,{children:c?"Loading types…":"No type matches."}),l.length>0?t.jsx(vn,{heading:"Types",children:l.map(m)}):null,g.length>0?t.jsx(vn,{heading:"System",children:g.map(m)}):null]}),t.jsx(_r,{}),t.jsxs(we,{to:"/$owner/data",params:{owner:e},onClick:()=>i(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[t.jsx(Mr,{className:"h-4 w-4"}),"Schema map"]})]})})]})}function Ri(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,n])=>n.on==="entity").map(([n,s])=>({name:n,description:s.description}))}const vt={table:{label:"Table",icon:Pr},board:{label:"Board",icon:ss},graph:{label:"Graph",icon:os}},_s=(e,n)=>`lobu.record-shape:v1:${e}/${n}`,Ii=new Set(["table","board","graph"]);function $i(e,n){const s=Kn(_s(e,n));return s&&Ii.has(s)?s:void 0}function Oi(e,n,s){Yn(_s(e,n),s)}const Un=":records";function Ai({ownerSlug:e,entityTypeSlug:n,create:s,onCreateChange:a,viewKey:r,shape:i}){const{orgContext:o,hasOrgContext:l}=Fe(),g=Zn(n,o),{data:c,isLoading:y,error:m}=g;Rr(`/${e}`,o);const f=Ir(),[h,b]=x.useState({key:"",page:0}),j=us({strict:!1}),d=ot(),S=tn(),N=`/${e}/${ls(n)}`,E=!y&&c?.slug===n,{collection:w,error:p,presentation:v,preset:M,edited:A,table:F}=x.useMemo(()=>Mo(j,c?.metadata_schema,!!r),[j,c?.metadata_schema,r]),z=E?p:void 0,Q=x.useMemo(()=>$o(j,w),[j,w]),[G,se]=x.useState(!1),[V,pe]=x.useState(0),ge=w.search??"",I=w.segment,L=JSON.stringify(w),q=I?Ri(c).find(O=>O.name===I)??{name:I,description:""}:null,U=O=>void d({to:".",search:{...Ue(O),...Q},replace:!0}),H=$r(g.data),J=H?F.sort:Ao(F),X=J?.field,fe=J?.order,de=x.useMemo(()=>X?[{id:X,desc:fe==="desc"}]:[],[X,fe]),Ce=x.useCallback(O=>void d({to:".",search:{...r?Ue(j):{},...Q,$table:JSON.stringify(O)},replace:!0}),[d,r,j,Q]),ze=x.useCallback(O=>{const te=typeof O=="function"?O(de):O;te[0]&&Ce({...F,sort:{field:te[0].id,order:te[0].desc?"desc":"asc"}})},[de,Ce,F]),Te=s===!0,Ge=()=>a(!0),ke=()=>a(!1),Le=de[0]?.id,ye=de[0]?de[0].desc?"desc":"asc":void 0,Re=g.data?.metadata_schema,je=!!un(Re)&&!H,We=ui(Re,{isDerived:H}),ue=ms(o),Ke=Ht(ue.data??[],n,w),xe=(O,te=!1,Ne=Ue(j))=>{const be=!r||!ue.data||Ht(ue.data,n,O).some(pt=>pt.key===r);d({to:be?".":N,search:{...be&&r?Ne:{},...To(O,M?.key),$table:JSON.stringify(F)},replace:te})},Ie=O=>{const te=O?jt(O):{},Ne=!r||Ht(ue.data??[],n,te).some(be=>be.key===r);se(!1),pe(be=>be+1),d({to:Ne?".":N,search:O?{$preset:O.key}:{}})},{isAdmin:$e}=Jn(o.organizationId),Be=Or(o),C=$e&&!!c&&!g.isPlaceholderData,u=x.useRef(j);u.current=j;const T=async()=>{if(!M)return;const O=JSON.stringify(j),{data:te}=await g.refetch(),Ne=te?.metadata_schema,be=Ne?nn(Ne[Yt]??{}):void 0,pt=be?.presets?.find(gt=>gt.key===M.key);if(!te||!Ne||!be||!pt){es.error("This saved filter changed. Reload and try again.");return}const Dt=Lo(pt,w,F,be);await Be.mutateAsync({slug:te.slug,metadata_schema:{...Ne,[Yt]:{...be,presets:be.presets?.map(gt=>gt.key===Dt.key?Dt:gt)}}}).then(()=>!0,()=>!1)&&(await g.refetch(),JSON.stringify(u.current)===O&&Ie(Dt))},$=x.useMemo(()=>$i(e,n),[e,n]),k=Ar(ue.data??[],n,{viewKey:r,shape:i??(r?void 0:$)},We,w),_=k.kind==="builtin"?k.mode==="board"&&!je?"table":k.mode:null,W=_==="graph";x.useEffect(()=>{i&&E&&_&&Oi(e,n,_)},[i,E,_,e,n]);const B=["table",...je?["board"]:[],"graph"],R=k.kind==="view"?k.view:null,D=k.kind==="missing"?k.key:null,ie=k.kind==="inapplicable"?k:null,ce=_==="table"?50:200,Se=`${n}?${L}&sort=${JSON.stringify(F.sort)}&size=${ce}`,Oe=h.key===Se?h.page:0,Ye=x.useCallback(O=>b(te=>({key:Se,page:O(te.key===Se?te.page:0)})),[Se]),Ae=wn(n,o,{limit:ce,offset:Oe*ce,search:ge.trim()||void 0,sortBy:Le,sortOrder:ye,segment:I,filters:w.filters,enabled:E&&!r&&!z}),Je=wn(n,o,{limit:1,offset:0,parentId:null,search:ge.trim()||void 0,segment:I,filters:w.filters,enabled:E&&!r&&!z&&!H}),{data:Qe,error:Ot}=Ae,P=Ae.isLoading||Ae.isPending&&Ae.fetchStatus==="paused",ee=z||m||(r?null:Ot),ne=!!r&&ue.data===void 0&&ue.isError,K=Qe?.entities??[],re=Qe?.metadata?.has_more??!1,Z=Qe?.metadata?.total_count??0,Pe=K.length>0||ge.trim().length>0||Oe>0||!!I||!!w.filters?.length,oe=c?.name?.trim()||qe(n),he=c?.icon||void 0,ae=H,me=Re,_e=!z&&(!l||!E||(r?ue.data===void 0&&!ue.isError:P||!H&&Je.isLoading)),He=Qe?.linked_entities??{},it=Je.data?.metadata?.total_count,Xe=Z>0&&typeof it=="number"?it<Z:!1,ct=x.useMemo(()=>c?.measure_columns??[],[c?.measure_columns]),Ze=x.useCallback(O=>Ce({...F,columns:O}),[Ce,F]),lt=x.useMemo(()=>({entities:K,owner:e,schema:me,entityTypeIcon:he,isDerived:ae,measureColumns:ct,linkedEntityLookups:He,hasAnyParents:Xe,sorting:de,onSortingChange:ze,visibleColumns:F.columns,columnChoices:Qt(me,ae,K),onVisibleColumnsChange:Ze,page:Oe,pageSize:ce,totalCount:Z,hasMore:re,pageTitle:oe,onPrevPage:()=>Ye(O=>Math.max(0,O-1)),onNextPage:()=>Ye(O=>O+1)}),[K,e,me,he,ae,ct,He,Xe,de,F.columns,Ze,ze,Ye,Oe,ce,Z,re,oe]),mn=Z>K.length,fn=`showing first ${K.length} of ${Z} — narrow with search`,hn=x.useMemo(()=>({owner:e,entityType:c,entities:K,totalCount:Z,schema:me,entityTypeIcon:he}),[e,c,K,Z,me,he]),At=x.useMemo(()=>({tableState:lt,boardState:hn,owner:e,schema:me,entityType:c,entityTypeIcon:he,totalCount:Z,isTruncated:mn,truncationNotice:fn,canCreate:!ae,addLabel:`Add ${c?.name||qe(n)}`}),[lt,hn,e,me,c,he,Z,mn,fn,ae,n]),Ms=x.useMemo(()=>fi({canShowBoard:je,builtinData:At,builtInLabels:{table:vt.table.label,board:vt.board.label}}),[je,At]),pn=_?Ms.find(O=>O.id===_)??null:null,Ts=pn?.template??Ns,Ls=pn?.data??At,gn=O=>void d({to:O===Un?N:`${N}${Wr(O)}`,search:Q}),Pt=Ue(j),Rs=Sa(R?.params,Pt,O=>void d({to:".",search:{...Ue(O),...Q}})),Is=()=>xe({...w,filters:[],segment:void 0},!1,Ea(R?.params,Pt)),yn=`Moved on ${c?.name||c?.slug||n} board`,xn=x.useMemo(()=>(O,te)=>f.mutateAsync({entityId:O,metadata:te,field_note:yn}),[f,yn]),$s=x.useMemo(()=>({updateEntity:xn,openCreate:()=>a(!0)}),[xn,a]),bn=O=>S?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:le("size-8 text-muted-foreground hover:text-foreground",O),"aria-label":"Edit type",title:"Edit type",onClick:()=>S.open({href:zr(e,n),title:oe}),children:t.jsx(Fr,{className:"h-4 w-4"})}):null;return t.jsxs("div",{className:"@container space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Li,{ownerSlug:e,typeSlug:n,title:oe,shape:r?null:_}),bn(Te||!E?"":"hidden @lg:inline-flex")]}),t.jsxs("div",{children:[Te?t.jsx("div",{className:"max-w-3xl",children:t.jsx(Eo,{onClose:ke,entityTypeSlug:n,orgContext:o})}):null,!Te&&E&&t.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${oe} views`,children:[bn("-mr-1 @lg:hidden"),!r&&B.length>1&&t.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:B.map(O=>{const te=vt[O].icon,Ne=_===O;return t.jsx(Y,{type:"button",variant:"ghost",size:"sm","aria-pressed":Ne,title:vt[O].label,"data-testid":`shape-${O}`,className:le("h-7 px-2",Ne&&"bg-accent text-accent-foreground"),onClick:()=>void d({to:`${N}/${ds}/${O}`,search:Q,replace:!0}),children:t.jsx(te,{className:"h-4 w-4"})},O)})}),r&&t.jsx(Y,{variant:"ghost",onClick:()=>gn(Un),children:"Records"}),!!v.presets?.length&&t.jsxs(sn,{open:G,onOpenChange:se,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Y,{variant:"outline",className:le("gap-2",A&&"border-dashed border-primary"),"data-edited":A||void 0,title:"Choose saved filter",children:[M?.label??(w.filters?.length||w.search?"Custom filter":"All records"),A?t.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,t.jsx(cs,{className:"h-4 w-4 text-muted-foreground"})]})}),t.jsxs(an,{align:"start",className:"w-60 p-1",children:[t.jsx(Y,{variant:M?"ghost":"secondary",className:"w-full justify-start",onClick:()=>Ie(),children:"All records"}),v.presets.map(O=>t.jsx(Y,{variant:M?.key===O.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>Ie(O),children:O.label},O.key))]})]}),M&&A?t.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>Ie(M),children:"Reset"}),C?t.jsx(Y,{size:"sm",disabled:Be.isPending,onClick:()=>void T(),children:Be.isPending?"Saving…":"Save"}):null]}):null,!z&&t.jsx(Ho,{collection:w,schema:me,label:oe,org:o??"",facetQuery:v.facetQuery,onChange:xe,viewFilters:Rs,onClearAll:Is,segmentChip:q?{id:"segment",label:"Segment",op:"is",value:qe(q.name),title:q.description||void 0,editor:q.description?{kind:"custom",render:()=>t.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:q.description})}:void 0,onRemove:()=>xe({...w,segment:void 0})}:void 0},`filters:${n}:${V}`),Ke.map(O=>t.jsx(Y,{"data-testid":`tab-${O.key}`,variant:r===O.key?"secondary":"ghost","aria-pressed":r===O.key,onClick:()=>gn(O.key),children:O.name},O.key)),t.jsx(Fo,{label:oe,search:w.search,onSearch:(O,te)=>xe({...w,search:O},te),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${n}:${V}`),!ae&&!r?t.jsxs(Y,{size:"sm","aria-label":`Add ${oe||"entity"}`,onClick:()=>Ge(),children:[t.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add"]}):null]}),Te?null:_e?W?t.jsx(cn,{label:`Loading ${oe} graph`}):t.jsx(Pi,{}):ee?t.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[ee.message||`Failed to load ${oe.toLowerCase()}.`,z&&t.jsx(Y,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>xe({}),children:"Clear filters"})]}):ne?t.jsx(hs,{onRetry:()=>void ue.refetch()}):ie?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[t.jsxs("h2",{className:"text-lg font-semibold",children:["“",ie.view.name,"” doesn’t apply to the current filters"]}),t.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(ie.when).map(([O,te])=>`${O} is ${te===null?"not supplied":String(te)}`).join(" and "),"."]}),t.jsx(we,{to:N,search:Q,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${oe}`})]}):D?t.jsx(ps,{viewKey:D,backTo:N,backLabel:`Back to ${oe}`}):R?t.jsx(gs,{orgSlug:e,viewKey:R.key,scope:{type:n,collection:w},params:Pt,onParamsChange:U,contentHash:R.content_hash,title:R.name,minHeight:320}):W&&Pe?t.jsx(ei,{ownerSlug:e,typeSlug:n,sourceBacked:H,records:K.map(O=>({...O,id:O.id??JSON.stringify([O.entity_type,O.slug])})),hasMore:re}):Pe?t.jsx(fa,{template:Ts,data:Ls,actions:$s,components:Ti}):t.jsx(as,{icon:Dr,iconElement:t.jsx(Rt,{icon:c?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${oe.toLowerCase()} yet`,description:ae?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${c?.name?.toLowerCase()||"entity"}.`,actionLabel:ae?void 0:`Add ${c?.name||"Entity"}`,onAction:ae?void 0:()=>Ge()})]})]})}function Pi(){return t.jsxs("div",{className:"space-y-4","aria-label":"Loading entities",role:"status",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(ve,{className:"h-9 max-w-sm flex-1"}),t.jsx(ve,{className:"h-9 w-28"})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[t.jsx("div",{className:"border-b px-4 py-3",children:t.jsx(ve,{className:"h-3 w-1/3"})}),t.jsx("div",{className:"divide-y",children:Array.from({length:5}).map((e,n)=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[t.jsx(ve,{className:"h-3 flex-1"}),t.jsx(ve,{className:"h-3 w-16 shrink-0"})]},n))})]})]})}function Di({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){const o=ot(),{orgContext:l}=Fe(),g=us({strict:!1}),c=n?Br(n):void 0,y=c==="$member",m=()=>{o({to:"/$owner/data",params:{owner:e},search:{}})},f=b=>{if(!c)return;const j=Qn(e,c);o({to:j.to,params:j.params,search:b?{create:!0}:{},replace:!0})},h=a?t.jsx("div",{className:"mx-auto w-full max-w-3xl",children:t.jsx(_a,{entityType:null,orgContext:l,onClose:m})}):c?t.jsx(Ai,{ownerSlug:e,entityTypeSlug:c,create:s,onCreateChange:f,viewKey:r,shape:i}):t.jsx(Fi,{ownerSlug:e,viewKey:r,search:g});return t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:y?t.jsx(Ma,{children:h}):h})}function Fi({ownerSlug:e,viewKey:n,search:s}){const a=ot(),{orgContext:r}=Fe(),{data:i,isError:o,refetch:l}=ms(r),g=Hr(i??[],n),c=Vr(),y=Ur(i??[]);return n&&i===void 0?o?t.jsx(hs,{onRetry:()=>void l()}):null:g.kind==="missing"?t.jsx(ps,{viewKey:g.key,backTo:`/${e}/data`,backLabel:"Back to Memory"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[c&&y.length>0?t.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap gap-1",children:[t.jsx(we,{to:"/$owner/data",params:{owner:e},search:{},activeOptions:{exact:!0},"aria-current":n?void 0:"page",className:qn(!n),children:"Overview"}),y.map(m=>t.jsx(we,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:m.key},search:{},activeOptions:{exact:!0},"aria-current":n===m.key?"page":void 0,className:qn(n===m.key),children:m.name},m.key))]}):null,c&&o?t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Couldn’t load views."," ",t.jsx("button",{type:"button",onClick:()=>void l(),className:"underline underline-offset-4",children:"Retry"})]}):null,g.kind==="view"?t.jsxs(t.Fragment,{children:[t.jsx(Ca,{decls:g.view.params,params:Ue(s),onParamsChange:m=>void a({to:".",search:m})}),t.jsx(gs,{orgSlug:e,viewKey:g.view.key,scope:{},params:Ue(s),onParamsChange:m=>void a({to:".",search:m,replace:!0}),contentHash:g.view.content_hash,title:g.view.name,minHeight:400})]}):t.jsx(So,{ownerSlug:e})]})}const qn=e=>le("inline-flex min-h-10 max-w-full items-center rounded-md px-3 text-sm font-medium break-words focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",e?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground");function rc({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){return t.jsxs("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[t.jsx(Gr,{}),t.jsx(qr,{owner:e,children:o=>t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:t.jsx(Di,{ownerSlug:o.ownerSlug,typeScope:n,create:s,createType:a,viewKey:r,shape:i})})})]})}export{rc as M};
74
- //# sourceMappingURL=memory-browse-page-CfDmjhDl.js.map
@@ -1,2 +0,0 @@
1
- import{c as f}from"./cronstrue-CKwjNYgj.js";import{g0 as d}from"./index-4gCDI7m4.js";function m(e){try{return f.toString(e.trim(),{throwExceptionOnParseError:!0})}catch{return`On schedule ${e.trim()}`}}function _(e,t){return t.get(e)??e}function k(e){return d(e.replace(/^\$/,""))}function h(e,t){const n=t?.display_name?.trim();return n&&t?.external_tenant_id===e?n:`#${e}`}function v(e,t){if(!e||typeof e!="object"||Array.isArray(e))return"";const n=e;return typeof n.repository=="string"?` in ${n.repository}`:typeof n.channel_id=="string"?` in ${h(n.channel_id,t)}`:typeof n.resource_ref=="string"?` for ${n.resource_ref}`:""}function $(e){return Array.isArray(e.triggers)?e.triggers.filter(t=>!!t&&typeof t=="object"):[]}function A(e,t,n){if(e.kind==="schedule"&&typeof e.cron=="string")return m(e.cron);if(e.kind==="event"&&e.source!=="workspace"&&typeof e.connector_key=="string"){const r=Array.isArray(e.event_types)?e.event_types.filter(u=>typeof u=="string"):[],o=r.length>0?r.join(" or "):"an event",i=typeof e.connection_id=="number"?n.get(e.connection_id):void 0;return`${_(e.connector_key,t)} sends ${o}${v(e.match,i)}`}if(e.kind==="event"&&e.source==="workspace"){const r=Array.isArray(e.event_types)?e.event_types.filter(u=>typeof u=="string"):[],o=r.length>0?r.join(" or "):"an event",i=typeof e.entity_type=="string"?` on ${k(e.entity_type)}`:"";return`another Automation writes ${o}${i}`}return null}function T(e){return e.health==="degraded"?"error":"enabled"}function w(e,t=new Map,n=new Map){const r=$(e),o=e.name?.trim()||"Untitled automation",i=r.some(s=>s.kind==="event"),u=r.some(s=>s.kind==="schedule"),p=i?"event":u?"schedule":"manual",c=r.map(s=>A(s,t,n)).filter(s=>!!s);let l="When started manually";c.length===1?l=`When ${c[0]}`:c.length>1&&(l=`When ${c[0]}${c.slice(1).map(s=>`, or when ${s}`).join("")}`);const y=r.some(s=>s.kind==="event"&&s.output==="reply_to_source")?"source":"silent";return{key:`automation:${e.automation_id}`,kind:p,when:l,does:o,output:{destination:y},state:T(e),sortTime:e.next_run_at?Date.parse(e.next_run_at):null,automation:e}}const a={event:0,schedule:1,manual:2};function S(e,t=new Map,n=new Map){return e.map(r=>w(r,t,n)).sort((r,o)=>r.state!==o.state?r.state==="enabled"?-1:1:a[r.kind]!==a[o.kind]?a[r.kind]-a[o.kind]:r.sortTime!==o.sortTime?r.sortTime===null?1:o.sortTime===null?-1:r.sortTime-o.sortTime:r.when.localeCompare(o.when)||r.key.localeCompare(o.key))}const j={kind:"all",output:"any",state:"any"};function E(e,t){return e.filter(n=>(t.kind==="all"||n.kind===t.kind)&&(t.output==="any"||(t.output==="reply"?n.output.destination==="source":n.output.destination==="silent"))&&(t.state==="any"||(t.state==="active"?n.state==="enabled":n.state==="error")))}function L(e){const t=Array.isArray(e.triggers)?e.triggers:[];for(const n of t)if(n&&typeof n=="object"&&n.kind==="event"&&n.source!=="workspace"&&typeof n.connector_key=="string")return n.connector_key;return null}export{j as D,w as d,L as e,E as f,S as m};
2
- //# sourceMappingURL=model-Dn40BUzs.js.map
@@ -1,2 +0,0 @@
1
- import{aE as g,aF as N,j as s,eI as y,cN as m,du as p,h as f,B as w,eK as b}from"./index-4gCDI7m4.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=[]}=g(),{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(),v=_(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)),v?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-88PJnyTq.js.map
@@ -1,2 +0,0 @@
1
- import{iI as e,j as r}from"./index-4gCDI7m4.js";import{a as m}from"./agents-workbench-C8bTa2rv.js";import"./agent-editor-form-DfMTSIvj.js";import"./model-selector-88PJnyTq.js";import"./proposal-review-shell-B4CSiyLB.js";import"./runs-BPtQBTRN.js";function g(){const{owner:o,agentId:t}=e.useParams();return r.jsx(m,{owner:o,agentId:t,tab:"models"})}export{g as component};
2
- //# sourceMappingURL=models-BBK_n2RP.js.map
@@ -1,2 +0,0 @@
1
- import{v as A,au as C,aI as S,aC as k,bd as T,r as g,j as e,gl as L,L as b,gm as B,bm as I,S as p,gU as w,aA as R}from"./index-4gCDI7m4.js";import{C as $,A as O}from"./create-automation-form-DmCOFbRT.js";import"./cronstrue-CKwjNYgj.js";import"./entity-options-BSW_EG0W.js";import"./connection-label-BobuYiAG.js";import"./use-automations-BHoV0dLs.js";import"./model-selector-88PJnyTq.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-rX0t1g5C.js";import"./index-wHFQv1aT.js";import"./use-mention-search-C3rWLuKm.js";function P(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function D({prefillAgentId:n,onCancel:t,initialTriggers:l,conversationSetup:x}){const{org:o}=C(),[c,h]=g.useState({ready:!1,triggers:[]}),[u,v]=g.useState(),a=g.useCallback(s=>{h(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx($,{startFromScratch:!!l,organizationId:o?.id??"",prefillAgentId:n,conversationSetup:x,onClose:t,onPrefillTriggers:s=>v(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!c.ready,createFields:{triggers:c.triggers},triggerFields:e.jsx(O,{organizationId:o?.id??null,initialTriggers:r,onChange:a},JSON.stringify(r??"new"))})}function E({owner:n,prefilled:t}){const l=A(),{org:x}=C(),o=S(x?.id??null,{status:"active",limit:500}),c=k(x?.id??null),{data:h=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),v=u&&(o.isLoading||c.isLoading),a=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const d=o.data??[],N=t.connection?d.find(i=>i.slug===t.connection):(()=>{const i=d.filter(f=>f.connector_key!==t.platform?!1:t.resource?!0:f.facets.chat&&(f.external_tenant_id??"")===(t.team??""));return i.length===1?i[0]:void 0})();if(t.connection&&!N)return;const j=t.events?.split(",").map(i=>i.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...N?{connection_id:N.id}:{},event_types:j.length>0?j:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:P(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),r=c.data?.find(d=>d.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&a&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,a,t?.listen]),y=()=>void l({to:"/$owner/automations",params:{owner:n}}),_=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!o.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[e.jsx(L,{crumbs:[e.jsx(b,{to:"/$owner/automations",params:{owner:n},className:B,children:"Automations"},"automations")],current:"New automation"}),e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx(I,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_}),m&&!t?.agent?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.length===0?"This workspace has no agents yet. ":"Choose the agent that answers here, or ",e.jsx(b,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:h.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,v?e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"h-10 w-full"}),e.jsx(p,{className:"h-32 w-full"})]}):u&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(D,{prefillAgentId:t?.agent,onCancel:y,initialTriggers:a,conversationSetup:m})]})})}function X(){const{owner:n}=w.useParams(),t=w.useSearch();return e.jsx(R,{owner:n,children:()=>e.jsx(E,{owner:n,prefilled:t})})}export{X as component};
2
- //# sourceMappingURL=new-4ruWHLR5.js.map
@@ -1,2 +0,0 @@
1
- import{h8 as r,v as p,a5 as x,o as h,au as b,bd as f,j as e,aL as w,gk as A,b5 as L,gl as j,L as C,gm as S,fg as N,b4 as k,c0 as y}from"./index-4gCDI7m4.js";import{A as E}from"./agent-editor-form-DfMTSIvj.js";import"./model-selector-88PJnyTq.js";const v="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function _(){const{owner:a}=r.useParams(),t=r.useSearch(),o=p(),i=x(),{isAuthenticated:c}=h(),{isMember:g,isLoading:m}=b(),n=c&&g,{data:u=[],isLoading:d}=f({enabled:n});return e.jsx("div",{className:v,children:e.jsxs(w,{className:"flex flex-1 flex-col gap-6",children:[e.jsx(A,{breadcrumb:e.jsx(j,{crumbs:[e.jsx(C,{to:"/$owner/agents",params:{owner:a},className:S,children:"Agents"},"agents")]}),icon:e.jsx(L.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&d?e.jsx(N,{rows:1}):n?e.jsx(E,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const l=["agents",a];if(await i.refetchQueries({queryKey:l,exact:!0}),t.platform&&t.listen){await o({to:"/$owner/automations/new",params:{owner:a},search:{...t,agent:s}});return}await o({to:"/$owner/agents/$agentId/settings",params:{owner:a,agentId:s},search:{run_id:void 0}})}}):e.jsx(k,{icon:y,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{_ as component};
2
- //# sourceMappingURL=new-gMD1PHTL.js.map
@@ -1,2 +0,0 @@
1
- import{r as m,j as e,V as F,W as O,h as I,Y as U,B as z,Z as H,$ as D,K as B,a0 as T}from"./index-4gCDI7m4.js";function P(t){if(!t)return null;try{const s=new URL(t);return s.protocol==="https:"&&s.hostname?s.toString():null}catch{return null}}function W(t){const s=P(t);if(!s)return null;const n=new URL(s).hostname.toLowerCase();return n.length>0&&n.length<=253&&/^[a-z0-9.-]+$/.test(n)?n:null}function V({clientName:t,logoUri:s=null,clientUri:n=null}){const[l,h]=m.useState(!1),[j,x]=m.useState(!1),f=l?null:P(s),g=j?null:W(n)??W(s);return f?e.jsx("img",{src:f,alt:"",referrerPolicy:"no-referrer",onError:()=>h(!0),className:"h-10 w-10 shrink-0 rounded-md object-contain"}):g?e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(g)}&sz=64`,alt:"",referrerPolicy:"no-referrer",onError:()=>x(!0),className:"h-10 w-10 shrink-0 rounded-md bg-secondary object-contain"}):e.jsx("div",{"aria-hidden":"true",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-secondary text-base font-bold text-secondary-foreground",children:(t??"?").charAt(0).toUpperCase()||"?"})}const _=["mcp:read","mcp:write","mcp:admin"],q=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],L={read:0,write:1,admin:2};function M(t){return t.includes("mcp:admin")?"admin":t.includes("mcp:write")?"write":t.includes("mcp:read")?"read":null}function G(t,s){const n=t.filter(h=>!_.includes(h));if(!s)return n;const l=M(t);return!l||L[s]>L[l]?n:["mcp:read",...s==="write"||s==="admin"?["mcp:write"]:[],...s==="admin"?["mcp:admin"]:[],...n]}function J({idPrefix:t,clientName:s,requestedScopes:n,accessLevel:l,onAccessLevelChange:h,sensitiveScopesAcknowledged:j=!1,onSensitiveScopesAcknowledgedChange:x,disabled:f=!1,resource:g=null,logoUri:b=null,clientUri:k=null}){const i=M(n),N=n.includes("profile:read"),o=n.includes("device_worker:run"),w=n.includes("connections:token"),d=o||w,v=n.filter(r=>!_.includes(r)&&r!=="profile:read"&&r!=="device_worker:run"&&r!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsx("section",{"aria-label":"Application",className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{clientName:s,logoUri:b,clientUri:k}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s||"Unnamed application"}),g&&e.jsxs("div",{className:"mt-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5",children:[e.jsx("p",{children:"Requesting access to"}),n.length>0&&e.jsx("p",{className:"flex flex-wrap gap-1.5",children:n.map(r=>e.jsx("span",{className:"px-1 py-0.5 font-mono text-[11px] text-foreground",children:r},r))})]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:e.jsxs("p",{children:["on"," ",e.jsx("code",{className:"break-all rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:g})]})})]})]})]})}),N&&e.jsxs("section",{"aria-labelledby":`${t}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${t}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(F,{variant:"secondary",children:"Always included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to. This is separate from the workspace data access below."})]})]}),i&&e.jsxs("fieldset",{className:"space-y-2",disabled:f,children:[e.jsx("legend",{className:"text-sm font-medium",children:"What should this client have access to?"}),e.jsx("div",{className:"space-y-2",children:q.filter(r=>L[r.value]<=L[i]).map(r=>{const y=`${t}-access-${r.value}`,c=l===r.value;return e.jsxs("label",{htmlFor:y,className:I("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",c&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:y,type:"radio",name:`${t}-access-level`,value:r.value,checked:c,onChange:()=>h(r.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[r.title,r.risk==="high"&&e.jsx(O,{"aria-label":"High risk",className:"h-3.5 w-3.5 shrink-0 text-destructive",children:e.jsx("title",{children:"High risk"})})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:r.description})]})]},r.value)})})]}),v.length>0&&e.jsxs("section",{"aria-labelledby":`${t}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${t}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:v.map(r=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:r},r))})]}),d&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),w&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(U,{id:`${t}-sensitive-acknowledgement`,checked:j,disabled:f,onCheckedChange:r=>x?.(r===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${t}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function K(t){const s=B(t);return s.kind==="cross-host"?s.href:s.to}function Q({idPrefix:t,orgList:s,selectedOrgIds:n,onWorkspaceAccessChange:l,onSelectedOrgChange:h,orgsLoading:j,orgsError:x,onRetry:f,disabled:g=!1,deviceHomeOrgId:b=null,allowMultiple:k}){const i=`${t}-workspace-access-legend`,N=`${t}-workspace-search`,[o,w]=m.useState(""),d=n.length===s.length;if(j)return e.jsxs("section",{"aria-labelledby":i,className:"space-y-2",children:[e.jsx("p",{id:i,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]});if(x)return e.jsxs("section",{"aria-labelledby":i,className:"space-y-2",children:[e.jsx("p",{id:i,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(z,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:f,children:"Retry"})]})]});if(s.length===0)return e.jsxs("section",{"aria-labelledby":i,className:"space-y-2",children:[e.jsx("p",{id:i,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]});const v=()=>{if(d)for(const c of n)h(c,!1);else l("all_current")},r=o.trim().toLowerCase(),y=r?s.filter(c=>c.name.toLowerCase().includes(r)||c.slug.toLowerCase().includes(r)):s;return e.jsxs("fieldset",{className:"min-w-0 space-y-3",disabled:g,children:[e.jsx("legend",{id:i,className:"sr-only",children:"Workspace access"}),e.jsxs("p",{className:"text-sm font-medium",children:["Workspace access"," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",n.length," selected"]})]}),b&&e.jsx("p",{className:"text-sm text-muted-foreground",children:k?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden rounded-md border bg-card",children:[e.jsxs("div",{className:"border-b bg-card p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),k&&e.jsx("button",{type:"button",onClick:v,className:"shrink-0 cursor-pointer bg-none p-0 text-xs font-semibold text-foreground underline underline-offset-4",children:d?"Clear all":`Select all ${s.length}`})]}),e.jsx("p",{className:"mt-0.5 whitespace-nowrap text-sm text-muted-foreground",children:k?"Choose workspaces for this app.":"Choose one workspace this application can access."}),e.jsx("input",{id:N,type:"search",value:o,onChange:c=>w(c.target.value),placeholder:"Filter workspaces…","aria-label":"Filter workspaces",className:"mt-2 flex h-9 w-full rounded-md border border-input bg-background px-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring"})]}),e.jsxs("div",{className:"max-h-80 space-y-1.5 overflow-auto p-2",children:[y.map(c=>{const C=`${t}-workspace-${c.id}`,A=c.id===b,R=n.includes(c.id);return e.jsxs("div",{className:I("flex items-center gap-2.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted/60",R&&"bg-primary/5 hover:bg-primary/5"),children:[e.jsx(U,{id:C,checked:R,disabled:g||A||b!==null&&!k,onCheckedChange:S=>h(c.id,S===!0)}),e.jsx("label",{htmlFor:C,className:"min-w-0 flex-1 cursor-pointer truncate text-sm font-medium text-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 truncate",children:c.name}),c.isPersonal&&e.jsx(H,{"aria-label":"Personal workspace",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",children:e.jsx("title",{children:"Personal workspace"})}),A&&e.jsx(F,{variant:"secondary",className:"shrink-0",children:"Device workspace"})]})}),e.jsx("a",{href:K(c.slug),target:"_blank",rel:"noopener noreferrer",onClick:S=>S.stopPropagation(),"aria-label":`Open ${c.name} workspace`,title:`Open ${c.name} workspace`,className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(D,{className:"h-3.5 w-3.5"})})]},c.id)}),y.length===0&&e.jsx("p",{className:"px-2 py-3 text-[13px] text-muted-foreground",children:"No workspaces match."})]}),e.jsx("div",{className:"border-t bg-card px-3 py-2 text-xs text-muted-foreground",children:e.jsxs("p",{"aria-live":"polite",children:[n.length," of ",s.length," workspaces selected."]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),n.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function X(t,s){m.useEffect(()=>{if(s||t)return;const n=new URL("/auth/login",window.location.origin);n.searchParams.set("callbackUrl",window.location.href),window.location.href=n.toString()},[t,s])}function Y(t,s){return t.length===s.length&&t.every((n,l)=>n===s[l])}function ee(t={}){const{requireDeviceHome:s=!1,deviceHomeOrgId:n=null,allowMultiple:l=!0}=t,{data:h,error:j,isPending:x,refetch:f}=T(),[g,b]=m.useState("selected"),[k,i]=m.useState([]),N=m.useRef(!1),o=m.useMemo(()=>h?h.filter(a=>a.is_member).map(a=>({id:a.id,name:a.name,slug:a.slug,isPersonal:a.is_personal===!0})):[],[h]),w=o.find(a=>a.isPersonal)?.id??null,d=s?n&&o.some(a=>a.id===n)?n:w:null,v=m.useRef(o);v.current=o;const r=j instanceof Error?j.message:j?"Unable to load workspaces":null;m.useEffect(()=>{if(x||r)return;const a=o.map(u=>u.id),p=new Set(a);i(u=>{const $=N.current?u.filter(E=>p.has(E)):[w??a[0]].filter(E=>!!E);return N.current=!0,Y(u,$)?u:$})},[o,r,x,w]);const y=m.useCallback(a=>{if(a==="all_current"){if(!l)return;i(v.current.map(p=>p.id))}b(a)},[l]),c=m.useCallback((a,p)=>{v.current.some(u=>u.id===a)&&(s&&(a===d||!l)||(b("selected"),i(u=>p?l?u.includes(a)?u:[...u,a]:[a]:u.filter($=>$!==a))))},[l,d,s]),C=m.useMemo(()=>{if(s&&d&&!l)return[d];const a=new Set(k);return s&&d&&a.add(d),o.filter(p=>a.has(p.id)).map(p=>p.id)},[l,k,d,o,s]),A=m.useCallback(()=>{const a=v.current,p=a.find(u=>u.isPersonal)?.id??a[0]?.id;N.current=a.length>0,b("selected"),i(p?[p]:[])},[]),R=!x&&!r&&o.length>0&&C.length>0&&(l||C.length===1)&&(!s||d!==null&&C.includes(d)),S=m.useCallback(()=>{f()},[f]);return{orgList:o,workspaceAccess:g,setWorkspaceAccess:y,selectedOrgIds:C,toggleSelectedOrgId:c,resetWorkspaceSelection:A,personalOrgId:w,deviceHomeOrgId:d,orgsLoading:x,orgsError:r,retryOrgs:S,workspaceSelectionReady:R}}function se(t){if(!t)return null;try{return new URL(t).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{J as A,Q as W,M as a,X as b,se as g,G as s,ee as u};
2
- //# sourceMappingURL=oauth-workspace-access-D9BNmyMY.js.map