@lobu/runtime-server 24.11.0 → 24.12.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 (275) hide show
  1. package/dist/catalogs/connectors.json +1113 -107
  2. package/dist/catalogs/skills.json +2 -2
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +2 -2
  5. package/dist/connectors/chat-transport-actions.ts +50 -0
  6. package/dist/connectors/discord.ts +2 -0
  7. package/dist/connectors/gchat.ts +2 -0
  8. package/dist/connectors/github.ts +4 -4
  9. package/dist/connectors/google_drive.ts +20 -0
  10. package/dist/connectors/google_gmail.ts +49 -8
  11. package/dist/connectors/herdr.ts +1 -1
  12. package/dist/connectors/imessage.ts +1 -0
  13. package/dist/connectors/linkedin-browser-script.ts +11 -0
  14. package/dist/connectors/linkedin-draft-page.js +24 -8
  15. package/dist/connectors/linkedin-inbox-adapter.js +209 -19
  16. package/dist/connectors/linkedin-inbox.ts +152 -4
  17. package/dist/connectors/linkedin-network.ts +788 -0
  18. package/dist/connectors/linkedin-search.ts +1284 -0
  19. package/dist/connectors/linkedin.ts +892 -27
  20. package/dist/connectors/microsoft_outlook.ts +57 -19
  21. package/dist/connectors/rss.ts +179 -33
  22. package/dist/connectors/slack.ts +2 -0
  23. package/dist/connectors/source-file-attachment.ts +46 -0
  24. package/dist/connectors/teams.ts +2 -0
  25. package/dist/connectors/telegram.ts +2 -0
  26. package/dist/connectors/tiktok_web.ts +1 -1
  27. package/dist/connectors/whatsapp.ts +2 -0
  28. package/dist/connectors/whatsapp_web.ts +3 -3
  29. package/dist/connectors/x-dm-adapter.js +8 -10
  30. package/dist/connectors/x.ts +8 -9
  31. package/dist/db/migrations/20261115040000_account_two_factor.sql +20 -0
  32. package/dist/db/migrations/20261115120000_events_unbound_tool_audit_without_bridge.sql +40 -0
  33. package/dist/db/migrations/20261115120001_events_unbound_tool_audit_validate.sql +19 -0
  34. package/dist/db/migrations/20261115120002_drop_events_linked_org_ids.sql +119 -0
  35. package/dist/db/migrations/20261115130000_entities_retired_type_idx.sql +34 -0
  36. package/dist/db/migrations/20261115140000_entity_identities_personal_owner_idx.sql +34 -0
  37. package/dist/db/migrations/20261117090000_write_policy_kind_note.sql +65 -0
  38. package/dist/db/migrations/20261117120000_app_policy_principal.sql +48 -0
  39. package/dist/db/migrations/20261117170000_personal_org_connector_auto_policy_backfill.sql +57 -0
  40. package/dist/db/migrations/20261117190000_org_slug_reserved_paths.sql +29 -0
  41. package/dist/db/migrations/20261118120000_workspace_view_top_level_paths.sql +69 -0
  42. package/dist/db/migrations/preconditions/20261117190000_org_slug_reserved_paths.sql +14 -0
  43. package/dist/db/migrations/preconditions/20261118120000_workspace_view_top_level_paths.sql +21 -0
  44. package/dist/dependencies.bun.lock +51 -46
  45. package/dist/guest.bundle.js +11 -2
  46. package/dist/owletto/dist/assets/_-BC9j6MkU.js +2 -0
  47. package/dist/owletto/dist/assets/_-Z1u1cIe6.js +3 -0
  48. package/dist/owletto/dist/assets/_agentId-B-TFq9TP.js +2 -0
  49. package/dist/owletto/dist/assets/{_agentId-CGScf8z_.js → _agentId-BGatZWsd.js} +2 -2
  50. package/dist/owletto/dist/assets/_automationId-CMUrWPvr.js +2 -0
  51. package/dist/owletto/dist/assets/_connectorKey._connectionId-CUoAoP0_.js +2 -0
  52. package/dist/owletto/dist/assets/_connectorKey.index-Bs49QGGH.js +2 -0
  53. package/dist/owletto/dist/assets/_conversationId-CszP1den.js +2 -0
  54. package/dist/owletto/dist/assets/_eventId-C0AZUBnD.js +2 -0
  55. package/dist/owletto/dist/assets/_owner-B4ydA75k.js +3 -0
  56. package/dist/owletto/dist/assets/_shape-C4-ikE70.js +2 -0
  57. package/dist/owletto/dist/assets/_slug-DE5J3KVu.js +2 -0
  58. package/dist/owletto/dist/assets/_viewKey-Dkcd8JQC.js +2 -0
  59. package/dist/owletto/dist/assets/{accept-invitation-BKeIzZXE.js → accept-invitation-DmrQQu_W.js} +2 -2
  60. package/dist/owletto/dist/assets/{activity-route-location-sLvKaSCa.js → activity-route-location-Bec6fW-t.js} +2 -2
  61. package/dist/owletto/dist/assets/activity-route-view-DCSNBKZU.js +2 -0
  62. package/dist/owletto/dist/assets/agent-client-connections-xvabPpi6.js +4 -0
  63. package/dist/owletto/dist/assets/agent-connect-pages-DDPtkcmq.js +6 -0
  64. package/dist/owletto/dist/assets/{agent-editor-form-DVFyyMyd.js → agent-editor-form-BrhQbHZg.js} +2 -2
  65. package/dist/owletto/dist/assets/{agent-loading-shells-BLNHIy-r.js → agent-loading-shells-D3y98xuO.js} +2 -2
  66. package/dist/owletto/dist/assets/{agent-permissions-matrix-UBKRR5vs.js → agent-permissions-matrix-jQJjSa9i.js} +2 -2
  67. package/dist/owletto/dist/assets/{agent-skill-context-fqedKd0D.js → agent-skill-context-CCcknBYE.js} +2 -2
  68. package/dist/owletto/dist/assets/{agent-subpage-shell-BUCoY2Nf.js → agent-subpage-shell-6f_53cSf.js} +2 -2
  69. package/dist/owletto/dist/assets/agent-thread-v_lSSnJi.js +6 -0
  70. package/dist/owletto/dist/assets/{app._appId-ByIypCL9.js → app._appId-CKWzZ2ic.js} +2 -2
  71. package/dist/owletto/dist/assets/assist-composer-Q9ZJjAta.js +2 -0
  72. package/dist/owletto/dist/assets/automation-run-now-Dl0MKx3N.js +2 -0
  73. package/dist/owletto/dist/assets/{callback-Pz5uS-k7.js → callback-Bentv78L.js} +2 -2
  74. package/dist/owletto/dist/assets/{card-CAPpY9P5.js → card-C4oPCVh6.js} +2 -2
  75. package/dist/owletto/dist/assets/{claim-DgWWK0KI.js → claim-B3C4qIi2.js} +2 -2
  76. package/dist/owletto/dist/assets/client-activity-scopes-DqaFEyir.js +2 -0
  77. package/dist/owletto/dist/assets/{client-rows-Dd5YV8vn.js → client-rows-rse9thnk.js} +2 -2
  78. package/dist/owletto/dist/assets/{clients-Bf7ZgGro.js → clients-BhPMbxHi.js} +2 -2
  79. package/dist/owletto/dist/assets/{code-editor-z1Sy_hiX.js → code-editor-CTdKUDPY.js} +2 -2
  80. package/dist/owletto/dist/assets/connect-D8o7HBlo.js +2 -0
  81. package/dist/owletto/dist/assets/connect-menu-D5EZvSHb.js +2 -0
  82. package/dist/owletto/dist/assets/connect._clientId-Dbagcg9L.js +2 -0
  83. package/dist/owletto/dist/assets/connected._clientId-DALW9S2K.js +2 -0
  84. package/dist/owletto/dist/assets/connection-DyxzSqVE.js +2 -0
  85. package/dist/owletto/dist/assets/connection-feed-detail-LqpxUCdy.js +2 -0
  86. package/dist/owletto/dist/assets/{connector-page-shell-an3SYLim.js → connector-page-shell-DZjKv9zQ.js} +2 -2
  87. package/dist/owletto/dist/assets/{connector-provenance-mSZCOud-.js → connector-provenance-DtTJn1Nk.js} +2 -2
  88. package/dist/owletto/dist/assets/connectors-BVl-AR33.js +2 -0
  89. package/dist/owletto/dist/assets/{consent-1ulwyJ3k.js → consent-XCqsHLxS.js} +2 -2
  90. package/dist/owletto/dist/assets/{core.esm-Ctg_pXLe.js → core.esm-B1du4Zwy.js} +3 -3
  91. package/dist/owletto/dist/assets/create-BYKCtGL4.js +2 -0
  92. package/dist/owletto/dist/assets/create-D6Mmuxcq.js +2 -0
  93. package/dist/owletto/dist/assets/{create-CGuoqPh8.js → create-GHTb6wKX.js} +2 -2
  94. package/dist/owletto/dist/assets/{create-automation-form-CD6jSlWL.js → create-automation-form-CTiy_S9G.js} +3 -3
  95. package/dist/owletto/dist/assets/create._connectorKey-DMH97KkK.js +2 -0
  96. package/dist/owletto/dist/assets/custom-guardrail-edits-DZy66ucV.js +2 -0
  97. package/dist/owletto/dist/assets/definition-comparison-C2mPfIMD.js +2 -0
  98. package/dist/owletto/dist/assets/detail-page-skeleton-DNBL7nyk.js +2 -0
  99. package/dist/owletto/dist/assets/device-CwP1PY8q.js +2 -0
  100. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkj7hrBE.js → device-pin-tombstone-DYTt7kU5.js} +2 -2
  101. package/dist/owletto/dist/assets/device._deviceId-DZ2kqI4Y.js +2 -0
  102. package/dist/owletto/dist/assets/{entity-options-D4t-NAcg.js → entity-options-D9K_5Lcs.js} +2 -2
  103. package/dist/owletto/dist/assets/entity-page-DggKXrcE.js +2 -0
  104. package/dist/owletto/dist/assets/entity-pages-C6M6yKFf.js +2 -0
  105. package/dist/owletto/dist/assets/{entity-schema-graph-Cq96SJ3c.js → entity-schema-graph-B255NKjF.js} +2 -2
  106. package/dist/owletto/dist/assets/entity-type-page-CGBAP2wt.js +2 -0
  107. package/dist/owletto/dist/assets/event-attachments-D8Z8uwv9.js +2 -0
  108. package/dist/owletto/dist/assets/event-detail-CgG3pDLA.js +2 -0
  109. package/dist/owletto/dist/assets/events-feed-ClhEywwV.js +2 -0
  110. package/dist/owletto/dist/assets/{filter-editors-DGVl9U4D.js → filter-editors-D_Sfn0dv.js} +3 -3
  111. package/dist/owletto/dist/assets/{full-page-spinner-CtVlF8GQ.js → full-page-spinner-C1clibUY.js} +2 -2
  112. package/dist/owletto/dist/assets/{index-CK5GDX4B.js → index-04B26s6E.js} +2 -2
  113. package/dist/owletto/dist/assets/index-2HrEO-nl.js +2 -0
  114. package/dist/owletto/dist/assets/index-BU3k9wpw.js +2 -0
  115. package/dist/owletto/dist/assets/{index-DvuJ_S_o.js → index-BXHqp23o.js} +2 -2
  116. package/dist/owletto/dist/assets/index-BdLRUDIR.js +2 -0
  117. package/dist/owletto/dist/assets/index-C2FrGwYN.js +2 -0
  118. package/dist/owletto/dist/assets/index-CB9wGfUm.js +2 -0
  119. package/dist/owletto/dist/assets/index-Caihaftb.js +2 -0
  120. package/dist/owletto/dist/assets/index-CwH59DJV.js +2 -0
  121. package/dist/owletto/dist/assets/index-DB2lVKuV.js +7908 -0
  122. package/dist/owletto/dist/assets/{index-DbjbHlDe.js → index-DTvJRjrM.js} +2 -2
  123. package/dist/owletto/dist/assets/index-SF2ni1Rs.css +1 -0
  124. package/dist/owletto/dist/assets/{index-BifR-LE9.js → index-mSrdbx3C.js} +9 -9
  125. package/dist/owletto/dist/assets/index-uFn-Ilrx.js +2 -0
  126. package/dist/owletto/dist/assets/{json-diff-OjtREegr.js → json-diff-Ce6YAXzY.js} +2 -2
  127. package/dist/owletto/dist/assets/{list-skeleton-CH0qQBYk.js → list-skeleton-DLPBTnbR.js} +2 -2
  128. package/dist/owletto/dist/assets/login-DeWlvogD.js +2 -0
  129. package/dist/owletto/dist/assets/{logout-DfdgOLoM.js → logout-CJY0ceN9.js} +2 -2
  130. package/dist/owletto/dist/assets/{member-scope-gate-Cxg2zGQT.js → member-scope-gate-CBPMprXu.js} +2 -2
  131. package/dist/owletto/dist/assets/memory-browse-page-D5kj1RaR.js +74 -0
  132. package/dist/owletto/dist/assets/{model-selector-D2OpDkwH.js → model-selector-CjkBPpjN.js} +2 -2
  133. package/dist/owletto/dist/assets/new-BKrNkOQD.js +2 -0
  134. package/dist/owletto/dist/assets/new-BetiMuDq.js +2 -0
  135. package/dist/owletto/dist/assets/new-dk_-eXqU.js +2 -0
  136. package/dist/owletto/dist/assets/new-efN--4Wx.js +2 -0
  137. package/dist/owletto/dist/assets/organization-C3rpwx_d.js +2 -0
  138. package/dist/owletto/dist/assets/pdf-document--AN-oCKj.css +1 -0
  139. package/dist/owletto/dist/assets/pdf-document-2W1q0sRA.js +56 -0
  140. package/dist/owletto/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
  141. package/dist/owletto/dist/assets/peek-pane-content-ChsBWO0P.js +3 -0
  142. package/dist/owletto/dist/assets/{pending-seed-BBACroge.js → pending-seed-CTKYdA4X.js} +2 -2
  143. package/dist/owletto/dist/assets/proposal-review-shell-EyGWEYwQ.js +2 -0
  144. package/dist/owletto/dist/assets/public-shell-ready-_KWdfzEM.js +2 -0
  145. package/dist/owletto/dist/assets/record-session-D27VNxP_.js +2 -0
  146. package/dist/owletto/dist/assets/{renderer-CTKNMcXP.js → renderer-B8yZ5lql.js} +34 -33
  147. package/dist/owletto/dist/assets/{reset-password-DKBEneyR.js → reset-password-BGVJIh2I.js} +2 -2
  148. package/dist/owletto/dist/assets/run-initiator-C0sur8lU.js +2 -0
  149. package/dist/owletto/dist/assets/runs-list-CJOFMgpk.js +2 -0
  150. package/dist/owletto/dist/assets/schema-value-DDNHANGs.js +3 -0
  151. package/dist/owletto/dist/assets/{scoped-feed-bar-DNFL0sYX.js → scoped-feed-bar-BTv9mPcR.js} +2 -2
  152. package/dist/owletto/dist/assets/settings-Ponr5XbS.js +3 -0
  153. package/dist/owletto/dist/assets/{status-variants-SzXYYedJ.js → status-variants-mLqVhg5O.js} +2 -2
  154. package/dist/owletto/dist/assets/subDays-BGA_fkig.js +2 -0
  155. package/dist/owletto/dist/assets/two-factor-pqoxGSgL.js +2 -0
  156. package/dist/owletto/dist/assets/{use-automations-DfBtVzGa.js → use-automations-DcdlmVuX.js} +2 -2
  157. package/dist/owletto/dist/assets/{use-login-redirect-BDiS3eyl.js → use-login-redirect-D7HW5Ed6.js} +2 -2
  158. package/dist/owletto/dist/assets/{use-mention-search-khySpz_V.js → use-mention-search-BniE-K2d.js} +3 -3
  159. package/dist/owletto/dist/assets/view-card-Cg6PeEiV.js +2 -0
  160. package/dist/owletto/dist/assets/view-param-filters-CvrKw0mZ.js +2 -0
  161. package/dist/owletto/dist/index.html +2 -2
  162. package/dist/server-main.bundle.mjs +5766 -2999
  163. package/npm-shrinkwrap.json +195 -172
  164. package/package.json +2 -1
  165. package/vendor/connector-sdk/dist/connector-types.d.ts +20 -0
  166. package/vendor/connector-sdk/dist/define-connector.js +2 -0
  167. package/vendor/connector-sdk/dist/extension-dom-scrape.d.ts +2 -0
  168. package/vendor/connector-sdk/dist/extension-dom-scrape.js +5 -0
  169. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +20 -0
  170. package/vendor/connector-sdk/package.json +1 -1
  171. package/vendor/core/dist/contracts/entity-reference.d.ts +2 -0
  172. package/vendor/core/dist/contracts/entity-reference.js +4 -3
  173. package/vendor/core/dist/contracts/tools/entity-list-sort.d.ts +18 -0
  174. package/vendor/core/dist/contracts/tools/entity-list-sort.js +64 -0
  175. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +1 -1
  176. package/vendor/core/dist/contracts/tools/manage-agents.js +3 -3
  177. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +4 -0
  178. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +4 -0
  179. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +4 -0
  180. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -1
  181. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +29 -3
  182. package/vendor/core/dist/contracts/tools/manage-operations.js +24 -2
  183. package/vendor/core/dist/contracts/tools/manage-views.d.ts +36 -0
  184. package/vendor/core/dist/contracts/tools/manage-views.js +15 -2
  185. package/vendor/core/dist/contracts/tools/view-definition.js +7 -2
  186. package/vendor/core/dist/contracts/tools/view-host.js +5 -0
  187. package/vendor/core/dist/contracts/tools/view-path.d.ts +8 -1
  188. package/vendor/core/dist/contracts/tools/view-path.js +11 -1
  189. package/vendor/core/dist/reserved.d.ts +7 -1
  190. package/vendor/core/dist/reserved.js +17 -0
  191. package/vendor/core/package.json +6 -1
  192. package/vendor/views/dist/api.d.ts +19 -3
  193. package/vendor/views/dist/api.js +53 -5
  194. package/vendor/views/dist/components.d.ts +7 -0
  195. package/vendor/views/dist/components.js +223 -2
  196. package/vendor/views/dist/embed.js +13 -2
  197. package/vendor/views/dist/live-gate.d.ts +34 -0
  198. package/vendor/views/dist/live-gate.js +100 -0
  199. package/vendor/views/dist/native.d.ts +43 -1
  200. package/vendor/views/dist/native.js +1 -0
  201. package/vendor/views/package.json +1 -1
  202. package/dist/owletto/dist/assets/_-BDMUN9XZ.js +0 -2
  203. package/dist/owletto/dist/assets/_-CF5X4ANe.js +0 -3
  204. package/dist/owletto/dist/assets/_agentId-EQU2aUP0.js +0 -2
  205. package/dist/owletto/dist/assets/_automationId-PXZ33jsF.js +0 -2
  206. package/dist/owletto/dist/assets/_connectorKey._connectionId-DcI29kGy.js +0 -2
  207. package/dist/owletto/dist/assets/_connectorKey.index-Cr2NDJWX.js +0 -2
  208. package/dist/owletto/dist/assets/_conversationId-CnmLYlVS.js +0 -2
  209. package/dist/owletto/dist/assets/_eventId-w5sDz5oa.js +0 -2
  210. package/dist/owletto/dist/assets/_owner-CkOZR4n0.js +0 -3
  211. package/dist/owletto/dist/assets/_shape-C_FmSf9G.js +0 -2
  212. package/dist/owletto/dist/assets/_slug-COPpRXLt.js +0 -2
  213. package/dist/owletto/dist/assets/_viewKey-BVdJiilV.js +0 -2
  214. package/dist/owletto/dist/assets/_viewKey-mxxpqjtC.js +0 -2
  215. package/dist/owletto/dist/assets/activity-route-view-msesKUwn.js +0 -2
  216. package/dist/owletto/dist/assets/agent-connect-pages-DVq9nAR7.js +0 -4
  217. package/dist/owletto/dist/assets/agent-thread-Cqf9ITrT.js +0 -6
  218. package/dist/owletto/dist/assets/assist-composer-kG_heHXo.js +0 -2
  219. package/dist/owletto/dist/assets/automation-run-now-C5XTS00o.js +0 -2
  220. package/dist/owletto/dist/assets/client-activity-scopes-Aqdo6Pdr.js +0 -2
  221. package/dist/owletto/dist/assets/connect-BFNp1y_s.js +0 -2
  222. package/dist/owletto/dist/assets/connect-menu-BWrAhMqO.js +0 -2
  223. package/dist/owletto/dist/assets/connect._clientId-CSPfwYIN.js +0 -2
  224. package/dist/owletto/dist/assets/connected._clientId-CuOeHafK.js +0 -2
  225. package/dist/owletto/dist/assets/connection-CVeHmDLs.js +0 -2
  226. package/dist/owletto/dist/assets/connection-feed-detail-BYo7zdVD.js +0 -2
  227. package/dist/owletto/dist/assets/connectors-DBEM9QQz.js +0 -2
  228. package/dist/owletto/dist/assets/copy-button-Xhh7ZnjO.js +0 -2
  229. package/dist/owletto/dist/assets/create-Ccb5R-S4.js +0 -2
  230. package/dist/owletto/dist/assets/create-DmhbacIa.js +0 -2
  231. package/dist/owletto/dist/assets/create._connectorKey-CZsAqj1p.js +0 -2
  232. package/dist/owletto/dist/assets/custom-guardrail-edits-Ce_BwiwD.js +0 -2
  233. package/dist/owletto/dist/assets/definition-comparison-D_qP25jR.js +0 -2
  234. package/dist/owletto/dist/assets/detail-page-skeleton-CPAfZLG0.js +0 -2
  235. package/dist/owletto/dist/assets/device-DDl5XKvt.js +0 -2
  236. package/dist/owletto/dist/assets/device._deviceId-bNhTcops.js +0 -2
  237. package/dist/owletto/dist/assets/dynamic-schema-form-CRyUchXo.js +0 -2
  238. package/dist/owletto/dist/assets/entity-page-BOOL_vy3.js +0 -2
  239. package/dist/owletto/dist/assets/entity-pages-_nuesgnp.js +0 -2
  240. package/dist/owletto/dist/assets/entity-type-page-CkCSbkBx.js +0 -2
  241. package/dist/owletto/dist/assets/event-detail-DUvlqn9b.js +0 -2
  242. package/dist/owletto/dist/assets/events-feed-DcKTkJVe.js +0 -2
  243. package/dist/owletto/dist/assets/index-BUlkNJzX.js +0 -2
  244. package/dist/owletto/dist/assets/index-BoqrvLHQ.js +0 -7906
  245. package/dist/owletto/dist/assets/index-CA9mW_ZM.js +0 -2
  246. package/dist/owletto/dist/assets/index-CH0GzG4i.js +0 -2
  247. package/dist/owletto/dist/assets/index-CtI5Eomq.js +0 -2
  248. package/dist/owletto/dist/assets/index-DmtQ0bds.js +0 -2
  249. package/dist/owletto/dist/assets/index-Du_J8hnx.js +0 -2
  250. package/dist/owletto/dist/assets/index-Pae_f9LM.css +0 -1
  251. package/dist/owletto/dist/assets/index-XETZnN7L.js +0 -2
  252. package/dist/owletto/dist/assets/login-DG0b9uSC.js +0 -2
  253. package/dist/owletto/dist/assets/memory-browse-page-qEDQ9Z18.js +0 -74
  254. package/dist/owletto/dist/assets/missing-view-xT0B-f5z.js +0 -2
  255. package/dist/owletto/dist/assets/needs-you-list-3uMsWcDv.js +0 -2
  256. package/dist/owletto/dist/assets/new-AdGV6a8R.js +0 -2
  257. package/dist/owletto/dist/assets/new-BdtIhBpo.js +0 -2
  258. package/dist/owletto/dist/assets/new-BjGwX6s6.js +0 -2
  259. package/dist/owletto/dist/assets/new-D-iMjV74.js +0 -2
  260. package/dist/owletto/dist/assets/organization-qaIpEiQg.js +0 -2
  261. package/dist/owletto/dist/assets/peek-pane-content-CEsDVScl.js +0 -2
  262. package/dist/owletto/dist/assets/proposal-review-shell-C8ZfIAYn.js +0 -2
  263. package/dist/owletto/dist/assets/public-shell-ready-K2R8iXSI.js +0 -2
  264. package/dist/owletto/dist/assets/record-session-BrM9cdXu.js +0 -2
  265. package/dist/owletto/dist/assets/run-initiator-BKSgI1o0.js +0 -2
  266. package/dist/owletto/dist/assets/runs-k2NpbZm8.js +0 -2
  267. package/dist/owletto/dist/assets/runs-list-DUXRMkWN.js +0 -2
  268. package/dist/owletto/dist/assets/schema-value-wjqGxXhv.js +0 -3
  269. package/dist/owletto/dist/assets/settings-V0m5Om5j.js +0 -2
  270. package/dist/owletto/dist/assets/source-record-panels-BMut9YIA.js +0 -2
  271. package/dist/owletto/dist/assets/subDays-9s9OEl5t.js +0 -2
  272. package/dist/owletto/dist/assets/table-ZuYMOjVR.js +0 -2
  273. package/dist/owletto/dist/assets/view-card-DiHWlypr.js +0 -2
  274. package/dist/owletto/dist/assets/view-param-filters-DGKxSr7r.js +0 -2
  275. package/dist/owletto/dist/assets/views-access-required-HA-PiOwA.js +0 -2
@@ -1,2 +0,0 @@
1
- import{jn as e,j as t,i8 as r}from"./index-BoqrvLHQ.js";function a(){const{owner:n,connectorKey:o}=e.useParams();return t.jsx(r,{owner:n,initialConnectorKey:o})}export{a as component};
2
- //# sourceMappingURL=create._connectorKey-CZsAqj1p.js.map
@@ -1,2 +0,0 @@
1
- import{r as m,j as e,Z as u,$ as g,bq as A,br as F,bs as L,bt as _,bu as D,fj as O,B as S}from"./index-BoqrvLHQ.js";import{M as B}from"./model-selector-D2OpDkwH.js";const R=[{value:"input",label:"Input",hint:"the user message, before the agent runs"},{value:"output",label:"Output",hint:"the agent's reply, before the user sees it"},{value:"pre-tool",label:"Pre-tool",hint:"a tool call, before it executes"},{value:"egress",label:"Egress",hint:"an outbound request to a judged domain"}];function I({initial:t,judgeModelDefault:a,submitLabel:r,submitting:s,onSubmit:i,onCancel:o}){const[d,n]=m.useState(t?.name??""),[c,k]=m.useState(t?.stage??"input"),[b,E]=m.useState(t?.policy??""),[f,G]=m.useState(t?.model??""),[p,y]=m.useState((t?.tools??[]).join(", ")),[x,T]=m.useState((t?.domains??[]).join(", ")),j=t?.kind,h=j==="require-tool",w=l=>{l.preventDefault();const N=p.split(",").map(v=>v.trim()).filter(Boolean);i({name:d,stage:c,...j?{kind:j}:{},policy:b,model:f.trim()||void 0,tools:(h||c==="pre-tool")&&N.length>0?N:void 0,domains:c==="egress"&&x.trim()?x.split(",").map(v=>v.trim()).filter(Boolean):void 0,enabled:t?.enabled??!0})};return e.jsxs("form",{onSubmit:w,className:"space-y-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(u,{htmlFor:"guardrail-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(g,{id:"guardrail-name",value:d,onChange:l=>n(l.target.value),placeholder:"no-competitor-mentions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Shown in the list and on every trip. Must be unique."})]}),h?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(u,{htmlFor:"guardrail-stage",children:"Stage"}),e.jsxs(A,{value:c,onValueChange:l=>k(l),disabled:s,children:[e.jsx(F,{id:"guardrail-stage",children:e.jsx(L,{})}),e.jsx(_,{children:R.map(l=>e.jsxs(D,{value:l.value,children:[l.label," — ",l.hint]},l.value))})]})]}),h?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(u,{htmlFor:"guardrail-required-tools",children:["Required tools ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(g,{id:"guardrail-required-tools",value:p,onChange:l=>y(l.target.value),placeholder:"suggest_actions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated. The turn trips if the agent finishes without calling every one of these. No judge model runs — this is a lookup against the tools the turn actually used."})]}):null,h?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(u,{htmlFor:"guardrail-policy",children:["Policy ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(O,{id:"guardrail-policy",rows:5,value:b,onChange:l=>E(l.target.value),placeholder:"Deny any response that names a competitor (Acme, Globex) or quotes their pricing.",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A judge model reads this and the text at the chosen stage, then allows or denies. Write it as an instruction to a reviewer."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(u,{htmlFor:"guardrail-model",children:["Judge model",a?null:e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(B,{value:f,onChange:G,placeholder:a?`Default (${a})`:"Select a model",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:a?"Optional. Leave blank to use the gateway's default judge model.":"Required: the gateway has no default judge model (EGRESS_JUDGE_MODEL is unset)."})]})]}),!h&&c==="pre-tool"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(u,{htmlFor:"guardrail-tools",children:"Tool scope"}),e.jsx(g,{id:"guardrail-tools",value:p,onChange:l=>y(l.target.value),placeholder:"github.delete_repo, fs.delete",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Optional, comma-separated. Leave blank to judge every tool call."})]}):null,c==="egress"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(u,{htmlFor:"guardrail-domains",children:"Domains"}),e.jsx(g,{id:"guardrail-domains",value:x,onChange:l=>T(l.target.value),placeholder:"api.github.com, .slack.com",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated hostnames this judge gates — exact (api.github.com) or wildcard (.slack.com). Leave blank to route nothing."})]}):null,e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[o?e.jsx(S,{type:"button",variant:"outline",onClick:o,disabled:s,children:"Cancel"}):null,e.jsx(S,{type:"submit",disabled:s,children:s?"Saving…":r})]})]})}function q(t){return t.kind==="require-tool"}function J(t,a,r,s,i){const o=t.name.trim();return o?/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/.test(o)?r.includes(o)?`"${o}" is a built-in guardrail name — pick another.`:a.some(n=>n.name===o&&n.name!==i)?`A custom guardrail named "${o}" already exists.`:q(t)?t.stage!=="output"?"A required-tool guardrail only runs at the output stage.":t.tools?.some(n=>n.trim())?null:"List at least one tool that must be used.":t.policy.trim()?!s&&!t.model?.trim()?"Judge model is required — the gateway has no default (EGRESS_JUDGE_MODEL is unset).":null:"Policy is required.":"Name may use letters, numbers, spaces, hyphens, and underscores.":"Name is required."}function C(t){const a=q(t),s=(a||t.stage==="pre-tool")&&t.tools&&t.tools.length>0?t.tools.map(n=>n.trim()).filter(Boolean):void 0,i=t.stage==="egress"&&t.domains&&t.domains.length>0?t.domains.map(n=>n.trim()).filter(Boolean):void 0,o=t.model?.trim()||void 0,d=t.policy.trim();return{name:t.name.trim(),enabled:t.enabled,stage:t.stage,...a?{kind:"require-tool"}:{},...a?d?{policy:d}:{}:{policy:d},...o?{model:o}:{},...s&&s.length>0?{tools:s}:{},...i&&i.length>0?{domains:i}:{}}}function z(t,a){return[...t,C(a)]}function M(t,a,r){return t.map(s=>s.name===a?C(r):s)}function Z(t,a){return t.filter(r=>r.name!==a)}function U(t,a,r){return t.map(s=>s.name===a?{...s,enabled:r}:s)}export{I as A,z as a,Z as r,U as s,M as u,J as v};
2
- //# sourceMappingURL=custom-guardrail-edits-Ce_BwiwD.js.map
@@ -1,2 +0,0 @@
1
- import{r as y,j as e,dx as fe,Z as h,fj as v,$ as w,ab as je,bq as be,br as ye,bs as Ne,bt as ve,bu as L,g3 as we,bz as M,g4 as Te,g5 as F,g6 as Ce,g7 as Me,g8 as Se,g9 as Ie,ga as G,bC as Ae,B as _e}from"./index-BoqrvLHQ.js";import{A as $e,J as Fe}from"./json-diff-OjtREegr.js";import{S as De}from"./schema-value-wjqGxXhv.js";import{C as Re}from"./code-editor-z1Sy_hiX.js";const Ee=72,Oe=2e3;function Pe({value:s,onChange:t,section:a="all",create:r=!1,disabled:l=!1,loading:m=!1,modelsEditor:d,sandboxes:x=[],includedFields:p}){const o=y.useId(),i=n=>!p||p.includes(n),{name:c,description:f,identityMd:te,soulMd:ne,userMd:ae,models:re,showToolCalls:ie,sandboxId:I,starters:A}=s,j=(n,b)=>t?.({...s,[n]:b}),oe=n=>j("name",n),de=n=>j("description",n),le=n=>j("identityMd",n),ce=n=>j("soulMd",n),ue=n=>j("userMd",n),me=n=>j("showToolCalls",n),xe=n=>j("sandboxId",n),E=n=>j("starters",n),O=r,g=l||!t,he=m,ge=r||a==="settings"||a==="all",pe=!r&&(a==="identity"||a==="settings"||a==="all"),P=!r&&(a==="settings"||a==="all"),k=!r&&(a==="models"||a==="all");return e.jsxs("div",{className:"grid content-start gap-4 py-2",children:[pe?he?e.jsx(fe,{rows:4}):e.jsxs(e.Fragment,{children:[i("identityMd")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:`${o}-identity-md`,children:"Identity"}),e.jsx(v,{id:`${o}-identity-md`,rows:6,value:te,onChange:n=>le(n.target.value),readOnly:g,placeholder:"You are a market intelligence agent. Track competitors, analyze launches and signals, and surface concise, decision-ready insights."})]}):null,i("soulMd")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:`${o}-soul-md`,children:"Soul"}),e.jsx(v,{id:`${o}-soul-md`,rows:6,value:ne,onChange:n=>ce(n.target.value),readOnly:g,placeholder:"Be rigorous, skeptical of weak signals, and calm under ambiguity. Prefer crisp summaries, explicit evidence, and clear confidence levels."})]}):null,i("userMd")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:`${o}-user-md`,children:"User prompt"}),e.jsx(v,{id:`${o}-user-md`,rows:6,value:ae,onChange:n=>ue(n.target.value),readOnly:g,placeholder:"Monitor the market for notable competitor moves, pricing changes, launches, partnerships, and customer sentiment shifts. Summarize what changed, why it matters, and what to watch next."})]}):null]}):null,ge?e.jsxs(e.Fragment,{children:[i("name")?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(h,{htmlFor:`${o}-agent-name`,children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(w,{id:`${o}-agent-name`,placeholder:"Support Bot",value:c,onChange:n=>oe(n.target.value),readOnly:g,required:!0}),O?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"The agent ID will be generated automatically from the name."}):null]}):null,O||!i("description")?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:`${o}-agent-description`,children:"Description"}),e.jsx(v,{id:`${o}-agent-description`,placeholder:"Handles customer support and triage across channels.",value:f,onChange:n=>de(n.target.value),readOnly:g,rows:3})]})]}):null,P&&i("showToolCalls")?e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/20 p-3",children:[e.jsx(je,{id:`${o}-show-tool-calls`,checked:ie,onCheckedChange:n=>me(n===!0),disabled:g,className:"mt-0.5"}),e.jsxs("div",{className:"grid gap-0.5",children:[e.jsx(h,{htmlFor:`${o}-show-tool-calls`,className:"cursor-pointer",children:"Show tool calls in chat"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Render the agent's tool invocations (name, arguments, and result) as cards in the web chat. Off by default."})]})]}):null,P&&i("starters")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{children:"Conversation starters"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Up to three prompts offered on a new chat, on the web and in Slack. The message is sent as the user when tapped."}),A.map((n,b)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[12rem_1fr]",children:[e.jsx(w,{"aria-label":`Starter ${b+1} title`,placeholder:"Plan this week",maxLength:Ee,value:n.title,onChange:_=>E(A.map((N,$)=>$===b?{...N,title:_.target.value}:N)),readOnly:g}),e.jsx(w,{"aria-label":`Starter ${b+1} message`,placeholder:"Plan this week's posts from what's trending",maxLength:Oe,value:n.message,onChange:_=>E(A.map((N,$)=>$===b?{...N,message:_.target.value}:N)),readOnly:g})]},b))]}):null,k&&i("models")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{children:"Models"}),d??e.jsx("ol",{className:"grid gap-2",children:re.map(n=>e.jsx("li",{className:"rounded-lg border px-3 py-2 text-sm",children:n},n))}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ordered list; the first is the default. Only these models may be used — a request for anything else falls back to the first available one. Leave empty to use the org default."})]}):null,k&&i("sandboxId")?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:`${o}-agent-sandbox`,children:"Run in sandbox"}),t?e.jsxs(be,{value:I,onValueChange:xe,disabled:g,children:[e.jsx(ye,{id:`${o}-agent-sandbox`,className:"w-full",children:e.jsx(Ne,{placeholder:"Built-in"})}),e.jsxs(ve,{children:[e.jsx(L,{value:"builtin",children:"Built-in (default)"}),x.map(n=>e.jsxs(L,{value:n.id,children:[n.name," (",n.providerKind,")",n.connected?"":" — no credential"]},n.id))]})]}):e.jsx(w,{"aria-label":"Run in sandbox",value:I==="builtin"?"Built-in (default)":I,readOnly:!0}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Where this agent's commands execute. Built-in runs in-process; sandboxes run on a connected provider. Manage sandboxes under Connect › Runtime."})]}):null]})}function q(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function u(s){return typeof s=="string"?s:""}function z(s){return Array.isArray(s)?s.map(q):[]}function ke(s){return Array.isArray(s)?s.filter(t=>typeof t=="string"):[]}function T({label:s,children:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:s}),t]})}function D({label:s,value:t,multiline:a=!1}){return e.jsxs(h,{className:"grid gap-2",children:[e.jsx("span",{children:s}),t===void 0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not included in snapshot"}):t===null?e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not set"}):a?e.jsx(v,{value:u(t),readOnly:!0,rows:6}):e.jsx(w,{value:u(t),readOnly:!0})]})}function C({value:s}){return s===null?e.jsx("span",{className:"text-muted-foreground",children:"Not set"}):Array.isArray(s)?s.length?e.jsx("ol",{className:"grid gap-3",children:s.map((t,a)=>e.jsx("li",{className:"min-w-0 rounded-lg border p-3",children:e.jsx(C,{value:t})},a))}):e.jsx("span",{className:"text-muted-foreground",children:"Empty list"}):s&&typeof s=="object"?e.jsx("dl",{className:"grid gap-3",children:Object.entries(s).map(([t,a])=>e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t.replaceAll("_"," ")}),e.jsx("dd",{className:"min-w-0 whitespace-pre-wrap text-sm",children:e.jsx(C,{value:a})})]},t))}):s===""?e.jsx("span",{className:"text-muted-foreground",children:"Empty text"}):e.jsx(De,{value:s})}function K({value:s,omit:t}){const a=Object.entries(s).filter(([r])=>!t.includes(r));return a.length?e.jsx(T,{label:"Settings",children:e.jsx("dl",{className:"grid gap-4",children:a.map(([r,l])=>e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("dt",{className:"text-sm text-muted-foreground",children:r.replaceAll("_"," ")}),e.jsx("dd",{className:"min-w-0 text-sm",children:e.jsx(C,{value:l})})]},r))})}):null}function Ye({value:s}){const t=z(s.sources).map(a=>({name:u(a.name),query:u(a.query)}));return e.jsxs("div",{className:"grid gap-6 py-2 [&_.cm-content_span]:text-inherit",children:[e.jsx(D,{label:"Name",value:s.name}),e.jsx(D,{label:"Description",value:s.description}),e.jsx(D,{label:"Instructions",value:s.prompt,multiline:!0}),e.jsx(T,{label:"Sources",children:s.sources===void 0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not included in snapshot"}):t.length?e.jsx($e,{sources:t,wrap:!0}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No sources."})}),e.jsx(T,{label:"When",children:s.triggers===void 0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not included in snapshot"}):Array.isArray(s.triggers)&&s.triggers.length?e.jsx(C,{value:s.triggers}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manual only."})}),s.outputs!==void 0?e.jsx(T,{label:"Outputs",children:e.jsx(C,{value:s.outputs})}):null,typeof s.reaction_script=="string"?e.jsx(T,{label:"Code",children:e.jsx(Re,{value:s.reaction_script,language:"typescript",readonly:!0})}):null,e.jsx(K,{value:s,omit:["name","description","prompt","sources","triggers","outputs","reaction_script"]})]})}function Ze({value:s}){const t=q(s.settings);return e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Pe,{includedFields:[...s.name!==void 0?["name"]:[],...s.description!==void 0?["description"]:[],...s.identity_md!==void 0||s.identityMd!==void 0?["identityMd"]:[],...s.soul_md!==void 0||s.soulMd!==void 0?["soulMd"]:[],...s.user_md!==void 0||s.userMd!==void 0?["userMd"]:[],...s.models!==void 0||t.models!==void 0?["models"]:[],...s.showToolCalls!==void 0||t.showToolCalls!==void 0?["showToolCalls"]:[],...s.sandboxId!==void 0||t.sandboxId!==void 0?["sandboxId"]:[],...s.starters!==void 0?["starters"]:[]],value:{name:u(s.name),description:u(s.description),identityMd:u(s.identity_md??s.identityMd),soulMd:u(s.soul_md??s.soulMd),userMd:u(s.user_md??s.userMd),models:ke(s.models??t.models),showToolCalls:(s.showToolCalls??t.showToolCalls)===!0,sandboxId:u(s.sandboxId??t.sandboxId)||"builtin",starters:z(s.starters).map(a=>({title:u(a.title),message:u(a.message)}))}}),e.jsx(K,{value:s,omit:["name","description","identity_md","identityMd","soul_md","soulMd","user_md","userMd","models","showToolCalls","sandboxId","starters"]})]})}var S="Tabs",[Le]=Ae(S,[G]),U=G(),[Ve,R]=Le(S),H=y.forwardRef((s,t)=>{const{__scopeTabs:a,value:r,onValueChange:l,defaultValue:m,orientation:d="horizontal",dir:x,activationMode:p="automatic",...o}=s,i=Me(x),[c,f]=Se({prop:r,onChange:l,defaultProp:m??"",caller:S});return e.jsx(Ve,{scope:a,baseId:Ie(),value:c,onValueChange:f,orientation:d,dir:i,activationMode:p,children:e.jsx(M.div,{dir:i,"data-orientation":d,...o,ref:t})})});H.displayName=S;var J="TabsList",W=y.forwardRef((s,t)=>{const{__scopeTabs:a,loop:r=!0,...l}=s,m=R(J,a),d=U(a);return e.jsx(Ce,{asChild:!0,...d,orientation:m.orientation,dir:m.dir,loop:r,children:e.jsx(M.div,{role:"tablist","aria-orientation":m.orientation,...l,ref:t})})});W.displayName=J;var X="TabsTrigger",Y=y.forwardRef((s,t)=>{const{__scopeTabs:a,value:r,disabled:l=!1,...m}=s,d=R(X,a),x=U(a),p=ee(d.baseId,r),o=se(d.baseId,r),i=r===d.value;return e.jsx(Te,{asChild:!0,...x,focusable:!l,active:i,children:e.jsx(M.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":o,"data-state":i?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:p,...m,ref:t,onMouseDown:F(s.onMouseDown,c=>{!l&&c.button===0&&c.ctrlKey===!1?d.onValueChange(r):c.preventDefault()}),onKeyDown:F(s.onKeyDown,c=>{[" ","Enter"].includes(c.key)&&d.onValueChange(r)}),onFocus:F(s.onFocus,()=>{const c=d.activationMode!=="manual";!i&&!l&&c&&d.onValueChange(r)})})})});Y.displayName=X;var Z="TabsContent",Q=y.forwardRef((s,t)=>{const{__scopeTabs:a,value:r,forceMount:l,children:m,...d}=s,x=R(Z,a),p=ee(x.baseId,r),o=se(x.baseId,r),i=r===x.value,c=y.useRef(i);return y.useEffect(()=>{const f=requestAnimationFrame(()=>c.current=!1);return()=>cancelAnimationFrame(f)},[]),e.jsx(we,{present:l||i,children:({present:f})=>e.jsx(M.div,{"data-state":i?"active":"inactive","data-orientation":x.orientation,role:"tabpanel","aria-labelledby":p,hidden:!f,id:o,tabIndex:0,...d,ref:t,style:{...s.style,animationDuration:c.current?"0s":void 0},children:f&&m})})});Q.displayName=Z;function ee(s,t){return`${s}-trigger-${t}`}function se(s,t){return`${s}-content-${t}`}var Be=H,Ge=W,qe=Y,ze=Q;function Ke({defaultValue:s,children:t}){return e.jsx(Be,{defaultValue:s,className:"space-y-4",children:t})}function Ue({label:s="Views",children:t}){return e.jsx(Ge,{"aria-label":s,className:"flex flex-wrap gap-1 border-b pb-2",children:t})}function V({value:s,children:t}){return e.jsx(qe,{value:s,asChild:!0,children:e.jsx(_e,{type:"button",variant:"ghost",size:"sm",className:"data-[state=active]:bg-secondary data-[state=active]:text-secondary-foreground",children:t})})}function B({value:s,children:t}){return e.jsx(ze,{value:s,children:t})}function Qe({current:s,proposed:t,render:a}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ke,{defaultValue:"proposed",children:[e.jsxs(Ue,{label:"Definition version",children:[e.jsx(V,{value:"current",children:"Current"}),e.jsx(V,{value:"proposed",children:"Proposed"})]}),e.jsx(B,{value:"current",children:s?a(s):e.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"No current definition."})}),e.jsx(B,{value:"proposed",children:t?a(t):e.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"This definition will be removed."})})]}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer rounded-sm py-2 text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Show technical diff"}),e.jsx(Fe,{before:s,after:t})]})]})}export{Ze as A,Qe as D,B as T,Ye as a,V as b,Ue as c,Ke as d,Pe as e};
2
- //# sourceMappingURL=definition-comparison-D_qP25jR.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,i as y,fB as S,r as o,B as R,au as k,m as r}from"./index-BoqrvLHQ.js";import{L as w,a as B}from"./list-skeleton-CH0qQBYk.js";import{u as P}from"./runs-k2NpbZm8.js";import{F as A,o as C}from"./filter-editors-DGVl9U4D.js";import{a as F}from"./runs-list-DUXRMkWN.js";const L=[{value:"all",label:"All"},{value:"automation",label:"Automation"},{value:"sync",label:"Sync"},{value:"action",label:"Action"},{value:"auth",label:"Auth"}],u=[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"},{value:"claimed",label:"Claimed"},{value:"cancelled",label:"Cancelled"},{value:"timeout",label:"Timed out"}];function E({bucket:t,status:a,onBucketChange:s,onStatusChange:n}){return e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[e.jsx("div",{className:"inline-flex max-w-full flex-wrap rounded-md border bg-muted/30 p-0.5 text-sm",children:L.map(l=>e.jsx("button",{type:"button",onClick:()=>s(l.value),className:y("rounded px-3 py-1 transition-colors",t===l.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:l.label},l.value))}),e.jsx(A,{label:"Run filters",className:"w-full min-w-0",fields:[{key:"status",label:"Status",icon:e.jsx(S,{className:"h-4 w-4"}),editor:C({searchPlaceholder:"Search statuses...",options:u,selected:a==="all"?[]:[a],onSelect:n})}],chips:a==="all"?[]:[{id:"status",label:"Status",op:"is",value:u.find(l=>l.value===a)?.label??a,onRemove:()=>n("all")}]})]})}function I({scope:t,ownerSlug:a}){const[s,n]=o.useState("all"),[l,c]=o.useState("all"),i=o.useMemo(()=>({runTypes:s==="all"?void 0:[s],status:l==="all"?void 0:l}),[s,l]),{data:d,isLoading:m,isError:x,hasNextPage:h,isFetching:f,isFetchingNextPage:v,fetchNextPage:p,refetch:b}=P(t,i,a),g=o.useMemo(()=>d?.pages.flatMap(N=>N.runs)??[],[d]),j={feed:!0,connection:"deviceId"in t||"connectorKey"in t,startedBy:!0};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{bucket:s,status:l,onBucketChange:n,onStatusChange:c}),m?e.jsx(w,{label:"Loading runs",rows:6,bordered:!1}):x?e.jsxs("p",{className:"rounded-lg border bg-destructive/5 px-3 py-6 text-center text-xs text-destructive",children:["Failed to load runs."," ",e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>void b(),children:"Retry"})]}):e.jsx(F,{runs:g,ownerSlug:a,columns:j,emptyState:e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:s==="all"&&l==="all"?"No runs yet.":"No runs match these filters."}),hasNextPage:!!h,isFetching:f,isFetchingNextPage:v,onLoadMore:()=>void p()})]})}function K({label:t,sections:a=2,rows:s=3}){return e.jsx(k,{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsxs("div",{role:"status","aria-label":t,children:[e.jsxs("div",{className:"flex flex-col gap-2 pb-1",children:[e.jsx(r,{className:"h-4 w-56"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(r,{className:"h-8 w-8 shrink-0 rounded-lg"}),e.jsx(r,{className:"h-6 w-56"})]})]}),e.jsx("div",{className:"mt-4 space-y-7",children:Array.from({length:a},(n,l)=>e.jsxs("div",{children:[e.jsx("div",{className:"mb-2.5 border-b pb-2",children:e.jsx(r,{className:"h-3.5 w-24"})}),Array.from({length:s},(c,i)=>e.jsx(B,{},i))]},l))})]})})}export{K as D,I as R};
2
- //# sourceMappingURL=detail-page-skeleton-CPAfZLG0.js.map
@@ -1,2 +0,0 @@
1
- import{a2 as Ce,H as je,r as h,a3 as Ne,j as e,$ as Se,B as ce,a4 as ie}from"./index-BoqrvLHQ.js";import{u as Ae,r as te,o as F,g as _e,a as De,C as ne,A as Ee,W as Re,b as re,c as Te,R as Pe}from"./use-login-redirect-BDiS3eyl.js";import{F as Le}from"./full-page-spinner-CtVlF8GQ.js";import{w as A}from"./workspace-label-o_QfBuCM.js";import"./card-CAPpY9P5.js";const Ie=[];function M(t){return t.trim().toUpperCase()}const Oe=15e3;async function ze(t){const i=new AbortController,p=window.setTimeout(()=>i.abort(),Oe);try{const n=await fetch(`${ie}/oauth/device/info?user_code=${encodeURIComponent(t)}`,{credentials:"include",signal:i.signal}),u=await n.json().catch(()=>null);return{response:n,data:u}}catch(n){throw i.signal.aborted?new Error("Verification timed out. Check your connection and try again."):n}finally{window.clearTimeout(p)}}function Ue({isVerified:t,requiresDeviceHome:i,requiresWorkspaceAccess:p,homeLabel:n,workspaceCount:u}){if(!t||p&&u===0)return null;const b=`${u} workspace${u===1?"":"s"}`;return i?n?p?`Pairs this device in ${n} and grants MCP access to ${b}.`:`Pairs this device in ${n} with no workspace data access.`:null:p?`Grants MCP access to ${b}.`:null}function qe(){const t=Ce.useSearch(),{session:i,isReady:p}=je(),n=!p,[u,b]=h.useState(t.user_code||""),[r,g]=h.useState(null),[w,s]=h.useState(null),[a,ae]=h.useState(null),[$,P]=h.useState(null),[le,V]=h.useState(null),k=h.useRef(0),j=Ne(t.return_to),q=j?"app":"terminal",de=!!t.user_code,_=M(u),m=$?.code===_?$:null,v=m!==null,D=m?.scopes??Ie,E=D.includes("device_worker:run"),ue=D.includes("connections:token"),L=m?.multiWorkspaceGrantsEnabled===!0,{accessLevel:G,setAccessLevel:I,selectedScopes:me,resourceOrg:O,hasMcpScopes:he,requiresWorkspaceAccess:N,orgList:C,workspaceAccess:pe,setWorkspaceAccess:ve,selectedOrgIds:z,toggleSelectedOrgId:fe,resetWorkspaceSelection:ge,deviceHomeOrgId:R,orgsLoading:U,orgsError:T,retryOrgs:B,workspaceSelectionReady:xe}=Ae({requestedScopes:D,resource:m?.resource??null,allowMultiple:L,requireDeviceHome:E,deviceHomeOrgId:le}),l=v&&E&&!O,d=C.find(o=>o.id===R)??null,Y=U||T!==null||C.length>1,J=C.length===1?C[0]:void 0,we=J!==void 0&&!J.isPersonal,K=l&&(Y||R===null||we),Q=N&&Y&&(L||!l),X=!N&&!l||xe,W=h.useCallback(async o=>{const x=++k.current;g("verify"),s(null);try{const{response:y,data:c}=await ze(o);if(x!==k.current)return;if(y.status===401){te();return}if(!y.ok||!c)throw new Error(F(c,"Failed to verify device authorization code"));const f=Array.isArray(c.scopes)?c.scopes:[];P({code:o,clientName:c.client_name??null,logoUri:typeof c.logo_uri=="string"?c.logo_uri:null,clientUri:typeof c.client_uri=="string"?c.client_uri:null,scopes:f,resource:typeof c.resource=="string"?c.resource:null,multiWorkspaceGrantsEnabled:c.multi_workspace_grants_enabled===!0}),I(_e(f))}catch(y){if(x!==k.current)return;P(null),s(y instanceof Error?y.message:"Unexpected error")}finally{x===k.current&&g(null)}},[I]);De(!!i,n),h.useEffect(()=>{if(!(n||!i||!t.user_code))return W(M(t.user_code)),()=>{k.current+=1}},[i,n,t.user_code,W]);const Z=async o=>{const x=_;if(!x){s(`Please enter the code shown in your ${q}.`);return}if(!v){s("Verify the device code before approving or denying access.");return}if(o&&!X){s(T?"Workspaces could not be loaded. Retry before approving.":l&&!d?"Choose a workspace for this device before approving.":"Choose at least one workspace before approving.");return}const y=m?.clientName??null,c=l&&d?A(d):null;g(o?"approve":"deny"),s(null);try{const f=await fetch(`${ie}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:x,approved:o,...o?{scope:me.join(" ")}:{},...o&&N?{workspace_access:pe,organization_ids:z}:{},...o&&l&&d?{organization_id:d.id}:{}})}),S=await f.json().catch(()=>null);if(f.status===401){te();return}if(!f.ok)throw new Error(F(S,"Failed to process device authorization"));const oe=o?"approved":"denied";if(S?.status!==oe)throw new Error(F(S,o?"The server did not confirm this approval. The device is still waiting — try again.":"The server did not confirm this denial. Try again."));const se=typeof S.user_code=="string"?M(S.user_code):null;if(se!==null&&se!==x)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");g(null),ae({outcome:oe,code:x,clientName:y,deviceHomeLabel:c})}catch(f){g(null),s(f instanceof Error?f.message:"Unexpected error")}};if(h.useEffect(()=>{if(a?.outcome!=="approved"||!j)return;const o=window.setTimeout(()=>{window.location.href=j},600);return()=>window.clearTimeout(o)},[a,j]),n||!i)return e.jsx(Le,{className:"min-h-[calc(100vh-3.5rem)]"});if(a)return e.jsx(ne,{live:!0,title:a.outcome==="approved"?de?"Access Authorized":"Device Authorized":"Authorization Denied",description:a.outcome==="approved"?j?"You can close this tab and return to the Lobu app.":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab.",review:e.jsxs("div",{className:"space-y-4 text-sm",children:[a.outcome==="approved"&&a.deviceHomeLabel?e.jsxs("p",{className:"text-muted-foreground",children:["This device now lives in ",a.deviceHomeLabel,". Change its workspace or share its connections from the device page under Connectors."]}):null,e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:a.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:a.code}),a.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:a.clientName})]}):null]})]})});const ye=Ue({isVerified:v,requiresDeviceHome:l,requiresWorkspaceAccess:N,homeLabel:d?A(d):null,workspaceCount:z.length}),ee=e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(Se,{id:"user-code",value:u,disabled:r==="approve"||r==="deny",onChange:o=>{k.current+=1,b(o.target.value.toUpperCase()),P(null),ge(),V(null),g(null),s(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!t.user_code})]}),H=K?e.jsx(We,{deviceName:m?.clientName??null,orgList:C,deviceHomeOrgId:R,onChange:V,orgsLoading:U,orgsError:T,onRetry:B,disabled:r!==null}):null,be=v?e.jsxs("div",{className:"space-y-5",children:[ee,e.jsx(Ee,{idPrefix:"oauth-device",clientName:m?.clientName??null,clientNote:E?"This device can run commands and control apps.":void 0,requestedScopes:D,accessLevel:G,onAccessLevelChange:I,allowNoAccess:E,disabled:r!==null,resource:m?.resource??null,logoUri:m?.logoUri??null,clientUri:m?.clientUri??null}),ue?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Can fetch tokens for your connected services."}):null,v&&l&&!K&&d?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device will live in ",A(d),".",N?" MCP access follows the device home.":""]}):null,H&&!Q?H:null]}):ee,ke=Q?e.jsxs("div",{className:"space-y-4",children:[H,l&&d?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A(d)," is always included as the device home. Additional workspaces grant MCP access only."]}):null,e.jsx(Re,{idPrefix:"oauth-device",heading:l?"Additional workspaces":void 0,allowMultiple:L,includedOrgId:l?R:null,orgList:C,selectedOrgIds:z,onWorkspaceAccessChange:ve,onSelectedOrgChange:fe,orgsLoading:U,orgsError:T,onRetry:B,disabled:r!==null})]}):void 0;return e.jsx(ne,{title:v?"Authorize application":"Connect a device",description:v?void 0:`Enter the code shown in your ${q}.`,busy:r!==null,error:w,review:be,aside:ke,below:v&&he&&O?e.jsx(Pe,{resourceOrg:O,accessLevel:G}):null,footer:v?e.jsx(re,{summary:ye,children:e.jsx(Te,{busy:r==="approve"||r==="deny"?r:null,approveDisabled:r!==null||!X,denyDisabled:r!==null,onApprove:()=>Z(!0),onDeny:()=>Z(!1)})}):e.jsx(re,{children:e.jsx(ce,{type:"button",onClick:()=>W(_),disabled:r!==null||!_,children:r==="verify"?"Verifying...":"Continue"})})})}function We({deviceName:t,orgList:i,deviceHomeOrgId:p,onChange:n,orgsLoading:u,orgsError:b,onRetry:r,disabled:g}){const w=i.find(s=>s.id===p)??null;return e.jsxs("section",{className:"space-y-2 rounded-md border bg-card p-3 text-sm",children:[e.jsx("label",{htmlFor:"oauth-device-home",className:"block font-medium text-foreground",children:"Device home"}),u?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your workspaces..."}):b?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(ce,{type:"button",variant:"outline",size:"sm",onClick:r,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("select",{id:"oauth-device-home",value:w?.id??"",disabled:g,onChange:s=>n(s.target.value),className:"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 disabled:cursor-not-allowed disabled:opacity-50",children:[w?null:e.jsx("option",{value:"",disabled:!0,children:"Choose a workspace"}),i.map(s=>e.jsx("option",{value:s.id,children:A(s)},s.id))]}),w&&!w.isPersonal?e.jsxs("p",{role:"note",className:"rounded-md bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-400",children:[t??"This device"," will be added to ",w.name,". Its Shell and Browser connections will be private to you — teammates can't use them unless you share them from the device page."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where this device is registered. Its connectors and Automations run here. A device that is already paired keeps its workspace; change it from the Devices page."})]})]})}export{qe as component};
2
- //# sourceMappingURL=device-DDl5XKvt.js.map
@@ -1,2 +0,0 @@
1
- import{aD as F,j1 as ne,j2 as U,r as v,j as e,j3 as P,B as y,al as L,j4 as C,cK as V,aU as te,i5 as z,m as Y,bj as M,hd as ae,he as ie,C as ce,hg as oe,cx as re,j5 as le,ad as de,c as me,aZ as ue,j6 as xe,j7 as he,j8 as pe,a_ as fe,aV as je,au as E,bi as T,L as I,j9 as ge,ja as ve,ba as be,jb as ye,jc as Ne,a8 as ke,dt as _e,iY as q,$ as we,c9 as Ce,dH as Se,du as $e,dv as K,ez as De,jd as O,aS as Pe}from"./index-BoqrvLHQ.js";import{C as Le}from"./connector-page-shell-an3SYLim.js";import{D as ze,R as Ae}from"./detail-page-skeleton-CPAfZLG0.js";import{S as Ee,g as Ie}from"./status-variants-SzXYYedJ.js";import{c as G,C as Re}from"./device-pin-tombstone-Dkj7hrBE.js";import{w as R}from"./workspace-label-o_QfBuCM.js";import"./list-skeleton-CH0qQBYk.js";import"./runs-k2NpbZm8.js";import"./filter-editors-DGVl9U4D.js";import"./subDays-9s9OEl5t.js";import"./runs-list-DUXRMkWN.js";import"./run-initiator-BKSgI1o0.js";import"./use-automations-DfBtVzGa.js";import"./clients-Bf7ZgGro.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(Z(s,o).map(t=>t.connector_key));return n.filter(t=>F(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function Z(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=U(),[u,p]=v.useState(null),[j,a]=v.useState(null),[f,N]=v.useState(null),[g,d]=v.useState([]),x=s.organization_id===n,b=async i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(g.map(i=>i.connectorKey)),l=Z(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[g.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&P[i.required_capability]&&P[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:P[i.required_capability]}):null]}),e.jsxs(y,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:j!==null,onClick:()=>x?void b(i):p(i.key),children:[j===i.key?e.jsx(L,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(J,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void b(i),onCancel:()=>p(null)}):null,f?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function J({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const j=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[j>0?`Moving pauses and unpins all ${j} connection${j===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(L,{className:"mr-1.5"}):null,r]}),e.jsx(y,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=V(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=G(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function H({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),j=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=j.get(d.connector_key);if(!x||!F(x)){f.push(d);continue}const b=x.required_capability??`connector:${x.key}`,k=a.get(b)??{key:b,name:x.name,connections:[]};k.name=P[b]??x.name,k.connections.push(d),a.set(b,k)}const N=Me(s,r,o),g=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(z,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(Y,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(W,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:j,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:g}):null,M(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(z,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(W,{group:{key:d,name:j.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:j,selectedConnection:h,openSettings:m},d))})]}):null]})}function W({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,j]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&j(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:j,children:[e.jsxs(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:j}=V(o,{connectionIds:[s.connection_id]}),a=t.find(g=>g.id===s.connection_id&&g.device_worker_id===n),f=m?.name??s.connector_key,N=a?G(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:re(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(Y,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>void j(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(le,{connection:a})}),e.jsx(Re,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function Oe({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=de(),m=U(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[j,a]=v.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),g=N?R(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,b=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),b()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),g]}),!r&&d.length>0?e.jsx(y,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:R(l)},l.id))]}),x?null:e.jsx(y,{size:"sm",variant:"ghost",onClick:b,children:"Cancel"})]}):null,x?e.jsx(J,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${g} to ${R(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void k(x.id),onCancel:b}):null,j?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:j}):null]})}function He({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=me(),{data:t=[],isLoading:u,isError:p,refetch:j}=ue(),a=xe(),f=he(),[N,g]=v.useState(!1),[d,x]=v.useState(!1),[b,k]=v.useState(""),l=pe(t,n),c=l&&fe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=je(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(v.useEffect(()=>{d||k($)},[$,d]),u)return e.jsx(ze,{label:"Loading device"});if(p)return e.jsx(E,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>void j(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{platform:M(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(E,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(I,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),A=D?ve(s,D,be()):void 0,Q=M(c),X=ye(c.app_version),ee=Ne(c,X),B=()=>{const _=b.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}f.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Le,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(I,{to:"/$owner/connectors",params:{owner:s},search:{},className:K,children:"Connectors"},"connectors"),...A?[e.jsx(I,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:K,children:A.name},"app")]:[]]}),icon:e.jsx(T,{platform:Q,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:b,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||B()):_.key==="Escape"&&(g(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(y,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{g(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(L,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(y,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>g(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{size:"sm",onClick:B,disabled:f.isPending,children:[f.isPending?e.jsx(L,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(y,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(y,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>g(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(c),e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{g(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${q(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${q(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Oe,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(z,{title:"Browser auth profiles",children:e.jsx(We,{profiles:S})}):null,e.jsx(z,{title:"Runs",children:e.jsx(Ae,{scope:{deviceId:i},ownerSlug:s})})]})})}function We({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Ee,{status:n.is_expired?"error":Ie(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function is(){const{owner:s,deviceId:n}=O.useParams(),{connection:o,settings:h}=O.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(He,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{is as component};
2
- //# sourceMappingURL=device._deviceId-bNhTcops.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,fU as V,Z as q,ab as ae,bq as ie,br as re,bs as ne,bt as le,bu as ce,gc as me,gF as de,gG as E,gH as p,gI as oe,gJ as k,gK as ue,B as O,c9 as U,dg as G,$ as z,dX as xe,fW as be,gL as je,aO as Z,gM as fe,a9 as ye,i as J,gN as he,r as Q,aE as Ne,aF as ge,gO as we,aH as $e,eN as Se,ea as R}from"./index-BoqrvLHQ.js";import{h as I,i as ve,F as Oe,j as L,k as Te}from"./renderer-CTKNMcXP.js";import{T as Be,a as De,b as C,c as X,d as Ee,e as M}from"./table-ZuYMOjVR.js";import{p as K,a as Fe}from"./schema-value-wjqGxXhv.js";function ee(l){return l.replace(/[^a-zA-Z0-9_-]/g,"-")}function Ie(l,r=!1){return l?Fe(l,r):r?"Pick a date and time":"Pick a date"}function P(l){if(!l)return"";const r=K(l);if(Number.isNaN(r.getTime()))return"";const s=r.getTimezoneOffset()*6e4;return new Date(r.getTime()-s).toISOString().slice(0,16)}function W(l){if(!l)return;const r=new Date(l);if(!Number.isNaN(r.getTime()))return r.toISOString()}function F(l,r){const s=r==="slug"?l.slug:l.metadata?.[r];return s==null?"":String(s)}function Y({id:l,value:r,onChange:s,readonly:a,ariaLabel:c,ariaDescribedBy:w,includeTime:N=!1,clearable:j}){const m=r?K(r):void 0,[d,u]=Q.useState(()=>P(r).slice(11));return Q.useEffect(()=>{u(P(r).slice(11))},[r]),e.jsx("div",{className:"relative",children:e.jsxs(Ne,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs(O,{id:l,"aria-label":c,"aria-describedby":w,type:"button",variant:"outline",disabled:a,className:J("w-full justify-start rounded-md bg-muted px-3 text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(we,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:Ie(r,N)})]})}),e.jsxs($e,{className:"w-auto space-y-3 p-0",align:"start",children:[e.jsx(Se,{mode:"single",selected:m,defaultMonth:m,onSelect:i=>{if(!i)return;if(!N){s(R(i,"yyyy-MM-dd"));return}const t=d||"00:00";s(W(`${R(i,"yyyy-MM-dd")}T${t}`))},initialFocus:!0}),N?e.jsxs("div",{className:"border-t p-3 pt-0",children:[e.jsx(q,{htmlFor:`${l}-time`,className:"text-xs text-muted-foreground",children:"Time"}),e.jsx(z,{id:`${l}-time`,type:"time",value:d,onChange:i=>{u(i.target.value);const t=r?P(r).slice(0,10):m?R(m,"yyyy-MM-dd"):"";t&&s(W(`${t}T${i.target.value}`))},disabled:a})]}):null,j&&r?e.jsx("div",{className:"border-t p-2",children:e.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:()=>s(void 0),children:"Clear"})}):null]})]})})}function Ae({id:l,value:r,onChange:s,readonly:a,ariaLabel:c,ariaDescribedBy:w,entityType:N,lookupField:j,numeric:m=!1,orgContext:d}){const u=o=>{if(o===void 0||o==="")return s(void 0);if(!m)return s(o);const x=Number(o);s(Number.isFinite(x)?x:o)},{data:i}=xe(N,d,{limit:be}),t=(i?.entities??[]).filter(o=>F(o,j)!==""),$=r==null?"":String(r),v=t.find(o=>F(o,j)===$);return d?a?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm",children:v?.name||$||"-"}):e.jsx(je,{contentClassName:"w-[320px]",searchPlaceholder:`Search ${L(N).toLowerCase()}...`,emptyText:`No ${N} found.`,trigger:o=>e.jsxs(O,{id:l,"aria-label":c,"aria-describedby":w,type:"button",variant:"outline",role:"combobox","aria-expanded":o,className:"w-full justify-between",children:[e.jsx("span",{className:J("truncate",!$&&"text-muted-foreground"),children:v?.name||$||`Select ${L(N).toLowerCase()}`}),e.jsx(he,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,x)=>{const n=x.trim(),f=n.length>0&&!t.some(y=>F(y,j)===n);return e.jsxs(e.Fragment,{children:[f?e.jsxs(Z,{value:`use ${n}`,onSelect:()=>{u(n),o()},children:[e.jsx(fe,{className:"mr-2 h-3.5 w-3.5 opacity-60"}),e.jsxs("span",{className:"truncate",children:["Use ",e.jsx("span",{className:"font-medium",children:n})]})]}):null,t.map(y=>{const h=F(y,j),T=h===$;return e.jsxs(Z,{value:`${y.name} ${y.slug} ${y.entity_type} ${h}`,onSelect:()=>{u(h||void 0),o()},children:[e.jsx(ye,{className:J("mr-2 h-4 w-4",T?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate",children:y.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:y.slug})]})]},`${y.id}-${h}`)})]})}}):e.jsx(z,{id:l,"aria-label":c,"aria-describedby":w,type:m?"number":"text",value:$,onChange:o=>u(o.target.value||void 0),disabled:a})}function se({fieldPath:l,fieldKey:r,prop:s,value:a,onChange:c,isRequired:w,readonly:N,orgContext:j,ariaLabel:m,helpId:d}){const u=I(r,s),i=ee(l),t=N||s.readOnly===!0,$=s.type==="object"||!!s.properties,v=s.type==="array"&&!!s.items&&(s.items?.type==="object"||!!s.items?.properties),o=s.type==="array"&&!!s.items&&(s.items?.type==="string"||s.items?.type==="number"||s.items?.type==="integer"||s.items?.type==="boolean");if(s.type==="boolean")return e.jsx(ae,{id:i,"aria-label":m,"aria-describedby":d,checked:a??!1,onCheckedChange:n=>c(n),disabled:t});let x;if(s.enum&&Array.isArray(s.enum))x=e.jsxs(ie,{value:a==null?"":String(a),onValueChange:n=>c(n===""?void 0:s.type==="number"||s.type==="integer"?Number(n):n),disabled:t,children:[e.jsx(re,{id:i,"aria-label":m,"aria-describedby":d,children:e.jsx(ne,{placeholder:`Select ${u.toLowerCase()}`})}),e.jsx(le,{children:s.enum.map(n=>{const f=String(n);return e.jsx(ce,{value:f,children:me(s,n)??L(f)},f)})})]});else if(s["x-link-entity-type"])x=e.jsx(Ae,{id:i,value:a,onChange:c,readonly:t,ariaLabel:m,ariaDescribedBy:d,entityType:s["x-link-entity-type"],lookupField:s["x-link-lookup-field"]||"slug",numeric:s.type==="number"||s.type==="integer",orgContext:j});else if(s.type==="number"||s.type==="integer")x=e.jsx(de,{id:i,ariaLabel:m,ariaDescribedBy:d,value:a,onChange:c,integer:s.type==="integer",placeholder:`Enter ${u.toLowerCase()}`,readOnly:t});else if($){const n=V(s.properties),f=new Set(s.required??[]),y=E(a)?a:{};x=Object.keys(s.properties??{}).length===0||!E(a)&&a!==void 0&&a!==null?e.jsx(p,{id:i,value:a,ariaLabel:`${u} JSON object`,ariaDescribedBy:d,readOnly:t,onChange:c}):e.jsx("fieldset",{"aria-label":m,"aria-labelledby":m?void 0:`${i}-label`,"aria-describedby":d,className:"space-y-3 rounded-md border p-3",children:n.map(([h,T])=>e.jsx(te,{fieldPath:`${l}.${h}`,fieldKey:h,prop:T,value:y[h],onChange:S=>{const b={...y};S===void 0?delete b[h]:b[h]=S,c(b)},isRequired:f.has(h),readonly:t,orgContext:j},h))})}else if(o)x=a!=null&&!oe(a)?e.jsx(k,{id:i,value:a,ariaLabel:`${u} JSON array`,ariaDescribedBy:d,readOnly:t,itemType:s.items?.type,itemEnum:s.items?.enum,minItems:s.minItems,maxItems:s.maxItems,onChange:c}):e.jsx(ue,{id:i,value:a,itemType:s.items?.type,itemEnum:s.items?.enum,minItems:s.minItems,maxItems:s.maxItems,ariaLabel:m,ariaDescribedBy:d,readOnly:t,showHelp:!m,onChange:c});else if(v&&s.items){const n=Array.isArray(a)?a:[],f=V(s.items.properties),y=new Set(s.items.required??[]),h=s.maxItems===void 0||n.length<s.maxItems,T=s.minItems===void 0||n.length>s.minItems;x=!Array.isArray(a)&&a!==void 0&&a!==null||Object.keys(s.items.properties??{}).length>0&&n.some(S=>!E(S))?e.jsx(k,{id:i,value:a,ariaLabel:`${u} JSON array`,ariaDescribedBy:d,readOnly:t,itemType:"object",minItems:s.minItems,maxItems:s.maxItems,onChange:c}):Object.keys(s.items.properties??{}).length===0?e.jsxs("fieldset",{"aria-label":m,"aria-labelledby":m?void 0:`${i}-label`,"aria-describedby":d,className:"space-y-3",children:[n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No rows"}):n.map((S,b)=>e.jsxs("fieldset",{className:"space-y-2 rounded-md border p-3",children:[e.jsxs("legend",{className:"px-1 text-xs font-medium text-muted-foreground",children:["Row ",b+1]}),e.jsx(p,{id:`${i}-${b}-json`,value:S,ariaLabel:`${u} row ${b+1} JSON object`,readOnly:t,onChange:B=>{const g=[...n];g[b]=B,c(g)}}),t?null:e.jsxs(O,{type:"button",variant:"ghost",size:"sm","aria-label":`Remove row ${b+1}`,disabled:!T,onClick:()=>c(n.filter((B,g)=>g!==b)),children:[e.jsx(U,{className:"mr-1.5 h-4 w-4"}),"Remove row"]})]},`${l}.${b}`)),t?null:e.jsxs(O,{type:"button",variant:"outline",size:"sm",disabled:!h,onClick:()=>c([...n,{}]),children:[e.jsx(G,{className:"mr-1.5 h-4 w-4"}),"Add row"]})]}):e.jsxs("fieldset",{"aria-label":m,"aria-labelledby":m?void 0:`${i}-label`,"aria-describedby":d,className:"space-y-3",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Be,{children:[e.jsx(De,{children:e.jsxs(C,{children:[f.map(([S,b])=>e.jsxs(X,{children:[I(S,b),y.has(S)?e.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]},S)),t?null:e.jsx(X,{className:"w-12"})]})}),e.jsx(Ee,{children:n.length===0?e.jsx(C,{children:e.jsx(M,{colSpan:f.length+(t?0:1),className:"text-sm text-muted-foreground",children:"No rows"})}):n.map((S,b)=>{const B=E(S)?S:{};return e.jsxs(C,{children:[f.map(([g,D])=>e.jsx(M,{className:"align-top",children:e.jsx(se,{fieldPath:`${l}.${b}.${g}`,fieldKey:g,prop:D,ariaLabel:I(g,D),value:B[g],onChange:_=>{const H=[...n],A={...B};_===void 0?delete A[g]:A[g]=_,H[b]=A,c(H)},isRequired:y.has(g),readonly:t,orgContext:j})},g)),t?null:e.jsx(M,{className:"align-top",children:e.jsx(O,{type:"button",variant:"ghost",size:"icon","aria-label":`Remove row ${b+1}`,disabled:!T,onClick:()=>c(n.filter((g,D)=>D!==b)),children:e.jsx(U,{className:"h-4 w-4"})})})]},`${l}.${b}`)})})]})}),t?null:e.jsxs(O,{type:"button",variant:"outline",size:"sm",disabled:!h,onClick:()=>c([...n,{}]),children:[e.jsx(G,{className:"mr-1.5 h-4 w-4"}),"Add row"]})]})}else if(s.type==="array")x=e.jsx(k,{id:i,value:a,ariaLabel:`${u} JSON array`,ariaDescribedBy:d,readOnly:t,itemType:s.items?.type,itemEnum:s.items?.enum,minItems:s.minItems,maxItems:s.maxItems,onChange:c});else if(s.format==="date")x=e.jsx(Y,{id:i,value:typeof a=="string"?a:void 0,onChange:c,readonly:t,ariaLabel:m,ariaDescribedBy:d,clearable:!w});else if(s.format==="date-time")x=e.jsx(Y,{id:i,value:typeof a=="string"?a:void 0,onChange:c,readonly:t,ariaLabel:m,ariaDescribedBy:d,includeTime:!0,clearable:!w});else{const n=s.format==="uri"||s.format==="url";x=e.jsx(z,{id:i,"aria-label":m,"aria-describedby":d,type:n?"url":"text",value:a??"",onChange:f=>c(f.target.value||void 0),placeholder:n?"https://example.com":`Enter ${u.toLowerCase()}`,disabled:t})}return x}function te({fieldPath:l,fieldKey:r,prop:s,value:a,onChange:c,isRequired:w,readonly:N,control:j,orgContext:m,customControl:d}){const u=I(r,s),i=ve(s),t=ee(l),$=i?`${t}-description`:void 0,v=i?e.jsx("p",{id:$,className:"text-xs text-muted-foreground",children:i}):null,o=j?e.jsx(Oe,{control:j}):null,x=d??e.jsx(se,{fieldPath:l,fieldKey:r,prop:s,value:a,onChange:c,isRequired:w,readonly:N,orgContext:m,helpId:$});if(s.type==="boolean"){const f=e.jsxs("div",{className:"flex items-center space-x-2 py-1",children:[x,e.jsxs(q,{htmlFor:t,className:"flex items-center gap-1.5 font-normal",children:[u,o]})]});return v?e.jsxs("div",{className:"space-y-1",children:[f,v]}):f}const n=s.type==="object"||!!s.properties||s.type==="array"&&!!s.items&&(s.items?.type==="object"||!!s.items?.properties);return e.jsxs("div",{className:"space-y-1.5",children:[n?e.jsxs("p",{id:`${t}-label`,className:"flex items-center gap-1.5 text-sm font-medium",children:[e.jsxs("span",{children:[u,w?e.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]}),o]}):e.jsxs(q,{htmlFor:t,className:"flex items-center gap-1.5",children:[e.jsxs("span",{children:[u,w?e.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]}),o]}),x,v]})}function Pe(l){const r={};for(const[s,a]of Object.entries(l)){const c=Te(a);c!==void 0&&(r[s]=c)}return r}function Ve({schema:l,values:r,onValuesChange:s,readonly:a=!1,fieldControls:c,orgContext:w,renderControl:N}){const j=l,m=j?.properties,d=new Set(j?.required??[]),u=(i,t)=>{s({...r,[i]:t})};return!m||Object.keys(m).length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No additional fields required for this entity type."}):e.jsx("div",{className:"space-y-4",children:V(m).map(([i,t])=>"x-measure"in t||"x-dimension"in t?null:e.jsx(te,{fieldPath:i,fieldKey:i,prop:t,value:r[i],onChange:$=>u(i,$),isRequired:d.has(i),readonly:a,control:c?.[i],orgContext:w,customControl:N?.(i,t,r[i])},i))})}export{Ve as D,se as S,Pe as c};
2
- //# sourceMappingURL=dynamic-schema-form-CRyUchXo.js.map
@@ -1,2 +0,0 @@
1
- import{eb as Re,r as E,c3 as Ee,k5 as N,gv as Fe,eU as se,j as e,B as S,u as Y,j_ as De,m as ae,dm as fe,V as Le,c as xe,b as Ce,c4 as B,n as Be,w as Pe,eW as Q,cJ as Ve,eE as Te,k6 as $e,dH as Ie,dz as ne,cg as ie,ci as oe,gb as Oe,gz as Me,dx as Ae,hI as ze,hJ as Ue,hK as Ke,hL as He,hM as We,k7 as qe,c8 as Ge,Z as W,$ as re,fj as Je,a8 as Qe,gt as le,fu as q,du as Xe,L as G,dv as J}from"./index-BoqrvLHQ.js";import{N as Ye,d as Ze,f as et,g as tt,S as st,h as at}from"./entity-pages-_nuesgnp.js";import{V as nt,R as it}from"./view-card-DiHWlypr.js";import{D as ot}from"./dynamic-schema-form-CRyUchXo.js";import{r as rt,V as lt}from"./views-access-required-HA-PiOwA.js";import{V as ce,M as ct,a as dt}from"./missing-view-xT0B-f5z.js";import{V as ut}from"./view-param-filters-DGKxSr7r.js";import{o as mt,k as X,h as ht,q as de,c as ge,R as ve,r as pt,d as ft}from"./renderer-CTKNMcXP.js";import"./table-ZuYMOjVR.js";import{a as xt}from"./source-record-panels-BMut9YIA.js";import{r as gt,R as ue,b as vt}from"./events-feed-DcKTkJVe.js";import{a as yt}from"./record-session-BrM9cdXu.js";import"./schema-value-wjqGxXhv.js";import"./filter-editors-DGVl9U4D.js";import"./subDays-9s9OEl5t.js";import"./runs-k2NpbZm8.js";import"./activity-route-location-sLvKaSCa.js";import"./event-kind-options-fHAIXu24.js";import"./clients-Bf7ZgGro.js";import"./client-activity-scopes-Aqdo6Pdr.js";import"./client-rows-Dd5YV8vn.js";import"./run-initiator-BKSgI1o0.js";import"./list-skeleton-CH0qQBYk.js";import"./use-automations-DfBtVzGa.js";import"./agent-loading-shells-BLNHIy-r.js";import"./member-scope-gate-Cxg2zGQT.js";import"./app-bridge-B-L0rGz9.js";import"./card-CAPpY9P5.js";import"./definition-comparison-D_qP25jR.js";import"./json-diff-OjtREegr.js";import"./code-editor-z1Sy_hiX.js";import"./index-Vcq4gwWv.js";import"./copy-button-Xhh7ZnjO.js";import"./device-automation-Dp3faMvp.js";function jt(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const i=!!(t.condition??!0),n=t.blockerFn;return{shouldBlockFn:async()=>i&&n!==void 0?await n():i,enableBeforeUnload:i,withResolver:n===void 0}}function bt(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:c=!1}=jt(t),l=Re(),{history:o}=l,[u,x]=E.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return E.useEffect(()=>{const p=async f=>{function r(y){const b=l.parseLocation(y),v=l.getMatchedRoutes(b.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:b.pathname,pathname:b.pathname,params:v.routeParams,search:l.options.parseSearch(y.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:b.pathname,params:v.routeParams,search:l.options.parseSearch(y.search)}}const m=r(f.currentLocation),d=r(f.nextLocation);if(m.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const h=await i({action:f.action,current:m,next:d});if(!c)return h;if(!h)return!1;const _=await new Promise(y=>{x({status:"blocked",current:m,next:d,action:f.action,proceed:()=>y(!1),reset:()=>y(!0)})});return x({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),_};return a?void 0:o.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,c,o,l]),u}function U(t,s){return se(X(t))===se(X(s))}function kt(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))U(t[n],s[n])||(i[n]=X(t[n])??null);return Object.keys(i).length>0?i:void 0}function _t(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!U(t[i],s[i])}catch{return!0}})}function me(t,s){return{name:t.name,slug:t.slug,metadata:mt(t.metadata??{},s)}}function wt(t,s,i){const n=new Set(i),a={},c={},l=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const o of l){const u=n.has(o),x=u?t.values.metadata[o]:t.baseline.metadata[o],p=U(x,s.metadata[o])?x:s.metadata[o];p!==void 0&&(a[o]=p);let f=!1;if(!u)try{f=!U(t.values.metadata[o],t.baseline.metadata[o])}catch{f=!0}const r=f?t.values.metadata[o]:p;r!==void 0&&(c[o]=r)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function St({entity:t,schema:s,orgContext:i}){const n=E.useMemo(()=>me(t,s),[t,s]),a=Ee(N(t),n,s),c=Fe(i),{values:l,baseline:o,commit:u}=a,x=E.useMemo(()=>_t(l.metadata,o.metadata),[l.metadata,o.metadata]),p=l.name!==o.name||l.slug!==o.slug,f=E.useCallback((m,d)=>a.setValues(h=>({...h,metadata:{...h.metadata,[m]:d}})),[a.setValues]),r=async({note:m}={})=>{if(typeof t.id!="number")throw new Error("Source records are read-only");if(!a.canSubmit)return null;const d=kt(l.metadata,o.metadata),h=l.name.trim()!==o.name.trim();if(!d&&!p)return null;const _=await c.mutateAsync({entityId:t.id,name:h?l.name.trim():void 0,slug:l.slug,metadata:d,field_note:d&&m?.trim()||void 0}),y=me(_.entity,s);return u(b=>wt(b,y,Object.keys(d??{})),y),{held:_.blocked_fields??[],approvalUrl:_.approval_url}};return{values:l,baseline:o,revision:a.revision,setValues:a.setValues,setMetadataField:f,reset:a.reset,save:r,saving:c.isPending,dirtyKeys:x,identityDirty:p,isDirty:p||x.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const Nt=3,Rt=50;function ye(t){const s=E.useRef(null);return E.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function V({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function Et({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:c=!1}){const l=Y(),o=ye(a),{data:u,isLoading:x,isError:p,refetch:f}=De(t,n,{limit:Rt});if(t===void 0)return null;if(x)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx(ae,{className:"h-4 w-24"}),e.jsx(ae,{className:"h-6 w-full rounded-md"})]});if(p||!u)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void f(),children:"Retry"})]})]});if(u.countsByType.length===0&&!u.hasMore&&!u.failures?.length)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const r=u.countsByType.flatMap(m=>{const d=m.count===1?u.rows.find(h=>h.relationship_type_slug===m.relationship_type_slug):void 0;return d?[gt(d,m.relationship_type_name)]:[m.relationship_type_name,String(m.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx(ue,{count:u.failures?.length??0,onRetry:()=>void f()}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:r.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx(ue,{count:u.failures?.length??0,onRetry:()=>void f()}),u.hasMore&&l?e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>l.open({href:"",key:`record-links:${t}`,title:"Linked records",recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,label:"Linked records"}}),children:"Browse linked records"}):null,u.countsByType.map(r=>{const m=u.rows.filter(h=>h.relationship_type_slug===r.relationship_type_slug).slice(0,Nt),d=r.count>m.length;return e.jsxs("div",{className:"space-y-1 text-sm",children:[d||m.length===0?e.jsxs("p",{className:"text-muted-foreground",children:[r.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",r.count,u.countsScope==="page"?" shown":""]}):null]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1",children:[m.map(h=>e.jsx(vt,{row:h,label:r.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},h.id)),d&&l?e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>l.open({href:"",key:`record-links:${t}:${r.relationship_type_slug}`,title:`${r.relationship_type_name} · ${r.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,relationshipType:r.relationship_type_slug,label:r.relationship_type_name}}),children:["Show all ",r.count]}):null]})]},r.relationship_type_slug)})]})}function Ft({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,c]=E.useState(n),l=ye(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(V,{headingRef:l,children:"Linked"}),a?e.jsx(xt,{record:t,ownerSlug:s,orgContext:i}):e.jsx(S,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const Dt="$name";function je({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const i=s?.properties??{},n=t.held.map(a=>a===Dt?"Name":ht(a,i[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[n.join(", ")," ",n.length===1?"needs":"need"," approval before ",n.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}function Lt({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=Y(),c=`${i}${fe(t.key)}`;return e.jsx(nt,{view:t,orgSlug:s,scope:n,open:a?()=>a.open({href:c,title:t.name}):void 0})}function Ct({recordUrl:t,dirty:s,onDiscard:i}){const n=bt({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${fe("")}`)}),a=n.status==="blocked";return e.jsx(ze,{open:a,onOpenChange:c=>{!c&&a&&n.reset()},children:e.jsxs(Ue,{className:"max-w-sm",children:[e.jsxs(Ke,{children:[e.jsx(He,{children:"Discard unsaved changes?"}),e.jsx(We,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(S,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const he=6;function Bt({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:c,isTypeLoading:l,record:o,canEdit:u,editing:x,onEditingChange:p,outcome:f,onSaved:r,formId:m,fieldLimit:d,onDeleted:h}){const _=x&&u,y=Y(),b={entity:{id:N(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:o,editing:_};yt(b);const v=y?.item?.recordField,D={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:o.dirtyKeys,openField:y?C=>y.open(rt(b,C.key)):void 0,openFieldKey:v?.entityId===N(t)?v.field:void 0},L=e.jsx(Ct,{recordUrl:n,dirty:_&&o.isDirty,onDiscard:()=>{o.reset(),p(!1)}});if(l)return e.jsx(Ae,{rows:6});if(_)return e.jsxs(e.Fragment,{children:[L,e.jsx(Pt,{formId:m,entity:t,entityTypeName:c,schema:a,record:o,orgContext:i,renderControl:(C,P,F)=>pt(P)?e.jsx(ft,{field:{key:C,prop:P},value:F,context:D}):void 0,onSaved:r,onDeleted:h,onDone:()=>p(!1)})]});const R=ge(o.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{outcome:f,schema:a}),e.jsx(ve,{fields:R,fieldLimit:d,values:o.values.metadata,context:D})]})}function Pt({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:c,renderControl:l,onSaved:o,onDeleted:u,onDone:x}){const p=qe(),f=s.field_controls,{name:r,slug:m,metadata:d}=a.values,h=g=>a.setValues(j=>({...j,name:g})),_=g=>a.setValues(j=>({...j,slug:g})),y=g=>a.setValues(j=>({...j,metadata:g})),[b,v]=B(N(s),""),[D,L]=B(N(s),null),[R,C]=B(N(s),null),[P,F]=B(N(s),!1),[w,T]=B(N(s),null),$=a.dirtyKeys.length>0,M=async g=>{if(g.preventDefault(),!!a.canSubmit){if(L(null),!r.trim()){L("Name is required");return}try{const j=await a.save({note:b});C(j),o(j),v(""),j?.held.length||x()}catch(j){L(j instanceof Error?j.message:"Failed to update entity")}}},K=async()=>{T(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),F(!1),u?.()}catch(g){T(g instanceof Error?g.message:"Failed to delete entity")}},A=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:M,className:"space-y-4",children:[e.jsx(Ge,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(W,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(re,{id:"sidebar-name",value:r,onChange:g=>h(g.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(W,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(re,{id:"sidebar-slug",value:m,onChange:g=>_(g.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(st,{}),e.jsx(ot,{schema:a.revision,values:d,onValuesChange:y,fieldControls:f,orgContext:c,renderControl:l})]}),$&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(W,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Je,{id:"sidebar-correction-note",value:b,onChange:g=>v(g.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),D&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}),e.jsx(je,{outcome:R,schema:n}),P?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Qe,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),A&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",A,". This cannot be easily undone."]})]})]}),w&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:w}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>{F(!1),T(null)},children:"Cancel"}),e.jsx(S,{type:"button",variant:"destructive",size:"sm",onClick:K,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>F(!0),children:"Delete"})})]})}function be(t,s){const i=new Set(t.measure_columns??[]),n=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&!Oe(n[a])&&n[a]?.const===void 0).map(a=>({key:a,prop:n[a]??{},label:n[a]?.["x-table-label"]??(i.has(a)?a:Me(a.replace(/_/g," "))),numeric:i.has(a)}))}function Vt({entity:t,schema:s,ownerSlug:i,orgContext:n,fieldLimit:a}){const c=be(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(ve,{fields:c,fieldLimit:a,values:t.metadata??{},context:{ownerSlug:i,orgContext:n}})]})}const pe="owletto:record-details-expanded";function Tt(){const[t,s]=E.useState(()=>{try{return window.localStorage.getItem(pe)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(pe,n?"1":"0")}catch{}}]}function $t({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:c}){const l=Le({strict:!1}),o=xe(),u=E.useRef(null),x=Ce(u,Ye),[p,f]=Tt(),[r,m]=B(N(s),!1),d={slug:t.slug,organizationId:t.id},{isMember:h,isPublic:_,isLoading:y}=Be(t.slug),b=h||_,v=Pe({...d,organizationId:h?t.id:null}),{data:D,isLoading:L}=Q(s.entity_type,d),R=D?.metadata_schema,{isAdmin:C,isLoading:P}=Ve(h?d.organizationId:void 0),F=h&&C&&!P&&!s.is_derived,w=St({entity:s,schema:R,orgContext:d}),[T,$]=B(N(s),null),M=`record-form-${s.id}`,K=r&&F,A=b?v.data??[]:[],g=Te(A,{type:s.entity_type,id:N(s)}),j=$e(g,n),z=!n&&l.tab==="relationships",ke=k=>void o({...ne,search:H=>ie(H,k),replace:!0}),Z={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},I=x&&!p&&!r&&!z,ee=s.is_derived?de(be(s,R),s.metadata??{}).length:de(ge(w.revision),w.values.metadata).length,te=I?he:void 0,_e=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(Vt,{entity:s,schema:R,ownerSlug:t.slug,orgContext:d,fieldLimit:te}),e.jsx(Ft,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:z})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bt,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:i,schema:R,entityTypeName:D?.name,isTypeLoading:L,record:w,canEdit:F,editing:r,onEditingChange:m,outcome:T,onSaved:$,formId:M,fieldLimit:te,onDeleted:c}),e.jsx(Et,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:z,collapsed:I})]}),x&&!r&&!z?e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!I,onClick:()=>f(I),children:I?ee>he?`Show all ${ee} fields`:"Show all details":"Show fewer"}):null]}),we=k=>e.jsx(et,{rootRef:u,narrow:x,details:_e,summary:e.jsx(tt,{entity:s,schema:R,context:{ownerSlug:t.slug,orgContext:d}}),children:k}),Se=K?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>{w.reset(),$(null),m(!1)},children:"Cancel"}),e.jsx(S,{type:"submit",form:M,size:"sm",disabled:!w.canSubmit||!w.isDirty||w.saving||!w.values.name.trim(),children:w.saving?"Saving...":"Save"})]}):F&&!L?e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{$(null),m(!0)},children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),"Edit"]}):null,O=k=>e.jsx(Ze,{entity:s,owner:t.slug,schema:R,title:a??null,actions:Se,layout:"content",children:k});if(n&&!b)return O(y?null:e.jsx(lt,{}));if(n&&v.data===void 0)return O(v.isError?e.jsx(ce,{onRetry:()=>void v.refetch()}):null);if(j.kind==="missing")return O(e.jsx(ct,{viewKey:j.key,backTo:i,backLabel:`Back to ${s.name}`}));if(j.kind==="view"){const{view:k}=j;return O(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(ut,{decls:k.params,params:oe(l),onParamsChange:H=>void o({...ne,search:Ne=>ie(Ne,H)})}),e.jsx(dt,{orgSlug:t.slug,viewKey:k.key,scope:Z,params:oe(l),onParamsChange:ke,paramDecls:k.params,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return O(we(e.jsxs("div",{className:"min-w-0 space-y-4",children:[b&&v.isError&&e.jsx(ce,{onRetry:()=>void v.refetch()}),g.map(k=>e.jsx(Lt,{view:k,orgSlug:t.slug,recordUrl:i,scope:Z},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(it,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function It(t){return t?.trim()?t:void 0}function ys({namespace:t,path:s,entity:i,viewKey:n}){const a=xe(),{data:c}=Q(i.entity_type,{slug:t.slug}),l=s[0]?.entity_type??i.entity_type,{data:o}=Q(l,{slug:t.slug}),u=It(c?.icon),x=s.map(r=>({entity_type:r.entity_type,slug:r.slug})),p=`/${t.slug}/${le(i.entity_type)}`,f=q(t.slug,x);return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx(Xe,{crumbs:[...l==="$member"?[]:[e.jsx(G,{to:"/$owner",params:{owner:t.slug},search:{section:"entity-type"},className:J,children:"Entity types"},"home")],e.jsx(G,{to:`/${t.slug}/${le(l)}`,className:J,children:l==="$member"?"Team":o?.name??l},"type"),...s.slice(0,-1).map((r,m)=>e.jsx(G,{to:q(t.slug,x.slice(0,m+1)),className:J,children:r.name},r.id))],current:i.name}),e.jsx($t,{namespace:t,entity:i,recordUrl:f,viewKey:n,title:e.jsx(at,{entity:i,schema:c?.metadata_schema,icon:u}),onDeleted:()=>{const r=s.slice(0,-1);r.length>0?a({to:q(t.slug,r)}):a({to:p})}})]})}export{ys as EntityPage};
2
- //# sourceMappingURL=entity-page-BOOL_vy3.js.map
@@ -1,2 +0,0 @@
1
- import{r as x,j as e,bz as ue,i as K,aE as me,aF as xe,B as F,gB as he,aH as pe,cP as ge,fU as ne,gz as T,gb as fe,dO as A,a7 as Z,L as P,fu as je,b as ve,m as E}from"./index-BoqrvLHQ.js";import{p as _,n as be,e as re,b as ye,g as Ne,f as q,R as we,c as Se,d as _e}from"./renderer-CTKNMcXP.js";import{S as J}from"./schema-value-wjqGxXhv.js";import{T as ke,a as Ce,b as $,c as Y,d as Ee,e as H}from"./table-ZuYMOjVR.js";var Re="Separator",ee="horizontal",Le=["horizontal","vertical"],ae=x.forwardRef((t,s)=>{const{decorative:n,orientation:l=ee,...o}=t,a=Me(l)?l:ee,h=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return e.jsx(ue.div,{"data-orientation":a,...h,...o,ref:s})});ae.displayName=Re;function Me(t){return Le.includes(t)}var oe=ae;const Pe=x.forwardRef(({className:t,orientation:s="horizontal",decorative:n=!0,...l},o)=>e.jsx(oe,{ref:o,decorative:n,orientation:s,className:K("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...l}));Pe.displayName=oe.displayName;function Ae({choices:t,visible:s,onChange:n}){return e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(F,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(pe,{align:"end",className:"max-h-80 overflow-y-auto p-3",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Visible columns"}),t.map(l=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 py-1.5 text-sm",children:[e.jsx("input",{type:"checkbox",checked:!s||s.includes(l.field),onChange:o=>{const a=s??t.map(c=>c.field);n(o.target.checked?[...a,l.field]:a.filter(c=>c!==l.field))}}),l.label]},l.field))]})]})}function Fe({direction:t}){return t?e.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("title",{children:t==="asc"?"Sort ascending":"Sort descending"}),t==="asc"?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})]}):e.jsxs("svg",{className:"h-4 w-4 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("title",{children:"Sort"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})]})}function te(t,s){const n=t?.properties;if(n)return Object.entries(n).find(([,l])=>l[s])?.[0]}function Te(t){const s=t.trim(),n=s.split(/[\s._@/-]+/).filter(Boolean),l=n.length>=2?`${n[0][0]}${n[1][0]}`:(n[0]??s).slice(0,2);let o=0;for(let a=0;a<s.length;a++)o=o*31+s.charCodeAt(a)>>>0;return{initials:l.toUpperCase()||"?",hue:o%360}}function Oe(t){const[s,n]=x.useState();return x.useEffect(()=>{if(!t||!globalThis.crypto?.subtle){n(void 0);return}let l=!1;const o=t.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(o)).then(a=>{l||n(Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join(""))}),()=>{l=!0}},[t]),s?`https://www.gravatar.com/avatar/${s}?d=identicon&s=80`:void 0}function le({metadata:t,metadataSchema:s,name:n,typeIcon:l,className:o="h-6 w-6",iconClassName:a="h-5 w-5",initialsFallback:c=!1}){const h=te(s,"x-image"),j=te(s,"x-email"),y=h&&t?.[h]||void 0,v=j&&t?.[j]||void 0,N=Oe(y?void 0:v),w=y||N,[k,R]=x.useState(!1);if(x.useEffect(()=>{R(!1)},[w]),w&&!k)return e.jsx("img",{src:w,alt:n,referrerPolicy:"no-referrer",onError:()=>R(!0),className:K("rounded-full object-cover border border-border",o)});if(c){const L=n.trim()||v||ze(t,s)||n,{initials:O,hue:z}=Te(L);return e.jsx("span",{role:"img","aria-label":n,className:K("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",o),style:{background:`oklch(0.55 0.13 ${z})`,fontSize:"0.85em"},children:O})}return e.jsx(ge,{icon:l,className:a})}function ze(t,s){if(!t)return;const n=s?.properties,l=["email","handle","username","login","github","x_handle","slug"],o=Object.keys(n||t);for(const a of o)if(l.includes(a.toLowerCase())){const c=t[a];if(typeof c=="string"&&c.trim())return c}}function S({column:t,children:s,alignRight:n=!1}){return e.jsxs("button",{type:"button",className:`flex items-center gap-1.5 whitespace-nowrap text-left transition-colors hover:text-foreground [&>svg]:shrink-0${n?" ml-auto":""}`,onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[s,e.jsx(Fe,{direction:t.getIsSorted()})]})}function se(t,s,n){const l=ne(t?.properties).filter(([a,c])=>(!s||a!=="name")&&!c["x-image"]&&c["x-table-column"]===!0);if(l.length)return l.map(([a,c])=>({field:a,label:c["x-table-label"]??T(a.replaceAll("_"," "))}));if(!s)return[];const o=n.find(a=>Object.keys(_(a.metadata)).length>0);return Object.keys(_(o?.metadata)).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&!fe(t?.properties?.[a])).map(a=>({field:a,label:T(a.replaceAll("_"," "))}))}function Ie(t){return t.some(s=>Object.hasOwn(_(s.metadata),"name"))}function Be(t,s){return A(t,re(s))}function $e(t){return`${t.entityType}:${t.lookupField}`}const He=new Set(["stage","category","round_type","investor_type"]);function Ke(t,s){const n=t.toLowerCase();return n==="mrr"||n==="arr"||n==="revenue"||n==="valuation"||n==="funding_raised"||n==="fund_size"||n.endsWith("_usd")||s.description?.toLowerCase().includes("usd")===!0}function Ue(t,s){if(Ke(t,s))return"currency";if(He.has(t)||t.endsWith("_slug"))return"enum"}function Ve({entities:t,owner:s,schema:n,entityTypeIcon:l,isDerived:o,measureColumns:a,linkedEntityLookups:c,hasAnyParents:h,sorting:j,onSortingChange:y,visibleColumns:v,columnChoices:N,onVisibleColumnsChange:w,page:k,pageSize:R,totalCount:L,hasMore:O,pageTitle:z,onPrevPage:ie,onNextPage:ce}){const M=N?.length&&w?e.jsx(Ae,{choices:N,visible:v,onChange:w}):null,f=n?.properties,U=!o||Ie(t),V=x.useMemo(()=>f?Object.fromEntries(Object.entries(f).flatMap(([i,r])=>r["x-link-entity-type"]?[[i,{entityType:r["x-link-entity-type"],lookupField:r["x-link-lookup-field"]||"slug"}]]:[])):{},[f]),C=x.useMemo(()=>f?se({properties:f},o,[]).map(({field:r})=>[r,f[r]]).map(([r,u])=>{const m=V[r],d=m?c[$e(m)]:void 0;return{id:o?r:`meta_${r}`,accessorFn:p=>{const g=_(p.metadata);return be(g[r],u.enum)},header:({column:p})=>{const g=u["x-table-label"]||u.title||u.description||T(r.replace(/_/g," "));return o?e.jsx(S,{column:p,children:g}):g},cell:({getValue:p})=>e.jsx(J,{value:p(),prop:u,format:Ue(r,u),className:"text-muted-foreground",resolveLink:d?g=>{const b=d[g];return b?{label:b.name,to:A(s,[{entity_type:b.entity_type,slug:b.slug}])}:void 0}:void 0})}}):[],[o,V,c,s,f]),W=x.useMemo(()=>new Set(a),[a]),I=x.useMemo(()=>!o||C.length>0?[]:se({properties:f},!0,t).map(({field:r})=>r).map(r=>{const u=W.has(r);return{id:r,accessorFn:m=>_(m.metadata)[r],header:({column:m})=>e.jsxs(S,{column:m,children:[u?r:T(r.replace(/_/g," ")),u&&e.jsx(Z,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:m})=>e.jsx(J,{value:m(),prop:f?.[r],className:u?"tabular-nums":"text-muted-foreground"}),meta:u?{align:"right"}:void 0}}),[o,C,t,W,f]),D=x.useMemo(()=>{const i=n?.["x-table-relationships"];return!i||i.length===0?[]:i.map(r=>({id:`rel_${r.relationship_type}`,accessorFn:u=>u.relationships?.[r.relationship_type]??[],header:r.label,cell:({getValue:u})=>{const m=u();return!m||m.length===0?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:m.map((d,p)=>{const g=A(s,[{entity_type:d.entity_type,slug:d.slug}]);return e.jsxs("span",{children:[e.jsx(P,{to:g,className:"text-primary hover:underline",onClick:b=>b.stopPropagation(),children:d.name}),p<m.length-1&&","]},d.id)})})}}))},[s,n]),G=x.useMemo(()=>h||t.some(r=>r.parent_name&&r.parent_slug&&r.parent_entity_type)?[{id:"parent",accessorFn:r=>r.parent_name,header:"Parent",cell:({row:r})=>{if(!r.original.parent_name||!r.original.parent_slug||!r.original.parent_entity_type)return e.jsx("span",{className:"text-muted-foreground",children:"-"});const u=A(s,[{entity_type:r.original.parent_entity_type,slug:r.original.parent_slug}]);return e.jsx(P,{to:u,className:"text-primary hover:underline",children:r.original.parent_name})}}]:[],[t,h,s]),Q=x.useMemo(()=>{const i=[],r=t.some(d=>(d.total_content??0)>0),u=t.some(d=>(d.active_connections??0)>0),m=t.some(d=>(d.automations_count??0)>0);return r&&i.push({accessorKey:"total_content",header:({column:d})=>e.jsx(S,{column:d,alignRight:!0,children:"Activity"}),cell:({row:d,getValue:p})=>{const g=p()??0;if(g===0)return e.jsx("span",{className:"tabular-nums",children:"0"});const b=re(d.original);return e.jsx(P,{to:je(s,b),className:"tabular-nums hover:underline",children:g})},meta:{align:"right"}}),u&&i.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:d})=>{const p=d();return p&&p>0?e.jsxs(Z,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[p," active"]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),m&&i.push({accessorKey:"automations_count",header:({column:d})=>e.jsx(S,{column:d,alignRight:!0,children:"Automations"}),cell:({getValue:d})=>e.jsx("span",{className:"tabular-nums",children:d()??0}),meta:{align:"right"}}),i},[t,s]),X=x.useMemo(()=>[{accessorKey:"name",header:({column:i})=>U?e.jsx(S,{column:i,children:"Name"}):"Name",cell:({row:i})=>{const r=_(i.original.metadata);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{metadata:r,metadataSchema:n,name:i.original.name,typeIcon:l,className:"h-6 w-6 shrink-0"}),e.jsx("div",{className:"min-w-0",children:(()=>{const u=Be(s,i.original);return e.jsx(P,{to:u,className:"block max-w-56 truncate font-medium hover:underline",title:i.original.name,children:i.original.name})})()})]})}},...G,...C,...I,...D,...Q,...o?[]:[{accessorKey:"created_at",header:({column:i})=>e.jsx(S,{column:i,children:"Created"}),cell:({getValue:i})=>e.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date(i()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[s,G,C,I,D,Q,n,l,o,U]),B=ye({data:t,columns:X,state:{sorting:j,columnVisibility:Object.fromEntries([...C,...I].flatMap(i=>i.id?[[i.id,!v||v.includes(o?i.id:i.id.replace(/^meta_/,""))]]:[]))},onSortingChange:y,getCoreRowModel:Ne(),manualSorting:!0,enableSortingRemoval:!1}),de=t.length>0||k>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border",children:e.jsxs(ke,{className:"min-w-[48rem]",children:[e.jsx(Ce,{children:B.getHeaderGroups().map(i=>e.jsxs($,{children:[i.headers.map(r=>e.jsx(Y,{"aria-sort":r.column.getIsSorted()==="asc"?"ascending":r.column.getIsSorted()==="desc"?"descending":void 0,className:r.column.columnDef.meta?.align==="right"?"text-right":"",children:r.isPlaceholder?null:q(r.column.columnDef.header,r.getContext())},r.id)),M?e.jsx(Y,{className:"w-10 pr-2 text-right",children:M}):null]},i.id))}),e.jsx(Ee,{children:B.getRowModel().rows.length?B.getRowModel().rows.map(i=>e.jsxs($,{children:[i.getVisibleCells().map(r=>e.jsx(H,{className:r.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:q(r.column.columnDef.cell,r.getContext())},r.id)),M?e.jsx(H,{}):null]},i.id)):e.jsx($,{children:e.jsx(H,{colSpan:X.length+(M?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),de&&e.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:[e.jsxs("div",{children:["Showing ",t.length," of ",L," ",z.toLowerCase()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{children:["Page ",k+1," of ",Math.max(1,Math.ceil(L/R))]}),e.jsx(F,{variant:"outline",size:"sm",onClick:ie,disabled:k===0,children:"Previous"}),e.jsx(F,{variant:"outline",size:"sm",onClick:ce,disabled:!O,children:"Next"})]})]})]})}const We=720;function De(){return e.jsxs("div",{className:"space-y-4","aria-label":"Loading entities",role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(E,{className:"h-9 max-w-sm flex-1"}),e.jsx(E,{className:"h-9 w-28"})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsx("div",{className:"border-b px-4 py-3",children:e.jsx(E,{className:"h-3 w-1/3"})}),e.jsx("div",{className:"divide-y",children:Array.from({length:5},(t,s)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx(E,{className:"h-3 flex-1"}),e.jsx(E,{className:"h-3 w-16 shrink-0"})]},s))})]})]})}function tt({title:t,actions:s,controls:n,table:l,children:o,loading:a=!1,error:c=null,onRetry:h,empty:j=e.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"No records."})}){return e.jsxs("div",{className:"@container space-y-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[typeof t=="string"?e.jsx("h2",{className:"text-lg font-semibold",children:t}):t,s]}),e.jsxs("div",{children:[n,a?e.jsx(De,{}):c!==null?e.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[c,h?e.jsx(F,{className:"ml-3",variant:"outline",size:"sm",onClick:h,children:"Retry"}):null]}):o!==void 0?o:l?e.jsx(Ve,{...l}):j]})]})}function Ge(t,s){return s?.properties?ne(s.properties).map(([n,l])=>({key:n,prop:l})):Object.keys(t.metadata??{}).map(n=>({key:n,prop:{}}))}function Qe({entity:t,schema:s,icon:n}){return e.jsxs(e.Fragment,{children:[e.jsx(le,{metadata:t.metadata,metadataSchema:s?{...s}:void 0,name:t.name,typeIcon:n,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:t.name})]})}function Xe({entity:t,schema:s,context:n}){const l=Se(s?{...s}:void 0).filter(({key:o,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&t.metadata?.[o]!==void 0&&t.metadata[o]!==null&&t.metadata[o]!=="");return l.length?e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:l.map(({key:o,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(_e,{field:{key:o,prop:a},value:t.metadata?.[o],context:n})]},o))}):null}function Ze({details:t,summary:s,children:n,rootRef:l,narrow:o}){return e.jsx("div",{ref:l,className:"min-w-0 space-y-4",children:o?e.jsxs(e.Fragment,{children:[s,e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:t}),n]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:t}),n]})})}function st({entity:t,owner:s,schema:n,title:l,actions:o,details:a,summary:c,children:h,layout:j="record"}){const y=x.useRef(null),v=ve(y,We),N=e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:l===void 0?e.jsx(Qe,{entity:t,schema:n}):l}),o]}),j==="content"?h:e.jsx(Ze,{rootRef:y,narrow:v,details:a===void 0?e.jsx(we,{fields:Ge(t,n),values:t.metadata??{},context:{ownerSlug:s}}):a,summary:c===void 0?e.jsx(Xe,{entity:t,schema:n,context:{ownerSlug:s}}):c,children:h})]});return j==="content"?N:e.jsx("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:N})}export{le as E,We as N,Pe as S,Ve as a,tt as b,De as c,st as d,se as e,Ze as f,Xe as g,Qe as h};
2
- //# sourceMappingURL=entity-pages-_nuesgnp.js.map
@@ -1,2 +0,0 @@
1
- import{M as $,cz as de,ds as ue,cC as K,j as e,bQ as me,r as h,cA as xe,cB as he,aE as pe,aF as ge,B as g,dg as I,aH as je,Z as S,bq as q,br as P,bs as M,bt as L,bu as k,$ as E,al as fe,h4 as ve,h5 as Ne,a7 as Y,cX as ye,X as W,dh as be,C as we,ab as Se,c9 as ae,fA as ne,h6 as Ce,a8 as re,h7 as ke,gx as Ee,c3 as _e,c4 as G,c8 as Re,fj as Te,bR as Oe,h8 as De,i as Q,dD as Ae,dE as Fe,dF as ze,L as le,d5 as qe,dG as Pe,A as Me}from"./index-BoqrvLHQ.js";import{f as B}from"./event-kind-options-fHAIXu24.js";import{C as ie}from"./code-editor-z1Sy_hiX.js";function Le({entityType:s}){const{orgContext:a}=$(),{data:o,isLoading:n}=de(a),{data:r}=ue(a),t=(o||[]).filter(u=>u.status==="active"),i=t.filter(u=>!u.organization_slug||u.organization_slug===a?.slug),c=i.filter(u=>u.purpose!==K),d=i.filter(u=>u.purpose===K),x=t.filter(u=>u.organization_slug&&u.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(me,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:c,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),x.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:x,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ue,{entityTypeSlug:s.slug,relationshipTypes:c,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:o,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Ve,{relationshipType:r,entityTypeSlug:s,allEntityTypes:o,readOnly:n},r.id))})}function Ve({relationshipType:s,entityTypeSlug:a,allEntityTypes:o,readOnly:n=!1}){const{orgContext:r}=$(),{data:t}=ve(s.slug,r),i=Ne(),c=(t||[]).filter(x=>x.source_entity_type_slug===a||x.target_entity_type_slug===a);if(c.length===0)return null;const d=new Map(o.map(x=>[x.slug,x.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx(Y,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx(Y,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),c.map(x=>e.jsx(Ie,{rule:x,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(x.id),isRemoving:i.isPending,readOnly:n},x.id))]})}function Ie({rule:s,entityTypeSlug:a,entityTypeNameMap:o,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,c]=h.useState(!1),d=s.source_entity_type_slug===a,x=d?s.target_entity_type_slug:s.source_entity_type_slug,u=o.get(x)||x;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":u}),e.jsx(ye,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?u:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(g,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(g,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>c(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(g,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>c(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Ue({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:o}){const{orgContext:n}=$(),r=o.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=h.useState(!1),[c,d]=h.useState("existing"),[x,u]=h.useState(""),[N,b]=h.useState(""),[w,y]=h.useState("source"),[v,j]=h.useState(""),[R,T]=h.useState(""),[D,O]=h.useState(!1),[A,C]=h.useState(null),m=xe(),p=he(),f=()=>{d("existing"),u(""),b(""),y("source"),j(""),T(""),O(!1),C(null)},_=l=>{i(l),l||f()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{C(null);try{let l=x;if(c==="new"){if(!v.trim()){C("Name is required");return}const H=R.trim()||F(v);if(!H){C("Slug is required");return}l=(await m.mutateAsync({slug:H,name:v.trim(),is_symmetric:D})).relationship_type.slug}if(!l){C("Select a relationship type");return}if(!N){C("Select a target entity type");return}const V=w==="source"?s:N,oe=w==="source"?N:s;await p.mutateAsync({slug:l,source_entity_type_slug:V,target_entity_type_slug:oe}),_(!1)}catch(l){C(l instanceof Error?l.message:"An error occurred")}},z=m.isPending||p.isPending;return e.jsxs(pe,{open:t,onOpenChange:_,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(g,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(I,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(g,{variant:c==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(g,{variant:c==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),c==="existing"?e.jsxs(q,{value:x,onValueChange:u,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(k,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:v,onChange:l=>{j(l.target.value),R||T("")}}),e.jsx(E,{placeholder:v?F(v)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:R,onChange:l=>T(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>O(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:w,onValueChange:l=>y(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"source",children:"This type → other"}),e.jsx(k,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{className:"text-xs",children:[w==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:N,onValueChange:b,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(k,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(g,{size:"sm",className:"w-full",onClick:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Be({options:s,onChange:a}){const[o,n]=h.useState(""),r=()=>{const i=o.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((c,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,c)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(c),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(E,{value:o,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(g,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(I,{className:"h-3 w-3"})})]})]})}const Je=[{value:"string",label:"Text"},{value:"number",label:"Number"},{value:"integer",label:"Whole number"},{value:"boolean",label:"Yes/No"},{value:"enum",label:"Choice"}];function $e({examples:s,onChange:a}){const[o,n]=h.useState(""),r=()=>{const t=o.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((c,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(E,{value:o,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(g,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(I,{className:"h-3 w-3"})})]})]})}function We({field:s,onChange:a,onDelete:o}){const[n,r]=h.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})}),e.jsx(E,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Je.map(t=>e.jsx(k,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(Se,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:o,children:e.jsx(ae,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Be,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(E,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(E,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"none",children:"None"}),e.jsx(k,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(k,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx($e,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({value:s,onChange:a,readonly:o,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ie,{value:s,onChange:a,readonly:o,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Z(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const o of Object.values(a)){if(!o||typeof o!="object")return!1;const n=o,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},o=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,c={id:ce(),name:n,required:o.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...c,type:"enum",enumOptions:r.enum||[]}:{...c,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const o=Number(s);return Number.isNaN(o)?s:o}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function He(s,a="auto"){const o={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(c=>se(c,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(c=>({value:c,label:c.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(c.toLowerCase())}))}:{}}),o[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:o};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function Ke({value:s,onChange:a,readonly:o=!1}){const[n,r]=h.useState("visual"),[t,i]=h.useState([]),[c,d]=h.useState("auto"),[x,u]=h.useState(""),[N,b]=h.useState(null),[w,y]=h.useState(!1),v=h.useRef(!1);h.useEffect(()=>{if(v.current){v.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),u(""),y(!1);return}const m=JSON.stringify(s,null,2);u(m),d(te(s)),Z(s)?(i(ee(s)),y(!1)):(y(!0),r("json"))},[s]);const j=h.useCallback((m,p)=>{v.current=!0;const f=He(m,p),_=m.some(F=>F.name.trim());u(_?JSON.stringify(f,null,2):""),a(_?f:void 0)},[a]),R=h.useCallback(m=>{i(m),j(m,c)},[j,c]),T=h.useCallback(m=>{d(m),j(t,m)},[j,t]),D=h.useCallback(m=>{if(v.current=!0,u(m),!m.trim()){b(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(m);b(null),d(te(p)),Z(p)?(i(ee(p)),y(!1)):y(!0),a(p)}catch(p){b(p instanceof Error?p.message:"Invalid JSON")}},[a]),O=()=>{R([...t,{id:ce(),name:"",type:"string",required:!1}])},A=(m,p)=>{const f=[...t];f[m]=p,R(f)},C=m=>{R(t.filter((p,f)=>f!==m))};return o?e.jsx(X,{value:x,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!w&&r("visual"),disabled:w,className:"h-7 text-xs",children:[e.jsx(ne,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(g,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Ce,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),w&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(re,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((m,p)=>e.jsx(We,{field:m,onChange:f=>A(p,f),onDelete:()=>C(p)},m.id)),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:O,className:"w-full",children:[e.jsx(I,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(m=>m.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:c,onValueChange:m=>T(m),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"auto",children:"Auto"}),e.jsx(k,{value:"table",children:"Table"}),e.jsx(k,{value:"board",children:"Board"})]})]})]})]}):e.jsx(X,{value:x,onChange:D,error:N})]})}function Ye(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ge({entityType:s,onCancel:a,onSaved:o}){const n=!!s,r=ke(),t=Ee(),i=s?.slug??"new",c=_e(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,x]=c.field("name"),[u,N]=c.field("slug"),[b,w]=c.field("description"),[y,v]=c.field("icon"),[j,R]=c.field("color"),[T,D]=c.field("metadataSchema"),[O,A]=c.field("backingSql"),[C,m]=G(i,n),[p,f]=G(i,null),_=O.trim().length>0,F=l=>{x(l),!n&&!C&&N(Ye(l))},U=async()=>{if(!c.canSubmit)return;if(f(null),!d.trim()){f("Name is required");return}if(!n&&!u.trim()){f("Slug is required");return}const l=_?{sql:O.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:b.trim()||void 0,icon:y.trim()||void 0,color:j.trim()||void 0,metadata_schema:_?void 0:T,backing:l}):await r.mutateAsync({slug:u.trim(),name:d.trim(),description:b.trim()||void 0,icon:y.trim()||void 0,color:j.trim()||void 0,metadata_schema:_?void 0:T,backing:l}),o()}catch(V){f(V instanceof Error?V.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(Re,{visible:c.hasConflict,onReload:c.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"et-name",children:"Name"}),e.jsx(E,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"et-slug",children:"Slug"}),e.jsx(E,{id:"et-slug",value:u,onChange:l=>{m(!0),N(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"et-desc",children:"Description"}),e.jsx(Te,{id:"et-desc",value:b,onChange:l=>w(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(E,{id:"et-icon",value:y,onChange:l=>v(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{id:"et-color",value:j,onChange:l=>R(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ie,{value:O,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),_?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ne,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(S,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(Ke,{value:T,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Le,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Oe,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(g,{onClick:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function as({entityType:s,onClose:a,orgContext:o,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,c]=h.useState(!1),[d,x]=h.useState(null),u=De(),N=s?.entity_count??0,b=N>0,w=async()=>{if(s){x(null);try{await u.mutateAsync(s.slug),a()}catch(j){x(j instanceof Error?j.message:"Failed to delete")}}},y=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",v=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Q("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h1",{className:Q("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:y}),t&&o.slug&&s?e.jsx(Qe,{owner:o.slug,typeSlug:s.slug}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ge,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[o.slug&&s?e.jsx(Xe,{owner:o.slug,entityType:s}):null,!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:i?e.jsxs("div",{className:"space-y-3",children:[b?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(re,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",N===1?"is":"are"," ",N," entit",N===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),d&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:d}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",onClick:()=>{c(!1),x(null)},children:"Cancel"}),e.jsx(g,{variant:"destructive",size:"sm",onClick:w,disabled:b||u.isPending,children:u.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>c(!0),children:[e.jsx(ae,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}function Qe({owner:s,typeSlug:a}){return e.jsx(Ae,{delayDuration:200,children:e.jsxs(Fe,{children:[e.jsx(ze,{asChild:!0,children:e.jsx(g,{asChild:!0,variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground",children:e.jsxs(le,{to:"/$owner/events",params:{owner:s},search:{type:a},children:[e.jsx(qe,{className:"h-4 w-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Activity"})]})})}),e.jsx(Pe,{children:"Activity"})]})})}function Xe({owner:s,entityType:a}){const o=Object.entries(a.event_kinds??{}).sort(([n],[r])=>B(n).localeCompare(B(r)));return e.jsxs("section",{"aria-label":"Event kinds",className:"border-t border-border pt-4 space-y-2",children:[e.jsxs("h2",{className:"text-sm font-medium",children:["Event kinds on ",a.name]}),o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This type declares no event kinds."}):e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:o.map(([n,r])=>e.jsx("li",{children:e.jsxs(le,{to:"/$owner/events",params:{owner:s},search:{type:a.slug,semantic_types:n},className:"flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-accent/50",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium",children:B(n)}),r?.description?e.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:r.description}):null]}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:["View in Activity",e.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]})},n))})]})}export{as as E};
2
- //# sourceMappingURL=entity-type-page-CkCSbkBx.js.map
@@ -1,2 +0,0 @@
1
- import{H as q,ad as I,h2 as J,r as B,h3 as K,eK as Q,j as s,ch as M,L as W}from"./index-BoqrvLHQ.js";import{E as X}from"./events-feed-DcKTkJVe.js";import{a as Y,V as Z,M as z}from"./missing-view-xT0B-f5z.js";import{V as ee}from"./view-param-filters-DGKxSr7r.js";const se={},te="calc(100dvh - 120px)";function oe({owner:a,organizationId:o,eventId:c,viewKey:r,params:f,onParamsChange:d,onSelectView:g,dense:h=!1,fullBleed:k=!1}){const{isAuthenticated:y,isReady:E}=q(),{data:O,isLoading:w}=I(),P=O?.some(t=>t.id===o&&t.is_member),i=a!=="me"&&o!==null&&E&&y&&!w&&P,n=J(i?{slug:a,organizationId:o}:null,c),[j,L]=B.useState(se),[T,V]=B.useState(null),m=K(n.views,r),e=i&&!n.isLoading&&!n.isError&&m.kind==="view"?m.view:null,v=e?`${Q(a,e.key)}/${e.content_hash}/${e.eventId}`:null,p=e!==null&&T===v,b=M(a,c),F=a!=="me"&&(!E||y&&(w||n.isLoading)),H=e!==null&&!p&&!F,u=k&&H,U=(k||h)&&H,N=F?s.jsx("div",{role:"status",className:"py-8 text-sm text-muted-foreground",children:"Loading event view…"}):e&&!p?s.jsxs(s.Fragment,{children:[s.jsx(ee,{decls:e.params,params:f??j,onParamsChange:t=>d?d(e.key,t,{replace:!1}):L(t)}),s.jsx(Y,{orgSlug:a,viewKey:e.key,scope:{event:e.eventId},params:f??j,onParamsChange:t=>d?d(e.key,t):L(t),paramDecls:e.params,onLoadError:()=>V(v),contentHash:e.content_hash,title:e.name,minHeight:h?240:320,fixedHeight:U?te:void 0},v)]}):void 0;return s.jsxs("div",{className:u?"w-full space-y-3":"mx-auto w-full max-w-3xl space-y-3",...u?{"data-testid":"event-view-fullbleed"}:{},children:[i&&n.isError&&s.jsx(Z,{onRetry:n.refetch}),(i||a==="me"&&r)&&!n.isLoading&&!n.isError&&m.kind==="missing"&&s.jsx(z,{viewKey:m.key,backTo:b,backLabel:"Back to the event"}),p&&s.jsxs("div",{role:"alert",className:"rounded-md border p-3 text-sm",children:[s.jsx("p",{children:"The custom view couldn’t load. The event content is shown below."}),s.jsx("button",{type:"button",className:"mt-2 underline",onClick:()=>V(null),children:"Retry custom view"})]}),s.jsx(X,{presentation:"detail",organizationId:o,ownerSlug:a,filters:{contentIds:[c],...a==="me"?{sortBy:"date",sortOrder:"desc"}:{}},hideDetails:h,renderDetail:t=>{const x=N!=null&&(t==null||!!r),A=(i?n.views:[]).filter(l=>!x||l.key!==e?.key).map(l=>({key:l.key,name:l.name,href:M(a,c,l.key)})),D=l=>l.length?s.jsx("nav",{"aria-label":"Event views",className:"flex flex-wrap gap-3 text-sm",children:l.map(({key:$,name:C,href:_})=>s.jsx(W,{to:_,className:"underline",onClick:g?G=>{G.preventDefault(),g(_)}:void 0,children:C},$))}):null,R=[...A],S=[...A];return i&&r&&t!=null&&S.unshift({key:":event",name:"Event details",href:b}),{content:x?N:t,nativeHeading:!x&&t!=null,headingAside:u?D(R):void 0,links:u?null:D(S)}}})]})}export{oe as E};
2
- //# sourceMappingURL=event-detail-DUvlqn9b.js.map